1 #ifndef __SYS_SOCKET_H__ 2 #define __SYS_SOCKET_H__ 3 4 #ifndef _BSD_EXTENSION 5 This header file is an extension to ANSI/POSIX 6 #endif 7 8 #pragma lib "/$M/lib/ape/libbsd.a" 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 /* 15 * Copyright (c) 1982,1985, 1986 Regents of the University of California. 16 * All rights reserved. The Berkeley software License Agreement 17 * specifies the terms and conditions for redistribution. 18 * 19 * @(#)socket.h 7.1 (Berkeley) 6/4/86 20 */ 21 22 /* 23 * Definitions related to sockets: types, address families, options. 24 */ 25 26 /* 27 * Types 28 */ 29 #define SOCK_STREAM 1 /* stream socket */ 30 #define SOCK_DGRAM 2 /* datagram socket */ 31 #define SOCK_RAW 3 /* raw-protocol interface */ 32 #define SOCK_RDM 4 /* reliably-delivered message */ 33 #define SOCK_SEQPACKET 5 /* sequenced packet stream */ 34 35 /* 36 * Option flags per-socket. 37 */ 38 #ifdef HAVE_SOCK_OPTS 39 #define SO_DEBUG 0x0001 /* turn on debugging info recording */ 40 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 41 #define SO_REUSEADDR 0x0004 /* allow local address reuse */ 42 #define SO_KEEPALIVE 0x0008 /* keep connections alive */ 43 #define SO_DONTROUTE 0x0010 /* just use interface addresses */ 44 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 45 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 46 #define SO_LINGER 0x0080 /* linger on close if data present */ 47 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 48 #endif 49 50 /* 51 * Additional options, not kept in so_options. 52 */ 53 #define SO_SNDBUF 0x1001 /* send buffer size */ 54 #define SO_RCVBUF 0x1002 /* receive buffer size */ 55 #define SO_SNDLOWAT 0x1003 /* send low-water mark */ 56 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 57 #define SO_SNDTIMEO 0x1005 /* send timeout */ 58 #define SO_RCVTIMEO 0x1006 /* receive timeout */ 59 #define SO_ERROR 0x1007 /* get error status and clear */ 60 #define SO_TYPE 0x1008 /* get socket type */ 61 62 /* 63 * Structure used for manipulating linger option. 64 */ 65 struct linger { 66 int l_onoff; /* option on/off */ 67 int l_linger; /* linger time */ 68 }; 69 70 /* 71 * Level number for (get/set)sockopt() to apply to socket itself. 72 */ 73 #define SOL_SOCKET 0xffff /* options for socket level */ 74 75 /* 76 * Address families. 77 * XTP really is not an address family, but is included here to take 78 * up space, because other AF_ entries are numerically equal to their 79 * PF_ counterparts. 80 */ 81 #define AF_UNSPEC 0 /* unspecified */ 82 #define AF_UNIX 1 /* local to host (pipes, portals) */ 83 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 84 #define AF_IMPLINK 3 /* arpanet imp addresses */ 85 #define AF_PUP 4 /* pup protocols: e.g. BSP */ 86 #define AF_CHAOS 5 /* mit CHAOS protocols */ 87 #define AF_NS 6 /* XEROX NS protocols */ 88 #define AF_ISO 7 /* ISO protocols */ 89 #define AF_OSI AF_ISO 90 #define AF_ECMA 8 /* european computer manufacturers */ 91 #define AF_DATAKIT 9 /* datakit protocols */ 92 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 93 #define AF_SNA 11 /* IBM SNA */ 94 #define AF_DECnet 12 /* DECnet */ 95 #define AF_DLI 13 /* DEC Direct data link interface */ 96 #define AF_LAT 14 /* LAT */ 97 #define AF_HYLINK 15 /* NSC Hyperchannel */ 98 #define AF_APPLETALK 16 /* Apple Talk */ 99 #define AF_ROUTE 17 /* Internal Routing Protocol */ 100 #define AF_LINK 18 /* Link layer interface */ 101 #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ 102 #define AF_INET6 24 /* IP version 6 */ 103 #define AF_MAX 30 104 105 /* 106 * Structure used by kernel to store most 107 * addresses. 108 */ 109 struct sockaddr { 110 unsigned short sa_family; /* address family */ 111 char sa_data[108]; 112 }; 113 114 /* 115 * Structure used by kernel to pass protocol 116 * information in raw sockets. 117 */ 118 struct sockproto { 119 unsigned short sp_family; /* address family */ 120 unsigned short sp_protocol; /* protocol */ 121 }; 122 123 /* 124 * Protocol families, same as address families for now. 125 */ 126 #define PF_UNSPEC AF_UNSPEC 127 #define PF_UNIX AF_UNIX 128 #define PF_INET AF_INET 129 #define PF_IMPLINK AF_IMPLINK 130 #define PF_PUP AF_PUP 131 #define PF_CHAOS AF_CHAOS 132 #define PF_NS AF_NS 133 #define PF_ISO AF_ISO 134 #define PF_OSI AF_ISO 135 #define PF_ECMA AF_ECMA 136 #define PF_DATAKIT AF_DATAKIT 137 #define PF_CCITT AF_CCITT 138 #define PF_SNA AF_SNA 139 #define PF_DECnet AF_DECnet 140 #define PF_DLI AF_DLI 141 #define PF_LAT AF_LAT 142 #define PF_HYLINK AF_HYLINK 143 #define PF_APPLETALK AF_APPLETALK 144 #define PF_ROUTE AF_ROUTE 145 #define PF_LINK AF_LINK 146 #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ 147 #define PF_INET6 AF_INET6 148 149 #define PF_MAX AF_MAX 150 151 /* 152 * Maximum queue length specifiable by listen. 153 */ 154 #define SOMAXCONN 5 155 156 /* 157 * Message header for recvmsg and sendmsg calls. 158 */ 159 struct msghdr { 160 char *msg_name; /* optional address */ 161 int msg_namelen; /* size of address */ 162 struct iovec *msg_iov; /* scatter/gather array */ 163 int msg_iovlen; /* # elements in msg_iov */ 164 char *msg_accrights; /* access rights sent/received */ 165 int msg_accrightslen; 166 }; 167 168 #define MSG_OOB 0x1 /* process out-of-band data */ 169 #define MSG_PEEK 0x2 /* peek at incoming message */ 170 #define MSG_DONTROUTE 0x4 /* send without using routing tables */ 171 172 #define MSG_MAXIOVLEN 16 173 174 extern int accept(int, void *, int *); 175 extern int bind(int, void *, int); 176 extern int connect(int, void *, int); 177 extern int getpeername(int, void *, int *); 178 extern int getsockname(int, void *, int *); 179 extern int getsockopt(int, int, int, void *, int *); 180 extern int setsockopt(int, int, int, void *, int); 181 extern int listen(int, int); 182 extern int recv(int, void *, int, int); 183 extern int recvfrom(int, void *, int, int, void *, int *); 184 extern int recvmsg(int, struct msghdr *, int); 185 extern int send(int, void *, int, int); 186 extern int sendto(int, void *, int, int, void *, int); 187 extern int sendmsg(int, struct msghdr *, int); 188 extern int shutdown(int, int); 189 extern int socket(int, int, int); 190 extern int socketpair(int, int, int, int *); 191 192 #ifdef __cplusplus 193 } 194 #endif 195 196 #endif /* !__SYS_SOCKET_H__ */ 197