+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* IS-IS TLV Serializer/Deserializer
*
* Copyright (C) 2015,2017 Christian Franke
*
* Copyright (C) 2019 Olivier Dugeon - Orange Labs (for TE and SR)
- *
- * This file is part of FRR.
- *
- * FRR is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRR is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FRR; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
*/
-#include <json-c/json_object.h>
+
#include <zebra.h>
+#include <json-c/json_object.h>
#ifdef CRYPTO_INTERNAL
#include "md5.h"
static void append_item(struct isis_item_list *dest, struct isis_item *item);
static void init_item_list(struct isis_item_list *items);
+/* For tests/isisd, TLV text requires ipv4-unicast instead of standard */
+static const char *isis_mtid2str_fake(uint16_t mtid)
+{
+ if (mtid == ISIS_MT_STANDARD)
+ return "ipv4-unicast";
+ return isis_mtid2str(mtid);
+}
+
/* Functions for Extended IS Reachability SubTLVs a.k.a Traffic Engineering */
struct isis_ext_subtlvs *isis_alloc_ext_subtlvs(void)
{
return ext;
}
+void isis_del_ext_subtlvs(struct isis_ext_subtlvs *ext)
+{
+ struct isis_item *item, *next_item;
+
+ if (!ext)
+ return;
+
+ /* First, free Adj SID and LAN Adj SID list if needed */
+ for (item = ext->adj_sid.head; item; item = next_item) {
+ next_item = item->next;
+ XFREE(MTYPE_ISIS_SUBTLV, item);
+ }
+ for (item = ext->lan_sid.head; item; item = next_item) {
+ next_item = item->next;
+ XFREE(MTYPE_ISIS_SUBTLV, item);
+ }
+ XFREE(MTYPE_ISIS_SUBTLV, ext);
+}
+
/*
* mtid parameter is used to determine if Adjacency is related to IPv4 or IPv6
* Multi-Topology. Special 4096 value i.e. first R flag set is used to indicate
static void free_item_ext_subtlvs(struct isis_ext_subtlvs *exts)
{
- struct isis_item *item, *next_item;
-
- /* First, free Adj SID and LAN Adj SID list if needed */
- for (item = exts->adj_sid.head; item; item = next_item) {
- next_item = item->next;
- XFREE(MTYPE_ISIS_SUBTLV, item);
- }
- for (item = exts->lan_sid.head; item; item = next_item) {
- next_item = item->next;
- XFREE(MTYPE_ISIS_SUBTLV, item);
- }
- XFREE(MTYPE_ISIS_SUBTLV, exts);
+ isis_del_ext_subtlvs(exts);
}
static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts,
log, indent,
"TLV size does not match expected size for Adjacency SID!\n");
stream_forward_getp(s, subtlv_len - 2);
+ XFREE(MTYPE_ISIS_SUBTLV, adj);
break;
}
log, indent,
"TLV size does not match expected size for Adjacency SID!\n");
stream_forward_getp(s, subtlv_len - 2);
+ XFREE(MTYPE_ISIS_SUBTLV, adj);
break;
}
stream_forward_getp(
s, subtlv_len - 2
- ISIS_SYS_ID_LEN);
+ XFREE(MTYPE_ISIS_SUBTLV, lan);
break;
}
stream_forward_getp(
s, subtlv_len - 2
- ISIS_SYS_ID_LEN);
+ XFREE(MTYPE_ISIS_SUBTLV, lan);
break;
}
static void free_item_extended_reach(struct isis_item *i)
{
struct isis_extended_reach *item = (struct isis_extended_reach *)i;
+
if (item->subtlvs != NULL)
free_item_ext_subtlvs(item->subtlvs);
XFREE(MTYPE_ISIS_TLV, item);
json_object_string_add(mt_json, "attached", info->attached?"true":"false");
} else
sbuf_push(buf, indent, "MT Router Info: %s%s%s\n",
- isis_mtid2str(info->mtid),
+ isis_mtid2str_fake(info->mtid),
info->overload ? " Overload" : "",
info->attached ? " Attached" : "");
}
}
static int unpack_tlv_router_cap(enum isis_tlv_context context,
- uint8_t tlv_type, uint8_t tlv_len,
- struct stream *s, struct sbuf *log,
- void *dest, int indent)
+ uint8_t tlv_type, uint8_t tlv_len,
+ struct stream *s, struct sbuf *log, void *dest,
+ int indent)
{
struct isis_tlvs *tlvs = dest;
struct isis_router_cap *rcap;
log, indent,
"WARNING: Router Capability subTLV length too large compared to expected size\n");
stream_forward_getp(s, STREAM_READABLE(s));
-
+ XFREE(MTYPE_ISIS_TLV, rcap);
return 0;
}
mtid = stream_getw(s) & ISIS_MT_MASK;
tlv_pos += 2;
sbuf_push(log, indent, "Unpacking as MT %s item TLV...\n",
- isis_mtid2str(mtid));
+ isis_mtid2str_fake(mtid));
} else {
sbuf_push(log, indent, "Unpacking as item TLV...\n");
mtid = ISIS_MT_IPV4_UNICAST;