Skip to content

Commit 692fba9

Browse files
committed
ospfv3: Encode/decode tests for Reverse(TE) Metric
Signed-off-by: Nicolas Rybowski <nicolas.rybowski@uclouvain.be>
1 parent 5713aad commit 692fba9

1 file changed

Lines changed: 94 additions & 32 deletions

File tree

holo-ospf/tests/packet/ospfv3.rs

Lines changed: 94 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use const_addrs::{ip, ip4, net};
1313
use holo_ospf::ospfv3::packet::lsa::*;
1414
use holo_ospf::ospfv3::packet::*;
1515
use holo_ospf::packet::auth::{AuthDecodeCtx, AuthEncodeCtx, AuthMethod};
16-
use holo_ospf::packet::lls::ExtendedOptionsFlags;
16+
use holo_ospf::packet::lls::{
17+
ExtendedOptionsFlags, ReverseMetricFlags, ReverseTeMetricFlags,
18+
};
1719
use holo_ospf::packet::lsa::{Lsa, LsaKey};
1820
use holo_ospf::packet::tlv::*;
1921
use holo_ospf::packet::{DbDescFlags, Packet, PacketType};
@@ -128,8 +130,10 @@ static HELLO1_LLS: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
128130
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
129131
0x01, 0x00, 0x02, 0x13, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00,
130132
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02,
131-
0xff, 0xf4, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00,
132-
0x00, 0x03,
133+
0x50, 0xd3, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00,
134+
0x00, 0x03, 0x00, 0x13, 0x00, 0x04, 0x00, 0x01, 0x12, 0x34,
135+
0x00, 0x13, 0x00, 0x04, 0x01, 0x02, 0x43, 0x21, 0x00, 0x14,
136+
0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x78,
133137
],
134138
None,
135139
Packet::Hello(Hello {
@@ -152,6 +156,14 @@ static HELLO1_LLS: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
152156
eof: Some(
153157
ExtendedOptionsFlags::LR | ExtendedOptionsFlags::RS,
154158
),
159+
reverse_metric: vec![
160+
(0 as u8, (ReverseMetricFlags::H, 0x1234)),
161+
(1 as u8, (ReverseMetricFlags::O, 0x4321)),
162+
]
163+
.iter()
164+
.map(|&entry| entry)
165+
.collect(),
166+
reverse_te_metric: Some((ReverseTeMetricFlags::O, 0x5678)),
155167
}),
156168
}),
157169
)
@@ -205,11 +217,21 @@ static HELLO1_HMAC_SHA1_LLS: Lazy<(
205217
0x03, 0x01, 0x00, 0x28, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
206218
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
207219
0x06, 0x13, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
208-
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x03,
209-
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
210-
0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x32, 0x45,
211-
0xd0, 0x14, 0xfe, 0xef, 0xc6, 0xce, 0x7d, 0xbe, 0x66, 0x4e, 0xc3,
212-
0x92, 0x0c, 0xc9, 0x2f, 0x6d, 0x42, 0x1f, 0x38, 0xb2, 0xd2, 0x3c,
220+
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x0a,
221+
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x13, 0x00,
222+
0x04, 0x00, 0x01, 0x12, 0x34, 0x00, 0x13, 0x00, 0x04, 0x01, 0x02,
223+
0x43, 0x21, 0x00, 0x14, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00,
224+
0x00, 0x56, 0x78,
225+
// 0x00, 0x00, 0x00, 0x03,
226+
// 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03,
227+
// 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
228+
// 0x00, 0x32, 0x45, 0xd0, 0x14, 0xfe, 0xef, 0xc6, 0xce, 0x7d, 0xbe,
229+
// 0x66, 0x4e, 0xc3, 0x92, 0x0c, 0xc9, 0x2f, 0x6d, 0x42, 0x1f, 0x38,
230+
// 0xb2, 0xd2, 0x3c,
231+
0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
232+
0x00, 0x32, 0x45, 0xd0, 0x14, 0x76, 0x0c, 0xf8, 0xe7, 0x32, 0xfd,
233+
0x4f, 0x95, 0x30, 0x97, 0xa1, 0x4e, 0xd0, 0x2b, 0x5d, 0x10, 0x7c,
234+
0x93, 0x8f, 0xe2,
213235
],
214236
Some((
215237
Key::new(1, CryptoAlgo::HmacSha1, "HOLO".as_bytes().to_vec()),
@@ -237,6 +259,14 @@ static HELLO1_HMAC_SHA1_LLS: Lazy<(
237259
neighbors: [ip4!("2.2.2.2")].into(),
238260
lls: Some(holo_ospf::packet::lls::LlsHelloData {
239261
eof: Some(ExtendedOptionsFlags::LR | ExtendedOptionsFlags::RS),
262+
reverse_metric: vec![
263+
(0 as u8, (ReverseMetricFlags::H, 0x1234)),
264+
(1 as u8, (ReverseMetricFlags::O, 0x4321)),
265+
]
266+
.iter()
267+
.map(|&entry| entry)
268+
.collect(),
269+
reverse_te_metric: Some((ReverseTeMetricFlags::O, 0x5678)),
240270
}),
241271
}),
242272
)
@@ -291,13 +321,15 @@ static HELLO1_HMAC_SHA256_LLS: Lazy<(
291321
0x03, 0x01, 0x00, 0x28, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
292322
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
293323
0x06, 0x13, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
294-
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x03,
295-
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
296-
0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x32, 0x45,
297-
0xd0, 0x14, 0xdf, 0x4b, 0x87, 0x87, 0xea, 0x1f, 0xaf, 0x92, 0xe9,
298-
0xcc, 0x0d, 0x1f, 0xbc, 0x70, 0xf7, 0xbc, 0x58, 0xa7, 0x1e, 0x37,
299-
0xc1, 0x4e, 0x6e, 0x8a, 0x22, 0xe3, 0xd1, 0xc7, 0x2d, 0xed, 0xef,
300-
0x67,
324+
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x0a,
325+
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x13, 0x00,
326+
0x04, 0x00, 0x01, 0x12, 0x34, 0x00, 0x13, 0x00, 0x04, 0x01, 0x02,
327+
0x43, 0x21, 0x00, 0x14, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00,
328+
0x00, 0x56, 0x78, 0x00, 0x01, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01,
329+
0x00, 0x00, 0x00, 0x00, 0x32, 0x45, 0xd0, 0x14, 0x6e, 0x98, 0x69,
330+
0xad, 0x05, 0x4c, 0x78, 0x40, 0x17, 0xab, 0xc4, 0x2d, 0x18, 0xca,
331+
0xe3, 0xb7, 0x3c, 0x2d, 0x38, 0x17, 0xdd, 0xb7, 0x53, 0x3d, 0xe2,
332+
0x89, 0x4e, 0x79, 0x65, 0x43, 0x56, 0xbd,
301333
],
302334
Some((
303335
Key::new(1, CryptoAlgo::HmacSha256, "HOLO".as_bytes().to_vec()),
@@ -325,6 +357,14 @@ static HELLO1_HMAC_SHA256_LLS: Lazy<(
325357
neighbors: [ip4!("2.2.2.2")].into(),
326358
lls: Some(holo_ospf::packet::lls::LlsHelloData {
327359
eof: Some(ExtendedOptionsFlags::LR | ExtendedOptionsFlags::RS),
360+
reverse_metric: vec![
361+
(0 as u8, (ReverseMetricFlags::H, 0x1234)),
362+
(1 as u8, (ReverseMetricFlags::O, 0x4321)),
363+
]
364+
.iter()
365+
.map(|&entry| entry)
366+
.collect(),
367+
reverse_te_metric: Some((ReverseTeMetricFlags::O, 0x5678)),
328368
}),
329369
}),
330370
)
@@ -381,14 +421,17 @@ static HELLO1_HMAC_SHA384_LLS: Lazy<(
381421
0x03, 0x01, 0x00, 0x28, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
382422
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
383423
0x06, 0x13, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
384-
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x03,
385-
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
386-
0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x32, 0x45,
387-
0xd0, 0x14, 0xb2, 0xe6, 0x9b, 0x9e, 0x54, 0xd0, 0xad, 0xb9, 0x59,
388-
0xad, 0x9c, 0x35, 0x1c, 0x08, 0x96, 0xda, 0x72, 0x77, 0x30, 0x4b,
389-
0x15, 0x88, 0xcc, 0x18, 0xf0, 0xc4, 0x02, 0xa9, 0x67, 0x65, 0x82,
390-
0x87, 0x68, 0xf5, 0xc0, 0x72, 0x10, 0x2b, 0xa0, 0x4c, 0x1e, 0x44,
391-
0x8f, 0xa1, 0xbe, 0x69, 0xac, 0x6e,
424+
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x0a,
425+
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x13, 0x00,
426+
0x04, 0x00, 0x01, 0x12, 0x34, 0x00, 0x13, 0x00, 0x04, 0x01, 0x02,
427+
0x43, 0x21, 0x00, 0x14, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00,
428+
0x00, 0x56, 0x78, 0x00, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01,
429+
0x00, 0x00, 0x00, 0x00, 0x32, 0x45, 0xd0, 0x14, 0xf3, 0x68, 0x6f,
430+
0x8a, 0x4e, 0x5b, 0xff, 0xef, 0xd9, 0x05, 0xa1, 0x1d, 0xe9, 0x43,
431+
0xba, 0x7f, 0x00, 0xff, 0x0c, 0xc2, 0x37, 0x41, 0xc2, 0xfc, 0xa9,
432+
0xdf, 0xc3, 0x28, 0x6c, 0xbe, 0x89, 0xd9, 0x73, 0xc7, 0x39, 0xf5,
433+
0x5e, 0x18, 0x9d, 0x18, 0x04, 0xe2, 0xbd, 0x5c, 0xca, 0xd4, 0x3c,
434+
0xa4,
392435
],
393436
Some((
394437
Key::new(1, CryptoAlgo::HmacSha384, "HOLO".as_bytes().to_vec()),
@@ -416,6 +459,14 @@ static HELLO1_HMAC_SHA384_LLS: Lazy<(
416459
neighbors: [ip4!("2.2.2.2")].into(),
417460
lls: Some(holo_ospf::packet::lls::LlsHelloData {
418461
eof: Some(ExtendedOptionsFlags::LR | ExtendedOptionsFlags::RS),
462+
reverse_metric: vec![
463+
(0 as u8, (ReverseMetricFlags::H, 0x1234)),
464+
(1 as u8, (ReverseMetricFlags::O, 0x4321)),
465+
]
466+
.iter()
467+
.map(|&entry| entry)
468+
.collect(),
469+
reverse_te_metric: Some((ReverseTeMetricFlags::O, 0x5678)),
419470
}),
420471
}),
421472
)
@@ -473,15 +524,18 @@ static HELLO1_HMAC_SHA512_LLS: Lazy<(
473524
0x03, 0x01, 0x00, 0x28, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
474525
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
475526
0x06, 0x13, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
476-
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x03,
477-
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
478-
0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x32, 0x45,
479-
0xd0, 0x14, 0x43, 0x1e, 0x7b, 0xcd, 0x00, 0x46, 0xe5, 0x6c, 0xb6,
480-
0x46, 0x63, 0x87, 0x02, 0xeb, 0x5b, 0x10, 0xe0, 0xd0, 0x7e, 0x96,
481-
0x20, 0xdb, 0x34, 0x7e, 0x12, 0xd8, 0x8c, 0xf0, 0xaa, 0xfd, 0xd9,
482-
0x32, 0xcc, 0x2f, 0x85, 0xef, 0x5f, 0x63, 0xcd, 0x5f, 0x0b, 0x10,
483-
0xa8, 0x0a, 0xf7, 0x7a, 0x27, 0x7f, 0x3c, 0xc9, 0x4b, 0xc4, 0xc0,
484-
0xf8, 0x92, 0xa5, 0x43, 0xf0, 0xac, 0x73, 0xe1, 0xf5, 0xfe, 0x7a,
527+
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x0a,
528+
0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x13, 0x00,
529+
0x04, 0x00, 0x01, 0x12, 0x34, 0x00, 0x13, 0x00, 0x04, 0x01, 0x02,
530+
0x43, 0x21, 0x00, 0x14, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00,
531+
0x00, 0x56, 0x78, 0x00, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01,
532+
0x00, 0x00, 0x00, 0x00, 0x32, 0x45, 0xd0, 0x14, 0x6c, 0xeb, 0xd1,
533+
0x49, 0x97, 0xb9, 0x46, 0x03, 0x52, 0x41, 0x96, 0x3a, 0xc1, 0xa6,
534+
0x9c, 0xdc, 0x6d, 0xe8, 0x1b, 0xc4, 0x35, 0x53, 0xd9, 0xcf, 0xda,
535+
0xa6, 0x15, 0x8e, 0x9f, 0x7a, 0x40, 0xda, 0x1f, 0x2e, 0x61, 0x24,
536+
0x6a, 0xb0, 0x6d, 0x33, 0xe1, 0x49, 0xb9, 0x01, 0x21, 0xa9, 0x64,
537+
0x17, 0xd9, 0x14, 0x28, 0xdd, 0x83, 0x35, 0xdb, 0x43, 0xf3, 0x0c,
538+
0xa9, 0x10, 0x43, 0xf9, 0x01, 0x86,
485539
],
486540
Some((
487541
Key::new(1, CryptoAlgo::HmacSha512, "HOLO".as_bytes().to_vec()),
@@ -509,6 +563,14 @@ static HELLO1_HMAC_SHA512_LLS: Lazy<(
509563
neighbors: [ip4!("2.2.2.2")].into(),
510564
lls: Some(holo_ospf::packet::lls::LlsHelloData {
511565
eof: Some(ExtendedOptionsFlags::LR | ExtendedOptionsFlags::RS),
566+
reverse_metric: vec![
567+
(0 as u8, (ReverseMetricFlags::H, 0x1234)),
568+
(1 as u8, (ReverseMetricFlags::O, 0x4321)),
569+
]
570+
.iter()
571+
.map(|&entry| entry)
572+
.collect(),
573+
reverse_te_metric: Some((ReverseTeMetricFlags::O, 0x5678)),
512574
}),
513575
}),
514576
)

0 commit comments

Comments
 (0)