1*17052Skarels /* socket.h 6.2 84/08/29 */ 24658Swnj 34658Swnj /* 412787Ssam * Definitions related to sockets: types, address families, options. 54658Swnj */ 64892Swnj 74892Swnj /* 812787Ssam * Types 94892Swnj */ 104930Swnj #define SOCK_STREAM 1 /* stream socket */ 114930Swnj #define SOCK_DGRAM 2 /* datagram socket */ 124930Swnj #define SOCK_RAW 3 /* raw-protocol interface */ 134930Swnj #define SOCK_RDM 4 /* reliably-delivered message */ 1412787Ssam #define SOCK_SEQPACKET 5 /* sequenced packet stream */ 154658Swnj 164812Swnj /* 174812Swnj * Option flags per-socket. 184812Swnj */ 194812Swnj #define SO_DEBUG 0x01 /* turn on debugging info recording */ 2012787Ssam #define SO_ACCEPTCONN 0x02 /* socket has had listen() */ 2112787Ssam #define SO_REUSEADDR 0x04 /* allow local address reuse */ 226215Swnj #define SO_KEEPALIVE 0x08 /* keep connections alive */ 237132Swnj #define SO_DONTROUTE 0x10 /* just use interface addresses */ 24*17052Skarels #define SO_BROADCAST 0x20 /* permit sending of broadcast msgs */ 2510209Ssam #define SO_USELOOPBACK 0x40 /* bypass hardware when possible */ 2610597Ssam #define SO_LINGER 0x80 /* linger on close if data present */ 274930Swnj 284930Swnj /* 29*17052Skarels * Pseudo flags for disabling options. 30*17052Skarels */ 31*17052Skarels #define SO_DONTDEBUG (~SO_DEBUG) 32*17052Skarels #define SO_DONTREUSEADDR (~SO_REUSEADDR) 33*17052Skarels #define SO_DONTKEEPALIVE (~SO_KEEPALIVE) 34*17052Skarels #define SO_ROUTE (~SO_DONTROUTE) 35*17052Skarels #define SO_DONTBROADCAST (~SO_BROADCAST) 36*17052Skarels #define SO_DONTUSELOOPBACK (~SO_LOOPBACK) 37*17052Skarels #define SO_DONTLINGER (~SO_LINGER) 38*17052Skarels 39*17052Skarels /* 4012787Ssam * Address families. 414930Swnj */ 4212787Ssam #define AF_UNSPEC 0 /* unspecified */ 4312787Ssam #define AF_UNIX 1 /* local to host (pipes, portals) */ 4412787Ssam #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 4512787Ssam #define AF_IMPLINK 3 /* arpanet imp addresses */ 4612787Ssam #define AF_PUP 4 /* pup protocols: e.g. BSP */ 4712787Ssam #define AF_CHAOS 5 /* mit CHAOS protocols */ 4812787Ssam #define AF_NS 6 /* XEROX NS protocols */ 4912787Ssam #define AF_NBS 7 /* nbs protocols */ 5012787Ssam #define AF_ECMA 8 /* european computer manufacturers */ 5112787Ssam #define AF_DATAKIT 9 /* datakit protocols */ 5212787Ssam #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 5312787Ssam #define AF_SNA 11 /* IBM SNA */ 544930Swnj 5512787Ssam #define AF_MAX 12 564930Swnj 574930Swnj /* 5812787Ssam * Structure used by kernel to store most 5912787Ssam * addresses. 604930Swnj */ 614930Swnj struct sockaddr { 6212508Ssam u_short sa_family; /* address family */ 634930Swnj char sa_data[14]; /* up to 14 bytes of direct address */ 644930Swnj }; 654930Swnj 664930Swnj /* 6712787Ssam * Structure used by kernel to pass protocol 6812787Ssam * information in raw sockets. 694930Swnj */ 7012787Ssam struct sockproto { 7112787Ssam u_short sp_family; /* address family */ 7212787Ssam u_short sp_protocol; /* protocol */ 7312787Ssam }; 746620Ssam 7512787Ssam /* 7612787Ssam * Protocol families, same as address families for now. 7712787Ssam */ 7812787Ssam #define PF_UNSPEC AF_UNSPEC 7912787Ssam #define PF_UNIX AF_UNIX 8012787Ssam #define PF_INET AF_INET 8112787Ssam #define PF_IMPLINK AF_IMPLINK 8212787Ssam #define PF_PUP AF_PUP 8312787Ssam #define PF_CHAOS AF_CHAOS 8412787Ssam #define PF_NS AF_NS 8512787Ssam #define PF_NBS AF_NBS 8612787Ssam #define PF_ECMA AF_ECMA 8712787Ssam #define PF_DATAKIT AF_DATAKIT 8812787Ssam #define PF_CCITT AF_CCITT 8912787Ssam #define PF_SNA AF_SNA 908274Sroot 9112787Ssam #define PF_MAX 12 9212787Ssam 9312787Ssam /* 9412787Ssam * Level number for (get/set)sockopt() to apply to socket itself. 9512787Ssam */ 9610209Ssam #define SOL_SOCKET 0xffff /* options for socket level */ 9710209Ssam 9812787Ssam /* 9912787Ssam * Maximum queue length specifiable by listen. 10012787Ssam */ 10112787Ssam #define SOMAXCONN 5 10212787Ssam 10312787Ssam /* 10412787Ssam * Message header for recvmsg and sendmsg calls. 10512787Ssam */ 10612787Ssam struct msghdr { 10712787Ssam caddr_t msg_name; /* optional address */ 10812787Ssam int msg_namelen; /* size of address */ 10912787Ssam struct iovec *msg_iov; /* scatter/gather array */ 11012787Ssam int msg_iovlen; /* # elements in msg_iov */ 11112787Ssam caddr_t msg_accrights; /* access rights sent/received */ 11212787Ssam int msg_accrightslen; 11312787Ssam }; 11412787Ssam 11512787Ssam #define MSG_OOB 0x1 /* process out-of-band data */ 11612787Ssam #define MSG_PEEK 0x2 /* peek at incoming message */ 11712787Ssam #define MSG_DONTROUTE 0x4 /* send without using routing tables */ 11812787Ssam 11912787Ssam #define MSG_MAXIOVLEN 16 120