summaryrefslogtreecommitdiff
path: root/ospfd/ospf_api.c
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2022-06-01 15:25:35 -0400
committerChristian Hopps <chopps@labn.net>2022-06-02 16:37:16 -0400
commit149491af80ceaeb666a9bf06f97e918a64c46a5c (patch)
treeda50c5f09450c81a31cccd916f179bf07c1848b8 /ospfd/ospf_api.c
parentb538baf352429ef238c7d6c8e23bb643d8e051cd (diff)
ospfd: api: add reachable router notifications
Reachable router information is used by OSPF opaque clients in order to determine if the router advertising the opaque LSA data is reachable (i.e., 2-way conectivity check). Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ospfd/ospf_api.c')
-rw-r--r--ospfd/ospf_api.c31
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 */