Changes to update Tomato RAF.
[tomato.git] / release / src / router / httpd / pptpd.c
blob3a51ac1ac9ef372844be3fb2ed00c4c870ea7268
1 /*
3 Tomato Firmware
4 PPTP Server Support
5 Copyright (C) 2012 Augusto Bott
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
19 #include "tomato.h"
21 #ifndef PPTP_CONNECTED
22 #define PPTP_CONNECTED "/tmp/pptp_connected"
23 #endif
25 #ifndef IF_SIZE
26 #define IF_SIZE 8
27 #endif
30 #ifndef IFNAMSIZ
31 #define IFNAMSIZ 16
32 #endif
35 void asp_pptpd_userol(int argc, char **argv) {
36 char comma;
37 char line[128];
38 FILE *fp;
40 char clientusername[32+1];
41 char clientlocalip[INET6_ADDRSTRLEN+1];
42 char clientremoteip[INET6_ADDRSTRLEN+1];
43 char interface[IF_SIZE+1];
44 int ppppid;
45 int clientuptime;
47 web_puts("\n\npptpd_online=[");
48 comma = ' ';
50 fp = fopen(PPTP_CONNECTED, "r");
51 if (fp) {
52 while (fgets(line, sizeof(line), fp) != NULL) {
53 if (sscanf(line, "%d %s %s %s %s %d", &ppppid, interface, clientlocalip, clientremoteip, clientusername, &clientuptime) != 6) continue;
54 web_printf("%c['%d', '%s', '%s', '%s', '%s', '%d']",
55 comma, ppppid, interface, clientlocalip, clientremoteip, clientusername, clientuptime);
56 comma = ',';
58 fclose(fp);
61 web_puts("];\n");
64 void wo_pptpdcmd(char *url) {
65 char *p;
66 int n = 10;
67 // do we really need to output anything?
68 web_puts("\npptd_result = [\n");
69 if ((p = webcgi_get("disconnect")) != NULL) {
70 while ((kill(atoi(p), SIGTERM) == 0) && (n > 1)) {
71 sleep(1);
72 n--;
75 web_puts("];\n");