/**
* Link State Node management functions
*/
+int ls_node_id_same(struct ls_node_id i1, struct ls_node_id i2)
+{
+ if (i1.origin != i2.origin)
+ return 0;
+
+ if (i1.origin == UNKNOWN)
+ return 1;
+
+ if (i1.origin == ISIS_L1 || i1.origin == ISIS_L2) {
+ if (memcmp(i1.id.iso.sys_id, i2.id.iso.sys_id, ISO_SYS_ID_LEN)
+ != 0
+ || (i1.id.iso.level != i2.id.iso.level))
+ return 0;
+ } else {
+ if (!IPV4_ADDR_SAME(&i1.id.ip.addr, &i2.id.ip.addr)
+ || !IPV4_ADDR_SAME(&i1.id.ip.area_id, &i2.id.ip.area_id))
+ return 1;
+ }
+
+ return 1;
+}
+
struct ls_node *ls_node_new(struct ls_node_id adv, struct in_addr rid,
struct in6_addr rid6)
{
}
}
if (!IN6_IS_ADDR_UNSPECIFIED(&rid6)) {
- new->router6_id = rid6;
+ new->router_id6 = rid6;
SET_FLAG(new->flags, LS_NODE_ROUTER_ID6);
}
return new;
int ls_node_same(struct ls_node *n1, struct ls_node *n2)
{
+ /* First, check pointer */
if ((n1 && !n2) || (!n1 && n2))
return 0;
if (n1 == n2)
return 1;
+ /* Then, verify Flags and Origin */
if (n1->flags != n2->flags)
return 0;
- if (n1->adv.origin != n2->adv.origin)
+ if (!ls_node_id_same(n1->adv, n2->adv))
return 0;
- if (!memcmp(&n1->adv.id, &n2->adv.id, sizeof(struct ls_node_id)))
+ /* Finally, check each individual parameters that are valid */
+ if (CHECK_FLAG(n1->flags, LS_NODE_NAME)
+ && (strncmp(n1->name, n2->name, MAX_NAME_LENGTH) != 0))
return 0;
-
- /* Do we need to test individually each field, instead performing a
- * global memcmp? There is a risk that an old value that is bit masked
- * i.e. corresponding flag = 0, will result into a false negative
- */
- if (!memcmp(n1, n2, sizeof(struct ls_node)))
+ if (CHECK_FLAG(n1->flags, LS_NODE_ROUTER_ID)
+ && !IPV4_ADDR_SAME(&n1->router_id, &n2->router_id))
return 0;
- else
- return 1;
+ if (CHECK_FLAG(n1->flags, LS_NODE_ROUTER_ID6)
+ && !IPV6_ADDR_SAME(&n1->router_id6, &n2->router_id6))
+ return 0;
+ if (CHECK_FLAG(n1->flags, LS_NODE_FLAG)
+ && (n1->node_flag != n2->node_flag))
+ return 0;
+ if (CHECK_FLAG(n1->flags, LS_NODE_TYPE) && (n1->type != n2->type))
+ return 0;
+ if (CHECK_FLAG(n1->flags, LS_NODE_AS_NUMBER)
+ && (n1->as_number != n2->as_number))
+ return 0;
+ if (CHECK_FLAG(n1->flags, LS_NODE_SR)) {
+ if (n1->srgb.flag != n2->srgb.flag
+ || n1->srgb.lower_bound != n2->srgb.lower_bound
+ || n1->srgb.range_size != n2->srgb.range_size)
+ return 0;
+ if ((n1->algo[0] != n2->algo[0])
+ || (n1->algo[1] != n2->algo[1]))
+ return 0;
+ if (CHECK_FLAG(n1->flags, LS_NODE_SRLB)
+ && ((n1->srlb.lower_bound != n2->srlb.lower_bound
+ || n1->srlb.range_size != n2->srlb.range_size)))
+ return 0;
+ if (CHECK_FLAG(n1->flags, LS_NODE_MSD) && (n1->msd != n2->msd))
+ return 0;
+ }
+
+ /* OK, n1 & n2 are equal */
+ return 1;
}
/**
int ls_attributes_same(struct ls_attributes *l1, struct ls_attributes *l2)
{
+ /* First, check pointer */
if ((l1 && !l2) || (!l1 && l2))
return 0;
if (l1 == l2)
return 1;
+ /* Then, verify Flags and Origin */
if (l1->flags != l2->flags)
return 0;
- if (l1->adv.origin != l2->adv.origin)
+ if (!ls_node_id_same(l1->adv, l2->adv))
return 0;
- if (!memcmp(&l1->adv.id, &l2->adv.id, sizeof(struct ls_node_id)))
+ /* Finally, check each individual parameters that are valid */
+ if (CHECK_FLAG(l1->flags, LS_ATTR_NAME)
+ && strncmp(l1->name, l2->name, MAX_NAME_LENGTH) != 0)
return 0;
-
- /* Do we need to test individually each field, instead performing a
- * global memcmp? There is a risk that an old value that is bit masked
- * i.e. corresponding flag = 0, will result into a false negative
- */
- if (!memcmp(l1, l2, sizeof(struct ls_attributes)))
+ if (CHECK_FLAG(l1->flags, LS_ATTR_METRIC) && (l1->metric != l2->metric))
return 0;
- else
- return 1;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_TE_METRIC)
+ && (l1->standard.te_metric != l2->standard.te_metric))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_ADM_GRP)
+ && (l1->standard.admin_group != l2->standard.admin_group))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_LOCAL_ADDR)
+ && !IPV4_ADDR_SAME(&l1->standard.local, &l2->standard.local))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_NEIGH_ADDR)
+ && !IPV4_ADDR_SAME(&l1->standard.remote, &l2->standard.remote))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_LOCAL_ADDR6)
+ && !IPV6_ADDR_SAME(&l1->standard.local6, &l2->standard.local6))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_NEIGH_ADDR6)
+ && !IPV6_ADDR_SAME(&l1->standard.remote6, &l2->standard.remote6))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_LOCAL_ID)
+ && (l1->standard.local_id != l2->standard.local_id))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_NEIGH_ID)
+ && (l1->standard.remote_id != l2->standard.remote_id))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_MAX_BW)
+ && (l1->standard.max_bw != l2->standard.max_bw))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_MAX_RSV_BW)
+ && (l1->standard.max_rsv_bw != l2->standard.max_rsv_bw))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_UNRSV_BW)
+ && memcmp(&l1->standard.unrsv_bw, &l2->standard.unrsv_bw, 32) != 0)
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_REMOTE_AS)
+ && (l1->standard.remote_as != l2->standard.remote_as))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_REMOTE_ADDR)
+ && !IPV4_ADDR_SAME(&l1->standard.remote_addr,
+ &l2->standard.remote_addr))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_REMOTE_ADDR6)
+ && !IPV6_ADDR_SAME(&l1->standard.remote_addr6,
+ &l2->standard.remote_addr6))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_DELAY)
+ && (l1->extended.delay != l2->extended.delay))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_MIN_MAX_DELAY)
+ && ((l1->extended.min_delay != l2->extended.min_delay)
+ || (l1->extended.max_delay != l2->extended.max_delay)))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_JITTER)
+ && (l1->extended.jitter != l2->extended.jitter))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_PACKET_LOSS)
+ && (l1->extended.pkt_loss != l2->extended.pkt_loss))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_AVA_BW)
+ && (l1->extended.ava_bw != l2->extended.ava_bw))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_RSV_BW)
+ && (l1->extended.rsv_bw != l2->extended.rsv_bw))
+ return 0;
+ if (CHECK_FLAG(l1->flags, LS_ATTR_USE_BW)
+ && (l1->extended.used_bw != l2->extended.used_bw))
+ return 0;
+ for (int i = 0; i < LS_ADJ_MAX; i++) {
+ if (!CHECK_FLAG(l1->flags, (LS_ATTR_ADJ_SID << i)))
+ continue;
+ if ((l1->adj_sid[i].sid != l2->adj_sid[i].sid)
+ || (l1->adj_sid[i].flags != l2->adj_sid[i].flags)
+ || (l1->adj_sid[i].weight != l2->adj_sid[i].weight))
+ return 0;
+ if (((l1->adv.origin == ISIS_L1) || (l1->adv.origin == ISIS_L2))
+ && (memcmp(&l1->adj_sid[i].neighbor.sysid,
+ &l2->adj_sid[i].neighbor.sysid, ISO_SYS_ID_LEN)
+ != 0))
+ return 0;
+ if (((l1->adv.origin == OSPFv2) || (l1->adv.origin == STATIC)
+ || (l1->adv.origin == DIRECT))
+ && (i < ADJ_PRI_IPV6)
+ && (!IPV4_ADDR_SAME(&l1->adj_sid[i].neighbor.addr,
+ &l2->adj_sid[i].neighbor.addr)))
+ return 0;
+ }
+ if (CHECK_FLAG(l1->flags, LS_ATTR_SRLG)
+ && ((l1->srlg_len != l2->srlg_len)
+ || memcmp(l1->srlgs, l2->srlgs,
+ l1->srlg_len * sizeof(uint32_t))
+ != 0))
+ return 0;
+
+ /* OK, l1 & l2 are equal */
+ return 1;
}
/**
int ls_prefix_same(struct ls_prefix *p1, struct ls_prefix *p2)
{
+ /* First, check pointer */
if ((p1 && !p2) || (!p1 && p2))
return 0;
if (p1 == p2)
return 1;
+ /* Then, verify Flags and Origin */
if (p1->flags != p2->flags)
return 0;
- if (p1->adv.origin != p2->adv.origin)
+ if (!ls_node_id_same(p1->adv, p2->adv))
return 0;
- if (!memcmp(&p1->adv.id, &p2->adv.id, sizeof(struct ls_node_id)))
+ /* Finally, check each individual parameters that are valid */
+ if (prefix_same(&p1->pref, &p2->pref) == 0)
return 0;
-
- /* Do we need to test individually each field, instead performing a
- * global memcmp? There is a risk that an old value that is bit masked
- * i.e. corresponding flag = 0, will result into a false negative
- */
- if (!memcmp(p1, p2, sizeof(struct ls_prefix)))
+ if (CHECK_FLAG(p1->flags, LS_PREF_IGP_FLAG)
+ && (p1->igp_flag != p2->igp_flag))
return 0;
- else
- return 1;
+ if (CHECK_FLAG(p1->flags, LS_PREF_ROUTE_TAG)
+ && (p1->route_tag != p2->route_tag))
+ return 0;
+ if (CHECK_FLAG(p1->flags, LS_PREF_EXTENDED_TAG)
+ && (p1->extended_tag != p2->extended_tag))
+ return 0;
+ if (CHECK_FLAG(p1->flags, LS_PREF_METRIC) && (p1->metric != p2->metric))
+ return 0;
+ if (CHECK_FLAG(p1->flags, LS_PREF_SR)) {
+ if ((p1->sr.algo != p2->sr.algo) || (p1->sr.sid != p2->sr.sid)
+ || (p1->sr.sid_flag != p2->sr.sid_flag))
+ return 0;
+ }
+
+ /* OK, p1 & p2 are equal */
+ return 1;
}
/**
* Link State Vertices management functions
*/
+uint64_t sysid_to_key(const uint8_t sysid[ISO_SYS_ID_LEN])
+{
+ uint64_t key = 0;
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint8_t *byte = (uint8_t *)&key;
+
+ for (int i = 0; i < ISO_SYS_ID_LEN; i++)
+ byte[i] = sysid[ISO_SYS_ID_LEN - i - 1];
+
+ byte[6] = 0;
+ byte[7] = 0;
+#else
+ memcpy(&key, sysid, ISO_SYS_ID_LEN);
+#endif
+
+ return key;
+}
+
struct ls_vertex *ls_vertex_add(struct ls_ted *ted, struct ls_node *node)
{
struct ls_vertex *new;
break;
case ISIS_L1:
case ISIS_L2:
- memcpy(&key, &node->adv.id.iso.sys_id, ISO_SYS_ID_LEN);
+ key = sysid_to_key(node->adv.id.iso.sys_id);
break;
default:
key = 0;
break;
case ISIS_L1:
case ISIS_L2:
- memcpy(&vertex.key, &nid.id.iso.sys_id, ISO_SYS_ID_LEN);
+ vertex.key = sysid_to_key(nid.id.iso.sys_id);
break;
default:
return NULL;
}
}
+static uint64_t get_edge_key(struct ls_attributes *attr, bool dst)
+{
+ uint64_t key = 0;
+ struct ls_standard *std;
+
+ if (!attr)
+ return key;
+
+ std = &attr->standard;
+
+ if (dst) {
+ /* Key is the IPv4 remote address */
+ if (CHECK_FLAG(attr->flags, LS_ATTR_NEIGH_ADDR))
+ key = ((uint64_t)ntohl(std->remote.s_addr))
+ & 0xffffffff;
+ /* or the 64 bits LSB of IPv6 remote address */
+ else if (CHECK_FLAG(attr->flags, LS_ATTR_NEIGH_ADDR6))
+ key = ((uint64_t)ntohl(std->remote6.s6_addr32[2]) << 32
+ | (uint64_t)ntohl(std->remote6.s6_addr32[3]));
+ /* of remote identifier if no IP addresses are defined */
+ else if (CHECK_FLAG(attr->flags, LS_ATTR_NEIGH_ID))
+ key = (((uint64_t)std->remote_id) & 0xffffffff)
+ | ((uint64_t)std->local_id << 32);
+ } else {
+ /* Key is the IPv4 local address */
+ if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR))
+ key = ((uint64_t)ntohl(std->local.s_addr)) & 0xffffffff;
+ /* or the 64 bits LSB of IPv6 local address */
+ else if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR6))
+ key = ((uint64_t)ntohl(std->local6.s6_addr32[2]) << 32
+ | (uint64_t)ntohl(std->local6.s6_addr32[3]));
+ /* of local identifier if no IP addresses are defined */
+ else if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ID))
+ key = (((uint64_t)std->local_id) & 0xffffffff)
+ | ((uint64_t)std->remote_id << 32);
+ }
+
+ return key;
+}
+
struct ls_edge *ls_edge_add(struct ls_ted *ted,
struct ls_attributes *attributes)
{
if (attributes == NULL)
return NULL;
- /* Key is the IPv4 local address */
- if (!IPV4_NET0(attributes->standard.local.s_addr))
- key = ((uint64_t)ntohl(attributes->standard.local.s_addr))
- & 0xffffffff;
- /* or the IPv6 local address if IPv4 is not defined */
- else if (!IN6_IS_ADDR_UNSPECIFIED(&attributes->standard.local6))
- key = (uint64_t)(attributes->standard.local6.s6_addr32[0]
- & 0xffffffff)
- | ((uint64_t)attributes->standard.local6.s6_addr32[1]
- << 32);
- /* of local identifier if no IP addresses are defined */
- else if (attributes->standard.local_id != 0)
- key = (uint64_t)(
- (attributes->standard.local_id & 0xffffffff)
- | ((uint64_t)attributes->standard.remote_id << 32));
-
- /* Check that key is valid */
+ key = get_edge_key(attributes, false);
if (key == 0)
return NULL;
/* Create Edge and add it to the TED */
new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_edge));
- if (!new)
- return NULL;
new->attributes = attributes;
new->key = key;
if (attributes == NULL)
return NULL;
- edge.key = 0;
- /* Key is the IPv4 local address */
- if (!IPV4_NET0(attributes->standard.local.s_addr))
- edge.key = ((uint64_t)ntohl(attributes->standard.local.s_addr))
- & 0xffffffff;
- /* or the IPv6 local address if IPv4 is not defined */
- else if (!IN6_IS_ADDR_UNSPECIFIED(&attributes->standard.local6))
- edge.key = (uint64_t)(attributes->standard.local6.s6_addr32[0]
- & 0xffffffff)
- | ((uint64_t)attributes->standard.local6.s6_addr32[1]
- << 32);
- /* of local identifier if no IP addresses are defined */
- else if (attributes->standard.local_id != 0)
- edge.key = (uint64_t)(
- (attributes->standard.local_id & 0xffffffff)
- | ((uint64_t)attributes->standard.remote_id << 32));
-
+ edge.key = get_edge_key(attributes, false);
if (edge.key == 0)
return NULL;
if (attributes == NULL)
return NULL;
- edge.key = 0;
- /* Key is the IPv4 remote address */
- if (!IPV4_NET0(attributes->standard.remote.s_addr))
- edge.key = ((uint64_t)ntohl(attributes->standard.remote.s_addr))
- & 0xffffffff;
- /* or the IPv6 remote address if IPv4 is not defined */
- else if (!IN6_IS_ADDR_UNSPECIFIED(&attributes->standard.remote6))
- edge.key =
- (uint64_t)(attributes->standard.remote6.s6_addr32[0]
- & 0xffffffff)
- | ((uint64_t)attributes->standard.remote6.s6_addr32[1]
- << 32);
- /* of remote identifier if no IP addresses are defined */
- else if (attributes->standard.remote_id != 0)
- edge.key = (uint64_t)(
- (attributes->standard.remote_id & 0xffffffff)
- | ((uint64_t)attributes->standard.local_id << 32));
-
+ edge.key = get_edge_key(attributes, true);
if (edge.key == 0)
return NULL;
struct ls_ted *new;
new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_ted));
- if (new == NULL)
- return new;
/* Set basic information for this ted */
new->key = key;
XFREE(MTYPE_LS_DB, ted);
}
-void ls_ted_del_all(struct ls_ted *ted)
+void ls_ted_del_all(struct ls_ted **ted)
{
struct ls_vertex *vertex;
struct ls_edge *edge;
struct ls_subnet *subnet;
- if (ted == NULL)
+ if (*ted == NULL)
return;
/* First remove Vertices, Edges and Subnets and associated Link State */
- frr_each (vertices, &ted->vertices, vertex)
- ls_vertex_del_all(ted, vertex);
- frr_each (edges, &ted->edges, edge)
- ls_edge_del_all(ted, edge);
- frr_each (subnets, &ted->subnets, subnet)
- ls_subnet_del_all(ted, subnet);
+ frr_each_safe (vertices, &(*ted)->vertices, vertex)
+ ls_vertex_del_all(*ted, vertex);
+ frr_each_safe (edges, &(*ted)->edges, edge)
+ ls_edge_del_all(*ted, edge);
+ frr_each_safe (subnets, &(*ted)->subnets, subnet)
+ ls_subnet_del_all(*ted, subnet);
/* then remove TED itself */
- ls_ted_del(ted);
+ ls_ted_del(*ted);
+ *ted = NULL;
}
void ls_ted_clean(struct ls_ted *ted)
return;
/* First, start with Vertices */
- frr_each (vertices, &ted->vertices, vertex)
+ frr_each_safe (vertices, &ted->vertices, vertex)
if (vertex->status == ORPHAN)
ls_vertex_del_all(ted, vertex);
/* Then Edges */
- frr_each (edges, &ted->edges, edge)
+ frr_each_safe (edges, &ted->edges, edge)
if (edge->status == ORPHAN)
ls_edge_del_all(ted, edge);
/* and Subnets */
- frr_each (subnets, &ted->subnets, subnet)
+ frr_each_safe (subnets, &ted->subnets, subnet)
if (subnet->status == ORPHAN)
ls_subnet_del_all(ted, subnet);
size_t len;
node = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_node));
- if (node == NULL)
- return NULL;
STREAM_GET(&node->adv, s, sizeof(struct ls_node_id));
STREAM_GETW(s, node->flags);
if (CHECK_FLAG(node->flags, LS_NODE_ROUTER_ID))
node->router_id.s_addr = stream_get_ipv4(s);
if (CHECK_FLAG(node->flags, LS_NODE_ROUTER_ID6))
- STREAM_GET(&node->router6_id, s, IPV6_MAX_BYTELEN);
+ STREAM_GET(&node->router_id6, s, IPV6_MAX_BYTELEN);
if (CHECK_FLAG(node->flags, LS_NODE_FLAG))
STREAM_GETC(s, node->node_flag);
if (CHECK_FLAG(node->flags, LS_NODE_TYPE))
size_t len;
attr = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_attributes));
- if (attr == NULL)
- return NULL;
attr->srlgs = NULL;
STREAM_GET(&attr->adv, s, sizeof(struct ls_node_id));
if (CHECK_FLAG(attr->flags, LS_ATTR_USE_BW))
STREAM_GETF(s, attr->extended.used_bw);
if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID)) {
- STREAM_GETL(s, attr->adj_sid[0].sid);
- STREAM_GETC(s, attr->adj_sid[0].flags);
- STREAM_GETC(s, attr->adj_sid[0].weight);
- if (attr->adv.origin == ISIS_L1 || attr->adv.origin == ISIS_L2)
- STREAM_GET(attr->adj_sid[0].neighbor.sysid, s,
- ISO_SYS_ID_LEN);
- else if (attr->adv.origin == OSPFv2)
- attr->adj_sid[0].neighbor.addr.s_addr =
- stream_get_ipv4(s);
+ STREAM_GETL(s, attr->adj_sid[ADJ_PRI_IPV4].sid);
+ STREAM_GETC(s, attr->adj_sid[ADJ_PRI_IPV4].flags);
+ STREAM_GETC(s, attr->adj_sid[ADJ_PRI_IPV4].weight);
+ attr->adj_sid[ADJ_PRI_IPV4].neighbor.addr.s_addr =
+ stream_get_ipv4(s);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID)) {
- STREAM_GETL(s, attr->adj_sid[1].sid);
- STREAM_GETC(s, attr->adj_sid[1].flags);
- STREAM_GETC(s, attr->adj_sid[1].weight);
- if (attr->adv.origin == ISIS_L1 || attr->adv.origin == ISIS_L2)
- STREAM_GET(attr->adj_sid[1].neighbor.sysid, s,
- ISO_SYS_ID_LEN);
- else if (attr->adv.origin == OSPFv2)
- attr->adj_sid[1].neighbor.addr.s_addr =
- stream_get_ipv4(s);
+ STREAM_GETL(s, attr->adj_sid[ADJ_BCK_IPV4].sid);
+ STREAM_GETC(s, attr->adj_sid[ADJ_BCK_IPV4].flags);
+ STREAM_GETC(s, attr->adj_sid[ADJ_BCK_IPV4].weight);
+ attr->adj_sid[ADJ_BCK_IPV4].neighbor.addr.s_addr =
+ stream_get_ipv4(s);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID6)) {
+ STREAM_GETL(s, attr->adj_sid[ADJ_PRI_IPV6].sid);
+ STREAM_GETC(s, attr->adj_sid[ADJ_PRI_IPV6].flags);
+ STREAM_GETC(s, attr->adj_sid[ADJ_PRI_IPV6].weight);
+ STREAM_GET(attr->adj_sid[ADJ_PRI_IPV6].neighbor.sysid, s,
+ ISO_SYS_ID_LEN);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID6)) {
+ STREAM_GETL(s, attr->adj_sid[ADJ_BCK_IPV6].sid);
+ STREAM_GETC(s, attr->adj_sid[ADJ_BCK_IPV6].flags);
+ STREAM_GETC(s, attr->adj_sid[ADJ_BCK_IPV6].weight);
+ STREAM_GET(attr->adj_sid[ADJ_BCK_IPV6].neighbor.sysid, s,
+ ISO_SYS_ID_LEN);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_SRLG)) {
STREAM_GETC(s, len);
size_t len;
ls_pref = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_prefix));
- if (ls_pref == NULL)
- return NULL;
STREAM_GET(&ls_pref->adv, s, sizeof(struct ls_node_id));
STREAM_GETW(s, ls_pref->flags);
struct ls_message *msg;
msg = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_message));
- if (msg == NULL)
- return NULL;
/* Read LS Message header */
STREAM_GETC(s, msg->event);
if (CHECK_FLAG(node->flags, LS_NODE_ROUTER_ID))
stream_put_ipv4(s, node->router_id.s_addr);
if (CHECK_FLAG(node->flags, LS_NODE_ROUTER_ID6))
- stream_put(s, &node->router6_id, IPV6_MAX_BYTELEN);
+ stream_put(s, &node->router_id6, IPV6_MAX_BYTELEN);
if (CHECK_FLAG(node->flags, LS_NODE_FLAG))
stream_putc(s, node->node_flag);
if (CHECK_FLAG(node->flags, LS_NODE_TYPE))
if (CHECK_FLAG(attr->flags, LS_ATTR_USE_BW))
stream_putf(s, attr->extended.used_bw);
if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID)) {
- stream_putl(s, attr->adj_sid[0].sid);
- stream_putc(s, attr->adj_sid[0].flags);
- stream_putc(s, attr->adj_sid[0].weight);
- if (attr->adv.origin == ISIS_L1 || attr->adv.origin == ISIS_L2)
- stream_put(s, attr->adj_sid[0].neighbor.sysid,
- ISO_SYS_ID_LEN);
- else if (attr->adv.origin == OSPFv2)
- stream_put_ipv4(s,
- attr->adj_sid[0].neighbor.addr.s_addr);
+ stream_putl(s, attr->adj_sid[ADJ_PRI_IPV4].sid);
+ stream_putc(s, attr->adj_sid[ADJ_PRI_IPV4].flags);
+ stream_putc(s, attr->adj_sid[ADJ_PRI_IPV4].weight);
+ stream_put_ipv4(
+ s, attr->adj_sid[ADJ_PRI_IPV4].neighbor.addr.s_addr);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID)) {
- stream_putl(s, attr->adj_sid[1].sid);
- stream_putc(s, attr->adj_sid[1].flags);
- stream_putc(s, attr->adj_sid[1].weight);
- if (attr->adv.origin == ISIS_L1 || attr->adv.origin == ISIS_L2)
- stream_put(s, attr->adj_sid[1].neighbor.sysid,
- ISO_SYS_ID_LEN);
- else if (attr->adv.origin == OSPFv2)
- stream_put_ipv4(s,
- attr->adj_sid[1].neighbor.addr.s_addr);
+ stream_putl(s, attr->adj_sid[ADJ_BCK_IPV4].sid);
+ stream_putc(s, attr->adj_sid[ADJ_BCK_IPV4].flags);
+ stream_putc(s, attr->adj_sid[ADJ_BCK_IPV4].weight);
+ stream_put_ipv4(
+ s, attr->adj_sid[ADJ_BCK_IPV4].neighbor.addr.s_addr);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID6)) {
+ stream_putl(s, attr->adj_sid[ADJ_PRI_IPV6].sid);
+ stream_putc(s, attr->adj_sid[ADJ_PRI_IPV6].flags);
+ stream_putc(s, attr->adj_sid[ADJ_PRI_IPV6].weight);
+ stream_put(s, attr->adj_sid[ADJ_PRI_IPV6].neighbor.sysid,
+ ISO_SYS_ID_LEN);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID6)) {
+ stream_putl(s, attr->adj_sid[ADJ_BCK_IPV6].sid);
+ stream_putc(s, attr->adj_sid[ADJ_BCK_IPV6].flags);
+ stream_putc(s, attr->adj_sid[ADJ_BCK_IPV6].weight);
+ stream_put(s, attr->adj_sid[ADJ_BCK_IPV6].neighbor.sysid,
+ ISO_SYS_ID_LEN);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_SRLG)) {
stream_putc(s, attr->srlg_len);
struct listnode *node;
struct ls_node *lsn;
struct ls_edge *edge;
+ struct ls_attributes *attr;
struct ls_subnet *subnet;
struct sbuf sbuf;
uint32_t upper;
} else {
sbuf_push(&sbuf, 6, "To:\t- (0.0.0.0)");
}
- sbuf_push(&sbuf, 0, "\tLocal: %pI4\tRemote: %pI4\n",
- &edge->attributes->standard.local,
- &edge->attributes->standard.remote);
+ attr = edge->attributes;
+ if ((CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR)))
+ sbuf_push(&sbuf, 0, "\tLocal: %pI4\tRemote: %pI4\n",
+ &attr->standard.local,
+ &attr->standard.remote);
+ else if ((CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR6)))
+ sbuf_push(&sbuf, 0, "\tLocal: %pI6\tRemote: %pI6\n",
+ &attr->standard.local6,
+ &attr->standard.remote6);
}
sbuf_push(&sbuf, 4, "Incoming Edges: %d\n",
} else {
sbuf_push(&sbuf, 6, "From:\t- (0.0.0.0)");
}
- sbuf_push(&sbuf, 0, "\tRemote: %pI4\tLocal: %pI4\n",
- &edge->attributes->standard.local,
- &edge->attributes->standard.remote);
+ attr = edge->attributes;
+ if ((CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR)))
+ sbuf_push(&sbuf, 0, "\tLocal: %pI4\tRemote: %pI4\n",
+ &attr->standard.local,
+ &attr->standard.remote);
+ else if ((CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR6)))
+ sbuf_push(&sbuf, 0, "\tLocal: %pI6\tRemote: %pI6\n",
+ &attr->standard.local6,
+ &attr->standard.remote6);
}
sbuf_push(&sbuf, 4, "Subnets: %d\n", listcount(vertex->prefixes));
json_object_string_add(json, "router-id", buf);
}
if (CHECK_FLAG(lsn->flags, LS_NODE_ROUTER_ID6)) {
- snprintfrr(buf, INET6_BUFSIZ, "%pI6", &lsn->router6_id);
+ snprintfrr(buf, INET6_BUFSIZ, "%pI6", &lsn->router_id6);
json_object_string_add(json, "router-id-v6", buf);
}
if (CHECK_FLAG(lsn->flags, LS_NODE_TYPE))
sbuf_push(&sbuf, 4, "Utilized Bandwidth: %g (Bytes/s)\n",
attr->extended.used_bw);
if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID)) {
- sbuf_push(&sbuf, 4, "Adjacency-SID: %u", attr->adj_sid[0].sid);
+ sbuf_push(&sbuf, 4, "IPv4 Adjacency-SID: %u",
+ attr->adj_sid[ADJ_PRI_IPV4].sid);
sbuf_push(&sbuf, 0, "\tFlags: 0x%x\tWeight: 0x%x\n",
- attr->adj_sid[0].flags, attr->adj_sid[0].weight);
+ attr->adj_sid[ADJ_PRI_IPV4].flags,
+ attr->adj_sid[ADJ_PRI_IPV4].weight);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID)) {
- sbuf_push(&sbuf, 4, "Bck. Adjacency-SID: %u",
- attr->adj_sid[1].sid);
+ sbuf_push(&sbuf, 4, "IPv4 Bck. Adjacency-SID: %u",
+ attr->adj_sid[ADJ_BCK_IPV4].sid);
+ sbuf_push(&sbuf, 0, "\tFlags: 0x%x\tWeight: 0x%x\n",
+ attr->adj_sid[ADJ_BCK_IPV4].flags,
+ attr->adj_sid[ADJ_BCK_IPV4].weight);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID6)) {
+ sbuf_push(&sbuf, 4, "IPv6 Adjacency-SID: %u",
+ attr->adj_sid[ADJ_PRI_IPV6].sid);
sbuf_push(&sbuf, 0, "\tFlags: 0x%x\tWeight: 0x%x\n",
- attr->adj_sid[1].flags, attr->adj_sid[1].weight);
+ attr->adj_sid[ADJ_PRI_IPV6].flags,
+ attr->adj_sid[ADJ_PRI_IPV6].weight);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID6)) {
+ sbuf_push(&sbuf, 4, "IPv6 Bck. Adjacency-SID: %u",
+ attr->adj_sid[ADJ_BCK_IPV6].sid);
+ sbuf_push(&sbuf, 0, "\tFlags: 0x%x\tWeight: 0x%x\n",
+ attr->adj_sid[ADJ_BCK_IPV6].flags,
+ attr->adj_sid[ADJ_BCK_IPV6].weight);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_SRLG)) {
sbuf_push(&sbuf, 4, "SRLGs: %d", attr->srlg_len);
jsr = json_object_new_array();
json_object_object_add(json, "segment-routing", jsr);
jobj = json_object_new_object();
- json_object_int_add(jobj, "adj-sid", attr->adj_sid[0].sid);
- snprintfrr(buf, 6, "0x%x", attr->adj_sid[0].flags);
+ json_object_int_add(jobj, "adj-sid",
+ attr->adj_sid[ADJ_PRI_IPV4].sid);
+ snprintfrr(buf, 6, "0x%x", attr->adj_sid[ADJ_PRI_IPV4].flags);
json_object_string_add(jobj, "flags", buf);
- json_object_int_add(jobj, "weight", attr->adj_sid[0].weight);
+ json_object_int_add(jobj, "weight",
+ attr->adj_sid[ADJ_PRI_IPV4].weight);
json_object_array_add(jsr, jobj);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID)) {
json_object_object_add(json, "segment-routing", jsr);
}
jobj = json_object_new_object();
- json_object_int_add(jobj, "adj-sid", attr->adj_sid[1].sid);
- snprintfrr(buf, 6, "0x%x", attr->adj_sid[1].flags);
+ json_object_int_add(jobj, "adj-sid",
+ attr->adj_sid[ADJ_BCK_IPV4].sid);
+ snprintfrr(buf, 6, "0x%x", attr->adj_sid[ADJ_BCK_IPV4].flags);
+ json_object_string_add(jobj, "flags", buf);
+ json_object_int_add(jobj, "weight",
+ attr->adj_sid[ADJ_BCK_IPV4].weight);
+ json_object_array_add(jsr, jobj);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID6)) {
+ jsr = json_object_new_array();
+ json_object_object_add(json, "segment-routing", jsr);
+ jobj = json_object_new_object();
+ json_object_int_add(jobj, "adj-sid",
+ attr->adj_sid[ADJ_PRI_IPV6].sid);
+ snprintfrr(buf, 6, "0x%x", attr->adj_sid[ADJ_PRI_IPV6].flags);
+ json_object_string_add(jobj, "flags", buf);
+ json_object_int_add(jobj, "weight",
+ attr->adj_sid[ADJ_PRI_IPV6].weight);
+ json_object_array_add(jsr, jobj);
+ }
+ if (CHECK_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SID6)) {
+ if (!jsr) {
+ jsr = json_object_new_array();
+ json_object_object_add(json, "segment-routing", jsr);
+ }
+ jobj = json_object_new_object();
+ json_object_int_add(jobj, "adj-sid",
+ attr->adj_sid[ADJ_BCK_IPV6].sid);
+ snprintfrr(buf, 6, "0x%x", attr->adj_sid[ADJ_BCK_IPV6].flags);
json_object_string_add(jobj, "flags", buf);
- json_object_int_add(jobj, "weight", attr->adj_sid[1].weight);
+ json_object_int_add(jobj, "weight",
+ attr->adj_sid[ADJ_BCK_IPV6].weight);
json_object_array_add(jsr, jobj);
}
}