/* * Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren This file is part of CLICON. CLICON is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. CLICON is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with CLICON; see the file COPYING. If not, see . * * Code for handling netconf hello messages *****************************************************************************/ /* Capabilities are advertised in messages sent by each peer during session establishment. When the NETCONF session is opened, each peer (both client and server) MUST send a element containing a list of that peer's capabilities. Each peer MUST send at least the base NETCONF capability, "urn:ietf:params:netconf:base:1.0". URI */ #ifdef HAVE_CONFIG_H #include "clicon_config.h" /* generated by config & autoconf */ #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* cligen */ #include /* clicon */ #include #include "netconf_lib.h" #include "netconf_hello.h" static int netconf_hello(cxobj *xn) { cxobj *x; x = NULL; while ((x = xpath_each(xn, "//capability", x)) != NULL) { //fprintf(stderr, "cap: %s\n", xml_body(x)); } return 0; } int netconf_hello_dispatch(cxobj *xn) { cxobj *xp; int retval = -1; if ((xp = xpath_first(xn, "//hello")) != NULL) retval = netconf_hello(xp); return retval; } /* * netconf_create_hello * create capability string (once) */ int netconf_create_hello(cbuf *xf, /* msg buffer */ int session_id) { int retval = 0; add_preamble(xf); cprintf(xf, ""); cprintf(xf, ""); cprintf(xf, "urn:ietf:params:xml:ns:netconf:base:1.0\n"); cprintf(xf, "urn:ietf:params:xml:ns:netconf:capability:candidate:1:0\n"); cprintf(xf, "urn:ietf:params:xml:ns:netconf:capability:validate:1.0\n"); cprintf(xf, "urn:ietf:params:netconf:capability:xpath:1.0\n"); cprintf(xf, "urn:ietf:params:netconf:capability:notification:1.0\n"); // cprintf(xf, "urn:rnr:rnrapi:1:0"); cprintf(xf, ""); cprintf(xf, "%lu", 42+session_id); cprintf(xf, ""); add_postamble(xf); return retval; }