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. |
| 26 | * |
| 27 | * $Id$ |
| 28 | */ |
| 29 | |
| 30 | #include "defs.h" |
| 31 | |
Roland McGrath | 561c799 | 2003-04-02 01:10:44 +0000 | [diff] [blame] | 32 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 33 | #include <sys/socket.h> |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 34 | #include <linux/sockios.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 35 | #else |
Roland McGrath | 8988d1e | 2004-10-19 23:33:50 +0000 | [diff] [blame] | 36 | #include <sys/socket.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 37 | #include <sys/sockio.h> |
| 38 | #endif |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 39 | #include <arpa/inet.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 40 | |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 41 | #if defined (ALPHA) || defined(SH) || defined(SH64) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 42 | #ifdef HAVE_SYS_IOCTL_H |
| 43 | #include <sys/ioctl.h> |
| 44 | #elif defined(HAVE_IOCTLS_H) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 45 | #include <ioctls.h> |
| 46 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 47 | #endif |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 48 | #include <net/if.h> |
| 49 | |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 50 | static const struct xlat iffflags[] = { |
| 51 | { IFF_UP, "IFF_UP" }, |
| 52 | { IFF_BROADCAST, "IFF_BROADCAST" }, |
| 53 | { IFF_DEBUG, "IFF_DEBUG" }, |
| 54 | { IFF_LOOPBACK, "IFF_LOOPBACK" }, |
| 55 | { IFF_POINTOPOINT, "IFF_POINTOPOINT" }, |
| 56 | { IFF_NOTRAILERS, "IFF_NOTRAILERS" }, |
| 57 | { IFF_RUNNING, "IFF_RUNNING" }, |
| 58 | { IFF_NOARP, "IFF_NOARP" }, |
| 59 | { IFF_PROMISC, "IFF_PROMISC" }, |
| 60 | { IFF_ALLMULTI, "IFF_ALLMULTI" }, |
| 61 | { IFF_MASTER, "IFF_MASTER" }, |
| 62 | { IFF_SLAVE, "IFF_SLAVE" }, |
| 63 | { IFF_MULTICAST, "IFF_MULTICAST" }, |
| 64 | { IFF_PORTSEL, "IFF_PORTSEL" }, |
| 65 | { IFF_AUTOMEDIA, "IFF_AUTOMEDIA" }, |
| 66 | { 0, NULL } |
| 67 | }; |
| 68 | |
| 69 | |
| 70 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 71 | print_addr(struct tcb *tcp, long addr, struct ifreq *ifr) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 72 | { |
| 73 | if (ifr->ifr_addr.sa_family == AF_INET) { |
| 74 | struct sockaddr_in *sinp; |
| 75 | sinp = (struct sockaddr_in *) &ifr->ifr_addr; |
| 76 | tprintf("inet_addr(\"%s\")", inet_ntoa(sinp->sin_addr)); |
| 77 | } else |
| 78 | printstr(tcp, addr, sizeof(ifr->ifr_addr.sa_data)); |
| 79 | } |
| 80 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 81 | int |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 82 | sock_ioctl(struct tcb *tcp, long code, long arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 83 | { |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 84 | struct ifreq ifr; |
| 85 | struct ifconf ifc; |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 86 | const char *str = NULL; |
| 87 | unsigned char *bytes; |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 88 | |
| 89 | if (entering(tcp)) { |
| 90 | if (code == SIOCGIFCONF) { |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 91 | if (umove(tcp, tcp->u_arg[2], &ifc) >= 0 |
| 92 | && ifc.ifc_buf == NULL) |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 93 | tprintf(", {%d -> ", ifc.ifc_len); |
| 94 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 95 | tprints(", {"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 96 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 97 | return 0; |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 98 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 99 | |
| 100 | switch (code) { |
| 101 | #ifdef SIOCSHIWAT |
| 102 | case SIOCSHIWAT: |
| 103 | #endif |
| 104 | #ifdef SIOCGHIWAT |
| 105 | case SIOCGHIWAT: |
| 106 | #endif |
| 107 | #ifdef SIOCSLOWAT |
| 108 | case SIOCSLOWAT: |
| 109 | #endif |
| 110 | #ifdef SIOCGLOWAT |
| 111 | case SIOCGLOWAT: |
| 112 | #endif |
| 113 | #ifdef FIOSETOWN |
| 114 | case FIOSETOWN: |
| 115 | #endif |
| 116 | #ifdef FIOGETOWN |
| 117 | case FIOGETOWN: |
| 118 | #endif |
| 119 | #ifdef SIOCSPGRP |
| 120 | case SIOCSPGRP: |
| 121 | #endif |
| 122 | #ifdef SIOCGPGRP |
| 123 | case SIOCGPGRP: |
| 124 | #endif |
| 125 | #ifdef SIOCATMARK |
| 126 | case SIOCATMARK: |
| 127 | #endif |
| 128 | printnum(tcp, arg, ", %#d"); |
| 129 | return 1; |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 130 | #ifdef LINUX |
| 131 | case SIOCGIFNAME: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 132 | case SIOCSIFNAME: |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 133 | case SIOCGIFINDEX: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 134 | case SIOCGIFADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 135 | case SIOCSIFADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 136 | case SIOCGIFDSTADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 137 | case SIOCSIFDSTADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 138 | case SIOCGIFBRDADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 139 | case SIOCSIFBRDADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 140 | case SIOCGIFNETMASK: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 141 | case SIOCSIFNETMASK: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 142 | case SIOCGIFFLAGS: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 143 | case SIOCSIFFLAGS: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 144 | case SIOCGIFMETRIC: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 145 | case SIOCSIFMETRIC: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 146 | case SIOCGIFMTU: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 147 | case SIOCSIFMTU: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 148 | case SIOCGIFSLAVE: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 149 | case SIOCSIFSLAVE: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 150 | case SIOCGIFHWADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 151 | case SIOCSIFHWADDR: |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 152 | case SIOCGIFTXQLEN: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 153 | case SIOCSIFTXQLEN: |
Dmitry V. Levin | ecdd0bb | 2007-03-21 13:57:50 +0000 | [diff] [blame] | 154 | case SIOCGIFMAP: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 155 | case SIOCSIFMAP: |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 156 | if (umove(tcp, tcp->u_arg[2], &ifr) < 0) |
| 157 | tprintf(", %#lx", tcp->u_arg[2]); |
| 158 | else if (syserror(tcp)) { |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 159 | if (code == SIOCGIFNAME || code == SIOCSIFNAME) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 160 | tprintf(", {ifr_index=%d, ifr_name=???}", ifr.ifr_ifindex); |
| 161 | else |
| 162 | tprintf(", {ifr_name=\"%s\", ???}", ifr.ifr_name); |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 163 | } else if (code == SIOCGIFNAME || code == SIOCSIFNAME) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 164 | tprintf(", {ifr_index=%d, ifr_name=\"%s\"}", |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 165 | ifr.ifr_ifindex, ifr.ifr_name); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 166 | else { |
| 167 | tprintf(", {ifr_name=\"%s\", ", ifr.ifr_name); |
| 168 | switch (code) { |
| 169 | case SIOCGIFINDEX: |
| 170 | tprintf("ifr_index=%d", ifr.ifr_ifindex); |
| 171 | break; |
| 172 | case SIOCGIFADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 173 | case SIOCSIFADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 174 | str = "ifr_addr"; |
| 175 | case SIOCGIFDSTADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 176 | case SIOCSIFDSTADDR: |
| 177 | if (!str) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 178 | str = "ifr_dstaddr"; |
| 179 | case SIOCGIFBRDADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 180 | case SIOCSIFBRDADDR: |
| 181 | if (!str) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 182 | str = "ifr_broadaddr"; |
| 183 | case SIOCGIFNETMASK: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 184 | case SIOCSIFNETMASK: |
| 185 | if (!str) |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 186 | str = "ifr_netmask"; |
| 187 | tprintf("%s={", str); |
| 188 | printxval(addrfams, |
| 189 | ifr.ifr_addr.sa_family, |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 190 | "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 191 | tprints(", "); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 192 | print_addr(tcp, ((long) tcp->u_arg[2] |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 193 | + offsetof(struct ifreq, |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 194 | ifr_addr.sa_data)), |
| 195 | &ifr); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 196 | tprints("}"); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 197 | break; |
| 198 | case SIOCGIFHWADDR: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 199 | case SIOCSIFHWADDR: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 200 | /* XXX Are there other hardware addresses |
| 201 | than 6-byte MACs? */ |
| 202 | bytes = (unsigned char *) &ifr.ifr_hwaddr.sa_data; |
| 203 | tprintf("ifr_hwaddr=%02x:%02x:%02x:%02x:%02x:%02x", |
| 204 | bytes[0], bytes[1], bytes[2], |
| 205 | bytes[3], bytes[4], bytes[5]); |
| 206 | break; |
| 207 | case SIOCGIFFLAGS: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 208 | case SIOCSIFFLAGS: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 209 | tprints("ifr_flags="); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 210 | printflags(iffflags, ifr.ifr_flags, "IFF_???"); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 211 | break; |
| 212 | case SIOCGIFMETRIC: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 213 | case SIOCSIFMETRIC: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 214 | tprintf("ifr_metric=%d", ifr.ifr_metric); |
| 215 | break; |
| 216 | case SIOCGIFMTU: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 217 | case SIOCSIFMTU: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 218 | tprintf("ifr_mtu=%d", ifr.ifr_mtu); |
| 219 | break; |
| 220 | case SIOCGIFSLAVE: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 221 | case SIOCSIFSLAVE: |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 222 | tprintf("ifr_slave=\"%s\"", ifr.ifr_slave); |
| 223 | break; |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 224 | case SIOCGIFTXQLEN: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 225 | case SIOCSIFTXQLEN: |
Dmitry V. Levin | 4028424 | 2007-03-21 13:52:14 +0000 | [diff] [blame] | 226 | tprintf("ifr_qlen=%d", ifr.ifr_qlen); |
| 227 | break; |
Dmitry V. Levin | ecdd0bb | 2007-03-21 13:57:50 +0000 | [diff] [blame] | 228 | case SIOCGIFMAP: |
Dmitry V. Levin | 5414bf7 | 2008-12-10 13:51:40 +0000 | [diff] [blame] | 229 | case SIOCSIFMAP: |
Dmitry V. Levin | ecdd0bb | 2007-03-21 13:57:50 +0000 | [diff] [blame] | 230 | tprintf("ifr_map={mem_start=%#lx, " |
| 231 | "mem_end=%#lx, base_addr=%#x, " |
| 232 | "irq=%u, dma=%u, port=%u}", |
| 233 | ifr.ifr_map.mem_start, |
| 234 | ifr.ifr_map.mem_end, |
| 235 | (unsigned) ifr.ifr_map.base_addr, |
| 236 | (unsigned) ifr.ifr_map.irq, |
| 237 | (unsigned) ifr.ifr_map.dma, |
| 238 | (unsigned) ifr.ifr_map.port); |
| 239 | break; |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 240 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 241 | tprints("}"); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 242 | } |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 243 | return 1; |
| 244 | case SIOCGIFCONF: |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 245 | if (umove(tcp, tcp->u_arg[2], &ifc) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 246 | tprints("???}"); |
Dmitry V. Levin | 652e448 | 2007-03-21 14:18:17 +0000 | [diff] [blame] | 247 | return 1; |
| 248 | } |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 249 | tprintf("%d, ", ifc.ifc_len); |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 250 | if (syserror(tcp)) { |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 251 | tprintf("%lx", (unsigned long) ifc.ifc_buf); |
| 252 | } else if (ifc.ifc_buf == NULL) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 253 | tprints("NULL"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 254 | } else { |
| 255 | int i; |
| 256 | unsigned nifra = ifc.ifc_len / sizeof(struct ifreq); |
| 257 | struct ifreq ifra[nifra]; |
Dmitry V. Levin | 62e0596 | 2009-11-03 14:38:44 +0000 | [diff] [blame] | 258 | |
| 259 | if (umoven(tcp, (unsigned long) ifc.ifc_buf, |
| 260 | sizeof(ifra), (char *) ifra) < 0) { |
| 261 | tprintf("%lx}", (unsigned long) ifc.ifc_buf); |
| 262 | return 1; |
| 263 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 264 | tprints("{"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 265 | for (i = 0; i < nifra; ++i ) { |
| 266 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 267 | tprints(", "); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 268 | tprintf("{\"%s\", {", |
| 269 | ifra[i].ifr_name); |
| 270 | if (verbose(tcp)) { |
| 271 | printxval(addrfams, |
| 272 | ifra[i].ifr_addr.sa_family, |
| 273 | "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 274 | tprints(", "); |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 275 | print_addr(tcp, ((long) tcp->u_arg[2] |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 276 | + offsetof(struct ifreq, |
Roland McGrath | e6a432d | 2005-02-02 20:25:17 +0000 | [diff] [blame] | 277 | ifr_addr.sa_data) |
| 278 | + ((char *) &ifra[i] |
| 279 | - (char *) &ifra[0])), |
| 280 | &ifra[i]); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 281 | } else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 282 | tprints("..."); |
| 283 | tprints("}}"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 284 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 285 | tprints("}"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 286 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 287 | tprints("}"); |
Roland McGrath | 5687ff1 | 2004-07-12 07:13:06 +0000 | [diff] [blame] | 288 | return 1; |
| 289 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 290 | default: |
| 291 | return 0; |
| 292 | } |
| 293 | } |
Dmitry V. Levin | b5e88d4 | 2012-02-20 17:02:38 +0000 | [diff] [blame^] | 294 | |
| 295 | int |
| 296 | sys_socketcall(struct tcb *tcp) |
| 297 | { |
| 298 | return printargs(tcp); |
| 299 | } |