5 * Different systems define different macros.
6 * For vpnc, this list should be used as
14 * __APPLE__ Darwin / MacOS X
15 * __sun__ SunOS / Solaris
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
25 #if !defined(__CYGWIN__)
27 #include <net/if_arp.h>
28 #include <netinet/if_ether.h>
33 int tun_open(char *dev
, enum if_mode_enum mode
);
34 int tun_close(int fd
, char *dev
);
35 int tun_write(int fd
, unsigned char *buf
, int len
);
36 int tun_read(int fd
, unsigned char *buf
, int len
);
37 int tun_get_hwaddr(int fd
, char *dev
, uint8_t *hwaddr
);
39 /***************************************************************************/
40 #if defined(__linux__) || defined(__GLIBC__)
43 #define HAVE_VASPRINTF 1
44 #define HAVE_ASPRINTF 1
46 #define HAVE_UNSETENV 1
50 /***************************************************************************/
51 #if defined(__NetBSD__)
54 #define HAVE_VASPRINTF 1
55 #define HAVE_ASPRINTF 1
56 #define HAVE_UNSETENV 1
60 /***************************************************************************/
61 #if defined(__OpenBSD__)
63 #define NEED_IPLEN_FIX 1
66 #define HAVE_VASPRINTF 1
67 #define HAVE_ASPRINTF 1
68 #define HAVE_UNSETENV 1
72 /***************************************************************************/
73 #if defined(__FreeBSD_kernel__)
77 /***************************************************************************/
78 #if defined(__FreeBSD__)
81 #define HAVE_VASPRINTF 1
82 #define HAVE_ASPRINTF 1
83 #define HAVE_UNSETENV 1
87 /***************************************************************************/
88 #if defined(__DragonFly__)
91 #define HAVE_VASPRINTF 1
92 #define HAVE_ASPRINTF 1
93 #define HAVE_UNSETENV 1
97 /***************************************************************************/
98 #if defined(__APPLE__)
100 #define NEED_IPLEN_FIX 1
102 #define HAVE_VASPRINTF 1
103 #define HAVE_ASPRINTF 1
104 #define HAVE_UNSETENV 1
105 #define HAVE_SETENV 1
106 #if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1070
110 /***************************************************************************/
112 #define NEED_IPLEN_FIX 1
115 #define IPPROTO_ESP 50
118 /* where is this defined? */
119 #include <sys/socket.h>
120 const char *inet_ntop(int af
, const void *src
, char *dst
, size_t cnt
);
122 /***************************************************************************/
123 #if defined (__SKYOS__)
124 #define HAVE_UNSETENV 1
126 #ifndef IPPROTO_ENCAP
127 #define IPPROTO_ENCAP 4
131 #define IPPROTO_ESP 50
134 /***************************************************************************/
135 #if defined (__CYGWIN__)
136 #define HAVE_VASPRINTF 1
137 #define HAVE_ASPRINTF 1
138 #define HAVE_UNSETENV 1
139 #define HAVE_SETENV 1
142 #define IPPROTO_ESP 50
145 #ifndef IPPROTO_ENCAP
146 #define IPPROTO_ENCAP 4
155 * At the moment the Cygwin environment does not have header files
156 * for raw ethernet access, hence we need to define here what
157 * is usually found in net/ethernet.h and netinet/if_ether.h
162 /* Ethernet header */
165 unsigned char ether_dhost
[ETH_ALEN
]; /* destination eth addr */
166 unsigned char ether_shost
[ETH_ALEN
]; /* source ether addr */
167 unsigned short ether_type
; /* packet type ID field */
168 } __attribute__ ((__packed__
));
170 #define ETHERTYPE_IP 0x0800 /* IP */
171 #define ETHERTYPE_ARP 0x0806 /* ARP */
173 /* Common ARP header */
175 unsigned short ar_hrd
; /* format of hardware address */
176 unsigned short ar_pro
; /* format of protocol address */
177 unsigned char ar_hln
; /* length of hardware address */
178 unsigned char ar_pln
; /* length of protocol address */
179 unsigned short ar_op
; /* ARP opcode (command) */
182 /* Ethernet ARP header */
184 struct arphdr ea_hdr
; /* fixed-size header */
185 unsigned char arp_sha
[ETH_ALEN
]; /* sender hardware address */
186 unsigned char arp_spa
[4]; /* sender protocol address */
187 unsigned char arp_tha
[ETH_ALEN
]; /* target hardware address */
188 unsigned char arp_tpa
[4]; /* target protocol address */
190 #define arp_hrd ea_hdr.ar_hrd
191 #define arp_pro ea_hdr.ar_pro
192 #define arp_hln ea_hdr.ar_hln
193 #define arp_pln ea_hdr.ar_pln
194 #define arp_op ea_hdr.ar_op
196 #define ARPHRD_ETHER 1 /* Ethernet */
198 #define ARPOP_REQUEST 1 /* ARP request */
199 #define ARPOP_REPLY 2 /* ARP reply */
202 /***************************************************************************/
206 #define IPDEFTTL 64 /* default ttl, from RFC 1340 */
210 #define IPPROTO_IPIP IPPROTO_ENCAP
214 #define ETH_HLEN (sizeof(struct ether_header))
218 #define ETH_ALEN (sizeof(struct ether_addr))
222 extern void error(int fd
, int errorno
, const char *fmt
, ...);
224 #ifndef HAVE_VASPRINTF
226 extern int vasprintf(char **strp
, const char *fmt
, va_list ap
);
228 #ifndef HAVE_ASPRINTF
229 extern int asprintf(char **strp
, const char *fmt
, ...);
232 extern int setenv(const char *name
, const char *value
, int overwrite
);
234 #ifndef HAVE_UNSETENV
235 extern int unsetenv(const char *name
);