1*10209Ssam /* socket.h 4.23 83/01/08 */ 24658Swnj 34658Swnj /* 44892Swnj * Externally visible attributes of sockets. 54658Swnj */ 64892Swnj 74892Swnj /* 84892Swnj * Socket types. 94892Swnj * 104892Swnj * The kernel implement these abstract (session-layer) socket 114892Swnj * services, with extra protocol on top of network services 124892Swnj * if necessary. 134892Swnj */ 144930Swnj #define SOCK_STREAM 1 /* stream socket */ 154930Swnj #define SOCK_DGRAM 2 /* datagram socket */ 164930Swnj #define SOCK_RAW 3 /* raw-protocol interface */ 174930Swnj #define SOCK_RDM 4 /* reliably-delivered message */ 184658Swnj 194812Swnj /* 204812Swnj * Option flags per-socket. 214812Swnj */ 224812Swnj #define SO_DEBUG 0x01 /* turn on debugging info recording */ 235394Swnj #define SO_ACCEPTCONN 0x02 /* willing to accept connections */ 246215Swnj #define SO_DONTLINGER 0x04 /* don't linger on close */ 256215Swnj #define SO_KEEPALIVE 0x08 /* keep connections alive */ 267132Swnj #define SO_DONTROUTE 0x10 /* just use interface addresses */ 277497Sroot #define SO_NEWFDONCONN 0x20 /* give new fd on connection */ 28*10209Ssam #define SO_USELOOPBACK 0x40 /* bypass hardware when possible */ 29*10209Ssam #define SO_LINGER 0x80 /* ~SO_DONTLINGER */ 304930Swnj 314930Swnj /* 324930Swnj * Generic socket protocol format. 334930Swnj * 344930Swnj * Each process is normally operating in a protocol family, 354930Swnj * whose protocols are used unless the process specifies otherwise. 364930Swnj * Most families supply protocols to the basic socket types. When 374930Swnj * protocols are not present in the family, the higher level (roughly 384930Swnj * ISO session layer) code in the system layers on the protocols 394930Swnj * to support the socket types. 404930Swnj */ 414930Swnj struct sockproto { 424930Swnj short sp_family; /* protocol family */ 435617Swnj short sp_protocol; /* protocol within family */ 444930Swnj }; 454930Swnj 464930Swnj #define PF_UNSPEC 0 /* unspecified */ 475119Swnj #define PF_UNIX 1 /* UNIX internal protocol */ 484930Swnj #define PF_INET 2 /* internetwork: UDP, TCP, etc. */ 495119Swnj #define PF_IMPLINK 3 /* imp link protocols */ 505119Swnj #define PF_PUP 4 /* pup protocols: e.g. BSP */ 515119Swnj #define PF_CHAOS 5 /* mit CHAOS protocols */ 525119Swnj #define PF_OISCP 6 /* ois communication protocols */ 535119Swnj #define PF_NBS 7 /* nbs protocols */ 545119Swnj #define PF_ECMA 8 /* european computer manufacturers */ 555119Swnj #define PF_DATAKIT 9 /* datakit protocols */ 565119Swnj #define PF_CCITT 10 /* CCITT protocols, X.25 etc */ 574930Swnj 584930Swnj /* 594930Swnj * Generic socket address format. 604930Swnj * 614930Swnj * Each process is also operating in an address family, whose 624930Swnj * addresses are assigned unless otherwise requested. The address 634930Swnj * family used affects address properties: whether addresses are 644930Swnj * externalized or internalized, location dependent or independent, etc. 654930Swnj * The address can be defined directly if it fits in 14 bytes, or 664930Swnj * a pointer and length can be given to variable length data. 674930Swnj * We give these as two different structures to allow initialization. 684930Swnj */ 694930Swnj struct sockaddr { 704930Swnj short sa_family; /* address family */ 714930Swnj char sa_data[14]; /* up to 14 bytes of direct address */ 724930Swnj }; 734930Swnj 744930Swnj /* 754930Swnj * The first few address families correspond to protocol 764930Swnj * families. Address families unrelated to protocol families 774930Swnj * are also possible. 784930Swnj */ 794930Swnj #define AF_UNSPEC 0 /* unspecified */ 805167Swnj #define AF_UNIX 1 /* local to host (pipes, portals) */ 814930Swnj #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 825119Swnj #define AF_IMPLINK 3 /* arpanet imp addresses */ 835119Swnj #define AF_PUP 4 /* pup protocols: e.g. BSP */ 845119Swnj #define AF_CHAOS 5 /* mit CHAOS protocols */ 855119Swnj #define AF_OISCP 6 /* ois communication protocols */ 865119Swnj #define AF_NBS 7 /* nbs protocols */ 875119Swnj #define AF_ECMA 8 /* european computer manufacturers */ 885119Swnj #define AF_DATAKIT 9 /* datakit protocols */ 895119Swnj #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 906620Ssam 916620Ssam #define AF_MAX 11 928274Sroot 93*10209Ssam /* 94*10209Ssam * Structure passed in at system call level. 95*10209Ssam */ 968274Sroot struct socketopt { 97*10209Ssam int so_optlen; /* total size of options */ 98*10209Ssam struct sotemplate *so_optdata; /* option records */ 998274Sroot }; 1008322Sroot 101*10209Ssam /* 102*10209Ssam * Options are specified as an array of records, 103*10209Ssam * each of the following structure. opt_level 104*10209Ssam * indicates who's options are being specified. 105*10209Ssam * Only SOL_SOCKET is globally known, other levels 106*10209Ssam * use protocol numbers to tag options. The 107*10209Ssam * opt_size field does not include the space 108*10209Ssam * occupied by opt_level and opt_size. opt_data 109*10209Ssam * is usually structured differently at each level. 110*10209Ssam */ 111*10209Ssam struct sotemplate { 112*10209Ssam u_short opt_level; /* level for which options are for */ 113*10209Ssam #define SOL_SOCKET 0xffff /* options for socket level */ 114*10209Ssam u_short opt_size; /* amount of data in opt_data */ 115*10209Ssam u_char opt_data[1]; /* acutally longer */ 116*10209Ssam }; 117*10209Ssam 118*10209Ssam /* 119*10209Ssam * Structure used in specifying socket 120*10209Ssam * level (SOL_SOCKET) options. 121*10209Ssam */ 122*10209Ssam struct sooptions { 123*10209Ssam int sop_name; /* defined above */ 124*10209Ssam int sop_val; /* optional value */ 125*10209Ssam }; 126*10209Ssam 127*10209Ssam #define SOF_OOB 0x1 /* send/recv out-of-band data */ 128*10209Ssam #define SOF_PREVIEW 0x2 /* look at data, but don't read */ 129*10209Ssam #define SOF_DONTROUTE 0x4 /* send without routing data */ 130