-
Notifications
You must be signed in to change notification settings - Fork 2
/
IpExport.pas
343 lines (309 loc) · 13.5 KB
/
IpExport.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
{******************************************************************************}
{ }
{ Internet Protocol Helper API interface Unit for Object Pascal }
{ }
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
{ Corporation. All Rights Reserved. }
{ }
{ The original file is: ipexport.h, released July 2000. The original Pascal }
{ code is: IpExport.pas, released September 2000. The initial developer of the }
{ Pascal code is Marcel van Brakel (brakelm@chello.nl). }
{ }
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
{ Marcel van Brakel. All Rights Reserved. }
{ }
{ Contributor(s): John C. Penman (jcp@craiglockhart.com) }
{ Vladimir Vassiliev (voldemarv@hotpop.com) }
{ }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project JEDI home }
{ page, located at http://delphi-jedi.org or my personal homepage located at }
{ http://members.chello.nl/m.vanbrakel2 }
{ }
{ The contents of this file are used with permission, subject to the Mozilla }
{ Public License Version 1.1 (the "License"); you may not use this file except }
{ in compliance with the License. You may obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License. }
{ }
{ Alternatively, the contents of this file may be used under the terms of the }
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
{ provisions of the LGPL License are applicable instead of those above. }
{ If you wish to allow use of your version of this file only under the terms }
{ of the LGPL License and not to allow others to use your version of this file }
{ under the MPL, indicate your decision by deleting the provisions above and }
{ replace them with the notice and other provisions required by the LGPL }
{ License. If you do not delete the provisions above, a recipient may use }
{ your version of this file under either the MPL or the LGPL License. }
{ }
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
{ }
{******************************************************************************}
unit IpExport;
{$WEAKPACKAGEUNIT}
{$HPPEMIT ''}
{$HPPEMIT '#include "ipexport.h"'}
{$HPPEMIT ''}
//{$I WINDEFINES.INC}
interface
uses
Windows;
//
// IP type definitions.
//
type
IPAddr = Cardinal; // An IP address.
{$EXTERNALSYM IPAddr}
IPMask = Cardinal; // An IP subnet mask.
{$EXTERNALSYM IPMask}
IP_STATUS = Cardinal; // Status code returned from IP APIs.
{$EXTERNALSYM IP_STATUS}
//
// The ip_option_information structure describes the options to be
// included in the header of an IP packet. The TTL, TOS, and Flags
// values are carried in specific fields in the header. The OptionsData
// bytes are carried in the options area following the standard IP header.
// With the exception of source route options, this data must be in the
// format to be transmitted on the wire as specified in RFC 791. A source
// route option should contain the full route - first hop thru final
// destination - in the route data. The first hop will be pulled out of the
// data and the option will be reformatted accordingly. Otherwise, the route
// option should be formatted as specified in RFC 791.
//
type
ip_option_information = record
Ttl: Byte; // Time To Live
Tos: Byte; // Type Of Service
Flags: Byte; // IP header flags
OptionsSize: Byte; // Size in bytes of options data
OptionsData: PByte; // Pointer to options data
end;
{$EXTERNALSYM ip_option_information}
TIpOptionInformation = ip_option_information;
PIpOptionInformation = ^ip_option_information;
//
// The icmp_echo_reply structure describes the data returned in response
// to an echo request.
//
icmp_echo_reply = record
Address: IPAddr; // Replying address
Status: Cardinal; // Reply IP_STATUS
RoundTripTime: Cardinal; // RTT in milliseconds
DataSize: Word; // Reply data size in bytes
Reserved: Word; // Reserved for system use
Data: Pointer; // Pointer to the reply data
Options: ip_option_information; // Reply options
end;
{$EXTERNALSYM icmp_echo_reply}
PIP_OPTION_INFORMATION = ^IP_OPTION_INFORMATION;
{$EXTERNALSYM PIP_OPTION_INFORMATION}
PICMP_ECHO_REPLY = ^ICMP_ECHO_REPLY;
{$EXTERNALSYM PICMP_ECHO_REPLY}
TIcmpEchoReply = icmp_echo_reply;
PIcmpEchoReply = PICMP_ECHO_REPLY;
PARP_SEND_REPLY = ^ARP_SEND_REPLY;
{$EXTERNALSYM PARP_SEND_REPLY}
ArpRequestBuffer = record
DestAddress: IPAddr;
SrcAddress: IPAddr;
end;
{$EXTERNALSYM ArpRequestBuffer}
ARP_SEND_REPLY = ArpRequestBuffer;
{$EXTERNALSYM ARP_SEND_REPLY}
TArpRequestBuffer = ARP_SEND_REPLY;
PArpRequestBuffer = PARP_SEND_REPLY;
_TCP_RESERVE_PORT_RANGE = record
UpperRange: Word;
LowerRange: Word;
end;
{$EXTERNALSYM _TCP_RESERVE_PORT_RANGE}
TCP_RESERVE_PORT_RANGE = _TCP_RESERVE_PORT_RANGE;
{$EXTERNALSYM TCP_RESERVE_PORT_RANGE}
TTcpReservePortRange = _TCP_RESERVE_PORT_RANGE;
PTcpReservePortRange = ^TCP_RESERVE_PORT_RANGE;
const
MAX_ADAPTER_NAME = 128;
{$EXTERNALSYM MAX_ADAPTER_NAME}
type
PIP_ADAPTER_INDEX_MAP = ^IP_ADAPTER_INDEX_MAP;
{$EXTERNALSYM PIP_ADAPTER_INDEX_MAP}
_IP_ADAPTER_INDEX_MAP = record
Index: ULONG;
Name: array [0..MAX_ADAPTER_NAME - 1] of WCHAR;
end;
{$EXTERNALSYM _IP_ADAPTER_INDEX_MAP}
IP_ADAPTER_INDEX_MAP = _IP_ADAPTER_INDEX_MAP;
{$EXTERNALSYM IP_ADAPTER_INDEX_MAP}
TIpAdapterIndexMap = IP_ADAPTER_INDEX_MAP;
PIpAdapterIndexMap = PIP_ADAPTER_INDEX_MAP;
PIP_INTERFACE_INFO = ^IP_INTERFACE_INFO;
{$EXTERNALSYM PIP_INTERFACE_INFO}
_IP_INTERFACE_INFO = record
NumAdapters: Longint;
Adapter: array [0..0] of IP_ADAPTER_INDEX_MAP;
end;
{$EXTERNALSYM _IP_INTERFACE_INFO}
IP_INTERFACE_INFO = _IP_INTERFACE_INFO;
{$EXTERNALSYM IP_INTERFACE_INFO}
TIpInterfaceInfo = IP_INTERFACE_INFO;
PIpInterfaceInfo = PIP_INTERFACE_INFO;
PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS = ^IP_UNIDIRECTIONAL_ADAPTER_ADDRESS;
{$EXTERNALSYM PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS}
_IP_UNIDIRECTIONAL_ADAPTER_ADDRESS = record
NumAdapters: ULONG;
Address: array [0..0] of IPAddr;
end;
{$EXTERNALSYM _IP_UNIDIRECTIONAL_ADAPTER_ADDRESS}
IP_UNIDIRECTIONAL_ADAPTER_ADDRESS = _IP_UNIDIRECTIONAL_ADAPTER_ADDRESS;
{$EXTERNALSYM IP_UNIDIRECTIONAL_ADAPTER_ADDRESS}
TIpUnidirectionalAdapterAddress = IP_UNIDIRECTIONAL_ADAPTER_ADDRESS;
PIpUnidirectionalAdapterAddress = PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS;
PIP_ADAPTER_ORDER_MAP = ^IP_ADAPTER_ORDER_MAP;
{$EXTERNALSYM PIP_ADAPTER_ORDER_MAP}
_IP_ADAPTER_ORDER_MAP = record
NumAdapters: ULONG;
AdapterOrder: array [0..0] of ULONG;
end;
{$EXTERNALSYM _IP_ADAPTER_ORDER_MAP}
IP_ADAPTER_ORDER_MAP = _IP_ADAPTER_ORDER_MAP;
{$EXTERNALSYM IP_ADAPTER_ORDER_MAP}
TIpAdapterOrderMap = IP_ADAPTER_ORDER_MAP;
PIpAdapterOrderMap = PIP_ADAPTER_ORDER_MAP;
//
// IP_STATUS codes returned from IP APIs
//
const
IP_STATUS_BASE = 11000;
{$EXTERNALSYM IP_STATUS_BASE}
IP_SUCCESS = 0;
{$EXTERNALSYM IP_SUCCESS}
IP_BUF_TOO_SMALL = IP_STATUS_BASE + 1;
{$EXTERNALSYM IP_BUF_TOO_SMALL}
IP_DEST_NET_UNREACHABLE = IP_STATUS_BASE + 2;
{$EXTERNALSYM IP_DEST_NET_UNREACHABLE}
IP_DEST_HOST_UNREACHABLE = IP_STATUS_BASE + 3;
{$EXTERNALSYM IP_DEST_HOST_UNREACHABLE}
IP_DEST_PROT_UNREACHABLE = IP_STATUS_BASE + 4;
{$EXTERNALSYM IP_DEST_PROT_UNREACHABLE}
IP_DEST_PORT_UNREACHABLE = IP_STATUS_BASE + 5;
{$EXTERNALSYM IP_DEST_PORT_UNREACHABLE}
IP_NO_RESOURCES = IP_STATUS_BASE + 6;
{$EXTERNALSYM IP_NO_RESOURCES}
IP_BAD_OPTION = IP_STATUS_BASE + 7;
{$EXTERNALSYM IP_BAD_OPTION}
IP_HW_ERROR = IP_STATUS_BASE + 8;
{$EXTERNALSYM IP_HW_ERROR}
IP_PACKET_TOO_BIG = IP_STATUS_BASE + 9;
{$EXTERNALSYM IP_PACKET_TOO_BIG}
IP_REQ_TIMED_OUT = IP_STATUS_BASE + 10;
{$EXTERNALSYM IP_REQ_TIMED_OUT}
IP_BAD_REQ = IP_STATUS_BASE + 11;
{$EXTERNALSYM IP_BAD_REQ}
IP_BAD_ROUTE = IP_STATUS_BASE + 12;
{$EXTERNALSYM IP_BAD_ROUTE}
IP_TTL_EXPIRED_TRANSIT = IP_STATUS_BASE + 13;
{$EXTERNALSYM IP_TTL_EXPIRED_TRANSIT}
IP_TTL_EXPIRED_REASSEM = IP_STATUS_BASE + 14;
{$EXTERNALSYM IP_TTL_EXPIRED_REASSEM}
IP_PARAM_PROBLEM = IP_STATUS_BASE + 15;
{$EXTERNALSYM IP_PARAM_PROBLEM}
IP_SOURCE_QUENCH = IP_STATUS_BASE + 16;
{$EXTERNALSYM IP_SOURCE_QUENCH}
IP_OPTION_TOO_BIG = IP_STATUS_BASE + 17;
{$EXTERNALSYM IP_OPTION_TOO_BIG}
IP_BAD_DESTINATION = IP_STATUS_BASE + 18;
{$EXTERNALSYM IP_BAD_DESTINATION}
//
// The next group are status codes passed up on status indications to
// transport layer protocols.
//
IP_ADDR_DELETED = IP_STATUS_BASE + 19;
{$EXTERNALSYM IP_ADDR_DELETED}
IP_SPEC_MTU_CHANGE = IP_STATUS_BASE + 20;
{$EXTERNALSYM IP_SPEC_MTU_CHANGE}
IP_MTU_CHANGE = IP_STATUS_BASE + 21;
{$EXTERNALSYM IP_MTU_CHANGE}
IP_UNLOAD = IP_STATUS_BASE + 22;
{$EXTERNALSYM IP_UNLOAD}
IP_ADDR_ADDED = IP_STATUS_BASE + 23;
{$EXTERNALSYM IP_ADDR_ADDED}
IP_MEDIA_CONNECT = IP_STATUS_BASE + 24;
{$EXTERNALSYM IP_MEDIA_CONNECT}
IP_MEDIA_DISCONNECT = IP_STATUS_BASE + 25;
{$EXTERNALSYM IP_MEDIA_DISCONNECT}
IP_BIND_ADAPTER = IP_STATUS_BASE + 26;
{$EXTERNALSYM IP_BIND_ADAPTER}
IP_UNBIND_ADAPTER = IP_STATUS_BASE + 27;
{$EXTERNALSYM IP_UNBIND_ADAPTER}
IP_DEVICE_DOES_NOT_EXIST = IP_STATUS_BASE + 28;
{$EXTERNALSYM IP_DEVICE_DOES_NOT_EXIST}
IP_DUPLICATE_ADDRESS = IP_STATUS_BASE + 29;
{$EXTERNALSYM IP_DUPLICATE_ADDRESS}
IP_INTERFACE_METRIC_CHANGE = IP_STATUS_BASE + 30;
{$EXTERNALSYM IP_INTERFACE_METRIC_CHANGE}
IP_RECONFIG_SECFLTR = IP_STATUS_BASE + 31;
{$EXTERNALSYM IP_RECONFIG_SECFLTR}
IP_NEGOTIATING_IPSEC = IP_STATUS_BASE + 32;
{$EXTERNALSYM IP_NEGOTIATING_IPSEC}
IP_INTERFACE_WOL_CAPABILITY_CHANGE = IP_STATUS_BASE + 33;
{$EXTERNALSYM IP_INTERFACE_WOL_CAPABILITY_CHANGE}
IP_DUPLICATE_IPADD = IP_STATUS_BASE + 34;
{$EXTERNALSYM IP_DUPLICATE_IPADD}
IP_GENERAL_FAILURE = IP_STATUS_BASE + 50;
{$EXTERNALSYM IP_GENERAL_FAILURE}
MAX_IP_STATUS = IP_GENERAL_FAILURE;
{$EXTERNALSYM MAX_IP_STATUS}
IP_PENDING = IP_STATUS_BASE + 255;
{$EXTERNALSYM IP_PENDING}
//
// Values used in the IP header Flags field.
//
IP_FLAG_DF = $2; // Don't fragment this packet.
{$EXTERNALSYM IP_FLAG_DF}
//
// Supported IP Option Types.
//
// These types define the options which may be used in the OptionsData field
// of the ip_option_information structure. See RFC 791 for a complete
// description of each.
//
IP_OPT_EOL = 0; // End of list option
{$EXTERNALSYM IP_OPT_EOL}
IP_OPT_NOP = 1; // No operation
{$EXTERNALSYM IP_OPT_NOP}
IP_OPT_SECURITY = $82; // Security option
{$EXTERNALSYM IP_OPT_SECURITY}
IP_OPT_LSRR = $83; // Loose source route
{$EXTERNALSYM IP_OPT_LSRR}
IP_OPT_SSRR = $89; // Strict source route
{$EXTERNALSYM IP_OPT_SSRR}
IP_OPT_RR = $7; // Record route
{$EXTERNALSYM IP_OPT_RR}
IP_OPT_TS = $44; // Timestamp
{$EXTERNALSYM IP_OPT_TS}
IP_OPT_SID = $88; // Stream ID (obsolete)
{$EXTERNALSYM IP_OPT_SID}
IP_OPT_ROUTER_ALERT = $94; // Router Alert Option
{$EXTERNALSYM IP_OPT_ROUTER_ALERT}
MAX_OPT_SIZE = 40; // Maximum length of IP options in bytes
{$EXTERNALSYM MAX_OPT_SIZE}
// Ioctls code exposed by Memphis tcpip stack.
// For NT these ioctls are define in ntddip.h (private\inc)
IOCTL_IP_RTCHANGE_NOTIFY_REQUEST = 101;
{$EXTERNALSYM IOCTL_IP_RTCHANGE_NOTIFY_REQUEST}
IOCTL_IP_ADDCHANGE_NOTIFY_REQUEST = 102;
{$EXTERNALSYM IOCTL_IP_ADDCHANGE_NOTIFY_REQUEST}
IOCTL_ARP_SEND_REQUEST = 103;
{$EXTERNALSYM IOCTL_ARP_SEND_REQUEST}
IOCTL_IP_INTERFACE_INFO = 104;
{$EXTERNALSYM IOCTL_IP_INTERFACE_INFO}
IOCTL_IP_GET_BEST_INTERFACE = 105;
{$EXTERNALSYM IOCTL_IP_GET_BEST_INTERFACE}
IOCTL_IP_UNIDIRECTIONAL_ADAPTER_ADDRESS = 106;
{$EXTERNALSYM IOCTL_IP_UNIDIRECTIONAL_ADAPTER_ADDRESS}
implementation
end.