@@ -10,8 +10,8 @@ use netlink_packet_core::{Emitable, Parseable};
1010use crate :: {
1111 neighbour:: {
1212 flags:: NeighbourFlags , NeighbourAttribute , NeighbourCacheInfo ,
13- NeighbourHeader , NeighbourMessage , NeighbourMessageBuffer ,
14- NeighbourState ,
13+ NeighbourExtFlags , NeighbourHeader , NeighbourMessage ,
14+ NeighbourMessageBuffer , NeighbourState ,
1515 } ,
1616 route:: { RouteProtocol , RouteType } ,
1717 AddressFamily ,
@@ -171,3 +171,86 @@ fn test_ipv4_neighbour_protocol_show() {
171171
172172 assert_eq ! ( buf, raw) ;
173173}
174+
175+ #[ test]
176+ fn test_ipv4_neighbour_add_ext_flags ( ) {
177+ let raw = vec ! [
178+ 0x02 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
179+ 0x08 , 0x00 , 0x01 , 0x00 , 0xac , 0x11 , 0x02 , 0x01 , 0x08 , 0x00 , 0x0f , 0x00 ,
180+ 0x01 , 0x00 , 0x00 , 0x00 ,
181+ ] ;
182+
183+ let expected = NeighbourMessage {
184+ header : NeighbourHeader {
185+ family : AddressFamily :: Inet ,
186+ ifindex : 3 ,
187+ state : NeighbourState :: None ,
188+ flags : NeighbourFlags :: empty ( ) ,
189+ kind : RouteType :: Unspec ,
190+ } ,
191+ attributes : vec ! [
192+ NeighbourAttribute :: Destination (
193+ Ipv4Addr :: from_str( "172.17.2.1" ) . unwrap( ) . into( ) ,
194+ ) ,
195+ NeighbourAttribute :: ExtFlags ( NeighbourExtFlags :: Managed ) ,
196+ ] ,
197+ } ;
198+
199+ assert_eq ! (
200+ expected,
201+ NeighbourMessage :: parse( & NeighbourMessageBuffer :: new( & raw) ) . unwrap( )
202+ ) ;
203+
204+ let mut buf = vec ! [ 0 ; expected. buffer_len( ) ] ;
205+
206+ expected. emit ( & mut buf) ;
207+
208+ assert_eq ! ( buf, raw) ;
209+ }
210+
211+ #[ test]
212+ fn test_ipv4_neighbour_show_ext_flags ( ) {
213+ let raw = vec ! [
214+ 0x02 , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x01 ,
215+ 0x08 , 0x00 , 0x01 , 0x00 , 0xac , 0x11 , 0x02 , 0x01 , 0x0a , 0x00 , 0x02 , 0x00 ,
216+ 0x48 , 0x21 , 0x0b , 0x3c , 0x1f , 0x01 , 0x00 , 0x00 , 0x08 , 0x00 , 0x04 , 0x00 ,
217+ 0x04 , 0x00 , 0x00 , 0x00 , 0x14 , 0x00 , 0x03 , 0x00 , 0x59 , 0x02 , 0x00 , 0x00 ,
218+ 0x33 , 0x00 , 0x00 , 0x00 , 0xf3 , 0x17 , 0x01 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 ,
219+ 0x08 , 0x00 , 0x0f , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 ,
220+ ] ;
221+
222+ let expected = NeighbourMessage {
223+ header : NeighbourHeader {
224+ family : AddressFamily :: Inet ,
225+ ifindex : 3 ,
226+ state : NeighbourState :: Reachable ,
227+ flags : NeighbourFlags :: empty ( ) ,
228+ kind : RouteType :: Unicast ,
229+ } ,
230+ attributes : vec ! [
231+ NeighbourAttribute :: Destination (
232+ Ipv4Addr :: from_str( "172.17.2.1" ) . unwrap( ) . into( ) ,
233+ ) ,
234+ NeighbourAttribute :: LinkLocalAddress ( vec![ 72 , 33 , 11 , 60 , 31 , 1 ] ) ,
235+ NeighbourAttribute :: Probes ( 4 ) ,
236+ NeighbourAttribute :: CacheInfo ( NeighbourCacheInfo {
237+ confirmed: 601 ,
238+ used: 51 ,
239+ updated: 71667 ,
240+ refcnt: 1 ,
241+ } ) ,
242+ NeighbourAttribute :: ExtFlags ( NeighbourExtFlags :: Managed ) ,
243+ ] ,
244+ } ;
245+
246+ assert_eq ! (
247+ expected,
248+ NeighbourMessage :: parse( & NeighbourMessageBuffer :: new( & raw) ) . unwrap( )
249+ ) ;
250+
251+ let mut buf = vec ! [ 0 ; expected. buffer_len( ) ] ;
252+
253+ expected. emit ( & mut buf) ;
254+
255+ assert_eq ! ( buf, raw) ;
256+ }
0 commit comments