2 * Copyright (c) 2010 Luigi Rizzo, Universita` di Pisa
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * headers to build userland ipfw under tcc.
33 #define NULL ((void *)0)
35 typedef unsigned char u_char;
36 typedef unsigned char uint8_t;
37 typedef unsigned char u_int8_t;
38 typedef unsigned short u_short;
39 typedef unsigned short uint16_t;
40 typedef unsigned short u_int16_t;
41 typedef int __int32_t;
43 typedef int socklen_t;
45 typedef unsigned int time_t;
46 typedef unsigned int uint;
47 typedef unsigned int u_int;
48 typedef unsigned int uint32_t;
49 typedef unsigned int u_int32_t;
50 typedef unsigned int gid_t;
51 typedef unsigned int uid_t;
52 typedef unsigned long u_long;
53 typedef unsigned long uintptr_t;
54 typedef long long int int64_t;
55 typedef unsigned long long int uint64_t;
56 typedef unsigned long long int u_int64_t;
58 typedef uint32_t in_addr_t;
66 struct in_addr sin_addr;
70 #define INET6_ADDRSTRLEN 64
74 uint8_t __s6_addr8[16];
75 uint16_t __s6_addr16[8];
76 uint32_t __s6_addr32[4];
77 } __u6; // _addr; /* 128-bit IP6 address */
81 #define LITTLE_ENDIAN 1234
82 #define BYTE_ORDER LITTLE_ENDIAN
88 #define EX_UNAVAILABLE 3
98 #define IPPROTO_IPV6 2
99 #define IPPROTO_RAW 100
101 #define IPTOS_LOWDELAY 100
102 #define IPTOS_MINCOST 101
103 #define IPTOS_RELIABILITY 102
104 #define IPTOS_THROUGHPUT 103
112 #define bcmp(src, dst, len) memcmp(src, dst, len)
113 #define bcopy(src, dst, len) memcpy(dst, src, len)
114 #define bzero(p, len) memset(p, 0, len)
115 #define index(s, c) strchr(s, c)
117 char *strsep(char **stringp, const char *delim);
119 void warn(const char *, ...);
120 //void warnx(const char *, ...);
122 void err(int, const char *, ...);
125 uint16_t htons(uint16_t)__attribute__ ((stdcall));
126 uint16_t ntohs(uint16_t)__attribute__ ((stdcall));
127 uint32_t htonl(uint32_t)__attribute__ ((stdcall));
128 uint32_t ntohl(uint32_t)__attribute__ ((stdcall));
129 int inet_aton(const char *cp, struct in_addr *pin);
130 char * inet_ntoa(struct in_addr);
131 const char * inet_ntop(int af, const void * src, char * dst,
133 int inet_pton(int af, const char * src, void * dst);
144 #define getpwnam(s) (NULL)
145 #define getpwuid(s) (NULL)
147 #define getgrnam(x) (NULL)
148 #define getgrgid(x) (NULL)
150 int getopt(int argc, char * const argv[], const char *optstring);
152 int getsockopt(int s, int level, int optname, void * optval,
155 int setsockopt(int s, int level, int optname, const void *optval,
159 char *p_name; /* official protocol name */
160 char **p_aliases; /* alias list */
161 short p_proto; /* protocol # */
165 char *s_name; /* official service name */
166 char **s_aliases; /* alias list */
167 short s_port; /* port # */
168 char *s_proto; /* protocol to use */
172 char *h_name; /* official name of host */
173 char **h_aliases; /* alias list */
174 short h_addrtype; /* host address type */
175 short h_length; /* length of address */
176 char **h_addr_list; /* list of addresses */
177 #define h_addr h_addr_list[0] /* address, for backward compat */
180 struct hostent* gethostbyaddr(const char* addr, int len, int type)__attribute__ ((stdcall));
181 struct hostent* gethostbyname(const char *name)__attribute__ ((stdcall));
183 struct protoent* getprotobynumber(int number)__attribute__ ((stdcall));
184 struct protoent* getprotobyname(const char* name)__attribute__ ((stdcall));
186 struct servent* getservbyport(int port, const char* proto)__attribute__ ((stdcall));
187 struct servent* getservbyname(const char* name, const char* proto) __attribute__ ((stdcall));
194 #define WSADESCRIPTION_LEN 256
195 #define WSASYS_STATUS_LEN 128
197 typedef struct WSAData {
200 char szDescription[WSADESCRIPTION_LEN+1];
201 char szSystemStatus[WSASYS_STATUS_LEN+1];
202 unsigned short iMaxSockets;
203 unsigned short iMaxUdpDg;
204 char FAR * lpVendorInfo;
205 } WSADATA, * LPWSADATA;
208 WORD wVersionRequested,
215 int WSAGetLastError();
217 /* return error on process handling */
219 #define kill(p, s) (-1)
220 #define waitpid(w,s,o) (-1)
222 #define execvp(f, a) (-1)
224 #define _W_INT(i) (i)
225 #define _WSTATUS(x) (_W_INT(x) & 0177)
226 #define WIFEXITED(x) (_WSTATUS(x) == 0)
227 #define WEXITSTATUS(x) (_W_INT(x) >> 8)
228 #define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
229 #define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
230 #define WTERMSIG(x) (_WSTATUS(x))
232 #endif /* _TCC_GLUE_H */