fi
fi
-all_protocols="bfd babel bgp mrt ospf perf pipe radv rip rpki static"
+all_protocols="bfd babel bgp mrt ospf perf pipe radv rip rpki snmp static"
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
if test "$with_protocols" = all ; then
extern struct protocol
proto_device, proto_radv, proto_rip, proto_static, proto_mrt,
proto_ospf, proto_perf,
- proto_pipe, proto_bgp, proto_bfd, proto_babel, proto_rpki;
+ proto_pipe, proto_bgp, proto_bfd, proto_babel, proto_rpki,
+ proto_snmp;
/*
* Routing Protocol Instance
};
extern struct channel_class channel_bgp;
+extern struct channel_class channel_snmp;
struct channel_config {
node n;
C radv
C rip
C rpki
+C snmp
C static
S ../nest/rt-dev.c
--- /dev/null
+src := snmp.c
+obj := $(src-o-files)
+$(all-daemon)
+$(cf-local)
+$(call proto-build,snmp_build)
+
+tests_objs := $(tests_objs) $(src-o-files)
--- /dev/null
+/*
+ * BIRD -- Statistics Protocol Configuration
+ *
+ * (c) 2022 Vojtech Vilimek <vojtech.vilimek@nic.cz>
+ * (c) 2022 CZ.NIC z.s.p.o.
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "proto/snmp/snmp.h"
+
+CF_DEFINES
+
+#define SNMP_CFG ((struct snmp_config *) this_proto)
+#define SNMP_CC ((struct snmp_channel_config *) this_channel)
+
+CF_DECLS
+
+CF_KEYWORDS(SNMP, TABLE, PROTOCOL, BPG)
+
+%type <cc> snmp_channel_start
+
+CF_GRAMMAR
+
+proto: snmp_proto '}' { this_channel = NULL; } ;
+
+snmp_proto:
+ snmp_proto_start '{'
+ | snmp_proto proto_item ';'
+ | snmp_proto snmp_proto_channel ';'
+ | snmp_proto ';'
+ ;
+
+snmp_proto_start: proto_start SNMP
+{
+ this_proto = proto_config_new(&proto_snmp, $1);
+}
+
+snmp_proto_channel: snmp_channel_start snmp_channel_opt_list channel_end ;
+
+snmp_channel_start: net_type symbol
+{
+ this_channel = channel_config_get(&channel_snmp, $2->name, $1, this_proto);
+}
+
+snmp_channel_opt_list:
+ /* empty */
+ | '{' snmp_opts '}'
+ ;
+
+snmp_opts:
+ /* empty */
+ | snmp_opts channel_item ';'
+ | snmp_opts snmp_opt ';'
+ ;
+
+snmp_opt:
+ PROTOCOL BGP symbol {
+ SNMP_CC->bgp = NULL;
+
+ struct proto_config *pc;
+ WALK_LIST(pc, this_proto->global->protos)
+ if (!strcmp(pc->name, $3->name)
+ && pc->protocol == &proto_bgp)
+ SNMP_CC->bgp = (struct bgp_config *) pc;
+
+ if (!SNMP_CC->bgp) cf_error("BGP protocol %s not found", $3);
+ }
+ ;
+
+CF_CODE
+
+CF_END
--- /dev/null
+/*
+ * BIRD -- Simple Network Management Protocol (SNMP)
+ *
+ * (c) 2022 Vojtech Vilimek <vojtech.vilimek@nic.cz>
+ * (c) 2022 CZ.NIC z.s.p.o.
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include "nest/bird.h"
+#include "nest/protocol.h"
+#include "nest/cli.h"
+
+#include "proto/snmp/snmp.h"
+
+static struct proto *
+snmp_init(struct proto_config *CF)
+{
+ struct proto *P = proto_new(CF);
+ struct snmp_proto *p = (void *) P;
+
+ p->rl_gen = (struct tbf) TBF_DEFAULT_LOG_LIMITS;
+
+ return P;
+}
+
+static int
+snmp_start(struct proto *P)
+{
+ struct channel_config *cc;
+ WALK_LIST(cc, P->cf->channels)
+ {
+ struct channel *c = NULL;
+ proto_configure_channel(P, &c, cc);
+ }
+
+ return PS_UP;
+}
+
+static int
+snmp_reconfigure(struct proto *P, struct proto_config *CF)
+{
+ return 0;
+}
+
+static void
+snmp_show_proto_info(struct proto *P)
+{
+ //struct stats_proto *p = (void *) P;
+
+ struct snmp_channel *sc;
+
+ WALK_LIST(sc, P->channels)
+ {
+ cli_msg(-1006, " Channel %s", sc->c.name);
+
+ if (!P->disabled)
+ {
+ cli_msg(-1006, " enabled");
+ }
+ else
+ cli_msg(-1006, " disabled");
+ }
+}
+
+static int
+snmp_channel_start(struct channel *C)
+{
+ return 0;
+}
+
+static void
+snmp_channel_shutdown(struct channel *C)
+{
+
+}
+
+struct channel_class channel_snmp = {
+ .channel_size = sizeof(struct snmp_channel),
+ .config_size = sizeof(struct snmp_channel_config),
+ .start = snmp_channel_start,
+ .shutdown = snmp_channel_shutdown,
+};
+
+struct protocol proto_snmp = {
+ .name = "Snmp",
+ .template = "snmp%d",
+ .channel_mask = NB_ANY,
+ .proto_size = sizeof(struct snmp_proto),
+ .config_size = sizeof(struct snmp_config),
+ .init = snmp_init,
+ .start = snmp_start,
+ .reconfigure = snmp_reconfigure,
+ .show_proto_info = snmp_show_proto_info,
+};
+
+void
+snmp_build(void)
+{
+ proto_build(&proto_snmp);
+}
--- /dev/null
+/*
+ * BIRD -- Simple Network Management Protocol (SNMP)
+ *
+ * (c) 2022 Vojtech Vilimek <vojtech.vilimek@nic.cz>
+ * (c) 2022 CZ.NIC z.s.p.o
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_SNMP_H_
+#define _BIRD_SNPM_H_
+
+#include "proto/bgp/bgp.h"
+
+struct snmp_config {
+ struct channel_config c;
+};
+
+struct snmp_proto {
+ struct channel c;
+ struct tbf rl_gen;
+};
+
+struct snmp_channel_config {
+ struct channel_config c;
+ struct bgp_config *bgp;
+};
+
+struct snmp_channel {
+ struct channel c;
+};
+
+#endif