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