DEADSOFTWARE

build-gui modified
[bbcp.git] / new / _OpenBSD_ / Lin / Mod / Net.txt
1 MODULE LinNet ["libc.so.66.0"];
3 (*
4 A. V. Shiryaev, 2012.11
6 OpenBSD 5.2
7 32-bit
8 *)
10 IMPORT Libc := LinLibc;
12 CONST
13 INVALID_SOCKET* = -1;
14 SOCKET_ERROR* = -1;
16 (* /usr/include/sys/socket.h *)
17 SOCK_STREAM* = 1; (* stream socket *)
18 SOCK_DGRAM* = 2; (* datagram socket *)
19 SOCK_RAW* = 3; (* raw-protocol interface *)
20 SOCK_RDM* = 4; (* reliably-delivered message *)
21 SOCK_SEQPACKET* = 5; (* sequenced packet stream *)
22 AF_UNSPEC* = 0; (* unspecified *)
23 AF_LOCAL* = 1; (* local to host (pipes, portals) *)
24 AF_UNIX* = AF_LOCAL; (* backward compatibility *)
25 AF_INET* = 2; (* internetwork: UDP, TCP, etc. *)
26 AF_IMPLINK* = 3; (* arpanet imp addresses *)
27 AF_PUP* = 4; (* pup protocols: e.g. BSP *)
28 AF_CHAOS* = 5; (* mit CHAOS protocols *)
29 AF_NS* = 6; (* XEROX NS protocols *)
30 AF_ISO* = 7; (* ISO protocols *)
31 AF_ECMA* = 8; (* european computer manufacturers *)
32 AF_DATAKIT* = 9; (* datakit protocols *)
33 AF_CCITT* = 10; (* CCITT protocols, X.25 etc *)
34 AF_SNA* = 11; (* IBM SNA *)
35 AF_DECnet* = 12; (* DECnet *)
36 AF_DLI* = 13; (* DEC Direct data link interface *)
37 AF_LAT* = 14; (* LAT *)
38 AF_HYLINK* = 15; (* NSC Hyperchannel *)
39 AF_APPLETALK* = 16; (* Apple Talk *)
40 AF_ROUTE* = 17; (* Internal Routing Protocol *)
41 AF_LINK* = 18; (* Link layer interface *)
42 AF_COIP* = 20; (* connection-oriented IP, aka ST II *)
43 AF_CNT* = 21; (* Computer Network Technology *)
44 AF_IPX* = 23; (* Novell Internet Protocol *)
45 AF_INET6* = 24; (* IPv6 *)
46 AF_ISDN* = 26; (* Integrated Services Digital Network *)
47 AF_E164* = AF_ISDN; (* CCITT E.164 recommendation *)
48 AF_NATM* = 27; (* native ATM access *)
49 AF_ENCAP* = 28;
50 AF_SIP* = 29; (* Simple Internet Protocol *)
51 AF_KEY* = 30;
52 AF_BLUETOOTH* = 32; (* Bluetooth *)
53 AF_MPLS* = 33; (* MPLS *)
54 AF_MAX* = 36;
55 SHUT_RD* = 0;
56 SHUT_WR* = 1;
57 SHUT_RDWR* = 2;
58 SOMAXCONN* = 128;
59 SO_DEBUG* = {0}; (* turn on debugging info recording *)
60 SO_ACCEPTCONN* = {1}; (* socket has had listen() *)
61 SO_REUSEADDR* = {2}; (* allow local address reuse *)
62 SO_KEEPALIVE* = {3}; (* keep connections alive *)
63 SO_DONTROUTE* = {4}; (* just use interface addresses *)
64 SO_BROADCAST* = {5}; (* permit sending of broadcast msgs *)
65 SO_USELOOPBACK* = {6}; (* bypass hardware when possible *)
66 SO_LINGER* = {7}; (* linger on close if data present *)
67 SO_OOBINLINE* = {8}; (* leave received OOB data in line *)
68 SO_REUSEPORT* = {9}; (* allow local address & port reuse *)
69 SO_TIMESTAMP* = {11}; (* timestamp received dgram traffic *)
70 SO_BINDANY* = {12}; (* allow bind to any address *)
71 SO_SNDBUF* = {0,12}; (* send buffer size *)
72 SO_RCVBUF* = {1,12}; (* receive buffer size *)
73 SO_SNDLOWAT* = {0,1,12}; (* send low-water mark *)
74 SO_RCVLOWAT* = {2,12}; (* receive low-water mark *)
75 SO_SNDTIMEO* = {0,2,12}; (* send timeout *)
76 SO_RCVTIMEO* = {1,2,12}; (* receive timeout *)
77 SO_ERROR* = {0..2,12}; (* get error status and clear *)
78 SO_TYPE* = {3,12}; (* get socket type *)
79 SO_NETPROC* = {5,12}; (* multiplex; network processing *)
80 SO_RTABLE* = {0,5,12}; (* routing table to be used *)
81 SO_PEERCRED* = {1,5,12}; (* get connect-time credentials *)
82 SO_SPLICE* = {0,1,5,12}; (* splice data to other socket *)
83 SOL_SOCKET* = 0FFFFH; (* {0..15} *) (* options for socket level *)
84 MSG_OOB* = {0}; (* process out-of-band data *)
85 MSG_PEEK* = {1}; (* peek at incoming message *)
86 MSG_DONTROUTE* = {2}; (* send without using routing tables *)
87 MSG_EOR* = {3}; (* data completes record *)
88 MSG_TRUNC* = {4}; (* data discarded before delivery *)
89 MSG_CTRUNC* = {5}; (* control data lost before delivery *)
90 MSG_WAITALL* = {6}; (* wait for full request or error *)
91 MSG_DONTWAIT* = {7}; (* this message should be nonblocking *)
92 MSG_BCAST* = {8}; (* this message rec'd as broadcast *)
93 MSG_MCAST* = {9}; (* this message rec'd as multicast *)
94 MSG_NOSIGNAL* = {10}; (* do not send SIGPIPE *)
96 (* /usr/include/netinet/in.h *)
97 INADDR_NONE* = -1;
98 IPPROTO_IP* = 0; (* dummy for IP *)
99 IPPROTO_HOPOPTS* = IPPROTO_IP; (* Hop-by-hop option header *)
100 IPPROTO_ICMP* = 1; (* control message protocol *)
101 IPPROTO_IGMP* = 2; (* group mgmt protocol *)
102 IPPROTO_GGP* = 3; (* gateway^2 (deprecated) *)
103 IPPROTO_IPIP* = 4; (* IP inside IP *)
104 IPPROTO_IPV4* = IPPROTO_IPIP; (* IP inside IP *)
105 IPPROTO_TCP* = 6; (* tcp *)
106 IPPROTO_EGP* = 8; (* exterior gateway protocol *)
107 IPPROTO_PUP* = 12; (* pup *)
108 IPPROTO_UDP* = 17; (* user datagram protocol *)
109 IPPROTO_IDP* = 22; (* xns idp *)
110 IPPROTO_TP* = 29; (* tp-4 w/ class negotiation *)
111 IPPROTO_IPV6* = 41; (* IPv6 in IPv6 *)
112 IPPROTO_ROUTING* = 43; (* Routing header *)
113 IPPROTO_FRAGMENT* = 44; (* Fragmentation/reassembly header *)
114 IPPROTO_RSVP* = 46; (* resource reservation *)
115 IPPROTO_GRE* = 47; (* GRE encap, RFCs 1701/1702 *)
116 IPPROTO_ESP* = 50; (* Encap. Security Payload *)
117 IPPROTO_AH* = 51; (* Authentication header *)
118 IPPROTO_MOBILE* = 55; (* IP Mobility, RFC 2004 *)
119 IPPROTO_ICMPV6* = 58; (* ICMP for IPv6 *)
120 IPPROTO_NONE* = 59; (* No next header *)
121 IPPROTO_DSTOPTS* = 60; (* Destination options header *)
122 IPPROTO_EON* = 80; (* ISO cnlp *)
123 IPPROTO_ETHERIP* = 97; (* Ethernet in IPv4 *)
124 IPPROTO_ENCAP* = 98; (* encapsulation header *)
125 IPPROTO_PIM* = 103; (* Protocol indep. multicast *)
126 IPPROTO_IPCOMP* = 108; (* IP Payload Comp. Protocol *)
127 IPPROTO_CARP* = 112; (* CARP *)
128 IPPROTO_MPLS* = 137; (* unicast MPLS packet *)
129 IPPROTO_PFSYNC* = 240; (* PFSYNC *)
130 IPPROTO_RAW* = 255; (* raw IP packet *)
131 IPPROTO_MAX* = 256;
132 IPPROTO_DIVERT* = 258; (* Divert sockets *)
133 IPPROTO_DONE* = 257;
135 (* /usr/include/sys/param.h *)
136 MAXHOSTNAMELEN* = 256; (* max hostname size *)
138 (* /usr/include/netdb.h *)
139 NETDB_INTERNAL* = -1; (* see errno *)
140 NETDB_SUCCESS* = 0; (* no problem *)
141 HOST_NOT_FOUND* = 1; (* Authoritative Answer Host not found *)
142 TRY_AGAIN* = 2; (* Non-Authoritative Host not found, or SERVERFAIL *)
143 NO_RECOVERY* = 3; (* Non recoverable errors, FORMERR, REFUSED, NOTIMP *)
144 NO_DATA* = 4; (* Valid name, no data record of requested type *)
145 NO_ADDRESS* = NO_DATA; (* no address *)
146 NI_MAXHOST* = MAXHOSTNAMELEN; (* max host name returned by getnameinfo *)
147 NI_MAXSERV* = 32; (* max serv. name length returned by getnameinfo *)
148 RRSET_VALIDATED* = 1;
149 ERRSET_SUCCESS* = 0;
150 ERRSET_NOMEMORY* = 1;
151 ERRSET_FAIL* = 2;
152 ERRSET_INVAL* = 3;
153 ERRSET_NONAME* = 4;
154 ERRSET_NODATA* = 5;
156 (* /usr/include/sys/select.h *)
157 FD_SETSIZE = 1024;
158 __NBBY = 8;
160 TYPE
161 SOCKET* = INTEGER;
163 (* /usr/include/sys/_types.h *)
164 socklen_t* = INTEGER;
165 sa_family_t* = SHORTCHAR;
166 in_addr_t* = INTEGER;
167 in_port_t* = SHORTINT;
169 (* /usr/include/sys/socket.h *)
170 sockaddr* = RECORD [untagged]
171 sa_len*: SHORTCHAR; (* total length *)
172 sa_family*: sa_family_t; (* address family *)
173 sa_data*: ARRAY [untagged] 14 OF SHORTCHAR; (* actually longer; address value *)
174 END;
175 sockaddr_storage* = RECORD [untagged]
176 ss_len*: SHORTCHAR; (* total length *)
177 ss_family*: sa_family_t; (* address family *)
178 __ss_pad1: ARRAY [untagged] 6 OF SHORTCHAR; (* align to quad *)
179 __ss_pad2: LONGINT; (* force alignment for stupid compilers *)
180 __ss_pad3: ARRAY [untagged] 240 OF SHORTCHAR; (* pad to a total of 256 bytes *)
181 END;
183 (* /usr/include/netinet/in.h *)
184 (*
185 in_addr* = RECORD [untagged]
186 s_addr*: in_addr_t;
187 END;
188 *)
189 in_addr* = RECORD [untagged]
190 S_un*: RECORD [union]
191 S_un_b*: RECORD [untagged]
192 s_b1*: SHORTCHAR;
193 s_b2*: SHORTCHAR;
194 s_b3*: SHORTCHAR;
195 s_b4*: SHORTCHAR;
196 END;
197 S_un_w*: RECORD [untagged]
198 s_w1*: SHORTINT;
199 s_w2*: SHORTINT;
200 END;
201 S_addr*: in_addr_t;
202 END;
203 END;
205 sockaddr_in* = RECORD [untagged]
206 sin_len*: SHORTCHAR;
207 sin_family*: sa_family_t;
208 sin_port*: in_port_t;
209 sin_addr*: in_addr;
210 sin_zero*: ARRAY [untagged] 8 OF SHORTCHAR;
211 END;
213 (* /usr/include/netdb.h *)
214 Ptrhostent* = POINTER TO hostent;
215 hostent* = RECORD [untagged]
216 h_name*: Libc.PtrSTR; (* official name of host *)
217 h_aliases*: POINTER TO ARRAY [untagged] OF Libc.PtrSTR; (* alias list *)
218 h_addrtype*: INTEGER; (* host address type *)
219 h_length*: INTEGER; (* length of address *)
220 h_addr_list*: POINTER TO ARRAY [untagged] OF POINTER TO ARRAY [untagged] OF in_addr; (* list of addresses from name server *)
221 END;
223 (* /usr/include/sys/time.h *)
224 timeval* = RECORD [untagged]
225 tv_sec*: INTEGER; (* seconds *)
226 tv_usec*: INTEGER; (* and microseconds *)
227 END;
229 (* /usr/include/sys/select.h *)
230 __fd_mask = SET;
231 fd_set* = ARRAY [untagged] (FD_SETSIZE + (SIZE(__fd_mask) * __NBBY - 1)) DIV (SIZE(__fd_mask) * __NBBY) OF __fd_mask;
233 VAR
234 h_errno*: INTEGER;
236 PROCEDURE [ccall] socket* (domain: INTEGER; type: INTEGER; protocol: INTEGER): SOCKET;
237 PROCEDURE [ccall] accept* (s: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): SOCKET;
238 PROCEDURE [ccall] bind* (s: SOCKET; VAR name: sockaddr; namelen: socklen_t): INTEGER;
239 PROCEDURE [ccall] connect* (s: SOCKET; VAR name: sockaddr; namelen: socklen_t): INTEGER;
240 PROCEDURE [ccall] listen* (s: SOCKET; backlog: INTEGER): INTEGER;
241 PROCEDURE [ccall] recv* (s: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
242 PROCEDURE [ccall] send* (s: SOCKET; msg: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
243 PROCEDURE [ccall] shutdown* (s: SOCKET; how: INTEGER): INTEGER;
244 PROCEDURE [ccall] getsockopt* (s: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; VAR optlen: socklen_t): INTEGER;
245 PROCEDURE [ccall] setsockopt* (s: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; optlen: socklen_t): INTEGER;
247 PROCEDURE [ccall] htons* (host16: SHORTINT): SHORTINT;
249 PROCEDURE [ccall] gethostbyname* (name: Libc.PtrSTR): Ptrhostent;
250 PROCEDURE [ccall] inet_addr* (cp: Libc.PtrSTR): in_addr_t;
252 PROCEDURE [ccall] getsockname* (s: SOCKET; VAR name: sockaddr; VAR namelen: socklen_t): INTEGER;
254 PROCEDURE [ccall] hstrerror* (err: INTEGER): Libc.PtrSTR;
256 (*
257 PROCEDURE FD_ZERO (VAR set: Net.fd_set);
258 VAR i: INTEGER;
259 BEGIN
260 i := LEN(set); REPEAT DEC(i); set[i] := {} UNTIL i = 0
261 END FD_ZERO;
263 PROCEDURE FD_SET (fd: Net.SOCKET; VAR set: Net.fd_set);
264 BEGIN
265 INCL(set[fd DIV 32], fd MOD 32)
266 END FD_SET;
267 *)
269 PROCEDURE [ccall] select* (nfds: INTEGER; VAR [nil] readfds: fd_set; VAR [nil] writefds: fd_set; VAR [nil] exceptfds: fd_set; VAR timeout: timeval): INTEGER;
271 END LinNet.