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