Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include "defs.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 29 | #include <sys/socket.h> |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 30 | #include <linux/sockios.h> |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 31 | #include <arpa/inet.h> |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 32 | #if defined(ALPHA) || defined(SH) || defined(SH64) |
Denys Vlasenko | a6d91de | 2012-03-16 12:02:22 +0100 | [diff] [blame] | 33 | # if defined(HAVE_SYS_IOCTL_H) |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 34 | # include <sys/ioctl.h> |
| 35 | # elif defined(HAVE_IOCTLS_H) |
| 36 | # include <ioctls.h> |
| 37 | # endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 38 | #endif |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 39 | #include <net/if.h> |
| 40 | |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 41 | static const struct xlat iffflags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 42 | XLAT(IFF_UP), |
| 43 | XLAT(IFF_BROADCAST), |
| 44 | XLAT(IFF_DEBUG), |
| 45 | XLAT(IFF_LOOPBACK), |
| 46 | XLAT(IFF_POINTOPOINT), |
| 47 | XLAT(IFF_NOTRAILERS), |
| 48 | XLAT(IFF_RUNNING), |
| 49 | XLAT(IFF_NOARP), |
| 50 | XLAT(IFF_PROMISC), |
| 51 | XLAT(IFF_ALLMULTI), |
| 52 | XLAT(IFF_MASTER), |
| 53 | XLAT(IFF_SLAVE), |
| 54 | XLAT(IFF_MULTICAST), |
| 55 | XLAT(IFF_PORTSEL), |
| 56 | XLAT(IFF_AUTOMEDIA), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 57 | XLAT_END |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 60 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 61 | print_addr(struct tcb *tcp, long addr, struct ifreq *ifr) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 62 | { |
| 63 | if (ifr->ifr_addr.sa_family == AF_INET) { |
| 64 | struct sockaddr_in *sinp; |
| 65 | sinp = (struct sockaddr_in *) &ifr->ifr_addr; |
| 66 | tprintf("inet_addr(\"%s\")", inet_ntoa(sinp->sin_addr)); |
| 67 | } else |
| 68 | printstr(tcp, addr, sizeof(ifr->ifr_addr.sa_data)); |
| 69 | } |
| 70 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 71 | int |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 72 | sock_ioctl(struct tcb *tcp, long code, long arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 73 | { |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 74 | struct ifreq ifr; |
| 75 | struct ifconf ifc; |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 76 | const char *str = NULL; |
| 77 | unsigned char *bytes; |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 78 | |
| 79 | if (entering(tcp)) { |
| 80 | if (code == SIOCGIFCONF) { |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 81 | if (umove(tcp, tcp->u_arg[2], &ifc) >= 0 |
| 82 | && ifc.ifc_buf == NULL) |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 83 | tprintf(", {%d -> ", ifc.ifc_len); |
| 84 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 85 | tprints(", {"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 86 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 87 | return 0; |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 88 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 89 | |
| 90 | switch (code) { |
| 91 | #ifdef SIOCSHIWAT |
| 92 | case SIOCSHIWAT: |
| 93 | #endif |
| 94 | #ifdef SIOCGHIWAT |
| 95 | case SIOCGHIWAT: |
| 96 | #endif |
| 97 | #ifdef SIOCSLOWAT |
| 98 | case SIOCSLOWAT: |
| 99 | #endif |
| 100 | #ifdef SIOCGLOWAT |
| 101 | case SIOCGLOWAT: |
| 102 | #endif |
| 103 | #ifdef FIOSETOWN |
| 104 | case FIOSETOWN: |
| 105 | #endif |
| 106 | #ifdef FIOGETOWN |
| 107 | case FIOGETOWN: |
| 108 | #endif |
| 109 | #ifdef SIOCSPGRP |
| 110 | case SIOCSPGRP: |
| 111 | #endif |
| 112 | #ifdef SIOCGPGRP |
| 113 | case SIOCGPGRP: |
| 114 | #endif |
| 115 | #ifdef SIOCATMARK |
| 116 | case SIOCATMARK: |
| 117 | #endif |
| 118 | printnum(tcp, arg, ", %#d"); |
| 119 | return 1; |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 120 | case SIOCGIFNAME: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 121 | case SIOCSIFNAME: |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 122 | case SIOCGIFINDEX: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 123 | case SIOCGIFADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 124 | case SIOCSIFADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 125 | case SIOCGIFDSTADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 126 | case SIOCSIFDSTADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 127 | case SIOCGIFBRDADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 128 | case SIOCSIFBRDADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 129 | case SIOCGIFNETMASK: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 130 | case SIOCSIFNETMASK: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 131 | case SIOCGIFFLAGS: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 132 | case SIOCSIFFLAGS: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 133 | case SIOCGIFMETRIC: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 134 | case SIOCSIFMETRIC: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 135 | case SIOCGIFMTU: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 136 | case SIOCSIFMTU: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 137 | case SIOCGIFSLAVE: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 138 | case SIOCSIFSLAVE: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 139 | case SIOCGIFHWADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 140 | case SIOCSIFHWADDR: |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 141 | case SIOCGIFTXQLEN: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 142 | case SIOCSIFTXQLEN: |
Dmitry V. Levin | ecdd0bb | 2007-03-21 13:57:50 +0000 | [diff] [blame] | 143 | case SIOCGIFMAP: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 144 | case SIOCSIFMAP: |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 145 | if (umove(tcp, tcp->u_arg[2], &ifr) < 0) |
| 146 | tprintf(", %#lx", tcp->u_arg[2]); |
| 147 | else if (syserror(tcp)) { |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 148 | if (code == SIOCGIFNAME || code == SIOCSIFNAME) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 149 | tprintf(", {ifr_index=%d, ifr_name=???}", ifr.ifr_ifindex); |
| 150 | else |
| 151 | tprintf(", {ifr_name=\"%s\", ???}", ifr.ifr_name); |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 152 | } else if (code == SIOCGIFNAME || code == SIOCSIFNAME) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 153 | tprintf(", {ifr_index=%d, ifr_name=\"%s\"}", |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 154 | ifr.ifr_ifindex, ifr.ifr_name); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 155 | else { |
| 156 | tprintf(", {ifr_name=\"%s\", ", ifr.ifr_name); |
| 157 | switch (code) { |
| 158 | case SIOCGIFINDEX: |
| 159 | tprintf("ifr_index=%d", ifr.ifr_ifindex); |
| 160 | break; |
| 161 | case SIOCGIFADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 162 | case SIOCSIFADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 163 | str = "ifr_addr"; |
| 164 | case SIOCGIFDSTADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 165 | case SIOCSIFDSTADDR: |
| 166 | if (!str) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 167 | str = "ifr_dstaddr"; |
| 168 | case SIOCGIFBRDADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 169 | case SIOCSIFBRDADDR: |
| 170 | if (!str) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 171 | str = "ifr_broadaddr"; |
| 172 | case SIOCGIFNETMASK: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 173 | case SIOCSIFNETMASK: |
| 174 | if (!str) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 175 | str = "ifr_netmask"; |
| 176 | tprintf("%s={", str); |
| 177 | printxval(addrfams, |
| 178 | ifr.ifr_addr.sa_family, |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 179 | "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 180 | tprints(", "); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 181 | print_addr(tcp, ((long) tcp->u_arg[2] |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 182 | + offsetof(struct ifreq, |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 183 | ifr_addr.sa_data)), |
| 184 | &ifr); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 185 | tprints("}"); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 186 | break; |
| 187 | case SIOCGIFHWADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 188 | case SIOCSIFHWADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 189 | /* XXX Are there other hardware addresses |
| 190 | than 6-byte MACs? */ |
| 191 | bytes = (unsigned char *) &ifr.ifr_hwaddr.sa_data; |
| 192 | tprintf("ifr_hwaddr=%02x:%02x:%02x:%02x:%02x:%02x", |
| 193 | bytes[0], bytes[1], bytes[2], |
| 194 | bytes[3], bytes[4], bytes[5]); |
| 195 | break; |
| 196 | case SIOCGIFFLAGS: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 197 | case SIOCSIFFLAGS: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 198 | tprints("ifr_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 199 | printflags(iffflags, ifr.ifr_flags, "IFF_???"); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 200 | break; |
| 201 | case SIOCGIFMETRIC: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 202 | case SIOCSIFMETRIC: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 203 | tprintf("ifr_metric=%d", ifr.ifr_metric); |
| 204 | break; |
| 205 | case SIOCGIFMTU: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 206 | case SIOCSIFMTU: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 207 | tprintf("ifr_mtu=%d", ifr.ifr_mtu); |
| 208 | break; |
| 209 | case SIOCGIFSLAVE: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 210 | case SIOCSIFSLAVE: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 211 | tprintf("ifr_slave=\"%s\"", ifr.ifr_slave); |
| 212 | break; |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 213 | case SIOCGIFTXQLEN: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 214 | case SIOCSIFTXQLEN: |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 215 | tprintf("ifr_qlen=%d", ifr.ifr_qlen); |
| 216 | break; |
Dmitry V. Levin | ecdd0bb | 2007-03-21 13:57:50 +0000 | [diff] [blame] | 217 | case SIOCGIFMAP: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 218 | case SIOCSIFMAP: |
Dmitry V. Levin | ecdd0bb | 2007-03-21 13:57:50 +0000 | [diff] [blame] | 219 | tprintf("ifr_map={mem_start=%#lx, " |
| 220 | "mem_end=%#lx, base_addr=%#x, " |
| 221 | "irq=%u, dma=%u, port=%u}", |
| 222 | ifr.ifr_map.mem_start, |
| 223 | ifr.ifr_map.mem_end, |
| 224 | (unsigned) ifr.ifr_map.base_addr, |
| 225 | (unsigned) ifr.ifr_map.irq, |
| 226 | (unsigned) ifr.ifr_map.dma, |
| 227 | (unsigned) ifr.ifr_map.port); |
| 228 | break; |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 229 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 230 | tprints("}"); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 231 | } |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 232 | return 1; |
| 233 | case SIOCGIFCONF: |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 234 | if (umove(tcp, tcp->u_arg[2], &ifc) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 235 | tprints("???}"); |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 236 | return 1; |
| 237 | } |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 238 | tprintf("%d, ", ifc.ifc_len); |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 239 | if (syserror(tcp)) { |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 240 | tprintf("%lx", (unsigned long) ifc.ifc_buf); |
| 241 | } else if (ifc.ifc_buf == NULL) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 242 | tprints("NULL"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 243 | } else { |
| 244 | int i; |
| 245 | unsigned nifra = ifc.ifc_len / sizeof(struct ifreq); |
| 246 | struct ifreq ifra[nifra]; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 247 | |
| 248 | if (umoven(tcp, (unsigned long) ifc.ifc_buf, |
| 249 | sizeof(ifra), (char *) ifra) < 0) { |
| 250 | tprintf("%lx}", (unsigned long) ifc.ifc_buf); |
| 251 | return 1; |
| 252 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 253 | tprints("{"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 254 | for (i = 0; i < nifra; ++i ) { |
| 255 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 256 | tprints(", "); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 257 | tprintf("{\"%s\", {", |
| 258 | ifra[i].ifr_name); |
| 259 | if (verbose(tcp)) { |
| 260 | printxval(addrfams, |
| 261 | ifra[i].ifr_addr.sa_family, |
| 262 | "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 263 | tprints(", "); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 264 | print_addr(tcp, ((long) tcp->u_arg[2] |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 265 | + offsetof(struct ifreq, |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 266 | ifr_addr.sa_data) |
| 267 | + ((char *) &ifra[i] |
| 268 | - (char *) &ifra[0])), |
| 269 | &ifra[i]); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 270 | } else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 271 | tprints("..."); |
| 272 | tprints("}}"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 273 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 274 | tprints("}"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 275 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 276 | tprints("}"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 277 | return 1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 278 | default: |
| 279 | return 0; |
| 280 | } |
| 281 | } |
Dmitry V. Levin | b5e88d4 | 2012-02-20 17:02:38 +0000 | [diff] [blame] | 282 | |
| 283 | int |
| 284 | sys_socketcall(struct tcb *tcp) |
| 285 | { |
| 286 | return printargs(tcp); |
| 287 | } |