1
+ //! Simple Network Protocol
2
+
3
+ use core:: ffi:: c_void;
4
+ use crate :: Status ;
5
+ use crate :: data_types:: Event ;
6
+ use super :: { IpAddress , MacAddress } ;
7
+
8
+ /// The Simple Network Protocol
9
+ #[ repr( C ) ]
10
+ #[ unsafe_guid( "a19832b9-ac25-11d3-9a2d-0090273fc14d" ) ]
11
+ #[ derive( Protocol ) ]
12
+ pub struct SimpleNetwork {
13
+ revision : u64 ,
14
+ start : extern "efiapi" fn ( this : & Self ) -> Status ,
15
+ stop : extern "efiapi" fn ( this : & Self ) -> Status ,
16
+ initialize : extern "efiapi" fn (
17
+ this : & Self ,
18
+ extra_recv_buffer_size : Option < usize > ,
19
+ extra_transmit_buffer_size : Option < usize >
20
+ ) -> Status ,
21
+ reset : extern "efiapi" fn ( this : & Self , extended_verification : bool ) -> Status ,
22
+ shutdown : extern "efiapi" fn ( this : & Self ) -> Status ,
23
+ receive_filters : extern "efiapi" fn (
24
+ this : & Self ,
25
+ enable : u32 ,
26
+ disable : u32 ,
27
+ reset_mcast_filter : bool ,
28
+ mcast_filter_count : Option < usize > ,
29
+ mcast_filter : Option < * const [ MacAddress ] >
30
+ ) -> Status ,
31
+ station_address : extern "efiapi" fn ( this : & Self , reset : bool , new : Option < MacAddress > ) -> Status ,
32
+ statistics : extern "efiapi" fn (
33
+ this : & Self ,
34
+ reset : bool ,
35
+ stats_size : Option < & mut usize > ,
36
+ stats_table : Option < & mut NetworkStats >
37
+ ) -> Status ,
38
+ mcast_ip_to_mac : extern "efiapi" fn (
39
+ this : & Self ,
40
+ ipv6 : bool ,
41
+ ip : & IpAdddress ,
42
+ mac : & mut MacAddress
43
+ ) -> Status ,
44
+ nv_data : extern "efiapi" fn (
45
+ this : & Self ,
46
+ read_write : bool ,
47
+ offset : usize ,
48
+ buffer_size : usize ,
49
+ buffer : * mut c_void
50
+ ) -> Status ,
51
+ get_status : extern "efiapi" fn (
52
+ this : & Self ,
53
+ interrupt_status : Option < & mut u32 > ,
54
+ tx_buf : Option < & mut * mut c_void >
55
+ ) -> Status ,
56
+ transmit : extern "efiapi" fn (
57
+ this : & Self ,
58
+ header_size : usize ,
59
+ buffer_size : usize ,
60
+ buffer : * mut c_void ,
61
+ src_addr : Option < & mut MacAddress > ,
62
+ dest_addr : Option < & mut MacAddress > ,
63
+ protocol : Option < & mut u16 >
64
+ ) -> Status ,
65
+ receive : extern "efiapi" fn (
66
+ this : & Self ,
67
+ header_size : Option < & mut usize > ,
68
+ buffer_size : & mut usize ,
69
+ buffer : * mut c_void ,
70
+ src_addr : Option < & mut MacAddress > ,
71
+ dest_addr : Option < & mut MacAddress > ,
72
+ protocol : Option < & mut u16 >
73
+ ) -> Status ,
74
+ wait_for_packet : Event ,
75
+ mode : * const NetworkMode ,
76
+ }
77
+
78
+ /// Network Statistics
79
+ ///
80
+ /// The description of statistics on the network with the SNP's `statistics` function
81
+ /// is returned in this structure
82
+ #[ repr( C ) ]
83
+ pub struct NetworkStats {
84
+ total_frames_rx : u64 ,
85
+ good_frames_rx : u64 ,
86
+ undersize_frames_rx : u64 ,
87
+ oversize_frames_rx : u64 ,
88
+ dropped_frames_rx : u64 ,
89
+ unicast_frames_rx : u64 ,
90
+ broadcast_frames_rx : u64 ,
91
+ multicast_frames_rx : u64 ,
92
+ crc_error_frames_rx : u64 ,
93
+ total_bytes_rx : u64 ,
94
+ total_frames_tx : u64 ,
95
+ good_frames_tx : u64 ,
96
+ undersize_frames_tx : u64 ,
97
+ oversize_frames_tx : u64 ,
98
+ dropped_frames_tx : u64 ,
99
+ unicast_frames_tx : u64 ,
100
+ broadcast_frames_tx : u64 ,
101
+ multicast_frames_tx : u64 ,
102
+ crc_error_frames_tx : u64 ,
103
+ total_bytes_tx : u64 ,
104
+ collisions : u64 ,
105
+ unsupported_protocol : u64 ,
106
+ duplicated_frames_rx : u64 ,
107
+ decrypt_error_frames_rx : u64 ,
108
+ error_frames_tx : u64 ,
109
+ retry_frames_tx : u64
110
+ }
111
+
112
+ #[ repr( C ) ]
113
+ #[ derive( Debug ) ]
114
+ pub struct NetworkMode {
115
+ state : u32 ,
116
+ hw_address_size : u32 ,
117
+ media_header_size : u32 ,
118
+ max_packet_size : u32 ,
119
+ nv_ram_size : u32 ,
120
+ nv_ram_access_size : u32 ,
121
+ receive_filter_mask : u32 ,
122
+ receive_filter_setting : u32 ,
123
+ max_mcast_filter_count : u32 ,
124
+ mcast_filter_count : u32 ,
125
+ mcast_filter : [ MacAddress ; 16 ] ,
126
+ current_address : MacAddress ,
127
+ broadcast_address : MacAddress ,
128
+ permanent_address : MacAddress ,
129
+ if_type : u8 ,
130
+ mac_address_changeable : bool ,
131
+ multiple_tx_supported : bool ,
132
+ media_present_supported : bool ,
133
+ media_present : bool
134
+ }
0 commit comments