int upnp_restart(void * pio) { char * cp; NET ifp; int iface; cp = nextarg( ((GEN_IO)pio)->inbuf ); if(!*cp) { ns_printf(pio, "please enter iface to restart UPnP\n"); return -1; } ifp = if_netbytext(pio, cp); if(ifp == NULL) /* error parsing iface name/number text? */ return -1; iface = if_netnumber(ifp); /* skip the DHCP step and go right to autoIP */ upnp[iface].state = UPNP_START; upnp[iface].ip_method = eIP_METHOD_AUTO_FIXED; autoIPs[iface].state = AUTOIP_START; autoIPs[iface].response_timer = 0; autoIPs[iface].arp_attempts = 0; ns_printf(pio, "(re)started UPnP in iface %s\n", ifp->name); return 0; }
int iface_stats(void * pio) { char * cp; struct net * ifp; ifp = (NET)(netlist.q_head); /* default to first net */ cp = nextarg(((GEN_IO)pio)->inbuf); /* get console arg */ if(cp && *cp) /* arg is present on command line */ { ifp = if_netbytext(pio, cp); if(ifp == NULL) /* error parsing iface name/number text? */ return -1; } ifstats(pio, ifp); return 0; }
int upnp_db(void * pio) { char * cp; NET ifp; int iface; ip_addr addr; ip_addr mask; ip_addr gateway; cp = nextarg( ((GEN_IO)pio)->inbuf ); if(!*cp) { ns_printf(pio, "please enter iface for database dump\n"); return -1; } ifp = if_netbytext(pio, cp); if(ifp == NULL) /* error parsing iface name/number text? */ return -1; iface = if_netnumber(ifp); /* Get the fixed IP info from database into tmp vars */ DS_get_long(tag_NET_FIXED_IP, iface, &addr); DS_get_long(tag_NET_FIXED_SUBNET, iface, &mask); DS_get_long(tag_NET_FIXED_GATEWAY, iface, &gateway); ns_printf(pio, "iface:%s; ", ifp->name); ns_printf(pio, " Fixed IP: %u.%u.%u.%u", PUSH_IPADDR(addr) ); ns_printf(pio, " mask: %u.%u.%u.%u", PUSH_IPADDR(mask) ); ns_printf(pio, " gateway: %u.%u.%u.%u\n", PUSH_IPADDR(gateway) ); /* Get the current IP info from database into tmp vars */ DS_get_long(tag_NET_IP_ADDRESS, iface, &addr); DS_get_long(tag_NET_SUBNET, iface, &mask); DS_get_long(tag_NET_GATEWAY, iface, &gateway); ns_printf(pio, "Current ip: %u.%u.%u.%u", PUSH_IPADDR(addr)); ns_printf(pio, " mask: %u.%u.%u.%u", PUSH_IPADDR(mask)); ns_printf(pio, " gateway: %u.%u.%u.%u\n", PUSH_IPADDR(gateway)); return 0; }
int upnp_disable(void * pio) { char * cp; NET ifp; int iface; cp = nextarg( ((GEN_IO)pio)->inbuf ); if(!*cp) { ns_printf(pio, "please enter iface to disable UPnP\n"); return -1; } ifp = if_netbytext(pio, cp); if(ifp == NULL) /* error parsing iface name/number text? */ return -1; iface = if_netnumber(ifp); upnp[iface].state = UPNP_DISABLED; ns_printf(pio, "Disabled UPnP in iface %s\n", ifp->name); return 0; }
int send_grat_arp(void * pio) { char * cp; struct net * ifp; int flag; ifp = (NET)(netlist.q_head); /* default to first net */ cp = nextarg(((GEN_IO)pio)->inbuf); /* get console arg */ if(cp && *cp) /* arg is present on command line */ { if (*cp == 'a') flag = 0; else if (*cp == 'r') flag = 1; else { ns_printf(pio,"USAGE: sendarp (a|r) [net]\n"); return 0; } } cp = nextarg(cp); /* get console arg */ if(cp && *cp) /* arg is present on command line */ { ifp = if_netbytext(pio, cp); if(ifp == NULL) /* error parsing iface name/number text? */ return -1; } grat_arp(ifp, flag); return 0; }