DEADSOFTWARE

old -> new
[bbcp.git] / ubuntu / Lin / Mod / Net.txt
1 MODULE LinNet ["libc.so.6"];
3 (*
4 A. V. Shiryaev, 2012.11
6 GNU/Linux
7 32-bit
8 *)
10 IMPORT Libc := LinLibc;
12 CONST
13 INVALID_SOCKET* = -1;
14 SOCKET_ERROR* = -1;
16 (* /usr/include/i386-linux-gnu/bits/socket.h *)
17 SHUT_RD* = 0;
18 SHUT_WR* = 1;
19 SHUT_RDWR* = 2;
20 SOCK_STREAM* = 1;
21 SOCK_DGRAM* = 2;
22 SOCK_RAW* = 3;
23 SOCK_RDM* = 4;
24 SOCK_SEQPACKET* = 5;
25 SOCK_DCCP* = 6;
26 SOCK_PACKET* = 10;
28 PF_UNSPEC* = 0; (* Unspecified. *)
29 PF_LOCAL* = 1; (* Local to host (pipes and file-domain). *)
30 PF_UNIX* = PF_LOCAL; (* POSIX name for PF_LOCAL. *)
31 PF_FILE* = PF_LOCAL; (* Another non-standard name for PF_LOCAL. *)
32 PF_INET* = 2; (* IP protocol family. *)
33 PF_AX25* = 3; (* Amateur Radio AX.25. *)
34 PF_IPX* = 4; (* Novell Internet Protocol. *)
35 PF_APPLETALK* = 5; (* Appletalk DDP. *)
36 PF_NETROM* = 6; (* Amateur radio NetROM. *)
37 PF_BRIDGE* = 7; (* Multiprotocol bridge. *)
38 PF_ATMPVC* = 8; (* ATM PVCs. *)
39 PF_X25* = 9; (* Reserved for X.25 project. *)
40 PF_INET6* = 10; (* IP version 6. *)
41 PF_ROSE* = 11; (* Amateur Radio X.25 PLP. *)
42 PF_DECnet* = 12; (* Reserved for DECnet project. *)
43 PF_NETBEUI* = 13; (* Reserved for 802.2LLC project. *)
44 PF_SECURITY* = 14; (* Security callback pseudo AF. *)
45 PF_KEY* = 15; (* PF_KEY key management API. *)
46 PF_NETLINK* = 16;
47 PF_ROUTE* = PF_NETLINK; (* Alias to emulate 4.4BSD. *)
48 PF_PACKET* = 17; (* Packet family. *)
49 PF_ASH* = 18; (* Ash. *)
50 PF_ECONET* = 19; (* Acorn Econet. *)
51 PF_ATMSVC* = 20; (* ATM SVCs. *)
52 PF_RDS* = 21; (* RDS sockets. *)
53 PF_SNA* = 22; (* Linux SNA Project *)
54 PF_IRDA* = 23; (* IRDA sockets. *)
55 PF_PPPOX* = 24; (* PPPoX sockets. *)
56 PF_WANPIPE* = 25; (* Wanpipe API sockets. *)
57 PF_LLC* = 26; (* Linux LLC. *)
58 PF_CAN* = 29; (* Controller Area Network. *)
59 PF_TIPC* = 30; (* TIPC sockets. *)
60 PF_BLUETOOTH* = 31; (* Bluetooth sockets. *)
61 PF_IUCV* = 32; (* IUCV sockets. *)
62 PF_RXRPC* = 33; (* RxRPC sockets. *)
63 PF_ISDN* = 34; (* mISDN sockets. *)
64 PF_PHONET* = 35; (* Phonet sockets. *)
65 PF_IEEE802154* = 36; (* IEEE 802.15.4 sockets. *)
66 PF_CAIF* = 37; (* CAIF sockets. *)
67 PF_ALG* = 38; (* Algorithm sockets. *)
68 PF_NFC* = 39; (* NFC sockets. *)
69 PF_MAX* = 40; (* For now.. *)
70 SOMAXCONN* = 128;
72 (* /usr/include/asm-generic/socket.h *)
73 SO_DEBUG* = {0};
74 SO_REUSEADDR* = {1};
75 SO_TYPE* = {0,1};
76 SO_ERROR* = {2};
77 SO_DONTROUTE* = {0,2};
78 SO_BROADCAST* = {1,2};
79 SO_SNDBUF* = {0..2};
80 SO_RCVBUF* = {3};
81 SO_SNDBUFFORCE* = {5};
82 SO_RCVBUFFORCE* = {0,5};
83 SO_KEEPALIVE* = {0,3};
84 SO_OOBINLINE* = {1,3};
85 SO_NO_CHECK* = {0,1,3};
86 SO_PRIORITY* = {2,3};
87 SO_LINGER* = {0,2,3};
88 SO_BSDCOMPAT* = {1..3};
89 SO_SECURITY_AUTHENTICATION* = {1,2,4};
90 SO_SECURITY_ENCRYPTION_TRANSPORT* = {0..2,4};
91 SO_SECURITY_ENCRYPTION_NETWORK* = {3,4};
92 SO_BINDTODEVICE* = {0,3,4};
93 SO_ATTACH_FILTER* = {1,3,4};
94 SO_DETACH_FILTER* = {0,1,3,4};
95 SO_PEERNAME* = {2..4};
96 SO_TIMESTAMP* = {0,2..4};
97 SO_ACCEPTCONN* = {1..4};
98 SO_PEERSEC* = {0..4};
99 SO_PASSSEC* = {1,5};
100 SO_TIMESTAMPNS* = {0,1,5};
101 SO_MARK* = {2,5};
102 SO_TIMESTAMPING* = {0,2,5};
103 SO_PROTOCOL* = {1,2,5};
104 SO_DOMAIN* = {0..2,5};
105 SO_RXQ_OVFL* = {3,5};
107 (* /usr/include/netinet/in.h *)
108 INADDR_NONE* = -1;
109 IPPROTO_IP = 0; (* Dummy protocol for TCP. *)
110 IPPROTO_HOPOPTS* = 0; (* IPv6 Hop-by-Hop options. *)
111 IPPROTO_ICMP* = 1; (* Internet Control Message Protocol. *)
112 IPPROTO_IGMP* = 2; (* Internet Group Management Protocol. *)
113 IPPROTO_IPIP* = 4; (* IPIP tunnels (older KA9Q tunnels use 94). *)
114 IPPROTO_TCP* = 6; (* Transmission Control Protocol. *)
115 IPPROTO_EGP* = 8; (* Exterior Gateway Protocol. *)
116 IPPROTO_PUP* = 12; (* PUP protocol. *)
117 IPPROTO_UDP* = 17; (* User Datagram Protocol. *)
118 IPPROTO_IDP* = 22; (* XNS IDP protocol. *)
119 IPPROTO_TP* = 29; (* SO Transport Protocol Class 4. *)
120 IPPROTO_DCCP* = 33; (* Datagram Congestion Control Protocol. *)
121 IPPROTO_IPV6* = 41; (* IPv6 header. *)
122 IPPROTO_ROUTING* = 43; (* IPv6 routing header. *)
123 IPPROTO_FRAGMENT* = 44; (* IPv6 fragmentation header. *)
124 IPPROTO_RSVP* = 46; (* Reservation Protocol. *)
125 IPPROTO_GRE* = 47; (* General Routing Encapsulation. *)
126 IPPROTO_ESP* = 50; (* encapsulating security payload. *)
127 IPPROTO_AH* = 51; (* authentication header. *)
128 IPPROTO_ICMPV6* = 58; (* ICMPv6. *)
129 IPPROTO_NONE* = 59; (* IPv6 no next header. *)
130 IPPROTO_DSTOPTS* = 60; (* IPv6 destination options. *)
131 IPPROTO_MTP* = 92; (* Multicast Transport Protocol. *)
132 IPPROTO_ENCAP* = 98; (* Encapsulation Header. *)
133 IPPROTO_PIM* = 103; (* Protocol Independent Multicast. *)
134 IPPROTO_COMP* = 108; (* Compression Header Protocol. *)
135 IPPROTO_SCTP* = 132; (* Stream Control Transmission Protocol. *)
136 IPPROTO_UDPLITE* = 136; (* UDP-Lite protocol. *)
137 IPPROTO_RAW* = 255; (* Raw IP packets. *)
139 (* /usr/include/asm-generic/param.h *)
140 MAXHOSTNAMELEN* = 64; (* max length of hostname *)
142 (* /usr/include/netdb.h *)
143 NETDB_INTERNAL* = -1; (* See errno. *)
144 NETDB_SUCCESS* = 0; (* No problem. *)
145 HOST_NOT_FOUND* = 1; (* Authoritative Answer Host not found. *)
146 TRY_AGAIN* = 2; (* Non-Authoritative Host not found, or SERVERFAIL. *)
147 NO_RECOVERY* = 3; (* Non recoverable errors, FORMERR, REFUSED, NOTIMP. *)
148 NO_DATA* = 4; (* Valid name, no data record of requested type. *)
150 (* /usr/include/i386-linux-gnu/bits/typesizes.h *)
151 __FD_SETSIZE = 1024;
153 TYPE
154 SOCKET* = INTEGER;
156 (* /usr/include/i386-linux-gnu/bits/types.h *)
157 socklen_t* = INTEGER;
158 (* /usr/include/i386-linux-gnu/bits/sockaddr.h *)
159 sa_family_t* = SHORTINT; (* unsigned short int *)
160 (* /usr/include/netinet/in.h *)
161 in_addr_t* = INTEGER;
162 in_port_t* = SHORTINT;
164 (* /usr/include/i386-linux-gnu/bits/socket.h *)
165 sockaddr* = RECORD [untagged]
166 sa_family: sa_family_t;
167 sa_data: ARRAY [untagged] 14 OF SHORTCHAR;
168 END;
170 (* /usr/include/linux/in.h *)
171 (*
172 in_addr* = INTEGER;
173 *)
174 in_addr* = RECORD [untagged]
175 S_un*: RECORD [union]
176 S_un_b*: RECORD [untagged]
177 s_b1*: SHORTCHAR;
178 s_b2*: SHORTCHAR;
179 s_b3*: SHORTCHAR;
180 s_b4*: SHORTCHAR;
181 END;
182 S_un_w*: RECORD [untagged]
183 s_w1*: SHORTINT;
184 s_w2*: SHORTINT;
185 END;
186 S_addr*: in_addr_t;
187 END;
188 END;
190 (* /usr/include/linux/in.h *)
191 sockaddr_in* = RECORD [untagged]
192 sin_family*: sa_family_t; (* address family *)
193 sin_port*: SHORTINT; (* port number *)
194 sin_addr*: in_addr; (* internet address *)
195 __pad: ARRAY [untagged] 8 OF SHORTCHAR;
196 END;
198 (* /usr/include/netdb.h *)
199 Ptrhostent* = POINTER TO hostent;
200 hostent* = RECORD [untagged]
201 h_name*: Libc.PtrSTR; (* official name of host *)
202 h_aliases*: POINTER TO ARRAY [untagged] OF Libc.PtrSTR; (* alias list *)
203 h_addrtype*: INTEGER; (* host address type *)
204 h_length*: INTEGER; (* length of address *)
205 h_addr_list*: POINTER TO ARRAY [untagged] OF POINTER TO ARRAY [untagged] OF in_addr; (* list of addresses from name server *)
206 END;
208 (* /usr/include/linux/time.h *)
209 (* /usr/include/asm-generic/posix_types.h *)
210 timeval* = RECORD [untagged]
211 tv_sec*: INTEGER; (* seconds *)
212 tv_usec*: INTEGER; (* microseconds *)
213 END;
215 (* /usr/include/i386-linux-gnu/sys/select.h *)
216 __fd_mask = SET;
217 fd_set* = ARRAY [untagged] __FD_SETSIZE DIV (SIZE(__fd_mask) * 8) OF __fd_mask;
219 VAR
220 h_errno*: INTEGER;
222 PROCEDURE [ccall] socket* (domain: INTEGER; type: INTEGER; protocol: INTEGER): SOCKET;
223 PROCEDURE [ccall] accept* (sockfd: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): SOCKET;
224 PROCEDURE [ccall] bind* (sockfd: SOCKET; VAR addr: sockaddr; addrlen: socklen_t): INTEGER;
225 PROCEDURE [ccall] connect* (sockfd: SOCKET; VAR addr: sockaddr; addrlen: socklen_t): INTEGER;
226 PROCEDURE [ccall] listen* (sockfd: SOCKET; backlog: INTEGER): INTEGER;
227 PROCEDURE [ccall] recv* (soskfd: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
228 PROCEDURE [ccall] send* (sockfd: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
229 PROCEDURE [ccall] shutdown* (sockfd: SOCKET; how: INTEGER): INTEGER;
230 PROCEDURE [ccall] getsockopt* (sockfd: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; VAR optlen: socklen_t): INTEGER;
231 PROCEDURE [ccall] setsockopt* (sockfd: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; optlen: socklen_t): INTEGER;
233 PROCEDURE [ccall] htons* (hostshort: SHORTINT): SHORTINT;
235 PROCEDURE [ccall] gethostbyname* (name: Libc.PtrSTR): Ptrhostent;
236 PROCEDURE [ccall] inet_addr* (cp: Libc.PtrSTR): in_addr_t;
238 PROCEDURE [ccall] getsockname* (sockfd: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): INTEGER;
240 PROCEDURE [ccall] hstrerror* (err: INTEGER): Libc.PtrSTR;
242 (*
243 PROCEDURE FD_ZERO (VAR set: Net.fd_set);
244 VAR i: INTEGER;
245 BEGIN
246 i := LEN(set); REPEAT DEC(i); set[i] := {} UNTIL i = 0
247 END FD_ZERO;
249 PROCEDURE FD_SET (fd: Net.SOCKET; VAR set: Net.fd_set);
250 BEGIN
251 INCL(set[fd DIV 32], fd MOD 32)
252 END FD_SET;
253 *)
255 PROCEDURE [ccall] select* (nfds: INTEGER; VAR [nil] readfds: fd_set; VAR [nil] writefds: fd_set; VAR [nil] exceptfds: fd_set; VAR timeout: timeval): INTEGER;
257 END LinNet.