Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / libc / include / sys / socket.h
blob207fa9b9cf6ba1a7af00b205e7dbcd9135f5cea3
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _SOCKET_H
22 #define _SOCKET_H
24 #include <sys/types.h>
26 /* Supported address families. */
27 #define AF_UNSPEC 0
28 #define AF_UNIX 1 /* Unix domain sockets */
29 #define AF_LOCAL 1 /* POSIX name for AF_UNIX */
30 #define AF_INET 2 /* Internet IP Protocol */
31 #define AF_AX25 3 /* Amateur Radio AX.25 */
32 #define AF_IPX 4 /* Novell IPX */
33 #define AF_APPLETALK 5 /* AppleTalk DDP */
34 #define AF_NETROM 6 /* Amateur Radio NET/ROM */
35 #define AF_BRIDGE 7 /* Multiprotocol bridge */
36 #define AF_ATMPVC 8 /* ATM PVCs */
37 #define AF_X25 9 /* Reserved for X.25 project */
38 #define AF_INET6 10 /* IP version 6 */
39 #define AF_ROSE 11 /* Amateur Radio X.25 PLP */
40 #define AF_DECnet 12 /* Reserved for DECnet project */
41 #define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/
42 #define AF_SECURITY 14 /* Security callback pseudo AF */
43 #define AF_KEY 15 /* PF_KEY key management API */
44 #define AF_NETLINK 16
45 #define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */
46 #define AF_PACKET 17 /* Packet family */
47 #define AF_ASH 18 /* Ash */
48 #define AF_ECONET 19 /* Acorn Econet */
49 #define AF_ATMSVC 20 /* ATM SVCs */
50 #define AF_SNA 22 /* Linux SNA Project (nutters!) */
51 #define AF_IRDA 23 /* IRDA sockets */
52 #define AF_PPPOX 24 /* PPPoX sockets */
53 #define AF_WANPIPE 25 /* Wanpipe API Sockets */
54 #define AF_LLC 26 /* Linux LLC */
55 #define AF_TIPC 30 /* TIPC sockets */
56 #define AF_BLUETOOTH 31 /* Bluetooth sockets */
57 #define AF_IUCV 32 /* IUCV sockets */
58 #define AF_RXRPC 33 /* RxRPC sockets */
59 #define AF_MAX 34 /* For now.. */
60 #define AF_RS232 35 /* Serial socket (NEW!) */
62 /* Protocol families, same as address families. */
63 #define PF_UNSPEC AF_UNSPEC
64 #define PF_UNIX AF_UNIX
65 #define PF_LOCAL AF_LOCAL
66 #define PF_INET AF_INET
67 #define PF_AX25 AF_AX25
68 #define PF_IPX AF_IPX
69 #define PF_APPLETALK AF_APPLETALK
70 #define PF_NETROM AF_NETROM
71 #define PF_BRIDGE AF_BRIDGE
72 #define PF_ATMPVC AF_ATMPVC
73 #define PF_X25 AF_X25
74 #define PF_INET6 AF_INET6
75 #define PF_ROSE AF_ROSE
76 #define PF_DECnet AF_DECnet
77 #define PF_NETBEUI AF_NETBEUI
78 #define PF_SECURITY AF_SECURITY
79 #define PF_KEY AF_KEY
80 #define PF_NETLINK AF_NETLINK
81 #define PF_ROUTE AF_ROUTE
82 #define PF_PACKET AF_PACKET
83 #define PF_ASH AF_ASH
84 #define PF_ECONET AF_ECONET
85 #define PF_ATMSVC AF_ATMSVC
86 #define PF_SNA AF_SNA
87 #define PF_IRDA AF_IRDA
88 #define PF_PPPOX AF_PPPOX
89 #define PF_WANPIPE AF_WANPIPE
90 #define PF_LLC AF_LLC
91 #define PF_TIPC AF_TIPC
92 #define PF_BLUETOOTH AF_BLUETOOTH
93 #define PF_IUCV AF_IUCV
94 #define PF_RXRPC AF_RXRPC
95 #define PF_MAX AF_MAX
96 #define PF_RS232 AF_RS232
98 /* Maximum queue length specifiable by listen. */
99 #define SOMAXCONN 128
101 /* Flags we can use with send/ and recv.
102 Added those for 1003.1g not all are supported yet
105 #define MSG_OOB 0x1
106 #define MSG_PEEK 0x2
107 #define MSG_DONTROUTE 0x4
108 #define MSG_TRYHARD 0x4 /* Synonym for MSG_DONTROUTE for DECnet */
109 #define MSG_CTRUNC 0x8
110 #define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */
111 #define MSG_TRUNC 0x20
112 #define MSG_DONTWAIT 0x40 /* Nonblocking io */
113 #define MSG_EOR 0x80 /* End of record */
114 #define MSG_WAITALL 0x100 /* Wait for a full request */
115 #define MSG_FIN 0x200
116 #define MSG_SYN 0x400
117 #define MSG_CONFIRM 0x800 /* Confirm path validity */
118 #define MSG_RST 0x1000
119 #define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */
120 #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
121 #define MSG_MORE 0x8000 /* Sender will send more */
123 #define MSG_EOF MSG_FIN
126 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
127 #define SOL_IP 0
128 #define SOL_ICMP 1
129 #define SOL_TCP 6
130 #define SOL_UDP 17
131 #define SOL_IPV6 41
132 #define SOL_ICMPV6 58
133 #define SOL_SCTP 132
134 #define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */
135 #define SOL_RAW 255
136 #define SOL_IPX 256
137 #define SOL_AX25 257
138 #define SOL_ATALK 258
139 #define SOL_NETROM 259
140 #define SOL_ROSE 260
141 #define SOL_DECNET 261
142 #define SOL_X25 262
143 #define SOL_PACKET 263
144 #define SOL_ATM 264 /* ATM layer (cell level) */
145 #define SOL_AAL 265 /* ATM Adaption Layer (packet level) */
146 #define SOL_IRDA 266
147 #define SOL_NETBEUI 267
148 #define SOL_LLC 268
149 #define SOL_DCCP 269
150 #define SOL_NETLINK 270
151 #define SOL_TIPC 271
152 #define SOL_RXRPC 272
153 #define SOL_SOCKET 0xffff
155 #define SO_DEBUG 1
156 #define SO_REUSEADDR 2
157 #define SO_TYPE 3
158 #define SO_ERROR 4
159 #define SO_DONTROUTE 5
160 #define SO_BROADCAST 6
161 #define SO_SNDBUF 7
162 #define SO_RCVBUF 8
163 #define SO_KEEPALIVE 9
164 #define SO_OOBINLINE 10
165 #define SO_NO_CHECK 11
166 #define SO_PRIORITY 12
167 #define SO_LINGER 13
168 #define SO_BSDCOMPAT 14
169 #define SO_REUSEPORT 15
170 #define SO_PASSCRED 16
171 #define SO_PEERCRED 17
172 #define SO_RCVLOWAT 18
173 #define SO_SNDLOWAT 19
174 #define SO_RCVTIMEO 20
175 #define SO_SNDTIMEO 21
176 #define SO_ACCEPTCONN 30
178 /* Option flags per-socket */
179 #define SO_NODELAY 0x200 /* Forward data expediently */
181 /* IPX options */
182 #define IPX_TYPE 1
184 /* Sock types */
185 #define SOCK_STREAM 1 /* stream (connection) socket */
186 #define SOCK_DGRAM 2 /* datagram (conn.less) socket */
187 #define SOCK_RAW 3 /* raw socket */
188 #define SOCK_RDM 4 /* reliably-delivered message */
189 #define SOCK_SEQPACKET 5 /* sequential packet socket */
190 #define SOCK_PACKET 10 /* linux specified */
192 #define IPPROTO_IP 0 /* Dummy for IP */
193 #define IPPROTO_ICMP 1 /* Control message protocol */
194 #define IPPROTO_IGMP 2 /* Group management protocol */
195 #define IPPROTO_TCP 6 /* Transmission control protocol */
196 #define IPPROTO_UDP 17 /* User datagram protocol */
197 #define IPPROTO_RAW 255 /* Raw IP packet */
198 #define IPPROTO_MAX 256 /* Maximum protocol identifier */
199 #define IPPORT_RESERVED 1024 /* Last reserved port number */
200 #define IPPORT_USERRESERVED 5000 /* User reserved port number */
202 #define INADDR_ANY (unsigned long) 0x00000000 /* Any IPv4 address */
203 #define INADDR6_ANY 0x0 /* Any IPv6 address */
204 #define INADDR_BROADCAST (unsigned long) 0xffffffff /* Broadcast IP address */
206 typedef unsigned socklen_t;
207 typedef unsigned short sa_family_t;
209 struct sockaddr {
210 unsigned short sa_family;
211 char sa_data[14];
214 /* externs */
215 extern int socket (int family, int type, int protocol);
216 extern int connect (int fd, struct sockaddr *addr, socklen_t len);
217 extern int send (int fd, char *msg, size_t size, int flags);
218 extern int recv (int fd, char *msg, size_t size, int flags);
219 extern int bind (int fd, struct sockaddr *addr, socklen_t len);
220 extern int listen (int fd, int backlog);
221 extern int accept (int fd, struct sockaddr *addr, socklen_t *addrlen);
222 extern int sendto (int fd, const void *msg, size_t len, int flags, struct sockaddr *to, socklen_t tolen);
223 extern int recvfrom (int fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
224 extern int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
226 #endif