From 7e57b55f493580be5253635b18ef83f8609c0501 Mon Sep 17 00:00:00 2001 From: pcarana Date: Wed, 13 Mar 2019 11:45:27 -0600 Subject: [PATCH] Support only RTR v0 (for now) --- src/configuration.c | 4 ++++ src/rtr/rtr.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/configuration.c b/src/configuration.c index 694c6d72..bc685444 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -192,6 +192,10 @@ handle_json(json_t *root) config.vrps_check_interval = DEFAULT_VRPS_CHECK_INTERVAL; } + /* + * TODO Exclusively for RTR v1, so this are optional values to configure + * since RTR v1 isn't fully supported yet + */ interval = json_object_get(root, OPTNAME_RTR_INTERVAL); if (interval != NULL) { if (!json_is_object(interval)) { diff --git a/src/rtr/rtr.c b/src/rtr/rtr.c index 23d8aeab..ff07c22c 100644 --- a/src/rtr/rtr.c +++ b/src/rtr/rtr.c @@ -16,6 +16,9 @@ #include "err_pdu.h" #include "pdu.h" +/* TODO Support both RTR v0 an v1 */ +#define RTR_VERSION_SUPPORTED RTR_V0 + /* * Creates the socket that will stay put and wait for new connections started * from the clients. @@ -125,13 +128,20 @@ client_thread_cb(void *param_void) if (err) return NULL; - /* Protocol Version Negotiation isn't necessary (for now) */ + /* Protocol Version Negotiation, accept only what's supported */ + if (rtr_version != RTR_VERSION_SUPPORTED) { + err_pdu_send(param.client_fd, RTR_VERSION_SUPPORTED, + ERR_PDU_UNSUP_PROTO_VERSION, + (struct pdu_header *) pdu, NULL); + return NULL; + } /* RTR Version ready, now update client */ err = update_client(param.client_fd, ¶m.client_addr, rtr_version); if (err) { if (err == -EINVAL) { err_pdu_send(param.client_fd, rtr_version, - ERR_PDU_UNEXPECTED_PROTO_VERSION, + (rtr_version == RTR_V0 ? ERR_PDU_UNSUP_PROTO_VERSION : + ERR_PDU_UNEXPECTED_PROTO_VERSION), (struct pdu_header *) pdu, NULL); } return NULL; -- 2.47.3