source: src/windows.h @ 79f009

Revision 79f009, 3.7 KB checked in by Erik Ekman <yarrick@…>, 2 years ago (diff)

Fix compile for win32

  • Property mode set to 100644
Line 
1/*
2 * Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef __FIX_WINDOWS_H__
18#define __FIX_WINDOWS_H__
19
20typedef unsigned int in_addr_t;
21
22#include <windows.h>
23#include <windns.h>
24#include <winsock2.h>
25#include <ws2tcpip.h>
26#include <iphlpapi.h>
27
28/* Missing from the mingw headers */
29#ifndef DNS_TYPE_SRV
30# define DNS_TYPE_SRV 33
31#endif
32#ifndef DNS_TYPE_TXT
33# define DNS_TYPE_TXT 16
34#endif
35
36#define T_A DNS_TYPE_A
37#define T_NS DNS_TYPE_NS
38#define T_NULL DNS_TYPE_NULL
39#define T_CNAME DNS_TYPE_CNAME
40#define T_MX DNS_TYPE_MX
41#define T_TXT DNS_TYPE_TXT
42#define T_SRV DNS_TYPE_SRV
43
44#define C_IN 1
45
46#define FORMERR 1
47#define SERVFAIL 2
48#define NXDOMAIN 3
49#define NOTIMP 4
50#define REFUSED 5
51
52#define sleep(seconds) Sleep((seconds)*1000)
53
54typedef struct {
55        unsigned        id :16;         /* query identification number */
56                        /* fields in third byte */
57        unsigned        rd :1;          /* recursion desired */
58        unsigned        tc :1;          /* truncated message */
59        unsigned        aa :1;          /* authoritive answer */
60        unsigned        opcode :4;      /* purpose of message */
61        unsigned        qr :1;          /* response flag */
62                        /* fields in fourth byte */
63        unsigned        rcode :4;       /* response code */
64        unsigned        cd: 1;          /* checking disabled by resolver */
65        unsigned        ad: 1;          /* authentic data from named */
66        unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
67        unsigned        ra :1;          /* recursion available */
68                        /* remaining bytes */
69        unsigned        qdcount :16;    /* number of question entries */
70        unsigned        ancount :16;    /* number of answer entries */
71        unsigned        nscount :16;    /* number of authority entries */
72        unsigned        arcount :16;    /* number of resource entries */
73} HEADER;
74
75struct ip
76  {
77    unsigned int ip_hl:4;               /* header length */
78    unsigned int ip_v:4;                /* version */
79    u_char ip_tos;                      /* type of service */
80    u_short ip_len;                     /* total length */
81    u_short ip_id;                      /* identification */
82    u_short ip_off;                     /* fragment offset field */
83#define IP_RF 0x8000                    /* reserved fragment flag */
84#define IP_DF 0x4000                    /* dont fragment flag */
85#define IP_MF 0x2000                    /* more fragments flag */
86#define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
87    u_char ip_ttl;                      /* time to live */
88    u_char ip_p;                        /* protocol */
89    u_short ip_sum;                     /* checksum */
90    struct in_addr ip_src, ip_dst;      /* source and dest address */
91  };
92
93DWORD WINAPI tun_reader(LPVOID arg);
94struct tun_data {
95        HANDLE tun;
96        int sock;
97        struct sockaddr_in addr;
98};
99
100#endif
Note: See TracBrowser for help on using the repository browser.