"Fossies" - the Fresh Open Source Software Archive 
Member "vpnc-0.5.3/sysdep.h" (19 Nov 2008, 6058 Bytes) of package /linux/privat/old/vpnc-0.5.3.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "sysdep.h" see the
Fossies "Dox" file reference documentation.
1 #ifndef __SYSDEP_H__
2 #define __SYSDEP_H__
3
4 /*
5 * Different systems define different macros.
6 * For vpnc, this list should be used as
7 * reference:
8 *
9 * __linux__
10 * __NetBSD__
11 * __OpenBSD__
12 * __FreeBSD__
13 * __DragonFly__
14 * __APPLE__ Darwin / MacOS X
15 * __sun__ SunOS / Solaris
16 * __CYGWIN__
17 * __SKYOS__
18 *
19 */
20
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24
25 #if !defined(__CYGWIN__)
26 #include <net/if.h>
27 #include <net/if_arp.h>
28 #include <netinet/if_ether.h>
29 #endif
30
31 #include "config.h"
32
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);
38
39 /***************************************************************************/
40 #if defined(__linux__) || defined(__GLIBC__)
41 #include <error.h>
42
43 #define HAVE_VASPRINTF 1
44 #define HAVE_ASPRINTF 1
45 #define HAVE_ERROR 1
46 #define HAVE_GETLINE 1
47 #define HAVE_UNSETENV 1
48 #define HAVE_SETENV 1
49 #endif
50
51 /***************************************************************************/
52 #if defined(__NetBSD__)
53 #define HAVE_SA_LEN 1
54
55 #define HAVE_VASPRINTF 1
56 #define HAVE_ASPRINTF 1
57 #define HAVE_FGETLN 1
58 #define HAVE_UNSETENV 1
59 #define HAVE_SETENV 1
60 #endif
61
62 /***************************************************************************/
63 #if defined(__OpenBSD__)
64 #define HAVE_SA_LEN 1
65 #define NEED_IPLEN_FIX 1
66 #define NEW_TUN 1
67
68 #define HAVE_VASPRINTF 1
69 #define HAVE_ASPRINTF 1
70 #define HAVE_FGETLN 1
71 #define HAVE_UNSETENV 1
72 #define HAVE_SETENV 1
73 #endif
74
75 /***************************************************************************/
76 #if defined(__FreeBSD_kernel__)
77 #define HAVE_SA_LEN 1
78 #endif
79
80 /***************************************************************************/
81 #if defined(__FreeBSD__)
82 #define HAVE_SA_LEN 1
83
84 #define HAVE_VASPRINTF 1
85 #define HAVE_ASPRINTF 1
86 #define HAVE_FGETLN 1
87 #define HAVE_UNSETENV 1
88 #define HAVE_SETENV 1
89 #endif
90
91 /***************************************************************************/
92 #if defined(__DragonFly__)
93 #define HAVE_SA_LEN 1
94
95 #define HAVE_VASPRINTF 1
96 #define HAVE_ASPRINTF 1
97 #define HAVE_FGETLN 1
98 #define HAVE_UNSETENV 1
99 #define HAVE_SETENV 1
100 #endif
101
102 /***************************************************************************/
103 #if defined(__APPLE__)
104 #define HAVE_SA_LEN 1
105 #define NEED_IPLEN_FIX 1
106
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 #endif
113
114 /***************************************************************************/
115 #if defined(__sun__)
116 #define NEED_IPLEN_FIX 1
117
118 #ifndef IPPROTO_ESP
119 #define IPPROTO_ESP 50
120 #endif
121
122 #define getpass(prompt) getpassphrase(prompt)
123
124 /* where is this defined? */
125 #include <sys/socket.h>
126 const char *inet_ntop(int af, const void *src, char *dst, size_t cnt);
127 #endif
128 /***************************************************************************/
129 #if defined (__SKYOS__)
130 #define HAVE_UNSETENV 1
131
132 #ifndef IPPROTO_ENCAP
133 #define IPPROTO_ENCAP 4
134 #endif
135
136 #ifndef IPPROTO_ESP
137 #define IPPROTO_ESP 50
138 #endif
139 #endif
140 /***************************************************************************/
141 #if defined (__CYGWIN__)
142 #define HAVE_VASPRINTF 1
143 #define HAVE_ASPRINTF 1
144 #define HAVE_GETLINE 1
145 #define HAVE_FGETLN 1
146 #define HAVE_UNSETENV 1
147 #define HAVE_SETENV 1
148
149 #ifndef IPPROTO_ESP
150 #define IPPROTO_ESP 50
151 #endif
152
153 #ifndef IPPROTO_ENCAP
154 #define IPPROTO_ENCAP 4
155 #endif
156
157 #ifdef IFNAMSIZ
158 #undef IFNAMSIZ
159 #endif
160 #define IFNAMSIZ 256
161
162 /*
163 * At the moment the Cygwin environment does not have header files
164 * for raw ethernet access, hence we need to define here what
165 * is usually found in net/ethernet.h and netinet/if_ether.h
166 */
167
168 #define ETH_ALEN 6
169
170 /* Ethernet header */
171 struct ether_header
172 {
173 unsigned char ether_dhost[ETH_ALEN]; /* destination eth addr */
174 unsigned char ether_shost[ETH_ALEN]; /* source ether addr */
175 unsigned short ether_type; /* packet type ID field */
176 } __attribute__ ((__packed__));
177
178 #define ETHERTYPE_IP 0x0800 /* IP */
179 #define ETHERTYPE_ARP 0x0806 /* ARP */
180
181 /* Common ARP header */
182 struct arphdr {
183 unsigned short ar_hrd; /* format of hardware address */
184 unsigned short ar_pro; /* format of protocol address */
185 unsigned char ar_hln; /* length of hardware address */
186 unsigned char ar_pln; /* length of protocol address */
187 unsigned short ar_op; /* ARP opcode (command) */
188 };
189
190 /* Ethernet ARP header */
191 struct ether_arp {
192 struct arphdr ea_hdr; /* fixed-size header */
193 unsigned char arp_sha[ETH_ALEN]; /* sender hardware address */
194 unsigned char arp_spa[4]; /* sender protocol address */
195 unsigned char arp_tha[ETH_ALEN]; /* target hardware address */
196 unsigned char arp_tpa[4]; /* target protocol address */
197 };
198 #define arp_hrd ea_hdr.ar_hrd
199 #define arp_pro ea_hdr.ar_pro
200 #define arp_hln ea_hdr.ar_hln
201 #define arp_pln ea_hdr.ar_pln
202 #define arp_op ea_hdr.ar_op
203
204 #define ARPHRD_ETHER 1 /* Ethernet */
205
206 #define ARPOP_REQUEST 1 /* ARP request */
207 #define ARPOP_REPLY 2 /* ARP reply */
208
209 #endif
210 /***************************************************************************/
211
212
213 #ifndef IPDEFTTL
214 #define IPDEFTTL 64 /* default ttl, from RFC 1340 */
215 #endif
216
217 #ifndef IPPROTO_IPIP
218 #define IPPROTO_IPIP IPPROTO_ENCAP
219 #endif
220
221 #ifndef ETH_HLEN
222 #define ETH_HLEN (sizeof(struct ether_header))
223 #endif
224
225 #ifndef ETH_ALEN
226 #define ETH_ALEN (sizeof(struct ether_addr))
227 #endif
228
229 #ifndef HAVE_ERROR
230 extern void error(int fd, int errorno, const char *fmt, ...);
231 #endif
232 #ifndef HAVE_GETLINE
233 extern int getline(char **line, size_t * length, FILE * stream);
234 #endif
235 #ifndef HAVE_VASPRINTF
236 #include <stdarg.h>
237 extern int vasprintf(char **strp, const char *fmt, va_list ap);
238 #endif
239 #ifndef HAVE_ASPRINTF
240 extern int asprintf(char **strp, const char *fmt, ...);
241 #endif
242 #ifndef HAVE_SETENV
243 extern int setenv(const char *name, const char *value, int overwrite);
244 #endif
245 #ifndef HAVE_UNSETENV
246 extern int unsetenv(const char *name);
247 #endif
248
249
250 #endif