@@ -8,7 +8,7 @@ use byteorder::{ByteOrder, NativeEndian};
8
8
use netlink_packet_utils:: {
9
9
nla:: { DefaultNla , Nla , NlaBuffer } ,
10
10
parsers:: { parse_u16, parse_u32, parse_u8} ,
11
- traits:: Parseable ,
11
+ traits:: { Parseable , ParseableParametrized } ,
12
12
DecodeError ,
13
13
} ;
14
14
@@ -146,8 +146,13 @@ impl Nla for InfoIpTunnel {
146
146
}
147
147
}
148
148
149
- impl < ' a , T : AsRef < [ u8 ] > + ?Sized > Parseable < NlaBuffer < & ' a T > > for InfoIpTunnel {
150
- fn parse ( buf : & NlaBuffer < & ' a T > ) -> Result < Self , DecodeError > {
149
+ impl < ' a , T : AsRef < [ u8 ] > + ?Sized >
150
+ ParseableParametrized < NlaBuffer < & ' a T > , super :: InfoKind > for InfoIpTunnel
151
+ {
152
+ fn parse_with_param (
153
+ buf : & NlaBuffer < & ' a T > ,
154
+ kind : super :: InfoKind ,
155
+ ) -> Result < Self , DecodeError > {
151
156
use self :: InfoIpTunnel :: * ;
152
157
let payload = buf. value ( ) ;
153
158
Ok ( match buf. kind ( ) {
@@ -202,9 +207,23 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoIpTunnel {
202
207
parse_u32 ( payload)
203
208
. context ( "invalid IFLA_IPTUN_FLOWINFO value" ) ?,
204
209
) ,
205
- IFLA_IPTUN_FLAGS => Flags ( TunnelFlags :: from_bits_retain (
206
- parse_u32 ( payload) . context ( "invalid IFLA_IPTUN_FLAGS value" ) ?,
207
- ) ) ,
210
+ IFLA_IPTUN_FLAGS => match kind {
211
+ super :: InfoKind :: SitTun => {
212
+ // Parse as u16 for SIT tunnels
213
+ Flags ( TunnelFlags :: from_bits_retain (
214
+ parse_u16 ( payload)
215
+ . context ( "invalid IFLA_IPTUN_FLAGS value for SIT" ) ?
216
+ as u32 ,
217
+ ) )
218
+ }
219
+ _ => {
220
+ // Default: parse as u32 for other tunnel types
221
+ Flags ( TunnelFlags :: from_bits_retain (
222
+ parse_u32 ( payload)
223
+ . context ( "invalid IFLA_IPTUN_FLAGS value" ) ?,
224
+ ) )
225
+ }
226
+ } ,
208
227
IFLA_IPTUN_PROTO => Protocol ( IpProtocol :: from (
209
228
parse_u8 ( payload) . context ( "invalid IFLA_IPTUN_PROTO value" ) ?
210
229
as i32 ,
0 commit comments