summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2023-05-30 17:23:56 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-05-30 17:23:56 +0200
commit1e45e2aa4e173869be071bfa28057d8b52e8948c (patch)
tree0def5026b349a66ac4060bf1efcbeb27bd249cd2
parent62d8fbdc1cb3d358b0d20d7b10bd3f17f357d567 (diff)
BMP: Add station address check
Also, do not initialize it to IPA_NONE4, use regular IPA_NONE.
-rw-r--r--proto/bmp/bmp.c17
-rw-r--r--proto/bmp/config.Y3
2 files changed, 17 insertions, 3 deletions
diff --git a/proto/bmp/bmp.c b/proto/bmp/bmp.c
index 7efa8f6a..fce9a0a1 100644
--- a/proto/bmp/bmp.c
+++ b/proto/bmp/bmp.c
@@ -964,6 +964,22 @@ bmp_close_socket(struct bmp_proto *p)
}
+static void
+bmp_postconfig(struct proto_config *CF)
+{
+ struct bmp_config *cf = (void *) CF;
+
+ /* Do not check templates at all */
+ if (cf->c.class == SYM_TEMPLATE)
+ return;
+
+ if (ipa_zero(cf->station_ip))
+ cf_error("Station IP address not specified");
+
+ if (!cf->station_port)
+ cf_error("Station port number not specified");
+}
+
/** Configuration handle section **/
static struct proto *
bmp_init(struct proto_config *CF)
@@ -1047,6 +1063,7 @@ struct protocol proto_bmp = {
.class = PROTOCOL_BMP,
.proto_size = sizeof(struct bmp_proto),
.config_size = sizeof(struct bmp_config),
+ .postconfig = bmp_postconfig,
.init = bmp_init,
.start = bmp_start,
.shutdown = bmp_shutdown,
diff --git a/proto/bmp/config.Y b/proto/bmp/config.Y
index 2fc87458..5a5e0812 100644
--- a/proto/bmp/config.Y
+++ b/proto/bmp/config.Y
@@ -25,9 +25,6 @@ proto: bmp_proto '}' ;
bmp_proto_start: proto_start BMP {
this_proto = proto_config_new(&proto_bmp, $1);
- BMP_CFG->local_addr = IPA_NONE4;
- BMP_CFG->station_ip = IPA_NONE4;
- BMP_CFG->station_port = 0;
BMP_CFG->sys_descr = "Not defined";
BMP_CFG->sys_name = "Not defined";
BMP_CFG->monitoring_rib_in_pre_policy = false;