]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BMP: Add station address check
authorOndrej Zajicek <santiago@crfreenet.org>
Tue, 30 May 2023 15:23:56 +0000 (17:23 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 30 May 2023 15:23:56 +0000 (17:23 +0200)
Also, do not initialize it to IPA_NONE4, use regular IPA_NONE.

proto/bmp/bmp.c
proto/bmp/config.Y

index 7efa8f6a343b4fb773e6da3d994a7f36d9d655fc..fce9a0a167ce17e317b6b1ddbc61322f323405fb 100644 (file)
@@ -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,
index 2fc8745816ab71ce7527f3dc14572c285c271bdc..5a5e08124e7bdd065e4d865773d5d835209dd5a4 100644 (file)
@@ -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;