@@ -17,16 +17,37 @@ fn is_wifi_interface(ifname: &str) -> bool {
1717 let base = PathBuf :: from ( "/sys/class/net" ) . join ( ifname) ;
1818
1919 // 1) Check uevent file for DEVTYPE=wlan
20- if let Some ( ue) = read_trimmed ( base. join ( "uevent" ) ) {
21- if ue. lines ( ) . any ( |l| l. trim ( ) == "DEVTYPE=wlan" ) {
22- return true ;
23- }
20+ if let Some ( ue) = read_trimmed ( base. join ( "uevent" ) )
21+ && ue. lines ( ) . any ( |l| l. trim ( ) == "DEVTYPE=wlan" )
22+ {
23+ return true ;
2424 }
2525
2626 // 2) Check for wireless or phy80211 directories
2727 exists ( base. join ( "wireless" ) ) || exists ( base. join ( "phy80211" ) )
2828}
2929
30+ /// Check if the interface is a WWAN/mobile broadband interface.
31+ fn is_wwan_interface ( ifname : & str ) -> bool {
32+ let base = PathBuf :: from ( "/sys/class/net" ) . join ( ifname) ;
33+
34+ if let Some ( uevent) = read_trimmed ( base. join ( "uevent" ) )
35+ && uevent. lines ( ) . any ( |line| line. trim ( ) == "DEVTYPE=wwan" )
36+ {
37+ return true ;
38+ }
39+
40+ is_wwan_name ( ifname)
41+ }
42+
43+ fn is_wwan_name ( ifname : & str ) -> bool {
44+ ifname == "wwan"
45+ || ifname. starts_with ( "wwan" )
46+ || ifname. starts_with ( "wwp" )
47+ || ifname. starts_with ( "rmnet" )
48+ || ifname. starts_with ( "ccmni" )
49+ }
50+
3051/// Check if the interface is a virtual interface.
3152pub fn is_virtual_interface ( ifname : & str ) -> bool {
3253 let dev_link = PathBuf :: from ( "/sys/class/net" ) . join ( ifname) . join ( "device" ) ;
@@ -52,6 +73,11 @@ pub fn get_interface_type(ifname: &str) -> InterfaceType {
5273 if is_wifi_interface ( ifname) {
5374 return InterfaceType :: Wireless80211 ;
5475 }
76+
77+ if is_wwan_interface ( ifname) {
78+ return InterfaceType :: Wwan ;
79+ }
80+
5581 // Read the type from sysfs
5682 let p = PathBuf :: from ( "/sys/class/net" ) . join ( ifname) . join ( "type" ) ;
5783 let ty = match read_trimmed ( & p) . and_then ( |s| s. parse :: < u32 > ( ) . ok ( ) ) {
0 commit comments