DEADSOFTWARE

Linux CommTCP implementation added
authorAlexander Shiryaev <aixp@mail.ru>
Wed, 14 Nov 2012 23:46:04 +0000 (03:46 +0400)
committerAlexander Shiryaev <aixp@mail.ru>
Wed, 14 Nov 2012 23:46:04 +0000 (03:46 +0400)
14 files changed:
Trurl-based/_Linux_/Comm/Mod/TCP.odc [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/Net.txt [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/gen-Net/Makefile [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/gen-Net/Net.txt.templ [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-in [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-netdb [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-sock [new file with mode: 0644]
Trurl-based/_Linux_/Lin/Mod/gen-Net/dumpdefs.py [new symlink]
Trurl-based/_Linux_/Lin/Mod/gen-Net/dumphstrerrno.c [new symlink]
Trurl-based/_Linux_/Lin/Mod/gen-Net/untempl.py [new symlink]
Trurl-based/_OpenBSD_/Comm/Mod/TCP.odc
Trurl-based/_OpenBSD_/Lin/Mod/Net.txt
Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/dumpdefs.py
Trurl-based/_OpenBSD_/Lin/Mod/gen-Net/Net.txt.templ

diff --git a/Trurl-based/_Linux_/Comm/Mod/TCP.odc b/Trurl-based/_Linux_/Comm/Mod/TCP.odc
new file mode 100644 (file)
index 0000000..770b445
Binary files /dev/null and b/Trurl-based/_Linux_/Comm/Mod/TCP.odc differ
diff --git a/Trurl-based/_Linux_/Lin/Mod/Net.txt b/Trurl-based/_Linux_/Lin/Mod/Net.txt
new file mode 100644 (file)
index 0000000..5636fe7
--- /dev/null
@@ -0,0 +1,258 @@
+MODULE LinNet ["libc.so.6"];
+
+       (*
+               A. V. Shiryaev, 2012.11
+
+               GNU/Linux
+               32-bit
+       *)
+
+       IMPORT Libc := LinLibc;
+
+       CONST
+               INVALID_SOCKET* = -1;
+               SOCKET_ERROR* = -1;
+
+               (* /usr/include/i386-linux-gnu/bits/socket.h *)
+                       SHUT_RD* = 0;
+                       SHUT_WR* = 1;
+                       SHUT_RDWR* = 2;
+                       SOCK_STREAM* = 1;
+                       SOCK_DGRAM* = 2;
+                       SOCK_RAW* = 3;
+                       SOCK_RDM* = 4;
+                       SOCK_SEQPACKET* = 5;
+                       SOCK_DCCP* = 6;
+                       SOCK_PACKET* = 10;
+
+                       PF_UNSPEC* = 0; (* Unspecified. *)
+                       PF_LOCAL* = 1; (* Local to host (pipes and file-domain). *)
+                       PF_UNIX* = PF_LOCAL; (* POSIX name for PF_LOCAL. *)
+                       PF_FILE* = PF_LOCAL; (* Another non-standard name for PF_LOCAL. *)
+                       PF_INET* = 2; (* IP protocol family. *)
+                       PF_AX25* = 3; (* Amateur Radio AX.25. *)
+                       PF_IPX* = 4; (* Novell Internet Protocol. *)
+                       PF_APPLETALK* = 5; (* Appletalk DDP. *)
+                       PF_NETROM* = 6; (* Amateur radio NetROM. *)
+                       PF_BRIDGE* = 7; (* Multiprotocol bridge. *)
+                       PF_ATMPVC* = 8; (* ATM PVCs. *)
+                       PF_X25* = 9; (* Reserved for X.25 project. *)
+                       PF_INET6* = 10; (* IP version 6. *)
+                       PF_ROSE* = 11; (* Amateur Radio X.25 PLP. *)
+                       PF_DECnet* = 12; (* Reserved for DECnet project. *)
+                       PF_NETBEUI* = 13; (* Reserved for 802.2LLC project. *)
+                       PF_SECURITY* = 14; (* Security callback pseudo AF. *)
+                       PF_KEY* = 15; (* PF_KEY key management API. *)
+                       PF_NETLINK* = 16;
+                       PF_ROUTE* = PF_NETLINK; (* Alias to emulate 4.4BSD. *)
+                       PF_PACKET* = 17; (* Packet family. *)
+                       PF_ASH* = 18; (* Ash. *)
+                       PF_ECONET* = 19; (* Acorn Econet. *)
+                       PF_ATMSVC* = 20; (* ATM SVCs. *)
+                       PF_RDS* = 21; (* RDS sockets. *)
+                       PF_SNA* = 22; (* Linux SNA Project *)
+                       PF_IRDA* = 23; (* IRDA sockets. *)
+                       PF_PPPOX* = 24; (* PPPoX sockets. *)
+                       PF_WANPIPE* = 25; (* Wanpipe API sockets. *)
+                       PF_LLC* = 26; (* Linux LLC. *)
+                       PF_CAN* = 29; (* Controller Area Network. *)
+                       PF_TIPC* = 30; (* TIPC sockets. *)
+                       PF_BLUETOOTH* = 31; (* Bluetooth sockets. *)
+                       PF_IUCV* = 32; (* IUCV sockets. *)
+                       PF_RXRPC* = 33; (* RxRPC sockets. *)
+                       PF_ISDN* = 34; (* mISDN sockets. *)
+                       PF_PHONET* = 35; (* Phonet sockets. *)
+                       PF_IEEE802154* = 36; (* IEEE 802.15.4 sockets. *)
+                       PF_CAIF* = 37; (* CAIF sockets. *)
+                       PF_ALG* = 38; (* Algorithm sockets. *)
+                       PF_NFC* = 39; (* NFC sockets. *)
+                       PF_MAX* = 40; (* For now.. *)
+                       SOMAXCONN* = 128;
+
+               (* /usr/include/asm-generic/socket.h *)
+                       SO_DEBUG* = {0};
+                       SO_REUSEADDR* = {1};
+                       SO_TYPE* = {0,1};
+                       SO_ERROR* = {2};
+                       SO_DONTROUTE* = {0,2};
+                       SO_BROADCAST* = {1,2};
+                       SO_SNDBUF* = {0..2};
+                       SO_RCVBUF* = {3};
+                       SO_SNDBUFFORCE* = {5};
+                       SO_RCVBUFFORCE* = {0,5};
+                       SO_KEEPALIVE* = {0,3};
+                       SO_OOBINLINE* = {1,3};
+                       SO_NO_CHECK* = {0,1,3};
+                       SO_PRIORITY* = {2,3};
+                       SO_LINGER* = {0,2,3};
+                       SO_BSDCOMPAT* = {1..3};
+                       SO_SECURITY_AUTHENTICATION* = {1,2,4};
+                       SO_SECURITY_ENCRYPTION_TRANSPORT* = {0..2,4};
+                       SO_SECURITY_ENCRYPTION_NETWORK* = {3,4};
+                       SO_BINDTODEVICE* = {0,3,4};
+                       SO_ATTACH_FILTER* = {1,3,4};
+                       SO_DETACH_FILTER* = {0,1,3,4};
+                       SO_PEERNAME* = {2..4};
+                       SO_TIMESTAMP* = {0,2..4};
+                       SO_ACCEPTCONN* = {1..4};
+                       SO_PEERSEC* = {0..4};
+                       SO_PASSSEC* = {1,5};
+                       SO_TIMESTAMPNS* = {0,1,5};
+                       SO_MARK* = {2,5};
+                       SO_TIMESTAMPING* = {0,2,5};
+                       SO_PROTOCOL* = {1,2,5};
+                       SO_DOMAIN* = {0..2,5};
+                       SO_RXQ_OVFL* = {3,5};
+
+               (* /usr/include/netinet/in.h *)
+                       INADDR_NONE* = -1;
+                       IPPROTO_IP = 0; (* Dummy protocol for TCP. *)
+                       IPPROTO_HOPOPTS* = 0; (* IPv6 Hop-by-Hop options. *)
+                       IPPROTO_ICMP* = 1; (* Internet Control Message Protocol. *)
+                       IPPROTO_IGMP* = 2; (* Internet Group Management Protocol. *)
+                       IPPROTO_IPIP* = 4; (* IPIP tunnels (older KA9Q tunnels use 94). *)
+                       IPPROTO_TCP* = 6; (* Transmission Control Protocol. *)
+                       IPPROTO_EGP* = 8; (* Exterior Gateway Protocol. *)
+                       IPPROTO_PUP* = 12; (* PUP protocol. *)
+                       IPPROTO_UDP* = 17; (* User Datagram Protocol. *)
+                       IPPROTO_IDP* = 22; (* XNS IDP protocol. *)
+                       IPPROTO_TP* = 29; (* SO Transport Protocol Class 4. *)
+                       IPPROTO_DCCP* = 33; (* Datagram Congestion Control Protocol. *)
+                       IPPROTO_IPV6* = 41; (* IPv6 header. *)
+                       IPPROTO_ROUTING* = 43; (* IPv6 routing header. *)
+                       IPPROTO_FRAGMENT* = 44; (* IPv6 fragmentation header. *)
+                       IPPROTO_RSVP* = 46; (* Reservation Protocol. *)
+                       IPPROTO_GRE* = 47; (* General Routing Encapsulation. *)
+                       IPPROTO_ESP* = 50; (* encapsulating security payload. *)
+                       IPPROTO_AH* = 51; (* authentication header. *)
+                       IPPROTO_ICMPV6* = 58; (* ICMPv6. *)
+                       IPPROTO_NONE* = 59; (* IPv6 no next header. *)
+                       IPPROTO_DSTOPTS* = 60; (* IPv6 destination options. *)
+                       IPPROTO_MTP* = 92; (* Multicast Transport Protocol. *)
+                       IPPROTO_ENCAP* = 98; (* Encapsulation Header. *)
+                       IPPROTO_PIM* = 103; (* Protocol Independent Multicast. *)
+                       IPPROTO_COMP* = 108; (* Compression Header Protocol. *)
+                       IPPROTO_SCTP* = 132; (* Stream Control Transmission Protocol. *)
+                       IPPROTO_UDPLITE* = 136; (* UDP-Lite protocol. *)
+                       IPPROTO_RAW* = 255; (* Raw IP packets. *)
+
+               (* /usr/include/asm-generic/param.h *)
+                       MAXHOSTNAMELEN* = 64; (* max length of hostname *)
+
+               (* /usr/include/netdb.h *)
+                       NETDB_INTERNAL* = -1; (* See errno. *)
+                       NETDB_SUCCESS* = 0; (* No problem. *)
+                       HOST_NOT_FOUND* = 1; (* Authoritative Answer Host not found. *)
+                       TRY_AGAIN* = 2; (* Non-Authoritative Host not found, or SERVERFAIL. *)
+                       NO_RECOVERY* = 3; (* Non recoverable errors, FORMERR, REFUSED, NOTIMP. *)
+                       NO_DATA* = 4; (* Valid name, no data record of requested type. *)
+
+               (* /usr/include/i386-linux-gnu/bits/typesizes.h *)
+                       __FD_SETSIZE = 1024;
+                       __NFDBITS = SIZE(SET) * 8;
+
+       TYPE
+               SOCKET* = INTEGER;
+
+               (* /usr/include/i386-linux-gnu/bits/types.h *)
+                       socklen_t* = INTEGER;
+               (* /usr/include/i386-linux-gnu/bits/sockaddr.h *)
+                       sa_family_t* = SHORTINT; (* unsigned short int *)
+               (* /usr/include/netinet/in.h *)
+                       in_addr_t* = INTEGER;
+                       in_port_t* = SHORTINT;
+
+               (* /usr/include/i386-linux-gnu/bits/socket.h *)
+                       sockaddr* = RECORD [untagged]
+                               sa_family: sa_family_t;
+                               sa_data: ARRAY [untagged] 14 OF SHORTCHAR;
+                       END;
+
+               (* /usr/include/linux/in.h *)
+(*
+                       in_addr* = INTEGER;
+*)
+                       in_addr* = RECORD [untagged]
+                               S_un*: RECORD [union]
+                                       S_un_b*: RECORD [untagged]
+                                               s_b1*: SHORTCHAR;
+                                               s_b2*: SHORTCHAR;
+                                               s_b3*: SHORTCHAR;
+                                               s_b4*: SHORTCHAR;
+                                       END;
+                                       S_un_w*: RECORD [untagged]
+                                               s_w1*: SHORTINT;
+                                               s_w2*: SHORTINT;
+                                       END;
+                                       S_addr*: in_addr_t;
+                               END;
+                       END;
+
+               (* /usr/include/linux/in.h *)
+                       sockaddr_in* = RECORD [untagged]
+                               sin_family*: sa_family_t; (* address family *)
+                               sin_port*: SHORTINT; (* port number *)
+                               sin_addr*: in_addr; (* internet address *)
+                               __pad: ARRAY [untagged] 8 OF SHORTCHAR;
+                       END;
+
+               (* /usr/include/netdb.h *)
+                       Ptrhostent* = POINTER TO hostent;
+                       hostent* = RECORD [untagged]
+                               h_name*: Libc.PtrSTR; (* official name of host *)
+                               h_aliases*: POINTER TO ARRAY [untagged] OF Libc.PtrSTR; (* alias list *)
+                               h_addrtype*: INTEGER; (* host address type *)
+                               h_length*: INTEGER; (* length of address *)
+                               h_addr_list*: POINTER TO ARRAY [untagged] OF POINTER TO ARRAY [untagged] OF in_addr; (* list of addresses from name server *)
+                       END;
+
+               (* /usr/include/linux/time.h *)
+               (* /usr/include/asm-generic/posix_types.h *)
+                       timeval* = RECORD [untagged]
+                               tv_sec*: INTEGER; (* seconds *)
+                               tv_usec*: INTEGER; (* microseconds *)
+                       END;
+
+               (* /usr/include/i386-linux-gnu/sys/select.h *)
+                       __fd_mask = SET;
+                       fd_set* = ARRAY [untagged] __FD_SETSIZE DIV __NFDBITS OF __fd_mask;
+
+       VAR
+               h_errno*: INTEGER;
+
+       PROCEDURE [ccall] socket* (domain: INTEGER; type: INTEGER; protocol: INTEGER): SOCKET;
+       PROCEDURE [ccall] accept* (sockfd: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): SOCKET;
+       PROCEDURE [ccall] bind* (sockfd: SOCKET; VAR addr: sockaddr; addrlen: socklen_t): INTEGER;
+       PROCEDURE [ccall] connect* (sockfd: SOCKET; VAR addr: sockaddr; addrlen: socklen_t): INTEGER;
+       PROCEDURE [ccall] listen* (sockfd: SOCKET; backlog: INTEGER): INTEGER;
+       PROCEDURE [ccall] recv* (soskfd: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
+       PROCEDURE [ccall] send* (sockfd: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
+       PROCEDURE [ccall] shutdown* (sockfd: SOCKET; how: INTEGER): INTEGER;
+       PROCEDURE [ccall] getsockopt* (sockfd: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; VAR optlen: socklen_t): INTEGER;
+       PROCEDURE [ccall] setsockopt* (sockfd: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; optlen: socklen_t): INTEGER;
+
+       PROCEDURE [ccall] htons* (hostshort: SHORTINT): SHORTINT;
+
+       PROCEDURE [ccall] gethostbyname* (name: Libc.PtrSTR): Ptrhostent;
+       PROCEDURE [ccall] inet_addr* (cp: Libc.PtrSTR): in_addr_t;
+
+       PROCEDURE [ccall] getsockname* (sockfd: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): INTEGER;
+
+       PROCEDURE [ccall] hstrerror* (err: INTEGER): Libc.PtrSTR;
+
+(*
+       PROCEDURE FD_ZERO (VAR set: Net.fd_set);
+               VAR i: INTEGER;
+       BEGIN
+               i := 0; WHILE i < LEN(set) DO set[i] := {}; INC(i) END
+       END FD_ZERO;
+
+       PROCEDURE FD_SET (fd: Net.SOCKET; VAR set: Net.fd_set);
+       BEGIN
+               INCL(set[fd DIV 32], fd MOD 32)
+       END FD_SET;
+*)
+
+       PROCEDURE [ccall] select* (nfds: INTEGER; VAR [nil] readfds: fd_set; VAR [nil] writefds: fd_set; VAR [nil] exceptfds: fd_set; VAR timeout: timeval): INTEGER;
+
+END LinNet.
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/Makefile b/Trurl-based/_Linux_/Lin/Mod/gen-Net/Makefile
new file mode 100644 (file)
index 0000000..d3c865f
--- /dev/null
@@ -0,0 +1,23 @@
+# This is GNU Makefile
+#    BSD       GNU
+# $@    $@
+# ${.ALLSRC}    $^
+# ${.IMPSRC}    $<
+
+all: Net.txt dumphstrerrno
+
+PY = python2.7
+DEFS = defs-socket defs-so
+
+Net.txt: Net.txt.templ ${DEFS} defs-netdb defs-in defs-sock
+       ${PY} ./untempl.py Net.txt.templ $@
+
+defs-socket:
+       ./dumpdefs.py 3 1 i /usr/include/i386-linux-gnu/bits/socket.h | grep "  PF_" > $@
+       ./dumpdefs.py 3 1 i /usr/include/i386-linux-gnu/bits/socket.h | grep "  SOMAXCONN" >> $@
+
+defs-so:
+       ./dumpdefs.py 3 1 s /usr/include/asm-generic/socket.h | grep "  SO_" > $@
+
+clean:
+       rm -f Net.txt ${DEFS} dumphstrerrno
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/Net.txt.templ b/Trurl-based/_Linux_/Lin/Mod/gen-Net/Net.txt.templ
new file mode 100644 (file)
index 0000000..ea54461
--- /dev/null
@@ -0,0 +1,140 @@
+MODULE LinNet ["libc.so.6"];
+
+       (*
+               A. V. Shiryaev, 2012.11
+
+               GNU/Linux
+               32-bit
+       *)
+
+       IMPORT Libc := LinLibc;
+
+       CONST
+               INVALID_SOCKET* = -1;
+               SOCKET_ERROR* = -1;
+
+               (* /usr/include/i386-linux-gnu/bits/socket.h *)
+                       SHUT_RD* = 0;
+                       SHUT_WR* = 1;
+                       SHUT_RDWR* = 2;
+%%defs-sock%%
+%%defs-socket%%
+               (* /usr/include/asm-generic/socket.h *)
+%%defs-so%%
+               (* /usr/include/netinet/in.h *)
+                       INADDR_NONE* = -1;
+%%defs-in%%
+               (* /usr/include/asm-generic/param.h *)
+                       MAXHOSTNAMELEN* = 64; (* max length of hostname *)
+
+               (* /usr/include/netdb.h *)
+%%defs-netdb%%
+               (* /usr/include/i386-linux-gnu/bits/typesizes.h *)
+                       __FD_SETSIZE = 1024;
+                       __NFDBITS = SIZE(SET) * 8;
+
+       TYPE
+               SOCKET* = INTEGER;
+
+               (* /usr/include/i386-linux-gnu/bits/types.h *)
+                       socklen_t* = INTEGER;
+               (* /usr/include/i386-linux-gnu/bits/sockaddr.h *)
+                       sa_family_t* = SHORTINT; (* unsigned short int *)
+               (* /usr/include/netinet/in.h *)
+                       in_addr_t* = INTEGER;
+                       in_port_t* = SHORTINT;
+
+               (* /usr/include/i386-linux-gnu/bits/socket.h *)
+                       sockaddr* = RECORD [untagged]
+                               sa_family: sa_family_t;
+                               sa_data: ARRAY [untagged] 14 OF SHORTCHAR;
+                       END;
+
+               (* /usr/include/linux/in.h *)
+(*
+                       in_addr* = INTEGER;
+*)
+                       in_addr* = RECORD [untagged]
+                               S_un*: RECORD [union]
+                                       S_un_b*: RECORD [untagged]
+                                               s_b1*: SHORTCHAR;
+                                               s_b2*: SHORTCHAR;
+                                               s_b3*: SHORTCHAR;
+                                               s_b4*: SHORTCHAR;
+                                       END;
+                                       S_un_w*: RECORD [untagged]
+                                               s_w1*: SHORTINT;
+                                               s_w2*: SHORTINT;
+                                       END;
+                                       S_addr*: in_addr_t;
+                               END;
+                       END;
+
+               (* /usr/include/linux/in.h *)
+                       sockaddr_in* = RECORD [untagged]
+                               sin_family*: sa_family_t; (* address family *)
+                               sin_port*: SHORTINT; (* port number *)
+                               sin_addr*: in_addr; (* internet address *)
+                               __pad: ARRAY [untagged] 8 OF SHORTCHAR;
+                       END;
+
+               (* /usr/include/netdb.h *)
+                       Ptrhostent* = POINTER TO hostent;
+                       hostent* = RECORD [untagged]
+                               h_name*: Libc.PtrSTR; (* official name of host *)
+                               h_aliases*: POINTER TO ARRAY [untagged] OF Libc.PtrSTR; (* alias list *)
+                               h_addrtype*: INTEGER; (* host address type *)
+                               h_length*: INTEGER; (* length of address *)
+                               h_addr_list*: POINTER TO ARRAY [untagged] OF POINTER TO ARRAY [untagged] OF in_addr; (* list of addresses from name server *)
+                       END;
+
+               (* /usr/include/linux/time.h *)
+               (* /usr/include/asm-generic/posix_types.h *)
+                       timeval* = RECORD [untagged]
+                               tv_sec*: INTEGER; (* seconds *)
+                               tv_usec*: INTEGER; (* microseconds *)
+                       END;
+
+               (* /usr/include/i386-linux-gnu/sys/select.h *)
+                       __fd_mask = SET;
+                       fd_set* = ARRAY [untagged] __FD_SETSIZE DIV __NFDBITS OF __fd_mask;
+
+       VAR
+               h_errno*: INTEGER;
+
+       PROCEDURE [ccall] socket* (domain: INTEGER; type: INTEGER; protocol: INTEGER): SOCKET;
+       PROCEDURE [ccall] accept* (sockfd: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): SOCKET;
+       PROCEDURE [ccall] bind* (sockfd: SOCKET; VAR addr: sockaddr; addrlen: socklen_t): INTEGER;
+       PROCEDURE [ccall] connect* (sockfd: SOCKET; VAR addr: sockaddr; addrlen: socklen_t): INTEGER;
+       PROCEDURE [ccall] listen* (sockfd: SOCKET; backlog: INTEGER): INTEGER;
+       PROCEDURE [ccall] recv* (soskfd: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
+       PROCEDURE [ccall] send* (sockfd: SOCKET; buf: Libc.PtrVoid; len: Libc.size_t; flags: SET): Libc.ssize_t;
+       PROCEDURE [ccall] shutdown* (sockfd: SOCKET; how: INTEGER): INTEGER;
+       PROCEDURE [ccall] getsockopt* (sockfd: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; VAR optlen: socklen_t): INTEGER;
+       PROCEDURE [ccall] setsockopt* (sockfd: SOCKET; level: INTEGER; optname: SET; optval: Libc.PtrVoid; optlen: socklen_t): INTEGER;
+
+       PROCEDURE [ccall] htons* (hostshort: SHORTINT): SHORTINT;
+
+       PROCEDURE [ccall] gethostbyname* (name: Libc.PtrSTR): Ptrhostent;
+       PROCEDURE [ccall] inet_addr* (cp: Libc.PtrSTR): in_addr_t;
+
+       PROCEDURE [ccall] getsockname* (sockfd: SOCKET; VAR addr: sockaddr; VAR addrlen: socklen_t): INTEGER;
+
+       PROCEDURE [ccall] hstrerror* (err: INTEGER): Libc.PtrSTR;
+
+(*
+       PROCEDURE FD_ZERO (VAR set: Net.fd_set);
+               VAR i: INTEGER;
+       BEGIN
+               i := 0; WHILE i < LEN(set) DO set[i] := {}; INC(i) END
+       END FD_ZERO;
+
+       PROCEDURE FD_SET (fd: Net.SOCKET; VAR set: Net.fd_set);
+       BEGIN
+               INCL(set[fd DIV 32], fd MOD 32)
+       END FD_SET;
+*)
+
+       PROCEDURE [ccall] select* (nfds: INTEGER; VAR [nil] readfds: fd_set; VAR [nil] writefds: fd_set; VAR [nil] exceptfds: fd_set; VAR timeout: timeval): INTEGER;
+
+END LinNet.
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-in b/Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-in
new file mode 100644 (file)
index 0000000..2c0402e
--- /dev/null
@@ -0,0 +1,29 @@
+                       IPPROTO_IP = 0; (* Dummy protocol for TCP. *)
+                       IPPROTO_HOPOPTS* = 0; (* IPv6 Hop-by-Hop options. *)
+                       IPPROTO_ICMP* = 1; (* Internet Control Message Protocol. *)
+                       IPPROTO_IGMP* = 2; (* Internet Group Management Protocol. *)
+                       IPPROTO_IPIP* = 4; (* IPIP tunnels (older KA9Q tunnels use 94). *)
+                       IPPROTO_TCP* = 6; (* Transmission Control Protocol. *)
+                       IPPROTO_EGP* = 8; (* Exterior Gateway Protocol. *)
+                       IPPROTO_PUP* = 12; (* PUP protocol. *)
+                       IPPROTO_UDP* = 17; (* User Datagram Protocol. *)
+                       IPPROTO_IDP* = 22; (* XNS IDP protocol. *)
+                       IPPROTO_TP* = 29; (* SO Transport Protocol Class 4. *)
+                       IPPROTO_DCCP* = 33; (* Datagram Congestion Control Protocol. *)
+                       IPPROTO_IPV6* = 41; (* IPv6 header. *)
+                       IPPROTO_ROUTING* = 43; (* IPv6 routing header. *)
+                       IPPROTO_FRAGMENT* = 44; (* IPv6 fragmentation header. *)
+                       IPPROTO_RSVP* = 46; (* Reservation Protocol. *)
+                       IPPROTO_GRE* = 47; (* General Routing Encapsulation. *)
+                       IPPROTO_ESP* = 50; (* encapsulating security payload. *)
+                       IPPROTO_AH* = 51; (* authentication header. *)
+                       IPPROTO_ICMPV6* = 58; (* ICMPv6. *)
+                       IPPROTO_NONE* = 59; (* IPv6 no next header. *)
+                       IPPROTO_DSTOPTS* = 60; (* IPv6 destination options. *)
+                       IPPROTO_MTP* = 92; (* Multicast Transport Protocol. *)
+                       IPPROTO_ENCAP* = 98; (* Encapsulation Header. *)
+                       IPPROTO_PIM* = 103; (* Protocol Independent Multicast. *)
+                       IPPROTO_COMP* = 108; (* Compression Header Protocol. *)
+                       IPPROTO_SCTP* = 132; (* Stream Control Transmission Protocol. *)
+                       IPPROTO_UDPLITE* = 136; (* UDP-Lite protocol. *)
+                       IPPROTO_RAW* = 255; (* Raw IP packets. *)
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-netdb b/Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-netdb
new file mode 100644 (file)
index 0000000..4b218bb
--- /dev/null
@@ -0,0 +1,6 @@
+                       NETDB_INTERNAL* = -1; (* See errno. *)
+                       NETDB_SUCCESS* = 0; (* No problem. *)
+                       HOST_NOT_FOUND* = 1; (* Authoritative Answer Host not found. *)
+                       TRY_AGAIN* = 2; (* Non-Authoritative Host not found, or SERVERFAIL. *)
+                       NO_RECOVERY* = 3; (* Non recoverable errors, FORMERR, REFUSED, NOTIMP. *)
+                       NO_DATA* = 4; (* Valid name, no data record of requested type. *)
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-sock b/Trurl-based/_Linux_/Lin/Mod/gen-Net/defs-sock
new file mode 100644 (file)
index 0000000..158217a
--- /dev/null
@@ -0,0 +1,7 @@
+                       SOCK_STREAM* = 1;
+                       SOCK_DGRAM* = 2;
+                       SOCK_RAW* = 3;
+                       SOCK_RDM* = 4;
+                       SOCK_SEQPACKET* = 5;
+                       SOCK_DCCP* = 6;
+                       SOCK_PACKET* = 10;
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/dumpdefs.py b/Trurl-based/_Linux_/Lin/Mod/gen-Net/dumpdefs.py
new file mode 120000 (symlink)
index 0000000..1730591
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/dumpdefs.py
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/dumphstrerrno.c b/Trurl-based/_Linux_/Lin/Mod/gen-Net/dumphstrerrno.c
new file mode 120000 (symlink)
index 0000000..d87b25c
--- /dev/null
@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Net/dumphstrerrno.c
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Net/untempl.py b/Trurl-based/_Linux_/Lin/Mod/gen-Net/untempl.py
new file mode 120000 (symlink)
index 0000000..5800713
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/untempl.py
\ No newline at end of file
index 3181e5eb2f4a74cbeafd8ca97c752fb56b701948..a281fd8430537097759eb06702135c79ca112607 100644 (file)
Binary files a/Trurl-based/_OpenBSD_/Comm/Mod/TCP.odc and b/Trurl-based/_OpenBSD_/Comm/Mod/TCP.odc differ
index 24b0984b8ef964ae0f06dcdd3ae23c9c2b3f68ae..7c5df4e81ac6b749d9ab77d7872c7987b67da2ef 100644 (file)
@@ -156,6 +156,7 @@ MODULE LinNet ["libc.so.66.0"];
                (* /usr/include/sys/select.h *)
                        FD_SETSIZE = 1024;
                        __NBBY = 8;
+
        TYPE
                SOCKET* = INTEGER;
 
index b424953120112d0fecf4144d7e4a42ca938e93be..500bac5c4436a72e6d127588f25ab1eee42a58c5 100755 (executable)
@@ -55,13 +55,24 @@ def fixVal (x, tip):
                                return x[2:].upper() + "H"
                        else:
                                return "0" + x[2:].upper() + "H"
-               else:
+               elif tip == 's':
                        return mkset(int(x, 16))
+               elif tip == 'c':
+                       if x[2] in ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'):
+                               return x[2:].upper() + "X"
+                       else:
+                               return "0" + x[2:].upper() + "X"
+               else:
+                       assert False
        elif x[0] == '0': # fix OCT
                if tip == 'i':
                        return str(int(x, 8))
-               else:
+               elif tip == 's':
                        return mkset(int(x, 8))
+               elif tip == 'c':
+                       return fixVal("0x%x" % (int(x, 8),), tip)
+               else:
+                       assert False
        else:
                if tip == 'i':
                        return x
@@ -71,7 +82,12 @@ def fixVal (x, tip):
                        except:
                                return x
                        else:
-                               return mkset(y)
+                               if tip == 's':
+                                       return mkset(y)
+                               elif tip == 'c':
+                                       return fixVal("0x%x" % (int(y),), tip)
+                               else:
+                                       assert False
 
 def p (nIndents, sym, val, comment, val1):
        r = [ "%s%s* = %s;" % (INDENT*nIndents, sym, val) ]
@@ -92,7 +108,7 @@ def main ():
                else:
                        level = int(sys.argv[2])
                tip = sys.argv[3]
-               assert tip in ('i', 's')
+               assert tip in ('i', 's', 'c')
 
                fh = open(sys.argv[4], 'r')
                st = 0
@@ -133,6 +149,7 @@ def main ():
                print " type:"
                print "         i: integer"
                print "         s: set"
+               print "         c: shortchar"
 
 if __name__ == '__main__':
        main()
index fa144c0e0d704fee7212c5fd2fafc6c41ef0ec5d..6d16b28192a65b6379c31bc29c840c701f2547b8 100644 (file)
@@ -26,6 +26,7 @@ MODULE LinNet ["libc.so.66.0"];
                (* /usr/include/sys/select.h *)
                        FD_SETSIZE = 1024;
                        __NBBY = 8;
+
        TYPE
                SOCKET* = INTEGER;