4
4
5
5
//! IP4 Config2 Protocol.
6
6
7
- extern crate alloc;
8
7
use alloc:: vec;
9
8
use alloc:: vec:: Vec ;
10
9
use core:: ffi:: c_void;
@@ -27,10 +26,10 @@ pub struct Ip4Config2(pub Ip4Config2Protocol);
27
26
28
27
impl Ip4Config2 {
29
28
/// Open IP4 Config2 protocol for the given NIC handle.
30
- pub fn new ( nic_handle : Handle ) -> uefi:: Result < ScopedProtocol < Ip4Config2 > > {
29
+ pub fn new ( nic_handle : Handle ) -> uefi:: Result < ScopedProtocol < Self > > {
31
30
let protocol;
32
31
unsafe {
33
- protocol = boot:: open_protocol :: < Ip4Config2 > (
32
+ protocol = boot:: open_protocol :: < Self > (
34
33
boot:: OpenProtocolParams {
35
34
handle : nic_handle,
36
35
agent : boot:: image_handle ( ) ,
@@ -45,7 +44,7 @@ impl Ip4Config2 {
45
44
/// Set configuration data. It is recommended to type-specific set_* helpers instead of calling this directly.
46
45
pub fn set_data ( & mut self , data_type : Ip4Config2DataType , data : & mut [ u8 ] ) -> uefi:: Result < ( ) > {
47
46
let status = unsafe {
48
- let data_ptr = data. as_mut_ptr ( ) as * mut c_void ;
47
+ let data_ptr = data. as_mut_ptr ( ) . cast :: < c_void > ( ) ;
49
48
( self . 0 . set_data ) ( & mut self . 0 , data_type, data. len ( ) , data_ptr)
50
49
} ;
51
50
match status {
@@ -70,7 +69,7 @@ impl Ip4Config2 {
70
69
// call #2: get data
71
70
let mut data = vec ! [ 0 ; data_size] ;
72
71
let status = unsafe {
73
- let data_ptr = data. as_mut_ptr ( ) as * mut c_void ;
72
+ let data_ptr = data. as_mut_ptr ( ) . cast :: < c_void > ( ) ;
74
73
( self . 0 . get_data ) ( & mut self . 0 , data_type, & mut data_size, data_ptr)
75
74
} ;
76
75
match status {
@@ -89,7 +88,7 @@ impl Ip4Config2 {
89
88
pub fn get_interface_info ( & mut self ) -> uefi:: Result < Ip4Config2InterfaceInfo > {
90
89
let data = self . get_data ( Ip4Config2DataType :: INTERFACE_INFO ) ?;
91
90
let info: & Ip4Config2InterfaceInfo =
92
- unsafe { & * ( data. as_ptr ( ) as * const Ip4Config2InterfaceInfo ) } ;
91
+ unsafe { & * ( data. as_ptr ( ) . cast :: < Ip4Config2InterfaceInfo > ( ) ) } ;
93
92
Ok ( Ip4Config2InterfaceInfo {
94
93
name : info. name ,
95
94
if_type : info. if_type ,
@@ -124,7 +123,7 @@ impl Ip4Config2 {
124
123
if info. station_addr != no_address {
125
124
if verbose {
126
125
print ! ( "Network is already up: " ) ;
127
- Ip4Config2 :: print_info ( & info) ;
126
+ Self :: print_info ( & info) ;
128
127
}
129
128
return Ok ( ( ) ) ;
130
129
}
@@ -143,7 +142,7 @@ impl Ip4Config2 {
143
142
if info. station_addr != no_address {
144
143
if verbose {
145
144
print ! ( " OK: " ) ;
146
- Ip4Config2 :: print_info ( & info) ;
145
+ Self :: print_info ( & info) ;
147
146
}
148
147
return Ok ( ( ) ) ;
149
148
}
0 commit comments