Rev 68 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
68 | daniel-mar | 1 | unit iphlp; |
2 | |||
3 | interface |
||
4 | |||
5 | uses |
||
6 | Windows; |
||
7 | |||
8 | const |
||
9 | MAX_INTERFACE_NAME_LEN = $100; |
||
10 | ERROR_SUCCESS = 0; |
||
11 | MAXLEN_IFDESCR = $100; |
||
12 | MAXLEN_PHYSADDR = 8; |
||
13 | |||
14 | MIB_IF_OPER_STATUS_NON_OPERATIONAL = 0 ; |
||
15 | MIB_IF_OPER_STATUS_UNREACHABLE = 1; |
||
16 | MIB_IF_OPER_STATUS_DISCONNECTED = 2; |
||
17 | MIB_IF_OPER_STATUS_CONNECTING = 3; |
||
18 | MIB_IF_OPER_STATUS_CONNECTED = 4; |
||
19 | MIB_IF_OPER_STATUS_OPERATIONAL = 5; |
||
20 | |||
21 | MIB_IF_TYPE_OTHER = 1; |
||
22 | MIB_IF_TYPE_ETHERNET = 6; |
||
23 | MIB_IF_TYPE_TOKENRING = 9; |
||
24 | MIB_IF_TYPE_FDDI = 15; |
||
25 | MIB_IF_TYPE_PPP = 23; |
||
26 | MIB_IF_TYPE_LOOPBACK = 24; |
||
27 | MIB_IF_TYPE_SLIP = 28; |
||
28 | |||
29 | MIB_IF_ADMIN_STATUS_UP = 1; |
||
30 | MIB_IF_ADMIN_STATUS_DOWN = 2; |
||
31 | MIB_IF_ADMIN_STATUS_TESTING = 3; |
||
32 | |||
33 | type |
||
34 | MIB_IFROW = Record |
||
35 | wszName: Array[0 .. (MAX_INTERFACE_NAME_LEN*2-1)] of char; |
||
36 | dwIndex: LongInt; |
||
37 | dwType: LongInt; |
||
38 | dwMtu: LongInt; |
||
39 | dwSpeed: LongInt; |
||
40 | dwPhysAddrLen: LongInt; |
||
41 | bPhysAddr: Array[0 .. (MAXLEN_PHYSADDR-1)] of Byte; |
||
42 | dwAdminStatus: LongInt; |
||
43 | dwOperStatus: LongInt; |
||
44 | dwLastChange: LongInt; |
||
45 | dwInOctets: LongInt; |
||
46 | dwInUcastPkts: LongInt; |
||
47 | dwInNUcastPkts: LongInt; |
||
48 | dwInDiscards: LongInt; |
||
49 | dwInErrors: LongInt; |
||
50 | dwInUnknownProtos: LongInt; |
||
51 | dwOutOctets: LongInt; |
||
52 | dwOutUcastPkts: LongInt; |
||
53 | dwOutNUcastPkts: LongInt; |
||
54 | dwOutDiscards: LongInt; |
||
55 | dwOutErrors: LongInt; |
||
56 | dwOutQLen: LongInt; |
||
57 | dwDescrLen: LongInt; |
||
58 | bDescr: Array[0 .. (MAXLEN_IFDESCR - 1)] of Char; |
||
59 | end; |
||
60 | |||
61 | const |
||
62 | MAX_HOSTNAME_LEN = 128; |
||
63 | MAX_DOMAIN_NAME_LEN = 128; |
||
64 | MAX_SCOPE_ID_LEN = 256; |
||
65 | |||
66 | MAX_ADAPTER_NAME_LENGTH = 256; |
||
67 | MAX_ADAPTER_DESCRIPTION_LENGTH = 128; |
||
68 | MAX_ADAPTER_ADDRESS_LENGTH = 8; |
||
69 | |||
70 | IPHelper = 'iphlpapi.dll'; |
||
71 | |||
72 | type |
||
73 | PIPAddressString = ^TIPAddressString; |
||
74 | PIPMaskString = ^TIPAddressString; |
||
75 | TIPAddressString = record |
||
76 | _String: array[0..(4 * 4) - 1] of Char; |
||
77 | end; |
||
78 | TIPMaskString = TIPAddressString; |
||
79 | PIPAddrString = ^TIPAddrString; |
||
80 | TIPAddrString = packed record |
||
81 | Next: PIPAddrString; |
||
82 | IpAddress: TIPAddressString; |
||
83 | IpMask: TIPMaskString; |
||
84 | Context: DWORD; |
||
85 | end; |
||
86 | PFixedInfo = ^TFixedInfo; |
||
87 | TFixedInfo = packed record |
||
88 | HostName: array[0..MAX_HOSTNAME_LEN + 4 - 1] of Char; |
||
89 | DomainName: array[0..MAX_DOMAIN_NAME_LEN + 4 - 1] of Char; |
||
90 | CurrentDnsServer: PIPAddrString; |
||
91 | DnsServerList: TIPAddrString; |
||
92 | NodeType: UINT; |
||
93 | ScopeId: array[0..MAX_SCOPE_ID_LEN + 4 - 1] of Char; |
||
94 | EnableRouting, |
||
95 | EnableProxy, |
||
96 | EnableDns: UINT; |
||
97 | end; |
||
98 | |||
99 | IP_ADDRESS_STRING = record |
||
100 | S: array [0..15] of Char; |
||
101 | end; |
||
102 | IP_MASK_STRING = IP_ADDRESS_STRING; |
||
103 | PIP_MASK_STRING = ^IP_MASK_STRING; |
||
104 | |||
105 | PIP_ADDR_STRING = ^IP_ADDR_STRING; |
||
106 | IP_ADDR_STRING = record |
||
107 | Next: PIP_ADDR_STRING; |
||
108 | IpAddress: IP_ADDRESS_STRING; |
||
109 | IpMask: IP_MASK_STRING; |
||
110 | Context: DWORD; |
||
111 | end; |
||
112 | |||
113 | PIP_ADAPTER_INFO = ^IP_ADAPTER_INFO; |
||
114 | IP_ADAPTER_INFO = record |
||
115 | Next: PIP_ADAPTER_INFO; |
||
116 | ComboIndex: DWORD; |
||
117 | AdapterName: array [0..MAX_ADAPTER_NAME_LENGTH + 3] of Char; |
||
118 | Description: array [0..MAX_ADAPTER_DESCRIPTION_LENGTH + 3] of Char; |
||
119 | AddressLength: UINT; |
||
120 | Address: array [0..MAX_ADAPTER_ADDRESS_LENGTH - 1] of BYTE; |
||
121 | Index: DWORD; |
||
122 | Type_: UINT; |
||
123 | DhcpEnabled: UINT; |
||
124 | CurrentIpAddress: PIP_ADDR_STRING; |
||
125 | IpAddressList: IP_ADDR_STRING; |
||
126 | GatewayList: IP_ADDR_STRING; |
||
127 | DhcpServer: IP_ADDR_STRING; |
||
128 | HaveWins: BOOL; |
||
129 | PrimaryWinsServer: IP_ADDR_STRING; |
||
130 | SecondaryWinsServer: IP_ADDR_STRING; |
||
131 | LeaseObtained: Cardinal; |
||
132 | LeaseExpires: Cardinal; |
||
133 | end; |
||
134 | |||
135 | function GetAdaptersInfo(pAdapterInfo: PIP_ADAPTER_INFO; pOutBufLen: PULONG): DWORD; stdcall; |
||
136 | function GetNetworkParams(pFixedInfo: PFixedInfo; pOutBufLen: PULONG): DWORD; stdcall; |
||
137 | function SendArp(DestIP, SrcIP: ULONG; pMacAddr: PULONG; PhyAddrLen: PULONG) : DWORD; stdcall; |
||
138 | function GetIfTable(pIfTable: Pointer; var pdwSize: LongInt; bOrder: LongInt): LongInt; stdcall; |
||
139 | |||
140 | implementation |
||
141 | |||
142 | function GetAdaptersInfo; external IPHelper Name 'GetAdaptersInfo'; |
||
143 | function GetNetworkParams; external IPHelper Name 'GetNetworkParams'; |
||
144 | function SendArp; external IPHelper name 'SendARP'; |
||
145 | function GetIfTable; external IPHelper Name 'GetIfTable'; |
||
146 | |||
147 | end. |
||
148 |