int launch_wan_usbnet(int unit) { int modem_devnum = 0; char ndis_ifname[16] = {0}; if (get_modem_ndis_ifname(ndis_ifname, &modem_devnum) && is_interface_exist(ndis_ifname)) { int ndis_mtu = nvram_safe_get_int("modem_mtu", 1500, 1000, 1500); check_upnp_wanif_changed(ndis_ifname); set_wan_unit_value(unit, "proto_t", "NDIS Modem"); set_wan_unit_value(unit, "ifname_t", ndis_ifname); /* bring up NDIS interface */ doSystem("ifconfig %s mtu %d up %s", ndis_ifname, ndis_mtu, "0.0.0.0"); /* re-build iptables rules (first stage w/o WAN IP) */ start_firewall_ex(); if (ndis_control_network(ndis_ifname, modem_devnum, 1) == 0) sleep(1); start_udhcpc_wan(ndis_ifname, unit, 0); return 0; } set_wan_unit_value(unit, "ifname_t", ""); return -1; }
void stop_modem_ndis(void) { int i, modem_devnum = 0; char node_fname[64]; char ndis_ifname[16] = {0}; system("killall -q usb_modeswitch"); system("killall -q eject"); if (get_modem_ndis_ifname(ndis_ifname, &modem_devnum)) { disconnect_ndis(modem_devnum); if (is_interface_exist(ndis_ifname)) ifconfig(ndis_ifname, 0, "0.0.0.0", NULL); } for (i=0; i<MAX_USB_NODE; i++) { sprintf(node_fname, "%s/ttyUSB%d", MODEM_NODE_DIR, i); unlink(node_fname); sprintf(node_fname, "%s/cdc-wdm%d", MODEM_NODE_DIR, i); unlink(node_fname); sprintf(node_fname, "%s/weth%d", MODEM_NODE_DIR, i); unlink(node_fname); sprintf(node_fname, "%s/wwan%d", MODEM_NODE_DIR, i); unlink(node_fname); } }
static int is_ready_modem_ndis(int *devnum_out) { char ndis_ifname[16]; if (get_modem_ndis_ifname(ndis_ifname, devnum_out) && is_interface_exist(ndis_ifname)) return 1; return 0; }
void stop_wan_usbnet(void) { int modem_devnum = 0; char ndis_ifname[16] = {0}; if (get_modem_ndis_ifname(ndis_ifname, &modem_devnum)) { ndis_control_network(ndis_ifname, modem_devnum, 0); if (is_interface_exist(ndis_ifname)) ifconfig(ndis_ifname, 0, "0.0.0.0", NULL); } }