| 1 |
// Licensed under the Apache License, Version 2.0 |
| 2 |
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. |
| 4 |
// All files in the project carrying such notice may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
// #include <winapifamily.h> |
| 7 |
// #include <in6addr.h> |
| 8 |
// #include <inaddr.h> |
| 9 |
use shared::basetsd::ULONG64; |
| 10 |
use shared::in6addr::in6_addr; |
| 11 |
use shared::ntdef::{INT, PUCHAR, PVOID, UCHAR, ULONG, USHORT, WCHAR}; |
| 12 |
pub const MAX_ADAPTER_NAME: usize = 128; |
| 13 |
pub const MAX_OPT_SIZE: usize = 40; |
| 14 |
pub type IPAddr = ULONG; |
| 15 |
pub type IPMask = ULONG; |
| 16 |
pub type IP_STATUS = ULONG; |
| 17 |
pub type IPv6Addr = in6_addr; |
| 18 |
STRUCT!{struct IP_OPTION_INFORMATION { |
| 19 |
Ttl: UCHAR, |
| 20 |
Tos: UCHAR, |
| 21 |
Flags: UCHAR, |
| 22 |
OptionsSize: UCHAR, |
| 23 |
OptionsData: PUCHAR, |
| 24 |
}} |
| 25 |
pub type PIP_OPTION_INFORMATION = *mut IP_OPTION_INFORMATION; |
| 26 |
#[cfg(target_arch = "x86_64")] |
| 27 |
STRUCT!{struct IP_OPTION_INFORMATION32 { |
| 28 |
Ttl: UCHAR, |
| 29 |
Tos: UCHAR, |
| 30 |
Flags: UCHAR, |
| 31 |
OptionsSize: UCHAR, |
| 32 |
OptionsData: u32, // UCHAR * POINTER_32 |
| 33 |
}} |
| 34 |
#[cfg(target_arch = "x86_64")] |
| 35 |
pub type PIP_OPTION_INFORMATION32 = *mut IP_OPTION_INFORMATION32; |
| 36 |
STRUCT!{struct ICMP_ECHO_REPLY { |
| 37 |
Address: IPAddr, |
| 38 |
Status: ULONG, |
| 39 |
RoundTripTime: ULONG, |
| 40 |
DataSize: USHORT, |
| 41 |
Reserved: USHORT, |
| 42 |
Data: PVOID, |
| 43 |
Options: IP_OPTION_INFORMATION, |
| 44 |
}} |
| 45 |
pub type PICMP_ECHO_REPLY = *mut ICMP_ECHO_REPLY; |
| 46 |
#[cfg(target_arch = "x86_64")] |
| 47 |
STRUCT!{struct ICMP_ECHO_REPLY32 { |
| 48 |
Address: IPAddr, |
| 49 |
Status: ULONG, |
| 50 |
RoundTripTime: ULONG, |
| 51 |
DataSize: USHORT, |
| 52 |
Reserved: USHORT, |
| 53 |
Data: u32, // VOID * POINTER_32 |
| 54 |
Options: IP_OPTION_INFORMATION32, |
| 55 |
}} |
| 56 |
#[cfg(target_arch = "x86_64")] |
| 57 |
pub type PICMP_ECHO_REPLY32 = *mut ICMP_ECHO_REPLY32; |
| 58 |
STRUCT!{#[repr(packed)] struct IPV6_ADDRESS_EX { |
| 59 |
sin6_port: USHORT, |
| 60 |
sin6_flowinfo: ULONG, |
| 61 |
sin6_addr: [USHORT; 8], |
| 62 |
sin6_scope_id: ULONG, |
| 63 |
}} |
| 64 |
pub type PIPV6_ADDRESS_EX = *mut IPV6_ADDRESS_EX; |
| 65 |
// #include <packoff.h> |
| 66 |
STRUCT!{struct ICMPV6_ECHO_REPLY_LH { |
| 67 |
Address: IPV6_ADDRESS_EX, |
| 68 |
Status: ULONG, |
| 69 |
RoundTripTime: INT, |
| 70 |
}} |
| 71 |
pub type PICMPV6_ECHO_REPLY_LH = *mut ICMPV6_ECHO_REPLY_LH; |
| 72 |
pub type ICMPV6_ECHO_REPLY = ICMPV6_ECHO_REPLY_LH; |
| 73 |
pub type PICMPV6_ECHO_REPLY = *mut ICMPV6_ECHO_REPLY; |
| 74 |
// #endif |
| 75 |
STRUCT!{struct ARP_SEND_REPLY { |
| 76 |
DestAddress: IPAddr, |
| 77 |
SrcAddress: IPAddr, |
| 78 |
}} |
| 79 |
pub type PARP_SEND_REPLY = *mut ARP_SEND_REPLY; |
| 80 |
STRUCT!{struct TCP_RESERVE_PORT_RANGE { |
| 81 |
UpperRange: USHORT, |
| 82 |
LowerRange: USHORT, |
| 83 |
}} |
| 84 |
pub type PTCP_RESERVE_PORT_RANGE = *mut TCP_RESERVE_PORT_RANGE; |
| 85 |
STRUCT!{struct IP_ADAPTER_INDEX_MAP { |
| 86 |
Index: ULONG, |
| 87 |
Name: [WCHAR; MAX_ADAPTER_NAME], |
| 88 |
}} |
| 89 |
pub type PIP_ADAPTER_INDEX_MAP = *mut IP_ADAPTER_INDEX_MAP; |
| 90 |
STRUCT!{struct IP_INTERFACE_INFO { |
| 91 |
NumAdapters: ULONG, |
| 92 |
Adapter: [IP_ADAPTER_INDEX_MAP; 1], |
| 93 |
}} |
| 94 |
pub type PIP_INTERFACE_INFO = *mut IP_INTERFACE_INFO; |
| 95 |
STRUCT!{struct IP_UNIDIRECTIONAL_ADAPTER_ADDRESS { |
| 96 |
NumAdapters: ULONG, |
| 97 |
Address: [IPAddr; 1], |
| 98 |
}} |
| 99 |
pub type PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS = *mut IP_UNIDIRECTIONAL_ADAPTER_ADDRESS; |
| 100 |
STRUCT!{struct IP_ADAPTER_ORDER_MAP { |
| 101 |
NumAdapters: ULONG, |
| 102 |
AdapterOrder: [ULONG; 1], |
| 103 |
}} |
| 104 |
pub type PIP_ADAPTER_ORDER_MAP = *mut IP_ADAPTER_ORDER_MAP; |
| 105 |
STRUCT!{struct IP_MCAST_COUNTER_INFO { |
| 106 |
InMcastOctets: ULONG64, |
| 107 |
OutMcastOctets: ULONG64, |
| 108 |
InMcastPkts: ULONG64, |
| 109 |
OutMcastPkts: ULONG64, |
| 110 |
}} |
| 111 |
pub type PIP_MCAST_COUNTER_INFO = *mut IP_MCAST_COUNTER_INFO; |
| 112 |
// IP_STATUS codes returned from IP APIs |
| 113 |
pub const IP_STATUS_BASE: IP_STATUS = 11000; |
| 114 |
pub const IP_SUCCESS: IP_STATUS = 0; |
| 115 |
pub const IP_BUF_TOO_SMALL: IP_STATUS = IP_STATUS_BASE + 1; |
| 116 |
pub const IP_DEST_NET_UNREACHABLE: IP_STATUS = IP_STATUS_BASE + 2; |
| 117 |
pub const IP_DEST_HOST_UNREACHABLE: IP_STATUS = IP_STATUS_BASE + 3; |
| 118 |
pub const IP_DEST_PROT_UNREACHABLE: IP_STATUS = IP_STATUS_BASE + 4; |
| 119 |
pub const IP_DEST_PORT_UNREACHABLE: IP_STATUS = IP_STATUS_BASE + 5; |
| 120 |
pub const IP_NO_RESOURCES: IP_STATUS = IP_STATUS_BASE + 6; |
| 121 |
pub const IP_BAD_OPTION: IP_STATUS = IP_STATUS_BASE + 7; |
| 122 |
pub const IP_HW_ERROR: IP_STATUS = IP_STATUS_BASE + 8; |
| 123 |
pub const IP_PACKET_TOO_BIG: IP_STATUS = IP_STATUS_BASE + 9; |
| 124 |
pub const IP_REQ_TIMED_OUT: IP_STATUS = IP_STATUS_BASE + 10; |
| 125 |
pub const IP_BAD_REQ: IP_STATUS = IP_STATUS_BASE + 11; |
| 126 |
pub const IP_BAD_ROUTE: IP_STATUS = IP_STATUS_BASE + 12; |
| 127 |
pub const IP_TTL_EXPIRED_TRANSIT: IP_STATUS = IP_STATUS_BASE + 13; |
| 128 |
pub const IP_TTL_EXPIRED_REASSEM: IP_STATUS = IP_STATUS_BASE + 14; |
| 129 |
pub const IP_PARAM_PROBLEM: IP_STATUS = IP_STATUS_BASE + 15; |
| 130 |
pub const IP_SOURCE_QUENCH: IP_STATUS = IP_STATUS_BASE + 16; |
| 131 |
pub const IP_OPTION_TOO_BIG: IP_STATUS = IP_STATUS_BASE + 17; |
| 132 |
pub const IP_BAD_DESTINATION: IP_STATUS = IP_STATUS_BASE + 18; |
| 133 |
pub const IP_DEST_NO_ROUTE: IP_STATUS = IP_STATUS_BASE + 2; |
| 134 |
pub const IP_DEST_ADDR_UNREACHABLE: IP_STATUS = IP_STATUS_BASE + 3; |
| 135 |
pub const IP_DEST_PROHIBITED: IP_STATUS = IP_STATUS_BASE + 4; |
| 136 |
pub const IP_HOP_LIMIT_EXCEEDED: IP_STATUS = IP_STATUS_BASE + 13; |
| 137 |
pub const IP_REASSEMBLY_TIME_EXCEEDED: IP_STATUS = IP_STATUS_BASE + 14; |
| 138 |
pub const IP_PARAMETER_PROBLEM: IP_STATUS = IP_STATUS_BASE + 15; |
| 139 |
pub const IP_DEST_UNREACHABLE: IP_STATUS = IP_STATUS_BASE + 40; |
| 140 |
pub const IP_TIME_EXCEEDED: IP_STATUS = IP_STATUS_BASE + 41; |
| 141 |
pub const IP_BAD_HEADER: IP_STATUS = IP_STATUS_BASE + 42; |
| 142 |
pub const IP_UNRECOGNIZED_NEXT_HEADER: IP_STATUS = IP_STATUS_BASE + 43; |
| 143 |
pub const IP_ICMP_ERROR: IP_STATUS = IP_STATUS_BASE + 44; |
| 144 |
pub const IP_DEST_SCOPE_MISMATCH: IP_STATUS = IP_STATUS_BASE + 45; |
| 145 |
pub const IP_ADDR_DELETED: IP_STATUS = IP_STATUS_BASE + 19; |
| 146 |
pub const IP_SPEC_MTU_CHANGE: IP_STATUS = IP_STATUS_BASE + 20; |
| 147 |
pub const IP_MTU_CHANGE: IP_STATUS = IP_STATUS_BASE + 21; |
| 148 |
pub const IP_UNLOAD: IP_STATUS = IP_STATUS_BASE + 22; |
| 149 |
pub const IP_ADDR_ADDED: IP_STATUS = IP_STATUS_BASE + 23; |
| 150 |
pub const IP_MEDIA_CONNECT: IP_STATUS = IP_STATUS_BASE + 24; |
| 151 |
pub const IP_MEDIA_DISCONNECT: IP_STATUS = IP_STATUS_BASE + 25; |
| 152 |
pub const IP_BIND_ADAPTER: IP_STATUS = IP_STATUS_BASE + 26; |
| 153 |
pub const IP_UNBIND_ADAPTER: IP_STATUS = IP_STATUS_BASE + 27; |
| 154 |
pub const IP_DEVICE_DOES_NOT_EXIST: IP_STATUS = IP_STATUS_BASE + 28; |
| 155 |
pub const IP_DUPLICATE_ADDRESS: IP_STATUS = IP_STATUS_BASE + 29; |
| 156 |
pub const IP_INTERFACE_METRIC_CHANGE: IP_STATUS = IP_STATUS_BASE + 30; |
| 157 |
pub const IP_RECONFIG_SECFLTR: IP_STATUS = IP_STATUS_BASE + 31; |
| 158 |
pub const IP_NEGOTIATING_IPSEC: IP_STATUS = IP_STATUS_BASE + 32; |
| 159 |
pub const IP_INTERFACE_WOL_CAPABILITY_CHANGE: IP_STATUS = IP_STATUS_BASE + 33; |
| 160 |
pub const IP_DUPLICATE_IPADD: IP_STATUS = IP_STATUS_BASE + 34; |
| 161 |
pub const IP_GENERAL_FAILURE: IP_STATUS = IP_STATUS_BASE + 50; |
| 162 |
pub const MAX_IP_STATUS: IP_STATUS = IP_GENERAL_FAILURE; |
| 163 |
pub const IP_PENDING: IP_STATUS = IP_STATUS_BASE + 255; |
| 164 |
pub const IP_FLAG_REVERSE: UCHAR = 0x1; |
| 165 |
pub const IP_FLAG_DF: UCHAR = 0x2; |
| 166 |
pub const IP_OPT_EOL: u8 = 0; |
| 167 |
pub const IP_OPT_NOP: u8 = 1; |
| 168 |
pub const IP_OPT_SECURITY: u8 = 0x82; |
| 169 |
pub const IP_OPT_LSRR: u8 = 0x83; |
| 170 |
pub const IP_OPT_SSRR: u8 = 0x89; |
| 171 |
pub const IP_OPT_RR: u8 = 0x7; |
| 172 |
pub const IP_OPT_TS: u8 = 0x44; |
| 173 |
pub const IP_OPT_SID: u8 = 0x88; |
| 174 |
pub const IP_OPT_ROUTER_ALERT: u8 = 0x94; |