1 /***********************************************************************\
2 *                               ipexport.d                              *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module win32.ipexport;
12 version(Windows):
13 
14 private import win32.windef;
15 
16 const size_t MAX_ADAPTER_NAME = 128;
17 
18 // IP STATUS flags
19 enum : IP_STATUS {
20 	IP_SUCCESS         =     0,
21 	IP_STATUS_BASE     = 11000,
22 	IP_BUF_TOO_SMALL,
23 	IP_DEST_NET_UNREACHABLE,
24 	IP_DEST_HOST_UNREACHABLE,
25 	IP_DEST_PROT_UNREACHABLE,
26 	IP_DEST_PORT_UNREACHABLE,
27 	IP_NO_RESOURCES,
28 	IP_BAD_OPTION,
29 	IP_HW_ERROR,
30 	IP_PACKET_TOO_BIG,
31 	IP_REQ_TIMED_OUT,
32 	IP_BAD_REQ,
33 	IP_BAD_ROUTE,
34 	IP_TTL_EXPIRED_TRANSIT,
35 	IP_TTL_EXPIRED_REASSEM,
36 	IP_PARAM_PROBLEM,
37 	IP_SOURCE_QUENCH,
38 	IP_OPTION_TOO_BIG,
39 	IP_BAD_DESTINATION,
40 	IP_ADDR_DELETED,
41 	IP_SPEC_MTU_CHANGE,
42 	IP_MTU_CHANGE,
43 	IP_UNLOAD,      // = IP_STATUS_BASE + 22
44 	IP_GENERAL_FAILURE = IP_STATUS_BASE + 50,
45 	MAX_IP_STATUS      = IP_GENERAL_FAILURE,
46 	IP_PENDING         = IP_STATUS_BASE + 255
47 }
48 
49 // IP header Flags values
50 const byte IP_FLAG_DF = 2;
51 
52 // IP Option types
53 enum : ubyte {
54 	IP_OPT_EOL          = 0,
55 	IP_OPT_NOP          = 0x01,
56 	IP_OPT_RR           = 0x07,
57 	IP_OPT_SECURITY     = 0x82,
58 	IP_OPT_LSRR         = 0x83,
59 	IP_OPT_SSRR         = 0x89,
60 	IP_OPT_TS           = 0x44,
61 	IP_OPT_SID          = 0x88,
62 	IP_OPT_ROUTER_ALERT = 0x94
63 }
64 
65 const ubyte MAX_OPT_SIZE = 40;
66 
67 alias uint IPAddr, IPMask, IP_STATUS;
68 
69 struct IP_OPTION_INFORMATION {
70 	ubyte  Ttl;
71 	ubyte  Tos;
72 	ubyte  Flags;
73 	ubyte  OptionsSize;
74 	ubyte* OptionsData;
75 }
76 alias IP_OPTION_INFORMATION* PIP_OPTION_INFORMATION;
77 
78 struct ICMP_ECHO_REPLY {
79   IPAddr Address;
80   uint   Status;
81   uint   RoundTripTime;
82   ushort DataSize;
83   ushort Reserved;
84   void*  Data;
85   IP_OPTION_INFORMATION Options;
86 }
87 alias ICMP_ECHO_REPLY* PICMP_ECHO_REPLY;
88 
89 struct IP_ADAPTER_INDEX_MAP {
90 	ULONG                   Index;
91 	WCHAR[MAX_ADAPTER_NAME] Name;
92 }
93 alias IP_ADAPTER_INDEX_MAP* PIP_ADAPTER_INDEX_MAP;
94 
95 struct IP_INTERFACE_INFO {
96 	LONG                    NumAdapters;
97 	IP_ADAPTER_INDEX_MAP[1] _Adapter;
98 
99 	IP_ADAPTER_INDEX_MAP* Adapter() { return _Adapter.ptr; }
100 }
101 alias IP_INTERFACE_INFO* PIP_INTERFACE_INFO;
102 
103 struct IP_UNIDIRECTIONAL_ADAPTER_ADDRESS {
104 	ULONG     NumAdapters;
105 	IPAddr[1] _Address;
106 
107 	IPAddr* Address() { return _Address.ptr; }
108 }
109 alias IP_UNIDIRECTIONAL_ADAPTER_ADDRESS* PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS;