diff options
Diffstat (limited to 'ospfd/ospf_api.c')
| -rw-r--r-- | ospfd/ospf_api.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c index 81de882754..99bc6c0b03 100644 --- a/ospfd/ospf_api.c +++ b/ospfd/ospf_api.c @@ -177,6 +177,10 @@ const char *ospf_api_typename(int msgtype) { MSG_NSM_CHANGE, "NSM change", }, + { + MSG_REACHABLE_CHANGE, + "Reachable change", + }, }; int i, n = array_size(NameTab); @@ -651,4 +655,31 @@ struct msg *new_msg_lsa_change_notify(uint8_t msgtype, uint32_t seqnum, return msg_new(msgtype, nmsg, seqnum, len); } +struct msg *new_msg_reachable_change(uint32_t seqnum, uint16_t nadd, + struct in_addr *add, uint16_t nremove, + struct in_addr *remove) +{ + uint8_t buf[OSPF_API_MAX_MSG_SIZE]; + struct msg_reachable_change *nmsg = (void *)buf; + const uint insz = sizeof(*nmsg->router_ids); + const uint nmax = (sizeof(buf) - sizeof(*nmsg)) / insz; + uint len; + + if (nadd > nmax) + nadd = nmax; + if (nremove > (nmax - nadd)) + nremove = (nmax - nadd); + + if (nadd) + memcpy(nmsg->router_ids, add, nadd * insz); + if (nremove) + memcpy(&nmsg->router_ids[nadd], remove, nremove * insz); + + nmsg->nadd = htons(nadd); + nmsg->nremove = htons(nremove); + len = sizeof(*nmsg) + insz * (nadd + nremove); + + return msg_new(MSG_REACHABLE_CHANGE, nmsg, seqnum, len); +} + #endif /* SUPPORT_OSPF_API */ |
