Quick example added to the examples.confd/netconf_notifications example using the built in NETCONF stream instead of your proprietary one:
$ diff -u notifier_builtin_replay_store.bak notifier_builtin_replay_store.c
--- notifier_builtin_replay_store.bak 2017-11-29 11:01:50.000000000 +0100
+++ notifier_builtin_replay_store.c 2017-11-29 11:02:30.000000000 +0100
@@ -14,14 +14,16 @@
#include <confd_lib.h>
#include <confd_dp.h>
+#include <confd_maapi.h>
#include "notif.h"
+#include "ietf-netconf-notifications.h"
#define OK(val) (assert((val) == CONFD_OK))
static int ctlsock, workersock;
static struct confd_daemon_ctx *dctx;
-static struct confd_notification_ctx *live_ctx;
+static struct confd_notification_ctx *live_ctx, *netconf_ctx;
static int get_ctlsock(struct addrinfo *addr)
{
@@ -73,6 +75,14 @@
datetime->min = tm.tm_min;
}
+static void send_netconf_notification(confd_tag_value_t *vals, int nvals)
+{
+ struct confd_datetime eventTime;
+
+ getdatetime(&eventTime);
+ OK(confd_notification_send(netconf_ctx, &eventTime, vals, nvals));
+}
+
static void send_notification(confd_tag_value_t *vals, int nvals)
{
struct confd_datetime eventTime;
@@ -81,6 +91,41 @@
OK(confd_notification_send(live_ctx, &eventTime, vals, nvals));
}
+static void send_x(void)
+{
+ confd_tag_value_t vals[11];
+ int i = 0;
+
+ confd_hkeypath_t *kp;
+ struct sockaddr_in saddr;
+ struct in_addr an_addr = {0xa0a0a0a0};
+
+ int msock;
+
+ saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ saddr.sin_family = AF_INET;
+ saddr.sin_port = htons(CONFD_PORT);
+
+ msock = socket(PF_INET, SOCK_STREAM, 0);
+ maapi_connect(msock, (struct sockaddr *)&saddr, sizeof(saddr));
+ maapi_xpath2kpath(msock, "/managed-element/enb-function/active-queue-management[aqm-index=0]", &kp);
+ maapi_close(msock);
+
+ CONFD_SET_TAG_XMLBEGIN(&vals[i], ncn_netconf_config_change, ncn__ns); i++;
+ CONFD_SET_TAG_XMLBEGIN(&vals[i], ncn_changed_by, ncn__ns); i++;
+ CONFD_SET_TAG_STR(&vals[i], ncn_username, "admin"); i++;
+ CONFD_SET_TAG_UINT32(&vals[i], ncn_session_id, 0); i++;
+ CONFD_SET_TAG_IPV4(&vals[i], ncn_source_host, an_addr); i++;
+ CONFD_SET_TAG_XMLEND(&vals[i], ncn_changed_by, ncn__ns); i++;
+ CONFD_SET_TAG_ENUM_VALUE(&vals[i], ncn_datastore, ncn_running); i++;
+ CONFD_SET_TAG_XMLBEGIN(&vals[i], ncn_edit, ncn__ns); i++;
+ CONFD_SET_TAG_OBJECTREF(&vals[i], ncn_target, kp); i++;
+ CONFD_SET_TAG_XMLEND(&vals[i], ncn_edit, ncn__ns); i++;
+ CONFD_SET_TAG_XMLEND(&vals[i], ncn_netconf_config_change, ncn__ns); i++;
+
+ send_netconf_notification(vals, i);
+ confd_free_hkeypath(kp);
+}
+
static void send_notifup_1(int index, int flags1, int flags2)
{
confd_tag_value_t vals[9];
@@ -238,6 +283,16 @@
if (confd_register_notification_stream(dctx, &ncb, &live_ctx) != CONFD_OK) {
confd_fatal("Couldn't register stream %s\n", ncb.streamname);
}
+
+ memset(&ncb, 0, sizeof(ncb));
+ ncb.fd = workersock;
+ ncb.get_log_times = NULL;
+ ncb.replay = NULL;
+ strcpy(ncb.streamname, "NETCONF");
+ ncb.cb_opaque = NULL;
+ if (confd_register_notification_stream(dctx, &ncb, &netconf_ctx) != CONFD_OK) {
+ confd_fatal("Couldn't register stream %s\n", ncb.streamname);
+ }
if (confd_register_done(dctx) != CONFD_OK) {
confd_fatal("Failed to complete registration \n");
}
@@ -291,6 +346,9 @@
printf("sending linkDown notification\n");
send_notifdown(1);
break;
+ case 'x':
+ send_x();
+ break;
case 'm':
printf("sending 10000 random notifications\n");
int i;
$ diff -u Makefile.bak Makefile
--- Makefile.bak 2017-11-29 11:03:12.000000000 +0100
+++ Makefile 2017-11-29 11:10:10.000000000 +0100
@@ -43,15 +43,17 @@
all: notifier notifier_builtin_replay_store notif.fxs $(CDB_DIR) ssh-keydir
@echo "Build complete"
+ietf-netconf-notifications.h:
+ $(CONFDC) --emit-h ietf-netconf-notifications.h $(CONFD_DIR)/etc/confd/ietf-netconf-notifications.fxs
notifier: notifier.o
$(CC) notifier.o $(LIBS) $(CFLAGS) -ansi -pedantic -o $@
-notifier.o: notifier.c notif.h
+notifier.o: notifier.c notif.h ietf-netconf-notifications.h
notifier_builtin_replay_store: notifier_builtin_replay_store.o
$(CC) notifier_builtin_replay_store.o $(LIBS) $(CFLAGS) -o $@
-notifier_builtin_replay_store.o: notifier_builtin_replay_store.c notif.h
+notifier_builtin_replay_store.o: notifier_builtin_replay_store.c notif.h ietf-netconf-notifications.h
$ diff -u notif.yang.bak notif.yang
--- notif.yang.bak 2017-11-29 11:08:24.000000000 +0100
+++ notif.yang 2017-11-29 09:48:11.000000000 +0100
@@ -14,6 +14,24 @@
}
}
+container managed-element {
+ container enb-function {
+ list active-queue-management{
+ key aqm-index;
+ leaf aqm-index{
+ type uint16{
+ range "0..7";
+ }
+ }
+ leaf qci{
+ type uint16 {
+ range "0..7";
+ }
+ }
+ }
+ }
+}
+
notification linkUp {
leaf ifIndex {
type leafref {