From: Roland McGrath Date: Mon, 12 Jul 2004 07:13:06 +0000 (+0000) Subject: 2004-07-12 Roland McGrath X-Git-Tag: v4.5.18~559 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5687ff1ca7b4a284c0638fc4bf14fa6c76e04fc9;p=strace 2004-07-12 Roland McGrath * net.c (addrfams): Make variable global. * sock.c (sock_ioctl): Decode the arguments for SIOCGIFNAME, SIOCGIFINDEX, and SIOCGIFCONF. From Ulrich Drepper . Fixes RH#126917. --- diff --git a/net.c b/net.c index 3c23b417..206518f8 100644 --- a/net.c +++ b/net.c @@ -218,7 +218,7 @@ static struct xlat domains[] = { #endif { 0, NULL }, }; -static struct xlat addrfams[] = { +struct xlat addrfams[] = { #ifdef AF_APPLETALK { AF_APPLETALK, "AF_APPLETALK" }, #endif diff --git a/sock.c b/sock.c index 7d1f244a..412577a2 100644 --- a/sock.c +++ b/sock.c @@ -31,9 +31,11 @@ #ifdef LINUX #include +#include #else #include #endif +#include #if defined (ALPHA) || defined(SH) || defined(SH64) #ifdef HAVE_SYS_IOCTL_H @@ -42,14 +44,28 @@ #include #endif #endif +#include + +extern struct xlat addrfams[]; int sock_ioctl(tcp, code, arg) struct tcb *tcp; long code, arg; { - if (entering(tcp)) + struct ifreq ifr; + struct ifconf ifc; + + if (entering(tcp)) { + if (code == SIOCGIFCONF) { + umove(tcp, tcp->u_arg[2], &ifc); + if (ifc.ifc_buf == NULL) + tprintf(", {%d -> ", ifc.ifc_len); + else + tprintf(", {"); + } return 0; + } switch (code) { #ifdef SIOCSHIWAT @@ -81,6 +97,61 @@ long code, arg; #endif printnum(tcp, arg, ", %#d"); return 1; +#ifdef LINUX + case SIOCGIFNAME: + case SIOCGIFINDEX: + umove(tcp, tcp->u_arg[2], &ifr); + if (syserror(tcp)) { + if (code == SIOCGIFNAME) + tprintf(", {%d, ???}", ifr.ifr_ifindex); + else if (code == SIOCGIFINDEX) + tprintf(", {???, \"%s\"}", ifr.ifr_name); + } else + tprintf(", {%d, \"%s\"}", + ifr.ifr_ifindex, ifr.ifr_name); + return 1; + case SIOCGIFCONF: + umove(tcp, tcp->u_arg[2], &ifc); + tprintf("%d, ", ifc.ifc_len); + if (syserror(tcp)) { + tprintf("%lx", (unsigned long) ifc.ifc_buf); + } else if (ifc.ifc_buf == NULL) { + tprintf("NULL"); + } else { + int i; + unsigned nifra = ifc.ifc_len / sizeof(struct ifreq); + struct ifreq ifra[nifra]; + umoven(tcp, (unsigned long) ifc.ifc_buf, sizeof(ifra), + (char *) ifra); + tprintf("{"); + for (i = 0; i < nifra; ++i ) { + if (i > 0) + tprintf(", "); + tprintf("{\"%s\", {", + ifra[i].ifr_name); + if (verbose(tcp)) { + printxval(addrfams, + ifra[i].ifr_addr.sa_family, + "AF_???"); + tprintf(", "); + if (ifra[i].ifr_addr.sa_family == AF_INET) { + struct sockaddr_in *sinp; + sinp = (struct sockaddr_in *) &ifra[i].ifr_addr; + tprintf("inet_addr(\"%s\")", + inet_ntoa(sinp->sin_addr)); + } else + printstr(tcp, + (long) &ifra[i].ifr_addr.sa_data, + sizeof(ifra[i].ifr_addr.sa_data)); + } else + tprintf("..."); + tprintf("}}"); + } + tprintf("}"); + } + tprintf("}"); + return 1; +#endif default: return 0; }