NET if_getbypio(void * pio) { char * name; name = nextarg(((GEN_IO)pio)->inbuf); return(if_getbyname(name)); }
/* FUNCTION: netdiag_arp() * * Display ARP table and statistics * * PARAM1: CLI_CTX CLI context * * RETURNS: int 0 if successful, otherwise error code * * arp [-z STRING] */ STATIC int netdiag_arp(CLI_CTX ctx) { GIO *gio = ctx->gio; int err = 0; if (!CLI_HELP(ctx)) { #ifndef MINI_IP struct cli_addr ipaddr = { 0 }; NET ifp = (NET)NULL; if (CLI_DEFINED(ctx, 'z')) { char *str = (char *)CLI_PARAM(ctx, 'z'); char *endp = (char *)NULL; if (isdigit(str[0])) { if ((cli_parse_ipaddr(str, &endp, CLI_IPV4, &ipaddr) != 0) || (ipaddr.type != CLI_IPV4)) { err = CLI_ERR_PARAM; /* not an IPv4 address */ } } else if (stricmp(str, "all") == 0) { gio_printf(gio, "'all' is not yet supported\n"); err = CLI_ERR_PARAM; } else { if ((ifp = if_getbyname(str)) == (NET)NULL) { err = CLI_ERR_PARAM; /* interface not found */ } } } #endif /* !MINI_IP */ if (err != 0) { gio_printf(gio, "illegal IPv4 address or network interface name.\n"); } else { /* display ARP statistics */ arp_stats(gio); #ifndef MINI_IP if (CLI_DEFINED(ctx, 'z')) { /* clear entry(s) associated with this IP or NI */ clear_arp_entries(*(ip_addr *)&ipaddr.addr, ifp); } #endif /* !MINI_IP */ } } return (err); }