1 /* socket.h 4.22 82/11/13 */ 2 3 /* 4 * Externally visible attributes of sockets. 5 */ 6 7 /* 8 * Socket types. 9 * 10 * The kernel implement these abstract (session-layer) socket 11 * services, with extra protocol on top of network services 12 * if necessary. 13 */ 14 #define SOCK_STREAM 1 /* stream socket */ 15 #define SOCK_DGRAM 2 /* datagram socket */ 16 #define SOCK_RAW 3 /* raw-protocol interface */ 17 #define SOCK_RDM 4 /* reliably-delivered message */ 18 19 /* 20 * Option flags per-socket. 21 */ 22 #define SO_DEBUG 0x01 /* turn on debugging info recording */ 23 #define SO_ACCEPTCONN 0x02 /* willing to accept connections */ 24 #define SO_DONTLINGER 0x04 /* don't linger on close */ 25 #define SO_KEEPALIVE 0x08 /* keep connections alive */ 26 #define SO_DONTROUTE 0x10 /* just use interface addresses */ 27 #define SO_NEWFDONCONN 0x20 /* give new fd on connection */ 28 29 /* 30 * Generic socket protocol format. 31 * 32 * Each process is normally operating in a protocol family, 33 * whose protocols are used unless the process specifies otherwise. 34 * Most families supply protocols to the basic socket types. When 35 * protocols are not present in the family, the higher level (roughly 36 * ISO session layer) code in the system layers on the protocols 37 * to support the socket types. 38 */ 39 struct sockproto { 40 short sp_family; /* protocol family */ 41 short sp_protocol; /* protocol within family */ 42 }; 43 44 #define PF_UNSPEC 0 /* unspecified */ 45 #define PF_UNIX 1 /* UNIX internal protocol */ 46 #define PF_INET 2 /* internetwork: UDP, TCP, etc. */ 47 #define PF_IMPLINK 3 /* imp link protocols */ 48 #define PF_PUP 4 /* pup protocols: e.g. BSP */ 49 #define PF_CHAOS 5 /* mit CHAOS protocols */ 50 #define PF_OISCP 6 /* ois communication protocols */ 51 #define PF_NBS 7 /* nbs protocols */ 52 #define PF_ECMA 8 /* european computer manufacturers */ 53 #define PF_DATAKIT 9 /* datakit protocols */ 54 #define PF_CCITT 10 /* CCITT protocols, X.25 etc */ 55 56 /* 57 * Generic socket address format. 58 * 59 * Each process is also operating in an address family, whose 60 * addresses are assigned unless otherwise requested. The address 61 * family used affects address properties: whether addresses are 62 * externalized or internalized, location dependent or independent, etc. 63 * The address can be defined directly if it fits in 14 bytes, or 64 * a pointer and length can be given to variable length data. 65 * We give these as two different structures to allow initialization. 66 */ 67 struct sockaddr { 68 short sa_family; /* address family */ 69 char sa_data[14]; /* up to 14 bytes of direct address */ 70 }; 71 72 /* 73 * The first few address families correspond to protocol 74 * families. Address families unrelated to protocol families 75 * are also possible. 76 */ 77 #define AF_UNSPEC 0 /* unspecified */ 78 #define AF_UNIX 1 /* local to host (pipes, portals) */ 79 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 80 #define AF_IMPLINK 3 /* arpanet imp addresses */ 81 #define AF_PUP 4 /* pup protocols: e.g. BSP */ 82 #define AF_CHAOS 5 /* mit CHAOS protocols */ 83 #define AF_OISCP 6 /* ois communication protocols */ 84 #define AF_NBS 7 /* nbs protocols */ 85 #define AF_ECMA 8 /* european computer manufacturers */ 86 #define AF_DATAKIT 9 /* datakit protocols */ 87 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 88 89 #define AF_MAX 11 90 91 struct socketopt { 92 int so_optlen; 93 char *so_optdata; 94 }; 95 96 #define SOF_OOB 0x1 97 #define SOF_PREVIEW 0x2 98