Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. The name of the author may not be used to endorse or promote products |
| 17 | * derived from this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | * |
| 30 | * $Id$ |
| 31 | */ |
| 32 | |
| 33 | #include "defs.h" |
| 34 | |
| 35 | #include <sys/stat.h> |
| 36 | #include <sys/socket.h> |
| 37 | #include <sys/un.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 38 | |
| 39 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 40 | #define in6_addr in6_addr_libc |
| 41 | #define ipv6_mreq ipv6_mreq_libc |
| 42 | #define sockaddr_in6 sockaddr_in6_libc |
| 43 | #endif |
| 44 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 45 | #include <netinet/in.h> |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 46 | #ifdef HAVE_NETINET_TCP_H |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 47 | #include <netinet/tcp.h> |
| 48 | #endif |
Wichert Akkerman | 8c7122c | 2001-02-16 19:59:55 +0000 | [diff] [blame] | 49 | #ifdef HAVE_NETINET_UDP_H |
| 50 | #include <netinet/udp.h> |
| 51 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 52 | #ifdef HAVE_NETINET_SCTP_H |
| 53 | #include <netinet/sctp.h> |
| 54 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | #include <arpa/inet.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 56 | #include <net/if.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | #include <asm/types.h> |
| 58 | #if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC__ + __GLIBC_MINOR__ >= 3) |
| 59 | # include <netipx/ipx.h> |
| 60 | #else |
| 61 | # include <linux/ipx.h> |
| 62 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 63 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 64 | #if defined(__GLIBC__) && (((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) || defined(HAVE_SIN6_SCOPE_ID_LINUX)) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 65 | #if defined(HAVE_LINUX_IN6_H) |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 66 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 67 | #undef in6_addr |
| 68 | #undef ipv6_mreq |
| 69 | #undef sockaddr_in6 |
| 70 | #define in6_addr in6_addr_kernel |
| 71 | #define ipv6_mreq ipv6_mreq_kernel |
| 72 | #define sockaddr_in6 sockaddr_in6_kernel |
| 73 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 74 | #include <linux/in6.h> |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 75 | #if defined(HAVE_SIN6_SCOPE_ID_LINUX) |
| 76 | #undef in6_addr |
| 77 | #undef ipv6_mreq |
| 78 | #undef sockaddr_in6 |
| 79 | #define in6_addr in6_addr_libc |
| 80 | #define ipv6_mreq ipv6_mreq_libc |
| 81 | #define sockaddr_in6 sockaddr_in6_kernel |
| 82 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 83 | #endif |
Wichert Akkerman | 2f473da | 1999-11-01 19:53:31 +0000 | [diff] [blame] | 84 | #endif |
Wichert Akkerman | 505e176 | 1999-11-01 19:39:08 +0000 | [diff] [blame] | 85 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 86 | #if defined(HAVE_SYS_UIO_H) |
| 87 | #include <sys/uio.h> |
| 88 | #endif |
| 89 | |
| 90 | #if defined(HAVE_LINUX_NETLINK_H) |
| 91 | #include <linux/netlink.h> |
| 92 | #endif |
| 93 | |
| 94 | #if defined(HAVE_LINUX_IF_PACKET_H) |
| 95 | #include <linux/if_packet.h> |
| 96 | #endif |
| 97 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 98 | #if defined(HAVE_LINUX_ICMP_H) |
| 99 | #include <linux/icmp.h> |
| 100 | #endif |
| 101 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 102 | #ifndef PF_UNSPEC |
| 103 | #define PF_UNSPEC AF_UNSPEC |
| 104 | #endif |
| 105 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 106 | /* Under Linux these are enums so we can't test for them with ifdef. */ |
| 107 | #define IPPROTO_EGP IPPROTO_EGP |
| 108 | #define IPPROTO_PUP IPPROTO_PUP |
| 109 | #define IPPROTO_IDP IPPROTO_IDP |
| 110 | #define IPPROTO_IGMP IPPROTO_IGMP |
| 111 | #define IPPROTO_RAW IPPROTO_RAW |
| 112 | #define IPPROTO_MAX IPPROTO_MAX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 114 | static const struct xlat domains[] = { |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 115 | #ifdef PF_AAL5 |
| 116 | { PF_AAL5, "PF_AAL5" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 117 | #endif |
| 118 | #ifdef PF_APPLETALK |
| 119 | { PF_APPLETALK, "PF_APPLETALK" }, |
| 120 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 121 | #ifdef PF_ASH |
| 122 | { PF_ASH, "PF_ASH" }, |
| 123 | #endif |
| 124 | #ifdef PF_ATMPVC |
| 125 | { PF_ATMPVC, "PF_ATMPVC" }, |
| 126 | #endif |
| 127 | #ifdef PF_ATMSVC |
| 128 | { PF_ATMSVC, "PF_ATMSVC" }, |
| 129 | #endif |
| 130 | #ifdef PF_AX25 |
| 131 | { PF_AX25, "PF_AX25" }, |
| 132 | #endif |
| 133 | #ifdef PF_BLUETOOTH |
| 134 | { PF_BLUETOOTH, "PF_BLUETOOTH" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 135 | #endif |
| 136 | #ifdef PF_BRIDGE |
| 137 | { PF_BRIDGE, "PF_BRIDGE" }, |
| 138 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 139 | #ifdef PF_DECnet |
| 140 | { PF_DECnet, "PF_DECnet" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 141 | #endif |
| 142 | #ifdef PF_DECNET |
| 143 | { PF_DECNET, "PF_DECNET" }, |
| 144 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 145 | #ifdef PF_ECONET |
| 146 | { PF_ECONET, "PF_ECONET" }, |
| 147 | #endif |
| 148 | #ifdef PF_FILE |
| 149 | { PF_FILE, "PF_FILE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | #endif |
| 151 | #ifdef PF_IMPLINK |
| 152 | { PF_IMPLINK, "PF_IMPLINK" }, |
| 153 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 154 | #ifdef PF_INET |
| 155 | { PF_INET, "PF_INET" }, |
| 156 | #endif |
| 157 | #ifdef PF_INET6 |
| 158 | { PF_INET6, "PF_INET6" }, |
| 159 | #endif |
| 160 | #ifdef PF_IPX |
| 161 | { PF_IPX, "PF_IPX" }, |
| 162 | #endif |
| 163 | #ifdef PF_IRDA |
| 164 | { PF_IRDA, "PF_IRDA" }, |
| 165 | #endif |
| 166 | #ifdef PF_ISO |
| 167 | { PF_ISO, "PF_ISO" }, |
| 168 | #endif |
| 169 | #ifdef PF_KEY |
| 170 | { PF_KEY, "PF_KEY" }, |
| 171 | #endif |
| 172 | #ifdef PF_UNIX |
| 173 | { PF_UNIX, "PF_UNIX" }, |
| 174 | #endif |
| 175 | #ifdef PF_LOCAL |
| 176 | { PF_LOCAL, "PF_LOCAL" }, |
| 177 | #endif |
| 178 | #ifdef PF_NETBEUI |
| 179 | { PF_NETBEUI, "PF_NETBEUI" }, |
| 180 | #endif |
| 181 | #ifdef PF_NETLINK |
| 182 | { PF_NETLINK, "PF_NETLINK" }, |
| 183 | #endif |
| 184 | #ifdef PF_NETROM |
| 185 | { PF_NETROM, "PF_NETROM" }, |
| 186 | #endif |
| 187 | #ifdef PF_PACKET |
| 188 | { PF_PACKET, "PF_PACKET" }, |
| 189 | #endif |
| 190 | #ifdef PF_PPPOX |
| 191 | { PF_PPPOX, "PF_PPPOX" }, |
| 192 | #endif |
| 193 | #ifdef PF_ROSE |
| 194 | { PF_ROSE, "PF_ROSE" }, |
| 195 | #endif |
| 196 | #ifdef PF_ROUTE |
| 197 | { PF_ROUTE, "PF_ROUTE" }, |
| 198 | #endif |
| 199 | #ifdef PF_SECURITY |
| 200 | { PF_SECURITY, "PF_SECURITY" }, |
| 201 | #endif |
| 202 | #ifdef PF_SNA |
| 203 | { PF_SNA, "PF_SNA" }, |
| 204 | #endif |
| 205 | #ifdef PF_UNSPEC |
| 206 | { PF_UNSPEC, "PF_UNSPEC" }, |
| 207 | #endif |
| 208 | #ifdef PF_WANPIPE |
| 209 | { PF_WANPIPE, "PF_WANPIPE" }, |
| 210 | #endif |
| 211 | #ifdef PF_X25 |
| 212 | { PF_X25, "PF_X25" }, |
| 213 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 214 | { 0, NULL }, |
| 215 | }; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 216 | const struct xlat addrfams[] = { |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 217 | #ifdef AF_APPLETALK |
| 218 | { AF_APPLETALK, "AF_APPLETALK" }, |
| 219 | #endif |
| 220 | #ifdef AF_ASH |
| 221 | { AF_ASH, "AF_ASH" }, |
| 222 | #endif |
| 223 | #ifdef AF_ATMPVC |
| 224 | { AF_ATMPVC, "AF_ATMPVC" }, |
| 225 | #endif |
| 226 | #ifdef AF_ATMSVC |
| 227 | { AF_ATMSVC, "AF_ATMSVC" }, |
| 228 | #endif |
| 229 | #ifdef AF_AX25 |
| 230 | { AF_AX25, "AF_AX25" }, |
| 231 | #endif |
| 232 | #ifdef AF_BLUETOOTH |
| 233 | { AF_BLUETOOTH, "AF_BLUETOOTH" }, |
| 234 | #endif |
| 235 | #ifdef AF_BRIDGE |
| 236 | { AF_BRIDGE, "AF_BRIDGE" }, |
| 237 | #endif |
| 238 | #ifdef AF_DECnet |
| 239 | { AF_DECnet, "AF_DECnet" }, |
| 240 | #endif |
| 241 | #ifdef AF_ECONET |
| 242 | { AF_ECONET, "AF_ECONET" }, |
| 243 | #endif |
| 244 | #ifdef AF_FILE |
| 245 | { AF_FILE, "AF_FILE" }, |
| 246 | #endif |
| 247 | #ifdef AF_IMPLINK |
| 248 | { AF_IMPLINK, "AF_IMPLINK" }, |
| 249 | #endif |
| 250 | #ifdef AF_INET |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 251 | { AF_INET, "AF_INET" }, |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 252 | #endif |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 253 | #ifdef AF_INET6 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 254 | { AF_INET6, "AF_INET6" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 255 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 256 | #ifdef AF_IPX |
| 257 | { AF_IPX, "AF_IPX" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 258 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 259 | #ifdef AF_IRDA |
| 260 | { AF_IRDA, "AF_IRDA" }, |
Wichert Akkerman | e4aafd4 | 1999-11-26 09:54:08 +0000 | [diff] [blame] | 261 | #endif |
| 262 | #ifdef AF_ISO |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 263 | { AF_ISO, "AF_ISO" }, |
| 264 | #endif |
Roland McGrath | 5a8146a | 2004-06-04 02:24:14 +0000 | [diff] [blame] | 265 | #ifdef AF_KEY |
| 266 | { AF_KEY, "AF_KEY" }, |
| 267 | #endif |
| 268 | #ifdef AF_UNIX |
| 269 | { AF_UNIX, "AF_UNIX" }, |
| 270 | #endif |
| 271 | #ifdef AF_LOCAL |
| 272 | { AF_LOCAL, "AF_LOCAL" }, |
| 273 | #endif |
| 274 | #ifdef AF_NETBEUI |
| 275 | { AF_NETBEUI, "AF_NETBEUI" }, |
| 276 | #endif |
| 277 | #ifdef AF_NETLINK |
| 278 | { AF_NETLINK, "AF_NETLINK" }, |
| 279 | #endif |
| 280 | #ifdef AF_NETROM |
| 281 | { AF_NETROM, "AF_NETROM" }, |
| 282 | #endif |
| 283 | #ifdef AF_PACKET |
| 284 | { AF_PACKET, "AF_PACKET" }, |
| 285 | #endif |
| 286 | #ifdef AF_PPPOX |
| 287 | { AF_PPPOX, "AF_PPPOX" }, |
| 288 | #endif |
| 289 | #ifdef AF_ROSE |
| 290 | { AF_ROSE, "AF_ROSE" }, |
| 291 | #endif |
| 292 | #ifdef AF_ROUTE |
| 293 | { AF_ROUTE, "AF_ROUTE" }, |
| 294 | #endif |
| 295 | #ifdef AF_SECURITY |
| 296 | { AF_SECURITY, "AF_SECURITY" }, |
| 297 | #endif |
| 298 | #ifdef AF_SNA |
| 299 | { AF_SNA, "AF_SNA" }, |
| 300 | #endif |
| 301 | #ifdef AF_UNSPEC |
| 302 | { AF_UNSPEC, "AF_UNSPEC" }, |
| 303 | #endif |
| 304 | #ifdef AF_WANPIPE |
| 305 | { AF_WANPIPE, "AF_WANPIPE" }, |
| 306 | #endif |
| 307 | #ifdef AF_X25 |
| 308 | { AF_X25, "AF_X25" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 309 | #endif |
| 310 | { 0, NULL }, |
| 311 | }; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 312 | static const struct xlat socktypes[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 313 | { SOCK_STREAM, "SOCK_STREAM" }, |
| 314 | { SOCK_DGRAM, "SOCK_DGRAM" }, |
| 315 | #ifdef SOCK_RAW |
| 316 | { SOCK_RAW, "SOCK_RAW" }, |
| 317 | #endif |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 318 | #ifdef SOCK_RDM |
| 319 | { SOCK_RDM, "SOCK_RDM" }, |
| 320 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 321 | #ifdef SOCK_SEQPACKET |
| 322 | { SOCK_SEQPACKET,"SOCK_SEQPACKET"}, |
| 323 | #endif |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 324 | #ifdef SOCK_DCCP |
| 325 | { SOCK_DCCP, "SOCK_DCCP" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 326 | #endif |
| 327 | #ifdef SOCK_PACKET |
| 328 | { SOCK_PACKET, "SOCK_PACKET" }, |
| 329 | #endif |
| 330 | { 0, NULL }, |
| 331 | }; |
Dmitry V. Levin | d475c06 | 2011-03-03 01:02:41 +0000 | [diff] [blame] | 332 | static const struct xlat sock_type_flags[] = { |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 333 | #ifdef SOCK_CLOEXEC |
| 334 | { SOCK_CLOEXEC, "SOCK_CLOEXEC" }, |
| 335 | #endif |
| 336 | #ifdef SOCK_NONBLOCK |
| 337 | { SOCK_NONBLOCK,"SOCK_NONBLOCK" }, |
| 338 | #endif |
| 339 | { 0, NULL }, |
| 340 | }; |
| 341 | #ifndef SOCK_TYPE_MASK |
| 342 | # define SOCK_TYPE_MASK 0xf |
| 343 | #endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 344 | static const struct xlat socketlayers[] = { |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 345 | #if defined(SOL_IP) |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 346 | { SOL_IP, "SOL_IP" }, |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 347 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 348 | #if defined(SOL_ICMP) |
| 349 | { SOL_ICMP, "SOL_ICMP" }, |
| 350 | #endif |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 351 | #if defined(SOL_TCP) |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 352 | { SOL_TCP, "SOL_TCP" }, |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 353 | #endif |
| 354 | #if defined(SOL_UDP) |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 355 | { SOL_UDP, "SOL_UDP" }, |
John Hughes | 1e4cb34 | 2001-03-06 09:25:46 +0000 | [diff] [blame] | 356 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 357 | #if defined(SOL_IPV6) |
| 358 | { SOL_IPV6, "SOL_IPV6" }, |
| 359 | #endif |
| 360 | #if defined(SOL_ICMPV6) |
| 361 | { SOL_ICMPV6, "SOL_ICMPV6" }, |
| 362 | #endif |
Holger Hans Peter Freyther | ce9e0f4 | 2011-01-14 11:08:11 +0100 | [diff] [blame] | 363 | #if defined(SOL_SCTP) |
| 364 | { SOL_SCTP, "SOL_SCTP" }, |
| 365 | #endif |
| 366 | #if defined(SOL_UDPLITE) |
| 367 | { SOL_UDPLITE, "SOL_UDPLITE" }, |
| 368 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 369 | #if defined(SOL_RAW) |
| 370 | { SOL_RAW, "SOL_RAW" }, |
| 371 | #endif |
| 372 | #if defined(SOL_IPX) |
| 373 | { SOL_IPX, "SOL_IPX" }, |
| 374 | #endif |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 375 | #if defined(SOL_AX25) |
| 376 | { SOL_AX25, "SOL_AX25" }, |
| 377 | #endif |
| 378 | #if defined(SOL_ATALK) |
| 379 | { SOL_ATALK, "SOL_ATALK" }, |
| 380 | #endif |
| 381 | #if defined(SOL_NETROM) |
| 382 | { SOL_NETROM, "SOL_NETROM" }, |
| 383 | #endif |
| 384 | #if defined(SOL_ROSE) |
| 385 | { SOL_ROSE, "SOL_ROSE" }, |
| 386 | #endif |
| 387 | #if defined(SOL_DECNET) |
| 388 | { SOL_DECNET, "SOL_DECNET" }, |
| 389 | #endif |
| 390 | #if defined(SOL_X25) |
| 391 | { SOL_X25, "SOL_X25" }, |
| 392 | #endif |
| 393 | #if defined(SOL_PACKET) |
| 394 | { SOL_PACKET, "SOL_PACKET" }, |
| 395 | #endif |
| 396 | #if defined(SOL_ATM) |
| 397 | { SOL_ATM, "SOL_ATM" }, |
| 398 | #endif |
| 399 | #if defined(SOL_AAL) |
| 400 | { SOL_AAL, "SOL_AAL" }, |
| 401 | #endif |
| 402 | #if defined(SOL_IRDA) |
| 403 | { SOL_IRDA, "SOL_IRDA" }, |
| 404 | #endif |
Holger Hans Peter Freyther | ce9e0f4 | 2011-01-14 11:08:11 +0100 | [diff] [blame] | 405 | #if defined(SOL_NETBEUI) |
| 406 | { SOL_NETBEUI, "SOL_NETBEUI" }, |
| 407 | #endif |
| 408 | #if defined(SOL_LLC) |
| 409 | { SOL_LLC, "SOL_LLC" }, |
| 410 | #endif |
| 411 | #if defined(SOL_DCCP) |
| 412 | { SOL_DCCP, "SOL_DCCP" }, |
| 413 | #endif |
| 414 | #if defined(SOL_NETLINK) |
| 415 | { SOL_NETLINK, "SOL_NETLINK" }, |
| 416 | #endif |
| 417 | #if defined(SOL_TIPC) |
| 418 | { SOL_TIPC, "SOL_TIPC" }, |
| 419 | #endif |
| 420 | #if defined(SOL_RXRPC) |
| 421 | { SOL_RXRPC, "SOL_RXRPC" }, |
| 422 | #endif |
| 423 | #if defined(SOL_PPPOL2TP) |
| 424 | { SOL_PPPOL2TP, "SOL_PPPOL2TP" }, |
| 425 | #endif |
| 426 | #if defined(SOL_BLUETOOTH) |
| 427 | { SOL_BLUETOOTH,"SOL_BLUETOOTH" }, |
| 428 | #endif |
| 429 | #if defined(SOL_PNPIPE) |
| 430 | { SOL_PNPIPE, "SOL_PNPIPE" }, |
| 431 | #endif |
| 432 | #if defined(SOL_RDS) |
| 433 | { SOL_RDS, "SOL_RDS" }, |
| 434 | #endif |
| 435 | #if defined(SOL_IUVC) |
| 436 | { SOL_IUCV, "SOL_IUCV" }, |
| 437 | #endif |
| 438 | #if defined(SOL_CAIF) |
| 439 | { SOL_CAIF, "SOL_CAIF" }, |
| 440 | #endif |
John Hughes | 6156357 | 2001-03-27 16:47:36 +0000 | [diff] [blame] | 441 | { SOL_SOCKET, "SOL_SOCKET" }, /* Never used! */ |
Dmitry V. Levin | d475c06 | 2011-03-03 01:02:41 +0000 | [diff] [blame] | 442 | /* The SOL_* array should remain not NULL-terminated. */ |
Wichert Akkerman | efdecac | 2000-11-26 03:59:21 +0000 | [diff] [blame] | 443 | }; |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 444 | /*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above |
| 445 | falls into "protocols" array below!!!! This is intended!!! ***/ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 446 | static const struct xlat protocols[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 447 | { IPPROTO_IP, "IPPROTO_IP" }, |
| 448 | { IPPROTO_ICMP, "IPPROTO_ICMP" }, |
| 449 | { IPPROTO_TCP, "IPPROTO_TCP" }, |
| 450 | { IPPROTO_UDP, "IPPROTO_UDP" }, |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 451 | #ifdef IPPROTO_IGMP |
| 452 | { IPPROTO_IGMP, "IPPROTO_IGMP" }, |
| 453 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 454 | #ifdef IPPROTO_GGP |
| 455 | { IPPROTO_GGP, "IPPROTO_GGP" }, |
| 456 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 457 | #ifdef IPPROTO_IPIP |
| 458 | { IPPROTO_IPIP, "IPPROTO_IPIP" }, |
| 459 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 460 | #ifdef IPPROTO_EGP |
| 461 | { IPPROTO_EGP, "IPPROTO_EGP" }, |
| 462 | #endif |
| 463 | #ifdef IPPROTO_PUP |
| 464 | { IPPROTO_PUP, "IPPROTO_PUP" }, |
| 465 | #endif |
| 466 | #ifdef IPPROTO_IDP |
| 467 | { IPPROTO_IDP, "IPPROTO_IDP" }, |
| 468 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 469 | #ifdef IPPROTO_TP |
| 470 | { IPPROTO_TP, "IPPROTO_TP" }, |
| 471 | #endif |
| 472 | #ifdef IPPROTO_DCCP |
| 473 | { IPPROTO_DCCP, "IPPROTO_DCCP" }, |
| 474 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 475 | #ifdef IPPROTO_IPV6 |
| 476 | { IPPROTO_IPV6, "IPPROTO_IPV6" }, |
| 477 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 478 | #ifdef IPPROTO_ROUTING |
| 479 | { IPPROTO_ROUTING, "IPPROTO_ROUTING" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 480 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 481 | #ifdef IPPROTO_FRAGMENT |
| 482 | { IPPROTO_FRAGMENT, "IPPROTO_FRAGMENT" }, |
| 483 | #endif |
| 484 | #ifdef IPPROTO_RSVP |
| 485 | { IPPROTO_RSVP, "IPPROTO_RSVP" }, |
| 486 | #endif |
| 487 | #ifdef IPPROTO_GRE |
| 488 | { IPPROTO_GRE, "IPPROTO_GRE" }, |
| 489 | #endif |
| 490 | #ifdef IPPROTO_ESP |
| 491 | { IPPROTO_ESP, "IPPROTO_ESP" }, |
| 492 | #endif |
| 493 | #ifdef IPPROTO_AH |
| 494 | { IPPROTO_AH, "IPPROTO_AH" }, |
| 495 | #endif |
| 496 | #ifdef IPPROTO_ICMPV6 |
| 497 | { IPPROTO_ICMPV6, "IPPROTO_ICMPV6" }, |
| 498 | #endif |
| 499 | #ifdef IPPROTO_NONE |
| 500 | { IPPROTO_NONE, "IPPROTO_NONE" }, |
| 501 | #endif |
| 502 | #ifdef IPPROTO_DSTOPTS |
| 503 | { IPPROTO_DSTOPTS, "IPPROTO_DSTOPTS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 504 | #endif |
| 505 | #ifdef IPPROTO_HELLO |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 506 | { IPPROTO_HELLO, "IPPROTO_HELLO" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 507 | #endif |
| 508 | #ifdef IPPROTO_ND |
| 509 | { IPPROTO_ND, "IPPROTO_ND" }, |
| 510 | #endif |
Dmitry V. Levin | d48c6b9 | 2011-01-10 01:14:38 +0000 | [diff] [blame] | 511 | #ifdef IPPROTO_MTP |
| 512 | { IPPROTO_MTP, "IPPROTO_MTP" }, |
| 513 | #endif |
| 514 | #ifdef IPPROTO_ENCAP |
| 515 | { IPPROTO_ENCAP, "IPPROTO_ENCAP" }, |
| 516 | #endif |
| 517 | #ifdef IPPROTO_PIM |
| 518 | { IPPROTO_PIM, "IPPROTO_PIM" }, |
| 519 | #endif |
| 520 | #ifdef IPPROTO_COMP |
| 521 | { IPPROTO_COMP, "IPPROTO_COMP" }, |
| 522 | #endif |
| 523 | #ifdef IPPROTO_SCTP |
| 524 | { IPPROTO_SCTP, "IPPROTO_SCTP" }, |
| 525 | #endif |
| 526 | #ifdef IPPROTO_UDPLITE |
| 527 | { IPPROTO_UDPLITE, "IPPROTO_UDPLITE" }, |
| 528 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 529 | #ifdef IPPROTO_RAW |
| 530 | { IPPROTO_RAW, "IPPROTO_RAW" }, |
| 531 | #endif |
| 532 | #ifdef IPPROTO_MAX |
| 533 | { IPPROTO_MAX, "IPPROTO_MAX" }, |
| 534 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 535 | { 0, NULL }, |
| 536 | }; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 537 | static const struct xlat msg_flags[] = { |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 538 | { MSG_OOB, "MSG_OOB" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 539 | #ifdef MSG_DONTROUTE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 540 | { MSG_DONTROUTE, "MSG_DONTROUTE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 541 | #endif |
| 542 | #ifdef MSG_PEEK |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 543 | { MSG_PEEK, "MSG_PEEK" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 544 | #endif |
| 545 | #ifdef MSG_CTRUNC |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 546 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 547 | #endif |
| 548 | #ifdef MSG_PROXY |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 549 | { MSG_PROXY, "MSG_PROXY" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 550 | #endif |
| 551 | #ifdef MSG_EOR |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 552 | { MSG_EOR, "MSG_EOR" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 553 | #endif |
| 554 | #ifdef MSG_WAITALL |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 555 | { MSG_WAITALL, "MSG_WAITALL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 556 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 557 | #ifdef MSG_TRUNC |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 558 | { MSG_TRUNC, "MSG_TRUNC" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 559 | #endif |
| 560 | #ifdef MSG_CTRUNC |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 561 | { MSG_CTRUNC, "MSG_CTRUNC" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 562 | #endif |
| 563 | #ifdef MSG_ERRQUEUE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 564 | { MSG_ERRQUEUE, "MSG_ERRQUEUE" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 565 | #endif |
| 566 | #ifdef MSG_DONTWAIT |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 567 | { MSG_DONTWAIT, "MSG_DONTWAIT" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 568 | #endif |
| 569 | #ifdef MSG_CONFIRM |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 570 | { MSG_CONFIRM, "MSG_CONFIRM" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 571 | #endif |
| 572 | #ifdef MSG_PROBE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 573 | { MSG_PROBE, "MSG_PROBE" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 574 | #endif |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 575 | #ifdef MSG_FIN |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 576 | { MSG_FIN, "MSG_FIN" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 577 | #endif |
| 578 | #ifdef MSG_SYN |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 579 | { MSG_SYN, "MSG_SYN" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 580 | #endif |
| 581 | #ifdef MSG_RST |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 582 | { MSG_RST, "MSG_RST" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 583 | #endif |
| 584 | #ifdef MSG_NOSIGNAL |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 585 | { MSG_NOSIGNAL, "MSG_NOSIGNAL" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 586 | #endif |
| 587 | #ifdef MSG_MORE |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 588 | { MSG_MORE, "MSG_MORE" }, |
Roland McGrath | 05e5e79 | 2004-04-14 02:53:54 +0000 | [diff] [blame] | 589 | #endif |
Roland McGrath | 71d3d66 | 2007-08-07 01:00:26 +0000 | [diff] [blame] | 590 | #ifdef MSG_CMSG_CLOEXEC |
| 591 | { MSG_CMSG_CLOEXEC, "MSG_CMSG_CLOEXEC" }, |
| 592 | #endif |
| 593 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 594 | }; |
| 595 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 596 | static const struct xlat sockoptions[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 597 | #ifdef SO_ACCEPTCONN |
Roland McGrath | 1bf4373 | 2004-08-31 07:16:14 +0000 | [diff] [blame] | 598 | { SO_ACCEPTCONN, "SO_ACCEPTCONN" }, |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 599 | #endif |
| 600 | #ifdef SO_ALLRAW |
| 601 | { SO_ALLRAW, "SO_ALLRAW" }, |
| 602 | #endif |
Roland McGrath | 1bf4373 | 2004-08-31 07:16:14 +0000 | [diff] [blame] | 603 | #ifdef SO_ATTACH_FILTER |
| 604 | { SO_ATTACH_FILTER, "SO_ATTACH_FILTER" }, |
| 605 | #endif |
| 606 | #ifdef SO_BINDTODEVICE |
| 607 | { SO_BINDTODEVICE, "SO_BINDTODEVICE" }, |
| 608 | #endif |
| 609 | #ifdef SO_BROADCAST |
| 610 | { SO_BROADCAST, "SO_BROADCAST" }, |
| 611 | #endif |
| 612 | #ifdef SO_BSDCOMPAT |
| 613 | { SO_BSDCOMPAT, "SO_BSDCOMPAT" }, |
| 614 | #endif |
| 615 | #ifdef SO_DEBUG |
| 616 | { SO_DEBUG, "SO_DEBUG" }, |
| 617 | #endif |
| 618 | #ifdef SO_DETACH_FILTER |
| 619 | { SO_DETACH_FILTER, "SO_DETACH_FILTER" }, |
| 620 | #endif |
| 621 | #ifdef SO_DONTROUTE |
| 622 | { SO_DONTROUTE, "SO_DONTROUTE" }, |
| 623 | #endif |
| 624 | #ifdef SO_ERROR |
| 625 | { SO_ERROR, "SO_ERROR" }, |
| 626 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 627 | #ifdef SO_ICS |
| 628 | { SO_ICS, "SO_ICS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 629 | #endif |
Roland McGrath | 1bf4373 | 2004-08-31 07:16:14 +0000 | [diff] [blame] | 630 | #ifdef SO_IMASOCKET |
| 631 | { SO_IMASOCKET, "SO_IMASOCKET" }, |
| 632 | #endif |
| 633 | #ifdef SO_KEEPALIVE |
| 634 | { SO_KEEPALIVE, "SO_KEEPALIVE" }, |
| 635 | #endif |
| 636 | #ifdef SO_LINGER |
| 637 | { SO_LINGER, "SO_LINGER" }, |
| 638 | #endif |
| 639 | #ifdef SO_LISTENING |
| 640 | { SO_LISTENING, "SO_LISTENING" }, |
| 641 | #endif |
| 642 | #ifdef SO_MGMT |
| 643 | { SO_MGMT, "SO_MGMT" }, |
| 644 | #endif |
| 645 | #ifdef SO_NO_CHECK |
| 646 | { SO_NO_CHECK, "SO_NO_CHECK" }, |
| 647 | #endif |
| 648 | #ifdef SO_OOBINLINE |
| 649 | { SO_OOBINLINE, "SO_OOBINLINE" }, |
| 650 | #endif |
| 651 | #ifdef SO_ORDREL |
| 652 | { SO_ORDREL, "SO_ORDREL" }, |
| 653 | #endif |
| 654 | #ifdef SO_PARALLELSVR |
| 655 | { SO_PARALLELSVR, "SO_PARALLELSVR" }, |
| 656 | #endif |
| 657 | #ifdef SO_PASSCRED |
| 658 | { SO_PASSCRED, "SO_PASSCRED" }, |
| 659 | #endif |
| 660 | #ifdef SO_PEERCRED |
| 661 | { SO_PEERCRED, "SO_PEERCRED" }, |
| 662 | #endif |
| 663 | #ifdef SO_PEERNAME |
| 664 | { SO_PEERNAME, "SO_PEERNAME" }, |
| 665 | #endif |
| 666 | #ifdef SO_PEERSEC |
| 667 | { SO_PEERSEC, "SO_PEERSEC" }, |
| 668 | #endif |
| 669 | #ifdef SO_PRIORITY |
| 670 | { SO_PRIORITY, "SO_PRIORITY" }, |
| 671 | #endif |
| 672 | #ifdef SO_PROTOTYPE |
| 673 | { SO_PROTOTYPE, "SO_PROTOTYPE" }, |
| 674 | #endif |
| 675 | #ifdef SO_RCVBUF |
| 676 | { SO_RCVBUF, "SO_RCVBUF" }, |
| 677 | #endif |
| 678 | #ifdef SO_RCVLOWAT |
| 679 | { SO_RCVLOWAT, "SO_RCVLOWAT" }, |
| 680 | #endif |
| 681 | #ifdef SO_RCVTIMEO |
| 682 | { SO_RCVTIMEO, "SO_RCVTIMEO" }, |
| 683 | #endif |
| 684 | #ifdef SO_RDWR |
| 685 | { SO_RDWR, "SO_RDWR" }, |
| 686 | #endif |
| 687 | #ifdef SO_REUSEADDR |
| 688 | { SO_REUSEADDR, "SO_REUSEADDR" }, |
| 689 | #endif |
| 690 | #ifdef SO_REUSEPORT |
| 691 | { SO_REUSEPORT, "SO_REUSEPORT" }, |
| 692 | #endif |
| 693 | #ifdef SO_SECURITY_AUTHENTICATION |
| 694 | { SO_SECURITY_AUTHENTICATION,"SO_SECURITY_AUTHENTICATION"}, |
| 695 | #endif |
| 696 | #ifdef SO_SECURITY_ENCRYPTION_NETWORK |
| 697 | { SO_SECURITY_ENCRYPTION_NETWORK,"SO_SECURITY_ENCRYPTION_NETWORK"}, |
| 698 | #endif |
| 699 | #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT |
| 700 | { SO_SECURITY_ENCRYPTION_TRANSPORT,"SO_SECURITY_ENCRYPTION_TRANSPORT"}, |
| 701 | #endif |
| 702 | #ifdef SO_SEMA |
| 703 | { SO_SEMA, "SO_SEMA" }, |
| 704 | #endif |
| 705 | #ifdef SO_SNDBUF |
| 706 | { SO_SNDBUF, "SO_SNDBUF" }, |
| 707 | #endif |
| 708 | #ifdef SO_SNDLOWAT |
| 709 | { SO_SNDLOWAT, "SO_SNDLOWAT" }, |
| 710 | #endif |
| 711 | #ifdef SO_SNDTIMEO |
| 712 | { SO_SNDTIMEO, "SO_SNDTIMEO" }, |
| 713 | #endif |
| 714 | #ifdef SO_TIMESTAMP |
| 715 | { SO_TIMESTAMP, "SO_TIMESTAMP" }, |
| 716 | #endif |
| 717 | #ifdef SO_TYPE |
| 718 | { SO_TYPE, "SO_TYPE" }, |
| 719 | #endif |
| 720 | #ifdef SO_USELOOPBACK |
| 721 | { SO_USELOOPBACK, "SO_USELOOPBACK" }, |
| 722 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 723 | { 0, NULL }, |
| 724 | }; |
| 725 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 726 | #if !defined(SOL_IP) && defined(IPPROTO_IP) |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 727 | #define SOL_IP IPPROTO_IP |
| 728 | #endif |
| 729 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 730 | #ifdef SOL_IP |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 731 | static const struct xlat sockipoptions[] = { |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 732 | #ifdef IP_TOS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 733 | { IP_TOS, "IP_TOS" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 734 | #endif |
| 735 | #ifdef IP_TTL |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 736 | { IP_TTL, "IP_TTL" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 737 | #endif |
| 738 | #ifdef IP_HDRINCL |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 739 | { IP_HDRINCL, "IP_HDRINCL" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 740 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 741 | #ifdef IP_OPTIONS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 742 | { IP_OPTIONS, "IP_OPTIONS" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 743 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 744 | #ifdef IP_ROUTER_ALERT |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 745 | { IP_ROUTER_ALERT, "IP_ROUTER_ALERT" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 746 | #endif |
| 747 | #ifdef IP_RECVOPTIONS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 748 | { IP_RECVOPTIONS, "IP_RECVOPTIONS" }, |
| 749 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 750 | #ifdef IP_RECVOPTS |
| 751 | { IP_RECVOPTS, "IP_RECVOPTS" }, |
| 752 | #endif |
| 753 | #ifdef IP_RECVRETOPTS |
| 754 | { IP_RECVRETOPTS, "IP_RECVRETOPTS" }, |
| 755 | #endif |
| 756 | #ifdef IP_RECVDSTADDR |
| 757 | { IP_RECVDSTADDR, "IP_RECVDSTADDR" }, |
| 758 | #endif |
| 759 | #ifdef IP_RETOPTS |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 760 | { IP_RETOPTS, "IP_RETOPTS" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 761 | #endif |
| 762 | #ifdef IP_PKTINFO |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 763 | { IP_PKTINFO, "IP_PKTINFO" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 764 | #endif |
| 765 | #ifdef IP_PKTOPTIONS |
| 766 | { IP_PKTOPTIONS, "IP_PKTOPTIONS" }, |
| 767 | #endif |
| 768 | #ifdef IP_MTU_DISCOVER |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 769 | { IP_MTU_DISCOVER, "IP_MTU_DISCOVER" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 770 | #endif |
| 771 | #ifdef IP_RECVERR |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 772 | { IP_RECVERR, "IP_RECVERR" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 773 | #endif |
| 774 | #ifdef IP_RECVTTL |
Roland McGrath | 04ac03a | 2005-07-04 23:30:27 +0000 | [diff] [blame] | 775 | { IP_RECVTTL, "IP_RECVTTL" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 776 | #endif |
| 777 | #ifdef IP_RECVTOS |
Roland McGrath | 04ac03a | 2005-07-04 23:30:27 +0000 | [diff] [blame] | 778 | { IP_RECVTOS, "IP_RECVTOS" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 779 | #endif |
| 780 | #ifdef IP_MTU |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 781 | { IP_MTU, "IP_MTU" }, |
| 782 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 783 | #ifdef IP_MULTICAST_IF |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 784 | { IP_MULTICAST_IF, "IP_MULTICAST_IF" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 785 | #endif |
| 786 | #ifdef IP_MULTICAST_TTL |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 787 | { IP_MULTICAST_TTL, "IP_MULTICAST_TTL" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 788 | #endif |
| 789 | #ifdef IP_MULTICAST_LOOP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 790 | { IP_MULTICAST_LOOP, "IP_MULTICAST_LOOP" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 791 | #endif |
| 792 | #ifdef IP_ADD_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 793 | { IP_ADD_MEMBERSHIP, "IP_ADD_MEMBERSHIP" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 794 | #endif |
| 795 | #ifdef IP_DROP_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 796 | { IP_DROP_MEMBERSHIP, "IP_DROP_MEMBERSHIP" }, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 797 | #endif |
| 798 | #ifdef IP_BROADCAST_IF |
| 799 | { IP_BROADCAST_IF, "IP_BROADCAST_IF" }, |
| 800 | #endif |
| 801 | #ifdef IP_RECVIFINDEX |
| 802 | { IP_RECVIFINDEX, "IP_RECVIFINDEX" }, |
| 803 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 804 | #ifdef IP_MSFILTER |
| 805 | { IP_MSFILTER, "IP_MSFILTER" }, |
| 806 | #endif |
| 807 | #ifdef MCAST_MSFILTER |
| 808 | { MCAST_MSFILTER, "MCAST_MSFILTER" }, |
| 809 | #endif |
| 810 | #ifdef IP_FREEBIND |
| 811 | { IP_FREEBIND, "IP_FREEBIND" }, |
| 812 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 813 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 814 | }; |
| 815 | #endif /* SOL_IP */ |
| 816 | |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 817 | #ifdef SOL_IPV6 |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 818 | static const struct xlat sockipv6options[] = { |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 819 | #ifdef IPV6_ADDRFORM |
| 820 | { IPV6_ADDRFORM, "IPV6_ADDRFORM" }, |
| 821 | #endif |
| 822 | #ifdef MCAST_FILTER |
| 823 | { MCAST_FILTER, "MCAST_FILTER" }, |
| 824 | #endif |
| 825 | #ifdef IPV6_PKTOPTIONS |
| 826 | { IPV6_PKTOPTIONS, "IPV6_PKTOPTIONS" }, |
| 827 | #endif |
| 828 | #ifdef IPV6_MTU |
| 829 | { IPV6_MTU, "IPV6_MTU" }, |
| 830 | #endif |
| 831 | #ifdef IPV6_V6ONLY |
| 832 | { IPV6_V6ONLY, "IPV6_V6ONLY" }, |
| 833 | #endif |
| 834 | #ifdef IPV6_PKTINFO |
| 835 | { IPV6_PKTINFO, "IPV6_PKTINFO" }, |
| 836 | #endif |
| 837 | #ifdef IPV6_HOPLIMIT |
| 838 | { IPV6_HOPLIMIT, "IPV6_HOPLIMIT" }, |
| 839 | #endif |
| 840 | #ifdef IPV6_RTHDR |
| 841 | { IPV6_RTHDR, "IPV6_RTHDR" }, |
| 842 | #endif |
| 843 | #ifdef IPV6_HOPOPTS |
| 844 | { IPV6_HOPOPTS, "IPV6_HOPOPTS" }, |
| 845 | #endif |
| 846 | #ifdef IPV6_DSTOPTS |
| 847 | { IPV6_DSTOPTS, "IPV6_DSTOPTS" }, |
| 848 | #endif |
| 849 | #ifdef IPV6_FLOWINFO |
| 850 | { IPV6_FLOWINFO, "IPV6_FLOWINFO" }, |
| 851 | #endif |
| 852 | #ifdef IPV6_UNICAST_HOPS |
| 853 | { IPV6_UNICAST_HOPS, "IPV6_UNICAST_HOPS" }, |
| 854 | #endif |
| 855 | #ifdef IPV6_MULTICAST_HOPS |
| 856 | { IPV6_MULTICAST_HOPS, "IPV6_MULTICAST_HOPS" }, |
| 857 | #endif |
| 858 | #ifdef IPV6_MULTICAST_LOOP |
| 859 | { IPV6_MULTICAST_LOOP, "IPV6_MULTICAST_LOOP" }, |
| 860 | #endif |
| 861 | #ifdef IPV6_MULTICAST_IF |
| 862 | { IPV6_MULTICAST_IF, "IPV6_MULTICAST_IF" }, |
| 863 | #endif |
| 864 | #ifdef IPV6_MTU_DISCOVER |
| 865 | { IPV6_MTU_DISCOVER, "IPV6_MTU_DISCOVER" }, |
| 866 | #endif |
| 867 | #ifdef IPV6_RECVERR |
| 868 | { IPV6_RECVERR, "IPV6_RECVERR" }, |
| 869 | #endif |
| 870 | #ifdef IPV6_FLOWINFO_SEND |
| 871 | { IPV6_FLOWINFO_SEND, "IPV6_FLOWINFO_SEND" }, |
| 872 | #endif |
Roland McGrath | c0b9e37 | 2005-07-04 23:33:38 +0000 | [diff] [blame] | 873 | #ifdef IPV6_ADD_MEMBERSHIP |
| 874 | { IPV6_ADD_MEMBERSHIP, "IPV6_ADD_MEMBERSHIP" }, |
| 875 | #endif |
| 876 | #ifdef IPV6_DROP_MEMBERSHIP |
| 877 | { IPV6_DROP_MEMBERSHIP, "IPV6_DROP_MEMBERSHIP" }, |
| 878 | #endif |
| 879 | #ifdef IPV6_ROUTER_ALERT |
| 880 | { IPV6_ROUTER_ALERT, "IPV6_ROUTER_ALERT" }, |
| 881 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 882 | { 0, NULL }, |
| 883 | }; |
| 884 | #endif /* SOL_IPV6 */ |
| 885 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 886 | #ifdef SOL_IPX |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 887 | static const struct xlat sockipxoptions[] = { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 888 | { IPX_TYPE, "IPX_TYPE" }, |
| 889 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 890 | }; |
| 891 | #endif /* SOL_IPX */ |
| 892 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 893 | #ifdef SOL_RAW |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 894 | static const struct xlat sockrawoptions[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 895 | #if defined(ICMP_FILTER) |
| 896 | { ICMP_FILTER, "ICMP_FILTER" }, |
| 897 | #endif |
| 898 | { 0, NULL }, |
| 899 | }; |
| 900 | #endif /* SOL_RAW */ |
| 901 | |
| 902 | #ifdef SOL_PACKET |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 903 | static const struct xlat sockpacketoptions[] = { |
Roland McGrath | c294b8f | 2007-11-01 21:37:33 +0000 | [diff] [blame] | 904 | #ifdef PACKET_ADD_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 905 | { PACKET_ADD_MEMBERSHIP, "PACKET_ADD_MEMBERSHIP" }, |
Roland McGrath | c294b8f | 2007-11-01 21:37:33 +0000 | [diff] [blame] | 906 | #endif |
| 907 | #ifdef PACKET_DROP_MEMBERSHIP |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 908 | { PACKET_DROP_MEMBERSHIP, "PACKET_DROP_MEMBERSHIP"}, |
Roland McGrath | c294b8f | 2007-11-01 21:37:33 +0000 | [diff] [blame] | 909 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 910 | #if defined(PACKET_RECV_OUTPUT) |
| 911 | { PACKET_RECV_OUTPUT, "PACKET_RECV_OUTPUT" }, |
| 912 | #endif |
| 913 | #if defined(PACKET_RX_RING) |
| 914 | { PACKET_RX_RING, "PACKET_RX_RING" }, |
| 915 | #endif |
| 916 | #if defined(PACKET_STATISTICS) |
| 917 | { PACKET_STATISTICS, "PACKET_STATISTICS" }, |
| 918 | #endif |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 919 | #if defined(PACKET_COPY_THRESH) |
| 920 | { PACKET_COPY_THRESH, "PACKET_COPY_THRESH" }, |
| 921 | #endif |
| 922 | #if defined(PACKET_AUXDATA) |
| 923 | { PACKET_AUXDATA, "PACKET_AUXDATA" }, |
| 924 | #endif |
| 925 | #if defined(PACKET_ORIGDEV) |
| 926 | { PACKET_ORIGDEV, "PACKET_ORIGDEV" }, |
| 927 | #endif |
| 928 | #if defined(PACKET_VERSION) |
| 929 | { PACKET_VERSION, "PACKET_VERSION" }, |
| 930 | #endif |
| 931 | #if defined(PACKET_HDRLEN) |
| 932 | { PACKET_HDRLEN, "PACKET_HDRLEN" }, |
| 933 | #endif |
| 934 | #if defined(PACKET_RESERVE) |
| 935 | { PACKET_RESERVE, "PACKET_RESERVE" }, |
| 936 | #endif |
| 937 | #if defined(PACKET_TX_RING) |
| 938 | { PACKET_TX_RING, "PACKET_TX_RING" }, |
| 939 | #endif |
| 940 | #if defined(PACKET_LOSS) |
| 941 | { PACKET_LOSS, "PACKET_LOSS" }, |
| 942 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 943 | { 0, NULL }, |
| 944 | }; |
| 945 | #endif /* SOL_PACKET */ |
| 946 | |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 947 | #ifdef SOL_SCTP |
| 948 | static const struct xlat socksctpoptions[] = { |
| 949 | #if defined(SCTP_RTOINFO) |
| 950 | { SCTP_RTOINFO, "SCTP_RTOINFO" }, |
| 951 | #endif |
| 952 | #if defined(SCTP_ASSOCINFO) |
| 953 | { SCTP_ASSOCINFO, "SCTP_ASSOCINFO"}, |
| 954 | #endif |
| 955 | #if defined(SCTP_INITMSG) |
| 956 | { SCTP_INITMSG, "SCTP_INITMSG" }, |
| 957 | #endif |
| 958 | #if defined(SCTP_NODELAY) |
| 959 | { SCTP_NODELAY, "SCTP_NODELAY" }, |
| 960 | #endif |
| 961 | #if defined(SCTP_AUTOCLOSE) |
| 962 | { SCTP_AUTOCLOSE, "SCTP_AUTOCLOSE"}, |
| 963 | #endif |
| 964 | #if defined(SCTP_SET_PEER_PRIMARY_ADDR) |
| 965 | { SCTP_SET_PEER_PRIMARY_ADDR, "SCTP_SET_PEER_PRIMARY_ADDR"}, |
| 966 | #endif |
| 967 | #if defined(SCTP_PRIMARY_ADDR) |
| 968 | { SCTP_PRIMARY_ADDR, "SCTP_PRIMARY_ADDR" }, |
| 969 | #endif |
| 970 | #if defined(SCTP_ADAPTATION_LAYER) |
| 971 | { SCTP_ADAPTATION_LAYER, "SCTP_ADAPTATION_LAYER" }, |
| 972 | #endif |
| 973 | #if defined(SCTP_DISABLE_FRAGMENTS) |
| 974 | { SCTP_DISABLE_FRAGMENTS, "SCTP_DISABLE_FRAGMENTS"}, |
| 975 | #endif |
| 976 | #if defined(SCTP_PEER_ADDR_PARAMS) |
| 977 | { SCTP_PEER_ADDR_PARAMS, "SCTP_PEER_ADDR_PARAMS" }, |
| 978 | #endif |
| 979 | #if defined(SCTP_DEFAULT_SEND_PARAM) |
| 980 | { SCTP_DEFAULT_SEND_PARAM, "SCTP_DEFAULT_SEND_PARAM"}, |
| 981 | #endif |
| 982 | #if defined(SCTP_EVENTS) |
| 983 | { SCTP_EVENTS, "SCTP_EVENTS" }, |
| 984 | #endif |
| 985 | #if defined(SCTP_I_WANT_MAPPED_V4_ADDR) |
| 986 | { SCTP_I_WANT_MAPPED_V4_ADDR, "SCTP_I_WANT_MAPPED_V4_ADDR"}, |
| 987 | #endif |
| 988 | #if defined(SCTP_MAXSEG) |
| 989 | { SCTP_MAXSEG, "SCTP_MAXSEG" }, |
| 990 | #endif |
| 991 | #if defined(SCTP_STATUS) |
| 992 | { SCTP_STATUS, "SCTP_STATUS" }, |
| 993 | #endif |
| 994 | #if defined(SCTP_GET_PEER_ADDR_INFO) |
| 995 | { SCTP_GET_PEER_ADDR_INFO, "SCTP_GET_PEER_ADDR_INFO"}, |
| 996 | #endif |
| 997 | #if defined(SCTP_DELAYED_ACK) |
| 998 | { SCTP_DELAYED_ACK, "SCTP_DELAYED_ACK" }, |
| 999 | #endif |
| 1000 | #if defined(SCTP_CONTEXT) |
| 1001 | { SCTP_CONTEXT, "SCTP_CONTEXT" }, |
| 1002 | #endif |
| 1003 | #if defined(SCTP_FRAGMENT_INTERLEAVE) |
| 1004 | { SCTP_FRAGMENT_INTERLEAVE, "SCTP_FRAGMENT_INTERLEAVE"}, |
| 1005 | #endif |
| 1006 | #if defined(SCTP_PARTIAL_DELIVERY_POINT) |
| 1007 | { SCTP_PARTIAL_DELIVERY_POINT, "SCTP_PARTIAL_DELIVERY_POINT"}, |
| 1008 | #endif |
| 1009 | #if defined(SCTP_MAX_BURST) |
| 1010 | { SCTP_MAX_BURST, "SCTP_MAX_BURST" }, |
| 1011 | #endif |
| 1012 | #if defined(SCTP_AUTH_CHUNK) |
| 1013 | { SCTP_AUTH_CHUNK, "SCTP_AUTH_CHUNK" }, |
| 1014 | #endif |
| 1015 | #if defined(SCTP_HMAC_IDENT) |
| 1016 | { SCTP_HMAC_IDENT, "SCTP_HMAC_IDENT" }, |
| 1017 | #endif |
| 1018 | #if defined(SCTP_AUTH_KEY) |
| 1019 | { SCTP_AUTH_KEY, "SCTP_AUTH_KEY" }, |
| 1020 | #endif |
| 1021 | #if defined(SCTP_AUTH_ACTIVE_KEY) |
| 1022 | { SCTP_AUTH_ACTIVE_KEY, "SCTP_AUTH_ACTIVE_KEY" }, |
| 1023 | #endif |
| 1024 | #if defined(SCTP_AUTH_DELETE_KEY) |
| 1025 | { SCTP_AUTH_DELETE_KEY, "SCTP_AUTH_DELETE_KEY" }, |
| 1026 | #endif |
| 1027 | #if defined(SCTP_PEER_AUTH_CHUNKS) |
| 1028 | { SCTP_PEER_AUTH_CHUNKS, "SCTP_PEER_AUTH_CHUNKS" }, |
| 1029 | #endif |
| 1030 | #if defined(SCTP_LOCAL_AUTH_CHUNKS) |
| 1031 | { SCTP_LOCAL_AUTH_CHUNKS, "SCTP_LOCAL_AUTH_CHUNKS"}, |
| 1032 | #endif |
| 1033 | #if defined(SCTP_GET_ASSOC_NUMBER) |
| 1034 | { SCTP_GET_ASSOC_NUMBER, "SCTP_GET_ASSOC_NUMBER" }, |
| 1035 | #endif |
| 1036 | |
| 1037 | /* linux specific things */ |
| 1038 | #if defined(SCTP_SOCKOPT_BINDX_ADD) |
| 1039 | { SCTP_SOCKOPT_BINDX_ADD, "SCTP_SOCKOPT_BINDX_ADD" }, |
| 1040 | #endif |
| 1041 | #if defined(SCTP_SOCKOPT_BINDX_REM) |
| 1042 | { SCTP_SOCKOPT_BINDX_REM, "SCTP_SOCKOPT_BINDX_REM" }, |
| 1043 | #endif |
| 1044 | #if defined(SCTP_SOCKOPT_PEELOFF) |
| 1045 | { SCTP_SOCKOPT_PEELOFF, "SCTP_SOCKOPT_PEELOFF" }, |
| 1046 | #endif |
| 1047 | #if defined(SCTP_GET_PEER_ADDRS_NUM_OLD) |
| 1048 | { SCTP_GET_PEER_ADDRS_NUM_OLD, "SCTP_GET_PEER_ADDRS_NUM_OLD" }, |
| 1049 | #endif |
| 1050 | #if defined(SCTP_GET_PEER_ADDRS_OLD) |
| 1051 | { SCTP_GET_PEER_ADDRS_OLD, "SCTP_GET_PEER_ADDRS_OLD" }, |
| 1052 | #endif |
| 1053 | #if defined(SCTP_GET_LOCAL_ADDRS_NUM_OLD) |
| 1054 | { SCTP_GET_LOCAL_ADDRS_NUM_OLD, "SCTP_GET_LOCAL_ADDRS_NUM_OLD" }, |
| 1055 | #endif |
| 1056 | #if defined(SCTP_GET_LOCAL_ADDRS_OLD) |
| 1057 | { SCTP_GET_LOCAL_ADDRS_OLD, "SCTP_GET_LOCAL_ADDRS_OLD" }, |
| 1058 | #endif |
| 1059 | #if defined(SCTP_SOCKOPT_CONNECTX_OLD) |
| 1060 | { SCTP_SOCKOPT_CONNECTX_OLD, "SCTP_SOCKOPT_CONNECTX_OLD" }, |
| 1061 | #endif |
| 1062 | #if defined(SCTP_GET_PEER_ADDRS) |
| 1063 | { SCTP_GET_PEER_ADDRS, "SCTP_GET_PEER_ADDRS" }, |
| 1064 | #endif |
| 1065 | #if defined(SCTP_GET_LOCAL_ADDRS) |
| 1066 | { SCTP_GET_LOCAL_ADDRS, "SCTP_GET_LOCAL_ADDRS" }, |
| 1067 | #endif |
| 1068 | |
| 1069 | { 0, NULL }, |
| 1070 | }; |
| 1071 | #endif |
| 1072 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 1073 | #if !defined(SOL_TCP) && defined(IPPROTO_TCP) |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1074 | #define SOL_TCP IPPROTO_TCP |
| 1075 | #endif |
| 1076 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1077 | #ifdef SOL_TCP |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1078 | static const struct xlat socktcpoptions[] = { |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1079 | { TCP_NODELAY, "TCP_NODELAY" }, |
| 1080 | { TCP_MAXSEG, "TCP_MAXSEG" }, |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1081 | #if defined(TCP_CORK) |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1082 | { TCP_CORK, "TCP_CORK" }, |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1083 | #endif |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1084 | #if defined(TCP_KEEPIDLE) |
| 1085 | { TCP_KEEPIDLE, "TCP_KEEPIDLE" }, |
| 1086 | #endif |
| 1087 | #if defined(TCP_KEEPINTVL) |
| 1088 | { TCP_KEEPINTVL, "TCP_KEEPINTVL" }, |
| 1089 | #endif |
| 1090 | #if defined(TCP_KEEPCNT) |
| 1091 | { TCP_KEEPCNT, "TCP_KEEPCNT" }, |
| 1092 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 1093 | #if defined(TCP_NKEEP) |
| 1094 | { TCP_NKEEP, "TCP_NKEEP" }, |
| 1095 | #endif |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1096 | #if defined(TCP_SYNCNT) |
| 1097 | { TCP_SYNCNT, "TCP_SYNCNT" }, |
| 1098 | #endif |
| 1099 | #if defined(TCP_LINGER2) |
| 1100 | { TCP_LINGER2, "TCP_LINGER2" }, |
| 1101 | #endif |
| 1102 | #if defined(TCP_DEFER_ACCEPT) |
| 1103 | { TCP_DEFER_ACCEPT, "TCP_DEFER_ACCEPT" }, |
| 1104 | #endif |
| 1105 | #if defined(TCP_WINDOW_CLAMP) |
| 1106 | { TCP_WINDOW_CLAMP, "TCP_WINDOW_CLAMP" }, |
| 1107 | #endif |
| 1108 | #if defined(TCP_INFO) |
| 1109 | { TCP_INFO, "TCP_INFO" }, |
| 1110 | #endif |
| 1111 | #if defined(TCP_QUICKACK) |
| 1112 | { TCP_QUICKACK, "TCP_QUICKACK" }, |
| 1113 | #endif |
Dmitry V. Levin | b05fc54 | 2011-12-01 21:06:00 +0000 | [diff] [blame] | 1114 | #if defined(TCP_CONGESTION) |
| 1115 | { TCP_CONGESTION, "TCP_CONGESTION" }, |
| 1116 | #endif |
| 1117 | #if defined(TCP_MD5SIG) |
| 1118 | { TCP_MD5SIG, "TCP_MD5SIG" }, |
| 1119 | #endif |
| 1120 | #if defined(TCP_COOKIE_TRANSACTIONS) |
| 1121 | { TCP_COOKIE_TRANSACTIONS, "TCP_COOKIE_TRANSACTIONS" }, |
| 1122 | #endif |
| 1123 | #if defined(TCP_THIN_LINEAR_TIMEOUTS) |
| 1124 | { TCP_THIN_LINEAR_TIMEOUTS, "TCP_THIN_LINEAR_TIMEOUTS" }, |
| 1125 | #endif |
| 1126 | #if defined(TCP_THIN_DUPACK) |
| 1127 | { TCP_THIN_DUPACK, "TCP_THIN_DUPACK" }, |
| 1128 | #endif |
| 1129 | #if defined(TCP_USER_TIMEOUT) |
| 1130 | { TCP_USER_TIMEOUT, "TCP_USER_TIMEOUT" }, |
| 1131 | #endif |
Wichert Akkerman | 8b8ff7c | 2001-12-27 22:27:30 +0000 | [diff] [blame] | 1132 | { 0, NULL }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1133 | }; |
| 1134 | #endif /* SOL_TCP */ |
| 1135 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1136 | #ifdef SOL_RAW |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1137 | static const struct xlat icmpfilterflags[] = { |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1138 | #if defined(ICMP_ECHOREPLY) |
| 1139 | { (1<<ICMP_ECHOREPLY), "ICMP_ECHOREPLY" }, |
| 1140 | #endif |
| 1141 | #if defined(ICMP_DEST_UNREACH) |
| 1142 | { (1<<ICMP_DEST_UNREACH), "ICMP_DEST_UNREACH" }, |
| 1143 | #endif |
| 1144 | #if defined(ICMP_SOURCE_QUENCH) |
| 1145 | { (1<<ICMP_SOURCE_QUENCH), "ICMP_SOURCE_QUENCH" }, |
| 1146 | #endif |
| 1147 | #if defined(ICMP_REDIRECT) |
| 1148 | { (1<<ICMP_REDIRECT), "ICMP_REDIRECT" }, |
| 1149 | #endif |
| 1150 | #if defined(ICMP_ECHO) |
| 1151 | { (1<<ICMP_ECHO), "ICMP_ECHO" }, |
| 1152 | #endif |
| 1153 | #if defined(ICMP_TIME_EXCEEDED) |
| 1154 | { (1<<ICMP_TIME_EXCEEDED), "ICMP_TIME_EXCEEDED" }, |
| 1155 | #endif |
| 1156 | #if defined(ICMP_PARAMETERPROB) |
| 1157 | { (1<<ICMP_PARAMETERPROB), "ICMP_PARAMETERPROB" }, |
| 1158 | #endif |
| 1159 | #if defined(ICMP_TIMESTAMP) |
| 1160 | { (1<<ICMP_TIMESTAMP), "ICMP_TIMESTAMP" }, |
| 1161 | #endif |
| 1162 | #if defined(ICMP_TIMESTAMPREPLY) |
| 1163 | { (1<<ICMP_TIMESTAMPREPLY), "ICMP_TIMESTAMPREPLY" }, |
| 1164 | #endif |
| 1165 | #if defined(ICMP_INFO_REQUEST) |
| 1166 | { (1<<ICMP_INFO_REQUEST), "ICMP_INFO_REQUEST" }, |
| 1167 | #endif |
| 1168 | #if defined(ICMP_INFO_REPLY) |
| 1169 | { (1<<ICMP_INFO_REPLY), "ICMP_INFO_REPLY" }, |
| 1170 | #endif |
| 1171 | #if defined(ICMP_ADDRESS) |
| 1172 | { (1<<ICMP_ADDRESS), "ICMP_ADDRESS" }, |
| 1173 | #endif |
| 1174 | #if defined(ICMP_ADDRESSREPLY) |
| 1175 | { (1<<ICMP_ADDRESSREPLY), "ICMP_ADDRESSREPLY" }, |
| 1176 | #endif |
| 1177 | { 0, NULL }, |
| 1178 | }; |
| 1179 | #endif /* SOL_RAW */ |
| 1180 | |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1181 | #if defined(AF_PACKET) /* from e.g. linux/if_packet.h */ |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 1182 | static const struct xlat af_packet_types[] = { |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1183 | #if defined(PACKET_HOST) |
| 1184 | { PACKET_HOST, "PACKET_HOST" }, |
| 1185 | #endif |
| 1186 | #if defined(PACKET_BROADCAST) |
| 1187 | { PACKET_BROADCAST, "PACKET_BROADCAST" }, |
| 1188 | #endif |
| 1189 | #if defined(PACKET_MULTICAST) |
| 1190 | { PACKET_MULTICAST, "PACKET_MULTICAST" }, |
| 1191 | #endif |
| 1192 | #if defined(PACKET_OTHERHOST) |
| 1193 | { PACKET_OTHERHOST, "PACKET_OTHERHOST" }, |
| 1194 | #endif |
| 1195 | #if defined(PACKET_OUTGOING) |
| 1196 | { PACKET_OUTGOING, "PACKET_OUTGOING" }, |
| 1197 | #endif |
| 1198 | #if defined(PACKET_LOOPBACK) |
| 1199 | { PACKET_LOOPBACK, "PACKET_LOOPBACK" }, |
| 1200 | #endif |
| 1201 | #if defined(PACKET_FASTROUTE) |
| 1202 | { PACKET_FASTROUTE, "PACKET_FASTROUTE" }, |
| 1203 | #endif |
| 1204 | { 0, NULL }, |
| 1205 | }; |
| 1206 | #endif /* defined(AF_PACKET) */ |
| 1207 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1208 | void |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1209 | printsock(struct tcb *tcp, long addr, int addrlen) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1210 | { |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1211 | union { |
| 1212 | char pad[128]; |
| 1213 | struct sockaddr sa; |
| 1214 | struct sockaddr_in sin; |
| 1215 | struct sockaddr_un sau; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1216 | #ifdef HAVE_INET_NTOP |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1217 | struct sockaddr_in6 sa6; |
| 1218 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1219 | #if defined(AF_IPX) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1220 | struct sockaddr_ipx sipx; |
| 1221 | #endif |
| 1222 | #ifdef AF_PACKET |
| 1223 | struct sockaddr_ll ll; |
| 1224 | #endif |
| 1225 | #ifdef AF_NETLINK |
| 1226 | struct sockaddr_nl nl; |
| 1227 | #endif |
| 1228 | } addrbuf; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1229 | char string_addr[100]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1230 | |
| 1231 | if (addr == 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1232 | tprints("NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1233 | return; |
| 1234 | } |
| 1235 | if (!verbose(tcp)) { |
| 1236 | tprintf("%#lx", addr); |
| 1237 | return; |
| 1238 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1239 | |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1240 | if (addrlen < 2 || addrlen > sizeof(addrbuf)) |
| 1241 | addrlen = sizeof(addrbuf); |
| 1242 | |
| 1243 | memset(&addrbuf, 0, sizeof(addrbuf)); |
| 1244 | if (umoven(tcp, addr, addrlen, addrbuf.pad) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1245 | tprints("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1246 | return; |
| 1247 | } |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1248 | addrbuf.pad[sizeof(addrbuf.pad) - 1] = '\0'; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1249 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1250 | tprints("{sa_family="); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1251 | printxval(addrfams, addrbuf.sa.sa_family, "AF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1252 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1253 | |
| 1254 | switch (addrbuf.sa.sa_family) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1255 | case AF_UNIX: |
Dmitry V. Levin | b6c32f4 | 2007-10-08 23:31:19 +0000 | [diff] [blame] | 1256 | if (addrlen == 2) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1257 | tprints("NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1258 | } else if (addrbuf.sau.sun_path[0]) { |
Dmitry V. Levin | c86340e | 2012-02-22 00:23:52 +0000 | [diff] [blame] | 1259 | tprints("sun_path="); |
Dmitry V. Levin | 16fbe97 | 2007-10-13 21:03:17 +0000 | [diff] [blame] | 1260 | printpathn(tcp, addr + 2, strlen(addrbuf.sau.sun_path)); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1261 | } else { |
Dmitry V. Levin | c86340e | 2012-02-22 00:23:52 +0000 | [diff] [blame] | 1262 | tprints("sun_path=@"); |
Dmitry V. Levin | 16fbe97 | 2007-10-13 21:03:17 +0000 | [diff] [blame] | 1263 | printpathn(tcp, addr + 3, strlen(addrbuf.sau.sun_path + 1)); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1264 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1265 | break; |
| 1266 | case AF_INET: |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 1267 | tprintf("sin_port=htons(%u), sin_addr=inet_addr(\"%s\")", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1268 | ntohs(addrbuf.sin.sin_port), inet_ntoa(addrbuf.sin.sin_addr)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1269 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1270 | #ifdef HAVE_INET_NTOP |
| 1271 | case AF_INET6: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1272 | inet_ntop(AF_INET6, &addrbuf.sa6.sin6_addr, string_addr, sizeof(string_addr)); |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1273 | tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u", |
| 1274 | ntohs(addrbuf.sa6.sin6_port), string_addr, |
| 1275 | addrbuf.sa6.sin6_flowinfo); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1276 | #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1277 | { |
| 1278 | #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1279 | int numericscope = 0; |
| 1280 | if (IN6_IS_ADDR_LINKLOCAL(&addrbuf.sa6.sin6_addr) |
| 1281 | || IN6_IS_ADDR_MC_LINKLOCAL(&addrbuf.sa6.sin6_addr)) { |
| 1282 | char scopebuf[IFNAMSIZ + 1]; |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1283 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1284 | if (if_indextoname(addrbuf.sa6.sin6_scope_id, scopebuf) == NULL) |
| 1285 | numericscope++; |
| 1286 | else |
| 1287 | tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf); |
| 1288 | } else |
| 1289 | numericscope++; |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1290 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1291 | if (numericscope) |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1292 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1293 | tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id); |
Wichert Akkerman | f185065 | 2001-02-16 20:29:03 +0000 | [diff] [blame] | 1294 | } |
| 1295 | #endif |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1296 | break; |
Wichert Akkerman | 9ce1a63 | 1999-08-29 23:15:07 +0000 | [diff] [blame] | 1297 | #endif |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1298 | #if defined(AF_IPX) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1299 | case AF_IPX: |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1300 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1301 | int i; |
John Hughes | 1fcb1d6 | 2001-09-18 15:56:53 +0000 | [diff] [blame] | 1302 | tprintf("sipx_port=htons(%u), ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1303 | ntohs(addrbuf.sipx.sipx_port)); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1304 | /* Yes, I know, this does not look too |
| 1305 | * strace-ish, but otherwise the IPX |
| 1306 | * addresses just look monstrous... |
| 1307 | * Anyways, feel free if you don't like |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1308 | * this way.. :) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1309 | */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1310 | tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network)); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1311 | for (i = 0; i < IPX_NODE_LEN; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1312 | tprintf("%02x", addrbuf.sipx.sipx_node[i]); |
| 1313 | tprintf("/[%02x]", addrbuf.sipx.sipx_type); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1314 | } |
| 1315 | break; |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1316 | #endif /* AF_IPX */ |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1317 | #ifdef AF_PACKET |
| 1318 | case AF_PACKET: |
| 1319 | { |
| 1320 | int i; |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1321 | tprintf("proto=%#04x, if%d, pkttype=", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1322 | ntohs(addrbuf.ll.sll_protocol), |
Wichert Akkerman | b0c598f | 2002-04-01 12:48:06 +0000 | [diff] [blame] | 1323 | addrbuf.ll.sll_ifindex); |
| 1324 | printxval(af_packet_types, addrbuf.ll.sll_pkttype, "?"); |
| 1325 | tprintf(", addr(%d)={%d, ", |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1326 | addrbuf.ll.sll_halen, |
| 1327 | addrbuf.ll.sll_hatype); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1328 | for (i = 0; i < addrbuf.ll.sll_halen; i++) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1329 | tprintf("%02x", addrbuf.ll.sll_addr[i]); |
| 1330 | } |
| 1331 | break; |
| 1332 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1333 | #endif /* AF_PACKET */ |
Roland McGrath | 36ef1bc | 2003-11-06 23:41:23 +0000 | [diff] [blame] | 1334 | #ifdef AF_NETLINK |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1335 | case AF_NETLINK: |
| 1336 | tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); |
| 1337 | break; |
| 1338 | #endif /* AF_NETLINK */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1339 | /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1340 | AF_X25 AF_ROSE etc. still need to be done */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1341 | |
| 1342 | default: |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1343 | tprints("sa_data="); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1344 | printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1345 | sizeof addrbuf.sa.sa_data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1346 | break; |
| 1347 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1348 | tprints("}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | #if HAVE_SENDMSG |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1352 | static const struct xlat scmvals[] = { |
| 1353 | #ifdef SCM_RIGHTS |
| 1354 | { SCM_RIGHTS, "SCM_RIGHTS" }, |
| 1355 | #endif |
| 1356 | #ifdef SCM_CREDENTIALS |
| 1357 | { SCM_CREDENTIALS, "SCM_CREDENTIALS" }, |
| 1358 | #endif |
| 1359 | { 0, NULL } |
| 1360 | }; |
| 1361 | |
| 1362 | static void |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 1363 | printcmsghdr(struct tcb *tcp, unsigned long addr, unsigned long len) |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1364 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1365 | struct cmsghdr *cmsg = len < sizeof(struct cmsghdr) ? |
| 1366 | NULL : malloc(len); |
| 1367 | if (cmsg == NULL || umoven(tcp, addr, len, (char *) cmsg) < 0) { |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1368 | tprintf(", msg_control=%#lx", addr); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1369 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1370 | return; |
| 1371 | } |
| 1372 | |
Denys Vlasenko | 132c52a | 2009-03-23 13:12:46 +0000 | [diff] [blame] | 1373 | tprintf(", {cmsg_len=%u, cmsg_level=", (unsigned) cmsg->cmsg_len); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1374 | printxval(socketlayers, cmsg->cmsg_level, "SOL_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1375 | tprints(", cmsg_type="); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1376 | |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1377 | if (cmsg->cmsg_level == SOL_SOCKET) { |
| 1378 | unsigned long cmsg_len; |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 1379 | |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1380 | printxval(scmvals, cmsg->cmsg_type, "SCM_???"); |
| 1381 | cmsg_len = (len < cmsg->cmsg_len) ? len : cmsg->cmsg_len; |
| 1382 | |
| 1383 | if (cmsg->cmsg_type == SCM_RIGHTS |
| 1384 | && CMSG_LEN(sizeof(int)) <= cmsg_len) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1385 | int *fds = (int *) CMSG_DATA(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1386 | int first = 1; |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1387 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1388 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1389 | while ((char *) fds < ((char *) cmsg + cmsg_len)) { |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1390 | if (!first) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1391 | tprints(", "); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1392 | tprintf("%d", *fds++); |
| 1393 | first = 0; |
| 1394 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1395 | tprints("}}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1396 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1397 | return; |
| 1398 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1399 | if (cmsg->cmsg_type == SCM_CREDENTIALS |
| 1400 | && CMSG_LEN(sizeof(struct ucred)) <= cmsg_len) { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1401 | struct ucred *uc = (struct ucred *) CMSG_DATA(cmsg); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1402 | |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1403 | tprintf("{pid=%ld, uid=%ld, gid=%ld}}", |
| 1404 | (long)uc->pid, (long)uc->uid, (long)uc->gid); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1405 | free(cmsg); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1406 | return; |
| 1407 | } |
| 1408 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 1409 | free(cmsg); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1410 | tprints(", ...}"); |
Roland McGrath | 5077082 | 2004-10-06 22:11:51 +0000 | [diff] [blame] | 1411 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1412 | |
| 1413 | static void |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1414 | do_msghdr(struct tcb *tcp, struct msghdr *msg) |
| 1415 | { |
| 1416 | tprintf("{msg_name(%d)=", msg->msg_namelen); |
| 1417 | printsock(tcp, (long)msg->msg_name, msg->msg_namelen); |
| 1418 | |
| 1419 | tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen); |
| 1420 | tprint_iov(tcp, (unsigned long)msg->msg_iovlen, |
Dmitry V. Levin | 8884968 | 2011-06-13 22:58:44 +0000 | [diff] [blame] | 1421 | (unsigned long)msg->msg_iov, 1); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1422 | |
| 1423 | #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL |
| 1424 | tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen); |
| 1425 | if (msg->msg_controllen) |
| 1426 | printcmsghdr(tcp, (unsigned long) msg->msg_control, |
| 1427 | msg->msg_controllen); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1428 | tprints(", msg_flags="); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1429 | printflags(msg_flags, msg->msg_flags, "MSG_???"); |
| 1430 | #else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
| 1431 | tprintf("msg_accrights=%#lx, msg_accrightslen=%u", |
| 1432 | (unsigned long) msg->msg_accrights, msg->msg_accrightslen); |
| 1433 | #endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1434 | tprints("}"); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1438 | printmsghdr(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1439 | { |
| 1440 | struct msghdr msg; |
| 1441 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1442 | if (umove(tcp, addr, &msg) < 0) { |
| 1443 | tprintf("%#lx", addr); |
| 1444 | return; |
| 1445 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1446 | do_msghdr(tcp, &msg); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1447 | } |
| 1448 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1449 | static void |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 1450 | printmmsghdr(struct tcb *tcp, long addr, unsigned int idx) |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1451 | { |
| 1452 | struct mmsghdr { |
| 1453 | struct msghdr msg_hdr; |
| 1454 | unsigned msg_len; |
| 1455 | } mmsg; |
| 1456 | |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 1457 | addr += sizeof(mmsg) * idx; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1458 | if (umove(tcp, addr, &mmsg) < 0) { |
| 1459 | tprintf("%#lx", addr); |
| 1460 | return; |
| 1461 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1462 | tprints("{"); |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1463 | do_msghdr(tcp, &mmsg.msg_hdr); |
| 1464 | tprintf(", %u}", mmsg.msg_len); |
| 1465 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1466 | |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 1467 | static void |
| 1468 | decode_mmsg(struct tcb *tcp) |
| 1469 | { |
| 1470 | /* mmsgvec */ |
| 1471 | if (syserror(tcp)) { |
| 1472 | tprintf("%#lx", tcp->u_arg[1]); |
| 1473 | } else { |
| 1474 | unsigned int len = tcp->u_rval; |
| 1475 | unsigned int i; |
| 1476 | |
| 1477 | tprints("{"); |
| 1478 | for (i = 0; i < len; ++i) { |
| 1479 | if (i) |
| 1480 | tprints(", "); |
| 1481 | printmmsghdr(tcp, tcp->u_arg[1], i); |
| 1482 | } |
| 1483 | tprints("}"); |
| 1484 | } |
| 1485 | /* vlen */ |
| 1486 | tprintf(", %u, ", (unsigned int) tcp->u_arg[2]); |
| 1487 | /* flags */ |
| 1488 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 1489 | } |
| 1490 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1491 | #endif /* HAVE_SENDMSG */ |
| 1492 | |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1493 | /* |
| 1494 | * low bits of the socket type define real socket type, |
| 1495 | * other bits are socket type flags. |
| 1496 | */ |
| 1497 | static void |
| 1498 | tprint_sock_type(struct tcb *tcp, int flags) |
| 1499 | { |
| 1500 | const char *str = xlookup(socktypes, flags & SOCK_TYPE_MASK); |
| 1501 | |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 1502 | if (str) { |
Denys Vlasenko | 5940e65 | 2011-09-01 09:55:05 +0200 | [diff] [blame] | 1503 | tprints(str); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1504 | flags &= ~SOCK_TYPE_MASK; |
| 1505 | if (!flags) |
| 1506 | return; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1507 | tprints("|"); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1508 | } |
| 1509 | printflags(sock_type_flags, flags, "SOCK_???"); |
| 1510 | } |
| 1511 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1512 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1513 | sys_socket(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1514 | { |
| 1515 | if (entering(tcp)) { |
| 1516 | printxval(domains, tcp->u_arg[0], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1517 | tprints(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1518 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1519 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1520 | switch (tcp->u_arg[0]) { |
| 1521 | case PF_INET: |
Roland McGrath | 8758e54 | 2003-06-23 23:39:59 +0000 | [diff] [blame] | 1522 | #ifdef PF_INET6 |
| 1523 | case PF_INET6: |
| 1524 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1525 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1526 | break; |
| 1527 | #ifdef PF_IPX |
| 1528 | case PF_IPX: |
| 1529 | /* BTW: I don't believe this.. */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1530 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1531 | printxval(domains, tcp->u_arg[2], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1532 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1533 | break; |
| 1534 | #endif /* PF_IPX */ |
| 1535 | default: |
| 1536 | tprintf("%lu", tcp->u_arg[2]); |
| 1537 | break; |
| 1538 | } |
| 1539 | } |
| 1540 | return 0; |
| 1541 | } |
| 1542 | |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 1543 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1544 | sys_bind(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1545 | { |
| 1546 | if (entering(tcp)) { |
| 1547 | tprintf("%ld, ", tcp->u_arg[0]); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1548 | printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1549 | tprintf(", %lu", tcp->u_arg[2]); |
| 1550 | } |
| 1551 | return 0; |
| 1552 | } |
| 1553 | |
| 1554 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1555 | sys_connect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1556 | { |
| 1557 | return sys_bind(tcp); |
| 1558 | } |
| 1559 | |
| 1560 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1561 | sys_listen(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1562 | { |
| 1563 | if (entering(tcp)) { |
| 1564 | tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]); |
| 1565 | } |
| 1566 | return 0; |
| 1567 | } |
| 1568 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1569 | static int |
| 1570 | do_accept(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1571 | { |
| 1572 | if (entering(tcp)) { |
| 1573 | tprintf("%ld, ", tcp->u_arg[0]); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1574 | return 0; |
| 1575 | } |
| 1576 | if (!tcp->u_arg[2]) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1577 | tprintf("%#lx, NULL", tcp->u_arg[1]); |
| 1578 | else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1579 | int len; |
| 1580 | if (tcp->u_arg[1] == 0 || syserror(tcp) |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1581 | || umove(tcp, tcp->u_arg[2], &len) < 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1582 | tprintf("%#lx", tcp->u_arg[1]); |
| 1583 | } else { |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1584 | printsock(tcp, tcp->u_arg[1], len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1585 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1586 | tprints(", "); |
Dmitry V. Levin | 2fc6615 | 2009-01-01 22:47:51 +0000 | [diff] [blame] | 1587 | printnum_int(tcp, tcp->u_arg[2], "%u"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1588 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1589 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1590 | tprints(", "); |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1591 | printflags(sock_type_flags, tcp->u_arg[flags_arg], |
| 1592 | "SOCK_???"); |
| 1593 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1594 | return 0; |
| 1595 | } |
| 1596 | |
| 1597 | int |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1598 | sys_accept(struct tcb *tcp) |
| 1599 | { |
| 1600 | return do_accept(tcp, -1); |
| 1601 | } |
| 1602 | |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1603 | int |
| 1604 | sys_accept4(struct tcb *tcp) |
| 1605 | { |
| 1606 | return do_accept(tcp, 3); |
| 1607 | } |
Paolo Bonzini | 705ff10 | 2009-08-14 12:34:05 +0200 | [diff] [blame] | 1608 | |
| 1609 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1610 | sys_send(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1611 | { |
| 1612 | if (entering(tcp)) { |
| 1613 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1614 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1615 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1616 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1617 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1618 | } |
| 1619 | return 0; |
| 1620 | } |
| 1621 | |
| 1622 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1623 | sys_sendto(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1624 | { |
| 1625 | if (entering(tcp)) { |
| 1626 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1627 | printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 1628 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1629 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1630 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1631 | /* to address */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1632 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1633 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1634 | /* to length */ |
| 1635 | tprintf(", %lu", tcp->u_arg[5]); |
| 1636 | } |
| 1637 | return 0; |
| 1638 | } |
| 1639 | |
| 1640 | #ifdef HAVE_SENDMSG |
| 1641 | |
| 1642 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1643 | sys_sendmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1644 | { |
| 1645 | if (entering(tcp)) { |
| 1646 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1647 | printmsghdr(tcp, tcp->u_arg[1]); |
| 1648 | /* flags */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1649 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1650 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1651 | } |
| 1652 | return 0; |
| 1653 | } |
| 1654 | |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 1655 | int |
| 1656 | sys_sendmmsg(struct tcb *tcp) |
| 1657 | { |
| 1658 | if (entering(tcp)) { |
| 1659 | /* sockfd */ |
| 1660 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 1661 | if (!verbose(tcp)) { |
| 1662 | tprintf("%#lx, %u, ", |
| 1663 | tcp->u_arg[1], (unsigned int) tcp->u_arg[2]); |
| 1664 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
| 1665 | } |
| 1666 | } else { |
| 1667 | if (verbose(tcp)) |
| 1668 | decode_mmsg(tcp); |
| 1669 | } |
| 1670 | return 0; |
| 1671 | } |
| 1672 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1673 | #endif /* HAVE_SENDMSG */ |
| 1674 | |
| 1675 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1676 | sys_recv(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1677 | { |
| 1678 | if (entering(tcp)) { |
| 1679 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1680 | } else { |
| 1681 | if (syserror(tcp)) |
| 1682 | tprintf("%#lx", tcp->u_arg[1]); |
| 1683 | else |
| 1684 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1685 | |
| 1686 | tprintf(", %lu, ", tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1687 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1688 | } |
| 1689 | return 0; |
| 1690 | } |
| 1691 | |
| 1692 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1693 | sys_recvfrom(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1694 | { |
| 1695 | int fromlen; |
| 1696 | |
| 1697 | if (entering(tcp)) { |
| 1698 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1699 | } else { |
| 1700 | if (syserror(tcp)) { |
| 1701 | tprintf("%#lx, %lu, %lu, %#lx, %#lx", |
| 1702 | tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3], |
| 1703 | tcp->u_arg[4], tcp->u_arg[5]); |
| 1704 | return 0; |
| 1705 | } |
| 1706 | /* buf */ |
| 1707 | printstr(tcp, tcp->u_arg[1], tcp->u_rval); |
| 1708 | /* len */ |
| 1709 | tprintf(", %lu, ", tcp->u_arg[2]); |
| 1710 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1711 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1712 | /* from address, len */ |
| 1713 | if (!tcp->u_arg[4] || !tcp->u_arg[5]) { |
| 1714 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1715 | tprints(", NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1716 | else |
| 1717 | tprintf(", %#lx", tcp->u_arg[4]); |
| 1718 | if (tcp->u_arg[5] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1719 | tprints(", NULL"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1720 | else |
| 1721 | tprintf(", %#lx", tcp->u_arg[5]); |
| 1722 | return 0; |
| 1723 | } |
| 1724 | if (umove(tcp, tcp->u_arg[5], &fromlen) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1725 | tprints(", {...}, [?]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1726 | return 0; |
| 1727 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1728 | tprints(", "); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 1729 | printsock(tcp, tcp->u_arg[4], tcp->u_arg[5]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1730 | /* from length */ |
| 1731 | tprintf(", [%u]", fromlen); |
| 1732 | } |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
| 1736 | #ifdef HAVE_SENDMSG |
| 1737 | |
| 1738 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1739 | sys_recvmsg(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1740 | { |
| 1741 | if (entering(tcp)) { |
| 1742 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1743 | } else { |
| 1744 | if (syserror(tcp) || !verbose(tcp)) |
| 1745 | tprintf("%#lx", tcp->u_arg[1]); |
| 1746 | else |
| 1747 | printmsghdr(tcp, tcp->u_arg[1]); |
| 1748 | /* flags */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1749 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 1750 | printflags(msg_flags, tcp->u_arg[2], "MSG_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1751 | } |
| 1752 | return 0; |
| 1753 | } |
| 1754 | |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1755 | int |
| 1756 | sys_recvmmsg(struct tcb *tcp) |
| 1757 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1758 | /* +5 chars are for "left " prefix */ |
| 1759 | static char str[5 + TIMESPEC_TEXT_BUFSIZE]; |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1760 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1761 | if (entering(tcp)) { |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1762 | tprintf("%ld, ", tcp->u_arg[0]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1763 | if (verbose(tcp)) { |
| 1764 | sprint_timespec(str, tcp, tcp->u_arg[4]); |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1765 | /* Abusing tcp->auxstr as temp storage. |
| 1766 | * Will be used and freed on syscall exit. |
| 1767 | */ |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1768 | tcp->auxstr = strdup(str); |
| 1769 | } else { |
| 1770 | tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]); |
| 1771 | printflags(msg_flags, tcp->u_arg[3], "MSG_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1772 | tprints(", "); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1773 | print_timespec(tcp, tcp->u_arg[4]); |
| 1774 | } |
| 1775 | return 0; |
| 1776 | } else { |
| 1777 | if (verbose(tcp)) { |
Dmitry V. Levin | 7af9f35 | 2012-03-11 23:59:29 +0000 | [diff] [blame] | 1778 | decode_mmsg(tcp); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1779 | /* timeout on entrance */ |
| 1780 | tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}"); |
| 1781 | free((void *) tcp->auxstr); |
| 1782 | tcp->auxstr = NULL; |
| 1783 | } |
| 1784 | if (syserror(tcp)) |
| 1785 | return 0; |
| 1786 | if (tcp->u_rval == 0) { |
| 1787 | tcp->auxstr = "Timeout"; |
| 1788 | return RVAL_STR; |
| 1789 | } |
| 1790 | if (!verbose(tcp)) |
| 1791 | return 0; |
| 1792 | /* timeout on exit */ |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 1793 | sprint_timespec(stpcpy(str, "left "), tcp, tcp->u_arg[4]); |
Dmitry V. Levin | e659103 | 2010-03-29 20:45:48 +0400 | [diff] [blame] | 1794 | tcp->auxstr = str; |
| 1795 | return RVAL_STR; |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1796 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1797 | } |
Andreas Schwab | 0873f29 | 2010-02-12 21:39:12 +0100 | [diff] [blame] | 1798 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1799 | #endif /* HAVE_SENDMSG */ |
| 1800 | |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1801 | static const struct xlat shutdown_modes[] = { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1802 | { 0, "SHUT_RD" }, |
| 1803 | { 1, "SHUT_WR" }, |
| 1804 | { 2, "SHUT_RDWR" }, |
| 1805 | { 0, NULL } |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1806 | }; |
| 1807 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1808 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1809 | sys_shutdown(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1810 | { |
| 1811 | if (entering(tcp)) { |
Sebastian Pipping | 9cd3850 | 2011-03-03 01:12:25 +0100 | [diff] [blame] | 1812 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1813 | printxval(shutdown_modes, tcp->u_arg[1], "SHUT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1814 | } |
| 1815 | return 0; |
| 1816 | } |
| 1817 | |
| 1818 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1819 | sys_getsockname(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1820 | { |
| 1821 | return sys_accept(tcp); |
| 1822 | } |
| 1823 | |
| 1824 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 1825 | sys_getpeername(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1826 | { |
| 1827 | return sys_accept(tcp); |
| 1828 | } |
| 1829 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1830 | static int |
| 1831 | do_pipe(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1832 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1833 | if (exiting(tcp)) { |
| 1834 | if (syserror(tcp)) { |
| 1835 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1836 | } else { |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1837 | #if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1838 | int fds[2]; |
| 1839 | |
| 1840 | if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1841 | tprints("[...]"); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1842 | else |
| 1843 | tprintf("[%u, %u]", fds[0], fds[1]); |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 1844 | #elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1845 | tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); |
| 1846 | #else |
| 1847 | tprintf("%#lx", tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1848 | #endif |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1849 | } |
| 1850 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1851 | tprints(", "); |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1852 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
| 1853 | } |
| 1854 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1855 | return 0; |
| 1856 | } |
| 1857 | |
| 1858 | int |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1859 | sys_pipe(struct tcb *tcp) |
| 1860 | { |
| 1861 | return do_pipe(tcp, -1); |
| 1862 | } |
| 1863 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1864 | int |
| 1865 | sys_pipe2(struct tcb *tcp) |
| 1866 | { |
| 1867 | return do_pipe(tcp, 1); |
| 1868 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 1869 | |
| 1870 | int |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1871 | sys_socketpair(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1872 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1873 | int fds[2]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1874 | |
| 1875 | if (entering(tcp)) { |
| 1876 | printxval(domains, tcp->u_arg[0], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1877 | tprints(", "); |
Dmitry V. Levin | 8a550d7 | 2008-11-10 17:21:23 +0000 | [diff] [blame] | 1878 | tprint_sock_type(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1879 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1880 | switch (tcp->u_arg[0]) { |
| 1881 | case PF_INET: |
| 1882 | printxval(protocols, tcp->u_arg[2], "IPPROTO_???"); |
| 1883 | break; |
| 1884 | #ifdef PF_IPX |
| 1885 | case PF_IPX: |
| 1886 | /* BTW: I don't believe this.. */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1887 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1888 | printxval(domains, tcp->u_arg[2], "PF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1889 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1890 | break; |
| 1891 | #endif /* PF_IPX */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1892 | default: |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1893 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1894 | break; |
| 1895 | } |
| 1896 | } else { |
| 1897 | if (syserror(tcp)) { |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 1898 | tprintf(", %#lx", tcp->u_arg[3]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1899 | return 0; |
| 1900 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1901 | if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1902 | tprints(", [...]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1903 | else |
| 1904 | tprintf(", [%u, %u]", fds[0], fds[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1905 | } |
| 1906 | return 0; |
| 1907 | } |
| 1908 | |
| 1909 | int |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1910 | sys_getsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1911 | { |
| 1912 | if (entering(tcp)) { |
| 1913 | tprintf("%ld, ", tcp->u_arg[0]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1914 | printxval(socketlayers, tcp->u_arg[1], "SOL_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1915 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1916 | switch (tcp->u_arg[1]) { |
| 1917 | case SOL_SOCKET: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1918 | printxval(sockoptions, tcp->u_arg[2], "SO_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1919 | break; |
| 1920 | #ifdef SOL_IP |
| 1921 | case SOL_IP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1922 | printxval(sockipoptions, tcp->u_arg[2], "IP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1923 | break; |
| 1924 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 1925 | #ifdef SOL_IPV6 |
| 1926 | case SOL_IPV6: |
| 1927 | printxval(sockipv6options, tcp->u_arg[2], "IPV6_???"); |
| 1928 | break; |
| 1929 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1930 | #ifdef SOL_IPX |
| 1931 | case SOL_IPX: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1932 | printxval(sockipxoptions, tcp->u_arg[2], "IPX_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1933 | break; |
| 1934 | #endif |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1935 | #ifdef SOL_PACKET |
| 1936 | case SOL_PACKET: |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1937 | printxval(sockpacketoptions, tcp->u_arg[2], "PACKET_???"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 1938 | break; |
| 1939 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1940 | #ifdef SOL_TCP |
| 1941 | case SOL_TCP: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1942 | printxval(socktcpoptions, tcp->u_arg[2], "TCP_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1943 | break; |
| 1944 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 1945 | #ifdef SOL_SCTP |
| 1946 | case SOL_SCTP: |
| 1947 | printxval(socksctpoptions, tcp->u_arg[2], "SCTP_???"); |
| 1948 | break; |
| 1949 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1950 | |
| 1951 | /* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
| 1952 | * etc. still need work */ |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 1953 | default: |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1954 | tprintf("%lu", tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1955 | break; |
| 1956 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 1957 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1958 | } else { |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 1959 | int len; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1960 | if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1961 | tprintf("%#lx, %#lx", |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1962 | tcp->u_arg[3], tcp->u_arg[4]); |
| 1963 | return 0; |
| 1964 | } |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1965 | |
| 1966 | switch (tcp->u_arg[1]) { |
| 1967 | case SOL_SOCKET: |
| 1968 | switch (tcp->u_arg[2]) { |
| 1969 | #ifdef SO_LINGER |
| 1970 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1971 | if (len == sizeof(struct linger)) { |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1972 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1973 | if (umove(tcp, |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1974 | tcp->u_arg[3], |
| 1975 | &linger) < 0) |
| 1976 | break; |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 1977 | tprintf("{onoff=%d, linger=%d}, " |
Roland McGrath | 96ad7b8 | 2005-02-02 03:11:32 +0000 | [diff] [blame] | 1978 | "[%d]", |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 1979 | linger.l_onoff, |
| 1980 | linger.l_linger, |
| 1981 | len); |
| 1982 | return 0; |
| 1983 | } |
| 1984 | break; |
| 1985 | #endif |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1986 | #ifdef SO_PEERCRED |
| 1987 | case SO_PEERCRED: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1988 | if (len == sizeof(struct ucred)) { |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1989 | struct ucred uc; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 1990 | if (umove(tcp, |
Dmitry V. Levin | 0ddd8ad | 2010-12-03 16:54:53 +0000 | [diff] [blame] | 1991 | tcp->u_arg[3], |
| 1992 | &uc) < 0) |
| 1993 | break; |
| 1994 | tprintf("{pid=%ld, uid=%ld, gid=%ld}, " |
| 1995 | "[%d]", |
| 1996 | (long)uc.pid, |
| 1997 | (long)uc.uid, |
| 1998 | (long)uc.gid, |
| 1999 | len); |
| 2000 | return 0; |
| 2001 | } |
| 2002 | break; |
| 2003 | #endif |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2004 | } |
| 2005 | break; |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2006 | case SOL_PACKET: |
| 2007 | switch (tcp->u_arg[2]) { |
| 2008 | #ifdef PACKET_STATISTICS |
| 2009 | case PACKET_STATISTICS: |
| 2010 | if (len == sizeof(struct tpacket_stats)) { |
| 2011 | struct tpacket_stats stats; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2012 | if (umove(tcp, |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2013 | tcp->u_arg[3], |
| 2014 | &stats) < 0) |
| 2015 | break; |
| 2016 | tprintf("{packets=%u, drops=%u}, " |
| 2017 | "[%d]", |
| 2018 | stats.tp_packets, |
| 2019 | stats.tp_drops, |
| 2020 | len); |
| 2021 | return 0; |
| 2022 | } |
| 2023 | break; |
| 2024 | #endif |
| 2025 | } |
| 2026 | break; |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2027 | } |
| 2028 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2029 | if (len == sizeof(int)) { |
Dmitry V. Levin | 3128919 | 2009-11-06 18:05:40 +0000 | [diff] [blame] | 2030 | printnum_int(tcp, tcp->u_arg[3], "%d"); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2031 | } |
| 2032 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2033 | printstr(tcp, tcp->u_arg[3], len); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2034 | } |
Roland McGrath | fc544db | 2005-02-02 02:48:57 +0000 | [diff] [blame] | 2035 | tprintf(", [%d]", len); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2036 | } |
| 2037 | return 0; |
| 2038 | } |
| 2039 | |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2040 | #if defined(ICMP_FILTER) |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2041 | static void printicmpfilter(struct tcb *tcp, long addr) |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2042 | { |
| 2043 | struct icmp_filter filter; |
| 2044 | |
| 2045 | if (!addr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2046 | tprints("NULL"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2047 | return; |
| 2048 | } |
| 2049 | if (syserror(tcp) || !verbose(tcp)) { |
| 2050 | tprintf("%#lx", addr); |
| 2051 | return; |
| 2052 | } |
| 2053 | if (umove(tcp, addr, &filter) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2054 | tprints("{...}"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2055 | return; |
| 2056 | } |
| 2057 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2058 | tprints("~("); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 2059 | printflags(icmpfilterflags, ~filter.data, "ICMP_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2060 | tprints(")"); |
Wichert Akkerman | 7987cdf | 2000-07-05 16:05:39 +0000 | [diff] [blame] | 2061 | } |
| 2062 | #endif /* ICMP_FILTER */ |
| 2063 | |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2064 | static int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2065 | printsockopt(struct tcb *tcp, int level, int name, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2066 | { |
| 2067 | printxval(socketlayers, level, "SOL_??"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2068 | tprints(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2069 | switch (level) { |
| 2070 | case SOL_SOCKET: |
| 2071 | printxval(sockoptions, name, "SO_???"); |
| 2072 | switch (name) { |
| 2073 | #if defined(SO_LINGER) |
| 2074 | case SO_LINGER: |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2075 | if (len == sizeof(struct linger)) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2076 | struct linger linger; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2077 | if (umove(tcp, addr, &linger) < 0) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2078 | break; |
| 2079 | tprintf(", {onoff=%d, linger=%d}", |
| 2080 | linger.l_onoff, |
| 2081 | linger.l_linger); |
| 2082 | return 0; |
| 2083 | } |
| 2084 | break; |
| 2085 | #endif |
| 2086 | } |
| 2087 | break; |
| 2088 | #ifdef SOL_IP |
| 2089 | case SOL_IP: |
| 2090 | printxval(sockipoptions, name, "IP_???"); |
| 2091 | break; |
| 2092 | #endif |
Roland McGrath | 4f6ba69 | 2004-08-31 07:01:26 +0000 | [diff] [blame] | 2093 | #ifdef SOL_IPV6 |
| 2094 | case SOL_IPV6: |
| 2095 | printxval(sockipv6options, name, "IPV6_???"); |
| 2096 | break; |
| 2097 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2098 | #ifdef SOL_IPX |
| 2099 | case SOL_IPX: |
| 2100 | printxval(sockipxoptions, name, "IPX_???"); |
| 2101 | break; |
| 2102 | #endif |
| 2103 | #ifdef SOL_PACKET |
| 2104 | case SOL_PACKET: |
| 2105 | printxval(sockpacketoptions, name, "PACKET_???"); |
| 2106 | /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */ |
Dmitry V. Levin | ca75bd6 | 2009-11-13 12:51:04 +0000 | [diff] [blame] | 2107 | switch (name) { |
| 2108 | #ifdef PACKET_RX_RING |
| 2109 | case PACKET_RX_RING: |
| 2110 | #endif |
| 2111 | #ifdef PACKET_TX_RING |
| 2112 | case PACKET_TX_RING: |
| 2113 | #endif |
| 2114 | #if defined(PACKET_RX_RING) || defined(PACKET_TX_RING) |
| 2115 | if (len == sizeof(struct tpacket_req)) { |
| 2116 | struct tpacket_req req; |
| 2117 | if (umove(tcp, addr, &req) < 0) |
| 2118 | break; |
| 2119 | tprintf(", {block_size=%u, block_nr=%u, frame_size=%u, frame_nr=%u}", |
| 2120 | req.tp_block_size, |
| 2121 | req.tp_block_nr, |
| 2122 | req.tp_frame_size, |
| 2123 | req.tp_frame_nr); |
| 2124 | return 0; |
| 2125 | } |
| 2126 | break; |
| 2127 | #endif /* PACKET_RX_RING || PACKET_TX_RING */ |
| 2128 | } |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2129 | break; |
| 2130 | #endif |
| 2131 | #ifdef SOL_TCP |
| 2132 | case SOL_TCP: |
| 2133 | printxval(socktcpoptions, name, "TCP_???"); |
| 2134 | break; |
| 2135 | #endif |
Holger Hans Peter Freyther | 7fea79b | 2011-01-14 11:08:12 +0100 | [diff] [blame] | 2136 | #ifdef SOL_SCTP |
| 2137 | case SOL_SCTP: |
| 2138 | printxval(socksctpoptions, name, "SCTP_???"); |
| 2139 | break; |
| 2140 | #endif |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2141 | #ifdef SOL_RAW |
| 2142 | case SOL_RAW: |
| 2143 | printxval(sockrawoptions, name, "RAW_???"); |
| 2144 | switch (name) { |
| 2145 | #if defined(ICMP_FILTER) |
Denys Vlasenko | b237b1b | 2012-02-27 13:56:59 +0100 | [diff] [blame] | 2146 | case ICMP_FILTER: |
| 2147 | tprints(", "); |
| 2148 | printicmpfilter(tcp, addr); |
| 2149 | return 0; |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2150 | #endif |
| 2151 | } |
| 2152 | break; |
| 2153 | #endif |
| 2154 | |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2155 | /* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2156 | * etc. still need work */ |
| 2157 | |
| 2158 | default: |
| 2159 | tprintf("%u", name); |
| 2160 | } |
| 2161 | |
| 2162 | /* default arg printing */ |
| 2163 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2164 | tprints(", "); |
Roland McGrath | 6d2b349 | 2002-12-30 00:51:30 +0000 | [diff] [blame] | 2165 | |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2166 | if (len == sizeof(int)) { |
| 2167 | printnum_int(tcp, addr, "%d"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2168 | } |
| 2169 | else { |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2170 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2171 | } |
| 2172 | return 0; |
| 2173 | } |
| 2174 | |
Roland McGrath | c3ca0d8 | 2003-01-14 07:53:38 +0000 | [diff] [blame] | 2175 | #ifdef HAVE_STRUCT_OPTHDR |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2176 | |
| 2177 | void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2178 | print_sock_optmgmt(struct tcb *tcp, long addr, int len) |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2179 | { |
| 2180 | int c = 0; |
| 2181 | struct opthdr hdr; |
| 2182 | |
John Hughes | 2c4e3a8 | 2002-05-24 10:19:44 +0000 | [diff] [blame] | 2183 | while (len >= (int) sizeof hdr) { |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2184 | if (umove(tcp, addr, &hdr) < 0) break; |
| 2185 | if (c++) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2186 | tprints(", "); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2187 | } |
| 2188 | else if (len > hdr.len + sizeof hdr) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2189 | tprints("["); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2190 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2191 | tprints("{"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2192 | addr += sizeof hdr; |
| 2193 | len -= sizeof hdr; |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2194 | printsockopt(tcp, hdr.level, hdr.name, addr, hdr.len); |
John Hughes | 2c4e3a8 | 2002-05-24 10:19:44 +0000 | [diff] [blame] | 2195 | if (hdr.len > 0) { |
| 2196 | addr += hdr.len; |
| 2197 | len -= hdr.len; |
| 2198 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2199 | tprints("}"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2200 | } |
| 2201 | if (len > 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2202 | if (c++) tprints(", "); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2203 | printstr(tcp, addr, len); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2204 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 2205 | if (c > 1) tprints("]"); |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | #endif |
| 2209 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2210 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 2211 | sys_setsockopt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2212 | { |
| 2213 | if (entering(tcp)) { |
| 2214 | tprintf("%ld, ", tcp->u_arg[0]); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 2215 | printsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2], |
John Hughes | 38ae88d | 2002-05-23 11:48:58 +0000 | [diff] [blame] | 2216 | tcp->u_arg[3], tcp->u_arg[4]); |
John Hughes | 93f7fcc | 2002-05-22 15:46:49 +0000 | [diff] [blame] | 2217 | tprintf(", %lu", tcp->u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2218 | } |
| 2219 | return 0; |
| 2220 | } |