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
|
/*
Tomato Firmware
Copyright (C) 2006-2009 Jonathan Zarate
*/
#include "tomato.h"
void asp_upnpinfo(int argc, char **argv)
{
#ifdef USE_MINIUPNPD
if (nvram_get_int("upnp_enable")) {
f_write_string("/etc/upnp/info", "", 0, 0);
if (killall("miniupnpd", SIGUSR2) == 0) {
f_wait_notexists("/etc/upnp/info", 5);
}
web_puts("\nmupnp_data = '");
web_putfile("/etc/upnp/data.info", WOF_JAVASCRIPT);
web_puts("';\n");
}
#else
unlink("/var/spool/upnp.js");
if (nvram_get_int("upnp_enable") == 1) {
if (killall("upnp", SIGUSR2) == 0) {
f_wait_exists("/var/spool/upnp.js", 5);
}
}
web_puts("\nupnp_data = [\n");
do_file("/var/spool/upnp.js");
web_puts("];\n");
unlink("/var/spool/upnp.js");
#endif
}
void wo_upnp(char *url)
{
#ifdef USE_MINIUPNPD
char s[256];
const char *proto;
const char *eport;
if (nvram_get_int("upnp_enable")) {
if (((proto = webcgi_get("remove_proto")) != NULL) && (*proto) &&
((eport = webcgi_get("remove_eport")) != NULL) && (*eport)) {
sprintf(s, "%3s %6s\n", proto, eport);
f_write_string("/etc/upnp/delete", s, 0, 0);
if (killall("miniupnpd", SIGUSR2) == 0) {
f_wait_notexists("/etc/upnp/delete", 5);
}
}
}
common_redirect();
#else
char s[256];
const char *proto;
const char *port;
if (nvram_get_int("upnp_enable") == 1) {
if (((proto = webcgi_get("remove_proto")) != NULL) && (*proto) &&
((port = webcgi_get("remove_ext_port")) != NULL) && (*port)) {
sprintf(s, "%s %s\n", proto, port);
f_write_string("/var/spool/upnp.delete", s, 0, 0);
if (killall("upnp", SIGUSR2) == 0) {
f_wait_notexists("/var/spool/upnp.delete", 5);
}
}
}
common_redirect();
#endif
}
|