add a internal socket for chilli, so you can control connection from external script...
[openwrt/svn-archive/archive.git] / net / chillispot / patches / 150-chillispot-rmtctrl.patch
1 diff -Nur chillispot-1.1.0.orig/src/chilli.c chillispot-1.1.0/src/chilli.c
2 --- chillispot-1.1.0.orig/src/chilli.c 2009-08-11 15:10:56.000000000 -0300
3 +++ chillispot-1.1.0/src/chilli.c 2009-08-13 13:17:24.000000000 -0300
4 @@ -102,6 +102,7 @@
5 #include "dhcp.h"
6 #include "cmdline.h"
7 #include "chilli.h"
8 +#include "remotectrl.h"
9
10 struct options_t options;
11
12 @@ -127,6 +128,12 @@
13 /* Forward declarations */
14 int static acct_req(struct app_conn_t *conn, int status_type);
15 int static config_radius();
16 +void admin_disconnect(struct app_conn_t *appconn, int terminateCause);
17 +void admin_authorize(struct app_conn_t *appconn);
18 +int send_acct_head( struct rmt_socket_t *client, struct app_conn_t *appconn);
19 +int send_Connection( struct rmt_socket_t *client, struct app_conn_t *appconn );
20 +int send_Acct_Setting ( struct rmt_socket_t *client, struct app_conn_t *appconn );
21 +int send_Accounting( struct rmt_socket_t *client, struct app_conn_t *appconn );
22
23 /* Fireman catches falling childs and eliminates zombies */
24 void static fireman(int signum) {
25 @@ -180,19 +187,18 @@
26 struct timeval timenow;
27 uint64_t timediff; /* In microseconds */
28 int result = 0;
29 -
30
31 gettimeofday(&timenow, NULL);
32
33 timediff = (timenow.tv_sec - conn->last_time.tv_sec) * ((uint64_t) 1000000);
34 timediff += (timenow.tv_usec - conn->last_time.tv_usec);
35
36 - /* if (options.debug) printf("Leaky bucket timediff: %lld, bucketup: %d, bucketdown: %d %d %d\n",
37 - timediff, conn->bucketup, conn->bucketdown,
38 - octetsup, octetsdown);*/
39 -
40 - if (conn->bandwidthmaxup) {
41 +/* if (options.debug)
42 + printf("Leaky bucket timediff: %lld, bucketup: %d, bucketdown: %d %d %d\n",
43 + timediff, conn->bucketup, conn->bucketdown, octetsup, octetsdown);
44 +*/
45
46 + if (conn->bandwidthmaxup) {
47 /* Subtract what the leak since last time we visited */
48 if (conn->bucketup > ((timediff * conn->bandwidthmaxup)/8000000)) {
49 conn->bucketup -= (timediff * conn->bandwidthmaxup) / 8000000;
50 @@ -200,9 +206,9 @@
51 else {
52 conn->bucketup = 0;
53 }
54 -
55 +// printf("octetsup: %d -> conn->bucketup+octetsup: %d > conn->bucketupsize: %d \n", octetsup, conn->bucketup + octetsup, conn->bucketupsize);
56 if ((conn->bucketup + octetsup) > conn->bucketupsize) {
57 - /*if (options.debug) printf("Leaky bucket deleting uplink packet\n");*/
58 + if (options.debug) printf("Leaky bucket deleting uplink packet\n");
59 result = -1;
60 }
61 else {
62 @@ -217,9 +223,10 @@
63 else {
64 conn->bucketdown = 0;
65 }
66 +// printf("octetsdown: %d -> conn->bucketdown+octetsdown: %d > conn->bucketdownsize: %d \n", octetsdown, conn->bucketdown + octetsdown, conn->bucketdownsize);
67
68 if ((conn->bucketdown + octetsdown) > conn->bucketdownsize) {
69 - /*if (options.debug) printf("Leaky bucket deleting downlink packet\n");*/
70 + if (options.debug) printf("Leaky bucket deleting downlink packet\n");
71 result = -1;
72 }
73 else {
74 @@ -233,6 +240,7 @@
75 }
76 #endif /* ifndef NO_LEAKY_BUCKET */
77
78 +
79 /* Run external script */
80
81 int set_env(char *name, char *value, int len, struct in_addr *addr,
82 @@ -550,7 +558,7 @@
83 return -1;
84 }
85
86 - if (cmdline_parser_configfile (args_info.conf_arg, &args_info, 0, 0, 0)) {
87 + if (cmdline_parser_configfile (args_info.conf_arg, &args_info, 0, 0, 0)) {
88 sys_err(LOG_ERR, __FILE__, __LINE__, 0,
89 "Failed to parse configuration file: %s!",
90 args_info.conf_arg);
91 @@ -1056,7 +1064,21 @@
92 strlen(args_info.macallowed_arg[numargs])))
93 return -1;
94 }
95 -
96 + /* remote monitor */
97 + /* Defaults to net plus 1 */
98 + if (!args_info.rmtlisten_arg)
99 + options.rmtlisten.s_addr = options.uamlisten.s_addr;
100 + else
101 + if (!inet_aton(args_info.rmtlisten_arg, &options.rmtlisten)){
102 + sys_err(LOG_ERR, __FILE__, __LINE__, 0,
103 + "Invalid Remote monitor IP address: %s!", args_info.rmtlisten_arg);
104 + return -1;
105 + }
106 + /* rmtport */
107 + options.rmtport = args_info.rmtport_arg;
108 + options.rmtpasswd = args_info.rmtpasswd_arg;
109 + options.bandwidthmaxup = args_info.bandwidthmaxup_arg;
110 + options.bandwidthmaxdown = args_info.bandwidthmaxdown_arg;
111
112 /* foreground */
113 /* If flag not given run as a daemon */
114 @@ -1095,7 +1117,6 @@
115 memcpy(&options, &options2, sizeof(options));
116 return;
117 }
118 -
119 /* Options which we do not allow to be affected */
120 /* fg, conf and statedir are not stored in options */
121 options.net = options2.net; /* net */
122 @@ -1123,6 +1144,13 @@
123 options.eapolenable = options2.eapolenable; /* eapolenable */
124 options.pidfile = options2.pidfile; /* pidfile */
125
126 + options.rmtlisten = options2.rmtlisten; /* remote listen */
127 + options.rmtport = options2.rmtport; /* remote port */
128 + options.rmtpasswd = options2.rmtpasswd; /* remote password */
129 +
130 +// options.bandwidthmaxup = options2.bandwidthmaxup; /* remote password */
131 +// options.bandwidthmaxdown = options2.bandwidthmaxdown; /* remote password */
132 +
133 /* Reinit DHCP parameters */
134 (void) dhcp_set(dhcp, (options.debug & DEBUG_DHCP),
135 options.uamserver, options.uamserverlen, options.uamanydns,
136 @@ -3099,9 +3127,8 @@
137 appconn->bucketupsize = BUCKET_SIZE_MIN;
138 #endif
139 }
140 - else {
141 + else
142 appconn->bandwidthmaxup = 0;
143 - }
144
145 /* Bandwidth down */
146 if (!radius_getattr(pack, &attr, RADIUS_ATTR_VENDOR_SPECIFIC,
147 @@ -3116,9 +3143,8 @@
148 appconn->bucketdownsize = BUCKET_SIZE_MIN;
149 #endif
150 }
151 - else {
152 + else
153 appconn->bandwidthmaxdown = 0;
154 - }
155
156 #ifdef RADIUS_ATTR_CHILLISPOT_BANDWIDTH_MAX_UP
157 /* Bandwidth up */
158 @@ -3623,7 +3649,7 @@
159 appconn->input_octets +=len;
160 #ifndef NO_LEAKY_BUCKET
161 #ifdef COUNT_UPLINK_DROP
162 - if (leaky_bucket(appconn, len, 0)) return 0;
163 + if (leaky_bucket(appconn, len, 0)==-1) return 0;
164 #endif /* ifdef COUNT_UPLINK_DROP */
165 #endif /* ifndef NO_LEAKY_BUCKET */
166 }
167 @@ -3889,6 +3915,10 @@
168 struct sigaction act;
169 struct itimerval itval;
170
171 + struct rmt_socket_t srv;
172 + struct rmt_socket_t client[MAX_CLIENTS];
173 + int activeClients = 0; /* NĂºmero clientes conectados */
174 +
175 /* open a connection to the syslog daemon */
176 /*openlog(PACKAGE, LOG_PID, LOG_DAEMON);*/
177 openlog(PACKAGE, (LOG_PID | LOG_PERROR), LOG_DAEMON);
178 @@ -4046,6 +4076,8 @@
179 if (options.debug)
180 printf("Waiting for client request...\n");
181
182 +
183 + srv = rmtctrl_initSrv(options.rmtlisten, options.rmtport);
184
185 /******************************************************************/
186 /* Main select loop */
187 @@ -4053,6 +4085,8 @@
188
189 while (keep_going) {
190
191 + rmtctrl_srv(srv,client,&activeClients);
192 +
193 if (do_timeouts) {
194 /*if (options.debug) printf("Do timeouts!\n");*/
195 (void) radius_timeout(radius);
196 @@ -4178,3 +4212,487 @@
197 return 0;
198
199 }
200 +
201 +void rmtctrl_msg_proccess(struct rmt_socket_t *client)
202 +{
203 + msg_head_t header;
204 + char *msg=NULL;
205 + char *reg=NULL;
206 + struct app_conn_t *appconn;
207 + struct dhcp_conn_t *dhcpconn;
208 + char str[2048];
209 + int found=0;
210 + int rslt=0;
211 + int n;
212 + uint64_t l;
213 + rslt = rmtctrl_read_msg(client,&header,&msg);
214 + if (rslt > 0)
215 + {
216 + switch (header.id)
217 + {
218 + case QRY_CONNECTED_LIST:
219 + rslt += send_srvData(client);
220 + rslt += rmtctrl_write_msg(client,MSG_START,0, "\n" );
221 + rslt += rmtctrl_write_msg(client,MSG_PART,0, "Ord ---------- User Name ----------- -- MAC Address -- -- IP Address - -- Input - - Output - Sta\n" );
222 + for (n=0; n<APP_NUM_CONN; n++) {
223 + appconn = &connection[n];
224 + if ((appconn->inuse != 0)){
225 + dhcpconn = (struct dhcp_conn_t*) appconn->dnlink;
226 + found++;
227 + l = found;
228 + rslt += send_number(client, MSG_PART, 0, "%3s ", l);
229 + rslt += send_line(client,MSG_PART,0, "%-32s ",appconn->proxyuser);
230 + rslt += send_mac(client,MSG_PART,0, "%17s ",appconn->hismac);
231 + rslt += send_line(client,MSG_PART,0, "%15s ",inet_ntoa(appconn->hisip));
232 + rslt += send_number(client,MSG_PART,0, "%10s ",appconn->input_octets);
233 + rslt += send_number(client,MSG_PART,0, "%10s ",appconn->output_octets);
234 + rslt += send_number(client, MSG_PART, 0, " %s ",appconn->authenticated);
235 + rslt += send_number(client, MSG_PART, 0, " %s \n",dhcpconn->authstate);
236 + }
237 + }
238 + rslt += send_number(client,MSG_END,found, "Total of connected device(s) %s\n",found);
239 + break;
240 + case QRY_CONNECTED_FULL_LIST:
241 + rslt += send_srvData(client);
242 + rslt += rmtctrl_write_msg(client,MSG_START,0, "\n" );
243 + for (n=0; n<APP_NUM_CONN; n++) {
244 + appconn = &connection[n];
245 + if ((appconn->inuse != 0)){
246 + found++;
247 + l = found;
248 + rslt += send_number(client, MSG_PART, 0, "Connection : %s\n{\n", l);
249 + rslt += send_acct_head( client, appconn);
250 + rslt += send_line(client, MSG_PART, 0, "%s\n", "}");
251 + }
252 + }
253 + rslt += send_number(client, MSG_END, found, "Total of connected device(s) %s\n",found);
254 + break;
255 + case QRY_STATUS:
256 + ///
257 + rslt += send_Status(client, appconn);
258 + break;
259 + case CMD_AUTHORIZE:
260 + for (n=0; n<APP_NUM_CONN; n++)
261 + {
262 + l = 0;
263 + appconn = &connection[n];
264 + if ((appconn->inuse != 0) && (appconn->authenticated == 0))
265 + {
266 + switch (header.extra)
267 + {
268 + case EXTRA_MAC_OP:
269 + if ( strcmp(msg,mac2str(appconn->hismac)) == 0)
270 + {
271 + found++;
272 + l=1;
273 + break;
274 + }
275 + break;
276 + case EXTRA_IP_OP:
277 + if ( strcmp(msg,inet_ntoa(appconn->hisip)) == 0)
278 + {
279 + found++;
280 + l=1;
281 + break;
282 + }
283 + break;
284 + case EXTRA_USER_OP:
285 + if ( strcmp(msg,appconn->proxyuser) == 0)
286 + {
287 + found++;
288 + l=1;
289 + break;
290 + }
291 + break;
292 + default:
293 + found++;
294 + l=1;
295 + break;
296 + }
297 + if ( l == 1 ){
298 + admin_authorize(appconn);
299 + rslt += send_srvData( client );
300 + rslt += rmtctrl_write_msg(client,MSG_PART,0, " \n" );
301 + rslt += send_acct_head( client, appconn);
302 + sys_err(LOG_NOTICE, __FILE__, __LINE__, 0,
303 + "Admin Authorize MAC=%s IP=%s",
304 + mac2str(appconn->hismac), inet_ntoa(appconn->hisip));
305 + }
306 + }
307 + }
308 + if (found == 0)
309 + rslt += rmtctrl_write_msg(client,MSG_END,0, "Not device found to Authorze\n" );
310 + else
311 + {
312 + rslt += send_number(client, MSG_END, found, "Autorized %s device(s)\n",found);
313 + }
314 + break;
315 + case CMD_DISCONNECT:
316 + for (n=0; n<APP_NUM_CONN; n++)
317 + {
318 + l = 0;
319 + appconn = &connection[n];
320 + if ((appconn->inuse != 0) && (appconn->authenticated == 1))
321 + {
322 + if (dhcpconn = (struct dhcp_conn_t*) appconn->dnlink) {
323 + switch (header.extra)
324 + {
325 + case EXTRA_MAC_OP:
326 + if ( strcmp(msg,mac2str(appconn->hismac)) == 0)
327 + {
328 + found++;
329 + l=1;
330 + break;
331 + }
332 + break;
333 + case EXTRA_IP_OP:
334 + if ( strcmp(msg,inet_ntoa(appconn->hisip)) == 0)
335 + {
336 + found++;
337 + l=1;
338 + break;
339 + }
340 + break;
341 + case EXTRA_USER_OP:
342 + if ( strcmp(msg,appconn->proxyuser) == 0)
343 + {
344 + found++;
345 + l=1;
346 + break;
347 + }
348 + break;
349 + default:
350 + found++;
351 + l=1;
352 + break;
353 + }
354 + if ( l == 1 ) {
355 + rslt += send_srvData( client );
356 + rslt += rmtctrl_write_msg(client,MSG_PART,0, " \n" );
357 + rslt += send_acct_head( client, appconn);
358 + admin_disconnect(appconn, RADIUS_TERMINATE_CAUSE_ADMIN_RESET);
359 + sys_err(LOG_NOTICE, __FILE__, __LINE__, 0,
360 + "Admin Disconnect username=%s IP=%s",
361 + appconn->user, inet_ntoa(appconn->hisip));
362 + }
363 + }
364 + }
365 + }
366 + if (found == 0)
367 + rslt += rmtctrl_write_msg(client,MSG_END,0, "Not decice found to Disconnect\n" );
368 + else
369 + {
370 + rslt += send_number(client, MSG_END, found, "Disconnect %s device(s)\n",found);
371 + }
372 + break;
373 + default:
374 + rslt += rmtctrl_write_msg(client,MSG_END,0, "Unknow command.\n" );
375 + break;
376 + }
377 + }
378 + else
379 + {
380 + printf("Desde %s se recibieron %d bytes y se enviaron %d bytes\n",inet_ntoa(client->addr.sin_addr),client->Rx,client->Tx);
381 + close(client->fd); /* cierra fd_rmt_client */
382 + printf("Client cerro conexiĂ³n desde %s\n",inet_ntoa(client->addr.sin_addr) );
383 + client->fd = -1;
384 + }
385 + if(msg)
386 + free(msg);
387 +}
388 +
389 +void admin_authorize(struct app_conn_t *appconn)
390 +{
391 + struct radius_packet_t radius_pack;
392 + strcpy(appconn->user,"Admin-Authorize");
393 + strcpy(appconn->proxyuser,"Admin-Authorize");
394 + appconn->proxyuserlen = strlen(appconn->proxyuser);
395 + appconn->interim_interval = 600;
396 + appconn->terminate_cause = 0;
397 + appconn->idletimeout = 300;
398 +
399 + radius_default_pack(radius, &radius_pack, RADIUS_CODE_ACCESS_REQUEST);
400 + radius_pack.code = RADIUS_CODE_ACCESS_REQUEST;
401 +// (void) radius_addattr(radius, &radius_pack, RADIUS_ATTR_USER_NAME, 0, 0, 0,
402 +// (uint8_t*) appconn->proxyuser, appconn->proxyuserlen);
403 +
404 + if ( options.bandwidthmaxup > 0 ){
405 + appconn->bandwidthmaxup = options.bandwidthmaxup * 1024;
406 + appconn->bucketupsize = BUCKET_TIME * appconn->bandwidthmaxup / 8000;
407 + if (appconn->bucketupsize < BUCKET_SIZE_MIN)
408 + appconn->bucketupsize = BUCKET_SIZE_MIN;
409 + }
410 + if ( options.bandwidthmaxdown > 0 ){
411 + appconn->bandwidthmaxdown = options.bandwidthmaxdown * 1024;
412 + appconn->bucketdownsize = BUCKET_TIME * appconn->bandwidthmaxdown / 8000;
413 + if (appconn->bucketdownsize < BUCKET_SIZE_MIN)
414 + appconn->bucketdownsize = BUCKET_SIZE_MIN;
415 + }
416 + dnprot_accept(appconn);
417 +}
418 +
419 +void admin_disconnect(struct app_conn_t *appconn, int terminateCause)
420 +{
421 + dnprot_terminate(appconn);
422 + (void) acct_req(appconn, RADIUS_STATUS_TYPE_STOP);
423 + set_sessionid(appconn);
424 +}
425 +
426 +int send_acct_head( struct rmt_socket_t *client, struct app_conn_t *appconn)
427 +{
428 + int rslt;
429 + rslt += send_Connection( client, appconn );
430 + rslt += send_Acct_Setting( client, appconn );
431 + rslt += send_Accounting( client, appconn );
432 + return rslt;
433 +}
434 +
435 +int send_Connection( struct rmt_socket_t *client, struct app_conn_t *appconn )
436 +{
437 + int rslt;
438 + uint64_t l;
439 + rslt += send_line(client, MSG_PART, 0, "\tSession-Id = %s\n",appconn->sessionid);
440 + rslt += send_line(client, MSG_PART, 0, "\tUser-Name = %s\n",appconn->user);
441 +// rslt = send_line(client, MSG_PART, 0, "\tnasip=%s\n",appconn->nasip);
442 + rslt += send_mac(client, MSG_PART, 0, "\tClient-Mac-Address = %s\n",appconn->hismac);
443 + rslt += send_mac(client, MSG_PART, 0, "\tNas-Mac-Address = %s\n",appconn->ourmac);
444 +// rslt += send_line(client, MSG_PART, 0, "\tourip=%s\n",inet_ntoa(appconn->ourip));
445 + rslt += send_line(client, MSG_PART, 0, "\tClient-Ip = %s\n",inet_ntoa(appconn->hisip));
446 + rslt += send_line(client, MSG_PART, 0, "\tClient-Require-Ip = %s\n",inet_ntoa(appconn->reqip));
447 + rslt += send_number(client, MSG_PART, 0, "\tAutheticated = %s\n",appconn->authenticated);
448 + l = appconn->uamtime;
449 + if (l > 0)
450 + rslt += send_number(client, MSG_PART, 0, "\tUAM-Time = %s\n",l);
451 + if (strlen(appconn->userurl)>0)
452 + rslt = send_line(client, MSG_PART, 0, "\tUser-URL = %s\n",appconn->userurl);
453 + return rslt;
454 +}
455 +
456 +int send_Acct_Setting ( struct rmt_socket_t *client, struct app_conn_t *appconn )
457 +{
458 + int rslt = 0;
459 + uint64_t l;
460 + if (appconn->authenticated == 0 ) return 0;
461 + /* Account Settings */
462 + l = appconn->sessionterminatetime;
463 + if (l > 0)
464 + rslt += send_number(client, MSG_PART, 0, "\tSession-Terminate-Time = %s\n",l);
465 + l = appconn->sessiontimeout;
466 + if (l > 0)
467 + rslt += send_number(client, MSG_PART, 0, "\tSession-Timeout = %s\n",l);
468 + l = appconn->idletimeout;
469 + if (l > 0)
470 + rslt += send_number(client, MSG_PART, 0, "\tIdle-Timeout = %s\n",l);
471 + l = appconn->bandwidthmaxup;
472 + if (l > 0)
473 + rslt += send_number(client, MSG_PART, 0, "\tBandwidth-Max-Up = %s\n",l);
474 + l = appconn->bandwidthmaxdown;
475 + if (l > 0)
476 + rslt += send_number(client, MSG_PART, 0, "\tBandwidth-Max-Down = %s\n",l);
477 + l = appconn->maxinputoctets;
478 + if (l > 0)
479 + rslt += send_number(client, MSG_PART, 0, "\tMax-Input-Octets = %s\n",l);
480 + l = appconn->maxoutputoctets;
481 + if (l > 0)
482 + rslt += send_number(client, MSG_PART, 0, "\tMax-Output-Octets = %s\n",l);
483 + l = appconn->maxtotaloctets;
484 + if (l > 0)
485 + rslt += send_number(client, MSG_PART, 0, "\tMax-Total-Octets = %s\n",l);
486 + return rslt;
487 +}
488 +
489 +int send_Accounting( struct rmt_socket_t *client, struct app_conn_t *appconn )
490 +{
491 + if (appconn->authenticated == 0 ) return 0;
492 + int rslt = 0;
493 + uint64_t l;
494 + l = appconn->start_time.tv_sec;
495 + if (l > 0)
496 + rslt += send_number(client, MSG_PART, 0, "\tStart-Time = %s\n",l);
497 + l = appconn->interim_time.tv_sec;
498 + if (l > 0)
499 + rslt += send_number(client, MSG_PART, 0, "\tInterim-Time = %s\n",l);
500 + l = appconn->interim_interval;
501 + if (l > 0)
502 + rslt += send_number(client, MSG_PART, 0, "\tInterim-Interval = %s\n",l);
503 + l = appconn->last_time.tv_sec;
504 + if (l > 0)
505 + rslt += send_number(client, MSG_PART, 0, "\tLast-Time = %s\n",l);
506 + l = appconn->input_packets;
507 + if (l > 0)
508 + rslt += send_number(client, MSG_PART, 0, "\tInput-Packets = %s\n",l);
509 + l = appconn->output_packets;
510 + if (l > 0)
511 + rslt += send_number(client, MSG_PART, 0, "\tOutput-Packets = %s\n",l);
512 + l = appconn->input_octets;
513 + if (l > 0)
514 + rslt += send_number(client, MSG_PART, 0, "\tInput-Octets = %s\n",l);
515 + l = appconn->output_octets;
516 + if (l > 0)
517 + rslt += send_number(client, MSG_PART, 0, "\tOutput-Octets = %s\n",l);
518 + l = appconn->terminate_cause;
519 + if (l > 0)
520 + rslt += send_number(client, MSG_PART, 0, "\tTerminate-Cause = %s\n",l);
521 + l = appconn->bucketup;
522 + if (l > 0)
523 + rslt += send_number(client, MSG_PART, 0, "\tBucket-Up = %s\n",l);
524 + l = appconn->bucketdown;
525 + if (l > 0)
526 + rslt += send_number(client, MSG_PART, 0, "\tBucket-Down = %s\n",l);
527 + l = appconn->bucketupsize;
528 + if (l > 0)
529 + rslt += send_number(client, MSG_PART, 0, "\tBucket-Up-Size = %s\n",l);
530 + l = appconn->bucketdownsize;
531 + if (l > 0)
532 + rslt += send_number(client, MSG_PART, 0, "\tBucket-Down-Size = %s\n",l);
533 + return rslt;
534 +}
535 +
536 +int send_srvData( struct rmt_socket_t *client)
537 +{
538 + int rslt=0;
539 + rslt += send_line(client, MSG_PART, 0, "%s\n",options.radiusnasid);
540 + if (options.radiuslocationid)
541 + rslt += send_line(client, MSG_PART, 0, "\tLOCATION ID:%s\n",options.radiuslocationid);
542 + if (options.radiuslocationname)
543 + rslt += send_line(client, MSG_PART, 0, "\tLOCATION NAME:%s\n",options.radiuslocationname);
544 +// rslt += send_line(client, MSG_PART, 0, "\tDEVICE: %s ",tun->devname);
545 +// rslt += send_line(client, MSG_PART, 0, "INTERFACE: %s\n",options.dhcpif);
546 +// rslt += send_line(client, MSG_PART, 0, "\tIP ADDR: %s ",inet_ntoa(options.dhcplisten));
547 +// rslt += send_line(client, MSG_PART, 0, "NETWORK: %s ",inet_ntoa(options.net));
548 +// rslt += send_line(client, MSG_PART, 0, "MASK: %s\n",inet_ntoa(options.mask));
549 + if (options.dns1.s_addr)
550 + rslt += send_line(client, MSG_PART, 0, "\tDNS SERVERS: %s - ",inet_ntoa(options.dns1));
551 + if (options.dns2.s_addr)
552 + rslt += send_line(client, MSG_PART, 0, "%s\n",inet_ntoa(options.dns2));
553 + rslt += send_line(client, MSG_PART, 0, "\tRADIUS SERVERS: %s - ",inet_ntoa(options.radiusserver1));
554 + rslt += send_line(client, MSG_PART, 0, "%s\n",inet_ntoa(options.radiusserver2));
555 + return rslt;
556 +}
557 +
558 +int send_Status( struct rmt_socket_t *client, struct app_conn_t *appconn )
559 +{
560 + int rslt = 0;
561 + int n;
562 + uint64_t l;
563 + l = options.debug;
564 + rslt += send_number(client, MSG_PART, 0, "\tdebug=%s\n",l);
565 + /* conf */
566 + l = options.interval;
567 + rslt += send_number(client, MSG_PART, 0, "\tinterval=%s\n",l);
568 + rslt += send_line(client, MSG_PART, 0, "\tpidfile=%s\n",options.pidfile);
569 + /* TUN parameters */
570 + rslt += send_line(client, MSG_PART, 0, "\tnet=%s\n",inet_ntoa(options.net)); /* Network IP address */
571 + rslt += send_line(client, MSG_PART, 0, "\tmask=%s\n",inet_ntoa(options.mask)); /* Network mask */
572 + rslt += send_line(client, MSG_PART, 0, "\tnetc=%s\n",options.netc);
573 + rslt += send_line(client, MSG_PART, 0, "\tmaskc=%s\n",options.maskc);
574 + l = options.allowdyn;
575 + rslt += send_number(client, MSG_PART, 0, "\tallowdyn=%s\n",l); /* Allow dynamic address allocation */
576 + rslt += send_line(client, MSG_PART, 0, "\tdynip=%s\n",options.dynip); /* Dynamic IP address pool */
577 +
578 + l = options.allowstat;
579 + rslt += send_number(client, MSG_PART, 0, "\tallowstat=%s\n",l); /* Allow static address allocation */
580 + rslt += send_line(client, MSG_PART, 0, "\tstatip=%s\n",options.statip); /* Static IP address pool */
581 +
582 + rslt += send_line(client, MSG_PART, 0, "\tdns1=%s\n",inet_ntoa(options.dns1)); /* Primary DNS server IP address */
583 + rslt += send_line(client, MSG_PART, 0, "\tdns2=%s\n",inet_ntoa(options.dns2)); /* Secondary DNS server IP address */
584 + rslt += send_line(client, MSG_PART, 0, "\tdomain=%s\n",options.domain); /* Domain to use for DNS lookups */
585 + rslt += send_line(client, MSG_PART, 0, "\tipup=%s\n",options.ipup); /* Script to run after link-up */
586 + rslt += send_line(client, MSG_PART, 0, "\tipdown=%s\n",options.ipdown); /* Script to run after link-down */
587 + rslt += send_line(client, MSG_PART, 0, "\tconup=%s\n",options.conup); /* Script to run after user logon */
588 + rslt += send_line(client, MSG_PART, 0, "\tcondown=%s\n",options.condown); /* Script to run after user logoff */
589 + /* Radius parameters */
590 + rslt += send_line(client, MSG_PART, 0, "\tradiuslisten=%s\n",inet_ntoa(options.radiuslisten)); /* IP address to listen to */
591 + rslt += send_line(client, MSG_PART, 0, "\tradiusserver1=%s\n",inet_ntoa(options.radiusserver1)); /* IP address of radius server 1 */
592 + rslt += send_line(client, MSG_PART, 0, "\tradiusserver2=%s\n",inet_ntoa(options.radiusserver2)); /* IP address of radius server 2 */
593 + l = options.radiusauthport;
594 + rslt += send_number(client, MSG_PART, 0, "\tradiusauthport=%s\n",l); /* Authentication UDP port */
595 + l = options.radiusacctport;
596 + rslt += send_number(client, MSG_PART, 0, "\tradiusacctport=%s\n",l); /* Accounting UDP port */
597 + rslt += send_line(client, MSG_PART, 0, "\tradiussecret=%s\n",options.radiussecret); /* Radius shared secret */
598 + rslt += send_line(client, MSG_PART, 0, "\tradiusnasid=%s\n",options.radiusnasid); /* Radius NAS-Identifier */
599 + rslt += send_line(client, MSG_PART, 0, "\tradiuscalled=%s\n",options.radiuscalled); /* Radius Called-Station-ID */
600 + rslt += send_line(client, MSG_PART, 0, "\tradiusnasip=%s\n",inet_ntoa(options.radiusnasip)); /* Radius NAS-IP-Address */
601 + rslt += send_line(client, MSG_PART, 0, "\tradiuslocationid=%s\n",options.radiuslocationid); /* WISPr location ID */
602 + rslt += send_line(client, MSG_PART, 0, "\tradiuslocationname=%s\n",options.radiuslocationname); /* WISPr location name */
603 + l = options.radiusnasporttype;
604 + rslt += send_number(client, MSG_PART, 0, "\tradiusnasporttype=%s\n",l); /* NAS-Port-Type */
605 + l = options.coaport;
606 + rslt += send_number(client, MSG_PART, 0, "\tcoaport=%s\n",l); /* UDP port to listen to */
607 + l = options.coanoipcheck;
608 + rslt += send_number(client, MSG_PART, 0, "\tcoaipcheck=%s\n",l); /* Allow disconnect from any IP */
609 + /* Radius proxy parameters */
610 + rslt += send_line(client, MSG_PART, 0, "\tproxylisten=%s\n",inet_ntoa(options.proxylisten)); /* IP address to listen to */
611 + l = options.proxyport;
612 + rslt += send_number(client, MSG_PART, 0, "\tproxyport=%s\n",l); /* UDP port to listen to */
613 + rslt += send_line(client, MSG_PART, 0, "\tproxyaddr=%s\n",inet_ntoa(options.proxyaddr)); /* IP address of proxy client(s) */
614 + rslt += send_line(client, MSG_PART, 0, "\tproxymask=%s\n",inet_ntoa(options.proxymask)); /* IP mask of proxy client(s) */
615 + rslt += send_line(client, MSG_PART, 0, "\tproxysecret=%s\n",options.proxysecret); /* Proxy shared secret */
616 + /* Radius configuration management parameters */
617 + rslt += send_line(client, MSG_PART, 0, "\tconfusername=%s\n",options.confusername); /* Username for remote config */
618 + rslt += send_line(client, MSG_PART, 0, "\tconfpassword=%s\n",options.confpassword); /* Password for remote config */
619 + /* DHCP parameters */
620 + l = options.nodhcp;
621 + rslt += send_number(client, MSG_PART, 0, "\tnodhcp=%s\n",l); /* Do not use DHCP */
622 + rslt += send_line(client, MSG_PART, 0, "\tdhcpif=%s\n",options.dhcpif); /* Interface: eth0 */
623 + rslt += send_mac(client, MSG_PART, 0, "\tdhcpmac=%s\n",options.dhcpmac); /* Interface MAC address */
624 + l = options.dhcpusemac;
625 + rslt += send_number(client, MSG_PART, 0, "\tdhcpusemac=%s\n",l); /* Use given MAC or interface default */
626 + rslt += send_line(client, MSG_PART, 0, "\tdhcplisten=%s\n",inet_ntoa(options.dhcplisten)); /* IP address to listen to */
627 + l = options.lease;
628 + rslt += send_number(client, MSG_PART, 0, "\tlease=%s\n",l); /* DHCP lease time */
629 + /* EAPOL parameters */
630 + l = options.eapolenable;
631 + rslt += send_number(client, MSG_PART, 0, "\teapolenable=%s\n",l); /* Use eapol */
632 + /* UAM parameters */
633 + l = options.uamserverlen;
634 + rslt += send_number(client, MSG_PART, 0, "\tuamserverlen=%s\n",l); /* Number of UAM servers */
635 + for (n = 0; n < options.uamserverlen; n++){
636 + rslt += send_number(client, MSG_PART, 0, "\tuamokip[%s]=",n);
637 + rslt += send_line(client, MSG_PART, 0, "%s\n",inet_ntoa(options.uamserver[n])); /* IP address of UAM server */
638 + }
639 + l = options.uamserverport;
640 + rslt += send_number(client, MSG_PART, 0, "\tuamserverport=%s\n",l); /* Port of UAM server */
641 + rslt += send_line(client, MSG_PART, 0, "\tuamsecret=%s\n",options.uamsecret); /* Shared secret */
642 + rslt += send_line(client, MSG_PART, 0, "\tuamurl=%s\n",options.uamurl); /* URL of authentication server */
643 + rslt += send_line(client, MSG_PART, 0, "\tuamhomepage=%s\n",options.uamhomepage); /* URL of redirection homepage */
644 + l = options.uamhomepageport;
645 + rslt += send_number(client, MSG_PART, 0, "\tuamhomepageport=%s\n",l); /* Port of redirection homepage */
646 + rslt += send_line(client, MSG_PART, 0, "\tuamlisten=%s\n",inet_ntoa(options.uamlisten)); /* IP address of local authentication */
647 + l = options.uamport;
648 + rslt += send_number(client, MSG_PART, 0, "\tuamport=%s\n",l); /* TCP port to listen to */
649 + l = options.uamokiplen;
650 + rslt += send_number(client, MSG_PART, 0, "\tuamokiplen=%s\n",l); /* Number of allowed IP addresses */
651 + for (n=0; n < options.uamokiplen; n++){
652 + rslt += send_number(client, MSG_PART, 0, "\tuamokip[%s]=",n);
653 + rslt = send_line(client, MSG_PART, 0, "%s\n",inet_ntoa(options.uamokip[n])); /* List of allowed IP addresses */
654 + }
655 + l = options.uamoknetlen;
656 + rslt += send_number(client, MSG_PART, 0, "\tuamoknetlen=%s\n",l); /* Number of networks */
657 + for (n=0; n < options.uamoknetlen; n++){
658 + rslt += send_number(client, MSG_PART, 0, "\tuamoknet[%s]=",n);
659 + rslt += send_line(client, MSG_PART, 0, "%s/",inet_ntoa(options.uamokaddr[n])); /* List of allowed network IP */
660 + rslt += send_line(client, MSG_PART, 0, "%s\n",inet_ntoa(options.uamokmask[n])); /* List of allowed network mask */
661 + }
662 + l = options.uamanydns;
663 + rslt += send_number(client, MSG_PART, 0, "\tuamanydns=%s\n",l); /* Allow client to use any DNS server */
664 + /* MAC Authentication */
665 + l = options.macauth;
666 + rslt += send_number(client, MSG_PART, 0, "\tmacauth=%s\n",l); /* Use MAC authentication */
667 + l = options.macoklen;
668 + rslt += send_number(client, MSG_PART, 0, "\tmacoklen=%s\n",l); /* Number of MAC addresses */
669 + for (n=0; n < options.macoklen; n++){
670 + rslt += send_number(client, MSG_PART, 0, "\tmacok[%s]=",n);
671 + rslt += send_mac(client, MSG_PART, 0, "\%s\n",options.macok[n]); /* Allowed MACs */
672 + }
673 + rslt += send_line(client, MSG_PART, 0, "\tmacsuffix=%s\n",options.macsuffix);
674 + rslt += send_line(client, MSG_PART, 0, "\tmacpasswd=%s\n",options.macpasswd);
675 +
676 + rslt += send_line(client, MSG_PART, 0, "\trmtlisten=%s\n",inet_ntoa(options.rmtlisten));
677 + l = options.rmtport;
678 + rslt += send_number(client, MSG_PART, 0, "\trmtport=%s\n",l); /* Number of MAC addresses */
679 + rslt += send_line(client, MSG_PART, 0, "\trmtpasswd=%s\n",options.rmtpasswd);
680 + rslt += send_number(client, MSG_PART, 0, "\tbandwidthmaxup=%s\n",options.bandwidthmaxup);
681 + rslt += send_number(client, MSG_PART, 0, "\tbandwidthmaxdown=%s\n",options.bandwidthmaxdown);
682 + rslt += rmtctrl_write_msg(client,MSG_END,0, "End of configuration\n");
683 +}
684 diff -Nur chillispot-1.1.0.orig/src/chilli.h chillispot-1.1.0/src/chilli.h
685 --- chillispot-1.1.0.orig/src/chilli.h 2009-08-11 15:10:56.000000000 -0300
686 +++ chillispot-1.1.0/src/chilli.h 2009-08-12 13:52:24.000000000 -0300
687 @@ -50,8 +50,8 @@
688 /* If the constants below are defined packets which have been dropped
689 by the traffic shaper will be counted towards accounting and
690 volume limitation */
691 -/* #define COUNT_DOWNLINK_DROP 1 */
692 -/* #define COUNT_UPLINK_DROP 1 */
693 +#define COUNT_DOWNLINK_DROP 1
694 +#define COUNT_UPLINK_DROP 1
695
696 #define APP_NUM_CONN 128
697 #define EAP_LEN 2048 /* TODO: Rather large */
698 @@ -68,7 +68,7 @@
699 #define CHALLENGESIZE 24 /* From chap.h MAX_CHALLENGE_LENGTH */
700 #define USERURLSIZE 256 /* Max length of URL requested by user */
701
702 -#define BUCKET_SIZE 300000 /* Size of leaky bucket (~200 packets) */
703 +//#define BUCKET_SIZE 300000 /* Size of leaky bucket (~200 packets) */
704
705 /* Time length of leaky bucket in milliseconds */
706 /* Bucket size = BUCKET_TIME * Bandwidth-Max radius attribute */
707 @@ -194,12 +194,14 @@
708 struct in_addr dns1;
709 struct in_addr dns2;
710 struct timeval last_time; /* Last time a packet was received or sent */
711 + struct timeval last_up_time; /* Last time a packet was received or sent */
712 + struct timeval last_down_time; /* Last time a packet was received or sent */
713
714 /* Leaky bucket */
715 - uint32_t bucketup;
716 - uint32_t bucketdown;
717 - uint32_t bucketupsize;
718 - uint32_t bucketdownsize;
719 + uint64_t bucketup;
720 + uint64_t bucketdown;
721 + uint64_t bucketupsize;
722 + uint64_t bucketdownsize;
723
724 /* UAM information */
725 uint8_t uamchal[REDIR_MD5LEN];
726 @@ -305,6 +307,11 @@
727 int macoklen; /* Number of MAC addresses */
728 char* macsuffix; /* Suffix to add to MAC address */
729 char* macpasswd; /* Password to use for MAC authentication */
730 + struct in_addr rmtlisten; /* IP address of remote monitor and config */
731 + int rmtport; /* TCP port to listen to monitor and config*/
732 + char* rmtpasswd; /* Password to use for MAC authentication */
733 + int bandwidthmaxup; /* Default Max Up Bandwith setting */
734 + int bandwidthmaxdown; /* Default Max Up Bandwith setting */
735 };
736
737 extern struct app_conn_t connection[APP_NUM_CONN];
738 Los ficheros binarios chillispot-1.1.0.orig/src/chilli.o y chillispot-1.1.0/src/chilli.o son distintos
739 diff -Nur chillispot-1.1.0.orig/src/cmdline.c chillispot-1.1.0/src/cmdline.c
740 --- chillispot-1.1.0.orig/src/cmdline.c 2006-09-24 14:48:26.000000000 -0300
741 +++ chillispot-1.1.0/src/cmdline.c 2009-08-11 16:17:58.000000000 -0300
742 @@ -113,6 +113,11 @@
743 args_info->macallowed_given = 0 ;
744 args_info->macsuffix_given = 0 ;
745 args_info->macpasswd_given = 0 ;
746 + args_info->rmtlisten_given = 0 ;
747 + args_info->rmtport_given = 0 ;
748 + args_info->rmtpasswd_given = 0 ;
749 + args_info->bandwidthmaxup_given = 0 ;
750 + args_info->bandwidthmaxdown_given = 0 ;
751 }
752
753 static
754 @@ -216,7 +221,19 @@
755 args_info->macsuffix_orig = NULL;
756 args_info->macpasswd_arg = gengetopt_strdup ("password");
757 args_info->macpasswd_orig = NULL;
758 -
759 + args_info->rmtport_arg = 3991;
760 + args_info->rmtport_orig = NULL;
761 + args_info->rmtlisten_arg = gengetopt_strdup("127.0.0.1");
762 + args_info->rmtlisten_orig = NULL;
763 + args_info->rmtport_orig = NULL;
764 + args_info->rmtpasswd_arg = NULL;
765 + args_info->rmtpasswd_orig = NULL;
766 +
767 + args_info->bandwidthmaxup_arg = 0;
768 + args_info->bandwidthmaxup_orig = NULL;
769 + args_info->bandwidthmaxdown_arg = 0;
770 + args_info->bandwidthmaxdown_orig = NULL;
771 +
772 }
773
774 void
775 @@ -284,7 +301,12 @@
776 printf("%s\n"," --macauth Authenticate based on MAC address \n (default=off)");
777 printf("%s\n"," --macallowed=STRING List of allowed MAC addresses");
778 printf("%s\n"," --macsuffix=STRING Suffix to add to the MAC address");
779 - printf("%s\n"," --macpasswd=STRING Password used when performing MAC \n authentication (default=`password')");
780 + printf("%s\n"," --macpasswd=STRING Password used when performing MAC \n authentication (default='password')");
781 + printf("%s\n"," --rmtlisten=STRING IP address to listen to for monitor and \n configuration (default=`127.0.0.1')");
782 + printf("%s\n"," --rmtport=INT TCP port to bind to for monitor and \n configuration (default=`3991')");
783 + printf("%s\n"," --rmtpasswd=STRING Password used for remote monitor and \n configuration\n");
784 + printf("%s\n"," --bandwidthmaxup=INT Deafaul Max Up Setting in Kilobits\n");
785 + printf("%s\n"," --bandwidthmaxdown=INT Deafaul Max Down Setting in Kilobits\n");
786
787 }
788
789 @@ -675,6 +697,11 @@
790 free (args_info->uamport_orig); /* free previous argument */
791 args_info->uamport_orig = 0;
792 }
793 + if (args_info->macpasswd_orig)
794 + {
795 + free (args_info->macpasswd_orig); /* free previous argument */
796 + args_info->macpasswd_orig = 0;
797 + }
798 if (args_info->uamallowed_arg)
799 {
800 for (i = 0; i < args_info->uamallowed_given; ++i)
801 @@ -739,6 +766,34 @@
802 free (args_info->macpasswd_orig); /* free previous argument */
803 args_info->macpasswd_orig = 0;
804 }
805 + if (args_info->rmtlisten_orig)
806 + {
807 + free (args_info->rmtlisten_orig); /* free previous argument */
808 + args_info->rmtlisten_orig = 0;
809 + }
810 + if (args_info->rmtport_orig)
811 + {
812 + free (args_info->rmtport_orig); /* free previous argument */
813 + args_info->rmtport_orig = 0;
814 + }
815 +
816 + if (args_info->rmtpasswd_orig)
817 + {
818 + free (args_info->rmtpasswd_orig); // free previous argument
819 + args_info->rmtpasswd_orig = 0;
820 + }
821 +
822 + if (args_info->bandwidthmaxup_orig)
823 + {
824 + free (args_info->bandwidthmaxup_orig); // free previous argument
825 + args_info->bandwidthmaxup_orig = 0;
826 + }
827 +
828 + if (args_info->bandwidthmaxdown_orig)
829 + {
830 + free (args_info->bandwidthmaxdown_orig); // free previous argument
831 + args_info->bandwidthmaxdown_orig = 0;
832 + }
833
834 clear_given (args_info);
835 }
836 @@ -1109,7 +1164,41 @@
837 fprintf(outfile, "%s\n", "macpasswd");
838 }
839 }
840 -
841 + if (args_info->rmtlisten_given) {
842 + if (args_info->rmtlisten_orig) {
843 + fprintf(outfile, "%s=\"%s\"\n", "rmtlisten", args_info->rmtlisten_orig);
844 + } else {
845 + fprintf(outfile, "%s\n", "rmtlisten");
846 + }
847 + }
848 + if (args_info->rmtport_given) {
849 + if (args_info->rmtport_orig) {
850 + fprintf(outfile, "%s=\"%s\"\n", "rmtport", args_info->rmtport_orig);
851 + } else {
852 + fprintf(outfile, "%s\n", "rmtport");
853 + }
854 + }
855 + if (args_info->rmtpasswd_given) {
856 + if (args_info->rmtpasswd_orig) {
857 + fprintf(outfile, "%s=\"%s\"\n", "rmtpasswd", args_info->rmtpasswd_orig);
858 + } else {
859 + fprintf(outfile, "%s\n", "rmtpasswd");
860 + }
861 + }
862 + if (args_info->bandwidthmaxup_given) {
863 + if (args_info->bandwidthmaxup_orig) {
864 + fprintf(outfile, "%s=\"%s\"\n", "bandwidthmaxup", args_info->bandwidthmaxup_orig);
865 + } else {
866 + fprintf(outfile, "%s\n", "bandwidthmaxup");
867 + }
868 + }
869 + if (args_info->bandwidthmaxdown_given) {
870 + if (args_info->bandwidthmaxdown_orig) {
871 + fprintf(outfile, "%s=\"%s\"\n", "bandwidthmaxdown", args_info->bandwidthmaxdown_orig);
872 + } else {
873 + fprintf(outfile, "%s\n", "bandwidthmaxdown");
874 + }
875 + }
876 fclose (outfile);
877
878 i = EXIT_SUCCESS;
879 @@ -1221,6 +1310,7 @@
880 {
881 int c; /* Character of the parsed option. */
882 char *multi_token, *multi_next; /* for multiple options */
883 + char quehace[100];
884
885 int i; /* Counter */
886
887 @@ -1299,6 +1389,11 @@
888 { "macallowed", 1, NULL, 0 },
889 { "macsuffix", 1, NULL, 0 },
890 { "macpasswd", 1, NULL, 0 },
891 + { "rmtport", 1, NULL, 0 },
892 + { "rmtlisten", 1, NULL, 0 },
893 + { "rmtpasswd", 1, NULL, 0 },
894 + { "bandwidthmaxup", 1, NULL, 0 },
895 + { "bandwidthmaxdown", 1, NULL, 0 },
896 { NULL, 0, NULL, 0 }
897 };
898
899 @@ -1380,8 +1475,6 @@
900 free (args_info->net_orig); /* free previous string */
901 args_info->net_orig = gengetopt_strdup (optarg);
902 break;
903 -
904 -
905 case 0: /* Long option with no short option */
906 /* Which modules to print debug messages for. */
907 if (strcmp (long_options[option_index].name, "debugfacility") == 0)
908 @@ -2273,7 +2366,93 @@
909 free (args_info->macpasswd_orig); /* free previous string */
910 args_info->macpasswd_orig = gengetopt_strdup (optarg);
911 }
912 -
913 + /* IP address to listen to for remote monitor and config. */
914 + else if (strcmp (long_options[option_index].name, "rmtlisten") == 0)
915 + {
916 + if (local_args_info.rmtlisten_given)
917 + {
918 + fprintf (stderr, "%s: `--rmtlisten' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
919 + goto failure;
920 + }
921 + if (args_info->rmtlisten_given && ! override)
922 + continue;
923 + local_args_info.rmtlisten_given = 1;
924 + args_info->rmtlisten_given = 1;
925 + if (args_info->rmtlisten_arg)
926 + free (args_info->rmtlisten_arg); /* free previous string */
927 + args_info->rmtlisten_arg = gengetopt_strdup (optarg);
928 + if (args_info->rmtlisten_orig)
929 + free (args_info->rmtlisten_orig); /* free previous string */
930 + args_info->rmtlisten_orig = gengetopt_strdup (optarg);
931 + }
932 + /* TCP port to bind to for authentication requests. */
933 + else if (strcmp (long_options[option_index].name, "rmtport") == 0)
934 + {
935 + if (local_args_info.rmtport_given)
936 + {
937 + fprintf (stderr, "%s: `--rmtport' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
938 + goto failure;
939 + }
940 + if (args_info->rmtport_given && ! override)
941 + continue;
942 + local_args_info.rmtport_given = 1;
943 + args_info->rmtport_given = 1;
944 + args_info->rmtport_arg = strtol (optarg,&stop_char,0);
945 + if (args_info->rmtport_orig)
946 + free (args_info->rmtport_orig); /* free previous string */
947 + args_info->rmtport_orig = gengetopt_strdup (optarg);
948 + }
949 + /* Password used when performing remote config. */
950 + else if (strcmp (long_options[option_index].name, "rmtpasswd") == 0)
951 + {
952 + if (local_args_info.rmtpasswd_given)
953 + {
954 + fprintf (stderr, "%s: `--rmtpasswd' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
955 + goto failure;
956 + }
957 + if (args_info->rmtpasswd_given && ! override)
958 + continue;
959 + local_args_info.rmtpasswd_given = 1;
960 + args_info->rmtpasswd_given = 1;
961 + if (args_info->rmtpasswd_arg)
962 + free (args_info->rmtpasswd_arg); // free previous string
963 + args_info->rmtpasswd_arg = gengetopt_strdup (optarg);
964 + if (args_info->rmtpasswd_orig)
965 + free (args_info->rmtpasswd_orig); // free previous string
966 + args_info->rmtpasswd_orig = gengetopt_strdup (optarg);
967 + }
968 + else if (strcmp (long_options[option_index].name, "bandwidthmaxup") == 0)
969 + {
970 + if (local_args_info.bandwidthmaxup_given)
971 + {
972 + fprintf (stderr, "%s: `--bandwidthmaxup' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
973 + goto failure;
974 + }
975 + if (args_info->bandwidthmaxup_given && ! override)
976 + continue;
977 + local_args_info.bandwidthmaxup_given = 1;
978 + args_info->bandwidthmaxup_given = 1;
979 + args_info->bandwidthmaxup_arg = strtol (optarg,&stop_char,0);
980 + if (args_info->bandwidthmaxup_orig)
981 + free (args_info->bandwidthmaxup_orig); /* free previous string */
982 + args_info->bandwidthmaxup_orig = gengetopt_strdup (optarg);
983 + }
984 + else if (strcmp (long_options[option_index].name, "bandwidthmaxdown") == 0)
985 + {
986 + if (local_args_info.bandwidthmaxdown_given)
987 + {
988 + fprintf (stderr, "%s: `--bandwidthmaxdown' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
989 + goto failure;
990 + }
991 + if (args_info->bandwidthmaxdown_given && ! override)
992 + continue;
993 + local_args_info.bandwidthmaxdown_given = 1;
994 + args_info->bandwidthmaxdown_given = 1;
995 + args_info->bandwidthmaxdown_arg = strtol (optarg,&stop_char,0);
996 + if (args_info->bandwidthmaxdown_orig)
997 + free (args_info->bandwidthmaxdown_orig); /* free previous string */
998 + args_info->bandwidthmaxdown_orig = gengetopt_strdup (optarg);
999 + }
1000 break;
1001 case '?': /* Invalid option. */
1002 /* `getopt_long' already printed an error message. */
1003 diff -Nur chillispot-1.1.0.orig/src/cmdline.ggo chillispot-1.1.0/src/cmdline.ggo
1004 --- chillispot-1.1.0.orig/src/cmdline.ggo 2006-09-24 14:48:26.000000000 -0300
1005 +++ chillispot-1.1.0/src/cmdline.ggo 2009-08-11 16:17:58.000000000 -0300
1006 @@ -119,3 +119,12 @@
1007 option "macsuffix" - "Suffix to add to the MAC address" string no
1008 option "macpasswd" - "Password used when performing MAC authentication" string default="password" no
1009
1010 +# Remote Monitor and Config
1011 +option "rmtlisten" - "IP address to listen to for authentication requests" string default="127.0.0.1" no
1012 +option "rmtport" - "TCP port to bind to for authentication requests" int default="3991" no
1013 +option "rmtpasswd" - "Password used when performing MAC authentication" string no
1014 +
1015 +# Extra settings
1016 +option "bandwidthmaxup" - "Default bandwidth control to apply when account don't have setting" int no
1017 +option "bandwidthmaxdown" - "Default bandwidth control to apply when account don't have setting" int no
1018 +
1019 diff -Nur chillispot-1.1.0.orig/src/cmdline.h chillispot-1.1.0/src/cmdline.h
1020 --- chillispot-1.1.0.orig/src/cmdline.h 2006-09-24 14:48:26.000000000 -0300
1021 +++ chillispot-1.1.0/src/cmdline.h 2009-08-11 16:17:58.000000000 -0300
1022 @@ -122,6 +122,17 @@
1023 char * macsuffix_orig; /* Suffix to add to the MAC address original value given at command line. */
1024 char * macpasswd_arg; /* Password used when performing MAC authentication (default='password'). */
1025 char * macpasswd_orig; /* Password used when performing MAC authentication original value given at command line. */
1026 + int rmtport_arg; /* TCP port to bind to for remote monitor and config (default='3991'). */
1027 + char * rmtport_orig; /* TCP port to bind to for remote monitor and config original value given at command line. */
1028 + char * rmtlisten_arg; /* IP address to listen to for remote monitor and config. */
1029 + char * rmtlisten_orig; /* IP address to listen to for remote monitor and config original value given at command line. */
1030 + char * rmtpasswd_arg; /* Password for remote monitor and config. */
1031 + char * rmtpasswd_orig; /* Password for remote monitor and config original value given at command line. */
1032 + int bandwidthmaxup_arg; /* Default Bandwidth Max Up. */
1033 + char *bandwidthmaxup_orig; /* Default Bandwidth Max Up value given at command line. */
1034 + int bandwidthmaxdown_arg; /* Default Bandwidth Max Down. */
1035 + char *bandwidthmaxdown_orig; /* Default Bandwidth Max Down value given at command line. */
1036 +
1037
1038 int help_given ; /* Whether help was given. */
1039 int version_given ; /* Whether version was given. */
1040 @@ -177,7 +188,11 @@
1041 unsigned int macallowed_given ; /* Whether macallowed was given. */
1042 int macsuffix_given ; /* Whether macsuffix was given. */
1043 int macpasswd_given ; /* Whether macpasswd was given. */
1044 -
1045 + int rmtport_given ; /* Whether uamport was given. */
1046 + int rmtlisten_given ; /* Whether uamlisten was given. */
1047 + int rmtpasswd_given ; /* Whether confpassword was given. */
1048 + int bandwidthmaxup_given ;
1049 + int bandwidthmaxdown_given ;
1050 } ;
1051
1052 int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info);
1053 diff -Nur chillispot-1.1.0.orig/src/Makefile chillispot-1.1.0/src/Makefile
1054 --- chillispot-1.1.0.orig/src/Makefile 2009-08-11 15:11:28.000000000 -0300
1055 +++ chillispot-1.1.0/src/Makefile 2009-08-11 16:18:32.000000000 -0300
1056 @@ -54,7 +54,7 @@
1057 am_chilli_OBJECTS = chilli.$(OBJEXT) tun.$(OBJEXT) cmdline.$(OBJEXT) \
1058 ippool.$(OBJEXT) radius.$(OBJEXT) md5.$(OBJEXT) \
1059 redir.$(OBJEXT) dhcp.$(OBJEXT) syserr.$(OBJEXT) \
1060 - iphash.$(OBJEXT) lookup.$(OBJEXT)
1061 + iphash.$(OBJEXT) lookup.$(OBJEXT) remotectrl.$(OBJEXT)
1062 chilli_OBJECTS = $(am_chilli_OBJECTS)
1063 chilli_LDADD = $(LDADD)
1064 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
1065 @@ -172,7 +172,7 @@
1066
1067 # add -pg to enable gprof
1068 AM_CFLAGS = -D_GNU_SOURCE -fno-builtin -DSBINDIR='"$(sbindir)"'
1069 -chilli_SOURCES = chilli.c defs.h tun.c tun.h cmdline.c cmdline.h ippool.c ippool.h radius.h radius.c md5.c md5.h redir.h redir.c dhcp.c dhcp.h syserr.c syserr.h iphash.c iphash.h lookup.c lookup.h
1070 +chilli_SOURCES = chilli.c defs.h tun.c tun.h cmdline.c cmdline.h ippool.c ippool.h radius.h radius.c md5.c md5.h redir.h redir.c dhcp.c dhcp.h syserr.c syserr.h iphash.c iphash.h lookup.c lookup.h remotectrl.c remotectrl.h
1071 all: all-am
1072
1073 .SUFFIXES:
1074 diff -Nur chillispot-1.1.0.orig/src/Makefile.in chillispot-1.1.0/src/Makefile.in
1075 --- chillispot-1.1.0.orig/src/Makefile.in 2006-09-24 16:34:58.000000000 -0300
1076 +++ chillispot-1.1.0/src/Makefile.in 2009-08-11 16:17:58.000000000 -0300
1077 @@ -54,7 +54,7 @@
1078 am_chilli_OBJECTS = chilli.$(OBJEXT) tun.$(OBJEXT) cmdline.$(OBJEXT) \
1079 ippool.$(OBJEXT) radius.$(OBJEXT) md5.$(OBJEXT) \
1080 redir.$(OBJEXT) dhcp.$(OBJEXT) syserr.$(OBJEXT) \
1081 - iphash.$(OBJEXT) lookup.$(OBJEXT)
1082 + iphash.$(OBJEXT) lookup.$(OBJEXT) remotectrl.$(OBJEXT)
1083 chilli_OBJECTS = $(am_chilli_OBJECTS)
1084 chilli_LDADD = $(LDADD)
1085 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
1086 @@ -172,7 +172,7 @@
1087
1088 # add -pg to enable gprof
1089 AM_CFLAGS = -D_GNU_SOURCE -fno-builtin -DSBINDIR='"$(sbindir)"'
1090 -chilli_SOURCES = chilli.c defs.h tun.c tun.h cmdline.c cmdline.h ippool.c ippool.h radius.h radius.c md5.c md5.h redir.h redir.c dhcp.c dhcp.h syserr.c syserr.h iphash.c iphash.h lookup.c lookup.h
1091 +chilli_SOURCES = chilli.c defs.h tun.c tun.h cmdline.c cmdline.h ippool.c ippool.h radius.h radius.c md5.c md5.h redir.h redir.c dhcp.c dhcp.h syserr.c syserr.h iphash.c iphash.h lookup.c lookup.h remotectrl.c remotectrl.h
1092 all: all-am
1093
1094 .SUFFIXES:
1095 diff -Nur chillispot-1.1.0.orig/src/remotectrl.c chillispot-1.1.0/src/remotectrl.c
1096 --- chillispot-1.1.0.orig/src/remotectrl.c 1969-12-31 21:00:00.000000000 -0300
1097 +++ chillispot-1.1.0/src/remotectrl.c 2009-08-11 16:17:58.000000000 -0300
1098 @@ -0,0 +1,340 @@
1099 +#include <stdio.h>
1100 +#include <sys/types.h>
1101 +#include <sys/socket.h>
1102 +#include <netinet/in.h>
1103 +#include <errno.h>
1104 +
1105 +#include "remotectrl.h"
1106 +
1107 +/*
1108 +char *vstrcat(char *first, ...)
1109 +{
1110 + size_t len = 0;
1111 + char *retbuf;
1112 + va_list argp;
1113 + char *p;
1114 + char *tmp="";
1115 + if(first == NULL)
1116 + first=tmp;
1117 +// return NULL;
1118 +
1119 + len = strlen(first);
1120 +
1121 + va_start(argp, first);
1122 +
1123 + while((p = va_arg(argp, char *)) != NULL)
1124 + len += strlen(p);
1125 +
1126 + va_end(argp);
1127 + retbuf = (char *)malloc(len + 1); // +1 for trailing \0
1128 +
1129 + if(retbuf == NULL)
1130 + return NULL; // error
1131 +
1132 + (void)strcpy(retbuf, first);
1133 +
1134 + va_start(argp, first);
1135 +
1136 + while((p = va_arg(argp, char *)) != NULL)
1137 + (void)strcat(retbuf, p);
1138 +
1139 + va_end(argp);
1140 +
1141 + return retbuf;
1142 +}
1143 +*/
1144 +
1145 +int rmtctrl_write_msg( struct rmt_socket_t *sckHnd, uint32_t id, uint32_t extra, char *message ){
1146 + msg_head_t header;
1147 + int rslt;
1148 + header.id = id;
1149 + header.len = strlen(message);
1150 + header.extra = extra;
1151 + rslt = send(sckHnd->fd,&header,sizeof(struct msg_head_t),0);
1152 + if (rslt != -1 && header.len > 0) {
1153 + sckHnd->Tx += rslt;
1154 + rslt = send(sckHnd->fd, message, header.len, 0);
1155 + if (rslt > 0)
1156 + {
1157 + sckHnd->Tx += rslt;
1158 + rslt += sizeof(struct msg_head_t);
1159 + }
1160 + }
1161 + return rslt;
1162 +}
1163 +
1164 +int rmtctrl_read_msg( struct rmt_socket_t *sckHnd, msg_head_t *head, char **message )
1165 +{
1166 +// msg_head_t header;
1167 + int rslt;
1168 + char *buffer;
1169 + int reading = 0;
1170 + int aux = 0;
1171 + rslt = recv(sckHnd->fd, head, sizeof(struct msg_head_t), 0);
1172 + if (rslt == sizeof(struct msg_head_t) ) {
1173 + sckHnd->Rx += rslt;
1174 + *message = (char *)malloc(head->len+1);
1175 + memset(*message,'\0', head->len+1);
1176 + while ( reading < head->len ){
1177 + aux = recv(sckHnd->fd, *message, head->len, 0);
1178 + switch ( aux )
1179 + {
1180 + case -1:
1181 + switch (errno)
1182 + {
1183 + case EINTR:
1184 + case EAGAIN:
1185 + usleep (100);
1186 + break;
1187 + default:
1188 + return -1;
1189 + }
1190 + break;
1191 + case 0: // mean socket was closed
1192 + sckHnd->Rx += reading;
1193 + return reading;
1194 + break;
1195 + break;
1196 + default:
1197 + reading+=aux;
1198 + break;
1199 + }
1200 + }
1201 +/*
1202 + buffer = (char *)malloc(head->len+1);
1203 + while ( reading < head->len ){
1204 + memset(buffer,'\0', head->len+1);
1205 + aux = recv(sckHnd->fd, buffer, head->len, 0);
1206 + switch ( aux ) {
1207 + case -1:
1208 + switch (errno){
1209 + case EINTR:
1210 + case EAGAIN:
1211 + usleep (100);
1212 + break;
1213 + default:
1214 + return -1;
1215 + }
1216 + break;
1217 + case 0: // mean socket was closed
1218 + sckHnd->Rx += reading;
1219 + return reading;
1220 + break;
1221 + break;
1222 + default:
1223 + if (reading == 0)
1224 + *message=(char *)malloc(aux+1);
1225 + else
1226 + *message=(char*)realloc(*message,(reading+aux+1)*sizeof(char));
1227 +// strcat(*message, buffer);
1228 + memcpy(*message+reading, buffer, aux);
1229 + reading += aux;
1230 + *message[reading]=0;
1231 + }
1232 + }
1233 + free(buffer);
1234 +*/
1235 + sckHnd->Rx += reading;
1236 + reading += rslt;
1237 + return reading;
1238 + }
1239 + return rslt;
1240 +}
1241 +
1242 +void rmtctrl_newClient(struct rmt_socket_t srv, struct rmt_socket_t *client, int *activeClients)
1243 +{
1244 + int rslt;
1245 + int cli = (*activeClients);
1246 + rmtctrl_accept(srv,&client[cli]);
1247 + if (client[(*activeClients)].fd != -1)
1248 + {
1249 + (*activeClients)++;
1250 + }
1251 + if ((*activeClients) >= MAX_CLIENTS)
1252 + {
1253 + (*activeClients)--;
1254 + rslt = rmtctrl_write_msg(&client[(*activeClients)],MSG_END,0, "Sorry Server is too Busy\n Try more late\n" );
1255 + if (rslt > 0) client[(*activeClients)].Tx += rslt;
1256 + rmtctrl_close(&client[(*activeClients)]);
1257 + }
1258 +}
1259 +
1260 +void rmtctrl_close ( struct rmt_socket_t *client )
1261 +{
1262 + printf("Desde %s se recibieron %d bytes y se enviaron %d bytes\n",inet_ntoa(client->addr.sin_addr),client->Rx,client->Tx);
1263 + close(client->fd); /* cierra fd_rmt_client */
1264 + printf("Se cerro conexiĂ³n desde %s\n",inet_ntoa(client->addr.sin_addr) );
1265 + client->fd = -1;
1266 +}
1267 +
1268 +void rmtctrl_accept (struct rmt_socket_t srv, struct rmt_socket_t *client )
1269 +{
1270 + int sin_size=sizeof(struct sockaddr_in);
1271 + int int_Send;
1272 + struct sockaddr_in addr;
1273 +
1274 + if ((client->fd = accept(srv.fd,(struct sockaddr *)&client->addr,&sin_size))!=-1)
1275 + {
1276 + client->Rx = 0;
1277 + client->Tx = 0;
1278 + unsigned char c = sizeof(uint32_t);
1279 + int_Send = send(client->fd, &c, 1, 0);
1280 + if (int_Send > 0) client->Tx += int_Send;
1281 + printf("Se abriĂ³ una conexiĂ³n desde %s\n", inet_ntoa(client->addr.sin_addr));
1282 + }
1283 +}
1284 +
1285 +//void cleanClients (int *table, int *n)
1286 +void rmtctrl_cleanClients (struct rmt_socket_t *client, int *n)
1287 +{
1288 + int i,j;
1289 +
1290 + if ((client == NULL) || ((*n) == 0))
1291 + return;
1292 +
1293 + j=0;
1294 + for (i=0; i<(*n); i++)
1295 + {
1296 + if (client[i].fd != -1)
1297 + {
1298 + client[j].fd = client[i].fd;
1299 + client[j].addr = client[i].addr;
1300 + client[j].Rx = client[i].Rx;
1301 + client[j].Tx = client[i].Tx;
1302 + j++;
1303 + }
1304 + }
1305 +
1306 + *n = j;
1307 +}
1308 +
1309 +int rmtctrl_maxValue (struct rmt_socket_t *client, int n)
1310 +{
1311 + int i;
1312 + int max;
1313 +
1314 + if ((client == NULL) || (n<1))
1315 + return 0;
1316 +
1317 + max = client[0].fd;
1318 + for (i=0; i<n; i++)
1319 + if (client[i].fd > max)
1320 + max = client[i].fd;
1321 +
1322 + return max;
1323 +}
1324 +
1325 +struct rmt_socket_t rmtctrl_initSrv(struct in_addr rmtlisten, int rmtport){
1326 + struct rmt_socket_t srv;
1327 + if ((srv.fd=socket(AF_INET, SOCK_STREAM, 0)) == -1 ) {
1328 + printf("error en socket()\n");
1329 + exit(1);
1330 + }
1331 + srv.addr.sin_family = AF_INET;
1332 + srv.addr.sin_port = htons(rmtport);
1333 + srv.addr.sin_addr.s_addr = rmtlisten.s_addr;
1334 + bzero(&(srv.addr.sin_zero),8);
1335 +
1336 + if(bind(srv.fd,(struct sockaddr*)&srv.addr,sizeof(struct sockaddr))==-1) {
1337 + printf("error en bind() \n");
1338 + exit(-1);
1339 + }
1340 +
1341 + if(listen(srv.fd,BACKLOG) == -1) {
1342 + printf("error en listen()\n");
1343 + exit(-1);
1344 + }
1345 + return srv;
1346 +}
1347 +
1348 +void rmtctrl_srv(struct rmt_socket_t srv, struct rmt_socket_t *client, int *activeClients)
1349 +{
1350 + fd_set fdRead;
1351 + int maxHnd;
1352 + int i;
1353 + struct timeval nowait;
1354 + memset((char *)&nowait,0,sizeof(nowait));
1355 +
1356 + rmtctrl_cleanClients(client, activeClients);
1357 + FD_ZERO (&fdRead);
1358 + FD_SET (srv.fd, &fdRead);
1359 +
1360 + for (i=0; i<*activeClients; i++)
1361 + FD_SET (client[i].fd, &fdRead);
1362 +
1363 + maxHnd = rmtctrl_maxValue (client, *activeClients);
1364 +
1365 + if (maxHnd < srv.fd)
1366 + maxHnd = srv.fd;
1367 +
1368 + select (maxHnd + 1, &fdRead, NULL, NULL,&nowait);
1369 + for (i=0; i<*activeClients; i++)
1370 + {
1371 + if (FD_ISSET (client[i].fd, &fdRead))
1372 + {
1373 + rmtctrl_msg_proccess(&client[i]);
1374 + }
1375 + }
1376 + if (FD_ISSET (srv.fd, &fdRead))
1377 + rmtctrl_newClient(srv,client, &(*activeClients));
1378 +}
1379 +
1380 +int send_line( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, char *data)
1381 +{
1382 + char str[2048];
1383 + memset(str,'\0',2048);
1384 + sprintf(str,fmt,data);
1385 + return rmtctrl_write_msg(client,msg_type,msg_extra, str);
1386 +}
1387 +
1388 +int send_octets( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint64_t value)
1389 +{
1390 + char *Buffer = (char *)octets2str(value);
1391 + int ret = send_line( client, msg_type, msg_extra, fmt, Buffer);
1392 + free(Buffer);
1393 + return ret;
1394 +}
1395 +
1396 +int send_mac( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint8_t *value)
1397 +{
1398 + char *Buffer = (char*)mac2str(value);
1399 + int ret = send_line( client, msg_type, msg_extra, fmt, Buffer);
1400 + free(Buffer);
1401 + return ret;
1402 +}
1403 +
1404 +int send_number( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint64_t value)
1405 +{
1406 + char Buffer[64];
1407 + sprintf(Buffer,"%d", value);
1408 + return send_line( client, msg_type, msg_extra, fmt, Buffer);
1409 +}
1410 +
1411 +const char * mac2str(uint8_t *mac)
1412 +{
1413 + char *buffer;
1414 + buffer=(char*)malloc(18*sizeof(char));
1415 + memset(buffer,'\0',18);
1416 + (void) sprintf(buffer,"%.2X-%.2X-%.2X-%.2X-%.2X-%.2X",
1417 + mac[0], mac[1],
1418 + mac[2], mac[3],
1419 + mac[4], mac[5]);
1420 + return buffer;
1421 +}
1422 +
1423 +const char * octets2str(uint64_t value)
1424 +{
1425 + char *buffer;
1426 + buffer=(char*)malloc(13*sizeof(char));
1427 + memset(buffer,'\0',13);
1428 + if (value/8 > 1073741824){ // gigas
1429 + sprintf(buffer,"%.1f(GiB)",((value/8.0)/1073741824.0));
1430 + }else if (value/8 > 1048576){ // megas
1431 + sprintf(buffer,"%.1f(MiB)",((value/8.0)/1048576.0));
1432 + }else if (value/8 > 1024){ // KiloBytes
1433 + sprintf(buffer,"%.1f(KiB)",((value/8.0)/1024.0));
1434 + }else // Bytes
1435 + sprintf(buffer,"%.1f(B)",(value/8));
1436 + return buffer;
1437 +}
1438 +
1439 diff -Nur chillispot-1.1.0.orig/src/remotectrl.h chillispot-1.1.0/src/remotectrl.h
1440 --- chillispot-1.1.0.orig/src/remotectrl.h 1969-12-31 21:00:00.000000000 -0300
1441 +++ chillispot-1.1.0/src/remotectrl.h 2009-08-11 16:17:58.000000000 -0300
1442 @@ -0,0 +1,86 @@
1443 +#include <stdarg.h>
1444 +#ifndef _RMTCTRL_H
1445 +#define _RMTCTRL_H
1446 +
1447 +enum
1448 +{
1449 + MSG_OK = 0,
1450 + MSG_START = 1,
1451 + MSG_PART = 2,
1452 + MSG_END = 3,
1453 + QRY_STATUS = 100,
1454 + QRY_CONNECTED_LIST = 101,
1455 + QRY_CONNECTED_FULL_LIST = 102,
1456 + QRY_MACADDR = 103,
1457 + QRY_IPADDR = 104,
1458 + QRY_USERNAME = 105,
1459 +
1460 + CMD_AUTHORIZE = 200,
1461 + CMD_DISCONNECT = 201,
1462 +
1463 + EXTRA_ALL_OP = 300,
1464 + EXTRA_MAC_OP = 301,
1465 + EXTRA_IP_OP = 302,
1466 + EXTRA_USER_OP = 303,
1467 +};
1468 +
1469 +enum
1470 +{
1471 + STRING,
1472 + IP_ADDR,
1473 + MAC_ADDR,
1474 + NUMBER,
1475 + OCTETS,
1476 +};
1477 +
1478 +#define PORT 15557 /* El puerto que ser? abierto */
1479 +#define BACKLOG 2 /* El n?mero de conexiones permitidas */
1480 +#define MAX_CLIENTS 10
1481 +static char CONVERT_BUFF[1024];
1482 +
1483 +typedef struct msg_head_t {
1484 + uint32_t id;
1485 + uint32_t extra;
1486 + uint32_t len;
1487 +} msg_head_t;
1488 +
1489 +typedef struct rmt_socket_t {
1490 + int fd;
1491 + struct sockaddr_in addr;
1492 + int Rx;
1493 + int Tx;
1494 +} rmt_socket_t;
1495 +
1496 +//char *vstrcat(char *first, ...);
1497 +
1498 +
1499 +int rmtctrl_write_msg( struct rmt_socket_t *sckHnd, uint32_t id, uint32_t extra, char *message );
1500 +int rmtctrl_read_msg( struct rmt_socket_t *sckHnd, msg_head_t *head, char **message );
1501 +void rmtctrl_newClient(struct rmt_socket_t srv, struct rmt_socket_t *client, int *activeClients);
1502 +void rmtctrl_close ( struct rmt_socket_t *client );
1503 +void rmtctrl_accept (struct rmt_socket_t srv, struct rmt_socket_t *client );
1504 +void rmtctrl_cleanClients (struct rmt_socket_t *client, int *n);
1505 +
1506 +//inicializa las variables y arranca el servidor
1507 +struct rmt_socket_t rmtctrl_initSrv(struct in_addr rmtlisten, int rmtport);
1508 +//esta funcion es la que va dentro del loop del programa que lo utiliza
1509 +void rmtctrl_srv(struct rmt_socket_t srv, struct rmt_socket_t *client, int *activeClients);
1510 +//En esta funcion es donde se define como se procesan los mensajes
1511 +void rmtctrl_msg_proccess(struct rmt_socket_t *client);
1512 +
1513 +//char * pepe(char *dest, char *sep, char *src);
1514 +
1515 +//char * send_value(char *name, char *value, int len, struct in_addr *addr,
1516 +// uint8_t *mac, long int *integer);
1517 +//int addfield(char* reg, char *field, char sep);
1518 +//int addfield1(char** reg,int rlen, char *field, int flen, char sep);
1519 +//int sendConnectedInfo(struct app_conn_t *appconn, struct rmt_socket_t *client);
1520 +//const char * value2str( int type, void *value);
1521 +const char * octets2str(uint64_t value);
1522 +const char * mac2str(uint8_t *mac);
1523 +int send_line( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, char *data);
1524 +int send_octets( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint64_t value);
1525 +int send_mac( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint8_t *value);
1526 +int send_number( struct rmt_socket_t *client, int msg_type, int msg_extra, char *fmt, uint64_t value);
1527 +
1528 +#endif /* !_RMTCTRL_H */
1529 Los ficheros binarios chillispot-1.1.0.orig/src/remotectrl.o y chillispot-1.1.0/src/remotectrl.o son distintos