@@ -4464,6 +4464,7 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context,
4464
4464
uint8_t length ;
4465
4465
uint8_t subtlv_len ;
4466
4466
uint8_t size ;
4467
+ int num_msd ;
4467
4468
4468
4469
sbuf_push (log , indent , "Unpacking Router Capability TLV...\n" );
4469
4470
if (tlv_len < ISIS_ROUTER_CAP_SIZE ) {
@@ -4632,19 +4633,66 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context,
4632
4633
4633
4634
break ;
4634
4635
case ISIS_SUBTLV_NODE_MSD :
4636
+ sbuf_push (log , indent ,
4637
+ "Unpacking Node MSD sub-TLV...\n" );
4638
+
4635
4639
/* Check that MSD is correctly formated */
4636
- if (length < MSD_TLV_SIZE ) {
4640
+ if (length % 2 ) {
4641
+ sbuf_push (
4642
+ log , indent ,
4643
+ "WARNING: Unexpected MSD sub-TLV length\n" );
4637
4644
stream_forward_getp (s , length );
4638
4645
break ;
4639
4646
}
4640
- msd_type = stream_getc (s );
4641
- rcap -> msd = stream_getc (s );
4642
- /* Only BMI-MSD type has been defined in RFC 8491 */
4643
- if (msd_type != MSD_TYPE_BASE_MPLS_IMPOSITION )
4644
- rcap -> msd = 0 ;
4645
- /* Only one MSD is standardized. Skip others */
4646
- if (length > MSD_TLV_SIZE )
4647
- stream_forward_getp (s , length - MSD_TLV_SIZE );
4647
+
4648
+ /* Get the number of MSDs carried in the value field of
4649
+ * the Node MSD sub-TLV. The value field consists of one
4650
+ * or more pairs of a 1-octet MSD-Type and 1-octet
4651
+ * MSD-Value */
4652
+ num_msd = length / 2 ;
4653
+
4654
+ /* Unpack MSDs */
4655
+ for (int i = 0 ; i < num_msd ; i ++ ) {
4656
+ msd_type = stream_getc (s );
4657
+
4658
+ switch (msd_type ) {
4659
+ case MSD_TYPE_BASE_MPLS_IMPOSITION :
4660
+ /* BMI-MSD type as per RFC 8491 */
4661
+ rcap -> msd = stream_getc (s );
4662
+ break ;
4663
+ case ISIS_SUBTLV_SRV6_MAX_SL_MSD :
4664
+ /* SRv6 Maximum Segments Left MSD Type
4665
+ * as per RFC 9352 section #4.1 */
4666
+ rcap -> srv6_msd .max_seg_left_msd =
4667
+ stream_getc (s );
4668
+ break ;
4669
+ case ISIS_SUBTLV_SRV6_MAX_END_POP_MSD :
4670
+ /* SRv6 Maximum End Pop MSD Type as per
4671
+ * RFC 9352 section #4.2 */
4672
+ rcap -> srv6_msd .max_end_pop_msd =
4673
+ stream_getc (s );
4674
+ break ;
4675
+ case ISIS_SUBTLV_SRV6_MAX_H_ENCAPS_MSD :
4676
+ /* SRv6 Maximum H.Encaps MSD Type as per
4677
+ * RFC 9352 section #4.3 */
4678
+ rcap -> srv6_msd .max_h_encaps_msd =
4679
+ stream_getc (s );
4680
+ break ;
4681
+ case ISIS_SUBTLV_SRV6_MAX_END_D_MSD :
4682
+ /* SRv6 Maximum End D MSD Type as per
4683
+ * RFC 9352 section #4.4 */
4684
+ rcap -> srv6_msd .max_end_d_msd =
4685
+ stream_getc (s );
4686
+ break ;
4687
+ default :
4688
+ /* Unknown MSD, let's skip it */
4689
+ sbuf_push (
4690
+ log , indent ,
4691
+ "WARNING: Skipping unknown MSD Type %hhu (1 byte)\n" ,
4692
+ msd_type );
4693
+ stream_forward_getp (s , 1 );
4694
+ }
4695
+ }
4648
4696
break ;
4649
4697
#ifndef FABRICD
4650
4698
case ISIS_SUBTLV_FAD :
0 commit comments