1 /* 2 * Copyright (c) 2017 George V. Neville-Neil 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 * 28 * Translators and flags for the socket structure. FreeBSD specific code. 29 */ 30 31 #pragma D depends_on module kernel 32 33 /* 34 * Option flags per-socket. 35 */ 36 #pragma D binding "1.13" SO_DEBUG 37 inline int SO_DEBUG = 0x0001; /* turn on debugging info recording */ 38 #pragma D binding "1.13" SO_ACCEPTCONN 39 inline int SO_ACCEPTCONN = 0x0002; /* socket has had listen() */ 40 #pragma D binding "1.13" SO_REUSEADDR 41 inline int SO_REUSEADDR = 0x0004; /* allow local address reuse */ 42 #pragma D binding "1.13" SO_KEEPALIVE 43 inline int SO_KEEPALIVE = 0x0008; /* keep connections alive */ 44 #pragma D binding "1.13" SO_DONTROUTE 45 inline int SO_DONTROUTE = 0x0010; /* just use interface addresses */ 46 #pragma D binding "1.13" SO_BROADCAST 47 inline int SO_BROADCAST = 0x0020; /* permit sending of broadcast msgs */ 48 #pragma D binding "1.13" SO_USELOOPBACK 49 inline int SO_USELOOPBACK = 0x0040; /* bypass hardware when possible */ 50 #pragma D binding "1.13" SO_LINGER 51 inline int SO_LINGER = 0x0080; /* linger on close if data present */ 52 #pragma D binding "1.13" SO_OOBINLINE 53 inline int SO_OOBINLINE = 0x0100; /* leave received OOB data in line */ 54 #pragma D binding "1.13" SO_REUSEPORT 55 inline int SO_REUSEPORT = 0x0200; /* allow local address & port reuse */ 56 #pragma D binding "1.13" SO_TIMESTAMP 57 inline int SO_TIMESTAMP = 0x0400; /* timestamp received dgram traffic */ 58 #pragma D binding "1.13" SO_NOSIGPIPE 59 inline int SO_NOSIGPIPE = 0x0800; /* no SIGPIPE from EPIPE */ 60 #pragma D binding "1.13" SO_ACCEPTFILTER 61 inline int SO_ACCEPTFILTER = 0x1000; /* there is an accept filter */ 62 #pragma D binding "1.13" SO_BINTIME 63 inline int SO_BINTIME = 0x2000; /* timestamp received dgram traffic */ 64 #pragma D binding "1.13" SO_NO_OFFLOAD 65 inline int SO_NO_OFFLOAD = 0x4000; /* socket cannot be offloaded */ 66 #pragma D binding "1.13" SO_NO_DDP 67 inline int SO_NO_DDP = 0x8000; /* disable direct data placement */ 68 69 /* 70 * Additional options, not kept in so_options. 71 */ 72 #pragma D binding "1.13" SO_SNDBUF 73 inline int SO_SNDBUF = 0x1001; /* send buffer size */ 74 #pragma D binding "1.13" SO_RCVBUF 75 inline int SO_RCVBUF = 0x1002; /* receive buffer size */ 76 #pragma D binding "1.13" SO_SNDLOWAT 77 inline int SO_SNDLOWAT = 0x1003; /* send low-water mark */ 78 #pragma D binding "1.13" SO_RCVLOWAT 79 inline int SO_RCVLOWAT = 0x1004; /* receive low-water mark */ 80 #pragma D binding "1.13" SO_SNDTIMEO 81 inline int SO_SNDTIMEO = 0x1005; /* send timeout */ 82 #pragma D binding "1.13" SO_RCVTIMEO 83 inline int SO_RCVTIMEO = 0x1006; /* receive timeout */ 84 #pragma D binding "1.13" SO_ERROR 85 inline int SO_ERROR = 0x1007; /* get error status and clear */ 86 #pragma D binding "1.13" SO_TYPE 87 inline int SO_TYPE = 0x1008; /* get socket type */ 88 #pragma D binding "1.13" SO_LABEL 89 inline int SO_LABEL = 0x1009; /* socket's MAC label */ 90 #pragma D binding "1.13" SO_PEERLABEL 91 inline int SO_PEERLABEL = 0x1010; /* socket's peer's MAC label */ 92 #pragma D binding "1.13" SO_LISTENQLIMIT 93 inline int SO_LISTENQLIMIT = 0x1011; /* socket's backlog limit */ 94 #pragma D binding "1.13" SO_LISTENQLEN 95 inline int SO_LISTENQLEN = 0x1012; /* socket's complete queue length */ 96 #pragma D binding "1.13" SO_LISTENINCQLEN 97 inline int SO_LISTENINCQLEN = 0x1013; /* socket's incomplete queue length */ 98 #pragma D binding "1.13" SO_SETFIB 99 inline int SO_SETFIB = 0x1014; /* use this FIB to route */ 100 #pragma D binding "1.13" SO_USER_COOKIE 101 inline int SO_USER_COOKIE = 0x1015; /* user cookie (dummynet etc.) */ 102 #pragma D binding "1.13" SO_PROTOCOL 103 inline int SO_PROTOCOL = 0x1016; /* get socket protocol (Linux name) */ 104 #pragma D binding "1.13" SO_PROTOTYPE 105 inline int SO_PROTOTYPE = SO_PROTOCOL; /* alias for SO_PROTOCOL (SunOS name) */ 106 #pragma D binding "1.13" SO_TS_CLOCK 107 inline int SO_TS_CLOCK = 0x1017; /* clock type used for SO_TIMESTAMP */ 108 #pragma D binding "1.13" SO_MAX_PACING_RATE 109 inline int SO_MAX_PACING_RATE = 0x1018; /* socket's max TX pacing rate (Linux name) */ 110 111 #pragma D binding "1.13" SO_TS_REALTIME_MICRO 112 inline int SO_TS_REALTIME_MICRO = 0; /* microsecond resolution, realtime */ 113 #pragma D binding "1.13" SO_TS_BINTIME 114 inline int SO_TS_BINTIME = 1; /* sub-nanosecond resolution, realtime */ 115 #pragma D binding "1.13" SO_TS_REALTIME 116 inline int SO_TS_REALTIME = 2; /* nanosecond resolution, realtime */ 117 #pragma D binding "1.13" SO_TS_MONOTONIC 118 inline int SO_TS_MONOTONIC = 3; /* nanosecond resolution, monotonic */ 119 #pragma D binding "1.13" SO_TS_DEFAULT 120 inline int SO_TS_DEFAULT = SO_TS_REALTIME_MICRO; 121 #pragma D binding "1.13" SO_TS_CLOCK_MAX 122 inline int SO_TS_CLOCK_MAX = SO_TS_MONOTONIC; 123 124 #pragma D binding "1.13" AF_UNSPEC 125 inline int AF_UNSPEC = 0; /* unspecified */ 126 #pragma D binding "1.13" AF_UNIX 127 inline int AF_UNIX = 1; /* standardized name for AF_LOCAL */ 128 #pragma D binding "1.13" AF_LOCAL 129 inline int AF_LOCAL = AF_UNIX; /* local to host (pipes, portals) */ 130 #pragma D binding "1.13" AF_INET 131 inline int AF_INET = 2; /* internetwork: UDP, TCP, etc. */ 132 #pragma D binding "1.13" AF_IMPLINK 133 inline int AF_IMPLINK = 3; /* arpanet imp addresses */ 134 #pragma D binding "1.13" AF_PUP 135 inline int AF_PUP = 4; /* pup protocols: e.g. BSP */ 136 #pragma D binding "1.13" AF_CHAOS 137 inline int AF_CHAOS = 5; /* mit CHAOS protocols */ 138 #pragma D binding "1.13" AF_NETBIOS 139 inline int AF_NETBIOS = 6; /* SMB protocols */ 140 #pragma D binding "1.13" AF_ISO 141 inline int AF_ISO = 7; /* ISO protocols */ 142 #pragma D binding "1.13" AF_OSI 143 inline int AF_OSI = AF_ISO; 144 #pragma D binding "1.13" AF_ECMA 145 inline int AF_ECMA = 8; /* European computer manufacturers */ 146 #pragma D binding "1.13" AF_DATAKIT 147 inline int AF_DATAKIT = 9; /* datakit protocols */ 148 #pragma D binding "1.13" AF_CCITT 149 inline int AF_CCITT = 10; /* CCITT protocols, X.25 etc */ 150 #pragma D binding "1.13" AF_SNA 151 inline int AF_SNA = 11; /* IBM SNA */ 152 #pragma D binding "1.13" AF_DECnet 153 inline int AF_DECnet = 12; /* DECnet */ 154 #pragma D binding "1.13" AF_DLI 155 inline int AF_DLI = 13; /* DEC Direct data link interface */ 156 #pragma D binding "1.13" AF_LAT 157 inline int AF_LAT = 14; /* LAT */ 158 #pragma D binding "1.13" AF_HYLINK 159 inline int AF_HYLINK = 15; /* NSC Hyperchannel */ 160 #pragma D binding "1.13" AF_APPLETALK 161 inline int AF_APPLETALK = 16; /* Apple Talk */ 162 #pragma D binding "1.13" AF_ROUTE 163 inline int AF_ROUTE = 17; /* Internal Routing Protocol */ 164 #pragma D binding "1.13" AF_LINK 165 inline int AF_LINK = 18; /* Link layer interface */ 166 #pragma D binding "1.13" pseudo_AF_XTP 167 inline int pseudo_AF_XTP = 19; /* eXpress Transfer Protocol (no AF) */ 168 #pragma D binding "1.13" AF_COIP 169 inline int AF_COIP = 20; /* connection-oriented IP, aka ST II */ 170 #pragma D binding "1.13" AF_CNT 171 inline int AF_CNT = 21; /* Computer Network Technology */ 172 #pragma D binding "1.13" pseudo_AF_RTIP 173 inline int pseudo_AF_RTIP = 22; /* Help Identify RTIP packets */ 174 #pragma D binding "1.13" AF_IPX 175 inline int AF_IPX = 23; /* Novell Internet Protocol */ 176 #pragma D binding "1.13" AF_SIP 177 inline int AF_SIP = 24; /* Simple Internet Protocol */ 178 #pragma D binding "1.13" pseudo_AF_PIP 179 inline int pseudo_AF_PIP = 25; /* Help Identify PIP packets */ 180 #pragma D binding "1.13" AF_ISDN 181 inline int AF_ISDN = 26; /* Integrated Services Digital Network*/ 182 #pragma D binding "1.13" AF_E164 183 inline int AF_E164 = AF_ISDN; /* CCITT E.164 recommendation */ 184 #pragma D binding "1.13" pseudo_AF_KEY 185 inline int pseudo_AF_KEY = 27; /* Internal key-management function */ 186 #pragma D binding "1.13" AF_INET6 187 inline int AF_INET6 = 28; /* IPv6 */ 188 #pragma D binding "1.13" AF_NATM 189 inline int AF_NATM = 29; /* native ATM access */ 190 #pragma D binding "1.13" AF_ATM 191 inline int AF_ATM = 30; /* ATM */ 192 #pragma D binding "1.13" pseudo_AF_HDRCMPLT 193 inline int pseudo_AF_HDRCMPLT = 31; /* Used by BPF to not rewrite headers 194 * in interface output routine 195 */ 196 #pragma D binding "1.13" AF_NETGRAPH 197 inline int AF_NETGRAPH = 32; /* Netgraph sockets */ 198 #pragma D binding "1.13" AF_SLOW 199 inline int AF_SLOW = 33; /* 802.3ad slow protocol */ 200 #pragma D binding "1.13" AF_SCLUSTER 201 inline int AF_SCLUSTER = 34; /* Sitara cluster protocol */ 202 #pragma D binding "1.13" AF_ARP 203 inline int AF_ARP = 35; /* Address Resolution Protocol */ 204 #pragma D binding "1.13" AF_BLUETOOTH 205 inline int AF_BLUETOOTH = 36; /* Bluetooth sockets */ 206 #pragma D binding "1.13" AF_IEEE80211 207 inline int AF_IEEE80211 = 37; /* IEEE 802.11 protocol */ 208 #pragma D binding "1.13" AF_INET_SDP 209 inline int AF_INET_SDP = 40; /* OFED Socket Direct Protocol ipv4 */ 210 #pragma D binding "1.13" AF_INET6_SDP 211 inline int AF_INET6_SDP = 42; /* OFED Socket Direct Protocol ipv6 */ 212 #pragma D binding "1.13" AF_MAX 213 inline int AF_MAX = 42; 214 215 /* 216 * Protocol families, same as address families for now. 217 */ 218 #pragma D binding "1.13" PF_UNSPEC 219 inline int PF_UNSPEC = AF_UNSPEC; 220 #pragma D binding "1.13" PF_LOCAL 221 inline int PF_LOCAL = AF_LOCAL; 222 #pragma D binding "1.13" PF_UNIX 223 inline int PF_UNIX = PF_LOCAL; /* backward compatibility */ 224 #pragma D binding "1.13" PF_INET 225 inline int PF_INET = AF_INET; 226 #pragma D binding "1.13" PF_IMPLINK 227 inline int PF_IMPLINK = AF_IMPLINK; 228 #pragma D binding "1.13" PF_PUP 229 inline int PF_PUP = AF_PUP; 230 #pragma D binding "1.13" PF_CHAOS 231 inline int PF_CHAOS = AF_CHAOS; 232 #pragma D binding "1.13" PF_NETBIOS 233 inline int PF_NETBIOS = AF_NETBIOS; 234 #pragma D binding "1.13" PF_ISO 235 inline int PF_ISO = AF_ISO; 236 #pragma D binding "1.13" PF_OSI 237 inline int PF_OSI = AF_ISO; 238 #pragma D binding "1.13" PF_ECMA 239 inline int PF_ECMA = AF_ECMA; 240 #pragma D binding "1.13" PF_DATAKIT 241 inline int PF_DATAKIT = AF_DATAKIT; 242 #pragma D binding "1.13" PF_CCITT 243 inline int PF_CCITT = AF_CCITT; 244 #pragma D binding "1.13" PF_SNA 245 inline int PF_SNA = AF_SNA; 246 #pragma D binding "1.13" PF_DECnet 247 inline int PF_DECnet = AF_DECnet; 248 #pragma D binding "1.13" PF_DLI 249 inline int PF_DLI = AF_DLI; 250 #pragma D binding "1.13" PF_LAT 251 inline int PF_LAT = AF_LAT; 252 #pragma D binding "1.13" PF_HYLINK 253 inline int PF_HYLINK = AF_HYLINK; 254 #pragma D binding "1.13" PF_APPLETALK 255 inline int PF_APPLETALK = AF_APPLETALK; 256 #pragma D binding "1.13" PF_ROUTE 257 inline int PF_ROUTE = AF_ROUTE; 258 #pragma D binding "1.13" PF_LINK 259 inline int PF_LINK = AF_LINK; 260 #pragma D binding "1.13" PF_XTP 261 inline int PF_XTP = pseudo_AF_XTP; /* really just proto family, no AF */ 262 #pragma D binding "1.13" PF_COIP 263 inline int PF_COIP = AF_COIP; 264 #pragma D binding "1.13" PF_CNT 265 inline int PF_CNT = AF_CNT; 266 #pragma D binding "1.13" PF_SIP 267 inline int PF_SIP = AF_SIP; 268 #pragma D binding "1.13" PF_IPX 269 inline int PF_IPX = AF_IPX; 270 #pragma D binding "1.13" PF_RTIP 271 inline int PF_RTIP = pseudo_AF_RTIP; /* same format as AF_INET */ 272 #pragma D binding "1.13" PF_PIP 273 inline int PF_PIP = pseudo_AF_PIP; 274 #pragma D binding "1.13" PF_ISDN 275 inline int PF_ISDN = AF_ISDN; 276 #pragma D binding "1.13" PF_KEY 277 inline int PF_KEY = pseudo_AF_KEY; 278 #pragma D binding "1.13" PF_INET6 279 inline int PF_INET6 = AF_INET6; 280 #pragma D binding "1.13" PF_NATM 281 inline int PF_NATM = AF_NATM; 282 #pragma D binding "1.13" PF_ATM 283 inline int PF_ATM = AF_ATM; 284 #pragma D binding "1.13" PF_NETGRAPH 285 inline int PF_NETGRAPH = AF_NETGRAPH; 286 #pragma D binding "1.13" PF_SLOW 287 inline int PF_SLOW = AF_SLOW; 288 #pragma D binding "1.13" PF_SCLUSTER 289 inline int PF_SCLUSTER = AF_SCLUSTER; 290 #pragma D binding "1.13" PF_ARP 291 inline int PF_ARP = AF_ARP; 292 #pragma D binding "1.13" PF_BLUETOOTH 293 inline int PF_BLUETOOTH = AF_BLUETOOTH; 294 #pragma D binding "1.13" PF_IEEE80211 295 inline int PF_IEEE80211 = AF_IEEE80211; 296 #pragma D binding "1.13" PF_INET_SDP 297 inline int PF_INET_SDP= AF_INET_SDP; 298 #pragma D binding "1.13" PF_INET6_SDP 299 inline int PF_INET6_SDP= AF_INET6_SDP; 300 #pragma D binding "1.13" PF_MAX 301 inline int PF_MAX = AF_MAX; 302