| 1 |
//! Managed Network Protocol |
| 2 |
//! |
| 3 |
//! It provides raw (unformatted) asynchronous network packet I/O services. |
| 4 |
//! These services make it possible for multiple-event-driven drivers and |
| 5 |
//! applications to access and use the system network interfaces at the same |
| 6 |
//! time. |
| 7 |
|
| 8 |
pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 9 |
0x7ab33a91, |
| 10 |
0xace5, |
| 11 |
0x4326, |
| 12 |
0xb5, |
| 13 |
0x72, |
| 14 |
&[0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16], |
| 15 |
); |
| 16 |
|
| 17 |
pub const SERVICE_BINDING_PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 18 |
0xf36ff770, |
| 19 |
0xa7e1, |
| 20 |
0x42cf, |
| 21 |
0x9e, |
| 22 |
0xd2, |
| 23 |
&[0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c], |
| 24 |
); |
| 25 |
|
| 26 |
#[repr(C)] |
| 27 |
#[derive(Clone, Copy, Debug)] |
| 28 |
pub struct ConfigData { |
| 29 |
pub received_queue_timeout_value: u32, |
| 30 |
pub transmit_queue_timeout_value: u32, |
| 31 |
pub protocol_type_filter: u16, |
| 32 |
pub enable_unicast_receive: crate::base::Boolean, |
| 33 |
pub enable_multicast_receive: crate::base::Boolean, |
| 34 |
pub enable_broadcast_receive: crate::base::Boolean, |
| 35 |
pub enable_promiscuous_receive: crate::base::Boolean, |
| 36 |
pub flush_queues_on_reset: crate::base::Boolean, |
| 37 |
pub enable_receive_timestamps: crate::base::Boolean, |
| 38 |
pub disable_background_polling: crate::base::Boolean, |
| 39 |
} |
| 40 |
|
| 41 |
#[repr(C)] |
| 42 |
#[derive(Clone, Copy)] |
| 43 |
pub struct CompletionToken { |
| 44 |
pub event: crate::base::Event, |
| 45 |
pub status: crate::base::Status, |
| 46 |
pub packet: CompletionTokenPacket, |
| 47 |
} |
| 48 |
|
| 49 |
#[repr(C)] |
| 50 |
#[derive(Clone, Copy)] |
| 51 |
pub union CompletionTokenPacket { |
| 52 |
pub rx_data: *mut ReceiveData, |
| 53 |
pub tx_data: *mut TransmitData, |
| 54 |
} |
| 55 |
|
| 56 |
#[repr(C)] |
| 57 |
#[derive(Clone, Copy, Debug)] |
| 58 |
pub struct ReceiveData { |
| 59 |
pub timestamp: crate::system::Time, |
| 60 |
pub recycle_event: crate::base::Event, |
| 61 |
pub packet_length: u32, |
| 62 |
pub header_length: u32, |
| 63 |
pub address_length: u32, |
| 64 |
pub data_length: u32, |
| 65 |
pub broadcast_flag: crate::base::Boolean, |
| 66 |
pub multicast_flag: crate::base::Boolean, |
| 67 |
pub promiscuous_flag: crate::base::Boolean, |
| 68 |
pub protocol_type: u16, |
| 69 |
pub destination_address: *mut core::ffi::c_void, |
| 70 |
pub source_address: *mut core::ffi::c_void, |
| 71 |
pub media_header: *mut core::ffi::c_void, |
| 72 |
pub packet_data: *mut core::ffi::c_void, |
| 73 |
} |
| 74 |
|
| 75 |
#[repr(C)] |
| 76 |
#[derive(Clone, Copy, Debug)] |
| 77 |
pub struct TransmitData<const N: usize = 0> { |
| 78 |
pub destination_address: *mut crate::base::MacAddress, |
| 79 |
pub source_address: *mut crate::base::MacAddress, |
| 80 |
pub protocol_type: u16, |
| 81 |
pub data_length: u32, |
| 82 |
pub header_length: u16, |
| 83 |
pub fragment_count: u16, |
| 84 |
pub fragment_table: [FragmentData; N], |
| 85 |
} |
| 86 |
|
| 87 |
#[repr(C)] |
| 88 |
#[derive(Clone, Copy, Debug)] |
| 89 |
pub struct FragmentData { |
| 90 |
pub fragment_length: u32, |
| 91 |
pub fragment_buffer: *mut core::ffi::c_void, |
| 92 |
} |
| 93 |
|
| 94 |
pub type ProtocolGetModeData = eficall! {fn( |
| 95 |
*mut Protocol, |
| 96 |
*mut ConfigData, |
| 97 |
*mut crate::protocols::simple_network::Mode, |
| 98 |
) -> crate::base::Status}; |
| 99 |
|
| 100 |
pub type ProtocolConfigure = eficall! {fn( |
| 101 |
*mut Protocol, |
| 102 |
*mut ConfigData, |
| 103 |
) -> crate::base::Status}; |
| 104 |
|
| 105 |
pub type ProtocolMcastIpToMac = eficall! {fn( |
| 106 |
*mut Protocol, |
| 107 |
crate::base::Boolean, |
| 108 |
*mut crate::base::IpAddress, |
| 109 |
*mut crate::base::MacAddress, |
| 110 |
) -> crate::base::Status}; |
| 111 |
|
| 112 |
pub type ProtocolGroups = eficall! {fn( |
| 113 |
*mut Protocol, |
| 114 |
crate::base::Boolean, |
| 115 |
*mut crate::base::MacAddress, |
| 116 |
) -> crate::base::Status}; |
| 117 |
|
| 118 |
pub type ProtocolTransmit = eficall! {fn( |
| 119 |
*mut Protocol, |
| 120 |
*mut CompletionToken, |
| 121 |
) -> crate::base::Status}; |
| 122 |
|
| 123 |
pub type ProtocolReceive = eficall! {fn( |
| 124 |
*mut Protocol, |
| 125 |
*mut CompletionToken, |
| 126 |
) -> crate::base::Status}; |
| 127 |
|
| 128 |
pub type ProtocolCancel = eficall! {fn( |
| 129 |
*mut Protocol, |
| 130 |
*mut CompletionToken, |
| 131 |
) -> crate::base::Status}; |
| 132 |
|
| 133 |
pub type ProtocolPoll = eficall! {fn( |
| 134 |
*mut Protocol, |
| 135 |
) -> crate::base::Status}; |
| 136 |
|
| 137 |
#[repr(C)] |
| 138 |
pub struct Protocol { |
| 139 |
pub get_mode_data: ProtocolGetModeData, |
| 140 |
pub configure: ProtocolConfigure, |
| 141 |
pub mcast_ip_to_mac: ProtocolMcastIpToMac, |
| 142 |
pub groups: ProtocolGroups, |
| 143 |
pub transmit: ProtocolTransmit, |
| 144 |
pub receive: ProtocolReceive, |
| 145 |
pub cancel: ProtocolCancel, |
| 146 |
pub poll: ProtocolPoll, |
| 147 |
} |