123438Smckusick /* 233186Sbostic * Copyright (c) 1982, 1985, 1986 Regents of the University of California. 333186Sbostic * All rights reserved. 423438Smckusick * 533186Sbostic * Redistribution and use in source and binary forms are permitted 6*34841Sbostic * provided that the above copyright notice and this paragraph are 7*34841Sbostic * duplicated in all such forms and that any documentation, 8*34841Sbostic * advertising materials, and other materials related to such 9*34841Sbostic * distribution and use acknowledge that the software was developed 10*34841Sbostic * by the University of California, Berkeley. The name of the 11*34841Sbostic * University may not be used to endorse or promote products derived 12*34841Sbostic * from this software without specific prior written permission. 13*34841Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34841Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34841Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1633186Sbostic * 17*34841Sbostic * @(#)socket.h 7.3 (Berkeley) 06/27/88 1823438Smckusick */ 194658Swnj 204658Swnj /* 2112787Ssam * Definitions related to sockets: types, address families, options. 224658Swnj */ 234892Swnj 244892Swnj /* 2512787Ssam * Types 264892Swnj */ 274930Swnj #define SOCK_STREAM 1 /* stream socket */ 284930Swnj #define SOCK_DGRAM 2 /* datagram socket */ 294930Swnj #define SOCK_RAW 3 /* raw-protocol interface */ 304930Swnj #define SOCK_RDM 4 /* reliably-delivered message */ 3112787Ssam #define SOCK_SEQPACKET 5 /* sequenced packet stream */ 324658Swnj 334812Swnj /* 344812Swnj * Option flags per-socket. 354812Swnj */ 3627192Skarels #define SO_DEBUG 0x0001 /* turn on debugging info recording */ 3727192Skarels #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 3827192Skarels #define SO_REUSEADDR 0x0004 /* allow local address reuse */ 3927192Skarels #define SO_KEEPALIVE 0x0008 /* keep connections alive */ 4027192Skarels #define SO_DONTROUTE 0x0010 /* just use interface addresses */ 4127192Skarels #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 4227192Skarels #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 4327192Skarels #define SO_LINGER 0x0080 /* linger on close if data present */ 4427192Skarels #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 454930Swnj 464930Swnj /* 4717552Skarels * Additional options, not kept in so_options. 4817552Skarels */ 4917552Skarels #define SO_SNDBUF 0x1001 /* send buffer size */ 5017552Skarels #define SO_RCVBUF 0x1002 /* receive buffer size */ 5117552Skarels #define SO_SNDLOWAT 0x1003 /* send low-water mark */ 5217552Skarels #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 5317552Skarels #define SO_SNDTIMEO 0x1005 /* send timeout */ 5417552Skarels #define SO_RCVTIMEO 0x1006 /* receive timeout */ 5524825Skarels #define SO_ERROR 0x1007 /* get error status and clear */ 5625503Skarels #define SO_TYPE 0x1008 /* get socket type */ 5717552Skarels 5817552Skarels /* 5917160Ssam * Structure used for manipulating linger option. 6017052Skarels */ 6117160Ssam struct linger { 6217160Ssam int l_onoff; /* option on/off */ 6317160Ssam int l_linger; /* linger time */ 6417160Ssam }; 6517052Skarels 6617052Skarels /* 6717160Ssam * Level number for (get/set)sockopt() to apply to socket itself. 6817160Ssam */ 6917160Ssam #define SOL_SOCKET 0xffff /* options for socket level */ 7017160Ssam 7117160Ssam /* 7212787Ssam * Address families. 734930Swnj */ 7412787Ssam #define AF_UNSPEC 0 /* unspecified */ 7512787Ssam #define AF_UNIX 1 /* local to host (pipes, portals) */ 7612787Ssam #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 7712787Ssam #define AF_IMPLINK 3 /* arpanet imp addresses */ 7812787Ssam #define AF_PUP 4 /* pup protocols: e.g. BSP */ 7912787Ssam #define AF_CHAOS 5 /* mit CHAOS protocols */ 8012787Ssam #define AF_NS 6 /* XEROX NS protocols */ 8112787Ssam #define AF_NBS 7 /* nbs protocols */ 8212787Ssam #define AF_ECMA 8 /* european computer manufacturers */ 8312787Ssam #define AF_DATAKIT 9 /* datakit protocols */ 8412787Ssam #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 8512787Ssam #define AF_SNA 11 /* IBM SNA */ 8623751Skarels #define AF_DECnet 12 /* DECnet */ 8723751Skarels #define AF_DLI 13 /* Direct data link interface */ 8823751Skarels #define AF_LAT 14 /* LAT */ 8923751Skarels #define AF_HYLINK 15 /* NSC Hyperchannel */ 9028881Skarels #define AF_APPLETALK 16 /* Apple Talk */ 914930Swnj 9228881Skarels #define AF_MAX 17 934930Swnj 944930Swnj /* 9512787Ssam * Structure used by kernel to store most 9612787Ssam * addresses. 974930Swnj */ 984930Swnj struct sockaddr { 9912508Ssam u_short sa_family; /* address family */ 1004930Swnj char sa_data[14]; /* up to 14 bytes of direct address */ 1014930Swnj }; 1024930Swnj 1034930Swnj /* 10412787Ssam * Structure used by kernel to pass protocol 10512787Ssam * information in raw sockets. 1064930Swnj */ 10712787Ssam struct sockproto { 10812787Ssam u_short sp_family; /* address family */ 10912787Ssam u_short sp_protocol; /* protocol */ 11012787Ssam }; 1116620Ssam 11212787Ssam /* 11312787Ssam * Protocol families, same as address families for now. 11412787Ssam */ 11512787Ssam #define PF_UNSPEC AF_UNSPEC 11612787Ssam #define PF_UNIX AF_UNIX 11712787Ssam #define PF_INET AF_INET 11812787Ssam #define PF_IMPLINK AF_IMPLINK 11912787Ssam #define PF_PUP AF_PUP 12012787Ssam #define PF_CHAOS AF_CHAOS 12112787Ssam #define PF_NS AF_NS 12212787Ssam #define PF_NBS AF_NBS 12312787Ssam #define PF_ECMA AF_ECMA 12412787Ssam #define PF_DATAKIT AF_DATAKIT 12512787Ssam #define PF_CCITT AF_CCITT 12612787Ssam #define PF_SNA AF_SNA 12723751Skarels #define PF_DECnet AF_DECnet 12823751Skarels #define PF_DLI AF_DLI 12923751Skarels #define PF_LAT AF_LAT 13023751Skarels #define PF_HYLINK AF_HYLINK 13128881Skarels #define PF_APPLETALK AF_APPLETALK 1328274Sroot 13323751Skarels #define PF_MAX AF_MAX 13412787Ssam 13512787Ssam /* 13612787Ssam * Maximum queue length specifiable by listen. 13712787Ssam */ 13812787Ssam #define SOMAXCONN 5 13912787Ssam 14012787Ssam /* 14112787Ssam * Message header for recvmsg and sendmsg calls. 14212787Ssam */ 14312787Ssam struct msghdr { 14412787Ssam caddr_t msg_name; /* optional address */ 14512787Ssam int msg_namelen; /* size of address */ 14612787Ssam struct iovec *msg_iov; /* scatter/gather array */ 14712787Ssam int msg_iovlen; /* # elements in msg_iov */ 14812787Ssam caddr_t msg_accrights; /* access rights sent/received */ 14912787Ssam int msg_accrightslen; 15012787Ssam }; 15112787Ssam 15212787Ssam #define MSG_OOB 0x1 /* process out-of-band data */ 15312787Ssam #define MSG_PEEK 0x2 /* peek at incoming message */ 15412787Ssam #define MSG_DONTROUTE 0x4 /* send without using routing tables */ 15512787Ssam 15612787Ssam #define MSG_MAXIOVLEN 16 157