| 1 |
//! Simple Network Protocol |
| 2 |
//! |
| 3 |
//! The simple network protcol provides services to initialize a network interface, transmit |
| 4 |
//! packets, receive packets, and close a network interface. |
| 5 |
|
| 6 |
pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 7 |
0xa19832b9, |
| 8 |
0xac25, |
| 9 |
0x11d3, |
| 10 |
0x9a, |
| 11 |
0x2d, |
| 12 |
&[0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d], |
| 13 |
); |
| 14 |
|
| 15 |
pub const REVISION: u64 = 0x0000000000010000u64; |
| 16 |
|
| 17 |
pub const MAX_MCAST_FILTER_CNT: usize = 16; |
| 18 |
|
| 19 |
pub const RECEIVE_UNICAST: u32 = 0x00000001u32; |
| 20 |
pub const RECEIVE_MULTICAST: u32 = 0x00000002u32; |
| 21 |
pub const RECEIVE_BROADCAST: u32 = 0x00000004u32; |
| 22 |
pub const RECEIVE_PROMISCUOUS: u32 = 0x00000008u32; |
| 23 |
pub const RECEIVE_PROMISCUOUS_MULTICAST: u32 = 0x00000010u32; |
| 24 |
|
| 25 |
pub const RECEIVE_INTERRUPT: u32 = 0x00000001u32; |
| 26 |
pub const TRANSMIT_INTERRUPT: u32 = 0x00000002u32; |
| 27 |
pub const COMMAND_INTERRUPT: u32 = 0x00000004u32; |
| 28 |
pub const SOFTWARE_INTERRUPT: u32 = 0x000000008u32; |
| 29 |
|
| 30 |
#[repr(C)] |
| 31 |
#[derive(Clone, Copy, Debug)] |
| 32 |
pub struct Mode { |
| 33 |
pub state: u32, |
| 34 |
pub hw_address_size: u32, |
| 35 |
pub media_header_size: u32, |
| 36 |
pub max_packet_size: u32, |
| 37 |
pub nvram_size: u32, |
| 38 |
pub nvram_access_size: u32, |
| 39 |
pub receive_filter_mask: u32, |
| 40 |
pub receive_filter_setting: u32, |
| 41 |
pub max_mcast_filter_count: u32, |
| 42 |
pub mcast_filter_count: u32, |
| 43 |
pub mcast_filter: [crate::base::MacAddress; MAX_MCAST_FILTER_CNT], |
| 44 |
pub current_address: crate::base::MacAddress, |
| 45 |
pub broadcast_address: crate::base::MacAddress, |
| 46 |
pub permanent_address: crate::base::MacAddress, |
| 47 |
pub if_type: u8, |
| 48 |
pub mac_address_changeable: crate::base::Boolean, |
| 49 |
pub multiple_tx_supported: crate::base::Boolean, |
| 50 |
pub media_present_supported: crate::base::Boolean, |
| 51 |
pub media_present: crate::base::Boolean, |
| 52 |
} |
| 53 |
|
| 54 |
pub type State = u32; |
| 55 |
|
| 56 |
pub const STOPPED: State = 0x00000000; |
| 57 |
pub const STARTED: State = 0x00000001; |
| 58 |
pub const INITIALIZED: State = 0x00000002; |
| 59 |
pub const MAX_STATE: State = 0x00000003; |
| 60 |
|
| 61 |
#[repr(C)] |
| 62 |
#[derive(Clone, Copy, Debug)] |
| 63 |
pub struct Statistics { |
| 64 |
pub rx_total_frames: u64, |
| 65 |
pub rx_good_frames: u64, |
| 66 |
pub rx_undersize_frames: u64, |
| 67 |
pub rx_oversize_frames: u64, |
| 68 |
pub rx_dropped_frames: u64, |
| 69 |
pub rx_unicast_frames: u64, |
| 70 |
pub rx_broadcast_frames: u64, |
| 71 |
pub rx_multicast_frames: u64, |
| 72 |
pub rx_crc_error_frames: u64, |
| 73 |
pub rx_total_bytes: u64, |
| 74 |
pub tx_total_frames: u64, |
| 75 |
pub tx_good_frames: u64, |
| 76 |
pub tx_undersize_frames: u64, |
| 77 |
pub tx_oversize_frames: u64, |
| 78 |
pub tx_dropped_frames: u64, |
| 79 |
pub tx_unicast_frames: u64, |
| 80 |
pub tx_broadcast_frames: u64, |
| 81 |
pub tx_multicast_frames: u64, |
| 82 |
pub tx_crc_error_frames: u64, |
| 83 |
pub tx_total_bytes: u64, |
| 84 |
pub collisions: u64, |
| 85 |
pub unsupported_protocol: u64, |
| 86 |
pub rx_duplicated_frames: u64, |
| 87 |
pub rx_decrypt_error_frames: u64, |
| 88 |
pub tx_error_frames: u64, |
| 89 |
pub tx_retry_frames: u64, |
| 90 |
} |
| 91 |
|
| 92 |
pub type ProtocolStart = eficall! {fn( |
| 93 |
*mut Protocol, |
| 94 |
) -> crate::base::Status}; |
| 95 |
|
| 96 |
pub type ProtocolStop = eficall! {fn( |
| 97 |
*mut Protocol, |
| 98 |
) -> crate::base::Status}; |
| 99 |
|
| 100 |
pub type ProtocolInitialize = eficall! {fn( |
| 101 |
*mut Protocol, |
| 102 |
usize, |
| 103 |
usize, |
| 104 |
) -> crate::base::Status}; |
| 105 |
|
| 106 |
pub type ProtocolReset = eficall! {fn( |
| 107 |
*mut Protocol, |
| 108 |
crate::base::Boolean, |
| 109 |
) -> crate::base::Status}; |
| 110 |
|
| 111 |
pub type ProtocolShutdown = eficall! {fn( |
| 112 |
*mut Protocol, |
| 113 |
) -> crate::base::Status}; |
| 114 |
|
| 115 |
pub type ProtocolReceiveFilters = eficall! {fn( |
| 116 |
*mut Protocol, |
| 117 |
u32, |
| 118 |
u32, |
| 119 |
crate::base::Boolean, |
| 120 |
usize, |
| 121 |
*mut crate::base::MacAddress, |
| 122 |
) -> crate::base::Status}; |
| 123 |
|
| 124 |
pub type ProtocolStationAddress = eficall! {fn( |
| 125 |
*mut Protocol, |
| 126 |
crate::base::Boolean, |
| 127 |
*mut crate::base::MacAddress, |
| 128 |
) -> crate::base::Status}; |
| 129 |
|
| 130 |
pub type ProtocolStatistics = eficall! {fn( |
| 131 |
*mut Protocol, |
| 132 |
crate::base::Boolean, |
| 133 |
*mut usize, |
| 134 |
*mut Statistics, |
| 135 |
) -> crate::base::Status}; |
| 136 |
|
| 137 |
pub type ProtocolMcastIpToMac = eficall! {fn( |
| 138 |
*mut Protocol, |
| 139 |
crate::base::Boolean, |
| 140 |
*mut crate::base::IpAddress, |
| 141 |
*mut crate::base::MacAddress, |
| 142 |
) -> crate::base::Status}; |
| 143 |
|
| 144 |
pub type ProtocolNvData = eficall! {fn( |
| 145 |
*mut Protocol, |
| 146 |
crate::base::Boolean, |
| 147 |
usize, |
| 148 |
usize, |
| 149 |
*mut core::ffi::c_void, |
| 150 |
) -> crate::base::Status}; |
| 151 |
|
| 152 |
pub type ProtocolGetStatus = eficall! {fn( |
| 153 |
*mut Protocol, |
| 154 |
*mut u32, |
| 155 |
*mut *mut core::ffi::c_void, |
| 156 |
) -> crate::base::Status}; |
| 157 |
|
| 158 |
pub type ProtocolTransmit = eficall! {fn( |
| 159 |
*mut Protocol, |
| 160 |
usize, |
| 161 |
usize, |
| 162 |
*mut core::ffi::c_void, |
| 163 |
*mut crate::base::MacAddress, |
| 164 |
*mut crate::base::MacAddress, |
| 165 |
*mut u16, |
| 166 |
) -> crate::base::Status}; |
| 167 |
|
| 168 |
pub type ProtocolReceive = eficall! {fn( |
| 169 |
*mut Protocol, |
| 170 |
*mut usize, |
| 171 |
*mut usize, |
| 172 |
*mut core::ffi::c_void, |
| 173 |
*mut crate::base::MacAddress, |
| 174 |
*mut crate::base::MacAddress, |
| 175 |
*mut u16, |
| 176 |
) -> crate::base::Status}; |
| 177 |
|
| 178 |
#[repr(C)] |
| 179 |
pub struct Protocol { |
| 180 |
pub revision: u64, |
| 181 |
pub start: ProtocolStart, |
| 182 |
pub stop: ProtocolStop, |
| 183 |
pub initialize: ProtocolInitialize, |
| 184 |
pub reset: ProtocolReset, |
| 185 |
pub shutdown: ProtocolShutdown, |
| 186 |
pub receive_filters: ProtocolReceiveFilters, |
| 187 |
pub station_address: ProtocolStationAddress, |
| 188 |
pub statistics: ProtocolStatistics, |
| 189 |
pub mcast_ip_to_mac: ProtocolMcastIpToMac, |
| 190 |
pub nv_data: ProtocolNvData, |
| 191 |
pub get_status: ProtocolGetStatus, |
| 192 |
pub transmit: ProtocolTransmit, |
| 193 |
pub receive: ProtocolReceive, |
| 194 |
pub wait_for_packet: crate::base::Event, |
| 195 |
pub mode: *mut Mode, |
| 196 |
} |