static void ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa) { switch (ntohs (lsa->header->type)) { case OSPF6_LSTYPE_ROUTER: case OSPF6_LSTYPE_NETWORK: if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type)) { zlog_debug ("LSA disappearing: %s", lsa->name); zlog_debug ("Schedule SPF Calculation for %s", OSPF6_AREA (lsa->lsdb->data)->name); } ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data)); break; case OSPF6_LSTYPE_INTRA_PREFIX: ospf6_intra_prefix_lsa_remove (lsa); break; case OSPF6_LSTYPE_INTER_PREFIX: case OSPF6_LSTYPE_INTER_ROUTER: ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data); break; default: break; } }
void ospf6_abr_examin_brouter (u_int32_t router_id) { struct ospf6_lsa *lsa; struct ospf6_area *oa; listnode node; u_int16_t type; type = htons (OSPF6_LSTYPE_INTER_ROUTER); for (node = listhead (ospf6->area_list); node; nextnode (node)) { oa = OSPF6_AREA (getdata (node)); for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) ospf6_abr_examin_summary (lsa, oa); } type = htons (OSPF6_LSTYPE_INTER_PREFIX); for (node = listhead (ospf6->area_list); node; nextnode (node)) { oa = OSPF6_AREA (getdata (node)); for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) ospf6_abr_examin_summary (lsa, oa); } }
int ospf6_is_router_abr (struct ospf6 *o) { listnode node; struct ospf6_area *oa; int area_count = 0; for (node = listhead (o->area_list); node; nextnode (node)) { oa = OSPF6_AREA (getdata (node)); if (IS_AREA_ENABLED (oa)) area_count++; } if (area_count > 1) return 1; return 0; }
void ospf6_abr_disable_area (struct ospf6_area *area) { struct ospf6_area *oa; struct ospf6_route *ro; struct ospf6_lsa *old; listnode node; /* Withdraw all summary prefixes previously originated */ for (ro = ospf6_route_head (area->summary_prefix); ro; ro = ospf6_route_next (ro)) { old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id, area->ospf6->router_id, area->lsdb); if (old) ospf6_lsa_purge (old); ospf6_route_remove (ro, area->summary_prefix); } /* Withdraw all summary router-routes previously originated */ for (ro = ospf6_route_head (area->summary_router); ro; ro = ospf6_route_next (ro)) { old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id, area->ospf6->router_id, area->lsdb); if (old) ospf6_lsa_purge (old); ospf6_route_remove (ro, area->summary_router); } /* Schedule Router-LSA for each area (ABR status may change) */ for (node = listhead (area->ospf6->area_list); node; nextnode (node)) { oa = OSPF6_AREA (getdata (node)); /* update B bit for each area */ OSPF6_ROUTER_LSA_SCHEDULE (oa); } }
void ospf6_abr_enable_area (struct ospf6_area *area) { struct ospf6_area *oa; struct ospf6_route *ro; listnode node; for (node = listhead (area->ospf6->area_list); node; nextnode (node)) { oa = OSPF6_AREA (getdata (node)); /* update B bit for each area */ OSPF6_ROUTER_LSA_SCHEDULE (oa); /* install other area's configured address range */ if (oa != area) { for (ro = ospf6_route_head (oa->range_table); ro; ro = ospf6_route_next (ro)) { if (CHECK_FLAG (ro->flag, OSPF6_ROUTE_ACTIVE_SUMMARY)) ospf6_abr_originate_summary_to_area (ro, area); } } } /* install calculated routes to border routers */ for (ro = ospf6_route_head (area->ospf6->brouter_table); ro; ro = ospf6_route_next (ro)) ospf6_abr_originate_summary_to_area (ro, area); /* install calculated routes to network (may be rejected by ranges) */ for (ro = ospf6_route_head (area->ospf6->route_table); ro; ro = ospf6_route_next (ro)) ospf6_abr_originate_summary_to_area (ro, area); }
static u_char * ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { struct ospf6_lsa *lsa = NULL; struct in_addr area_id; u_int16_t type; struct in_addr id; struct in_addr adv_router; int len; oid *offset; int offsetlen; char a[16], b[16], c[16]; struct ospf6_area *oa; struct listnode *node; memset (&area_id, 0, sizeof (struct in_addr)); type = 0; memset (&id, 0, sizeof (struct in_addr)); memset (&adv_router, 0, sizeof (struct in_addr)); /* Check OSPFv3 instance. */ if (ospf6 == NULL) return NULL; /* Get variable length. */ offset = name + v->namelen; offsetlen = *length - v->namelen; #define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET \ (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE) if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET) return NULL; /* Parse area-id */ len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE); if (len) oid2in_addr (offset, len, &area_id); offset += len; offsetlen -= len; /* Parse type */ len = (offsetlen < 1 ? offsetlen : 1); if (len) type = htons (*offset); offset += len; offsetlen -= len; /* Parse Router-ID */ len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE); if (len) oid2in_addr (offset, len, &adv_router); offset += len; offsetlen -= len; /* Parse LS-ID */ len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE); if (len) oid2in_addr (offset, len, &id); offset += len; offsetlen -= len; ospf6_id2str (area_id.s_addr, a, sizeof (a)); ospf6_id2str (adv_router.s_addr, b, sizeof (b)); ospf6_id2str (id.s_addr, c, sizeof (c)); zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d" " type=%#x adv_router=%s id=%s", a, exact, (u_long)*length, v->magic, ntohs (type), b, c); if (exact) { oa = ospf6_area_lookup (area_id.s_addr, ospf6); lsa = ospf6_lsdb_lookup (type, id.s_addr, adv_router.s_addr, oa->lsdb); } else { for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) { if (lsa) continue; if (ntohl (oa->area_id) < ntohl (area_id.s_addr)) continue; lsa = ospf6_lsdb_lookup_next (type, id.s_addr, adv_router.s_addr, oa->lsdb); if (! lsa) { type = 0; memset (&id, 0, sizeof (struct in_addr)); memset (&adv_router, 0, sizeof (struct in_addr)); } } } if (! lsa) { zlog_debug ("SNMP respond: No LSA to return"); return NULL; } oa = OSPF6_AREA (lsa->lsdb->data); zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name); /* Add Index (AreaId, Type, RouterId, Lsid) */ *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET; offset = name + v->namelen; oid_copy_addr (offset, (struct in_addr *) &oa->area_id, IN_ADDR_SIZE); offset += IN_ADDR_SIZE; *offset = ntohs (lsa->header->type); offset++; oid_copy_addr (offset, (struct in_addr *) &lsa->header->adv_router, IN_ADDR_SIZE); offset += IN_ADDR_SIZE; oid_copy_addr (offset, (struct in_addr *) &lsa->header->id, IN_ADDR_SIZE); offset += IN_ADDR_SIZE; /* Return the current value of the variable */ switch (v->magic) { case OSPFv3AREALSDBAREAID: /* 1 */ area_id.s_addr = OSPF6_AREA (lsa->lsdb->data)->area_id; return SNMP_IPADDRESS (area_id); break; case OSPFv3AREALSDBTYPE: /* 2 */ return SNMP_INTEGER (ntohs (lsa->header->type)); break; case OSPFv3AREALSDBROUTERID: /* 3 */ adv_router.s_addr = lsa->header->adv_router; return SNMP_IPADDRESS (adv_router); break; case OSPFv3AREALSDBLSID: /* 4 */ id.s_addr = lsa->header->id; return SNMP_IPADDRESS (id); break; case OSPFv3AREALSDBSEQUENCE: /* 5 */ return SNMP_INTEGER (lsa->header->seqnum); break; case OSPFv3AREALSDBAGE: /* 6 */ ospf6_lsa_age_current (lsa); return SNMP_INTEGER (lsa->header->age); break; case OSPFv3AREALSDBCHECKSUM: /* 7 */ return SNMP_INTEGER (lsa->header->checksum); break; case OSPFv3AREALSDBADVERTISEMENT: /* 8 */ *var_len = ntohs (lsa->header->length); return (u_char *) lsa->header; break; case OSPFv3AREALSDBTYPEKNOWN: /* 9 */ return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ? SNMP_TRUE : SNMP_FALSE); break; default: return NULL; break; } return NULL; }