mirror of
https://github.com/rtbrick/bngblaster.git
synced 2024-05-06 15:54:57 +00:00
add ospf3 support for intra-area-prefix LSA
This commit is contained in:
@@ -742,7 +742,7 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
|
||||
/* Host name */
|
||||
if (node->node_name) {
|
||||
lsdb_reset_attr_template(&attr_template);
|
||||
attr_template.key.ordinal = 1;
|
||||
//attr_template.key.ordinal = 1;
|
||||
attr_template.key.attr_cp[0] = OSPF_MSG_LSUPDATE;
|
||||
attr_template.key.attr_cp[1] = OSPF_LSA_OPAQUE_AREA_RI;
|
||||
attr_template.key.attr_cp[2] = OSPF_TLV_HOSTNAME;
|
||||
@@ -756,10 +756,11 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
|
||||
lspgen_store_addr(addr, attr_template.key.prefix.ipv6_prefix.address, IPV6_ADDR_LEN);
|
||||
attr_template.key.prefix.ipv6_prefix.len = ctx->ipv6_node_prefix.len;
|
||||
attr_template.key.attr_cp[0] = OSPF_MSG_LSUPDATE;
|
||||
attr_template.key.attr_cp[1] = OSPF_LSA_ROUTER;
|
||||
attr_template.key.attr_cp[2] = OSPF_ROUTER_LSA_LINK_STUB;
|
||||
attr_template.key.attr_cp[1] = OSPF_LSA_INTRA_AREA_PREFIX;
|
||||
attr_template.key.attr_cp[2] = OSPF_IA_PREFIX_LSA_PREFIX;
|
||||
lsdb_add_node_attr(node, &attr_template);
|
||||
|
||||
#if 0
|
||||
if (!ctx->no_sr) {
|
||||
lsdb_reset_attr_template(&attr_template);
|
||||
lspgen_store_addr(addr, (uint8_t*)&attr_template.key.prefix.ipv6_prefix.address, IPV6_ADDR_LEN);
|
||||
@@ -773,6 +774,7 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
|
||||
lsdb_add_node_attr(node, &attr_template);
|
||||
}
|
||||
addr += node->node_index;
|
||||
#endif
|
||||
|
||||
/* external prefixes */
|
||||
ext_per_node = ctx->num_ext / ctx->num_nodes;
|
||||
@@ -800,7 +802,7 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
|
||||
attr_template.key.attr_cp[0] = OSPF_MSG_LSUPDATE;
|
||||
attr_template.key.attr_cp[1] = OSPF_LSA_OPAQUE_AREA_RI;
|
||||
attr_template.key.attr_cp[2] = OSPF_TLV_SID_LABEL_RANGE;
|
||||
attr_template.key.ordinal = 1;
|
||||
//attr_template.key.ordinal = 1;
|
||||
lsdb_add_node_attr(node, &attr_template);
|
||||
}
|
||||
|
||||
@@ -853,6 +855,7 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
|
||||
attr_template.key.link.metric = metric;
|
||||
lsdb_add_node_attr(node, &attr_template);
|
||||
|
||||
#if 0
|
||||
/* Generate an IPv6 prefix for each link */
|
||||
lsdb_reset_attr_template(&attr_template);
|
||||
lspgen_store_addr(addr, (uint8_t*)&attr_template.key.prefix.ipv6_prefix.address, IPV6_ADDR_LEN);
|
||||
@@ -860,9 +863,10 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
|
||||
attr_template.key.prefix.metric = metric;
|
||||
|
||||
attr_template.key.attr_cp[0] = OSPF_MSG_LSUPDATE;
|
||||
attr_template.key.attr_cp[1] = OSPF_LSA_ROUTER;
|
||||
attr_template.key.attr_cp[2] = OSPF_ROUTER_LSA_LINK_STUB;
|
||||
attr_template.key.attr_cp[1] = OSPF_LSA_INTRA_AREA_PREFIX;
|
||||
attr_template.key.attr_cp[2] = OSPF_IA_PREFIX_LSA_PREFIX;
|
||||
lsdb_add_node_attr(node, &attr_template);
|
||||
#endif
|
||||
}
|
||||
|
||||
} while (dict_itor_next(itor));
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#define OSPF_LSA_SUMMARY 3
|
||||
#define OSPF_LSA_ASBR_SUMMARY 4
|
||||
#define OSPF_LSA_EXTERNAL 5
|
||||
|
||||
#define OSPF_LSA_OPAQUE_LINK 9
|
||||
#define OSPF_LSA_INTRA_AREA_PREFIX 39 /* OSPFv3 LSA Type 9*/
|
||||
#define OSPF_LSA_OPAQUE_AREA_RI 104
|
||||
#define OSPF_LSA_OPAQUE_AREA_EP 107 /* rfc 7684 */
|
||||
#define OSPF_LSA_OPAQUE_DOMAIN 11
|
||||
@@ -31,3 +31,6 @@
|
||||
|
||||
/* Opaque LSA Extended Prefix TLVs */
|
||||
#define OSPF_TLV_EXTENDED_PREFIX_RANGE 2
|
||||
|
||||
/* Inter Area Prefix LSA */
|
||||
#define OSPF_IA_PREFIX_LSA_PREFIX 31
|
||||
|
||||
@@ -1027,6 +1027,7 @@ lspgen_serialize_ospf3_state(lsdb_attr_t *attr, lsdb_packet_t *packet, uint16_t
|
||||
case OSPF_LSA_EXTERNAL:
|
||||
case OSPF_LSA_OPAQUE_AREA_RI:
|
||||
case OSPF_LSA_OPAQUE_AREA_EP:
|
||||
case OSPF_LSA_INTRA_AREA_PREFIX:
|
||||
inc_be_uint(buf0->data+40+16, 4); /* Update #LSAs */
|
||||
write_be_uint(buf1->data+18, 2, buf1->idx); /* Update Packet length */
|
||||
write_be_uint(buf1->data+16, 2, 0); /* reset checksum field */
|
||||
@@ -1131,12 +1132,28 @@ lspgen_serialize_ospf3_state(lsdb_attr_t *attr, lsdb_packet_t *packet, uint16_t
|
||||
push_pad4(buf1);
|
||||
break;
|
||||
|
||||
case OSPF_LSA_INTRA_AREA_PREFIX:
|
||||
push_be_uint(buf1, 2, lspgen_get_ospf_age(node)); /* LS-age */
|
||||
push_be_uint(buf1, 2, 0x2009); /* LS-Type */
|
||||
push_data(buf1, (uint8_t*)&attr->key.prefix.ipv4_prefix.address, 4); /* Link State ID */
|
||||
router_id = read_be_uint(node->key.node_id, 4);
|
||||
push_be_uint(buf1, 4, router_id); /* Advertising Router */
|
||||
push_be_uint(buf1, 4, node->sequence); /* Sequence */
|
||||
push_be_uint(buf1, 2, 0); /* Checksum - will be overwritten later */
|
||||
push_be_uint(buf1, 2, 0); /* Length - will be overwritten later */
|
||||
|
||||
push_be_uint(buf1, 2, 0); /* # Prefixes - will be overwritten later */
|
||||
push_be_uint(buf1, 2, 0x2001); /* # Referenced LS Type */
|
||||
|
||||
push_be_uint(buf1, 4, 0); /* Referenced Link State ID */
|
||||
push_be_uint(buf1, 4, router_id); /* Referenced Advertising Router */
|
||||
|
||||
break;
|
||||
|
||||
case OSPF_LSA_OPAQUE_AREA_RI:
|
||||
push_be_uint(buf1, 2, lspgen_get_ospf_age(node)); /* LS-age */
|
||||
push_be_uint(buf1, 1, 0); /* Options */
|
||||
push_be_uint(buf1, 1, 10); /* LS-Type */
|
||||
push_be_uint(buf1, 1, 4); /* Opaque Type: Router-Information */
|
||||
push_be_uint(buf1, 3, 0); /* Opaque subtype */
|
||||
push_be_uint(buf1, 2, 0x800c); /* LS-Type */
|
||||
push_be_uint(buf1, 4, 0); /* Link State ID (Instance ID) */
|
||||
router_id = read_be_uint(node->key.node_id, 4);
|
||||
push_be_uint(buf1, 4, router_id); /* Advertising Router */
|
||||
push_be_uint(buf1, 4, node->sequence); /* Sequence */
|
||||
@@ -1184,6 +1201,17 @@ lspgen_serialize_ospf3_state(lsdb_attr_t *attr, lsdb_packet_t *packet, uint16_t
|
||||
push_be_uint(buf2, 4, read_be_uint(attr->key.link.remote_node_id, 4)); /* Neighbor Router ID */
|
||||
break;
|
||||
|
||||
case OSPF_IA_PREFIX_LSA_PREFIX:
|
||||
push_be_uint(buf2, 1, attr->key.prefix.ipv6_prefix.len); /* Prefix Length */
|
||||
push_be_uint(buf2, 1, 0x00); /* Prefix Options */
|
||||
push_be_uint(buf2, 2, attr->key.prefix.metric); /* Metric */
|
||||
attr_len = (attr->key.prefix.ipv6_prefix.len+7)/8;
|
||||
push_data(buf2, attr->key.prefix.ipv6_prefix.address, attr_len); /* Prefix */
|
||||
push_pad4(buf2);
|
||||
|
||||
inc_be_uint(buf1->data+20, 2); /* Update #prefixes */
|
||||
break;
|
||||
|
||||
case OSPF_TLV_HOSTNAME:
|
||||
attr_len = strnlen(attr->key.hostname, sizeof(attr->key.hostname));
|
||||
if (attr_len) {
|
||||
@@ -1206,7 +1234,7 @@ lspgen_serialize_ospf3_state(lsdb_attr_t *attr, lsdb_packet_t *packet, uint16_t
|
||||
push_be_uint(buf2, 3, attr->key.cap.srgb_base);
|
||||
push_pad4(buf2);
|
||||
|
||||
//write_be_uint(buf2->data+2, 2, buf2->idx-4); /* Update length */
|
||||
write_be_uint(buf2->data+2, 2, buf2->idx-4); /* Update length */
|
||||
push_pad4(buf2);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user