-
Notifications
You must be signed in to change notification settings - Fork 7
/
NetDrv.h
185 lines (154 loc) · 3.84 KB
/
NetDrv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef NETDRV_H
#define NETDRV_H
#ifndef SkLineData
#define SkLineData struct _ClientData
#endif
#if 0
#define SWAP4(a) htonl(a)
#define SWAP2(a) htons(a)
#else
#define SWAP4(a) (a)
#define SWAP2(a) (a)
#endif
#include <Serv.h>
#include <stdlib.h>
#include <stdio.h>
#include <linux/if_ether.h>
#include <time.h>
#define ETH_H_PACKET SK_H_USER1
typedef struct _EthPacket
{
struct sockaddr from;
struct ethhdr ethhdr;
unsigned char *data;
int len;
} EthPacket;
typedef struct _ClientData
{
int cl_id;
int modify_state;
int mode;
int active_log;
int num_wrong_frames;
/* http data */
int post_mode;
char *filename;
int boundary;
int size;
int written;
FILE *fp;
char logger;
int nlines;
SkTimerType rcv_timer;
int last_x;
} ClientData;
#define MODE_UNKNOWN 0
#define MODE_HTTP 1
#define MODE_LOG 3
/* vinter.c */
extern char **M5sStrgCut( char *in, int *rargc, char beautify );
#ifdef NOINTERFACES
#define Log if(0)printf
#else
extern void Log( int lv, char *fmt, ... );
#endif
/* rd2.c */
extern void _HReadable( SkLine *l, int pt, void *own, void *sys );
/* write.c */
extern int _WritePacket( SkLine * l, unsigned char * from, int cnt );
extern int _WriteString( SkLine * l, char * strg );
extern int _FlushLine( SkLine *l );
extern int _SyncLine( SkLine *l );
extern void _AsySyncLine( SkLine *l );
/* u.c */
extern void _clientPacket( SkLine *l, int pt, void *own, void *sys );
extern void _clientConnected( SkLine *l, int pt, void *own, void *sys );
extern void _ShowStatistic( SkLine *l, int ashtml );
extern void _ResetStatistik( void );
extern void SetMaxLog( int nr );
extern void _RestartMe( void );
/* listen.c */
extern SkLine *_lgListen( unsigned short port );
/* http.c */
extern void HttpStatAddClData( void );
extern void HttpPck( SkLine *l, int pt, void *own, void *sys );
extern int HttpNeedPicture( void );
extern void HttpPictureDone( int rc );
extern void HttpSetNoCam( void );
extern void HttpLoadCleaningRecord( SkTimerType tid, void *own );
/* vinter.c */
extern void DoLogData( SkLine *l, char *data, int len );
extern int LogActive( int lv );
/* control.c */
extern void RunControlFrame( unsigned char *in );
extern int FillControlFrame( SkLine *l, unsigned char *out );
/* ident.c */
extern void FillIdentFrame( SkLine *l, unsigned char *out );
/* param.c */
extern void FillParamFrame( SkLine *l, unsigned char *out );
/* data.c */
extern void FillDataFrame( SkLine *l, unsigned char *out );
/* proc.c */
extern int ReadProcStat( int *a_user, int *a_sys, int *a_nice, int *a_idle );
#if 0
/* v4l2.c */
extern void _v4l2_start( void );
/* jpeg.c */
extern int GenerateJpegFile( unsigned char *img, char *filename );
#endif
/* json.c */
typedef struct _JsonVars
{
char *robot_state;
char *turbo;
char *repeat;
char *batt;
char *mode;
char *nickname;
char *version;
char *battperc;
} JsonVars;
extern int jsonSend( char *command );
/* json.c */
typedef struct _TimerVars
{
char *mon;
char *tue;
char *wed;
char *thu;
char *fri;
char *sat;
char *sun;
} TimerVars;
extern void ReadTimerFromFile( void );
extern void RunTimerParam( char *param );
extern void StartTimer( void );
/* mail.c */
typedef struct _MailVars
{
struct {
char *receiver;
char *gateway;
char *user;
char *pass;
int enable;
} send;
struct {
char *gateway;
char *user;
char *pass;
char *sign;
int cycle;
int enable;
} get;
char *response;
} MailVars;
extern void ReadMailConfigFromFile( void );
extern int sendMail( char *subject, char *text );
extern void NewState( char *stext );
extern void RunMailCfgParam( char *param );
extern void SndMailAddLog( int to_response, char *fmt, ... );
/* base64.c */
extern size_t base64_decode(char *source, unsigned char *target, size_t targetlen);
extern int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen);
#endif