diff --git a/proto/bmp/bmp.c b/proto/bmp/bmp.c index ca508049..7efa8f6a 100644 --- a/proto/bmp/bmp.c +++ b/proto/bmp/bmp.c @@ -892,6 +892,7 @@ bmp_connect(struct bmp_proto *p) sock *sk = sk_new(p->p.pool); sk->type = SK_TCP_ACTIVE; + sk->saddr = p->local_addr; sk->daddr = p->station_ip; sk->dport = p->station_port; sk->ttl = IP4_MAX_TTL; @@ -970,26 +971,26 @@ bmp_init(struct proto_config *CF) struct proto *P = proto_new(CF); struct bmp_proto *p = (void *) P; struct bmp_config *cf = (void *) CF; - p->cf = cf; + p->local_addr = cf->local_addr; p->station_ip = cf->station_ip; p->station_port = cf->station_port; strcpy(p->sys_descr, cf->sys_descr); strcpy(p->sys_name, cf->sys_name); p->monitoring_rib.in_pre_policy = cf->monitoring_rib_in_pre_policy; - p->monitoring_rib.in_post_policy = cf->monitoring_rib_in_post_policy; - p->monitoring_rib.local = cf->monitoring_rib_local; return P; } +/** + * bmp_start - initialize internal resources of BMP implementation. + * NOTE: It does not connect to BMP collector yet. + */ static int bmp_start(struct proto *P) { struct bmp_proto *p = (void *) P; - log(L_DEBUG "Init BMP"); - p->buffer_mpool = rp_new(P->pool, "BMP Buffer"); p->map_mem_pool = rp_new(P->pool, "BMP Map"); p->tx_mem_pool = rp_new(P->pool, "BMP Tx"); diff --git a/proto/bmp/bmp.h b/proto/bmp/bmp.h index 40d42e6a..6d429e66 100644 --- a/proto/bmp/bmp.h +++ b/proto/bmp/bmp.h @@ -35,11 +35,10 @@ struct bmp_config { struct proto_config c; const char *sys_descr; // sysDescr MIB-II [RFC1213] object const char *sys_name; // sysName MIB-II [RFC1213] object + ip_addr local_addr; // Local IP address ip_addr station_ip; // Monitoring station address u16 station_port; // Monitoring station TCP port bool monitoring_rib_in_pre_policy; // Route monitoring pre-policy Adj-Rib-In - bool monitoring_rib_in_post_policy; // Route monitoring post-policy Adj-Rib-In - bool monitoring_rib_local; // Route monitoring Local Rib }; /* Forward declarations */ @@ -59,9 +58,10 @@ struct bmp_proto { struct proto p; // Parent proto const struct bmp_config *cf; // Shortcut to BMP configuration sock *sk; // TCP connection - event *tx_ev; // TX event + event *tx_ev; // TX event char sys_descr[MIB_II_STR_LEN]; // sysDescr MIB-II [RFC1213] object char sys_name[MIB_II_STR_LEN]; // sysName MIB-II [RFC1213] object + ip_addr local_addr; // Source local IP address ip_addr station_ip; // Monitoring station IP address u16 station_port; // Monitoring station TCP port struct monitoring_rib monitoring_rib; diff --git a/proto/bmp/config.Y b/proto/bmp/config.Y index 776d7ecc..2fc87458 100644 --- a/proto/bmp/config.Y +++ b/proto/bmp/config.Y @@ -25,13 +25,12 @@ 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; - BMP_CFG->monitoring_rib_in_post_policy = false; - BMP_CFG->monitoring_rib_local = false; } ; @@ -52,6 +51,9 @@ bmp_station_address: bmp_proto: bmp_proto_start proto_name '{' | bmp_proto proto_item ';' + | bmp_proto LOCAL ADDRESS ipa ';' { + BMP_CFG->local_addr = $4; + } | bmp_proto STATION ADDRESS bmp_station_address ';' | bmp_proto SYSTEM DESCRIPTION text ';' { if (!$4 || (strlen($4) == 0)) @@ -70,12 +72,6 @@ bmp_proto: | bmp_proto MONITORING RIB IN PRE_POLICY bool ';' { BMP_CFG->monitoring_rib_in_pre_policy = $6; } - | bmp_proto MONITORING RIB IN POST_POLICY bool ';' { - BMP_CFG->monitoring_rib_in_post_policy = $6; - } - | bmp_proto MONITORING RIB LOCAL bool ';' { - BMP_CFG->monitoring_rib_local = $5; - } ; CF_CODE