3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /* Supported address families. */
26 #define AF_UNIX 1 /* Unix domain sockets */
27 #define AF_LOCAL 1 /* POSIX name for AF_UNIX */
28 #define AF_INET 2 /* Internet IP Protocol */
29 #define AF_AX25 3 /* Amateur Radio AX.25 */
30 #define AF_IPX 4 /* Novell IPX */
31 #define AF_APPLETALK 5 /* AppleTalk DDP */
32 #define AF_NETROM 6 /* Amateur Radio NET/ROM */
33 #define AF_BRIDGE 7 /* Multiprotocol bridge */
34 #define AF_ATMPVC 8 /* ATM PVCs */
35 #define AF_X25 9 /* Reserved for X.25 project */
36 #define AF_INET6 10 /* IP version 6 */
37 #define AF_ROSE 11 /* Amateur Radio X.25 PLP */
38 #define AF_DECnet 12 /* Reserved for DECnet project */
39 #define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/
40 #define AF_SECURITY 14 /* Security callback pseudo AF */
41 #define AF_KEY 15 /* PF_KEY key management API */
43 #define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */
44 #define AF_PACKET 17 /* Packet family */
45 #define AF_ASH 18 /* Ash */
46 #define AF_ECONET 19 /* Acorn Econet */
47 #define AF_ATMSVC 20 /* ATM SVCs */
48 #define AF_SNA 22 /* Linux SNA Project (nutters!) */
49 #define AF_IRDA 23 /* IRDA sockets */
50 #define AF_PPPOX 24 /* PPPoX sockets */
51 #define AF_WANPIPE 25 /* Wanpipe API Sockets */
52 #define AF_LLC 26 /* Linux LLC */
53 #define AF_TIPC 30 /* TIPC sockets */
54 #define AF_BLUETOOTH 31 /* Bluetooth sockets */
55 #define AF_IUCV 32 /* IUCV sockets */
56 #define AF_RXRPC 33 /* RxRPC sockets */
57 #define AF_MAX 34 /* For now.. */
58 #define AF_RS232 35 /* Serial socket (NEW!) */
60 /* Protocol families, same as address families. */
61 #define PF_UNSPEC AF_UNSPEC
62 #define PF_UNIX AF_UNIX
63 #define PF_LOCAL AF_LOCAL
64 #define PF_INET AF_INET
65 #define PF_AX25 AF_AX25
67 #define PF_APPLETALK AF_APPLETALK
68 #define PF_NETROM AF_NETROM
69 #define PF_BRIDGE AF_BRIDGE
70 #define PF_ATMPVC AF_ATMPVC
72 #define PF_INET6 AF_INET6
73 #define PF_ROSE AF_ROSE
74 #define PF_DECnet AF_DECnet
75 #define PF_NETBEUI AF_NETBEUI
76 #define PF_SECURITY AF_SECURITY
78 #define PF_NETLINK AF_NETLINK
79 #define PF_ROUTE AF_ROUTE
80 #define PF_PACKET AF_PACKET
82 #define PF_ECONET AF_ECONET
83 #define PF_ATMSVC AF_ATMSVC
85 #define PF_IRDA AF_IRDA
86 #define PF_PPPOX AF_PPPOX
87 #define PF_WANPIPE AF_WANPIPE
89 #define PF_TIPC AF_TIPC
90 #define PF_BLUETOOTH AF_BLUETOOTH
91 #define PF_IUCV AF_IUCV
92 #define PF_RXRPC AF_RXRPC
94 #define PF_RS232 AF_RS232
96 /* Maximum queue length specifiable by listen. */
99 /* Flags we can use with send/ and recv.
100 Added those for 1003.1g not all are supported yet
105 #define MSG_DONTROUTE 4
106 #define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */
108 #define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */
109 #define MSG_TRUNC 0x20
110 #define MSG_DONTWAIT 0x40 /* Nonblocking io */
111 #define MSG_EOR 0x80 /* End of record */
112 #define MSG_WAITALL 0x100 /* Wait for a full request */
113 #define MSG_FIN 0x200
114 #define MSG_SYN 0x400
115 #define MSG_CONFIRM 0x800 /* Confirm path validity */
116 #define MSG_RST 0x1000
117 #define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */
118 #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
119 #define MSG_MORE 0x8000 /* Sender will send more */
121 #define MSG_EOF MSG_FIN
123 #if defined(CONFIG_COMPAT)
124 #define MSG_CMSG_COMPAT 0x80000000 /* This message needs 32 bit fixups */
126 #define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
130 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
132 /* #define SOL_ICMP 1 No-no-no! Due to Linux :-) we cannot use SOL_ICMP=1 */
136 #define SOL_ICMPV6 58
138 #define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */
142 #define SOL_ATALK 258
143 #define SOL_NETROM 259
145 #define SOL_DECNET 261
147 #define SOL_PACKET 263
148 #define SOL_ATM 264 /* ATM layer (cell level) */
149 #define SOL_AAL 265 /* ATM Adaption Layer (packet level) */
151 #define SOL_NETBEUI 267
154 #define SOL_NETLINK 270
156 #define SOL_RXRPC 272
162 #define SOCK_STREAM 1 /* stream (connection) socket */
163 #define SOCK_DGRAM 2 /* datagram (conn.less) socket */
164 #define SOCK_RAW 3 /* raw socket */
165 #define SOCK_RDM 4 /* reliably-delivered message */
166 #define SOCK_SEQPACKET 5 /* sequential packet socket */
167 #define SOCK_PACKET 10 /* linux specified */
169 #define _NETINET_IN_H_
170 #define IPPROTO_IP 0 // Dummy for IP.
171 #define IPPROTO_ICMP 1 // Control message protocol.
172 #define IPPROTO_IGMP 2 // Group management protocol.
173 #define IPPROTO_TCP 6 // Transmission control protocol.
174 #define IPPROTO_UDP 17 // User datagram protocol.
175 #define IPPROTO_RAW 255 // Raw IP packet.
176 #define IPPROTO_MAX 256 // Maximum protocol identifier.
177 #define IPPORT_RESERVED 1024 // Last reserved port number.
178 #define IPPORT_USERRESERVED 5000 // User reserved port number.
179 #define INADDR_ANY 0x00000000 // Any IP address.
180 #define INADDR_BROADCAST 0xffffffff // Broadcast IP address.
182 #define FD_SOCK 0x100
184 typedef unsigned socklen_t
;
186 /* Device structure */
187 typedef struct socket_context
{
188 struct socket_context
*next
, *prev
;
197 unsigned short s6_addr
[8]; /* IPv6 address */
201 unsigned short sa_family
;
213 unsigned char sin6_len
; /* length of this structure */
214 unsigned char sin6_family
; /* AF_INET6 */
215 unsigned short sin6_port
; /* Transport layer port # */
216 unsigned sin6_flowinfo
; /* IPv6 flow information */
217 unsigned short sin6_addr
[8]; /* IPv6 address */
221 unsigned short sun_family
; /* AF_UNIX */
234 //extern int htons (int port);
235 extern hostent
*gethostbyname (char *hostname
);
236 extern int socket (int family
, int type
, int protocol
);
237 extern int connect (int fd
, sockaddr
*addr
, socklen_t len
);
238 extern int send (int fd
, char *msg
, size_t size
, int flags
);
239 extern int recv (int fd
, char *msg
, size_t size
, int flags
);
240 extern int bind (int fd
, sockaddr
*addr
, socklen_t len
);
241 extern int sclose (int fd
);
242 extern int sfcntl (int fd
, int cmd
, long arg
);
243 extern unsigned int init_socket ();