123438Smckusick /* 2*33186Sbostic * Copyright (c) 1982, 1985, 1986 Regents of the University of California. 3*33186Sbostic * All rights reserved. 423438Smckusick * 5*33186Sbostic * Redistribution and use in source and binary forms are permitted 6*33186Sbostic * provided that this notice is preserved and that due credit is given 7*33186Sbostic * to the University of California at Berkeley. The name of the University 8*33186Sbostic * may not be used to endorse or promote products derived from this 9*33186Sbostic * software without specific prior written permission. This software 10*33186Sbostic * is provided ``as is'' without express or implied warranty. 11*33186Sbostic * 12*33186Sbostic * @(#)socket.h 7.2 (Berkeley) 12/30/87 1323438Smckusick */ 144658Swnj 154658Swnj /* 1612787Ssam * Definitions related to sockets: types, address families, options. 174658Swnj */ 184892Swnj 194892Swnj /* 2012787Ssam * Types 214892Swnj */ 224930Swnj #define SOCK_STREAM 1 /* stream socket */ 234930Swnj #define SOCK_DGRAM 2 /* datagram socket */ 244930Swnj #define SOCK_RAW 3 /* raw-protocol interface */ 254930Swnj #define SOCK_RDM 4 /* reliably-delivered message */ 2612787Ssam #define SOCK_SEQPACKET 5 /* sequenced packet stream */ 274658Swnj 284812Swnj /* 294812Swnj * Option flags per-socket. 304812Swnj */ 3127192Skarels #define SO_DEBUG 0x0001 /* turn on debugging info recording */ 3227192Skarels #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 3327192Skarels #define SO_REUSEADDR 0x0004 /* allow local address reuse */ 3427192Skarels #define SO_KEEPALIVE 0x0008 /* keep connections alive */ 3527192Skarels #define SO_DONTROUTE 0x0010 /* just use interface addresses */ 3627192Skarels #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 3727192Skarels #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 3827192Skarels #define SO_LINGER 0x0080 /* linger on close if data present */ 3927192Skarels #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 404930Swnj 414930Swnj /* 4217552Skarels * Additional options, not kept in so_options. 4317552Skarels */ 4417552Skarels #define SO_SNDBUF 0x1001 /* send buffer size */ 4517552Skarels #define SO_RCVBUF 0x1002 /* receive buffer size */ 4617552Skarels #define SO_SNDLOWAT 0x1003 /* send low-water mark */ 4717552Skarels #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 4817552Skarels #define SO_SNDTIMEO 0x1005 /* send timeout */ 4917552Skarels #define SO_RCVTIMEO 0x1006 /* receive timeout */ 5024825Skarels #define SO_ERROR 0x1007 /* get error status and clear */ 5125503Skarels #define SO_TYPE 0x1008 /* get socket type */ 5217552Skarels 5317552Skarels /* 5417160Ssam * Structure used for manipulating linger option. 5517052Skarels */ 5617160Ssam struct linger { 5717160Ssam int l_onoff; /* option on/off */ 5817160Ssam int l_linger; /* linger time */ 5917160Ssam }; 6017052Skarels 6117052Skarels /* 6217160Ssam * Level number for (get/set)sockopt() to apply to socket itself. 6317160Ssam */ 6417160Ssam #define SOL_SOCKET 0xffff /* options for socket level */ 6517160Ssam 6617160Ssam /* 6712787Ssam * Address families. 684930Swnj */ 6912787Ssam #define AF_UNSPEC 0 /* unspecified */ 7012787Ssam #define AF_UNIX 1 /* local to host (pipes, portals) */ 7112787Ssam #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 7212787Ssam #define AF_IMPLINK 3 /* arpanet imp addresses */ 7312787Ssam #define AF_PUP 4 /* pup protocols: e.g. BSP */ 7412787Ssam #define AF_CHAOS 5 /* mit CHAOS protocols */ 7512787Ssam #define AF_NS 6 /* XEROX NS protocols */ 7612787Ssam #define AF_NBS 7 /* nbs protocols */ 7712787Ssam #define AF_ECMA 8 /* european computer manufacturers */ 7812787Ssam #define AF_DATAKIT 9 /* datakit protocols */ 7912787Ssam #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 8012787Ssam #define AF_SNA 11 /* IBM SNA */ 8123751Skarels #define AF_DECnet 12 /* DECnet */ 8223751Skarels #define AF_DLI 13 /* Direct data link interface */ 8323751Skarels #define AF_LAT 14 /* LAT */ 8423751Skarels #define AF_HYLINK 15 /* NSC Hyperchannel */ 8528881Skarels #define AF_APPLETALK 16 /* Apple Talk */ 864930Swnj 8728881Skarels #define AF_MAX 17 884930Swnj 894930Swnj /* 9012787Ssam * Structure used by kernel to store most 9112787Ssam * addresses. 924930Swnj */ 934930Swnj struct sockaddr { 9412508Ssam u_short sa_family; /* address family */ 954930Swnj char sa_data[14]; /* up to 14 bytes of direct address */ 964930Swnj }; 974930Swnj 984930Swnj /* 9912787Ssam * Structure used by kernel to pass protocol 10012787Ssam * information in raw sockets. 1014930Swnj */ 10212787Ssam struct sockproto { 10312787Ssam u_short sp_family; /* address family */ 10412787Ssam u_short sp_protocol; /* protocol */ 10512787Ssam }; 1066620Ssam 10712787Ssam /* 10812787Ssam * Protocol families, same as address families for now. 10912787Ssam */ 11012787Ssam #define PF_UNSPEC AF_UNSPEC 11112787Ssam #define PF_UNIX AF_UNIX 11212787Ssam #define PF_INET AF_INET 11312787Ssam #define PF_IMPLINK AF_IMPLINK 11412787Ssam #define PF_PUP AF_PUP 11512787Ssam #define PF_CHAOS AF_CHAOS 11612787Ssam #define PF_NS AF_NS 11712787Ssam #define PF_NBS AF_NBS 11812787Ssam #define PF_ECMA AF_ECMA 11912787Ssam #define PF_DATAKIT AF_DATAKIT 12012787Ssam #define PF_CCITT AF_CCITT 12112787Ssam #define PF_SNA AF_SNA 12223751Skarels #define PF_DECnet AF_DECnet 12323751Skarels #define PF_DLI AF_DLI 12423751Skarels #define PF_LAT AF_LAT 12523751Skarels #define PF_HYLINK AF_HYLINK 12628881Skarels #define PF_APPLETALK AF_APPLETALK 1278274Sroot 12823751Skarels #define PF_MAX AF_MAX 12912787Ssam 13012787Ssam /* 13112787Ssam * Maximum queue length specifiable by listen. 13212787Ssam */ 13312787Ssam #define SOMAXCONN 5 13412787Ssam 13512787Ssam /* 13612787Ssam * Message header for recvmsg and sendmsg calls. 13712787Ssam */ 13812787Ssam struct msghdr { 13912787Ssam caddr_t msg_name; /* optional address */ 14012787Ssam int msg_namelen; /* size of address */ 14112787Ssam struct iovec *msg_iov; /* scatter/gather array */ 14212787Ssam int msg_iovlen; /* # elements in msg_iov */ 14312787Ssam caddr_t msg_accrights; /* access rights sent/received */ 14412787Ssam int msg_accrightslen; 14512787Ssam }; 14612787Ssam 14712787Ssam #define MSG_OOB 0x1 /* process out-of-band data */ 14812787Ssam #define MSG_PEEK 0x2 /* peek at incoming message */ 14912787Ssam #define MSG_DONTROUTE 0x4 /* send without using routing tables */ 15012787Ssam 15112787Ssam #define MSG_MAXIOVLEN 16 152