| 1 | |
|---|
| 2 | #include <stdio.h> |
|---|
| 3 | #include <stdlib.h> |
|---|
| 4 | #include <string.h> |
|---|
| 5 | #include <dirent.h> |
|---|
| 6 | #include <signal.h> |
|---|
| 7 | #include <unistd.h> |
|---|
| 8 | #include <errno.h> |
|---|
| 9 | #include <ctype.h> |
|---|
| 10 | #include <sys/types.h> |
|---|
| 11 | #include <sys/stat.h> |
|---|
| 12 | #include <sys/ioctl.h> /* AhMan March 18 2005 */ |
|---|
| 13 | #include <sys/socket.h> |
|---|
| 14 | #include <netinet/in.h> |
|---|
| 15 | #include <arpa/inet.h> |
|---|
| 16 | #include <wait.h> |
|---|
| 17 | #include <net/route.h> /* AhMan March 18 2005 */ |
|---|
| 18 | #include <sys/types.h> |
|---|
| 19 | #include <signal.h> |
|---|
| 20 | #include <dlfcn.h> |
|---|
| 21 | |
|---|
| 22 | #include <bcmnvram.h> |
|---|
| 23 | #include <bcmconfig.h> |
|---|
| 24 | #include <netconf.h> |
|---|
| 25 | #include <shutils.h> |
|---|
| 26 | #include <utils.h> |
|---|
| 27 | #include <cy_conf.h> |
|---|
| 28 | #include <code_pattern.h> |
|---|
| 29 | #include <rc.h> |
|---|
| 30 | #include <wlutils.h> |
|---|
| 31 | #include <nvparse.h> |
|---|
| 32 | |
|---|
| 33 | #define WL_IOCTL(name, cmd, buf, len) (wl_ioctl((name), (cmd), (buf), (len))) |
|---|
| 34 | |
|---|
| 35 | #define TXPWR_MAX 251 |
|---|
| 36 | #define TXPWR_DEFAULT 28 |
|---|
| 37 | |
|---|
| 38 | #define IFUP (IFF_UP | IFF_RUNNING | IFF_BROADCAST | IFF_MULTICAST) |
|---|
| 39 | |
|---|
| 40 | /* |
|---|
| 41 | * AhMan March 18 2005 |
|---|
| 42 | */ |
|---|
| 43 | #define sin_addr(s) (((struct sockaddr_in *)(s))->sin_addr) |
|---|
| 44 | |
|---|
| 45 | /* |
|---|
| 46 | * AhMan March 18 2005 |
|---|
| 47 | */ |
|---|
| 48 | void start_tmp_ppp(int num); |
|---|
| 49 | |
|---|
| 50 | void del_routes(char *route) |
|---|
| 51 | { |
|---|
| 52 | char word[80], *tmp; |
|---|
| 53 | char *ipaddr, *netmask, *gateway, *metric, *ifname; |
|---|
| 54 | |
|---|
| 55 | foreach(word, route, tmp) { |
|---|
| 56 | netmask = word; |
|---|
| 57 | ipaddr = strsep(&netmask, ":"); |
|---|
| 58 | if (!ipaddr || !netmask) |
|---|
| 59 | continue; |
|---|
| 60 | gateway = netmask; |
|---|
| 61 | netmask = strsep(&gateway, ":"); |
|---|
| 62 | if (!netmask || !gateway) |
|---|
| 63 | continue; |
|---|
| 64 | metric = gateway; |
|---|
| 65 | gateway = strsep(&metric, ":"); |
|---|
| 66 | if (!gateway || !metric) |
|---|
| 67 | continue; |
|---|
| 68 | ifname = metric; |
|---|
| 69 | metric = strsep(&ifname, ":"); |
|---|
| 70 | if (!metric || !ifname) |
|---|
| 71 | continue; |
|---|
| 72 | |
|---|
| 73 | if (!strcmp(ipaddr, "0.0.0.0")) |
|---|
| 74 | eval("route", "del", "default", "gw", gateway); |
|---|
| 75 | |
|---|
| 76 | eval("route", "del", "-net", ipaddr, "netmask", netmask, "gw", |
|---|
| 77 | gateway); |
|---|
| 78 | // route_del (ifname, atoi (metric) + 1, ipaddr, gateway, netmask); |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | int start_services_main(int argc, char **argv) |
|---|
| 83 | { |
|---|
| 84 | void *handle = NULL; |
|---|
| 85 | |
|---|
| 86 | nvram_set("qos_done", "0"); |
|---|
| 87 | #ifdef HAVE_CPUTEMP |
|---|
| 88 | handle = start_service_nofree_f("hwmon", handle); |
|---|
| 89 | #endif |
|---|
| 90 | #ifdef HAVE_TELNET |
|---|
| 91 | handle = start_service_nofree_f("telnetd", handle); |
|---|
| 92 | #endif |
|---|
| 93 | #ifdef HAVE_FTP |
|---|
| 94 | handle = start_service_nofree_f("ftpsrv", handle); |
|---|
| 95 | #endif |
|---|
| 96 | #ifdef HAVE_SAMBA_SRV |
|---|
| 97 | handle = start_service_nofree_f("sambasrv", handle); |
|---|
| 98 | #endif |
|---|
| 99 | #ifdef HAVE_SYSLOG |
|---|
| 100 | handle = start_service_nofree_f("syslog", handle); |
|---|
| 101 | #endif |
|---|
| 102 | #ifdef HAVE_TFTP |
|---|
| 103 | handle = start_service_nofree_f("tftpd", handle); |
|---|
| 104 | #endif |
|---|
| 105 | handle = start_service_nofree_f("httpd", handle); |
|---|
| 106 | handle = start_service_nofree_f("udhcpd", handle); |
|---|
| 107 | #ifdef HAVE_DNSMASQ |
|---|
| 108 | handle = start_service_nofree_f("dnsmasq", handle); |
|---|
| 109 | #endif |
|---|
| 110 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 111 | handle = start_service_nofree_f("zebra", handle); |
|---|
| 112 | #endif |
|---|
| 113 | #ifdef HAVE_OLSRD |
|---|
| 114 | handle = start_service_nofree_f("olsrd", handle); |
|---|
| 115 | #endif |
|---|
| 116 | |
|---|
| 117 | handle = start_service_nofree_f("wshaper", handle); |
|---|
| 118 | handle = start_service_nofree_f("wland", handle); |
|---|
| 119 | handle = start_service_nofree_f("cron", handle); |
|---|
| 120 | |
|---|
| 121 | #ifdef HAVE_PPTPD |
|---|
| 122 | handle = start_service_nofree_f("pptpd", handle); |
|---|
| 123 | #endif |
|---|
| 124 | |
|---|
| 125 | #ifdef HAVE_SSHD |
|---|
| 126 | #ifdef HAVE_REGISTER |
|---|
| 127 | if (isregistered_real()) |
|---|
| 128 | #endif |
|---|
| 129 | handle = start_service_nofree_f("sshd", handle); |
|---|
| 130 | #endif |
|---|
| 131 | |
|---|
| 132 | #ifdef HAVE_RADVD |
|---|
| 133 | handle = start_service_nofree_f("radvd", handle); |
|---|
| 134 | #endif |
|---|
| 135 | |
|---|
| 136 | #ifdef HAVE_SNMP |
|---|
| 137 | handle = start_service_nofree_f("snmp", handle); |
|---|
| 138 | #endif |
|---|
| 139 | |
|---|
| 140 | #ifdef HAVE_PPPOESERVER |
|---|
| 141 | handle = start_service_nofree_f("pppoeserver", handle); |
|---|
| 142 | #endif |
|---|
| 143 | |
|---|
| 144 | #ifdef HAVE_WOL |
|---|
| 145 | handle = start_service_nofree_f("wol", handle); |
|---|
| 146 | #endif |
|---|
| 147 | |
|---|
| 148 | #ifdef HAVE_NOCAT |
|---|
| 149 | handle = start_service_nofree_f("splashd", handle); |
|---|
| 150 | #endif |
|---|
| 151 | |
|---|
| 152 | #ifdef HAVE_UPNP |
|---|
| 153 | handle = start_service_nofree_f("upnp", handle); |
|---|
| 154 | #endif |
|---|
| 155 | |
|---|
| 156 | #ifdef HAVE_OPENVPN |
|---|
| 157 | handle = start_service_nofree_f("openvpnserversys", handle); |
|---|
| 158 | #endif |
|---|
| 159 | #ifdef HAVE_VNCREPEATER |
|---|
| 160 | handle = start_service_nofree_f("vncrepeater", handle); |
|---|
| 161 | #endif |
|---|
| 162 | #ifdef HAVE_RSTATS |
|---|
| 163 | handle = start_service_nofree_f("rstats", handle); |
|---|
| 164 | #endif |
|---|
| 165 | #ifdef HAVE_NSTX |
|---|
| 166 | handle = start_service_nofree_f("nstxd", handle); |
|---|
| 167 | #endif |
|---|
| 168 | #ifdef HAVE_PPPOERELAY |
|---|
| 169 | handle = start_service_nofree_f("pppoerelay", handle); |
|---|
| 170 | #endif |
|---|
| 171 | #ifdef HAVE_MILKFISH |
|---|
| 172 | handle = start_service_nofree_f("milkfish", handle); |
|---|
| 173 | #endif |
|---|
| 174 | #ifdef HAVE_FREERADIUS |
|---|
| 175 | handle = start_service_nofree_f("freeradius", handle); |
|---|
| 176 | #endif |
|---|
| 177 | #ifdef HAVE_AP_SERV |
|---|
| 178 | handle = start_service_nofree_f("apserv", handle); |
|---|
| 179 | #endif |
|---|
| 180 | // if( handle ) |
|---|
| 181 | // dlclose( handle ); |
|---|
| 182 | |
|---|
| 183 | cprintf("done\n"); |
|---|
| 184 | return 0; |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | int stop_services_main(int argc, char **argv) |
|---|
| 188 | { |
|---|
| 189 | void *handle = NULL; |
|---|
| 190 | |
|---|
| 191 | // stop_ses(); |
|---|
| 192 | #ifdef HAVE_AP_SERV |
|---|
| 193 | handle = stop_service_nofree("apserv", handle); |
|---|
| 194 | #endif |
|---|
| 195 | #ifdef HAVE_FREERADIUS |
|---|
| 196 | handle = stop_service_nofree("freeradius", handle); |
|---|
| 197 | #endif |
|---|
| 198 | #ifdef HAVE_MULTICAST |
|---|
| 199 | handle = stop_service_nofree("igmp_proxy", handle); |
|---|
| 200 | #endif |
|---|
| 201 | #ifdef HAVE_PPPOERELAY |
|---|
| 202 | handle = stop_service_nofree("pppoerelay", handle); |
|---|
| 203 | #endif |
|---|
| 204 | #ifdef HAVE_RSTATS |
|---|
| 205 | handle = stop_service_nofree("rstats", handle); |
|---|
| 206 | #endif |
|---|
| 207 | #ifdef HAVE_NSTX |
|---|
| 208 | handle = stop_service_nofree("nstxd", handle); |
|---|
| 209 | #endif |
|---|
| 210 | |
|---|
| 211 | #ifdef HAVE_UPNP |
|---|
| 212 | handle = stop_service_nofree("upnp", handle); |
|---|
| 213 | #endif |
|---|
| 214 | handle = stop_service_nofree("udhcpd", handle); |
|---|
| 215 | handle = stop_service_nofree("dns_clear_resolv", handle); |
|---|
| 216 | handle = stop_service_nofree("cron", handle); |
|---|
| 217 | |
|---|
| 218 | #ifdef HAVE_TFTP |
|---|
| 219 | handle = stop_service_nofree("tftpd", handle); |
|---|
| 220 | #endif |
|---|
| 221 | #ifdef HAVE_SYSLOG |
|---|
| 222 | handle = stop_service_nofree("syslog", handle); |
|---|
| 223 | #endif |
|---|
| 224 | #ifdef HAVE_OLSRD |
|---|
| 225 | handle = stop_service_nofree("olsrd", handle); |
|---|
| 226 | #endif |
|---|
| 227 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 228 | handle = stop_service_nofree("zebra", handle); |
|---|
| 229 | #endif |
|---|
| 230 | handle = stop_service_nofree("wland", handle); |
|---|
| 231 | #ifdef HAVE_TELNET |
|---|
| 232 | handle = stop_service_nofree("telnetd", handle); |
|---|
| 233 | #endif |
|---|
| 234 | #ifdef HAVE_FTP |
|---|
| 235 | handle = stop_service_nofree("ftpsrv", handle); |
|---|
| 236 | #endif |
|---|
| 237 | #ifdef HAVE_SAMBA_SRV |
|---|
| 238 | handle = stop_service_nofree("sambasrv", handle); |
|---|
| 239 | #endif |
|---|
| 240 | #ifdef HAVE_SSHD |
|---|
| 241 | #ifdef HAVE_REGISTER |
|---|
| 242 | if (isregistered_real()) |
|---|
| 243 | #endif |
|---|
| 244 | handle = stop_service_nofree("sshd", handle); |
|---|
| 245 | #endif |
|---|
| 246 | |
|---|
| 247 | #ifdef HAVE_RADVD |
|---|
| 248 | handle = stop_service_nofree("radvd", handle); |
|---|
| 249 | #endif |
|---|
| 250 | |
|---|
| 251 | #ifdef HAVE_WIFIDOG |
|---|
| 252 | handle = stop_service_nofree("wifidog", handle); |
|---|
| 253 | #endif |
|---|
| 254 | |
|---|
| 255 | #ifdef HAVE_CHILLI |
|---|
| 256 | handle = stop_service_nofree("chilli", handle); |
|---|
| 257 | #endif |
|---|
| 258 | |
|---|
| 259 | #ifdef HAVE_PPPOESERVER |
|---|
| 260 | handle = stop_service_nofree("pppoeserver", handle); |
|---|
| 261 | #endif |
|---|
| 262 | |
|---|
| 263 | #ifdef HAVE_SNMP |
|---|
| 264 | handle = stop_service_nofree("snmp", handle); |
|---|
| 265 | #endif |
|---|
| 266 | |
|---|
| 267 | #ifdef HAVE_WOL |
|---|
| 268 | handle = stop_service_nofree("wol", handle); |
|---|
| 269 | #endif |
|---|
| 270 | handle = stop_service_nofree("wland", handle); |
|---|
| 271 | handle = stop_service_nofree("wshaper", handle); |
|---|
| 272 | |
|---|
| 273 | #ifdef HAVE_PPTPD |
|---|
| 274 | handle = stop_service_nofree("pptpd", handle); |
|---|
| 275 | #endif |
|---|
| 276 | #ifdef HAVE_NOCAT |
|---|
| 277 | handle = stop_service_nofree("splashd", handle); |
|---|
| 278 | #endif |
|---|
| 279 | #ifdef HAVE_VNCREPEATER |
|---|
| 280 | handle = stop_service_nofree("vncrepeater", handle); |
|---|
| 281 | #endif |
|---|
| 282 | #ifdef HAVE_OPENVPN |
|---|
| 283 | handle = stop_service_nofree("openvpnserversys", handle); |
|---|
| 284 | #endif |
|---|
| 285 | // if( handle ) |
|---|
| 286 | // dlclose( handle ); |
|---|
| 287 | |
|---|
| 288 | cprintf("done\n"); |
|---|
| 289 | return 0; |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | static void handle_dhcpd(void) |
|---|
| 293 | { |
|---|
| 294 | startstop_f("udhcpd"); |
|---|
| 295 | } |
|---|
| 296 | |
|---|
| 297 | static void handle_index(void) |
|---|
| 298 | { |
|---|
| 299 | unlink("/tmp/ppp/log"); |
|---|
| 300 | void *handle = NULL; |
|---|
| 301 | |
|---|
| 302 | handle = stop_service_nofree("wan", handle); |
|---|
| 303 | handle = stop_service_nofree("radio_timer", handle); |
|---|
| 304 | #ifdef HAVE_MULTICAST |
|---|
| 305 | handle = stop_service_nofree("igmp_proxy", handle); |
|---|
| 306 | #endif |
|---|
| 307 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 308 | handle = stop_service_nofree("nas", handle); |
|---|
| 309 | #endif |
|---|
| 310 | #ifdef HAVE_MADWIFI |
|---|
| 311 | handle = stop_service_nofree("stabridge", handle); |
|---|
| 312 | #endif |
|---|
| 313 | #ifdef HAVE_VLANTAGGING |
|---|
| 314 | handle = stop_service_nofree("bridgesif", handle); |
|---|
| 315 | handle = stop_service_nofree("vlantagging", handle); |
|---|
| 316 | #endif |
|---|
| 317 | #ifdef HAVE_BONDING |
|---|
| 318 | handle = stop_service_nofree("bonding", handle); |
|---|
| 319 | #endif |
|---|
| 320 | handle = stop_service_nofree("lan", handle); |
|---|
| 321 | #ifdef HAVE_VLANTAGGING |
|---|
| 322 | handle = stop_service_nofree("bridging", handle); |
|---|
| 323 | #endif |
|---|
| 324 | handle = stop_service_nofree("ttraff", handle); |
|---|
| 325 | handle = stop_service_nofree("wan", handle); |
|---|
| 326 | #ifdef HAVE_VLANTAGGING |
|---|
| 327 | handle = start_service_nofree("bridging", handle); |
|---|
| 328 | #endif |
|---|
| 329 | handle = start_service_nofree("lan", handle); |
|---|
| 330 | #ifdef HAVE_BONDING |
|---|
| 331 | handle = start_service_nofree("bonding", handle); |
|---|
| 332 | #endif |
|---|
| 333 | handle = start_service_nofree("wan_boot", handle); |
|---|
| 334 | handle = start_service_nofree_f("ttraff", handle); |
|---|
| 335 | #ifdef HAVE_MADWIFI |
|---|
| 336 | handle = start_service_nofree_f("stabridge", handle); |
|---|
| 337 | #endif |
|---|
| 338 | handle = startstop_nofree_f("udhcpd", handle); |
|---|
| 339 | #ifdef HAVE_DNSMASQ |
|---|
| 340 | handle = startstop_nofree_f("dnsmasq", handle); |
|---|
| 341 | #endif |
|---|
| 342 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 343 | handle = startstop_nofree_f("zebra", handle); |
|---|
| 344 | #endif |
|---|
| 345 | #ifdef HAVE_OLSRD |
|---|
| 346 | handle = startstop_nofree_f("olsrd", handle); |
|---|
| 347 | #endif |
|---|
| 348 | #ifdef HAVE_VLANTAGGING |
|---|
| 349 | handle = start_service_nofree("vlantagging", handle); |
|---|
| 350 | handle = start_service_nofree("bridgesif", handle); |
|---|
| 351 | #endif |
|---|
| 352 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 353 | handle = start_service_nofree("nas", handle); |
|---|
| 354 | handle = start_service_nofree("guest_nas", handle); |
|---|
| 355 | #endif |
|---|
| 356 | handle = start_service_nofree_f("radio_timer", handle); |
|---|
| 357 | handle = startstop_nofree("firewall", handle); |
|---|
| 358 | handle = startstop_nofree_f("httpd", handle); // httpd will not |
|---|
| 359 | // accept connection |
|---|
| 360 | // anymore on wan/lan |
|---|
| 361 | // ip changes changes |
|---|
| 362 | handle = startstop_nofree_f("cron", handle); // httpd will not |
|---|
| 363 | // accept connection |
|---|
| 364 | // anymore on wan/lan |
|---|
| 365 | // ip changes changes |
|---|
| 366 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 367 | handle = start_service_nofree("wan_boot", handle); |
|---|
| 368 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 369 | // if( handle ) |
|---|
| 370 | // dlclose( handle ); |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | static void handle_router(void) |
|---|
| 374 | { |
|---|
| 375 | void *handle = NULL; |
|---|
| 376 | |
|---|
| 377 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 378 | handle = startstop_nofree_f("zebra", handle); |
|---|
| 379 | #endif |
|---|
| 380 | #ifdef HAVE_OLSRD |
|---|
| 381 | handle = startstop_nofree_f("olsrd", handle); |
|---|
| 382 | #endif |
|---|
| 383 | // if( handle ) |
|---|
| 384 | // dlclose( handle ); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | static void handle_anchorfree(void) |
|---|
| 388 | { |
|---|
| 389 | void *handle = NULL; |
|---|
| 390 | |
|---|
| 391 | handle = startstop_nofree_f("anchorfree", handle); |
|---|
| 392 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 393 | // if( handle ) |
|---|
| 394 | // dlclose( handle ); |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | static void handle_hotspot(void) |
|---|
| 398 | { |
|---|
| 399 | void *handle = NULL; |
|---|
| 400 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 401 | handle = stop_service_nofree("zebra", handle); |
|---|
| 402 | #endif |
|---|
| 403 | |
|---|
| 404 | handle = stop_service_nofree("radio_timer", handle); |
|---|
| 405 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 406 | handle = stop_service_nofree("nas", handle); |
|---|
| 407 | eval("wlconf", nvram_safe_get("wl0_ifname"), "down"); |
|---|
| 408 | eval("wlconf", nvram_safe_get("wl1_ifname"), "down"); |
|---|
| 409 | #endif |
|---|
| 410 | #ifdef HAVE_MADWIFI |
|---|
| 411 | handle = stop_service_nofree("stabridge", handle); |
|---|
| 412 | #endif |
|---|
| 413 | handle = stop_service_nofree("ttraff", handle); |
|---|
| 414 | handle = stop_service_nofree("wan", handle); |
|---|
| 415 | #ifdef HAVE_VLANTAGGING |
|---|
| 416 | handle = stop_service_nofree("bridgesif", handle); |
|---|
| 417 | handle = stop_service_nofree("vlantagging", handle); |
|---|
| 418 | #endif |
|---|
| 419 | #ifdef HAVE_BONDING |
|---|
| 420 | handle = stop_service_nofree("bonding", handle); |
|---|
| 421 | #endif |
|---|
| 422 | handle = stop_service_nofree("lan", handle); |
|---|
| 423 | #ifdef HAVE_VLANTAGGING |
|---|
| 424 | handle = stop_service_nofree("bridging", handle); |
|---|
| 425 | #endif |
|---|
| 426 | #ifdef HAVE_WIFIDOG |
|---|
| 427 | handle = startstop_nofree_f("wifidog", handle); |
|---|
| 428 | #endif |
|---|
| 429 | #ifdef HAVE_NOCAT |
|---|
| 430 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 431 | #endif |
|---|
| 432 | #ifdef HAVE_SPUTNIK_APD |
|---|
| 433 | handle = startstop_nofree_f("sputnik", handle); |
|---|
| 434 | #endif |
|---|
| 435 | #ifdef HAVE_CHILLI |
|---|
| 436 | handle = startstop_nofree_f("chilli", handle); |
|---|
| 437 | #endif |
|---|
| 438 | #ifdef HAVE_VLANTAGGING |
|---|
| 439 | handle = start_service_nofree("bridging", handle); |
|---|
| 440 | #endif |
|---|
| 441 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 442 | handle = start_service_nofree("wlconf", handle); |
|---|
| 443 | #endif |
|---|
| 444 | handle = start_service_nofree("lan", handle); |
|---|
| 445 | #ifdef HAVE_BONDING |
|---|
| 446 | handle = start_service_nofree("bonding", handle); |
|---|
| 447 | #endif |
|---|
| 448 | handle = start_service_nofree_f("wan", handle); |
|---|
| 449 | handle = start_service_nofree_f("ttraff", handle); |
|---|
| 450 | #ifdef HAVE_MADWIFI |
|---|
| 451 | handle = start_service_nofree_f("stabridge", handle); |
|---|
| 452 | #endif |
|---|
| 453 | #ifdef HAVE_VLANTAGGING |
|---|
| 454 | handle = start_service_nofree("vlantagging", handle); |
|---|
| 455 | handle = start_service_nofree("bridgesif", handle); |
|---|
| 456 | #endif |
|---|
| 457 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 458 | handle = start_service_nofree("nas", handle); |
|---|
| 459 | handle = start_service_nofree("guest_nas", handle); |
|---|
| 460 | #endif |
|---|
| 461 | handle = start_service_nofree_f("radio_timer", handle); |
|---|
| 462 | //restart dhcp as well, to fix repeater bridge save issue (dhcp disables itself here) |
|---|
| 463 | handle = startstop_nofree_f("udhcpd", handle); |
|---|
| 464 | #ifdef HAVE_DNSMASQ |
|---|
| 465 | handle = startstop_nofree_f("dnsmasq", handle); |
|---|
| 466 | #endif |
|---|
| 467 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 468 | handle = start_service_nofree("zebra", handle); |
|---|
| 469 | #endif |
|---|
| 470 | startstop_f("httpd"); // httpd will not accept connection anymore |
|---|
| 471 | |
|---|
| 472 | FORK(eval("/etc/config/http-redirect.firewall")); |
|---|
| 473 | FORK(eval("/etc/config/smtp-redirect.firewall")); |
|---|
| 474 | #ifdef HAVE_ZEROIP |
|---|
| 475 | FORK(eval("/etc/config/shat.startup")); |
|---|
| 476 | #endif |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | static void handle_services(void) |
|---|
| 480 | { |
|---|
| 481 | void *handle = NULL; |
|---|
| 482 | #ifdef HAVE_P910ND |
|---|
| 483 | handle = startstop_nofree_f("printer", handle); |
|---|
| 484 | #endif |
|---|
| 485 | #ifdef HAVE_AP_SERV |
|---|
| 486 | handle = startstop_nofree_f("apserv", handle); |
|---|
| 487 | #endif |
|---|
| 488 | #ifdef HAVE_PPPOERELAY |
|---|
| 489 | handle = startstop_nofree_f("pppoerelay", handle); |
|---|
| 490 | #endif |
|---|
| 491 | handle = startstop_nofree_f("udhcpd", handle); |
|---|
| 492 | #ifdef HAVE_SYSLOG |
|---|
| 493 | handle = startstop_nofree_f("syslog", handle); |
|---|
| 494 | #endif |
|---|
| 495 | #ifdef HAVE_RSTATS |
|---|
| 496 | handle = startstop_nofree_f("rstats", handle); |
|---|
| 497 | #endif |
|---|
| 498 | handle = startstop_nofree_f("ttraff", handle); |
|---|
| 499 | #ifdef HAVE_NSTX |
|---|
| 500 | handle = startstop_nofree_f("nstxd", handle); |
|---|
| 501 | #endif |
|---|
| 502 | #ifdef HAVE_PPPOESERVER |
|---|
| 503 | handle = startstop_nofree("firewall", handle); |
|---|
| 504 | handle = startstop_nofree_f("pppoeserver", handle); |
|---|
| 505 | #endif |
|---|
| 506 | #ifdef HAVE_DNSMASQ |
|---|
| 507 | handle = startstop_nofree_f("dnsmasq", handle); |
|---|
| 508 | #endif |
|---|
| 509 | handle = startstop_nofree_f("udhcpd", handle); |
|---|
| 510 | #ifdef HAVE_CPUTEMP |
|---|
| 511 | handle = start_service_nofree_f("hwmon", handle); |
|---|
| 512 | #endif |
|---|
| 513 | #ifdef HAVE_TELNET |
|---|
| 514 | handle = startstop_nofree_f("telnetd", handle); |
|---|
| 515 | #endif |
|---|
| 516 | #ifdef HAVE_SNMP |
|---|
| 517 | handle = startstop_nofree_f("snmp", handle); |
|---|
| 518 | #endif |
|---|
| 519 | #ifdef HAVE_OPENVPN |
|---|
| 520 | handle = startstop_nofree_f("openvpn", handle); |
|---|
| 521 | #endif |
|---|
| 522 | #ifdef HAVE_PPTPD |
|---|
| 523 | handle = startstop_nofree_f("pptpd", handle); |
|---|
| 524 | #endif |
|---|
| 525 | #ifdef HAVE_PPTP |
|---|
| 526 | FORK(eval("/etc/config/pptpd_client.startup")); |
|---|
| 527 | #endif |
|---|
| 528 | #ifdef HAVE_RFLOW |
|---|
| 529 | FORK(eval("/etc/config/rflow.startup")); |
|---|
| 530 | #endif |
|---|
| 531 | #ifdef HAVE_KAID |
|---|
| 532 | FORK(eval("/etc/config/kaid.startup")); |
|---|
| 533 | #endif |
|---|
| 534 | #ifdef HAVE_SSHD |
|---|
| 535 | #ifdef HAVE_REGISTER |
|---|
| 536 | if (isregistered_real()) |
|---|
| 537 | #endif |
|---|
| 538 | handle = startstop_nofree_f("sshd", handle); |
|---|
| 539 | #endif |
|---|
| 540 | handle = startstop_nofree("firewall", handle); |
|---|
| 541 | handle = startstop_nofree_f("wshaper", handle); |
|---|
| 542 | #ifdef HAVE_SYSLOG |
|---|
| 543 | handle = startstop_nofree_f("syslog", handle); |
|---|
| 544 | #endif |
|---|
| 545 | #ifdef HAVE_VNCREPEATER |
|---|
| 546 | handle = startstop_nofree_f("vncrepeater", handle); |
|---|
| 547 | #endif |
|---|
| 548 | #ifdef HAVE_OPENVPN |
|---|
| 549 | handle = startstop_nofree_f("openvpnserver", handle); |
|---|
| 550 | #endif |
|---|
| 551 | #ifdef HAVE_NOCAT |
|---|
| 552 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 553 | #endif |
|---|
| 554 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 555 | // if( handle ) |
|---|
| 556 | // dlclose( handle ); |
|---|
| 557 | |
|---|
| 558 | } |
|---|
| 559 | |
|---|
| 560 | static void handle_nassrv(void) |
|---|
| 561 | { |
|---|
| 562 | void *handle = NULL; |
|---|
| 563 | |
|---|
| 564 | #ifdef HAVE_FTP |
|---|
| 565 | handle = startstop_nofree_f("ftpsrv", handle); |
|---|
| 566 | #endif |
|---|
| 567 | #ifdef HAVE_SAMBA_SRV |
|---|
| 568 | handle = startstop_nofree_f("sambasrv", handle); |
|---|
| 569 | #endif |
|---|
| 570 | // if( handle ) |
|---|
| 571 | // dlclose( handle ); |
|---|
| 572 | |
|---|
| 573 | } |
|---|
| 574 | |
|---|
| 575 | static void handle_management(void) |
|---|
| 576 | { |
|---|
| 577 | void *handle = NULL; |
|---|
| 578 | |
|---|
| 579 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 580 | handle = stop_service_nofree("nas", handle); |
|---|
| 581 | #endif |
|---|
| 582 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 583 | handle = stop_service_nofree("zebra", handle); |
|---|
| 584 | #endif |
|---|
| 585 | handle = stop_service_nofree("cron", handle); |
|---|
| 586 | handle = stop_service_nofree("udhcpd", handle); |
|---|
| 587 | handle = start_service_nofree_f("udhcpd", handle); |
|---|
| 588 | handle = start_service_nofree_f("cron", handle); |
|---|
| 589 | #ifdef HAVE_IPV6 |
|---|
| 590 | eval("/etc/config/ipv6.startup"); |
|---|
| 591 | if (nvram_match("need_reboot", "1")) { |
|---|
| 592 | nvram_set("need_reboot", "0"); |
|---|
| 593 | nvram_set("need_commit", "0"); |
|---|
| 594 | nvram_commit(); |
|---|
| 595 | handle = start_service_nofree_f("ipv6", handle); |
|---|
| 596 | } |
|---|
| 597 | #endif |
|---|
| 598 | #ifdef HAVE_RADVD |
|---|
| 599 | handle = startstop_nofree_f("radvd", handle); |
|---|
| 600 | #endif |
|---|
| 601 | #ifdef HAVE_PPTPD |
|---|
| 602 | handle = startstop_nofree_f("pptpd", handle); |
|---|
| 603 | #endif |
|---|
| 604 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 605 | handle = start_service_nofree_f("zebra", handle); |
|---|
| 606 | #endif |
|---|
| 607 | handle = startstop_nofree("firewall", handle); |
|---|
| 608 | handle = stop_service_nofree("wland", handle); |
|---|
| 609 | handle = startstop_nofree_f("wshaper", handle); |
|---|
| 610 | handle = start_service_nofree_f("wland", handle); |
|---|
| 611 | handle = startstop_nofree_f("httpd", handle); |
|---|
| 612 | #ifdef HAVE_NOCAT |
|---|
| 613 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 614 | #endif |
|---|
| 615 | #ifdef HAVE_WOL |
|---|
| 616 | handle = startstop_nofree_f("wol", handle); |
|---|
| 617 | #endif |
|---|
| 618 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 619 | handle = start_service_nofree("nas", handle); |
|---|
| 620 | handle = start_service_nofree("guest_nas", handle); |
|---|
| 621 | #endif |
|---|
| 622 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 623 | |
|---|
| 624 | // if( handle ) |
|---|
| 625 | // dlclose( handle ); |
|---|
| 626 | |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | static void handle_pppoe(void) |
|---|
| 630 | { |
|---|
| 631 | unlink("/tmp/ppp/log"); |
|---|
| 632 | void *handle = NULL; |
|---|
| 633 | |
|---|
| 634 | handle = stop_service_nofree("radio_timer", handle); |
|---|
| 635 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 636 | handle = stop_service_nofree("nas", handle); |
|---|
| 637 | #endif |
|---|
| 638 | #ifdef HAVE_MADWIFI |
|---|
| 639 | handle = stop_service_nofree("stabridge", handle); |
|---|
| 640 | #endif |
|---|
| 641 | #ifdef HAVE_VLANTAGGING |
|---|
| 642 | handle = stop_service_nofree("bridgesif", handle); |
|---|
| 643 | handle = stop_service_nofree("vlantagging", handle); |
|---|
| 644 | #endif |
|---|
| 645 | handle = stop_service_nofree("lan", handle); |
|---|
| 646 | #ifdef HAVE_BONDING |
|---|
| 647 | handle = stop_service_nofree("bonding", handle); |
|---|
| 648 | #endif |
|---|
| 649 | #ifdef HAVE_VLANTAGGING |
|---|
| 650 | handle = stop_service_nofree("bridging", handle); |
|---|
| 651 | #endif |
|---|
| 652 | handle = stop_service_nofree("ttraff", handle); |
|---|
| 653 | handle = stop_service_nofree("wan", handle); |
|---|
| 654 | #ifdef HAVE_VLANTAGGING |
|---|
| 655 | handle = start_service_nofree("bridging", handle); |
|---|
| 656 | #endif |
|---|
| 657 | handle = start_service_nofree("lan", handle); |
|---|
| 658 | #ifdef HAVE_BONDING |
|---|
| 659 | handle = start_service_nofree("bonding", handle); |
|---|
| 660 | #endif |
|---|
| 661 | handle = start_service_nofree("wan_boot", handle); |
|---|
| 662 | handle = start_service_nofree_f("ttraff", handle); |
|---|
| 663 | #ifdef HAVE_MADWIFI |
|---|
| 664 | handle = start_service_nofree_f("stabridge", handle); |
|---|
| 665 | #endif |
|---|
| 666 | #ifdef HAVE_VLANTAGGING |
|---|
| 667 | handle = start_service_nofree("vlantagging", handle); |
|---|
| 668 | handle = start_service_nofree("bridgesif", handle); |
|---|
| 669 | #endif |
|---|
| 670 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 671 | handle = start_service_nofree("nas", handle); |
|---|
| 672 | handle = start_service_nofree("guest_nas", handle); |
|---|
| 673 | #endif |
|---|
| 674 | handle = start_service_nofree_f("radio_timer", handle); |
|---|
| 675 | // if( handle ) |
|---|
| 676 | // dlclose( handle ); |
|---|
| 677 | |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | static void handle_spppoe(void) |
|---|
| 681 | { |
|---|
| 682 | stop_service_f("ttraff"); |
|---|
| 683 | stop_service_f("wan"); |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | static void handle_filters(void) |
|---|
| 687 | { |
|---|
| 688 | void *handle = NULL; |
|---|
| 689 | |
|---|
| 690 | handle = stop_service_nofree("cron", handle); |
|---|
| 691 | handle = startstop_nofree("firewall", handle); |
|---|
| 692 | #ifdef HAVE_SYSLOG |
|---|
| 693 | handle = startstop_nofree_f("syslog", handle); |
|---|
| 694 | #endif |
|---|
| 695 | handle = stop_service_nofree("wland", handle); |
|---|
| 696 | handle = startstop_nofree_f("wshaper", handle); |
|---|
| 697 | handle = start_service_nofree_f("wland", handle); |
|---|
| 698 | handle = start_service_nofree_f("cron", handle); |
|---|
| 699 | #ifdef HAVE_NOCAT |
|---|
| 700 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 701 | #endif |
|---|
| 702 | #ifdef HAVE_MULTICAST |
|---|
| 703 | handle = startstop_nofree_f("igmp_proxy", handle); |
|---|
| 704 | #endif |
|---|
| 705 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 706 | // if( handle ) |
|---|
| 707 | // dlclose( handle ); |
|---|
| 708 | } |
|---|
| 709 | |
|---|
| 710 | static void handle_routing(void) |
|---|
| 711 | { |
|---|
| 712 | void *handle = NULL; |
|---|
| 713 | |
|---|
| 714 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 715 | handle = stop_service_nofree("zebra", handle); |
|---|
| 716 | #endif |
|---|
| 717 | handle = startstop_nofree("firewall", handle); |
|---|
| 718 | handle = start_service_nofree_f("set_routes", handle); |
|---|
| 719 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 720 | handle = start_service_nofree_f("zebra", handle); |
|---|
| 721 | #endif |
|---|
| 722 | #ifdef HAVE_OLSRD |
|---|
| 723 | handle = startstop_nofree_f("olsrd", handle); |
|---|
| 724 | #endif |
|---|
| 725 | #ifdef HAVE_NOCAT |
|---|
| 726 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 727 | #endif |
|---|
| 728 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 729 | // if( handle ) |
|---|
| 730 | // dlclose( handle ); |
|---|
| 731 | |
|---|
| 732 | } |
|---|
| 733 | |
|---|
| 734 | static void handle_alive(void) |
|---|
| 735 | { |
|---|
| 736 | void *handle = NULL; |
|---|
| 737 | |
|---|
| 738 | handle = stop_service_nofree("cron", handle); |
|---|
| 739 | #ifdef HAVE_REGISTER |
|---|
| 740 | if (isregistered_real()) |
|---|
| 741 | #endif |
|---|
| 742 | { |
|---|
| 743 | FORK(eval("/etc/config/wdswatchdog.startup")); |
|---|
| 744 | FORK(eval("/etc/config/schedulerb.startup")); |
|---|
| 745 | FORK(eval("/etc/config/proxywatchdog.startup")); |
|---|
| 746 | } |
|---|
| 747 | handle = start_service_nofree_f("cron", handle); |
|---|
| 748 | // if( handle ) |
|---|
| 749 | // dlclose( handle ); |
|---|
| 750 | } |
|---|
| 751 | |
|---|
| 752 | static void handle_forward(void) |
|---|
| 753 | { |
|---|
| 754 | void *handle = NULL; |
|---|
| 755 | |
|---|
| 756 | handle = stop_service_nofree("wland", handle); |
|---|
| 757 | handle = stop_service_nofree("wshaper", handle); |
|---|
| 758 | #ifdef HAVE_UPNP |
|---|
| 759 | // handle = stop_service_nofree( "upnp", handle ); |
|---|
| 760 | #endif |
|---|
| 761 | handle = startstop_nofree("firewall", handle); |
|---|
| 762 | #ifdef HAVE_UPNP |
|---|
| 763 | // handle = start_service_nofree( "upnp", handle ); |
|---|
| 764 | #endif |
|---|
| 765 | handle = start_service_nofree_f("wshaper", handle); |
|---|
| 766 | handle = start_service_nofree_f("wland", handle); |
|---|
| 767 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 768 | #ifdef HAVE_NOCAT |
|---|
| 769 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 770 | #endif |
|---|
| 771 | // if( handle ) |
|---|
| 772 | // dlclose( handle ); |
|---|
| 773 | |
|---|
| 774 | } |
|---|
| 775 | |
|---|
| 776 | static void handle_qos(void) |
|---|
| 777 | { |
|---|
| 778 | void *handle = NULL; |
|---|
| 779 | |
|---|
| 780 | startstop_f("wshaper"); |
|---|
| 781 | startstop_f("wland"); |
|---|
| 782 | #ifdef HAVE_NOCAT |
|---|
| 783 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 784 | #endif |
|---|
| 785 | // if( handle ) |
|---|
| 786 | // dlclose( handle ); |
|---|
| 787 | } |
|---|
| 788 | |
|---|
| 789 | static void handle_forwardupnp(void) |
|---|
| 790 | { |
|---|
| 791 | void *handle = NULL; |
|---|
| 792 | |
|---|
| 793 | #ifdef HAVE_UPNP |
|---|
| 794 | handle = stop_service_nofree("upnp", handle); |
|---|
| 795 | #endif |
|---|
| 796 | handle = startstop_nofree("firewall", handle); |
|---|
| 797 | #ifdef HAVE_UPNP |
|---|
| 798 | handle = start_service_nofree_f("upnp", handle); |
|---|
| 799 | #endif |
|---|
| 800 | handle = stop_service_nofree("wland", handle); |
|---|
| 801 | handle = startstop_nofree_f("wshaper", handle); |
|---|
| 802 | handle = start_service_nofree_f("wland", handle); |
|---|
| 803 | handle = start_service_nofree_f("anchorfreednat", handle); |
|---|
| 804 | #ifdef HAVE_NOCAT |
|---|
| 805 | handle = startstop_nofree_f("splashd", handle); |
|---|
| 806 | #endif |
|---|
| 807 | // if( handle ) |
|---|
| 808 | // dlclose( handle ); |
|---|
| 809 | |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | static void handle_routedel(void) |
|---|
| 813 | { |
|---|
| 814 | del_routes(nvram_safe_get("action_service_arg1")); |
|---|
| 815 | |
|---|
| 816 | } |
|---|
| 817 | |
|---|
| 818 | struct SERVICES { |
|---|
| 819 | char *servicename; |
|---|
| 820 | void (*service) (void); |
|---|
| 821 | }; |
|---|
| 822 | |
|---|
| 823 | static void handle_ddns(void) |
|---|
| 824 | { |
|---|
| 825 | startstop("ddns"); |
|---|
| 826 | nvram_set("ddns_change", "update"); |
|---|
| 827 | |
|---|
| 828 | } |
|---|
| 829 | |
|---|
| 830 | #ifdef HAVE_FREERADIUS |
|---|
| 831 | |
|---|
| 832 | static void handle_freeradius(void) |
|---|
| 833 | { |
|---|
| 834 | startstop_f("freeradius"); |
|---|
| 835 | } |
|---|
| 836 | #endif |
|---|
| 837 | |
|---|
| 838 | /* |
|---|
| 839 | * static void handle_ping (void) { char *ip = nvram_safe_get ("ping_ip"); // |
|---|
| 840 | * use Ping.asp as a debugging console char cmd[256] = { 0 }; //snprintf |
|---|
| 841 | * (cmd, sizeof (cmd), "%s > %s 2>&1 &", ip, PING_TMP); setenv ("PATH", |
|---|
| 842 | * "/sbin:/bin:/usr/sbin:/usr/bin", 1); // snprintf (cmd, sizeof (cmd), "%s |
|---|
| 843 | * 2>&1 &", ip); // system (cmd); |
|---|
| 844 | * |
|---|
| 845 | * snprintf (cmd, sizeof (cmd), "alias ping=\'ping -c 3\'; eval \"%s\" > %s |
|---|
| 846 | * 2>&1 &", ip, PING_TMP); system (cmd); |
|---|
| 847 | * |
|---|
| 848 | * } |
|---|
| 849 | */ |
|---|
| 850 | |
|---|
| 851 | static void handle_upgrade(void) |
|---|
| 852 | { |
|---|
| 853 | void *handle = NULL; |
|---|
| 854 | |
|---|
| 855 | handle = stop_service_nofree("ttraff", handle); |
|---|
| 856 | handle = stop_service_nofree("wan", handle); |
|---|
| 857 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 858 | handle = stop_service_nofree("zebra", handle); |
|---|
| 859 | #endif |
|---|
| 860 | #ifdef HAVE_OLSRD |
|---|
| 861 | handle = stop_service_nofree("olsrd", handle); |
|---|
| 862 | #endif |
|---|
| 863 | #ifdef HAVE_UPNP |
|---|
| 864 | handle = stop_service_nofree("upnp", handle); |
|---|
| 865 | #endif |
|---|
| 866 | handle = stop_service_nofree("cron", handle); |
|---|
| 867 | // if( handle ) |
|---|
| 868 | // dlclose( handle ); |
|---|
| 869 | |
|---|
| 870 | } |
|---|
| 871 | |
|---|
| 872 | #ifdef HAVE_MILKFISH |
|---|
| 873 | static void handle_milkfish(void) |
|---|
| 874 | { |
|---|
| 875 | startstop("milkfish"); |
|---|
| 876 | } |
|---|
| 877 | #endif |
|---|
| 878 | |
|---|
| 879 | static void handle_wireless(void) |
|---|
| 880 | { |
|---|
| 881 | void *handle = NULL; |
|---|
| 882 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 883 | handle = stop_service_nofree("zebra", handle); |
|---|
| 884 | #endif |
|---|
| 885 | |
|---|
| 886 | handle = stop_service_nofree("radio_timer", handle); |
|---|
| 887 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 888 | handle = stop_service_nofree("nas", handle); |
|---|
| 889 | eval("wlconf", nvram_safe_get("wl0_ifname"), "down"); |
|---|
| 890 | eval("wlconf", nvram_safe_get("wl1_ifname"), "down"); |
|---|
| 891 | #endif |
|---|
| 892 | #ifdef HAVE_MADWIFI |
|---|
| 893 | handle = stop_service_nofree("stabridge", handle); |
|---|
| 894 | #endif |
|---|
| 895 | handle = stop_service_nofree("ttraff", handle); |
|---|
| 896 | handle = stop_service_nofree("wan", handle); |
|---|
| 897 | #ifdef HAVE_VLANTAGGING |
|---|
| 898 | handle = stop_service_nofree("bridgesif", handle); |
|---|
| 899 | handle = stop_service_nofree("vlantagging", handle); |
|---|
| 900 | #endif |
|---|
| 901 | #ifdef HAVE_BONDING |
|---|
| 902 | handle = stop_service_nofree("bonding", handle); |
|---|
| 903 | #endif |
|---|
| 904 | handle = stop_service_nofree("lan", handle); |
|---|
| 905 | #ifdef HAVE_VLANTAGGING |
|---|
| 906 | handle = stop_service_nofree("bridging", handle); |
|---|
| 907 | #endif |
|---|
| 908 | #ifdef HAVE_VLANTAGGING |
|---|
| 909 | handle = start_service_nofree("bridging", handle); |
|---|
| 910 | #endif |
|---|
| 911 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 912 | handle = start_service_nofree("wlconf", handle); |
|---|
| 913 | #endif |
|---|
| 914 | handle = start_service_nofree("lan", handle); |
|---|
| 915 | #ifdef HAVE_BONDING |
|---|
| 916 | handle = start_service_nofree("bonding", handle); |
|---|
| 917 | #endif |
|---|
| 918 | handle = start_service_nofree_f("wan", handle); |
|---|
| 919 | handle = start_service_nofree_f("ttraff", handle); |
|---|
| 920 | #ifdef HAVE_MADWIFI |
|---|
| 921 | handle = start_service_nofree_f("stabridge", handle); |
|---|
| 922 | #endif |
|---|
| 923 | #ifdef HAVE_VLANTAGGING |
|---|
| 924 | handle = start_service_nofree("vlantagging", handle); |
|---|
| 925 | handle = start_service_nofree("bridgesif", handle); |
|---|
| 926 | #endif |
|---|
| 927 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 928 | handle = start_service_nofree("nas", handle); |
|---|
| 929 | handle = start_service_nofree("guest_nas", handle); |
|---|
| 930 | #endif |
|---|
| 931 | handle = start_service_nofree_f("radio_timer", handle); |
|---|
| 932 | //restart dhcp as well, to fix repeater bridge save issue (dhcp disables itself here) |
|---|
| 933 | handle = startstop_nofree_f("udhcpd", handle); |
|---|
| 934 | #ifdef HAVE_DNSMASQ |
|---|
| 935 | handle = startstop_nofree_f("dnsmasq", handle); |
|---|
| 936 | #endif |
|---|
| 937 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 938 | handle = start_service_nofree("zebra", handle); |
|---|
| 939 | #endif |
|---|
| 940 | startstop_f("httpd"); // httpd will not accept connection anymore |
|---|
| 941 | // on wan/lan ip changes changes |
|---|
| 942 | // if( handle ) |
|---|
| 943 | // dlclose( handle ); |
|---|
| 944 | |
|---|
| 945 | } |
|---|
| 946 | |
|---|
| 947 | static void handle_wireless_2(void) |
|---|
| 948 | { |
|---|
| 949 | void *handle = NULL; |
|---|
| 950 | |
|---|
| 951 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 952 | handle = stop_service_nofree("zebra", handle); |
|---|
| 953 | #endif |
|---|
| 954 | |
|---|
| 955 | handle = stop_service_nofree("radio_timer", handle); |
|---|
| 956 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 957 | handle = stop_service_nofree("nas", handle); |
|---|
| 958 | eval("wlconf", nvram_safe_get("wl0_ifname"), "down"); |
|---|
| 959 | eval("wlconf", nvram_safe_get("wl1_ifname"), "down"); |
|---|
| 960 | #endif |
|---|
| 961 | #ifdef HAVE_MADWIFI |
|---|
| 962 | handle = stop_service_nofree("stabridge", handle); |
|---|
| 963 | #endif |
|---|
| 964 | if (getSTA() || getWET()) { |
|---|
| 965 | handle = stop_service_nofree("ttraff", handle); |
|---|
| 966 | handle = stop_service_nofree("wan", handle); |
|---|
| 967 | } |
|---|
| 968 | #ifdef HAVE_VLANTAGGING |
|---|
| 969 | handle = stop_service_nofree("bridgesif", handle); |
|---|
| 970 | handle = stop_service_nofree("vlantagging", handle); |
|---|
| 971 | #endif |
|---|
| 972 | #ifdef HAVE_BONDING |
|---|
| 973 | handle = stop_service_nofree("bonding", handle); |
|---|
| 974 | #endif |
|---|
| 975 | handle = stop_service_nofree("lan", handle); |
|---|
| 976 | #ifdef HAVE_VLANTAGGING |
|---|
| 977 | handle = stop_service_nofree("bridging", handle); |
|---|
| 978 | #endif |
|---|
| 979 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 980 | handle = start_service_nofree("wlconf", handle); |
|---|
| 981 | #endif |
|---|
| 982 | #ifdef HAVE_VLANTAGGING |
|---|
| 983 | handle = start_service_nofree("bridging", handle); |
|---|
| 984 | #endif |
|---|
| 985 | handle = start_service_nofree("lan", handle); |
|---|
| 986 | #ifdef HAVE_BONDING |
|---|
| 987 | handle = start_service_nofree("bonding", handle); |
|---|
| 988 | #endif |
|---|
| 989 | if (getSTA() || getWET()) // since we need to cover apstawet, |
|---|
| 990 | // we must use getWET as well |
|---|
| 991 | { |
|---|
| 992 | handle = start_service_nofree_f("wan", handle); |
|---|
| 993 | handle = start_service_nofree_f("ttraff", handle); |
|---|
| 994 | } |
|---|
| 995 | #ifdef HAVE_MADWIFI |
|---|
| 996 | handle = start_service_nofree_f("stabridge", handle); |
|---|
| 997 | #endif |
|---|
| 998 | #ifdef HAVE_VLANTAGGING |
|---|
| 999 | handle = start_service_nofree("vlantagging", handle); |
|---|
| 1000 | handle = start_service_nofree("bridgesif", handle); |
|---|
| 1001 | #endif |
|---|
| 1002 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 1003 | handle = start_service_nofree("nas", handle); |
|---|
| 1004 | handle = start_service_nofree("guest_nas", handle); |
|---|
| 1005 | #endif |
|---|
| 1006 | handle = start_service_nofree_f("radio_timer", handle); |
|---|
| 1007 | if (getSTA() || getWET()) |
|---|
| 1008 | startstop_f("httpd"); // httpd will not accept connection anymore |
|---|
| 1009 | // on wan/lan ip changes changes |
|---|
| 1010 | #ifdef HAVE_MADWIFI |
|---|
| 1011 | handle = start_service_nofree_f("hostapdwan", handle); |
|---|
| 1012 | #endif |
|---|
| 1013 | #if defined(HAVE_BIRD) || defined(HAVE_QUAGGA) |
|---|
| 1014 | handle = start_service_nofree_f("zebra", handle); |
|---|
| 1015 | #endif |
|---|
| 1016 | // if( handle ) |
|---|
| 1017 | // dlclose( handle ); |
|---|
| 1018 | |
|---|
| 1019 | } |
|---|
| 1020 | |
|---|
| 1021 | static void handle_dhcp_release(void) |
|---|
| 1022 | { |
|---|
| 1023 | killall("udhcpc", SIGUSR2); |
|---|
| 1024 | sleep(1); |
|---|
| 1025 | |
|---|
| 1026 | } |
|---|
| 1027 | |
|---|
| 1028 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 1029 | static void handle_eop(void) |
|---|
| 1030 | { |
|---|
| 1031 | FORK(eval("/etc/config/eop-tunnel.startup")); |
|---|
| 1032 | FORK(eval("/etc/config/eop-tunnel.firewall")); |
|---|
| 1033 | |
|---|
| 1034 | } |
|---|
| 1035 | #endif |
|---|
| 1036 | static struct SERVICES services_def[] = { |
|---|
| 1037 | {"dhcp", handle_dhcpd}, |
|---|
| 1038 | {"index", handle_index}, |
|---|
| 1039 | {"router", handle_router}, |
|---|
| 1040 | {"hotspot", handle_hotspot}, |
|---|
| 1041 | {"anchorfree", handle_anchorfree}, |
|---|
| 1042 | {"services", handle_services}, |
|---|
| 1043 | #if defined(HAVE_FTP) || defined(HAVE_SAMBA_SRV) |
|---|
| 1044 | {"nassrv", handle_nassrv}, |
|---|
| 1045 | #endif |
|---|
| 1046 | {"management", handle_management}, |
|---|
| 1047 | #ifdef HAVE_3G |
|---|
| 1048 | {"start_3g", handle_pppoe}, |
|---|
| 1049 | {"stop_3g", handle_spppoe}, |
|---|
| 1050 | #endif |
|---|
| 1051 | {"start_pppoe", handle_pppoe}, |
|---|
| 1052 | {"start_pptp", handle_pppoe}, |
|---|
| 1053 | #ifdef HAVE_L2TP |
|---|
| 1054 | {"start_l2tp", handle_pppoe}, |
|---|
| 1055 | #endif |
|---|
| 1056 | #ifdef HAVE_FREERADIUS |
|---|
| 1057 | {"freeradius", handle_freeradius}, |
|---|
| 1058 | #endif |
|---|
| 1059 | #ifdef HAVE_HEARTBEAT |
|---|
| 1060 | {"start_heartbeat", handle_pppoe}, |
|---|
| 1061 | #endif |
|---|
| 1062 | {"stop_pppoe", handle_spppoe}, |
|---|
| 1063 | {"stop_pptp", handle_spppoe}, |
|---|
| 1064 | #ifdef HAVE_L2TP |
|---|
| 1065 | {"stop_l2tp", handle_spppoe}, |
|---|
| 1066 | #endif |
|---|
| 1067 | #ifdef HAVE_HEARTBEAT |
|---|
| 1068 | {"stop_heartbeat", handle_spppoe}, |
|---|
| 1069 | #endif |
|---|
| 1070 | {"filters", handle_filters}, |
|---|
| 1071 | {"routing", handle_routing}, |
|---|
| 1072 | {"alive", handle_alive}, |
|---|
| 1073 | {"forward", handle_forward}, |
|---|
| 1074 | {"qos", handle_qos}, |
|---|
| 1075 | {"forward_upnp", handle_forwardupnp}, |
|---|
| 1076 | {"static_route_del", handle_routedel}, |
|---|
| 1077 | {"ddns", handle_ddns}, |
|---|
| 1078 | // {"start_ping", handle_ping}, |
|---|
| 1079 | {"http_upgrade", handle_upgrade}, |
|---|
| 1080 | #ifdef HAVE_MILKFISH |
|---|
| 1081 | {"milkfish", handle_milkfish}, |
|---|
| 1082 | #endif |
|---|
| 1083 | {"wireless", handle_wireless}, |
|---|
| 1084 | {"wireless_2", handle_wireless_2}, |
|---|
| 1085 | {"dhcp_release", handle_dhcp_release}, |
|---|
| 1086 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 1087 | {"eop", handle_eop}, |
|---|
| 1088 | #endif |
|---|
| 1089 | {NULL, NULL} |
|---|
| 1090 | }; |
|---|
| 1091 | |
|---|
| 1092 | int start_single_service_main(int argc, char **argv) |
|---|
| 1093 | { |
|---|
| 1094 | |
|---|
| 1095 | sleep(3); |
|---|
| 1096 | start_service("overclocking"); |
|---|
| 1097 | char *next; |
|---|
| 1098 | char service[80]; |
|---|
| 1099 | char *services = nvram_safe_get("action_service"); |
|---|
| 1100 | |
|---|
| 1101 | foreach(service, services, next) { |
|---|
| 1102 | #ifdef HAVE_OLED |
|---|
| 1103 | char message[32]; |
|---|
| 1104 | sprintf(message, "restart: %s", service); |
|---|
| 1105 | lcdmessage(message); |
|---|
| 1106 | #endif |
|---|
| 1107 | cprintf("Restart service=[%s]\n", service); |
|---|
| 1108 | int servicecount = 0; |
|---|
| 1109 | |
|---|
| 1110 | while (services_def[servicecount].servicename != NULL) { |
|---|
| 1111 | if (!strcmp |
|---|
| 1112 | (services_def[servicecount].servicename, service)) |
|---|
| 1113 | services_def[servicecount].service(); |
|---|
| 1114 | servicecount++; |
|---|
| 1115 | } |
|---|
| 1116 | } |
|---|
| 1117 | lcdmessage(""); |
|---|
| 1118 | |
|---|
| 1119 | nvram_unset("action_service"); |
|---|
| 1120 | nvram_unset("action_service_arg1"); |
|---|
| 1121 | return 0; |
|---|
| 1122 | } |
|---|
| 1123 | |
|---|
| 1124 | int is_running(char *process_name) |
|---|
| 1125 | { |
|---|
| 1126 | DIR *dir; |
|---|
| 1127 | struct dirent *next; |
|---|
| 1128 | int retval = 0; |
|---|
| 1129 | |
|---|
| 1130 | dir = opendir("/proc"); |
|---|
| 1131 | if (!dir) { |
|---|
| 1132 | perror("Cannot open /proc"); |
|---|
| 1133 | return 0; |
|---|
| 1134 | } |
|---|
| 1135 | |
|---|
| 1136 | while ((next = readdir(dir)) != NULL) { |
|---|
| 1137 | FILE *status; |
|---|
| 1138 | char filename[100]; |
|---|
| 1139 | char buffer[100]; |
|---|
| 1140 | char name[100]; |
|---|
| 1141 | |
|---|
| 1142 | if (strcmp(next->d_name, "..") == 0) |
|---|
| 1143 | continue; |
|---|
| 1144 | if (!isdigit(*next->d_name)) |
|---|
| 1145 | continue; |
|---|
| 1146 | |
|---|
| 1147 | sprintf(filename, "/proc/%s/status", next->d_name); |
|---|
| 1148 | |
|---|
| 1149 | if (!(status = fopen(filename, "r"))) |
|---|
| 1150 | continue; |
|---|
| 1151 | |
|---|
| 1152 | if (fgets(buffer, 99, status) == NULL) { |
|---|
| 1153 | fclose(status); |
|---|
| 1154 | continue; |
|---|
| 1155 | } |
|---|
| 1156 | fclose(status); |
|---|
| 1157 | |
|---|
| 1158 | sscanf(buffer, "%*s %s", name); |
|---|
| 1159 | |
|---|
| 1160 | if (strcmp(name, process_name) == 0) |
|---|
| 1161 | retval++; |
|---|
| 1162 | } |
|---|
| 1163 | |
|---|
| 1164 | closedir(dir); |
|---|
| 1165 | return retval; |
|---|
| 1166 | } |
|---|