#include "isisd/isis_te.h"
#include "isisd/isis_sr.h"
+#define TLV_SIZE_MISMATCH(log, indent, target) \
+ sbuf_push(log, indent, \
+ "TLV size does not match expected size for " target "!\n")
+
DEFINE_MTYPE_STATIC(ISISD, ISIS_TLV, "ISIS TLVs");
DEFINE_MTYPE(ISISD, ISIS_SUBTLV, "ISIS Sub-TLVs");
DEFINE_MTYPE_STATIC(ISISD, ISIS_MT_ITEM_LIST, "ISIS MT Item Lists");
/* Standard Metric as defined in RFC5305 */
case ISIS_SUBTLV_ADMIN_GRP:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Administrative Group!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Administrative Group");
stream_forward_getp(s, subtlv_len);
} else {
exts->adm_group = stream_getl(s);
break;
case ISIS_SUBTLV_LLRI:
if (subtlv_len != ISIS_SUBTLV_LLRI_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Link ID!\n");
+ TLV_SIZE_MISMATCH(log, indent, "Link ID");
stream_forward_getp(s, subtlv_len);
} else {
exts->local_llri = stream_getl(s);
break;
case ISIS_SUBTLV_LOCAL_IPADDR:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Local IP address!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Local IP address");
stream_forward_getp(s, subtlv_len);
} else {
stream_get(&exts->local_addr.s_addr, s, 4);
break;
case ISIS_SUBTLV_RMT_IPADDR:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Remote IP address!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Remote IP address");
stream_forward_getp(s, subtlv_len);
} else {
stream_get(&exts->neigh_addr.s_addr, s, 4);
break;
case ISIS_SUBTLV_LOCAL_IPADDR6:
if (subtlv_len != ISIS_SUBTLV_IPV6_ADDR_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Local IPv6 address!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Local IPv6 address");
stream_forward_getp(s, subtlv_len);
} else {
stream_get(&exts->local_addr6, s, 16);
break;
case ISIS_SUBTLV_RMT_IPADDR6:
if (subtlv_len != ISIS_SUBTLV_IPV6_ADDR_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Remote IPv6 address!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Remote IPv6 address");
stream_forward_getp(s, subtlv_len);
} else {
stream_get(&exts->neigh_addr6, s, 16);
break;
case ISIS_SUBTLV_MAX_BW:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Maximum Bandwidth!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Maximum Bandwidth");
stream_forward_getp(s, subtlv_len);
} else {
exts->max_bw = stream_getf(s);
break;
case ISIS_SUBTLV_MAX_RSV_BW:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Maximum Reservable Bandwidth!\n");
+ TLV_SIZE_MISMATCH(
+ log, indent,
+ "Maximum Reservable Bandwidth");
stream_forward_getp(s, subtlv_len);
} else {
exts->max_rsv_bw = stream_getf(s);
break;
case ISIS_SUBTLV_UNRSV_BW:
if (subtlv_len != ISIS_SUBTLV_UNRSV_BW_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Unreserved Bandwidth!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Unreserved Bandwidth");
stream_forward_getp(s, subtlv_len);
} else {
for (int i = 0; i < MAX_CLASS_TYPE; i++)
break;
case ISIS_SUBTLV_TE_METRIC:
if (subtlv_len != ISIS_SUBTLV_TE_METRIC_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Traffic Engineering Metric!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Traffic Engineering Metric");
stream_forward_getp(s, subtlv_len);
} else {
exts->te_metric = stream_get3(s);
break;
case ISIS_SUBTLV_RAS:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Remote AS number!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Remote AS number");
stream_forward_getp(s, subtlv_len);
} else {
exts->remote_as = stream_getl(s);
break;
case ISIS_SUBTLV_RIP:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Remote ASBR IP Address!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Remote ASBR IP Address");
stream_forward_getp(s, subtlv_len);
} else {
stream_get(&exts->remote_ip.s_addr, s, 4);
/* Extended Metrics as defined in RFC 7810 */
case ISIS_SUBTLV_AV_DELAY:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Average Link Delay!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Average Link Delay");
stream_forward_getp(s, subtlv_len);
} else {
exts->delay = stream_getl(s);
break;
case ISIS_SUBTLV_MM_DELAY:
if (subtlv_len != ISIS_SUBTLV_MM_DELAY_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Min/Max Link Delay!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Min/Max Link Delay");
stream_forward_getp(s, subtlv_len);
} else {
exts->min_delay = stream_getl(s);
break;
case ISIS_SUBTLV_DELAY_VAR:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Delay Variation!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Delay Variation");
stream_forward_getp(s, subtlv_len);
} else {
exts->delay_var = stream_getl(s);
break;
case ISIS_SUBTLV_PKT_LOSS:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Link Packet Loss!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Link Packet Loss");
stream_forward_getp(s, subtlv_len);
} else {
exts->pkt_loss = stream_getl(s);
break;
case ISIS_SUBTLV_RES_BW:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Unidirectional Residual Bandwidth!\n");
+ TLV_SIZE_MISMATCH(
+ log, indent,
+ "Unidirectional Residual Bandwidth");
stream_forward_getp(s, subtlv_len);
} else {
exts->res_bw = stream_getf(s);
break;
case ISIS_SUBTLV_AVA_BW:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Unidirectional Available Bandwidth!\n");
+ TLV_SIZE_MISMATCH(
+ log, indent,
+ "Unidirectional Available Bandwidth");
stream_forward_getp(s, subtlv_len);
} else {
exts->ava_bw = stream_getf(s);
break;
case ISIS_SUBTLV_USE_BW:
if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Unidirectional Utilized Bandwidth!\n");
+ TLV_SIZE_MISMATCH(
+ log, indent,
+ "Unidirectional Utilized Bandwidth");
stream_forward_getp(s, subtlv_len);
} else {
exts->use_bw = stream_getf(s);
case ISIS_SUBTLV_ADJ_SID:
if (subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE
&& subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE + 1) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for Adjacency SID!\n");
+ TLV_SIZE_MISMATCH(log, indent, "Adjacency SID");
stream_forward_getp(s, subtlv_len);
} else {
struct isis_adj_sid *adj;
adj->weight = stream_getc(s);
if (adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG
&& subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE) {
- sbuf_push(
- log, indent,
- "TLV size does not match expected size for Adjacency SID!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Adjacency SID");
stream_forward_getp(s, subtlv_len - 2);
XFREE(MTYPE_ISIS_SUBTLV, adj);
break;
&& subtlv_len
!= ISIS_SUBTLV_ADJ_SID_SIZE
+ 1) {
- sbuf_push(
- log, indent,
- "TLV size does not match expected size for Adjacency SID!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "Adjacency SID");
stream_forward_getp(s, subtlv_len - 2);
XFREE(MTYPE_ISIS_SUBTLV, adj);
break;
case ISIS_SUBTLV_LAN_ADJ_SID:
if (subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE
&& subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE + 1) {
- sbuf_push(log, indent,
- "TLV size does not match expected size for LAN-Adjacency SID!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "LAN-Adjacency SID");
stream_forward_getp(s, subtlv_len);
} else {
struct isis_lan_adj_sid *lan;
if (lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG
&& subtlv_len
!= ISIS_SUBTLV_LAN_ADJ_SID_SIZE) {
- sbuf_push(
- log, indent,
- "TLV size does not match expected size for LAN-Adjacency SID!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "LAN-Adjacency SID");
stream_forward_getp(
s, subtlv_len - 2
- ISIS_SYS_ID_LEN);
&& subtlv_len
!= ISIS_SUBTLV_LAN_ADJ_SID_SIZE
+ 1) {
- sbuf_push(
- log, indent,
- "TLV size does not match expected size for LAN-Adjacency SID!\n");
+ TLV_SIZE_MISMATCH(log, indent,
+ "LAN-Adjacency SID");
stream_forward_getp(
s, subtlv_len - 2
- ISIS_SYS_ID_LEN);