| 1 |
//! IPv6 Protocol |
| 2 |
//! |
| 3 |
//! It implements a simple packet-oriented interface that can be used by |
| 4 |
//! drivers, daemons, and applications to transmit and receive network packets. |
| 5 |
|
| 6 |
pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 7 |
0x2c8759d5, |
| 8 |
0x5c2d, |
| 9 |
0x66ef, |
| 10 |
0x92, |
| 11 |
0x5f, |
| 12 |
&[0xb6, 0x6c, 0x10, 0x19, 0x57, 0xe2], |
| 13 |
); |
| 14 |
|
| 15 |
pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 16 |
0xec835dd3, |
| 17 |
0xfe0f, |
| 18 |
0x617b, |
| 19 |
0xa6, |
| 20 |
0x21, |
| 21 |
&[0xb3, 0x50, 0xc3, 0xe1, 0x33, 0x88], |
| 22 |
); |
| 23 |
|
| 24 |
#[repr(C)] |
| 25 |
#[derive(Clone, Copy, Debug)] |
| 26 |
pub struct ModeData { |
| 27 |
pub is_started: crate::base::Boolean, |
| 28 |
pub max_packet_size: u32, |
| 29 |
pub config_data: ConfigData, |
| 30 |
pub is_configured: crate::base::Boolean, |
| 31 |
pub address_count: u32, |
| 32 |
pub address_list: *mut AddressInfo, |
| 33 |
pub group_count: u32, |
| 34 |
pub group_table: *mut crate::base::Ipv6Address, |
| 35 |
pub route_count: u32, |
| 36 |
pub route_table: *mut RouteTable, |
| 37 |
pub neighbor_count: u32, |
| 38 |
pub neighbor_cache: *mut NeighborCache, |
| 39 |
pub prefix_count: u32, |
| 40 |
pub prefix_table: *mut AddressInfo, |
| 41 |
pub icmp_type_count: u32, |
| 42 |
pub icmp_type_list: *mut IcmpType, |
| 43 |
} |
| 44 |
|
| 45 |
#[repr(C)] |
| 46 |
#[derive(Clone, Copy, Debug)] |
| 47 |
pub struct ConfigData { |
| 48 |
pub default_protocol: u8, |
| 49 |
pub accept_any_protocol: crate::base::Boolean, |
| 50 |
pub accept_icmp_errors: crate::base::Boolean, |
| 51 |
pub accept_promiscuous: crate::base::Boolean, |
| 52 |
pub destination_address: crate::base::Ipv6Address, |
| 53 |
pub station_address: crate::base::Ipv6Address, |
| 54 |
pub traffic_class: u8, |
| 55 |
pub hop_limit: u8, |
| 56 |
pub flow_lable: u32, |
| 57 |
pub receive_timeout: u32, |
| 58 |
pub transmit_timeout: u32, |
| 59 |
} |
| 60 |
|
| 61 |
#[repr(C)] |
| 62 |
#[derive(Clone, Copy, Debug)] |
| 63 |
pub struct AddressInfo { |
| 64 |
pub address: crate::base::Ipv6Address, |
| 65 |
pub prefix_length: u8, |
| 66 |
} |
| 67 |
|
| 68 |
#[repr(C)] |
| 69 |
#[derive(Clone, Copy, Debug)] |
| 70 |
pub struct RouteTable { |
| 71 |
pub gateway: crate::base::Ipv6Address, |
| 72 |
pub destination: crate::base::Ipv6Address, |
| 73 |
pub prefix_length: u8, |
| 74 |
} |
| 75 |
|
| 76 |
pub type NeighborState = u32; |
| 77 |
|
| 78 |
pub const NEIGHBOR_IN_COMPLETE: NeighborState = 0x00000000; |
| 79 |
pub const NEIGHBOR_REACHABLE: NeighborState = 0x00000001; |
| 80 |
pub const NEIGHBOR_STATE: NeighborState = 0x00000002; |
| 81 |
pub const NEIGHBOR_DELAY: NeighborState = 0x00000003; |
| 82 |
pub const NEIGHBOR_PROBE: NeighborState = 0x00000004; |
| 83 |
|
| 84 |
#[repr(C)] |
| 85 |
#[derive(Clone, Copy, Debug)] |
| 86 |
pub struct NeighborCache { |
| 87 |
pub neighbor: crate::base::Ipv6Address, |
| 88 |
pub link_address: crate::base::MacAddress, |
| 89 |
pub state: NeighborState, |
| 90 |
} |
| 91 |
|
| 92 |
#[repr(C)] |
| 93 |
#[derive(Clone, Copy, Debug)] |
| 94 |
pub struct IcmpType { |
| 95 |
pub r#type: u8, |
| 96 |
pub code: u8, |
| 97 |
} |
| 98 |
|
| 99 |
pub const ICMP_V6_DEST_UNREACHABLE: u8 = 0x01; |
| 100 |
pub const ICMP_V6_PACKET_TOO_BIG: u8 = 0x02; |
| 101 |
pub const ICMP_V6_TIME_EXCEEDED: u8 = 0x03; |
| 102 |
pub const ICMP_V6_PARAMETER_PROBLEM: u8 = 0x04; |
| 103 |
|
| 104 |
pub const ICMP_V6_ECHO_REQUEST: u8 = 0x80; |
| 105 |
pub const ICMP_V6_ECHO_REPLY: u8 = 0x81; |
| 106 |
pub const ICMP_V6_LISTENER_QUERY: u8 = 0x82; |
| 107 |
pub const ICMP_V6_LISTENER_REPORT: u8 = 0x83; |
| 108 |
pub const ICMP_V6_LISTENER_DONE: u8 = 0x84; |
| 109 |
pub const ICMP_V6_ROUTER_SOLICIT: u8 = 0x85; |
| 110 |
pub const ICMP_V6_ROUTER_ADVERTISE: u8 = 0x86; |
| 111 |
pub const ICMP_V6_NEIGHBOR_SOLICIT: u8 = 0x87; |
| 112 |
pub const ICMP_V6_NEIGHBOR_ADVERTISE: u8 = 0x88; |
| 113 |
pub const ICMP_V6_REDIRECT: u8 = 0x89; |
| 114 |
pub const ICMP_V6_LISTENER_REPORT_2: u8 = 0x8f; |
| 115 |
|
| 116 |
pub const ICMP_V6_NO_ROUTE_TO_DEST: u8 = 0x00; |
| 117 |
pub const ICMP_V6_COMM_PROHIBITED: u8 = 0x01; |
| 118 |
pub const ICMP_V6_BEYOND_SCOPE: u8 = 0x02; |
| 119 |
pub const ICMP_V6_ADDR_UNREACHABLE: u8 = 0x03; |
| 120 |
pub const ICMP_V6_PORT_UNREACHABLE: u8 = 0x04; |
| 121 |
pub const ICMP_V6_SOURCE_ADDR_FAILED: u8 = 0x05; |
| 122 |
pub const ICMP_V6_ROUTE_REJECTED: u8 = 0x06; |
| 123 |
|
| 124 |
pub const ICMP_V6_TIMEOUT_HOP_LIMIT: u8 = 0x00; |
| 125 |
pub const ICMP_V6_TIMEOUT_REASSEMBLE: u8 = 0x01; |
| 126 |
|
| 127 |
pub const ICMP_V6_ERRONEOUS_HEADER: u8 = 0x00; |
| 128 |
pub const ICMP_V6_UNRECOGNIZE_NEXT_HDR: u8 = 0x01; |
| 129 |
pub const ICMP_V6_UNRECOGNIZE_OPTION: u8 = 0x02; |
| 130 |
|
| 131 |
#[repr(C)] |
| 132 |
#[derive(Clone, Copy)] |
| 133 |
pub struct CompletionToken { |
| 134 |
pub event: crate::base::Event, |
| 135 |
pub status: crate::base::Status, |
| 136 |
pub packet: CompletionTokenPacket, |
| 137 |
} |
| 138 |
|
| 139 |
#[repr(C)] |
| 140 |
#[derive(Clone, Copy)] |
| 141 |
pub union CompletionTokenPacket { |
| 142 |
pub rx_data: *mut ReceiveData, |
| 143 |
pub tx_data: *mut TransmitData, |
| 144 |
} |
| 145 |
|
| 146 |
#[repr(C)] |
| 147 |
#[derive(Clone, Copy, Debug)] |
| 148 |
pub struct ReceiveData<const N: usize = 0> { |
| 149 |
pub time_stamp: crate::system::Time, |
| 150 |
pub recycle_signal: crate::base::Event, |
| 151 |
pub header_length: u32, |
| 152 |
pub header: *mut Header, |
| 153 |
pub data_length: u32, |
| 154 |
pub fragment_count: u32, |
| 155 |
pub fragment_table: [FragmentData; N], |
| 156 |
} |
| 157 |
|
| 158 |
#[repr(C)] |
| 159 |
#[derive(Clone, Copy, Debug)] |
| 160 |
pub struct Header { |
| 161 |
pub traffic_class_h_version: u8, |
| 162 |
pub flow_label_h_traffic_class_l: u8, |
| 163 |
pub flow_label_l: u16, |
| 164 |
pub payload_length: u16, |
| 165 |
pub next_header: u8, |
| 166 |
pub hop_limit: u8, |
| 167 |
pub source_address: crate::base::Ipv6Address, |
| 168 |
pub destination_address: crate::base::Ipv6Address, |
| 169 |
} |
| 170 |
|
| 171 |
#[repr(C)] |
| 172 |
#[derive(Clone, Copy, Debug)] |
| 173 |
pub struct FragmentData { |
| 174 |
pub fragment_length: u32, |
| 175 |
pub fragment_buffer: *mut core::ffi::c_void, |
| 176 |
} |
| 177 |
|
| 178 |
#[repr(C)] |
| 179 |
#[derive(Clone, Copy, Debug)] |
| 180 |
pub struct TransmitData<const N: usize = 0> { |
| 181 |
pub destination_address: *mut crate::base::Ipv6Address, |
| 182 |
pub override_data: *mut OverrideData, |
| 183 |
pub ext_hdrs_length: u32, |
| 184 |
pub ext_hdrs: *mut core::ffi::c_void, |
| 185 |
pub next_header: u8, |
| 186 |
pub data_length: u32, |
| 187 |
pub fragment_count: u32, |
| 188 |
pub fragment_table: [FragmentData; N], |
| 189 |
} |
| 190 |
|
| 191 |
#[repr(C)] |
| 192 |
#[derive(Clone, Copy, Debug)] |
| 193 |
pub struct OverrideData { |
| 194 |
pub protocol: u8, |
| 195 |
pub hop_limit: u8, |
| 196 |
pub flow_label: u32, |
| 197 |
} |
| 198 |
|
| 199 |
pub type ProtocolGetModeData = eficall! {fn( |
| 200 |
*mut Protocol, |
| 201 |
*mut ModeData, |
| 202 |
*mut crate::protocols::managed_network::ConfigData, |
| 203 |
*mut crate::protocols::simple_network::Mode, |
| 204 |
) -> crate::base::Status}; |
| 205 |
|
| 206 |
pub type ProtocolConfigure = eficall! {fn( |
| 207 |
*mut Protocol, |
| 208 |
*mut ConfigData, |
| 209 |
) -> crate::base::Status}; |
| 210 |
|
| 211 |
pub type ProtocolGroups = eficall! {fn( |
| 212 |
*mut Protocol, |
| 213 |
crate::base::Boolean, |
| 214 |
*mut crate::base::Ipv6Address, |
| 215 |
) -> crate::base::Status}; |
| 216 |
|
| 217 |
pub type ProtocolRoutes = eficall! {fn( |
| 218 |
*mut Protocol, |
| 219 |
crate::base::Boolean, |
| 220 |
*mut crate::base::Ipv6Address, |
| 221 |
u8, |
| 222 |
*mut crate::base::Ipv6Address, |
| 223 |
) -> crate::base::Status}; |
| 224 |
|
| 225 |
pub type ProtocolNeighbors = eficall! {fn( |
| 226 |
*mut Protocol, |
| 227 |
crate::base::Boolean, |
| 228 |
*mut crate::base::Ipv6Address, |
| 229 |
*mut crate::base::MacAddress, |
| 230 |
u32, |
| 231 |
crate::base::Boolean, |
| 232 |
) -> crate::base::Status}; |
| 233 |
|
| 234 |
pub type ProtocolTransmit = eficall! {fn( |
| 235 |
*mut Protocol, |
| 236 |
*mut CompletionToken, |
| 237 |
) -> crate::base::Status}; |
| 238 |
|
| 239 |
pub type ProtocolReceive = eficall! {fn( |
| 240 |
*mut Protocol, |
| 241 |
*mut CompletionToken, |
| 242 |
) -> crate::base::Status}; |
| 243 |
|
| 244 |
pub type ProtocolCancel = eficall! {fn( |
| 245 |
*mut Protocol, |
| 246 |
*mut CompletionToken, |
| 247 |
) -> crate::base::Status}; |
| 248 |
|
| 249 |
pub type ProtocolPoll = eficall! {fn( |
| 250 |
*mut Protocol, |
| 251 |
) -> crate::base::Status}; |
| 252 |
|
| 253 |
#[repr(C)] |
| 254 |
pub struct Protocol { |
| 255 |
pub get_mode_data: ProtocolGetModeData, |
| 256 |
pub configure: ProtocolConfigure, |
| 257 |
pub groups: ProtocolGroups, |
| 258 |
pub routes: ProtocolRoutes, |
| 259 |
pub neighbors: ProtocolNeighbors, |
| 260 |
pub transmit: ProtocolTransmit, |
| 261 |
pub receive: ProtocolReceive, |
| 262 |
pub cancel: ProtocolCancel, |
| 263 |
pub poll: ProtocolPoll, |
| 264 |
} |