Skip to content

Commit 7cec1f1

Browse files
committed
address: Parse AfSpecInet6::Token to Ipv6Addr
Signed-off-by: Gris Ge <[email protected]>
1 parent 75c0318 commit 7cec1f1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/link/af_spec/inet6.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// SPDX-License-Identifier: MIT
22

3+
use std::net::Ipv6Addr;
4+
35
use anyhow::Context;
46
use byteorder::{ByteOrder, NativeEndian};
57
use netlink_packet_utils::{
68
nla::{DefaultNla, Nla, NlaBuffer, NlasIterator},
7-
parsers::{parse_ipv6, parse_u32, parse_u8},
9+
parsers::{parse_u32, parse_u8},
810
traits::{Emitable, Parseable},
911
DecodeError,
1012
};
@@ -15,6 +17,7 @@ use super::super::{
1517
Inet6IfaceFlags, Inet6Stats, Inet6StatsBuffer,
1618
};
1719
use super::inet6_devconf::LINK_INET6_DEV_CONF_LEN;
20+
use crate::ip::parse_ipv6_addr;
1821

1922
const IFLA_INET6_FLAGS: u16 = 1;
2023
const IFLA_INET6_CONF: u16 = 2;
@@ -36,7 +39,7 @@ pub enum AfSpecInet6 {
3639
DevConf(Inet6DevConf),
3740
Stats(Inet6Stats),
3841
Icmp6Stats(Icmp6Stats),
39-
Token([u8; 16]),
42+
Token(Ipv6Addr),
4043
AddrGenMode(u8),
4144
RaMtu(u32),
4245
Other(DefaultNla),
@@ -84,7 +87,7 @@ impl Nla for AfSpecInet6 {
8487
DevConf(ref v) => v.emit(buffer),
8588
Stats(ref v) => v.emit(buffer),
8689
Icmp6Stats(ref v) => v.emit(buffer),
87-
Token(ref ipv6) => buffer.copy_from_slice(&ipv6[..]),
90+
Token(v) => buffer.copy_from_slice(&v.octets()),
8891
AddrGenMode(value) => buffer[0] = value,
8992
Other(ref nla) => nla.emit_value(buffer),
9093
}
@@ -151,7 +154,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for AfSpecInet6 {
151154
))?,
152155
),
153156
IFLA_INET6_TOKEN => Token(
154-
parse_ipv6(payload)
157+
parse_ipv6_addr(payload)
155158
.context("invalid IFLA_INET6_TOKEN value")?,
156159
),
157160
IFLA_INET6_ADDR_GEN_MODE => AddrGenMode(

0 commit comments

Comments
 (0)