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_GETLINE 1
47 #define HAVE_UNSETENV 1
51 /***************************************************************************/
52 #if defined(__NetBSD__)
55 #define HAVE_VASPRINTF 1
56 #define HAVE_ASPRINTF 1
58 #define HAVE_UNSETENV 1
62 /***************************************************************************/
63 #if defined(__OpenBSD__)
65 #define NEED_IPLEN_FIX 1
68 #define HAVE_VASPRINTF 1
69 #define HAVE_ASPRINTF 1
71 #define HAVE_UNSETENV 1
75 /***************************************************************************/
76 #if defined(__FreeBSD_kernel__)
80 /***************************************************************************/
81 #if defined(__FreeBSD__)
84 #define HAVE_VASPRINTF 1
85 #define HAVE_ASPRINTF 1
87 #define HAVE_UNSETENV 1
91 /***************************************************************************/
92 #if defined(__DragonFly__)
95 #define HAVE_VASPRINTF 1
96 #define HAVE_ASPRINTF 1
98 #define HAVE_UNSETENV 1
102 /***************************************************************************/
103 #if defined(__APPLE__)
104 #define HAVE_SA_LEN 1
105 #define NEED_IPLEN_FIX 1
107 #define HAVE_VASPRINTF 1
108 #define HAVE_ASPRINTF 1
109 #define HAVE_FGETLN 1
110 #define HAVE_UNSETENV 1
111 #define HAVE_SETENV 1
112 #if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1070
113 #define HAVE_GETLINE 1
117 /***************************************************************************/
119 #define NEED_IPLEN_FIX 1
122 #define IPPROTO_ESP 50
125 #define getpass(prompt) getpassphrase(prompt)
127 /* where is this defined? */
128 #include <sys/socket.h>
129 const char *inet_ntop(int af
, const void *src
, char *dst
, size_t cnt
);
131 /***************************************************************************/
132 #if defined (__SKYOS__)
133 #define HAVE_UNSETENV 1
135 #ifndef IPPROTO_ENCAP
136 #define IPPROTO_ENCAP 4
140 #define IPPROTO_ESP 50
143 /***************************************************************************/
144 #if defined (__CYGWIN__)
145 #define HAVE_VASPRINTF 1
146 #define HAVE_ASPRINTF 1
147 #define HAVE_GETLINE 1
148 #define HAVE_FGETLN 1
149 #define HAVE_UNSETENV 1
150 #define HAVE_SETENV 1
153 #define IPPROTO_ESP 50
156 #ifndef IPPROTO_ENCAP
157 #define IPPROTO_ENCAP 4
166 * At the moment the Cygwin environment does not have header files
167 * for raw ethernet access, hence we need to define here what
168 * is usually found in net/ethernet.h and netinet/if_ether.h
173 /* Ethernet header */
176 unsigned char ether_dhost
[ETH_ALEN
]; /* destination eth addr */
177 unsigned char ether_shost
[ETH_ALEN
]; /* source ether addr */
178 unsigned short ether_type
; /* packet type ID field */
179 } __attribute__ ((__packed__
));
181 #define ETHERTYPE_IP 0x0800 /* IP */
182 #define ETHERTYPE_ARP 0x0806 /* ARP */
184 /* Common ARP header */
186 unsigned short ar_hrd
; /* format of hardware address */
187 unsigned short ar_pro
; /* format of protocol address */
188 unsigned char ar_hln
; /* length of hardware address */
189 unsigned char ar_pln
; /* length of protocol address */
190 unsigned short ar_op
; /* ARP opcode (command) */
193 /* Ethernet ARP header */
195 struct arphdr ea_hdr
; /* fixed-size header */
196 unsigned char arp_sha
[ETH_ALEN
]; /* sender hardware address */
197 unsigned char arp_spa
[4]; /* sender protocol address */
198 unsigned char arp_tha
[ETH_ALEN
]; /* target hardware address */
199 unsigned char arp_tpa
[4]; /* target protocol address */
201 #define arp_hrd ea_hdr.ar_hrd
202 #define arp_pro ea_hdr.ar_pro
203 #define arp_hln ea_hdr.ar_hln
204 #define arp_pln ea_hdr.ar_pln
205 #define arp_op ea_hdr.ar_op
207 #define ARPHRD_ETHER 1 /* Ethernet */
209 #define ARPOP_REQUEST 1 /* ARP request */
210 #define ARPOP_REPLY 2 /* ARP reply */
213 /***************************************************************************/
217 #define IPDEFTTL 64 /* default ttl, from RFC 1340 */
221 #define IPPROTO_IPIP IPPROTO_ENCAP
225 #define ETH_HLEN (sizeof(struct ether_header))
229 #define ETH_ALEN (sizeof(struct ether_addr))
233 extern void error(int fd
, int errorno
, const char *fmt
, ...);
236 extern int getline(char **line
, size_t * length
, FILE * stream
);
238 #ifndef HAVE_VASPRINTF
240 extern int vasprintf(char **strp
, const char *fmt
, va_list ap
);
242 #ifndef HAVE_ASPRINTF
243 extern int asprintf(char **strp
, const char *fmt
, ...);
246 extern int setenv(const char *name
, const char *value
, int overwrite
);
248 #ifndef HAVE_UNSETENV
249 extern int unsetenv(const char *name
);