32
32
* RFC 8966
33
33
* RFC 8967
34
34
* RFC 9079
35
+ * RFC 9229
35
36
*/
36
37
37
38
#ifdef HAVE_CONFIG_H
@@ -206,7 +207,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
206
207
207
208
if (plen >= 0 )
208
209
pb = (plen + 7 ) / 8 ;
209
- else if (ae == 1 )
210
+ else if (ae == 1 || ae == 4 )
210
211
pb = 4 ;
211
212
else
212
213
pb = 16 ;
@@ -219,6 +220,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
219
220
switch (ae ) {
220
221
case 0 : break ;
221
222
case 1 :
223
+ case 4 :
222
224
if (omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted ))
223
225
return -1 ;
224
226
memcpy (prefix , v4prefix , 12 );
@@ -381,6 +383,8 @@ babel_print_v2_tlvs(netdissect_options *ndo,
381
383
u_char v4_prefix [16 ] =
382
384
{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF , 0xFF , 0 , 0 , 0 , 0 };
383
385
u_char v6_prefix [16 ] = {0 };
386
+ u_char v4viav6_prefix [16 ] =
387
+ {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF , 0xFF , 0 , 0 , 0 , 0 };
384
388
385
389
i = 0 ;
386
390
while (i < tlvs_length ) {
@@ -535,31 +539,45 @@ babel_print_v2_tlvs(netdissect_options *ndo,
535
539
u_char ae , plen ;
536
540
int rc ;
537
541
u_char prefix [16 ];
542
+ u_char * update_prefix ;
538
543
ND_PRINT ("\n\tUpdate" );
539
544
if (len < 10 ) goto invalid ;
540
545
ae = GET_U_1 (message + 2 );
541
- plen = GET_U_1 (message + 4 ) + (GET_U_1 (message + 2 ) == 1 ? 96 : 0 );
546
+ switch (ae ) {
547
+ case 0 :
548
+ case 2 :
549
+ case 3 :
550
+ update_prefix = v6_prefix ;
551
+ break ;
552
+ case 1 :
553
+ update_prefix = v4_prefix ;
554
+ break ;
555
+ case 4 :
556
+ update_prefix = v4viav6_prefix ;
557
+ break ;
558
+ default :
559
+ goto invalid ;
560
+ }
561
+ plen = GET_U_1 (message + 4 ) + ((ae == 1 || ae == 4 ) ? 96 : 0 );
542
562
rc = network_prefix (ae ,
543
563
GET_U_1 (message + 4 ),
544
564
GET_U_1 (message + 5 ),
545
565
message + 12 ,
546
- GET_U_1 ( message + 2 ) == 1 ? v4_prefix : v6_prefix ,
566
+ update_prefix ,
547
567
len - 10 , prefix );
548
568
if (rc < 0 ) goto invalid ;
549
569
interval = GET_BE_U_2 (message + 6 );
550
570
seqno = GET_BE_U_2 (message + 8 );
551
571
metric = GET_BE_U_2 (message + 10 );
552
- ND_PRINT ("%s%s%s %s metric %u seqno %u interval %s" ,
572
+ ND_PRINT ("%s%s%s %s metric %u seqno %u interval %s%s " ,
553
573
(GET_U_1 (message + 3 ) & 0x80 ) ? "/prefix" : "" ,
554
574
(GET_U_1 (message + 3 ) & 0x40 ) ? "/id" : "" ,
555
575
(GET_U_1 (message + 3 ) & 0x3f ) ? "/unknown" : "" ,
556
576
ae == 0 ? "any" : format_prefix (ndo , prefix , plen ),
557
- metric , seqno , format_interval_update (interval ));
577
+ metric , seqno , format_interval_update (interval ),
578
+ ae == 4 ? " (v4-via-v6)" : "" );
558
579
if (GET_U_1 (message + 3 ) & 0x80 ) {
559
- if (GET_U_1 (message + 2 ) == 1 )
560
- memcpy (v4_prefix , prefix , 16 );
561
- else
562
- memcpy (v6_prefix , prefix , 16 );
580
+ memcpy (update_prefix , prefix , 16 );
563
581
}
564
582
/* extra data? */
565
583
if ((u_int )rc < len - 10 )
@@ -582,8 +600,9 @@ babel_print_v2_tlvs(netdissect_options *ndo,
582
600
GET_U_1 (message + 3 ), 0 ,
583
601
message + 4 , NULL , len - 2 , prefix );
584
602
if (rc < 0 ) goto invalid ;
585
- ND_PRINT ("for %s" ,
586
- ae == 0 ? "any" : format_prefix (ndo , prefix , plen ));
603
+ ND_PRINT ("for %s%s" ,
604
+ ae == 0 ? "any" : format_prefix (ndo , prefix , plen ),
605
+ ae == 4 ? " (v4-via-v6)" : "" );
587
606
}
588
607
}
589
608
break ;
@@ -604,10 +623,11 @@ babel_print_v2_tlvs(netdissect_options *ndo,
604
623
message + 16 , NULL , len - 14 , prefix );
605
624
if (rc < 0 ) goto invalid ;
606
625
plen = GET_U_1 (message + 3 ) + (GET_U_1 (message + 2 ) == 1 ? 96 : 0 );
607
- ND_PRINT ("(%u hops) for %s seqno %u id %s" ,
626
+ ND_PRINT ("(%u hops) for %s seqno %u id %s%s " ,
608
627
GET_U_1 (message + 6 ),
609
628
ae == 0 ? "invalid AE 0" : format_prefix (ndo , prefix , plen ),
610
- seqno , format_id (ndo , message + 8 ));
629
+ seqno , format_id (ndo , message + 8 ),
630
+ ae == 4 ? " (v4-via-v6)" : "" );
611
631
}
612
632
}
613
633
break ;
@@ -710,6 +730,9 @@ babel_print_v2_tlvs(netdissect_options *ndo,
710
730
ND_PRINT ("for (%s, " , format_prefix (ndo , prefix , plen ));
711
731
ND_PRINT ("%s)" , format_prefix (ndo , src_prefix , src_plen ));
712
732
}
733
+ if (ae == 4 ) {
734
+ ND_PRINT (" (v4-via-v6)" );
735
+ }
713
736
}
714
737
}
715
738
break ;
@@ -746,6 +769,9 @@ babel_print_v2_tlvs(netdissect_options *ndo,
746
769
ND_PRINT ("%s) seqno %u id %s" ,
747
770
format_prefix (ndo , src_prefix , src_plen ),
748
771
seqno , format_id (ndo , router_id ));
772
+ if (ae == 4 ) {
773
+ ND_PRINT (" (v4-via-v6)" );
774
+ }
749
775
}
750
776
}
751
777
break ;
0 commit comments