@@ -13,6 +13,7 @@ use const_addrs::{ip, ip4, net};
13
13
use holo_ospf:: ospfv3:: packet:: lsa:: * ;
14
14
use holo_ospf:: ospfv3:: packet:: * ;
15
15
use holo_ospf:: packet:: auth:: { AuthDecodeCtx , AuthEncodeCtx , AuthMethod } ;
16
+ use holo_ospf:: packet:: lls:: ExtendedOptionsFlags ;
16
17
use holo_ospf:: packet:: lsa:: { Lsa , LsaKey } ;
17
18
use holo_ospf:: packet:: tlv:: * ;
18
19
use holo_ospf:: packet:: { DbDescFlags , Packet , PacketType } ;
@@ -119,6 +120,43 @@ static HELLO1: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
119
120
)
120
121
} ) ;
121
122
123
+ static HELLO1_LLS : Lazy < ( Vec < u8 > , Option < ( Key , u64 ) > , Packet < Ospfv3 > ) > =
124
+ Lazy :: new ( || {
125
+ (
126
+ vec ! [
127
+ 0x03 , 0x01 , 0x00 , 0x28 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 ,
128
+ 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04 ,
129
+ 0x01 , 0x00 , 0x02 , 0x13 , 0x00 , 0x03 , 0x00 , 0x24 , 0x00 , 0x00 ,
130
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02 , 0x02 , 0x02 , 0x02 ,
131
+ 0xf3 , 0x86 , 0x00 , 0x03 , 0x00 , 0x01 , 0x00 , 0x04 , 0x00 , 0x00 ,
132
+ 0x00 , 0x03 ,
133
+ ] ,
134
+ None ,
135
+ Packet :: Hello ( Hello {
136
+ hdr : PacketHdr {
137
+ pkt_type : PacketType :: Hello ,
138
+ router_id : ip4 ! ( "1.1.1.1" ) ,
139
+ area_id : ip4 ! ( "0.0.0.1" ) ,
140
+ instance_id : 0 ,
141
+ auth_seqno : None ,
142
+ } ,
143
+ iface_id : 4 ,
144
+ priority : 1 ,
145
+ options : Options :: R | Options :: E | Options :: V6 | Options :: L ,
146
+ hello_interval : 3 ,
147
+ dead_interval : 36 ,
148
+ dr : None ,
149
+ bdr : None ,
150
+ neighbors : [ ip4 ! ( "2.2.2.2" ) ] . into ( ) ,
151
+ lls : Some ( holo_ospf:: packet:: lls:: LlsHelloData {
152
+ eof : Some (
153
+ ExtendedOptionsFlags :: LR | ExtendedOptionsFlags :: RS ,
154
+ ) ,
155
+ } ) ,
156
+ } ) ,
157
+ )
158
+ } ) ;
159
+
122
160
static HELLO1_HMAC_SHA1 : Lazy < ( Vec < u8 > , Option < ( Key , u64 ) > , Packet < Ospfv3 > ) > =
123
161
Lazy :: new ( || {
124
162
(
@@ -157,6 +195,53 @@ static HELLO1_HMAC_SHA1: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
157
195
)
158
196
} ) ;
159
197
198
+ static HELLO1_HMAC_SHA1_LLS : Lazy < (
199
+ Vec < u8 > ,
200
+ Option < ( Key , u64 ) > ,
201
+ Packet < Ospfv3 > ,
202
+ ) > = Lazy :: new ( || {
203
+ (
204
+ vec ! [
205
+ 0x03 , 0x01 , 0x00 , 0x28 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 ,
206
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04 , 0x01 , 0x00 ,
207
+ 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 ,
213
+ ] ,
214
+ Some ( (
215
+ Key :: new ( 1 , CryptoAlgo :: HmacSha1 , "HOLO" . as_bytes ( ) . to_vec ( ) ) ,
216
+ 843436052 ,
217
+ ) ) ,
218
+ Packet :: Hello ( Hello {
219
+ hdr : PacketHdr {
220
+ pkt_type : PacketType :: Hello ,
221
+ router_id : ip4 ! ( "1.1.1.1" ) ,
222
+ area_id : ip4 ! ( "0.0.0.1" ) ,
223
+ instance_id : 0 ,
224
+ auth_seqno : Some ( 843436052 ) ,
225
+ } ,
226
+ iface_id : 4 ,
227
+ priority : 1 ,
228
+ options : Options :: R
229
+ | Options :: E
230
+ | Options :: V6
231
+ | Options :: AT
232
+ | Options :: L ,
233
+ hello_interval : 3 ,
234
+ dead_interval : 36 ,
235
+ dr : None ,
236
+ bdr : None ,
237
+ neighbors : [ ip4 ! ( "2.2.2.2" ) ] . into ( ) ,
238
+ lls : Some ( holo_ospf:: packet:: lls:: LlsHelloData {
239
+ eof : Some ( ExtendedOptionsFlags :: LR | ExtendedOptionsFlags :: RS ) ,
240
+ } ) ,
241
+ } ) ,
242
+ )
243
+ } ) ;
244
+
160
245
static HELLO1_HMAC_SHA256 : Lazy < ( Vec < u8 > , Option < ( Key , u64 ) > , Packet < Ospfv3 > ) > =
161
246
Lazy :: new ( || {
162
247
(
@@ -196,6 +281,55 @@ static HELLO1_HMAC_SHA256: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
196
281
)
197
282
} ) ;
198
283
284
+ static HELLO1_HMAC_SHA256_LLS : Lazy < (
285
+ Vec < u8 > ,
286
+ Option < ( Key , u64 ) > ,
287
+ Packet < Ospfv3 > ,
288
+ ) > = Lazy :: new ( || {
289
+ (
290
+ vec ! [
291
+ 0x03 , 0x01 , 0x00 , 0x28 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 ,
292
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04 , 0x01 , 0x00 ,
293
+ 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 ,
301
+ ] ,
302
+ Some ( (
303
+ Key :: new ( 1 , CryptoAlgo :: HmacSha256 , "HOLO" . as_bytes ( ) . to_vec ( ) ) ,
304
+ 843436052 ,
305
+ ) ) ,
306
+ Packet :: Hello ( Hello {
307
+ hdr : PacketHdr {
308
+ pkt_type : PacketType :: Hello ,
309
+ router_id : ip4 ! ( "1.1.1.1" ) ,
310
+ area_id : ip4 ! ( "0.0.0.1" ) ,
311
+ instance_id : 0 ,
312
+ auth_seqno : Some ( 843436052 ) ,
313
+ } ,
314
+ iface_id : 4 ,
315
+ priority : 1 ,
316
+ options : Options :: R
317
+ | Options :: E
318
+ | Options :: V6
319
+ | Options :: AT
320
+ | Options :: L ,
321
+ hello_interval : 3 ,
322
+ dead_interval : 36 ,
323
+ dr : None ,
324
+ bdr : None ,
325
+ neighbors : [ ip4 ! ( "2.2.2.2" ) ] . into ( ) ,
326
+ lls : Some ( holo_ospf:: packet:: lls:: LlsHelloData {
327
+ eof : Some ( ExtendedOptionsFlags :: LR | ExtendedOptionsFlags :: RS ) ,
328
+ } ) ,
329
+ } ) ,
330
+ )
331
+ } ) ;
332
+
199
333
static HELLO1_HMAC_SHA384 : Lazy < ( Vec < u8 > , Option < ( Key , u64 ) > , Packet < Ospfv3 > ) > =
200
334
Lazy :: new ( || {
201
335
(
@@ -237,6 +371,56 @@ static HELLO1_HMAC_SHA384: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
237
371
)
238
372
} ) ;
239
373
374
+ static HELLO1_HMAC_SHA384_LLS : Lazy < (
375
+ Vec < u8 > ,
376
+ Option < ( Key , u64 ) > ,
377
+ Packet < Ospfv3 > ,
378
+ ) > = Lazy :: new ( || {
379
+ (
380
+ vec ! [
381
+ 0x03 , 0x01 , 0x00 , 0x28 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 ,
382
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04 , 0x01 , 0x00 ,
383
+ 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 ,
392
+ ] ,
393
+ Some ( (
394
+ Key :: new ( 1 , CryptoAlgo :: HmacSha384 , "HOLO" . as_bytes ( ) . to_vec ( ) ) ,
395
+ 843436052 ,
396
+ ) ) ,
397
+ Packet :: Hello ( Hello {
398
+ hdr : PacketHdr {
399
+ pkt_type : PacketType :: Hello ,
400
+ router_id : ip4 ! ( "1.1.1.1" ) ,
401
+ area_id : ip4 ! ( "0.0.0.1" ) ,
402
+ instance_id : 0 ,
403
+ auth_seqno : Some ( 843436052 ) ,
404
+ } ,
405
+ iface_id : 4 ,
406
+ priority : 1 ,
407
+ options : Options :: R
408
+ | Options :: E
409
+ | Options :: V6
410
+ | Options :: AT
411
+ | Options :: L ,
412
+ hello_interval : 3 ,
413
+ dead_interval : 36 ,
414
+ dr : None ,
415
+ bdr : None ,
416
+ neighbors : [ ip4 ! ( "2.2.2.2" ) ] . into ( ) ,
417
+ lls : Some ( holo_ospf:: packet:: lls:: LlsHelloData {
418
+ eof : Some ( ExtendedOptionsFlags :: LR | ExtendedOptionsFlags :: RS ) ,
419
+ } ) ,
420
+ } ) ,
421
+ )
422
+ } ) ;
423
+
240
424
static HELLO1_HMAC_SHA512 : Lazy < ( Vec < u8 > , Option < ( Key , u64 ) > , Packet < Ospfv3 > ) > =
241
425
Lazy :: new ( || {
242
426
(
@@ -279,6 +463,57 @@ static HELLO1_HMAC_SHA512: Lazy<(Vec<u8>, Option<(Key, u64)>, Packet<Ospfv3>)> =
279
463
)
280
464
} ) ;
281
465
466
+ static HELLO1_HMAC_SHA512_LLS : Lazy < (
467
+ Vec < u8 > ,
468
+ Option < ( Key , u64 ) > ,
469
+ Packet < Ospfv3 > ,
470
+ ) > = Lazy :: new ( || {
471
+ (
472
+ vec ! [
473
+ 0x03 , 0x01 , 0x00 , 0x28 , 0x01 , 0x01 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 ,
474
+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04 , 0x01 , 0x00 ,
475
+ 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 ,
485
+ ] ,
486
+ Some ( (
487
+ Key :: new ( 1 , CryptoAlgo :: HmacSha512 , "HOLO" . as_bytes ( ) . to_vec ( ) ) ,
488
+ 843436052 ,
489
+ ) ) ,
490
+ Packet :: Hello ( Hello {
491
+ hdr : PacketHdr {
492
+ pkt_type : PacketType :: Hello ,
493
+ router_id : ip4 ! ( "1.1.1.1" ) ,
494
+ area_id : ip4 ! ( "0.0.0.1" ) ,
495
+ instance_id : 0 ,
496
+ auth_seqno : Some ( 843436052 ) ,
497
+ } ,
498
+ iface_id : 4 ,
499
+ priority : 1 ,
500
+ options : Options :: R
501
+ | Options :: E
502
+ | Options :: V6
503
+ | Options :: AT
504
+ | Options :: L ,
505
+ hello_interval : 3 ,
506
+ dead_interval : 36 ,
507
+ dr : None ,
508
+ bdr : None ,
509
+ neighbors : [ ip4 ! ( "2.2.2.2" ) ] . into ( ) ,
510
+ lls : Some ( holo_ospf:: packet:: lls:: LlsHelloData {
511
+ eof : Some ( ExtendedOptionsFlags :: LR | ExtendedOptionsFlags :: RS ) ,
512
+ } ) ,
513
+ } ) ,
514
+ )
515
+ } ) ;
516
+
282
517
static DBDESCR1 : Lazy < ( Vec < u8 > , Option < ( Key , u64 ) > , Packet < Ospfv3 > ) > =
283
518
Lazy :: new ( || {
284
519
(
@@ -998,6 +1233,18 @@ fn test_decode_hello1() {
998
1233
test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
999
1234
}
1000
1235
1236
+ #[ test]
1237
+ fn test_encode_hello1_lls ( ) {
1238
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_LLS ;
1239
+ test_encode_packet ( bytes, auth, hello) ;
1240
+ }
1241
+
1242
+ #[ test]
1243
+ fn test_decode_hello1_lls ( ) {
1244
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_LLS ;
1245
+ test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1246
+ }
1247
+
1001
1248
#[ test]
1002
1249
fn test_encode_hello_hmac_sha1 ( ) {
1003
1250
let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA1 ;
@@ -1010,6 +1257,18 @@ fn test_decode_hello_hmac_sha1() {
1010
1257
test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1011
1258
}
1012
1259
1260
+ #[ test]
1261
+ fn test_encode_hello_hmac_sha1_lls ( ) {
1262
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA1_LLS ;
1263
+ test_encode_packet ( bytes, auth, hello) ;
1264
+ }
1265
+
1266
+ #[ test]
1267
+ fn test_decode_hello_hmac_sha1_lls ( ) {
1268
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA1_LLS ;
1269
+ test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1270
+ }
1271
+
1013
1272
#[ test]
1014
1273
fn test_encode_hello_hmac_sha256 ( ) {
1015
1274
let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA256 ;
@@ -1022,6 +1281,18 @@ fn test_decode_hello_hmac_sha256() {
1022
1281
test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1023
1282
}
1024
1283
1284
+ #[ test]
1285
+ fn test_encode_hello_hmac_sha256_lls ( ) {
1286
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA256_LLS ;
1287
+ test_encode_packet ( bytes, auth, hello) ;
1288
+ }
1289
+
1290
+ #[ test]
1291
+ fn test_decode_hello_hmac_sha256_lls ( ) {
1292
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA256_LLS ;
1293
+ test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1294
+ }
1295
+
1025
1296
#[ test]
1026
1297
fn test_encode_hello_hmac_sha384 ( ) {
1027
1298
let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA384 ;
@@ -1034,6 +1305,18 @@ fn test_decode_hello_hmac_sha384() {
1034
1305
test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1035
1306
}
1036
1307
1308
+ #[ test]
1309
+ fn test_encode_hello_hmac_sha384_lls ( ) {
1310
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA384_LLS ;
1311
+ test_encode_packet ( bytes, auth, hello) ;
1312
+ }
1313
+
1314
+ #[ test]
1315
+ fn test_decode_hello_hmac_sha384_lls ( ) {
1316
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA384_LLS ;
1317
+ test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1318
+ }
1319
+
1037
1320
#[ test]
1038
1321
fn test_encode_hello_hmac_sha512 ( ) {
1039
1322
let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA512 ;
@@ -1046,6 +1329,18 @@ fn test_decode_hello_hmac_sha512() {
1046
1329
test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1047
1330
}
1048
1331
1332
+ #[ test]
1333
+ fn test_encode_hello_hmac_sha512_lls ( ) {
1334
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA512_LLS ;
1335
+ test_encode_packet ( bytes, auth, hello) ;
1336
+ }
1337
+
1338
+ #[ test]
1339
+ fn test_decode_hello_hmac_sha512_lls ( ) {
1340
+ let ( ref bytes, ref auth, ref hello) = * HELLO1_HMAC_SHA512_LLS ;
1341
+ test_decode_packet ( bytes, auth, hello, AddressFamily :: Ipv6 ) ;
1342
+ }
1343
+
1049
1344
#[ test]
1050
1345
fn test_encode_dbdescr1 ( ) {
1051
1346
let ( ref bytes, ref auth, ref dbdescr) = * DBDESCR1 ;
0 commit comments