From a760dfb253161911fc3aa3c8b879c461d53ade6e Mon Sep 17 00:00:00 2001 From: YohanPipereau Date: Wed, 6 Mar 2019 14:01:58 +0100 Subject: Sweetcomb global cleanup -Merge IETF and Openconfig to use SCVPP 2 -Move L2 bridge from sc_vpp_interface to sc_vpp_v3po -Implement tav2 dump -Make openconfig-interfaces functions static -Try one more dispatch after failure in VAPI_CALL -Add error return code for scvpp -Remove unused length maccros -Return appropriate error code for interface dump when interface not found -Improve scvpp test suite -Change get_interface_id prototype -Use interface_dump_iface in openconfig_interface. -No more vapi types in openconfig_interfaces.c -Move openconfig_local_routing VAPI operations to sc_vpp_ip -Implement a multiple dump with a stack data structure -Comment out state_cb code from openconfig_local_routing to use new functions later. -Rename YANG model to their fully qualified name : @ -Remove headers almost empty and put registration declaration in sc_model.h -Shorten vapi context global variable name -Reorganize scvpp unit test suite -Add instructions to Makefile to install/uninstall YANG models in sysrepo. -Add this new instructions to README.md. -Reimplement interface_dump_all -Use a common message at INFO Log Level to know when sysrepo callbacks are triggered -Remove old structure to perform dump of all interfaces -Reimplement get_interface_name and add scvpp test for it -Clean sys_util -Use UNUSED maccro everywhere to have lighter prototypes -Have ietf-interfaces:interfaces-state work with new dump function -Add setup and teardown for NAT tests -Remove unused tapv2 dump -Remove useless sysrepo module callback -Remove xpath_find_first_key usage in openconfig-interfaces -Remove xpath_find_first_key in oc_local_routing and in the rest of sweetcomb -Reorganize scvpp include dir and fix scvpp_test new warnings -Fix scvpp tests for ip routes -Factorize scvpp nat and test return code of its function -Correct test_dump_if_all if there is an existing hardware interface -Implement a per-prefix dump in scvpp -free changes iterator in ietf-interfaces -Add new XPATH in oc local-routing -Introduce helper methods for sysrepo config callbacks -Factorize config callback -Refactor the openconfig-local-routing config callback -Use common foreach_change to iterate over changes in all models -Create a sample directory gathering example of configurations supposed to work with sweetcomb -Fix state callback of oc-local-routing -Add new sample for get operation on next-hop -foreach_elt maccro condition forgets to read one element Change-Id: I8e87fce577a00337977588f057a6e095a20f457c Signed-off-by: YohanPipereau --- Makefile | 27 +- README.md | 24 +- samples/ietf-interfaces/set-ip.xml | 18 + samples/openconfig-interfaces/get-iface.xpath | 1 + samples/openconfig-interfaces/get-subiface.xpath | 1 + samples/openconfig-interfaces/set-enable.xml | 15 + samples/openconfig-interfaces/set-ip.xml | 36 + .../add_route_with_iface.xml | 41 + .../add_route_with_nhop.xml | 20 + .../get-prefix-nhop-interface.xpath | 2 + .../openconfig-local-routing/get-prefix-nhop.xpath | 1 + samples/openconfig-local-routing/get-prefix.xpath | 1 + src/plugins/CMakeLists.txt | 1 - src/plugins/ietf/ietf_interface.c | 194 +-- src/plugins/ietf/ietf_interface.h | 25 - src/plugins/ietf/ietf_nat.c | 54 +- src/plugins/ietf/ietf_nat.h | 25 - src/plugins/openconfig/openconfig_interfaces.c | 759 ++++----- src/plugins/openconfig/openconfig_interfaces.h | 26 - src/plugins/openconfig/openconfig_local_routing.c | 888 ++++------- src/plugins/openconfig/openconfig_local_routing.h | 25 - src/plugins/sc_model.h | 16 +- src/plugins/sc_plugins.c | 5 - src/plugins/sys_util.c | 170 -- src/plugins/sys_util.h | 163 +- src/plugins/yang/ietf-interfaces.data.xml | 21 - src/plugins/yang/ietf/iana-if-type@2017-01-19.yang | 1619 ++++++++++++++++++++ src/plugins/yang/ietf/ietf-interfaces.yang | 1123 -------------- .../yang/ietf/ietf-interfaces@2014-05-08.yang | 707 --------- .../yang/ietf/ietf-interfaces@2018-02-20.yang | 1123 ++++++++++++++ .../yang/openconfig/openconfig-extensions.yang | 91 -- .../openconfig-extensions@2017-04-11.yang | 91 ++ .../yang/openconfig/openconfig-if-aggregate.yang | 223 --- .../openconfig-if-aggregate@2018-03-23.yang | 223 +++ .../yang/openconfig/openconfig-if-ethernet.yang | 428 ------ .../openconfig-if-ethernet@2018-09-04.yang | 428 ++++++ src/plugins/yang/openconfig/openconfig-if-ip.yang | 1312 ---------------- .../openconfig/openconfig-if-ip@2018-01-05.yang | 1312 ++++++++++++++++ .../yang/openconfig/openconfig-if-types.yang | 98 -- .../openconfig/openconfig-if-types@2018-01-05.yang | 98 ++ .../yang/openconfig/openconfig-inet-types.yang | 332 ---- .../openconfig-inet-types@2017-08-24.yang | 332 ++++ .../yang/openconfig/openconfig-interfaces.yang | 1040 ------------- .../openconfig-interfaces@2018-08-07.yang | 1040 +++++++++++++ .../yang/openconfig/openconfig-local-routing.yang | 408 ----- .../openconfig-local-routing@2017-05-15.yang | 408 +++++ .../yang/openconfig/openconfig-policy-types.yang | 220 --- .../openconfig-policy-types@2018-06-05.yang | 220 +++ src/plugins/yang/openconfig/openconfig-types.yang | 455 ------ .../openconfig/openconfig-types@2018-05-05.yang | 455 ++++++ .../yang/openconfig/openconfig-vlan-types.yang | 195 --- .../openconfig-vlan-types@2018-02-14.yang | 195 +++ src/plugins/yang/openconfig/openconfig-vlan.yang | 438 ------ .../openconfig/openconfig-vlan@2018-06-05.yang | 438 ++++++ .../yang/openconfig/openconfig-yang-types.yang | 180 --- .../openconfig-yang-types@2018-04-24.yang | 180 +++ src/scvpp/CMakeLists.txt | 66 +- src/scvpp/inc/scvpp/comm.h | 213 +++ src/scvpp/inc/scvpp/interface.h | 69 + src/scvpp/inc/scvpp/ip.h | 77 + src/scvpp/inc/scvpp/nat.h | 61 + src/scvpp/inc/scvpp/v3po.h | 54 + src/scvpp/src/CMakeLists.txt | 57 - src/scvpp/src/comm.c | 113 ++ src/scvpp/src/interface.c | 176 +++ src/scvpp/src/ip.c | 259 ++++ src/scvpp/src/nat.c | 294 ++++ src/scvpp/src/sc_vpp_comm.c | 113 -- src/scvpp/src/sc_vpp_comm.h | 136 -- src/scvpp/src/sc_vpp_interface.c | 252 --- src/scvpp/src/sc_vpp_interface.h | 61 - src/scvpp/src/sc_vpp_ip.c | 206 --- src/scvpp/src/sc_vpp_ip.h | 36 - src/scvpp/src/sc_vpp_nat.c | 319 ---- src/scvpp/src/sc_vpp_nat.h | 61 - src/scvpp/src/sc_vpp_v3po.c | 107 -- src/scvpp/src/sc_vpp_v3po.h | 26 - src/scvpp/src/v3po.c | 89 ++ src/scvpp/tests/CMakeLists.txt | 37 +- src/scvpp/tests/scvpp_iface_test.c | 130 ++ src/scvpp/tests/scvpp_ip_test.c | 184 +++ src/scvpp/tests/scvpp_nat_test.c | 51 +- src/scvpp/tests/scvpp_nat_test.h | 24 - src/scvpp/tests/scvpp_test.c | 160 +- src/scvpp/tests/scvpp_test.h | 31 + 85 files changed, 11102 insertions(+), 10331 deletions(-) create mode 100644 samples/ietf-interfaces/set-ip.xml create mode 100644 samples/openconfig-interfaces/get-iface.xpath create mode 100644 samples/openconfig-interfaces/get-subiface.xpath create mode 100644 samples/openconfig-interfaces/set-enable.xml create mode 100644 samples/openconfig-interfaces/set-ip.xml create mode 100644 samples/openconfig-local-routing/add_route_with_iface.xml create mode 100644 samples/openconfig-local-routing/add_route_with_nhop.xml create mode 100644 samples/openconfig-local-routing/get-prefix-nhop-interface.xpath create mode 100644 samples/openconfig-local-routing/get-prefix-nhop.xpath create mode 100644 samples/openconfig-local-routing/get-prefix.xpath delete mode 100644 src/plugins/ietf/ietf_interface.h delete mode 100644 src/plugins/ietf/ietf_nat.h delete mode 100644 src/plugins/openconfig/openconfig_interfaces.h delete mode 100644 src/plugins/openconfig/openconfig_local_routing.h delete mode 100644 src/plugins/sys_util.c delete mode 100644 src/plugins/yang/ietf-interfaces.data.xml create mode 100644 src/plugins/yang/ietf/iana-if-type@2017-01-19.yang delete mode 100644 src/plugins/yang/ietf/ietf-interfaces.yang delete mode 100644 src/plugins/yang/ietf/ietf-interfaces@2014-05-08.yang create mode 100644 src/plugins/yang/ietf/ietf-interfaces@2018-02-20.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-extensions.yang create mode 100644 src/plugins/yang/openconfig/openconfig-extensions@2017-04-11.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-if-aggregate.yang create mode 100644 src/plugins/yang/openconfig/openconfig-if-aggregate@2018-03-23.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-if-ethernet.yang create mode 100644 src/plugins/yang/openconfig/openconfig-if-ethernet@2018-09-04.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-if-ip.yang create mode 100644 src/plugins/yang/openconfig/openconfig-if-ip@2018-01-05.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-if-types.yang create mode 100644 src/plugins/yang/openconfig/openconfig-if-types@2018-01-05.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-inet-types.yang create mode 100644 src/plugins/yang/openconfig/openconfig-inet-types@2017-08-24.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-interfaces.yang create mode 100644 src/plugins/yang/openconfig/openconfig-interfaces@2018-08-07.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-local-routing.yang create mode 100644 src/plugins/yang/openconfig/openconfig-local-routing@2017-05-15.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-policy-types.yang create mode 100644 src/plugins/yang/openconfig/openconfig-policy-types@2018-06-05.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-types.yang create mode 100644 src/plugins/yang/openconfig/openconfig-types@2018-05-05.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-vlan-types.yang create mode 100644 src/plugins/yang/openconfig/openconfig-vlan-types@2018-02-14.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-vlan.yang create mode 100644 src/plugins/yang/openconfig/openconfig-vlan@2018-06-05.yang delete mode 100644 src/plugins/yang/openconfig/openconfig-yang-types.yang create mode 100644 src/plugins/yang/openconfig/openconfig-yang-types@2018-04-24.yang create mode 100644 src/scvpp/inc/scvpp/comm.h create mode 100644 src/scvpp/inc/scvpp/interface.h create mode 100644 src/scvpp/inc/scvpp/ip.h create mode 100644 src/scvpp/inc/scvpp/nat.h create mode 100644 src/scvpp/inc/scvpp/v3po.h delete mode 100644 src/scvpp/src/CMakeLists.txt create mode 100644 src/scvpp/src/comm.c create mode 100644 src/scvpp/src/interface.c create mode 100644 src/scvpp/src/ip.c create mode 100644 src/scvpp/src/nat.c delete mode 100644 src/scvpp/src/sc_vpp_comm.c delete mode 100644 src/scvpp/src/sc_vpp_comm.h delete mode 100644 src/scvpp/src/sc_vpp_interface.c delete mode 100644 src/scvpp/src/sc_vpp_interface.h delete mode 100644 src/scvpp/src/sc_vpp_ip.c delete mode 100644 src/scvpp/src/sc_vpp_ip.h delete mode 100644 src/scvpp/src/sc_vpp_nat.c delete mode 100644 src/scvpp/src/sc_vpp_nat.h delete mode 100644 src/scvpp/src/sc_vpp_v3po.c delete mode 100644 src/scvpp/src/sc_vpp_v3po.h create mode 100644 src/scvpp/src/v3po.c create mode 100644 src/scvpp/tests/scvpp_iface_test.c create mode 100644 src/scvpp/tests/scvpp_ip_test.c delete mode 100644 src/scvpp/tests/scvpp_nat_test.h create mode 100644 src/scvpp/tests/scvpp_test.h diff --git a/Makefile b/Makefile index 7933b38..f2ee6ee 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,8 @@ help: @echo " install-dep - install software dependencies" @echo " install-dep-extra - install software extra dependencips from source code" @echo " install-vpp - install released vpp" + @echo " install-models - install YANG models" + @echo " uninstall-models - uninstall YANG models" @echo " install-dep-gnmi-extra - install software extra dependencips from source code for gNMI" @echo " checkstyle - check coding style" @echo " fixstyle - fix coding style" @@ -247,10 +249,10 @@ fixstyle: @build-root/scripts/checkstyle.sh --fix build-scvpp: - @mkdir -p $(BR)/build-scvpp/;cd $(BR)/build-scvpp;cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr $(WS_ROOT)/src/scvpp/;make install; + @mkdir -p $(BR)/build-scvpp/;cd $(BR)/build-scvpp;cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=/usr $(WS_ROOT)/src/scvpp/;make install; build-plugins: - @mkdir -p $(BR)/build-plugins/;cd $(BR)/build-plugins/;cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr $(WS_ROOT)/src/plugins/;make install; + @mkdir -p $(BR)/build-plugins/;cd $(BR)/build-plugins/;cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=/usr $(WS_ROOT)/src/plugins/;make install; docker: @build-root/scripts/docker.sh @@ -270,6 +272,27 @@ build-package: @mkdir -p $(BR)/build-scvpp/;cd $(BR)/build-scvpp;cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr $(WS_ROOT)/src/scvpp/;make install; @mkdir -p $(BR)/build-package/;cd $(BR)/build-package/;$(cmake) $(WS_ROOT)/src/;make package;rm -rf $(BR)/build-package/_CPack_Packages; +install-models: + @cd src/plugins/yang/ietf \ + && sysrepoctl --install --yang=ietf-ip@2014-06-16.yang \ + && sysrepoctl --install --yang=ietf-nat@2017-11-16.yang \ + && sysrepoctl --install --yang=iana-if-type@2017-01-19.yang \ + && sysrepoctl -e if-mib -m ietf-interfaces; + @cd src/plugins/yang/openconfig \ + && sysrepoctl -S --install --yang=openconfig-local-routing@2017-05-15.yang \ + && sysrepoctl -S --install --yang=openconfig-interfaces@2018-08-07.yang \ + && sysrepoctl -S --install --yang=openconfig-if-ip@2018-01-05.yang; + +uninstall-models: + @sysrepoctl -u -m openconfig-if-ip \ + && sysrepoctl -u -m openconfig-if-aggregate \ + && sysrepoctl -u -m openconfig-local-routing \ + && sysrepoctl -u -m openconfig-interfaces \ + && sysrepoctl -u -m openconfig-vlan-types \ + && sysrepoctl -u -m ietf-ip \ + && sysrepoctl -u -m ietf-nat \ + && sysrepoctl -u -m iana-if-type; + clean: @cd $(BR)/build-scvpp && make clean; @cd $(BR)/build-plugins && make clean; diff --git a/README.md b/README.md index 96a10b9..83e6864 100644 --- a/README.md +++ b/README.md @@ -28,24 +28,32 @@ Details of the changes leading up to this version of Sweetcomb can be found unde Make sure you have added FD.io repository using https://packagecloud.io/fdio/release/ installation script. -You should have a sight on the release package, the package name may be defferent in -rpm and deb on defferent version -(such vpp-plugins.deb in 19.01 and vpp-plugin-core.deb and vpp-plugin-dpdk.deb in 19.04) +You should have a sight on the release package, the package name may be different depending on the distribution. +(ex: vpp-plugins.deb for VPP 19.01 and vpp-plugin-core.deb and vpp-plugin-dpdk.deb in 19.04) Firstly, please follow below steps to install dependencies and build code: +``` cd $/sweetcomb/ make install-dep make install-dep-extra make install-vpp make build-scvpp make build-plugins +``` + +Next, install YANG models in sysrepo: +``` + make install-models +``` Then, please start each daemon one by one: +``` start vpp (for example on Ubuntu: systemctl start vpp) sysrepod sysrepo-plugind netopeer2-server netopeer2-cli +``` Now you can utilize Sweetcomb. @@ -54,13 +62,16 @@ For example, if you want to configure ipv4 address on HW interface TenGigabitEth You can follow below steps to verify if Sweetcomb is working well. Firstly, set interface up: - vppctl set interface state TenGigabitEthernet5/0/0 up +`vppctl set interface state TenGigabitEthernet5/0/0 up` Then, starting netopeer2-cli on any host: netopeer2-cli +``` > connect --host --login > edit-config --target running --config -## Press Enter and then past below XML example into the editor and quit +``` + +``` TenGigabitEthernet5/0/0 @@ -77,8 +88,9 @@ Then, starting netopeer2-cli on any host: true +``` Finally, check the configuration result. - vppctl show interface address + `vppctl show interface address` If you configure above successfully, you will get ip address set up on interface TenGigabitEthernet5/0/0. diff --git a/samples/ietf-interfaces/set-ip.xml b/samples/ietf-interfaces/set-ip.xml new file mode 100644 index 0000000..2d8f1e2 --- /dev/null +++ b/samples/ietf-interfaces/set-ip.xml @@ -0,0 +1,18 @@ + + + + local0 + eth0 + ianaift:ethernetCsmacd + + true + 1514 +
+ 192.168.50.72 + 24 +
+
+ true +
+
+ diff --git a/samples/openconfig-interfaces/get-iface.xpath b/samples/openconfig-interfaces/get-iface.xpath new file mode 100644 index 0000000..bc829f6 --- /dev/null +++ b/samples/openconfig-interfaces/get-iface.xpath @@ -0,0 +1 @@ +get --filter-xpath /openconfig-interfaces:interfaces/interface[name="tap0"]/state diff --git a/samples/openconfig-interfaces/get-subiface.xpath b/samples/openconfig-interfaces/get-subiface.xpath new file mode 100644 index 0000000..e38de57 --- /dev/null +++ b/samples/openconfig-interfaces/get-subiface.xpath @@ -0,0 +1 @@ +get --filter-xpath /openconfig-interfaces:interfaces/interface[name="tap0"]/subinterfaces/* diff --git a/samples/openconfig-interfaces/set-enable.xml b/samples/openconfig-interfaces/set-enable.xml new file mode 100644 index 0000000..dc60769 --- /dev/null +++ b/samples/openconfig-interfaces/set-enable.xml @@ -0,0 +1,15 @@ + + + + GigabitEthernet0/9/0 + + GigabitEthernet0/9/0 + ianaift:ethernetCsmacd + 1501 + true + openconfig + true + + + + diff --git a/samples/openconfig-interfaces/set-ip.xml b/samples/openconfig-interfaces/set-ip.xml new file mode 100644 index 0000000..80b368c --- /dev/null +++ b/samples/openconfig-interfaces/set-ip.xml @@ -0,0 +1,36 @@ + + + + tap0 + + tap0 + ianaift:ethernetCsmacd + 1501 + true + openconfig + true + + + + 0 + + +
+ 192.168.0.2 + + 192.168.0.2 + 24 + +
+
+
+ + 0 + openconfig + true + +
+
+
+
+ diff --git a/samples/openconfig-local-routing/add_route_with_iface.xml b/samples/openconfig-local-routing/add_route_with_iface.xml new file mode 100644 index 0000000..378a927 --- /dev/null +++ b/samples/openconfig-local-routing/add_route_with_iface.xml @@ -0,0 +1,41 @@ + + + + GigabitEthernet0/9/0 + + GigabitEthernet0/9/0 + ianaift:ethernetCsmacd + 1501 + true + openconfig + true + + + + + + + + + + 10.0.0.0/24 + + 10.0.0.0/24 + + + + 0 + + 0 + 10.0.0.1 + + + + GigabitEthernet0/9/0 + + + + + + + diff --git a/samples/openconfig-local-routing/add_route_with_nhop.xml b/samples/openconfig-local-routing/add_route_with_nhop.xml new file mode 100644 index 0000000..8089c4d --- /dev/null +++ b/samples/openconfig-local-routing/add_route_with_nhop.xml @@ -0,0 +1,20 @@ + + + + + 10.0.0.2/24 + + 10.0.0.2/24 + + + + 0 + + 0 + 10.0.0.1 + + + + + + diff --git a/samples/openconfig-local-routing/get-prefix-nhop-interface.xpath b/samples/openconfig-local-routing/get-prefix-nhop-interface.xpath new file mode 100644 index 0000000..68c96ca --- /dev/null +++ b/samples/openconfig-local-routing/get-prefix-nhop-interface.xpath @@ -0,0 +1,2 @@ +get --filter-xpath /openconfig-local-routing:local-routes/static-routes/static[prefix="10.0.0.0/24"]/next-hops/next-hop[index="0"]/interface-ref/state + diff --git a/samples/openconfig-local-routing/get-prefix-nhop.xpath b/samples/openconfig-local-routing/get-prefix-nhop.xpath new file mode 100644 index 0000000..4e161da --- /dev/null +++ b/samples/openconfig-local-routing/get-prefix-nhop.xpath @@ -0,0 +1 @@ +get --filter-xpath /openconfig-local-routing:local-routes/static-routes/static[prefix="10.0.0.0/24"]/next-hops/next-hop[index="0"]/state diff --git a/samples/openconfig-local-routing/get-prefix.xpath b/samples/openconfig-local-routing/get-prefix.xpath new file mode 100644 index 0000000..936442b --- /dev/null +++ b/samples/openconfig-local-routing/get-prefix.xpath @@ -0,0 +1 @@ +get --filter-xpath /openconfig-local-routing:local-routes/static-routes/static[prefix="10.0.0.0/24"]/state diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index d8dba04..d7f38e0 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -55,7 +55,6 @@ set(CMAKE_C_FLAGS_RELEASE "-Wall -Wextra -std=gnu99 -DNDEBUG -O2 ${RIGOROUS_C_FL set(PLUGINS_SOURCES sc_plugins.c sc_model.c - sys_util.c ietf/ietf_interface.c ietf/ietf_nat.c openconfig/openconfig_interfaces.c diff --git a/src/plugins/ietf/ietf_interface.c b/src/plugins/ietf/ietf_interface.c index 922c84f..0f8c37e 100644 --- a/src/plugins/ietf/ietf_interface.c +++ b/src/plugins/ietf/ietf_interface.c @@ -15,33 +15,12 @@ #include #include -#include -#include -#include "ietf_interface.h" +#include "../sc_model.h" +#include "../sys_util.h" -#include "sc_vpp_interface.h" -#include "sc_vpp_ip.h" - -/** - * @brief Helper function for converting netmask (ex: 255.255.255.0) - * to prefix length (ex: 24). - */ -static uint8_t -netmask_to_prefix(const char *netmask) -{ - in_addr_t n = 0; - uint8_t i = 0; - - inet_pton(AF_INET, netmask, &n); - - while (n > 0) { - n = n >> 1; - i++; - } - - return i; -} +#include +#include /** * @brief Callback to be called by any config change of @@ -51,6 +30,7 @@ static int ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, sr_notif_event_t event, void *private_ctx) { + UNUSED(private_ctx); char *if_name = NULL; sr_change_iter_t *iter = NULL; sr_change_oper_t op = SR_OP_CREATED; @@ -60,22 +40,22 @@ ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, int rc = SR_ERR_OK, op_rc = SR_ERR_OK; SRP_LOG_INF("In %s", __FUNCTION__); + /* no-op for apply, we only care about SR_EV_ENABLED, SR_EV_VERIFY, SR_EV_ABORT */ - if (SR_EV_APPLY == event) { + if (SR_EV_APPLY == event) return SR_ERR_OK; - } + SRP_LOG_DBG("'%s' modified, event=%d", xpath, event); /* get changes iterator */ rc = sr_get_changes_iter(session, xpath, &iter); if (SR_ERR_OK != rc) { + sr_free_change_iter(iter); SRP_LOG_ERR("Unable to retrieve change iterator: %s", sr_strerror(rc)); return rc; } - /* iterate over all changes */ - while ((SR_ERR_OK == op_rc || event == SR_EV_ABORT) && - (SR_ERR_OK == (rc = sr_get_change_next(session, iter, &op, &old_val, &new_val)))) { + foreach_change (session, iter, op, old_val, new_val) { SRP_LOG_DBG("A change detected in '%s', op=%d", new_val ? new_val->xpath : old_val->xpath, op); if_name = sr_xpath_key_value(new_val ? new_val->xpath : old_val->xpath, "interface", "name", &xpath_ctx); @@ -102,23 +82,6 @@ ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, return op_rc; } -static int free_sw_interface_dump_ctx(dump_all_ctx * dctx) -{ - if(dctx == NULL) - return -1; - - if(dctx->intfcArray != NULL) - { - free(dctx->intfcArray); - } - - dctx->intfcArray = NULL; - dctx->capacity = 0; - dctx->num_ifs = 0; - - return 0; -} - /** * @brief Modify existing IPv4/IPv6 config on an interface. */ @@ -169,7 +132,8 @@ interface_ipv46_config_modify(const char *if_name, sr_val_t *old_val, } /** - * @brief Callback to be called by any config change in subtrees "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address" + * @brief Callback to be called by any config change in subtrees + * "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address" * or "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address". */ static int @@ -178,6 +142,7 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, sr_notif_event_t event, void *private_ctx) { + UNUSED(private_ctx); sr_change_iter_t *iter = NULL; sr_change_oper_t op = SR_OP_CREATED; sr_val_t *old_val = NULL; @@ -207,13 +172,12 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, /* get changes iterator */ rc = sr_get_changes_iter(session, xpath, &iter); if (SR_ERR_OK != rc) { + sr_free_change_iter(iter); SRP_LOG_ERR("Unable to retrieve change iterator: %s", sr_strerror(rc)); return rc; } - /* iterate over all changes */ - while ((SR_ERR_OK == op_rc || event == SR_EV_ABORT) && - (SR_ERR_OK == (rc = sr_get_change_next(session, iter, &op, &old_val, &new_val)))) { + foreach_change(session, iter, op, old_val, new_val) { SRP_LOG_DBG("A change detected in '%s', op=%d", new_val ? new_val->xpath : old_val->xpath, op); if_name = strdup(sr_xpath_key_value(new_val ? new_val->xpath : old_val->xpath, "interface", "name", &xpath_ctx)); @@ -287,8 +251,9 @@ static int ietf_interface_change_cb(sr_session_ctx_t *session, const char *xpath, sr_notif_event_t event, void *private_ctx) { + UNUSED(session); UNUSED(xpath); UNUSED(event); UNUSED(private_ctx); + SRP_LOG_INF("In %s", __FUNCTION__); - SRP_LOG_DBG("'%s' modified, event=%d", xpath, event); return SR_ERR_OK; } @@ -298,87 +263,80 @@ ietf_interface_change_cb(sr_session_ctx_t *session, const char *xpath, */ static int ietf_interface_state_cb(const char *xpath, sr_val_t **values, - size_t *values_cnt, - __attribute__((unused)) uint64_t request_id, - __attribute__((unused)) const char *original_xpath, - __attribute__((unused)) void *private_ctx) + size_t *values_cnt, uint64_t request_id, + const char *original_xpath, void *private_ctx) { - sr_val_t *values_arr = NULL; - int values_arr_size = 0, values_arr_cnt = 0; - dump_all_ctx dctx; - int nb_iface; - vpp_interface_t* if_details; - int rc = 0; + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + struct elt* stack; + sw_interface_dump_t *dump; + sr_val_t *val = NULL; + int vc = 5; //number of answer per interfaces + int cnt = 0; //value counter + int rc = SR_ERR_OK; SRP_LOG_INF("In %s", __FUNCTION__); - if (! sr_xpath_node_name_eq(xpath, "interface")) { - /* statistics, ipv4 and ipv6 state data not supported */ - *values = NULL; - *values_cnt = 0; - return SR_ERR_OK; - } + if (!sr_xpath_node_name_eq(xpath, "interface")) + goto nothing_todo; //no interface field specified /* dump interfaces */ - nb_iface = interface_dump_all(&dctx); - if (nb_iface <= 0) { - SRP_LOG_ERR_MSG("Error by processing of a interface dump request."); - free_sw_interface_dump_ctx(&dctx); - return SR_ERR_INTERNAL; - } + stack = interface_dump_all(); + if (!stack) + goto nothing_todo; //no element returned /* allocate array of values to be returned */ - values_arr_size = nb_iface * 5; - rc = sr_new_values(values_arr_size, &values_arr); - if (0 != rc) { - free_sw_interface_dump_ctx(&dctx); - return rc; - } - - int i = 0; - for (; i < nb_iface; i++) { - if_details = dctx.intfcArray+i; - - /* currently the only supported interface types are propVirtual / ethernetCsmacd */ - sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/type", xpath, if_details->interface_name); - sr_val_set_str_data(&values_arr[values_arr_cnt], SR_IDENTITYREF_T, - strstr((char*)if_details->interface_name, "local0") ? "iana-if-type:propVirtual" : "iana-if-type:ethernetCsmacd"); - values_arr_cnt++; - - sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/admin-status", xpath, if_details->interface_name); - sr_val_set_str_data(&values_arr[values_arr_cnt], SR_ENUM_T, if_details->admin_up_down ? "up" : "down"); - values_arr_cnt++; - - sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/oper-status", xpath, if_details->interface_name); - sr_val_set_str_data(&values_arr[values_arr_cnt], SR_ENUM_T, if_details->link_up_down ? "up" : "down"); - values_arr_cnt++; - - if (if_details->l2_address_length > 0) { - sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/phys-address", xpath, if_details->interface_name); - sr_val_build_str_data(&values_arr[values_arr_cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", - if_details->l2_address[0], if_details->l2_address[1], if_details->l2_address[2], - if_details->l2_address[3], if_details->l2_address[4], if_details->l2_address[5]); - values_arr_cnt++; + SRP_LOG_DBG("number of interfaces: %d", stack->id+1); + rc = sr_new_values((stack->id + 1)* vc, &val); + if (0 != rc) + goto nothing_todo; + + foreach_stack_elt(stack) { + dump = (sw_interface_dump_t *) data; + + SRP_LOG_DBG("State of interface %s", dump->interface_name); + //TODO need support for type propvirtual + sr_val_build_xpath(&val[cnt], "%s[name='%s']/type", xpath, dump->interface_name); + sr_val_set_str_data(&val[cnt], SR_IDENTITYREF_T, "iana-if-type:ethernetCsmacd"); + cnt++; + + //Be careful, it needs if-mib feature to work ! + sr_val_build_xpath(&val[cnt], "%s[name='%s']/admin-status", xpath, dump->interface_name); + sr_val_set_str_data(&val[cnt], SR_ENUM_T, dump->link_up_down ? "up" : "down"); + cnt++; + + sr_val_build_xpath(&val[cnt], "%s[name='%s']/oper-status", xpath, dump->interface_name); + sr_val_set_str_data(&val[cnt], SR_ENUM_T, dump->link_up_down ? "up" : "down"); + cnt++; + + sr_val_build_xpath(&val[cnt], "%s[name='%s']/phys-address", xpath, dump->interface_name); + if (dump->l2_address_length > 0) { + sr_val_build_str_data(&val[cnt], SR_STRING_T, + "%02x:%02x:%02x:%02x:%02x:%02x", + dump->l2_address[0], dump->l2_address[1], + dump->l2_address[2], dump->l2_address[3], + dump->l2_address[4], dump->l2_address[5]); } else { - sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/phys-address", xpath, if_details->interface_name); - sr_val_build_str_data(&values_arr[values_arr_cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", 0,0,0,0,0,0); - values_arr_cnt++; + sr_val_build_str_data(&val[cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", 0,0,0,0,0,0); } + cnt++; - sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/speed", xpath, if_details->interface_name); - values_arr[values_arr_cnt].type = SR_UINT64_T; - values_arr[values_arr_cnt].data.uint64_val = if_details->link_speed; - values_arr_cnt++; - } - - SRP_LOG_DBG("Returning %zu state data elements for '%s'", values_arr, xpath); + sr_val_build_xpath(&val[cnt], "%s[name='%s']/speed", xpath, dump->interface_name); + val[cnt].type = SR_UINT64_T; + val[cnt].data.uint64_val = dump->link_speed; + cnt++; - *values = values_arr; - *values_cnt = values_arr_cnt; + free(dump); + } - free_sw_interface_dump_ctx(&dctx); + *values = val; + *values_cnt = cnt; return SR_ERR_OK; + +nothing_todo: + *values = NULL; + *values_cnt = 0; + return rc; } const xpath_t ietf_interfaces_xpaths[IETF_INTERFACES_SIZE] = { diff --git a/src/plugins/ietf/ietf_interface.h b/src/plugins/ietf/ietf_interface.h deleted file mode 100644 index 28a3783..0000000 --- a/src/plugins/ietf/ietf_interface.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018 HUACHENTEL and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __IETF_INTERFACE_H__ -#define __IETF_INTERFACE_H__ - -#include "../sc_model.h" - -#define IETF_INTERFACES_SIZE 5 -extern const xpath_t ietf_interfaces_xpaths[IETF_INTERFACES_SIZE]; - -#endif /* __IETF_INTERFACE_H__ */ - diff --git a/src/plugins/ietf/ietf_nat.c b/src/plugins/ietf/ietf_nat.c index 86c8570..9b2890e 100644 --- a/src/plugins/ietf/ietf_nat.c +++ b/src/plugins/ietf/ietf_nat.c @@ -14,10 +14,11 @@ * limitations under the License. */ -#include "ietf_nat.h" -#include "sc_vpp_comm.h" -#include "sc_vpp_interface.h" -#include "sc_vpp_nat.h" +#include +#include +#include + +#include "../sc_model.h" #include #include @@ -30,17 +31,6 @@ #include "../sys_util.h" -static int ietf_nat_mod_cb( - __attribute__((unused)) sr_session_ctx_t *session, - __attribute__((unused)) const char *module_name, - __attribute__((unused)) sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) -{ - SRP_LOG_INF("Module subscribe: %s", module_name); - - return SR_ERR_OK; -} - /** * @brief Wrapper struct for VAPI address range payload. */ @@ -103,8 +93,7 @@ static int parse_instance_policy_external_ip_address_pool( if (sr_xpath_node_name_eq(val->xpath, "pool-id")) { SRP_LOG_WRN("%s not supported.", val->xpath); } else if(sr_xpath_node_name_eq(val->xpath, "external-ip-pool")) { - rc = get_address_from_prefix(tmp_str, val->data.string_val, - VPP_IP4_ADDRESS_STRING_LEN, &prefix); + rc = prefix2address(tmp_str, val->data.string_val, &prefix); if (0 != rc) { SRP_LOG_ERR_MSG("Error translate"); return SR_ERR_INVAL_ARG; @@ -136,8 +125,9 @@ static int parse_instance_policy_external_ip_address_pool( // XPATH: /ietf-nat:nat/instances/instance[id='%s']/policy[id='%s']/external-ip-address-pool[pool-id='%s']/ static int instances_instance_policy_external_ip_address_pool_cb( sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) + void *private_ctx) { + UNUSED(private_ctx); sr_error_t rc = SR_ERR_OK; sr_change_iter_t *it = NULL; sr_change_oper_t oper; @@ -150,6 +140,8 @@ static int instances_instance_policy_external_ip_address_pool_cb( ARG_CHECK2(SR_ERR_INVAL_ARG, ds, xpath); + SRP_LOG_INF("In %s", __FUNCTION__); + new_address_r.payload.vrf_id = ~0; old_address_r.payload.vrf_id = ~0; @@ -165,8 +157,7 @@ static int instances_instance_policy_external_ip_address_pool_cb( return SR_ERR_OK; } - while (sr_get_change_next(ds, it, &oper, - &old_val, &new_val) == SR_ERR_OK) { + foreach_change (ds, it, oper, old_val, new_val) { SRP_LOG_DBG("A change detected in '%s', op=%d", new_val ? new_val->xpath : old_val->xpath, oper); @@ -345,8 +336,7 @@ static int parse_instance_mapping_table_mapping_entry( return SR_ERR_INVAL_ARG; } - rc = get_address_from_prefix(tmp_str, val->data.string_val, - VPP_IP4_PREFIX_STRING_LEN, NULL); + rc = prefix2address(tmp_str, val->data.string_val, NULL); if (0 != rc) { SRP_LOG_ERR_MSG("Error translate"); return SR_ERR_INVAL_ARG; @@ -367,8 +357,7 @@ static int parse_instance_mapping_table_mapping_entry( return SR_ERR_INVAL_ARG; } - rc = get_address_from_prefix(tmp_str, val->data.string_val, - VPP_IP4_ADDRESS_STRING_LEN, NULL); + rc = prefix2address(tmp_str, val->data.string_val, NULL); if (0 != rc) { SRP_LOG_ERR_MSG("Error translate"); return SR_ERR_INVAL_ARG; @@ -402,8 +391,9 @@ static int parse_instance_mapping_table_mapping_entry( // XPATH: /ietf-nat:nat/instances/instance[id='%s']/mapping-table/mapping-entry[index='%s']/ static int instances_instance_mapping_table_mapping_entry_cb( sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) + void *private_ctx) { + UNUSED(private_ctx); sr_error_t rc = SR_ERR_OK; sr_change_iter_t *it = NULL; sr_change_oper_t oper; @@ -416,6 +406,8 @@ static int instances_instance_mapping_table_mapping_entry_cb( ARG_CHECK2(SR_ERR_INVAL_ARG, ds, xpath); + SRP_LOG_INF("In %s", __FUNCTION__); + new_mapping.mtype = UNKNOWN; old_mapping.mtype = UNKNOWN; @@ -431,8 +423,7 @@ static int instances_instance_mapping_table_mapping_entry_cb( return SR_ERR_OK; } - while (sr_get_change_next(ds, it, &oper, - &old_val, &new_val) == SR_ERR_OK) { + foreach_change (ds, it, oper, old_val, new_val) { SRP_LOG_DBG("A change detected in '%s', op=%d", new_val ? new_val->xpath : old_val->xpath, oper); @@ -502,15 +493,6 @@ error: } const xpath_t ietf_nat_xpaths[IETF_NAT_SIZE] = { - { - .xpath = "ietf-nat", - .method = MODULE, - .datastore = SR_DS_RUNNING, - .cb.mcb = ietf_nat_mod_cb, - .private_ctx = NULL, - .priority = 0, - .opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY | SR_SUBSCR_CTX_REUSE - }, { .xpath = "/ietf-nat:nat/instances/instance/policy/external-ip-address-pool", .method = XPATH, diff --git a/src/plugins/ietf/ietf_nat.h b/src/plugins/ietf/ietf_nat.h deleted file mode 100644 index 7495209..0000000 --- a/src/plugins/ietf/ietf_nat.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2019 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __IETF_NAT_H__ -#define __IETF_NAT_H__ - -#include "../sc_model.h" - -#define IETF_NAT_SIZE 3 -extern const xpath_t ietf_nat_xpaths[IETF_NAT_SIZE]; - -#endif diff --git a/src/plugins/openconfig/openconfig_interfaces.c b/src/plugins/openconfig/openconfig_interfaces.c index c72ad7f..7242c2b 100644 --- a/src/plugins/openconfig/openconfig_interfaces.c +++ b/src/plugins/openconfig/openconfig_interfaces.c @@ -17,119 +17,72 @@ #include #include -#include "openconfig_interfaces.h" -#include "../sys_util.h" - -#include "sc_vpp_comm.h" -#include "sc_vpp_interface.h" -#include "sc_vpp_ip.h" +#include +#include +#include -#define XPATH_SIZE 2000 +#include "../sc_model.h" +#include "../sys_util.h" // XPATH: /openconfig-interfaces:interfaces/interface[name='%s']/config/ -int openconfig_interfaces_interfaces_interface_config_cb( +static int openconfig_interfaces_interfaces_interface_config_cb( sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) + void *private_ctx) { + UNUSED(private_ctx); sr_change_iter_t *it = NULL; sr_change_oper_t oper; - sr_val_t *old_val = NULL; - sr_val_t *new_val = NULL; + sr_xpath_ctx_t state = {0}; + sr_val_t *old = NULL; + sr_val_t *new = NULL; char *tmp = NULL; char interface_name[XPATH_SIZE] = {0}; int rc = 0; - SRP_LOG_INF_MSG("In openconfig_interfaces_interfaces_interface_config_cb"); + SRP_LOG_INF("In %s", __FUNCTION__); + SRP_LOG_INF("XPATH %s", xpath); ARG_CHECK2(SR_ERR_INVAL_ARG, ds, xpath); - // if we receive event SR_EV_APPLY - config has changed - - log_recv_event(event, "subtree_change_cb received"); - SRP_LOG_DBG("[SRP_LOG_DBG] xpath: %s", xpath); - - // apply configuration - // - // - // in this type i guess we can call sr_get_item() - // because we are subscribed to leaf we shouldn't - // get more than one change in one callback - // each chage represent change in a hierarchy of - // xml document - // - if (event != SR_EV_APPLY) { + if (event == SR_EV_APPLY) return SR_ERR_OK; - } - - // first we get event VERIFY - // then we get event APPLY - // - we can return error from VERIFY event - // - we can't return error from APPLY event if (sr_get_changes_iter(ds, (char *)xpath, &it) != SR_ERR_OK) { - // in example he calls even on fale sr_free_change_iter(it); return SR_ERR_OK; } - while (sr_get_change_next(ds, it, &oper, - &old_val, &new_val) == SR_ERR_OK) { + foreach_change (ds, it, oper, old, new) { - log_recv_oper(oper, "subtree_change_cb received"); + SRP_LOG_DBG("xpath: %s", new->xpath); - SRP_LOG_DBG("xpath: %s", new_val->xpath); - - sr_xpath_ctx_t state = {0}; - - tmp = xpath_find_first_key(new_val->xpath, "name", &state); - if (NULL == tmp) { - SRP_LOG_DBG_MSG("interface_name NOT found."); - continue; + tmp = sr_xpath_key_value(new->xpath, "interface", "name", &state); + if (!tmp) { + sr_set_error(ds, "XPATH interface name NOT found", new->xpath); + return SR_ERR_INVAL_ARG; } - strncpy(interface_name, tmp, XPATH_SIZE); sr_xpath_recover(&state); switch (oper) { case SR_OP_CREATED: - if (sr_xpath_node_name_eq(new_val->xpath, "name")) { - //TODO: LEAF: name, type: string - } else if(sr_xpath_node_name_eq(new_val->xpath, "type")) { - //TODO: LEAF: type, type: identityref - } else if(sr_xpath_node_name_eq(new_val->xpath, "mtu")) { - //TODO: LEAF: mtu, type: uint16 - } else if(sr_xpath_node_name_eq(new_val->xpath, - "loopback-mode")) { - //TODO: LEAF: loopback-mode, type: boolean - } else if(sr_xpath_node_name_eq(new_val->xpath, - "description")) { - //TODO: LEAF: description, type: string - } else if(sr_xpath_node_name_eq(new_val->xpath, "enabled")) { - rc = interface_enable(interface_name, - new_val->data.bool_val); - } else if(sr_xpath_node_name_eq(new_val->xpath, - "oc-vlan:tpid")) { - //TODO: LEAF: oc-vlan:tpid, type: identityref - } - break; - case SR_OP_MODIFIED: - if (sr_xpath_node_name_eq(new_val->xpath, "name")) { + if (sr_xpath_node_name_eq(new->xpath, "name")) { //TODO: LEAF: name, type: string - } else if(sr_xpath_node_name_eq(new_val->xpath, "type")) { + } else if(sr_xpath_node_name_eq(new->xpath, "type")) { //TODO: LEAF: type, type: identityref - } else if(sr_xpath_node_name_eq(new_val->xpath, "mtu")) { + } else if(sr_xpath_node_name_eq(new->xpath, "mtu")) { //TODO: LEAF: mtu, type: uint16 - } else if(sr_xpath_node_name_eq(new_val->xpath, + } else if(sr_xpath_node_name_eq(new->xpath, "loopback-mode")) { //TODO: LEAF: loopback-mode, type: boolean - } else if(sr_xpath_node_name_eq(new_val->xpath, + } else if(sr_xpath_node_name_eq(new->xpath, "description")) { //TODO: LEAF: description, type: string - } else if(sr_xpath_node_name_eq(new_val->xpath, "enabled")) { + } else if(sr_xpath_node_name_eq(new->xpath, "enabled")) { rc = interface_enable(interface_name, - new_val->data.bool_val); - } else if(sr_xpath_node_name_eq(new_val->xpath, + new->data.bool_val); + } else if(sr_xpath_node_name_eq(new->xpath, "oc-vlan:tpid")) { //TODO: LEAF: oc-vlan:tpid, type: identityref } @@ -139,21 +92,21 @@ int openconfig_interfaces_interfaces_interface_config_cb( break; case SR_OP_DELETED: - if (sr_xpath_node_name_eq(old_val->xpath, "name")) { + if (sr_xpath_node_name_eq(old->xpath, "name")) { //TODO: LEAF: name, type: string - } else if(sr_xpath_node_name_eq(old_val->xpath, "type")) { + } else if(sr_xpath_node_name_eq(old->xpath, "type")) { //TODO: LEAF: type, type: identityref - } else if(sr_xpath_node_name_eq(old_val->xpath, "mtu")) { + } else if(sr_xpath_node_name_eq(old->xpath, "mtu")) { //TODO: LEAF: mtu, type: uint16 - } else if(sr_xpath_node_name_eq(old_val->xpath, + } else if(sr_xpath_node_name_eq(old->xpath, "loopback-mode")) { //TODO: LEAF: loopback-mode, type: boolean - } else if(sr_xpath_node_name_eq(old_val->xpath, + } else if(sr_xpath_node_name_eq(old->xpath, "description")) { //TODO: LEAF: description, type: string - } else if(sr_xpath_node_name_eq(old_val->xpath, "enabled")) { + } else if(sr_xpath_node_name_eq(old->xpath, "enabled")) { rc = interface_enable(interface_name, false); - } else if(sr_xpath_node_name_eq(old_val->xpath, + } else if(sr_xpath_node_name_eq(old->xpath, "oc-vlan:tpid")) { //TODO: LEAF: oc-vlan:tpid, type: identityref } @@ -163,8 +116,8 @@ int openconfig_interfaces_interfaces_interface_config_cb( if (0 != rc) { sr_xpath_recover(&state); - sr_free_val(old_val); - sr_free_val(new_val); + sr_free_val(old); + sr_free_val(new); sr_free_change_iter(it); @@ -173,175 +126,190 @@ int openconfig_interfaces_interfaces_interface_config_cb( sr_xpath_recover(&state); - sr_free_val(old_val); - sr_free_val(new_val); + sr_free_val(old); + sr_free_val(new); } sr_free_change_iter(it); return SR_ERR_OK; } -// openconfig-interfaces -int openconfig_interface_mod_cb( - __attribute__((unused)) sr_session_ctx_t *session, - __attribute__((unused)) const char *module_name, - __attribute__((unused)) sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) -{ - SRP_LOG_INF_MSG("In openconfig_interface_mod_cb"); - - return SR_ERR_OK; -} - -typedef struct +//XPATH : /openconfig-interfaces:interfaces/interface/state +static int +openconfig_interfaces_interfaces_interface_state_cb( + const char *xpath, sr_val_t **values, + size_t *values_cnt, uint64_t request_id, const char *original_xpath, + void *private_ctx) { - bool is_subif; - u32 subinterface_index; - sw_interface_details_query_t sw_interface_details_query; - sysr_values_ctx_t sysr_values_ctx; -} sys_sw_interface_dump_ctx; + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + sw_interface_dump_t reply = {0}; + sr_val_t *vals = NULL; + sr_xpath_ctx_t state = {0}; + char interface_name[VPP_INTFC_NAME_LEN] = {0}; + char xpath_root[XPATH_SIZE]; + int vc = 10; + char *tmp; + int rc; -#define NOT_AVAL "NA" + SRP_LOG_INF("In %s", __FUNCTION__); + ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); -static int sw_interface_dump_cb_inner( - vapi_payload_sw_interface_details * reply, - sys_sw_interface_dump_ctx * dctx) -{ - sr_val_t *vals = NULL; - int rc = 0; - int vc = 0; + tmp = sr_xpath_key_value((char*) xpath, "interface", "name", &state); + if (!tmp) { + SRP_LOG_ERR_MSG("XPATH interface name not found"); + return SR_ERR_INVAL_ARG; + } + strncpy(interface_name, tmp, VPP_INTFC_NAME_LEN); + sr_xpath_recover(&state); - ARG_CHECK2(SR_ERR_INVAL_ARG, reply, dctx); + snprintf(xpath_root, XPATH_SIZE, + "/openconfig-interfaces:interfaces/interface[name='%s']/state", + interface_name); - vc = 10; + //dump interface interface_name + rc = interface_dump_iface(&reply, interface_name); + if (rc == -SCVPP_NOT_FOUND) { + SRP_LOG_ERR_MSG("interface not found"); + return SR_ERR_NOT_FOUND; + } - /* convenient functions such as this can be found in sysrepo/values.h */ rc = sr_new_values(vc, &vals); - if (SR_ERR_OK != rc) { + if (SR_ERR_OK != rc) return rc; - } - - const char* interface_name = (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name; - sr_val_build_xpath(&vals[0], "%s/name", dctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[0], SR_STRING_T, interface_name); + sr_val_build_xpath(&vals[0], "%s/name", xpath_root); + sr_val_set_str_data(&vals[0], SR_STRING_T, (char *)reply.interface_name); - sr_val_build_xpath(&vals[1], "%s/type", dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[1], "%s/type", xpath_root); sr_val_set_str_data(&vals[1], SR_IDENTITYREF_T, "ianaift:ethernetCsmacd"); - sr_val_build_xpath(&vals[2], "%s/mtu", dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[2], "%s/mtu", xpath_root); vals[2].type = SR_UINT16_T; - vals[2].data.uint16_val = reply->link_mtu; + vals[2].data.uint16_val = reply.link_mtu; - sr_val_build_xpath(&vals[3], "%s/loopback-mode", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[3], "%s/loopback-mode", xpath_root); vals[3].type = SR_BOOL_T; - vals[3].data.bool_val = (0 == strncmp(interface_name, "loop", 4)) ? 1 : 0; + if (strncmp((char*)reply.interface_name, "loop", 4) == 0) + vals[3].data.bool_val = 1; + else + vals[3].data.bool_val = 0; - sr_val_build_xpath(&vals[4], "%s/description", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[4], "%s/description", xpath_root); sr_val_set_str_data(&vals[4], SR_STRING_T, NOT_AVAL); - sr_val_build_xpath(&vals[5], "%s/enabled", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[5], "%s/enabled", xpath_root); vals[5].type = SR_BOOL_T; - vals[5].data.bool_val = reply->admin_up_down; + vals[5].data.bool_val = reply.admin_up_down; - sr_val_build_xpath(&vals[6], "%s/ifindex", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[6], "%s/ifindex", xpath_root); vals[6].type = SR_UINT32_T; - vals[6].data.uint32_val = reply->sw_if_index; + vals[6].data.uint32_val = reply.sw_if_index; - sr_val_build_xpath(&vals[7], "%s/admin-status", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[7], "%s/admin-status", xpath_root); sr_val_set_str_data(&vals[7], SR_ENUM_T, - reply->admin_up_down ? "UP" : "DOWN"); + reply.admin_up_down ? "UP" : "DOWN"); - sr_val_build_xpath(&vals[8], "%s/oper-status", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[8], "%s/oper-status", xpath_root); sr_val_set_str_data(&vals[8], SR_ENUM_T, - reply->link_up_down ? "UP" : "DOWN"); + reply.link_up_down ? "UP" : "DOWN"); //TODO: Openconfig required this value - // sr_val_build_xpath(&vals[9], "%s/last-change", dctx->sysr_values_ctx.xpath_root); + // sr_val_build_xpath(&vals[9], "%s/last-change", xpath_root); // sr_val_set_str_data(&vals[9], YANG INPUT TYPE: oc-types:timeticks64); - sr_val_build_xpath(&vals[9], "%s/logical", - dctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[9], "%s/logical", xpath_root); vals[9].type = SR_BOOL_T; - vals[9].data.bool_val = true; //for now, we assume all are logical + vals[9].data.bool_val = true; //for now, we assume all are logical - dctx->sysr_values_ctx.values = vals; - dctx->sysr_values_ctx.values_cnt = vc; + *values = vals; + *values_cnt = vc; return SR_ERR_OK; } -static int sw_subinterface_dump_cb_inner( - vapi_payload_sw_interface_details *reply, - sys_sw_interface_dump_ctx *dctx) +//TODO: for some arcane reason, this doesn't work +static int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_cb( + const char *xpath, sr_val_t **values, size_t *values_cnt, + uint64_t request_id, const char *original_xpath, void *private_ctx) { + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + char xpath_root[XPATH_SIZE] = {0}; + sr_xpath_ctx_t state = {0}; sr_val_t *vals = NULL; - int rc = 0; - int vc = 0, val_idx = 0; + char interface_name[VPP_INTFC_NAME_LEN] = {0}; + char subinterface_index[XPATH_SIZE] = {0}; + char address_ip[XPATH_SIZE] = {0}; + u8 prefix_len; + char *tmp = NULL; + int rc, cnt = 0; - ARG_CHECK2(SR_ERR_INVAL_ARG, reply, dctx); + ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); - vc = 6; - /* convenient functions such as this can be found in sysrepo/values.h */ - rc = sr_new_values(vc, &vals); - if (SR_ERR_OK != rc) { - return rc; + SRP_LOG_INF("In %s", __FUNCTION__); + + /* Get XPATH parameters name, index and ip */ + + tmp = sr_xpath_key_value((char*)xpath, "interface", "name", &state); + if (!tmp) { + SRP_LOG_ERR_MSG("XPATH interface name not found"); + return SR_ERR_INVAL_ARG; } + strncpy(interface_name, tmp, VPP_INTFC_NAME_LEN); + sr_xpath_recover(&state); - sr_val_build_xpath(&vals[val_idx], "%s/index", - dctx->sysr_values_ctx.xpath_root); - vals[val_idx].type = SR_UINT32_T; - vals[val_idx++].data.uint32_val = dctx->subinterface_index; + tmp = sr_xpath_key_value((char*)xpath, "subinterface", "index", &state); + if (NULL == tmp) { + SRP_LOG_ERR_MSG("XPATH subinterface index not found."); + return SR_ERR_INVAL_ARG; + } + strncpy(subinterface_index, tmp, XPATH_SIZE); + sr_xpath_recover(&state); - sr_val_build_xpath(&vals[val_idx], "%s/description", - dctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[val_idx++], SR_STRING_T, NOT_AVAL); + tmp = sr_xpath_key_value((char*)xpath, "address", "ip", &state); + if (NULL == tmp) { + SRP_LOG_ERR_MSG("XPATH address ip not found."); + return SR_ERR_INVAL_ARG; + } + strncpy(address_ip, tmp, XPATH_SIZE); + sr_xpath_recover(&state); - sr_val_build_xpath(&vals[val_idx], "%s/enabled", - dctx->sysr_values_ctx.xpath_root); - vals[val_idx].type = SR_BOOL_T; - vals[val_idx++].data.bool_val = reply->admin_up_down; + snprintf(xpath_root, XPATH_SIZE, "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/openconfig-if-ip:ipv4/openconfig-if-ip:addresses/openconfig-if-ip:address[ip='%s']/openconfig-if-ip:state", + interface_name, subinterface_index, address_ip); - //TODO: Openconfig required this value - // sr_val_build_xpath(&vals[val_idx], "%s/name", dctx->sysr_values_ctx.xpath_root); - // sr_val_set_str_data(&vals[val_idx++], SR_STRING_T, YANG INPUT TYPE: string); + rc = ipv46_address_dump(interface_name, address_ip, &prefix_len, false); + if (!rc) { + SRP_LOG_ERR_MSG("ipv46_address_dump failed"); + return SR_ERR_INVAL_ARG; + } - // sr_val_build_xpath(&vals[val_idx], "%s/ifindex", interface_name, subinterface_index); - // vals[val_idx].type = SR_UINT32_T; - // vals[val_idx++].data.uint32_val = YANG INPUT TYPE: uint32; + /* Build answer to state XPATH */ - sr_val_build_xpath(&vals[val_idx], "%s/admin-status", - dctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, - reply->admin_up_down ? "UP" : "DOWN"); + rc = sr_new_values(3, &vals); + if (SR_ERR_OK != rc) + return rc; - sr_val_build_xpath(&vals[val_idx], "%s/oper-status", - dctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, - reply->admin_up_down ? "UP" : "DOWN"); + sr_val_build_xpath(&vals[cnt], "%s/openconfig-if-ip:ip", xpath_root); + sr_val_set_str_data(&vals[cnt], SR_STRING_T, address_ip); + cnt++; - //TODO: Openconfig required this value - // sr_val_build_xpath(&vals[val_idx], "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/state/last-change", interface_name, subinterface_index); - // sr_val_set_str_data(&vals[val_idx++], YANG INPUT TYPE: oc-types:timeticks64); + sr_val_build_xpath(&vals[cnt], "%s/openconfig-if-ip:prefix-length", xpath_root); + vals[cnt].type = SR_UINT8_T; + vals[cnt].data.uint8_val = prefix_len; + cnt++; - sr_val_build_xpath(&vals[val_idx], "%s/logical", - dctx->sysr_values_ctx.xpath_root); - vals[val_idx].type = SR_BOOL_T; - vals[val_idx++].data.bool_val = true; //for now, we assume all are logical + sr_val_build_xpath(&vals[cnt], "%s/openconfig-if-ip:origin", xpath_root); + sr_val_set_str_data(&vals[cnt], SR_ENUM_T, "STATIC"); + cnt++; - dctx->sysr_values_ctx.values = vals; - dctx->sysr_values_ctx.values_cnt = vc; + sr_xpath_recover(&state); + *values = vals; + *values_cnt = cnt; return SR_ERR_OK; } +/* TODO move to common functions between all plugins */ static bool is_subinterface(const char* subif_name, const char* base_name, const u32 subif_index) @@ -351,11 +319,10 @@ is_subinterface(const char* subif_name, const char* base_name, const char* dot = strchr(subif_name, '.'); if (NULL == dot && 0 == subif_index) - return true; //subif_index == 0 can pass as a "real" interface + return true; //subif_index == 0 can pass as a "real" interface if (dot > subif_name && 0 == strncmp(subif_name, base_name, - dot - subif_name)) - { + dot - subif_name)) { char * eptr = NULL; u32 si = strtoul(dot + 1, &eptr, 10); @@ -366,289 +333,126 @@ is_subinterface(const char* subif_name, const char* base_name, return false; } -static vapi_error_e -sw_interface_dump_vapi_cb(struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_sw_interface_details * reply) -{ - ARG_CHECK(VAPI_EINVAL, callback_ctx); - - if (is_last) - { - assert (NULL == reply); - } - else - { - assert (NULL != reply); - sys_sw_interface_dump_ctx *dctx = callback_ctx; - - const char* const dctx_interface_name = (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name; - - SRP_LOG_DBG("interface_name: '%s', if_name: '%s'", reply->interface_name, dctx_interface_name); - - if (dctx->is_subif) - { - if (is_subinterface((const char*)reply->interface_name, - dctx_interface_name, dctx->subinterface_index)) - sw_subinterface_dump_cb_inner(reply, dctx); - } - else - { - if (0 == strcmp(dctx_interface_name, (char *)reply->interface_name)) - { - dctx->sw_interface_details_query.sw_interface_details = *reply; - dctx->sw_interface_details_query.interface_found = true; - - sw_interface_dump_cb_inner(reply, dctx); - } - } - } - - return VAPI_OK; -} - -static vapi_error_e sysr_sw_interface_dump(sys_sw_interface_dump_ctx * dctx) -{ - vapi_msg_sw_interface_dump *dump; - vapi_error_e rv; - - ARG_CHECK(VAPI_EINVAL, dctx); - - dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance); - - dump->payload.name_filter_valid = true; - strcpy((char*)dump->payload.name_filter, (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name); - - VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, dump, sw_interface_dump_vapi_cb, - dctx)); - - if (VAPI_OK != rv) { - SRP_LOG_DBG("vapi_sw_interface_dump error=%d", rv); - } - - return rv; -} - -int openconfig_interfaces_interfaces_interface_state_cb( - const char *xpath, sr_val_t **values, - size_t *values_cnt, - __attribute__((unused)) uint64_t request_id, - __attribute__((unused)) const char *original_xpath, - __attribute__((unused)) void *private_ctx) -{ - sr_xpath_ctx_t state = {0}; - char *tmp = NULL; - char interface_name[XPATH_SIZE] = {0}; - - SRP_LOG_INF_MSG("In openconfig_interfaces_interfaces_interface_state_cb"); - - ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); - - tmp = xpath_find_first_key(xpath, "name", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("Interface name not found in sysrepo database"); - return SR_ERR_INVAL_ARG; - } - - strncpy(interface_name, tmp, XPATH_SIZE); - sr_xpath_recover(&state); - - sys_sw_interface_dump_ctx dctx = { - .is_subif = false - }; - sw_interface_details_query_set_name(&dctx.sw_interface_details_query, - interface_name); - - snprintf(dctx.sysr_values_ctx.xpath_root, XPATH_SIZE, - "/openconfig-interfaces:interfaces/interface[name='%s']/state", - interface_name); - - sysr_sw_interface_dump(&dctx); - - if (!dctx.sw_interface_details_query.interface_found) { - SRP_LOG_ERR_MSG("interface not found"); - return SR_ERR_NOT_FOUND; - } - - sr_xpath_recover(&state); - *values = dctx.sysr_values_ctx.values; - *values_cnt = dctx.sysr_values_ctx.values_cnt; - - return SR_ERR_OK; -} - -int oc_dump_ip_helper(char *address_ip, u8 prefix_len, - sysr_values_ctx_t *sysr_values_ctx) -{ - sr_val_t *vals = NULL; - int rc = 0; - int vc = 0; - - ARG_CHECK2(SR_ERR_INVAL_ARG, address_ip, sysr_values_ctx); - - vc = 3; - /* convenient functions such as this can be found in sysrepo/values.h */ - rc = sr_new_values(vc, &vals); - if (SR_ERR_OK != rc) { - return rc; - } - - sr_val_build_xpath(&vals[0], "%s/openconfig-if-ip:ip", - sysr_values_ctx->xpath_root); - sr_val_set_str_data(&vals[0], SR_STRING_T, address_ip); - - sr_val_build_xpath(&vals[1], "%s/openconfig-if-ip:prefix-length", - sysr_values_ctx->xpath_root); - vals[1].type = SR_UINT8_T; - vals[1].data.uint8_val = prefix_len; - - sr_val_build_xpath(&vals[2], "%s/openconfig-if-ip:origin", - sysr_values_ctx->xpath_root); - sr_val_set_str_data(&vals[2], SR_ENUM_T, "STATIC"); - - sysr_values_ctx->values = vals; - sysr_values_ctx->values_cnt = vc; - - return SR_ERR_OK; -} - -//TODO: for some arcane reason, this doesn't work -int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_cb( +// openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/state +static int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_state_cb( const char *xpath, sr_val_t **values, size_t *values_cnt, - __attribute__((unused)) uint64_t request_id, - __attribute__((unused)) const char *original_xpath, - __attribute__((unused)) void *private_ctx) + uint64_t request_id, const char *original_xpath, void *private_ctx) { + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + sw_interface_dump_t reply = {0}; + char xpath_root[XPATH_SIZE]; sr_xpath_ctx_t state = {0}; - int rc; char *tmp = NULL; - char interface_name[XPATH_SIZE] = {0}; + char interface_name[VPP_INTFC_NAME_LEN] = {0}; char subinterface_index[XPATH_SIZE] = {0}; - char address_ip[XPATH_SIZE] = {0}; - u8 prefix_len; + u32 sub_id; + sr_val_t *vals = NULL; + int vc = 6; + int val_idx = 0; + int rc; ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); - SRP_LOG_INF_MSG("In oc-interfaces oc-ip"); + SRP_LOG_INF("In %s", __FUNCTION__); - tmp = xpath_find_first_key(xpath, "name", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("interface_name not found."); + tmp = sr_xpath_key_value((char*)xpath, "interface", "name", &state); + if (!tmp) { + SRP_LOG_ERR_MSG("XPATH interface name not found"); return SR_ERR_INVAL_ARG; } - - strncpy(interface_name, tmp, XPATH_SIZE); + strncpy(interface_name, tmp, VPP_INTFC_NAME_LEN); sr_xpath_recover(&state); - tmp = xpath_find_first_key(xpath, "index", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("subinterface_index not found."); + tmp = sr_xpath_key_value((char*)xpath, "subinterface", "index", &state); + if (!tmp) { + SRP_LOG_ERR_MSG("subinterface index not found"); return SR_ERR_INVAL_ARG; } - strncpy(subinterface_index, tmp, XPATH_SIZE); sr_xpath_recover(&state); - tmp = xpath_find_first_key(xpath, "ip", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("address_ip not found."); - return SR_ERR_INVAL_ARG; - } - - strncpy(address_ip, tmp, XPATH_SIZE); - sr_xpath_recover(&state); - - sysr_values_ctx_t dctx = {0}; - snprintf(dctx.xpath_root, XPATH_SIZE, "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/openconfig-if-ip:ipv4/openconfig-if-ip:addresses/openconfig-if-ip:address[ip='%s']/openconfig-if-ip:state", - interface_name, subinterface_index, address_ip); + snprintf(xpath_root, XPATH_SIZE, + "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/state", + interface_name, subinterface_index); - rc = ipv46_address_dump(interface_name, address_ip, &prefix_len, false); - if (!rc) { - SRP_LOG_ERR_MSG("ipv46_address_dump failed"); - return SR_ERR_INVAL_ARG; + rc = interface_dump_iface(&reply, interface_name); + if (rc == -SCVPP_NOT_FOUND) { + SRP_LOG_ERR_MSG("interface not found"); + return SR_ERR_NOT_FOUND; } - rc = oc_dump_ip_helper(address_ip, prefix_len, &dctx); - if (!rc) { - SRP_LOG_ERR_MSG("oc_dump_ip_helper failed"); - return rc; + /* Check that requested subinterface index matches reply subid */ + sub_id = atoi(subinterface_index); + if (sub_id != reply.sub_id) { + SRP_LOG_ERR_MSG("subinterface index not found."); + return SR_ERR_NOT_FOUND; } - sr_xpath_recover(&state); - *values = dctx.values; - *values_cnt = dctx.values_cnt; - - return SR_ERR_OK; -} + /* Check that interface is a sub interface */ + if (!is_subinterface((char*)reply.interface_name, interface_name, sub_id)) { + SRP_LOG_ERR("%s not a subinterface", interface_name); + return SR_ERR_OPERATION_FAILED; + } -// openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/state -int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_state_cb( - const char *xpath, sr_val_t **values, size_t *values_cnt, - __attribute__((unused)) uint64_t request_id, - __attribute__((unused)) const char *original_xpath, - __attribute__((unused)) void *private_ctx) -{ - sr_xpath_ctx_t state = {0}; - char *tmp = NULL; - char interface_name[XPATH_SIZE] = {0}; - char subinterface_index[XPATH_SIZE] = {0}; + rc = sr_new_values(vc, &vals); + if (SR_ERR_OK != rc) + return rc; - ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); + sr_val_build_xpath(&vals[val_idx], "%s/index", xpath_root); + vals[val_idx].type = SR_UINT32_T; + vals[val_idx++].data.uint32_val = sub_id; - tmp = xpath_find_first_key(xpath, "name", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("interface_name not found."); - return SR_ERR_INVAL_ARG; - } + sr_val_build_xpath(&vals[val_idx], "%s/description", xpath_root); + sr_val_set_str_data(&vals[val_idx++], SR_STRING_T, NOT_AVAL); - strncpy(interface_name, tmp, XPATH_SIZE); - sr_xpath_recover(&state); + sr_val_build_xpath(&vals[val_idx], "%s/enabled", xpath_root); + vals[val_idx].type = SR_BOOL_T; + vals[val_idx++].data.bool_val = reply.admin_up_down; - tmp = xpath_find_first_key(xpath, "index", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("subinterface_index not found."); - return SR_ERR_INVAL_ARG; - } + //TODO: Openconfig required this value + // sr_val_build_xpath(&vals[val_idx], "%s/name", xpath_root); + // sr_val_set_str_data(&vals[val_idx++], SR_STRING_T, YANG INPUT TYPE: string); - strncpy(subinterface_index, tmp, XPATH_SIZE); - sr_xpath_recover(&state); + // sr_val_build_xpath(&vals[val_idx], "%s/ifindex", interface_name, sub_id); + // vals[val_idx].type = SR_UINT32_T; + // vals[val_idx++].data.uint32_val = YANG INPUT TYPE: uint32; - sys_sw_interface_dump_ctx dctx = - { - .is_subif = true, - .subinterface_index = atoi(subinterface_index) - }; - sw_interface_details_query_set_name(&dctx.sw_interface_details_query, - interface_name); + sr_val_build_xpath(&vals[val_idx], "%s/admin-status", xpath_root); + sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, + reply.admin_up_down ? "UP" : "DOWN"); - snprintf(dctx.sysr_values_ctx.xpath_root, XPATH_SIZE, "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/state", - interface_name, subinterface_index); + sr_val_build_xpath(&vals[val_idx], "%s/oper-status", xpath_root); + sr_val_set_str_data(&vals[val_idx++], SR_ENUM_T, reply.admin_up_down ? "UP" : "DOWN"); - sysr_sw_interface_dump(&dctx); + //TODO: Openconfig required this value + // sr_val_build_xpath(&vals[val_idx], "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/state/last-change", interface_name, sub_id); + // sr_val_set_str_data(&vals[val_idx++], YANG INPUT TYPE: oc-types:timeticks64); - if (!dctx.sw_interface_details_query.interface_found) { - SRP_LOG_DBG_MSG("interface not found"); - return SR_ERR_NOT_FOUND; - } + sr_val_build_xpath(&vals[val_idx], "%s/logical", xpath_root); + vals[val_idx].type = SR_BOOL_T; + vals[val_idx++].data.bool_val = true; //for now, we assume all are logical sr_xpath_recover(&state); - *values = dctx.sysr_values_ctx.values; - *values_cnt = dctx.sysr_values_ctx.values_cnt; + + *values = vals; + *values_cnt = vc; return SR_ERR_OK; } // openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/oc-ip:ipv4/oc-ip:addresses/oc-ip:address[ip='%s']/oc-ip:config/ -int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_config_cb( +static int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_config_cb( sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) + void *private_ctx) { + UNUSED(private_ctx); sr_change_iter_t *it = NULL; sr_change_oper_t oper; - sr_val_t *old_val = NULL; - sr_val_t *new_val = NULL; + sr_xpath_ctx_t state = {0}; + sr_val_t *old = NULL; + sr_val_t *new = NULL; char *tmp = NULL; - char interface_name[XPATH_SIZE] = {0}; + char interface_name[VPP_INTFC_NAME_LEN] = {0}; char subinterface_index[XPATH_SIZE] = {0}; char address_ip[XPATH_SIZE] = {0}; char old_address_ip[XPATH_SIZE] = {0}; @@ -662,82 +466,69 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ // if we receive event SR_EV_APPLY - config has changed - log_recv_event(event, "subtree_change_cb received"); - SRP_LOG_DBG("[SRP_LOG_DBG] xpath: %s", xpath); - - if (event != SR_EV_APPLY) { + if (event == SR_EV_APPLY) return SR_ERR_OK; - } if (sr_get_changes_iter(ds, (char *)xpath, &it) != SR_ERR_OK) { - // in example he calls even on fale sr_free_change_iter(it); return SR_ERR_OK; } - while (sr_get_change_next(ds, it, &oper, &old_val, &new_val) == SR_ERR_OK) { - - log_recv_oper(oper, "subtree_change_cb received"); + foreach_change (ds, it, oper, old, new) { - SRP_LOG_DBG("xpath: %s", new_val->xpath); + SRP_LOG_DBG("xpath: %s", new->xpath); - sr_xpath_ctx_t state = {0}; - - tmp = xpath_find_first_key(new_val->xpath, "name", &state); - if (NULL == tmp) { - SRP_LOG_DBG_MSG("interface_name NOT found."); - continue; + tmp = sr_xpath_key_value(new->xpath, "interface", "name", &state); + if (!tmp) { + sr_set_error(ds, "XPATH interface name NOT found", new->xpath); + return SR_ERR_INVAL_ARG; } - - strncpy(interface_name, tmp, XPATH_SIZE); + strncpy(interface_name, tmp, VPP_INTFC_NAME_LEN); sr_xpath_recover(&state); - tmp = xpath_find_first_key(new_val->xpath, "index", &state); - if (NULL == tmp) { - SRP_LOG_DBG_MSG("subinterface_index NOT found."); - continue; + tmp = sr_xpath_key_value(new->xpath, "subinterface", "index", &state); + if (!tmp) { + sr_set_error(ds, "XPATH subinterface index NOT found", new->xpath); + return SR_ERR_INVAL_ARG; } - strncpy(subinterface_index, tmp, XPATH_SIZE); sr_xpath_recover(&state); switch (oper) { case SR_OP_CREATED: - if (sr_xpath_node_name_eq(new_val->xpath, "ip")) { + if (sr_xpath_node_name_eq(new->xpath, "ip")) { ip_set = true; - strncpy(address_ip, new_val->data.string_val, XPATH_SIZE); - } else if (sr_xpath_node_name_eq(new_val->xpath, + strncpy(address_ip, new->data.string_val, XPATH_SIZE); + } else if (sr_xpath_node_name_eq(new->xpath, "prefix-length")) { prefix_len_set = true; - prefix_len = new_val->data.uint8_val; + prefix_len = new->data.uint8_val; } - if (ip_set && prefix_len_set) { - //add ipv4 + if (ip_set && prefix_len_set) //add ipv4 rc = ipv46_config_add_remove(interface_name, address_ip, prefix_len, false , true); - } break; case SR_OP_MODIFIED: - if (sr_xpath_node_name_eq(old_val->xpath, "ip")) { + if (sr_xpath_node_name_eq(old->xpath, "ip")) { old_ip_set = true; - strncpy(old_address_ip, old_val->data.string_val, + strncpy(old_address_ip, old->data.string_val, XPATH_SIZE); - } else if (sr_xpath_node_name_eq(old_val->xpath, + } else if (sr_xpath_node_name_eq(old->xpath, " prefix-length")) { old_prefix_len_set = true; - old_prefix_len = old_val->data.uint8_val; + old_prefix_len = old->data.uint8_val; } - if (sr_xpath_node_name_eq(new_val->xpath, "ip")) { + if (sr_xpath_node_name_eq(new->xpath, "ip")) { ip_set = true; - strncpy(address_ip, new_val->data.string_val, XPATH_SIZE); - } else if (sr_xpath_node_name_eq(new_val->xpath, + strncpy(address_ip, new->data.string_val, XPATH_SIZE); + } else if (sr_xpath_node_name_eq(new->xpath, "prefix-length")) { prefix_len_set = true; - prefix_len = new_val->data.uint8_val; + prefix_len = new->data.uint8_val; } if (old_ip_set && old_prefix_len_set) { @@ -760,14 +551,14 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ break; case SR_OP_DELETED: - if (sr_xpath_node_name_eq(old_val->xpath, "ip")) { + if (sr_xpath_node_name_eq(old->xpath, "ip")) { old_ip_set = true; - strncpy(old_address_ip, old_val->data.string_val, + strncpy(old_address_ip, old->data.string_val, XPATH_SIZE); - } else if (sr_xpath_node_name_eq(old_val->xpath, + } else if (sr_xpath_node_name_eq(old->xpath, "prefix-length")) { old_prefix_len_set = true; - old_prefix_len = old_val->data.uint8_val; + old_prefix_len = old->data.uint8_val; } if (old_ip_set && old_prefix_len_set) { @@ -781,8 +572,8 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ if (0 != rc) { sr_xpath_recover(&state); - sr_free_val(old_val); - sr_free_val(new_val); + sr_free_val(old); + sr_free_val(new); sr_free_change_iter(it); @@ -791,8 +582,8 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ sr_xpath_recover(&state); - sr_free_val(old_val); - sr_free_val(new_val); + sr_free_val(old); + sr_free_val(new); } sr_free_change_iter(it); @@ -800,16 +591,6 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ } const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = { - { - .xpath = "openconfig-interfaces", - .method = MODULE, - .datastore = SR_DS_RUNNING, - .cb.mcb = openconfig_interface_mod_cb, - .private_ctx = NULL, - .priority = 0, - //.opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY - .opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY | SR_SUBSCR_CTX_REUSE - }, { .xpath = "/openconfig-interfaces:interfaces/interface/config", .method = XPATH, diff --git a/src/plugins/openconfig/openconfig_interfaces.h b/src/plugins/openconfig/openconfig_interfaces.h deleted file mode 100644 index 88d5fe0..0000000 --- a/src/plugins/openconfig/openconfig_interfaces.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __OPENCONFIG_INTERFACES_H__ -#define __OPENCONFIG_INTERFACES_H__ - -#include "../sc_model.h" - -#define OC_INTERFACES_SIZE 6 -extern const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE]; - -#endif /* __OPENCONFIG_INTERFACES_H__ */ diff --git a/src/plugins/openconfig/openconfig_local_routing.c b/src/plugins/openconfig/openconfig_local_routing.c index 5c63eaa..5d18b52 100644 --- a/src/plugins/openconfig/openconfig_local_routing.c +++ b/src/plugins/openconfig/openconfig_local_routing.c @@ -17,732 +17,494 @@ #include #include -#include "openconfig_local_routing.h" +#include +#include +#include +#include "../sc_model.h" #include "../sys_util.h" -#include "sc_vpp_comm.h" -#include "sc_vpp_interface.h" -#include "sc_vpp_ip.h" +#define HOP_INDEX_SIZE 10 //number of digit in max 32 bit integer -#define XPATH_SIZE 2000 - -int openconfig_local_routing_mod_cb( - __attribute__((unused)) sr_session_ctx_t* session, - __attribute__((unused)) const char* module_name, - __attribute__((unused)) sr_notif_event_t event, - __attribute__((unused)) void* private_ctx) +static inline int +_set_route (const char *prefix, const char *nhop, bool is_add, + const char *iface) { - SRP_LOG_DBG("Local routing module subscribe: %s", module_name); + int table = 0; //FIB table ID + int mask; + int rc; + + // Put prefix length in mask and prefix IP in prefix + mask = ip_prefix_split(prefix); + if (mask < 1) { + SRP_LOG_ERR("Prefix length can not be %d", mask); + return SR_ERR_INVAL_ARG; + } + + rc = ipv46_config_add_del_route(prefix, mask, nhop, is_add, table, iface); + if (rc != SCVPP_OK) { + SRP_LOG_ERR("Add/delete route failed for %s %s", prefix, iface); + return SR_ERR_INVAL_ARG; + } + + SRP_LOG_INF("Add/delete route Success for %s %s", prefix, iface); return SR_ERR_OK; } -static int set_route(sr_session_ctx_t *sess, const char *index, - const char *n_interface /*NULLABLE*/, - const char *n_next_hop /*NULLABLE*/, - const char *prefix, bool is_add) -{ - int rc = SR_ERR_OK; - sr_val_t *value = NULL; - char xpath[XPATH_SIZE] = {0}; - const char *interface = NULL; - const char *next_hop = NULL; +#define STR(string) #string - ARG_CHECK3(SR_ERR_INVAL_ARG, sess, index, prefix); +#define ROOT "/openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/%s" - if (NULL == n_interface) { - snprintf(xpath, XPATH_SIZE, - "/openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/interface-ref/config/interface", prefix, index); +static inline char * _get_ds_elem(sr_session_ctx_t *sess, const char *prefix, + const char *index, const char *sub) +{ + char xpath[XPATH_SIZE] = {0}; + sr_val_t *value = NULL; + int rc; - rc = sr_get_item(sess, xpath, &value); - if (SR_ERR_OK != rc) { - SRP_LOG_DBG_MSG("Interface not set"); - return 0; - } + snprintf(xpath, XPATH_SIZE, ROOT, prefix, index, sub); - interface = value->data.string_val; - } else { - interface = n_interface; + rc = sr_get_item(sess, xpath, &value); + if (SR_ERR_OK != rc) { + SRP_LOG_DBG("XPATH %s not set", xpath); + return NULL; } - if (NULL == n_next_hop) { - snprintf(xpath, XPATH_SIZE, - "/openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/config/next-hop", prefix, index); + return value->data.string_val; +} - rc = sr_get_item(sess, xpath, &value); - if (SR_ERR_OK != rc) { - SRP_LOG_DBG_MSG("Next-hop not set"); - return 0; - } +/* @brief add/del route to FIB table 0. + * If you add/delete an entry to FIB, prefix is mandatory and next hop can be: + * - interface only + * - next hop IP + * - both interface and next hop IP + */ +static int set_route(sr_session_ctx_t *sess, const char *index, + const char *interface /* NULLABLE*/, + const char *next_hop /* NULLABLE*/, + const char *prefix, bool is_add) +{ + const char *iface = NULL; + const char *nhop = NULL; - next_hop = value->data.string_val; - } else { - next_hop = n_next_hop; - } + ARG_CHECK3(SR_ERR_INVAL_ARG, sess, index, prefix); - int mask = ip_prefix_split(prefix); - if (mask < 1) { + if (!interface && !next_hop) return SR_ERR_INVAL_ARG; - } - rc = ipv46_config_add_del_route(prefix, mask, next_hop, is_add, 0, - interface); - if (!rc) { - return SR_ERR_INVAL_ARG; - } + if (!interface) //fetch interface in datastore, can return NULL + iface = _get_ds_elem(sess, prefix, index, "interface-ref/config/interface"); + else //use interface provided + iface = interface; + + if (!next_hop) //fetch next-hop in datastore , can return NULL + nhop = _get_ds_elem(sess, prefix, index, "config/next-hop"); + else //use next hop IP provided + nhop = next_hop; + + return _set_route(prefix, nhop, is_add, iface); +} + +/* @brief Callback used to add prefix entry for XPATH: + * /openconfig-local-routing:local-routes/static-routes/static/config + */ +static int +oc_prefix_config_cb(sr_session_ctx_t *ds, const char *xpath, + sr_notif_event_t event, void *private_ctx) +{ + UNUSED(ds); UNUSED(xpath); UNUSED(event); UNUSED(private_ctx); + + SRP_LOG_INF("In %s", __FUNCTION__); return SR_ERR_OK; } // XPATH: /openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/config/ -int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_config_cb( - sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) +static int oc_next_hop_config_cb(sr_session_ctx_t *ds, const char *xpath, + sr_notif_event_t event, void *private_ctx) { - sr_change_iter_t *it = NULL; + char prefix[VPP_IP4_PREFIX_STRING_LEN] = {0}; + char next_hop[VPP_IP4_ADDRESS_STRING_LEN] = {0}; //IP of next router + char index[HOP_INDEX_SIZE]; //next hop index + bool index_set = false, next_hop_set = false; + sr_change_iter_t *it; sr_change_oper_t oper; - sr_val_t *old_val = NULL; - sr_val_t *new_val = NULL; + sr_val_t *old, *new, *tmp; + sr_xpath_ctx_t state = {0}; int rc = SR_ERR_OK; - char *tmp = NULL; - char static_prefix[XPATH_SIZE] = {0}; - char next_hop_index[XPATH_SIZE] = {0}; - char next_hop[XPATH_SIZE] = {0}; - char old_next_hop_index[XPATH_SIZE] = {0}; - char old_next_hop[XPATH_SIZE] = {0}; - bool index_set = false, next_hop_set = false; - bool old_index_set = false, old_next_hop_set = false; + UNUSED(private_ctx); ARG_CHECK2(SR_ERR_INVAL_ARG, ds, xpath); - // if we receive event SR_EV_APPLY - config has changed + SRP_LOG_INF("In %s", __FUNCTION__); - log_recv_event(event, "subtree_change_cb received"); - SRP_LOG_DBG("[SRP_LOG_DBG] xpath: %s", xpath); - - if (event != SR_EV_APPLY) { + if (event == SR_EV_APPLY) //SR_EV_VERIFY already applied the changes return SR_ERR_OK; - } - if (sr_get_changes_iter(ds, (char *)xpath, &it) != SR_ERR_OK) { - // in example he calls even on fale + rc = sr_get_changes_iter(ds, (char *)xpath, &it); + if (rc != SR_ERR_OK) { sr_free_change_iter(it); - return SR_ERR_OK; + return rc; } - while (sr_get_change_next(ds, it, &oper, - &old_val, &new_val) == SR_ERR_OK) { - - log_recv_oper(oper, "subtree_change_cb received"); - - SRP_LOG_DBG("xpath: %s", new_val->xpath); - - sr_xpath_ctx_t state = {0}; - - tmp = xpath_find_first_key(new_val->xpath, "prefix", &state); - if (NULL == tmp) { - SRP_LOG_DBG_MSG("static_prefix NOT found."); - continue; - } + foreach_change(ds, it, oper, old, new) { - strncpy(static_prefix, tmp, XPATH_SIZE); - sr_xpath_recover(&state); + rc = get_xpath_key(prefix, new->xpath, "static", "prefix", + VPP_IP4_PREFIX_STRING_LEN, &state); + if (rc != 0) + goto error; switch (oper) { - case SR_OP_CREATED: - if (sr_xpath_node_name_eq(new_val->xpath, "index")) { - strncpy(next_hop_index, new_val->data.string_val, - XPATH_SIZE); - index_set = true; - } else if(sr_xpath_node_name_eq(new_val->xpath, "next-hop")) { - next_hop_set = true; - strncpy(next_hop, new_val->data.string_val, XPATH_SIZE); - } else if(sr_xpath_node_name_eq(new_val->xpath, "metric")) { - //TODO: LEAF: metric, type: uint32 - } else if(sr_xpath_node_name_eq(new_val->xpath, "recurse")) { - //TODO: LEAF: recurse, type: boolean - } - - if (index_set && next_hop_set) { - rc = set_route(ds, next_hop_index, NULL, next_hop, - static_prefix, true); - } - break; - case SR_OP_MODIFIED: - if (sr_xpath_node_name_eq(old_val->xpath, "index")) { - strncpy(old_next_hop_index, old_val->data.string_val, - XPATH_SIZE); - old_index_set = true; - } else if(sr_xpath_node_name_eq(old_val->xpath, "next-hop")) { - old_next_hop_set = true; - strncpy(old_next_hop, old_val->data.string_val, XPATH_SIZE); - } else if(sr_xpath_node_name_eq(old_val->xpath, "metric")) { - //TODO: LEAF: metric, type: uint32 - } else if(sr_xpath_node_name_eq(old_val->xpath, "recurse")) { - //TODO: LEAF: recurse, type: boolean - } - - if (sr_xpath_node_name_eq(new_val->xpath, "index")) { - strncpy(next_hop_index, new_val->data.string_val, - XPATH_SIZE); - index_set = true; - } else if(sr_xpath_node_name_eq(new_val->xpath, "next-hop")) { - next_hop_set = true; - strncpy(next_hop, new_val->data.string_val, XPATH_SIZE); - } else if(sr_xpath_node_name_eq(new_val->xpath, "metric")) { - //TODO: LEAF: metric, type: uint32 - } else if(sr_xpath_node_name_eq(new_val->xpath, "recurse")) { - //TODO: LEAF: recurse, type: boolean - } - - if (old_index_set && old_next_hop_set) { - rc = set_route(ds, old_next_hop_index, NULL, old_next_hop, - static_prefix, false); - } - - if (index_set && next_hop_set) { - rc = set_route(ds, next_hop_index, NULL, next_hop, - static_prefix, true); - } - break; - - case SR_OP_MOVED: + case SR_OP_CREATED: + tmp = new; break; - case SR_OP_DELETED: - if (sr_xpath_node_name_eq(old_val->xpath, "index")) { - strncpy(old_next_hop_index, old_val->data.string_val, - XPATH_SIZE); - old_index_set = true; - } else if(sr_xpath_node_name_eq(old_val->xpath, "next-hop")) { - old_next_hop_set = true; - strncpy(old_next_hop, old_val->data.string_val, XPATH_SIZE); - } else if(sr_xpath_node_name_eq(old_val->xpath, "metric")) { - //TODO: LEAF: metric, type: uint32 - } else if(sr_xpath_node_name_eq(old_val->xpath, "recurse")) { - //TODO: LEAF: recurse, type: boolean - } - - if (old_index_set && old_next_hop_set) { - rc = set_route(ds, old_next_hop_index, NULL, old_next_hop, - static_prefix, false); - } + tmp = old; + break; + default: + SRP_LOG_WRN_MSG("Operation not supported"); break; } - if (SR_ERR_OK != rc) { - sr_xpath_recover(&state); + if (sr_xpath_node_name_eq(tmp->xpath, "config")) { + SRP_LOG_DBG("xpath: %s", tmp->xpath); + } else if (sr_xpath_node_name_eq(tmp->xpath, "index")) { + strncpy(index, tmp->data.string_val, HOP_INDEX_SIZE); + index_set = true; + } else if(sr_xpath_node_name_eq(tmp->xpath, "next-hop")) { + strncpy(next_hop, tmp->data.string_val, VPP_IP4_ADDRESS_STRING_LEN); + next_hop_set = true; + } else if(sr_xpath_node_name_eq(tmp->xpath, "recurse")) { + //SYSREPO BUG: Just catch it, sysrepo thinks it is mandatory... + } else { //metric, recurse + SRP_LOG_ERR("Unsupported field %s", tmp->xpath); + return SR_ERR_UNSUPPORTED; + } - sr_free_val(old_val); - sr_free_val(new_val); + if (index_set && next_hop_set) { + if (oper == SR_OP_CREATED) { + rc = set_route(ds, index, NULL, next_hop, prefix, true); + } else if (oper == SR_OP_MODIFIED) { + rc = set_route(ds, index, NULL, next_hop, prefix, false); + rc |= set_route(ds, index, NULL, next_hop, prefix, true); + } else if (oper == SR_OP_DELETED) { + rc = set_route(ds, index, NULL, next_hop, prefix, false); + } - sr_free_change_iter(it); - return SR_ERR_OPERATION_FAILED; + if (rc != 0) { + SRP_LOG_ERR_MSG("setting route failed"); + goto error; + } + index_set = false; next_hop_set = false; } + sr_free_val(old); + sr_free_val(new); sr_xpath_recover(&state); - - sr_free_val(old_val); - sr_free_val(new_val); } sr_free_change_iter(it); - return SR_ERR_OK; + return rc; + +error: + sr_free_val(old); + sr_free_val(new); + sr_xpath_recover(&state); + sr_free_change_iter(it); + return rc; } // XPATH: /openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/interface-ref/config/ -int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_config_cb( - sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event, - __attribute__((unused)) void *private_ctx) +static int +oc_next_hop_interface_config_cb(sr_session_ctx_t *ds, const char *xpath, + sr_notif_event_t event, void *private_ctx) { + char prefix[VPP_IP4_PREFIX_STRING_LEN] = {0}; + char interface[VPP_INTFC_NAME_LEN] = {0}; + char index[HOP_INDEX_SIZE] = {0}; sr_change_iter_t *it = NULL; sr_change_oper_t oper; - sr_val_t *old_val = NULL; - sr_val_t *new_val = NULL; - char *tmp = NULL; - char static_prefix[XPATH_SIZE] = {0}; - char next_hop_index[XPATH_SIZE] = {0}; - char interface[XPATH_SIZE] = {0}; - char old_interface[XPATH_SIZE] = {0}; + sr_val_t *old, *new, *tmp; + sr_xpath_ctx_t state = {0}; + bool interface_set = false; int rc = SR_ERR_OK; + UNUSED(private_ctx); - // if we receive event SR_EV_APPLY - config has changed - - log_recv_event(event, "subtree_change_cb received"); - SRP_LOG_DBG("[SRP_LOG_DBG] xpath: %s", xpath); + SRP_LOG_INF("In %s", __FUNCTION__); - if (event != SR_EV_APPLY) { + if (event == SR_EV_APPLY) return SR_ERR_OK; - } - if (sr_get_changes_iter(ds, (char *)xpath, &it) != SR_ERR_OK) { - // in example he calls even on fale + rc = sr_get_changes_iter(ds, (char *)xpath, &it); + if (rc != SR_ERR_OK) { sr_free_change_iter(it); - return SR_ERR_OK; + return rc; } - while (sr_get_change_next(ds, it, &oper, - &old_val, &new_val) == SR_ERR_OK) { + foreach_change(ds, it, oper, old, new) { - log_recv_oper(oper, "subtree_change_cb received"); + SRP_LOG_DBG("xpath: %s", new->xpath); - SRP_LOG_DBG("xpath: %s", new_val->xpath); + rc = get_xpath_key(prefix, new->xpath, "static", "prefix", + VPP_IP4_PREFIX_STRING_LEN, &state); - sr_xpath_ctx_t state = {0}; - - tmp = xpath_find_first_key(new_val->xpath, "prefix", &state); - if (NULL == tmp) { - SRP_LOG_DBG_MSG("static_prefix NOT found."); - continue; - } - - strncpy(static_prefix, tmp, XPATH_SIZE); - sr_xpath_recover(&state); - - tmp = xpath_find_first_key(new_val->xpath, "index", &state); - if (NULL == tmp) { - SRP_LOG_DBG_MSG("next-hop_index NOT found."); - continue; - } - - strncpy(next_hop_index, tmp, XPATH_SIZE); - sr_xpath_recover(&state); + rc |= get_xpath_key(index, new->xpath, "next-hop", "index", + HOP_INDEX_SIZE, &state); + if (rc) + goto error; switch (oper) { - case SR_OP_CREATED: - if (sr_xpath_node_name_eq(new_val->xpath, "interface")) { - strncpy(interface, new_val->data.string_val, XPATH_SIZE); - rc = set_route(ds, next_hop_index, interface, NULL, - static_prefix, true); - } else if (sr_xpath_node_name_eq(new_val->xpath, - "subinterface")) { - } - break; - case SR_OP_MODIFIED: - if (sr_xpath_node_name_eq(old_val->xpath, "interface")) { - strncpy(old_interface, old_val->data.string_val, - XPATH_SIZE); - rc = set_route(ds, next_hop_index, old_interface, NULL, - static_prefix, false); - } else if (sr_xpath_node_name_eq(old_val->xpath, - "subinterface")) { - } - - if (sr_xpath_node_name_eq(new_val->xpath, "interface")) { - strncpy(interface, new_val->data.string_val, XPATH_SIZE); - rc = set_route(ds, next_hop_index, interface, NULL, - static_prefix, true); - } else if (sr_xpath_node_name_eq(new_val->xpath, - "subinterface")) { - } - break; - - case SR_OP_MOVED: + case SR_OP_CREATED: + tmp = new; break; - case SR_OP_DELETED: - if (sr_xpath_node_name_eq(old_val->xpath, "interface")) { - strncpy(old_interface, old_val->data.string_val, - XPATH_SIZE); - rc = set_route(ds, next_hop_index, old_interface, NULL, - static_prefix, false); - } else if (sr_xpath_node_name_eq(old_val->xpath, - "subinterface")) { - } + tmp = old; + break; + default: + SRP_LOG_WRN_MSG("Operation not supported"); break; } - if (SR_ERR_OK != rc) { - sr_xpath_recover(&state); + if (sr_xpath_node_name_eq(tmp->xpath, "config")) { + SRP_LOG_DBG("xpath: %s", tmp->xpath); + } else if (sr_xpath_node_name_eq(tmp->xpath, "interface")) { + strncpy(interface, tmp->data.string_val, VPP_INTFC_NAME_LEN); + interface_set = true; + } else { //metric, recurse + SRP_LOG_ERR("Unsupported field %s", tmp->xpath); + return SR_ERR_UNSUPPORTED; + } - sr_free_val(old_val); - sr_free_val(new_val); + if (oper == SR_OP_CREATED && interface_set) { + rc = set_route(ds, index, interface, NULL, prefix, true); + interface_set = false; + } else if (oper == SR_OP_MODIFIED && interface_set) { + rc = set_route(ds, index, interface, NULL, prefix, false); + rc |= set_route(ds, index, interface, NULL, prefix, true); + interface_set = false; + } else if (oper == SR_OP_DELETED && interface_set) { + rc = set_route(ds, index, interface, NULL, prefix, false); + interface_set = false; + } - sr_free_change_iter(it); - return SR_ERR_OPERATION_FAILED; + if (rc != 0) { + SRP_LOG_ERR_MSG("setting route failed"); + goto error; } + sr_free_val(old); + sr_free_val(new); sr_xpath_recover(&state); - - sr_free_val(old_val); - sr_free_val(new_val); } sr_free_change_iter(it); return SR_ERR_OK; -} - -typedef struct -{ - u8 length; - u8 address[4]; -} address_prefix_t; - -typedef struct { - char *next_hop_index; - address_prefix_t address_prefix; - const bool is_interface_ref; - sw_interface_details_query_t sw_interface_details_query; - sysr_values_ctx_t sysr_values_ctx; -} sysr_ip_fib_details_ctx_t; - -static -bool address_prefix_cmp(address_prefix_t* address_prefix, - vapi_payload_ip_fib_details* reply) -{ - ARG_CHECK2(false, address_prefix, reply); - - if (address_prefix->length == reply->address_length) - { - if (0 == memcmp(address_prefix->address, reply->address, sizeof(reply->address))) - return true; - } - - return false; -} - -static -bool address_prefix_init(address_prefix_t* address_prefix, char* str_prefix) -{ - ARG_CHECK2(false, address_prefix, str_prefix); - - address_prefix->length = ip_prefix_split(str_prefix); - if(address_prefix->length < 1) - { - SRP_LOG_ERR_MSG("not a valid prefix"); - return false; - } - return sc_aton(str_prefix, address_prefix->address, - sizeof(address_prefix->address)); +error: + sr_free_val(old); + sr_free_val(new); + sr_xpath_recover(&state); + sr_free_change_iter(it); + return rc; } // XPATH: /openconfig-local-routing:local-routes/static-routes/static/state -int openconfig_local_routing_local_routes_static_routes_static_state_vapi_cb( - vapi_payload_ip_fib_details *reply, - sysr_ip_fib_details_ctx_t *sysr_ip_fib_details_ctx) +static int oc_prefix_state_cb( + const char *xpath, sr_val_t **values, size_t *values_cnt, + uint64_t request_id, const char *original_xpath, void *private_ctx) { + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + char prefix[VPP_IP4_PREFIX_STRING_LEN] = {0}; + sr_xpath_ctx_t state = {0}; sr_val_t *vals = NULL; + fib_dump_t *reply = NULL; + int vc = 1; int rc = 0; - int vc = 0; - char address_prefix[INET_ADDRSTRLEN + 3] = {0}; - vc = 1; - ARG_CHECK2(SR_ERR_INVAL_ARG, reply, sysr_ip_fib_details_ctx); + ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); - rc = sr_new_values(vc, &vals); - if (SR_ERR_OK != rc) { - return rc; - } + SRP_LOG_INF("In %s", __FUNCTION__); - //Filling the structure - snprintf(address_prefix, sizeof(address_prefix), "%s/%u", - sc_ntoa(reply->address), reply->address_length); + rc = get_xpath_key(prefix, (char *)xpath, "static", "prefix", + VPP_IP4_PREFIX_STRING_LEN, &state); + if (rc != 0) + return SR_ERR_INVAL_ARG; - sr_val_build_xpath(&vals[0], "%s/prefix", - sysr_ip_fib_details_ctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[0], SR_STRING_T, address_prefix); + rc = ipv4_fib_dump_prefix(prefix, &reply); + if (rc == -SCVPP_NOT_FOUND) { + SRP_LOG_ERR("Prefix %s not found in VPP FIB", prefix); + return SR_ERR_NOT_FOUND; + } - sysr_ip_fib_details_ctx->sysr_values_ctx.values = vals; - sysr_ip_fib_details_ctx->sysr_values_ctx.values_cnt = vc; + /* Allocation for number of elements dumped by ipv4_fib_dump_all */ + rc = sr_new_values(vc, &vals); + if (SR_ERR_OK != rc) + return rc; - return SR_ERR_OK; -} + sr_val_build_xpath(&vals[0], "%s/prefix", xpath); + sr_val_set_str_data(&vals[0], SR_STRING_T, prefix); -vapi_error_e -ip_routing_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_ip_fib_details * reply) -{ - if (is_last) - { - assert (NULL == reply); - } - else - { - sysr_ip_fib_details_ctx_t *dctx = callback_ctx; - assert(dctx && reply); + sr_xpath_recover(&state); - if (address_prefix_cmp(&dctx->address_prefix, reply)) - { - openconfig_local_routing_local_routes_static_routes_static_state_vapi_cb(reply, - dctx); - } - } + free(reply); + *values = vals; + *values_cnt = vc; - return VAPI_OK; + return SR_ERR_OK; } -int openconfig_local_routing_local_routes_static_routes_static_state_cb( - const char *xpath, sr_val_t **values, size_t *values_cnt, - __attribute__((unused)) uint64_t request_id, - __attribute__((unused)) const char *original_xpath, - __attribute__((unused)) void *private_ctx) +// XPATH /openconfig-local-routing:local-routes/static-routes/static/next-hops/next-hop/state +static int +oc_next_hop_state_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, + uint64_t request_id, const char *original_xpath, + void *private_ctx) { + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + char prefix[VPP_IP4_PREFIX_STRING_LEN] = {0}; + char index[HOP_INDEX_SIZE]; + char next_hop[INET_ADDRSTRLEN] = {0}; + fib_dump_t *reply = NULL; sr_xpath_ctx_t state = {0}; - vapi_error_e rv = 0; - char *tmp = NULL; - char static_prefix[XPATH_SIZE] = {0}; - sysr_ip_fib_details_ctx_t dctx = {0}; + sr_val_t *vals = NULL; + int vc = 3; + int rc = 0; ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); - tmp = xpath_find_first_key(xpath, "prefix", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("static_prefix not found."); - return SR_ERR_INVAL_ARG; - } + SRP_LOG_INF("In %s", __FUNCTION__); - strncpy(static_prefix, tmp, XPATH_SIZE); - sr_xpath_recover(&state); + /* Get prefix and index key from XPATH */ + rc = get_xpath_key(prefix, (char *)xpath, "static", "prefix", + VPP_IP4_PREFIX_STRING_LEN, &state); - //VPP callback - snprintf(dctx.sysr_values_ctx.xpath_root, XPATH_SIZE, "/openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/state", static_prefix); + rc |= get_xpath_key(index, (char*)xpath, "next-hop", "index", + VPP_IP4_PREFIX_STRING_LEN, &state); - if (!address_prefix_init(&dctx.address_prefix, static_prefix)) - { + if (rc != 0) return SR_ERR_INVAL_ARG; - } - - vapi_msg_ip_fib_dump *mp = vapi_alloc_ip_fib_dump (g_vapi_ctx_instance); - - VAPI_CALL(vapi_ip_fib_dump(g_vapi_ctx_instance, mp, ip_routing_dump_cb, &dctx)); - if(VAPI_OK != rv) - { - SRP_LOG_ERR_MSG("VAPI call failed"); + rc = ipv4_fib_dump_prefix(prefix, &reply); + if (rc != SCVPP_OK) { + SRP_LOG_ERR("Fail to dump prefix %s", prefix); return SR_ERR_INVAL_ARG; } - sr_xpath_recover(&state); - *values = dctx.sysr_values_ctx.values; - *values_cnt = dctx.sysr_values_ctx.values_cnt; - - return SR_ERR_OK; -} - -// // XPATH: /openconfig-local-routing:local-routes/static-routes/l/next-hops/next-hop/state -int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_state_vapi_cb( - vapi_type_fib_path *reply, - sysr_ip_fib_details_ctx_t *sysr_ip_fib_details_ctx) -{ - sr_val_t *vals = NULL; - int rc = 0; - int vc = 0; - char next_hop[INET_ADDRSTRLEN] = {0}; - - ARG_CHECK2(SR_ERR_INVAL_ARG, reply, sysr_ip_fib_details_ctx); - - vc = 3; - /* convenient functions such as this can be found in sysrepo/values.h */ rc = sr_new_values(vc, &vals); - if (SR_ERR_OK != rc) { + if (SR_ERR_OK != rc) return rc; + + // check next hop index equals next hop id + if (strtoul(index, NULL, 0) != reply->path[0].next_hop_id) { + SRP_LOG_ERR("next hop index is %d for prefix %s", + reply->path[0].next_hop_id, prefix); + SRP_LOG_ERR("before %s, stroul is %d", index, strtoul(index, NULL, 0)); + return SR_ERR_INVAL_ARG; } - sr_val_build_xpath(&vals[0], "%s/index", - sysr_ip_fib_details_ctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[0], SR_STRING_T, - sysr_ip_fib_details_ctx->next_hop_index); + sr_val_build_xpath(&vals[0], "%s/index", xpath); + sr_val_set_str_data(&vals[0], SR_STRING_T, index); - strncpy(next_hop, sc_ntoa(reply->next_hop), sizeof(next_hop)); - sr_val_build_xpath(&vals[1], "%s/next-hop", sysr_ip_fib_details_ctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[1], SR_STRING_T, next_hop); + strncpy(next_hop, sc_ntoa(reply->path[0].next_hop), VPP_IP4_ADDRESS_LEN); + sr_val_build_xpath(&vals[1], "%s/next-hop", xpath); + sr_val_set_str_data(&vals[1], SR_STRING_T, (char *)reply->path[0].next_hop); - sr_val_build_xpath(&vals[2], "%s/metric", sysr_ip_fib_details_ctx->sysr_values_ctx.xpath_root); + sr_val_build_xpath(&vals[2], "%s/metric", xpath); vals[2].type = SR_UINT32_T; - vals[2].data.uint32_val = reply->weight; - - // sr_val_build_xpath(&vals[3], "%s/recurse", sysr_ip_fib_details_ctx->sysr_values_ctx.xpath_root); - // vals[3].type = SR_BOOL_T; - // vals[3].data.bool_val = YANG INPUT TYPE: boolean; + vals[2].data.uint32_val = reply->path[0].weight; - sysr_ip_fib_details_ctx->sysr_values_ctx.values = vals; - sysr_ip_fib_details_ctx->sysr_values_ctx.values_cnt = vc; + free(reply); + sr_xpath_recover(&state); + *values = vals; + *values_cnt = vc; return SR_ERR_OK; } -// // XPATH: /openconfig-local-routing:local-routes/static-routes/l/next-hops/next-hop/interface-ref/state -int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_state_vapi_cb( - sysr_ip_fib_details_ctx_t * dctx) +// XPATH /openconfig-local-routing:local-routes/static-routes/static/next-hops/next-hop/interface-ref/state +static int +oc_next_hop_interface_state_cb(const char *xpath, sr_val_t **values, + size_t *values_cnt, uint64_t request_id, + const char *original_xpath, void *private_ctx) { + UNUSED(request_id); UNUSED(original_xpath); UNUSED(private_ctx); + sr_xpath_ctx_t state = {0}; + char prefix[VPP_IP4_PREFIX_STRING_LEN] = {0}; + char interface[VPP_INTFC_NAME_LEN] = {0}; + char index[HOP_INDEX_SIZE]; //next hop index + fib_dump_t *reply = NULL; sr_val_t *vals = NULL; + int vc = 1; int rc = 0; - int vc = 0; - - ARG_CHECK(SR_ERR_INVAL_ARG, dctx); - - vc = 2; - /* convenient functions such as this can be found in sysrepo/values.h */ - rc = sr_new_values(vc, &vals); - if (SR_ERR_OK != rc) { - return rc; - } - sr_val_build_xpath(&vals[0], "%s/interface", - dctx->sysr_values_ctx.xpath_root); - sr_val_set_str_data(&vals[0], SR_STRING_T, - (const char*)dctx->sw_interface_details_query.sw_interface_details.interface_name); + //ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); - sr_val_build_xpath(&vals[1], "%s/subinterface", - dctx->sysr_values_ctx.xpath_root); - vals[1].type = SR_UINT32_T; - vals[1].data.uint32_val = 0; + SRP_LOG_INF("In %s", __FUNCTION__); - dctx->sysr_values_ctx.values = vals; - dctx->sysr_values_ctx.values_cnt = vc; + ///* Get prefix key from XPATH */ + rc = get_xpath_key(prefix, (char*) xpath, "static", "prefix", + VPP_IP4_PREFIX_STRING_LEN, &state); - return SR_ERR_OK; -} - -vapi_error_e -ip_routing_next_hop_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_ip_fib_details * reply) -{ - ARG_CHECK(VAPI_EINVAL, callback_ctx); - - sysr_ip_fib_details_ctx_t *dctx = callback_ctx; - - if (is_last) - { - assert (NULL == reply); - } - else - { - assert (NULL != reply); - - if (reply->count > 0 && address_prefix_cmp(&dctx->address_prefix, reply)) - { - if (dctx->is_interface_ref) - { - dctx->sw_interface_details_query.interface_found = true; - dctx->sw_interface_details_query.sw_interface_details.sw_if_index = reply->path[0].sw_if_index; - //sw_interface_dump will have to be called outside this VAPI - } - else - { - openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_state_vapi_cb(reply->path, dctx); - } - } - } - - return VAPI_OK; -} - -int next_hop_inner( - bool is_interface_ref, const char *xpath, sr_val_t **values, - size_t *values_cnt, __attribute__((unused)) uint64_t request_id, - __attribute__((unused)) void *private_ctx) -{ - sr_xpath_ctx_t state = {0}; - vapi_error_e rv; - char *tmp = NULL; - char static_prefix[XPATH_SIZE] = {0}; - char next_hop_index[XPATH_SIZE] = {0}; - sysr_ip_fib_details_ctx_t dctx = {.is_interface_ref = is_interface_ref}; - - ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt); + rc |= get_xpath_key(index, (char *)xpath, "next-hop", "index", + HOP_INDEX_SIZE, &state); - tmp = xpath_find_first_key(xpath, "prefix", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("static_prefix not found."); + if (rc != 0) return SR_ERR_INVAL_ARG; - } - strncpy(static_prefix, tmp, XPATH_SIZE); - sr_xpath_recover(&state); - tmp = xpath_find_first_key(xpath, "index", &state); - if (NULL == tmp) { - SRP_LOG_ERR_MSG("index not found."); + rc = ipv4_fib_dump_prefix(prefix, &reply); + if (rc != SCVPP_OK) { + SRP_LOG_ERR("Fail to dump prefix %s", prefix); return SR_ERR_INVAL_ARG; } - strncpy(next_hop_index, tmp, XPATH_SIZE); - sr_xpath_recover(&state); + //TODO: check nhop? - //VPP callback - dctx.next_hop_index = next_hop_index; - if (is_interface_ref) { - snprintf(dctx.sysr_values_ctx.xpath_root, XPATH_SIZE, - "/openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/interface-ref/state", - static_prefix, next_hop_index); - } else { - snprintf(dctx.sysr_values_ctx.xpath_root, XPATH_SIZE, - "/openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/state", - static_prefix, next_hop_index); - } + rc = sr_new_values(vc, &vals); + if (SR_ERR_OK != rc) + return rc; - if (!address_prefix_init(&dctx.address_prefix, static_prefix)) - { + // check next hop index equals next hop id + if (strtoul(index, NULL, 0) != reply->path[0].next_hop_id) { + SRP_LOG_ERR("next hop index is %d for prefix %s", + reply->path[0].next_hop_id, prefix); + SRP_LOG_ERR("before %s, stroul is %d", index, strtoul(index, NULL, 0)); return SR_ERR_INVAL_ARG; } - vapi_msg_ip_fib_dump *mp = vapi_alloc_ip_fib_dump (g_vapi_ctx_instance); - VAPI_CALL(vapi_ip_fib_dump(g_vapi_ctx_instance, mp, ip_routing_next_hop_dump_cb, &dctx)); - if (VAPI_OK != rv) - { - SRP_LOG_ERR_MSG("VAPI call failed"); + rc = get_interface_name(interface, reply->path[0].sw_if_index); + if (rc != SCVPP_OK) { + SRP_LOG_ERR("No interface name for id %d", reply->path[0].sw_if_index); return SR_ERR_INVAL_ARG; } - if (is_interface_ref) - { - if (dctx.sw_interface_details_query.interface_found) - { - if (!get_interface_name(&dctx.sw_interface_details_query)) - { - return SR_ERR_INVAL_ARG; - } - if (strlen((const char*) - dctx.sw_interface_details_query.sw_interface_details.interface_name)) { - openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_state_vapi_cb(&dctx); - } - } - } + sr_val_build_xpath(&vals[0], "%s/interface", xpath); + sr_val_set_str_data(&vals[0], SR_STRING_T, interface); + free(reply); sr_xpath_recover(&state); - *values = dctx.sysr_values_ctx.values; - *values_cnt = dctx.sysr_values_ctx.values_cnt; + *values = vals; + *values_cnt = vc; return SR_ERR_OK; } -int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_state_cb( - const char *xpath, sr_val_t **values, size_t *values_cnt, - uint64_t request_id, const char *original_xpath, void *private_ctx) -{ - return next_hop_inner(false, xpath, values, values_cnt, request_id, - private_ctx); -} - -int openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_state_cb( - const char *xpath, sr_val_t **values, size_t *values_cnt, - uint64_t request_id, const char *original_xpath, void *private_ctx) -{ - return next_hop_inner(true, xpath, values, values_cnt, request_id, - private_ctx); -} - const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE] = { { - .xpath = "openconfig-local-routing", - .method = MODULE, + .xpath = "/openconfig-local-routing:local-routes/static-routes/static/config", + .method = XPATH, .datastore = SR_DS_RUNNING, - .cb.mcb = openconfig_local_routing_mod_cb, + .cb.scb = oc_prefix_config_cb, .private_ctx = NULL, .priority = 0, - //.opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY - .opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY | SR_SUBSCR_CTX_REUSE + //.opts = SR_SUBSCR_DEFAULT + .opts = SR_SUBSCR_CTX_REUSE }, { .xpath = "/openconfig-local-routing:local-routes/static-routes/static/next-hops/next-hop/config", .method = XPATH, .datastore = SR_DS_RUNNING, - .cb.scb = openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_config_cb, + .cb.scb = oc_next_hop_config_cb, .private_ctx = NULL, .priority = 0, //.opts = SR_SUBSCR_DEFAULT @@ -752,7 +514,7 @@ const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE] = { .xpath = "/openconfig-local-routing:local-routes/static-routes/static/next-hops/next-hop/interface-ref/config", .method = XPATH, .datastore = SR_DS_RUNNING, - .cb.scb = openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_config_cb, + .cb.scb = oc_next_hop_interface_config_cb, .private_ctx = NULL, .priority = 0, //.opts = SR_SUBSCR_DEFAULT @@ -762,7 +524,7 @@ const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE] = { .xpath = "/openconfig-local-routing:local-routes/static-routes/static/state", .method = GETITEM, .datastore = SR_DS_RUNNING, - .cb.gcb = openconfig_local_routing_local_routes_static_routes_static_state_cb, + .cb.gcb = oc_prefix_state_cb, .private_ctx = NULL, .priority = 0, .opts = SR_SUBSCR_CTX_REUSE @@ -771,7 +533,7 @@ const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE] = { .xpath = "/openconfig-local-routing:local-routes/static-routes/static/next-hops/next-hop/state", .method = GETITEM, .datastore = SR_DS_RUNNING, - .cb.gcb = openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_state_cb, + .cb.gcb = oc_next_hop_state_cb, .private_ctx = NULL, .priority = 0, .opts = SR_SUBSCR_CTX_REUSE @@ -780,7 +542,7 @@ const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE] = { .xpath = "/openconfig-local-routing:local-routes/static-routes/static/next-hops/next-hop/interface-ref/state", .method = GETITEM, .datastore = SR_DS_RUNNING, - .cb.gcb = openconfig_local_routing_local_routes_static_routes_static_next_hops_next_hop_interface_ref_state_cb, + .cb.gcb = oc_next_hop_interface_state_cb, .private_ctx = NULL, .priority = 0, .opts = SR_SUBSCR_CTX_REUSE diff --git a/src/plugins/openconfig/openconfig_local_routing.h b/src/plugins/openconfig/openconfig_local_routing.h deleted file mode 100644 index 13d2982..0000000 --- a/src/plugins/openconfig/openconfig_local_routing.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __OPENCONFIG_LOCAL_ROUTING_H__ -#define __OPENCONFIG_LOCAL_ROUTING_H__ - -#include "../sc_model.h" - -#define OC_LROUTING_SIZE 6 -extern const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE]; - -#endif /* __OPENCONFIG_LOCAL_ROUTING_H__ */ diff --git a/src/plugins/sc_model.h b/src/plugins/sc_model.h index ad4055b..a9392f9 100644 --- a/src/plugins/sc_model.h +++ b/src/plugins/sc_model.h @@ -29,7 +29,7 @@ #include #include -#include "sc_vpp_comm.h" //for ARG_CHECK only +#include //for ARG_CHECK only typedef enum { MODULE, @@ -68,4 +68,18 @@ typedef struct { int model_register(plugin_main_t *plugin_main, const xpath_t *xpaths, size_t size); +/* Declare registration */ + +#define OC_INTERFACES_SIZE 5 +extern const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE]; + +#define OC_LROUTING_SIZE 6 +extern const xpath_t oc_local_routing_xpaths[OC_LROUTING_SIZE]; + +#define IETF_NAT_SIZE 2 +extern const xpath_t ietf_nat_xpaths[IETF_NAT_SIZE]; + +#define IETF_INTERFACES_SIZE 5 +extern const xpath_t ietf_interfaces_xpaths[IETF_INTERFACES_SIZE]; + #endif /* __SC_MODEL_H__ */ diff --git a/src/plugins/sc_plugins.c b/src/plugins/sc_plugins.c index 87ea2d7..4dc6751 100644 --- a/src/plugins/sc_plugins.c +++ b/src/plugins/sc_plugins.c @@ -16,11 +16,6 @@ #include "sc_plugins.h" #include "sc_model.h" -#include "ietf/ietf_interface.h" -#include "ietf/ietf_nat.h" -#include "openconfig/openconfig_interfaces.h" -#include "openconfig/openconfig_local_routing.h" - int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) { plugin_main_t plugin_main; diff --git a/src/plugins/sys_util.c b/src/plugins/sys_util.c deleted file mode 100644 index a3ee0c9..0000000 --- a/src/plugins/sys_util.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sys_util.h" -#include "sc_vpp_comm.h" - -#include -#include - -char* xpath_find_first_key(const char *xpath, char *key, sr_xpath_ctx_t *state) -{ - char *value = NULL; - - if (sr_xpath_next_node((char *)xpath, state) == NULL) { - return NULL; - } - - while (((value = sr_xpath_node_key_value(NULL, - key, state)) == NULL) && - (sr_xpath_next_node(NULL, state) != NULL)); - - return value; -} - -// we can call sr_get_item after change is called to see if the value has or has not -// changed (simpleton solution :D) -// sr_get_item(sess, "/ietf-interfaces:interfaces/interface[name='eth0']/enabled", &value); - -void log_recv_event(sr_notif_event_t event, const char *msg) { - const char *event_s; - switch (event) { - case SR_EV_VERIFY: event_s = "SR_EV_VERIFY"; break; - case SR_EV_APPLY: event_s = "SR_EV_APPLY"; break; - case SR_EV_ABORT: event_s = "SR_EV_ABORT"; break; - default: event_s = "SR_EV_UNKNOWN"; - } - SRP_LOG_DBG("%s: %s\n", msg, event_s); -} - -void log_recv_oper(sr_change_oper_t oper, const char *msg) { - const char *oper_s; - switch (oper) { - case SR_OP_CREATED: oper_s = "SR_OP_CREATED"; break; - case SR_OP_DELETED: oper_s = "SR_OP_DELETED"; break; - case SR_OP_MODIFIED: oper_s = "SR_OP_MODIFIED"; break; - case SR_OP_MOVED: oper_s = "SR_OP_MOVED"; break; - default: oper_s = "SR_OP_UNKNOWN"; break; - } - SRP_LOG_DBG("%s: %s\n", msg, oper_s); -} - -int ip_prefix_split(const char* ip_prefix) -{ - //find the slash - char* slash = strchr(ip_prefix, '/'); - if (NULL == slash) - return -1; - - //extract subnet mask length - char * eptr = NULL; - u8 mask = strtoul(slash + 1, &eptr, 10); - if (*eptr || mask <= 0) - return -1; - - //keep just the address part - *slash = '\0'; //replace '/' with 0 - - //return mask length - return mask; -} - -/** - * @brief Get IPv4 host address from IPv4 prefix. - * - * @param[out] dst Host IPv4 address. - * @param[in] src IPv4 Prefix. - * @param[in] length dst buffer length. - * @param[out] prefix Get Prefix length, optional value. Can be NULL. - * @return -1 when failure, 0 on success. - */ -int get_address_from_prefix(char *dst, const char *src, size_t length, - uint8_t *prefix_length) -{ - ARG_CHECK2(-1, src, dst); - - size_t size = 0; - char *p = strchr(src, '/'); - if (NULL == p) { - return -1; - } - - size = p - src; - - // + 1, need size for \0 - if ((size + 1) > length) { - return -1; - } - - strncpy(dst, src, size); - - if (NULL != prefix_length) { - *prefix_length = atoi(++p); - } - - return 0; -} - -/** - * @brief Get IPv4 broadcast IP address form IPv4 network address. - * - * @param[out] broadcat Broadcast Ipv4 address. - * @param[in] network Network IPv4 address. - * @param[in] prefix Prefix number. - * @return -1 when failure, 0 on success. - */ -int get_network_broadcast(sc_ipv4_addr *broadcast, const sc_ipv4_addr *network, - uint8_t prefix_length) -{ - uint8_t mask = ~0; - uint8_t tmp_p = prefix_length; - int i; - - ARG_CHECK2(-1, network, broadcast); - - if (32 < prefix_length) { - SRP_LOG_ERR_MSG("Prefix length to big."); - return -1; - } - - for (i = 0; i < 4 ; i++) { - broadcast->address[i] = network->address[i] | - (mask >> (tmp_p > 8 ? 8 : tmp_p)); - if (tmp_p >= 8) { - tmp_p -= 8; - } else { - tmp_p = 0; - } - } - - return 0; -} - -/** - * @brief Get last IPv4 address from the IP range. - * - * @param[out] last_ip_address Last Ipv4 address. - * @param[in] first_ip_address First IPv4 address. - * @param[in] prefix Prefix number. - * @return -1 when failure, 0 on success. - */ -int get_last_ip_address(sc_ipv4_addr* last_ip_address, - const sc_ipv4_addr* first_ip_address, - uint8_t prefix_length) -{ - return get_network_broadcast(last_ip_address, first_ip_address, - prefix_length); -} diff --git a/src/plugins/sys_util.h b/src/plugins/sys_util.h index d449712..692a012 100644 --- a/src/plugins/sys_util.h +++ b/src/plugins/sys_util.h @@ -19,20 +19,71 @@ #include #include +#include + +#include +#include + +#include + +#include + +/* BEGIN sysrepo utils */ + +#define foreach_change(ds, it, oper, old, new) \ + while( (event != SR_EV_ABORT) && \ + sr_get_change_next(ds, it, &oper, &old, &new) == SR_ERR_OK) #define XPATH_SIZE 2000 +#define NOT_AVAL "NOT AVAILABLE" + +static inline int +get_xpath_key(char *dst, char *xpath, char *node, char *key, int length, + sr_xpath_ctx_t *state) { + char *tmp; + + tmp = sr_xpath_key_value(xpath, node, key, state); + if (!tmp) { + SRP_LOG_ERR("%s %s not found.", node, key); + return SR_ERR_INVAL_ARG; + } + strncpy(dst, tmp, length); + sr_xpath_recover(state); + + return 0; +} + +/* END of sysrepo utils */ typedef struct { - char xpath_root[XPATH_SIZE]; - sr_val_t * values; - size_t values_cnt; -} sysr_values_ctx_t; + uint8_t address[4]; +} sc_ipv4_addr; -char* xpath_find_first_key(const char *xpath, char *key, sr_xpath_ctx_t *state); -void log_recv_event(sr_notif_event_t event, const char *msg); -void log_recv_oper(sr_change_oper_t oper, const char *msg); -int ip_prefix_split(const char* ip_prefix); +/** + * @brief Extract IP "AAA.BBB.CCC.DDD" from an IP prefix: "AAA.BBB.CCC.DDD/XX" + * @param prefix - IPv4 or IPv6 prefix: + * @return prefix length + */ +static inline int ip_prefix_split(const char* ip_prefix) +{ + //find the slash + char* slash = strchr(ip_prefix, '/'); + if (NULL == slash) + return -1; + + //extract subnet mask length + char * eptr = NULL; + uint8_t plen = strtoul(slash + 1, &eptr, 10); + if (*eptr || plen <= 0) + return -1; + + //keep just the address part + *slash = '\0'; //replace '/' with 0 + + //return prefix length + return plen; +} /** * @brief Get IPv4 host address from IPv4 prefix. @@ -43,13 +94,61 @@ int ip_prefix_split(const char* ip_prefix); * @param[out] prefix Get Prefix length, optional value. Can be NULL. * @return -1 when failure, 0 on success. */ -int get_address_from_prefix(char* dst, const char* src, size_t length, - uint8_t* prefix_length); +static inline int +prefix2address(char *dst, const char *src, uint8_t *prefix_length) +{ + if (!src || !dst) + return -1; -typedef struct + char *p = strchr(src, '/'); + if (!p) + return -1; // '/' not found + + if ((p - src + 1) > VPP_IP4_ADDRESS_STRING_LEN) //+ 1 needed for \0 + return -1; + + strncpy(dst, src, VPP_IP4_ADDRESS_STRING_LEN); + + if (!prefix_length) + *prefix_length = atoi(++p); + + return 0; +} + +/** + * @brief Helper function for converting netmask (ex: 255.255.255.0) + * to prefix length (ex: 24). + * @param netmask - string of netmask "AAA.BBB.CCC.DDD" + * @return prefix length + */ +static inline uint8_t netmask_to_prefix(const char *netmask) { - uint8_t address[4]; -} sc_ipv4_addr; + in_addr_t n = 0; + uint8_t i = 0; + + inet_pton(AF_INET, netmask, &n); + + while (n > 0) { + n = n >> 1; + i++; + } + + return i; +} + +/** + * @brief Convert prefix length to netmask + * @param prefix - prefix length (ex: 24) + * @return netmask - integer (ex: 111111111111111111111111100000000b ) + */ +static inline uint32_t prefix2mask(int prefix) +{ + if (prefix) { + return htonl(~((1 << (32 - prefix)) - 1)); + } else { + return htonl(0); + } +} /** * @brief Get IPv4 broadcast IP address form IPv4 network address. @@ -59,8 +158,32 @@ typedef struct * @param[in] prefix Prefix number. * @return -1 when failure, 0 on success. */ -int get_network_broadcast(sc_ipv4_addr *broadcast, const sc_ipv4_addr *network, - uint8_t prefix_length); +static inline int get_network_broadcast(sc_ipv4_addr *broadcast, const sc_ipv4_addr *network, + uint8_t prefix_length) +{ + uint8_t mask = ~0; + uint8_t tmp_p = prefix_length; + int i; + + ARG_CHECK2(-1, network, broadcast); + + if (32 < prefix_length) { + SRP_LOG_ERR_MSG("Prefix length to big."); + return -1; + } + + for (i = 0; i < 4 ; i++) { + broadcast->address[i] = network->address[i] | + (mask >> (tmp_p > 8 ? 8 : tmp_p)); + if (tmp_p >= 8) { + tmp_p -= 8; + } else { + tmp_p = 0; + } + } + + return 0; +} /** * @brief Get last IPv4 address from the IP range. @@ -70,8 +193,12 @@ int get_network_broadcast(sc_ipv4_addr *broadcast, const sc_ipv4_addr *network, * @param[in] prefix Prefix number. * @return -1 when failure, 0 on success. */ -int get_last_ip_address(sc_ipv4_addr *last_ip_address, - const sc_ipv4_addr *first_ip_address, - uint8_t prefix_length); +static inline int get_last_ip_address(sc_ipv4_addr* last_ip_address, + const sc_ipv4_addr* first_ip_address, + uint8_t prefix_length) +{ + return get_network_broadcast(last_ip_address, first_ip_address, + prefix_length); +} #endif /* __SYS_UTIL_H__ */ diff --git a/src/plugins/yang/ietf-interfaces.data.xml b/src/plugins/yang/ietf-interfaces.data.xml deleted file mode 100644 index 3aae96e..0000000 --- a/src/plugins/yang/ietf-interfaces.data.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - GigabitEthernet0/8/0 - Ethernet 8 - ethernetCsmacd - true - -
- 192.168.2.100 - 24 -
-
- -
- 2001:db8::10 - 32 -
-
-
-
- diff --git a/src/plugins/yang/ietf/iana-if-type@2017-01-19.yang b/src/plugins/yang/ietf/iana-if-type@2017-01-19.yang new file mode 100644 index 0000000..7bfee36 --- /dev/null +++ b/src/plugins/yang/ietf/iana-if-type@2017-01-19.yang @@ -0,0 +1,1619 @@ +module iana-if-type { + namespace "urn:ietf:params:xml:ns:yang:iana-if-type"; + prefix ianaift; + + import ietf-interfaces { + prefix if; + } + + organization "IANA"; + contact + " Internet Assigned Numbers Authority + + Postal: ICANN + 12025 Waterfront Drive, Suite 300 + Los Angeles, CA 90094-2536 + United States + + Tel: +1 310 301 5800 + "; + description + "This YANG module defines YANG identities for IANA-registered + interface types. + + This YANG module is maintained by IANA and reflects the + 'ifType definitions' registry. + + The latest revision of this YANG module can be obtained from + the IANA web site. + + Requests for new values should be made to IANA via + email (iana&iana.org). + + Copyright (c) 2014 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (http://trustee.ietf.org/license-info). + + The initial version of this YANG module is part of RFC 7224; + see the RFC itself for full legal notices."; + reference + "IANA 'ifType definitions' registry. + "; + + revision 2017-01-19 { + description + "Registered ifType 289."; + } + + revision 2016-11-23 { + description + "Registered ifTypes 283-288."; + } + + revision 2016-06-09 { + description + "Registered ifType 282."; + } + revision 2016-05-03 { + description + "Registered ifType 281."; + } + revision 2015-06-12 { + description + "Corrected formatting issue."; + } + revision 2014-09-24 { + description + "Registered ifType 280."; + } + revision 2014-09-19 { + description + "Registered ifType 279."; + } + revision 2014-07-03 { + description + "Registered ifTypes 277-278."; + } + revision 2014-05-19 { + description + "Updated the contact address."; + } + revision 2014-05-08 { + description + "Initial revision."; + reference + "RFC 7224: IANA Interface Type YANG Module"; + } + + identity iana-interface-type { + base if:interface-type; + description + "This identity is used as a base for all interface types + defined in the 'ifType definitions' registry."; + } + + identity other { + base iana-interface-type; + } + identity regular1822 { + base iana-interface-type; + } + identity hdh1822 { + base iana-interface-type; + } + identity ddnX25 { + base iana-interface-type; + } + identity rfc877x25 { + base iana-interface-type; + reference + "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer"; + } + identity ethernetCsmacd { + base iana-interface-type; + description + "For all Ethernet-like interfaces, regardless of speed, + as per RFC 3635."; + reference + "RFC 3635 - Definitions of Managed Objects for the + Ethernet-like Interface Types"; + } + identity iso88023Csmacd { + base iana-interface-type; + status deprecated; + description + "Deprecated via RFC 3635. + Use ethernetCsmacd(6) instead."; + reference + "RFC 3635 - Definitions of Managed Objects for the + Ethernet-like Interface Types"; + } + identity iso88024TokenBus { + base iana-interface-type; + } + identity iso88025TokenRing { + base iana-interface-type; + } + identity iso88026Man { + base iana-interface-type; + } + identity starLan { + base iana-interface-type; + status deprecated; + description + "Deprecated via RFC 3635. + Use ethernetCsmacd(6) instead."; + reference + "RFC 3635 - Definitions of Managed Objects for the + Ethernet-like Interface Types"; + } + identity proteon10Mbit { + base iana-interface-type; + } + identity proteon80Mbit { + base iana-interface-type; + } + identity hyperchannel { + base iana-interface-type; + } + identity fddi { + base iana-interface-type; + reference + "RFC 1512 - FDDI Management Information Base"; + } + identity lapb { + base iana-interface-type; + reference + "RFC 1381 - SNMP MIB Extension for X.25 LAPB"; + } + identity sdlc { + base iana-interface-type; + } + identity ds1 { + base iana-interface-type; + description + "DS1-MIB."; + reference + "RFC 4805 - Definitions of Managed Objects for the + DS1, J1, E1, DS2, and E2 Interface Types"; + } + identity e1 { + base iana-interface-type; + status obsolete; + description + "Obsolete; see DS1-MIB."; + reference + "RFC 4805 - Definitions of Managed Objects for the + DS1, J1, E1, DS2, and E2 Interface Types"; + } + identity basicISDN { + base iana-interface-type; + description + "No longer used. See also RFC 2127."; + } + identity primaryISDN { + base iana-interface-type; + description + "No longer used. See also RFC 2127."; + } + identity propPointToPointSerial { + base iana-interface-type; + description + "Proprietary serial."; + } + identity ppp { + base iana-interface-type; + } + identity softwareLoopback { + base iana-interface-type; + } + identity eon { + base iana-interface-type; + description + "CLNP over IP."; + } + identity ethernet3Mbit { + base iana-interface-type; + } + identity nsip { + base iana-interface-type; + description + "XNS over IP."; + } + identity slip { + base iana-interface-type; + description + "Generic SLIP."; + } + identity ultra { + base iana-interface-type; + description + "Ultra Technologies."; + } + identity ds3 { + base iana-interface-type; + description + "DS3-MIB."; + reference + "RFC 3896 - Definitions of Managed Objects for the + DS3/E3 Interface Type"; + } + identity sip { + base iana-interface-type; + description + "SMDS, coffee."; + reference + "RFC 1694 - Definitions of Managed Objects for SMDS + Interfaces using SMIv2"; + } + identity frameRelay { + base iana-interface-type; + description + "DTE only."; + reference + "RFC 2115 - Management Information Base for Frame Relay + DTEs Using SMIv2"; + } + identity rs232 { + base iana-interface-type; + reference + "RFC 1659 - Definitions of Managed Objects for RS-232-like + Hardware Devices using SMIv2"; + } + identity para { + base iana-interface-type; + description + "Parallel-port."; + reference + "RFC 1660 - Definitions of Managed Objects for + Parallel-printer-like Hardware Devices using + SMIv2"; + } + identity arcnet { + base iana-interface-type; + description + "ARCnet."; + } + identity arcnetPlus { + base iana-interface-type; + description + "ARCnet Plus."; + } + identity atm { + base iana-interface-type; + description + "ATM cells."; + } + identity miox25 { + base iana-interface-type; + reference + "RFC 1461 - SNMP MIB extension for Multiprotocol + Interconnect over X.25"; + } + identity sonet { + base iana-interface-type; + description + "SONET or SDH."; + } + identity x25ple { + base iana-interface-type; + reference + "RFC 2127 - ISDN Management Information Base using SMIv2"; + } + identity iso88022llc { + base iana-interface-type; + } + identity localTalk { + base iana-interface-type; + } + identity smdsDxi { + base iana-interface-type; + } + identity frameRelayService { + base iana-interface-type; + description + "FRNETSERV-MIB."; + reference + "RFC 2954 - Definitions of Managed Objects for Frame + Relay Service"; + } + identity v35 { + base iana-interface-type; + } + identity hssi { + base iana-interface-type; + } + identity hippi { + base iana-interface-type; + } + identity modem { + base iana-interface-type; + description + "Generic modem."; + } + identity aal5 { + base iana-interface-type; + description + "AAL5 over ATM."; + } + identity sonetPath { + base iana-interface-type; + } + identity sonetVT { + base iana-interface-type; + } + identity smdsIcip { + base iana-interface-type; + description + "SMDS InterCarrier Interface."; + } + identity propVirtual { + base iana-interface-type; + description + "Proprietary virtual/internal."; + reference + "RFC 2863 - The Interfaces Group MIB"; + } + identity propMultiplexor { + base iana-interface-type; + description + "Proprietary multiplexing."; + reference + "RFC 2863 - The Interfaces Group MIB"; + } + identity ieee80212 { + base iana-interface-type; + description + "100BaseVG."; + } + identity fibreChannel { + base iana-interface-type; + description + "Fibre Channel."; + } + identity hippiInterface { + base iana-interface-type; + description + "HIPPI interfaces."; + } + identity frameRelayInterconnect { + base iana-interface-type; + status obsolete; + description + "Obsolete; use either + frameRelay(32) or frameRelayService(44)."; + } + identity aflane8023 { + base iana-interface-type; + description + "ATM Emulated LAN for 802.3."; + } + identity aflane8025 { + base iana-interface-type; + description + "ATM Emulated LAN for 802.5."; + } + identity cctEmul { + base iana-interface-type; + description + "ATM Emulated circuit."; + } + identity fastEther { + base iana-interface-type; + status deprecated; + description + "Obsoleted via RFC 3635. + ethernetCsmacd(6) should be used instead."; + reference + "RFC 3635 - Definitions of Managed Objects for the + Ethernet-like Interface Types"; + } + identity isdn { + base iana-interface-type; + description + "ISDN and X.25."; + reference + "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN + in the Packet Mode"; + } + identity v11 { + base iana-interface-type; + description + "CCITT V.11/X.21."; + } + identity v36 { + base iana-interface-type; + description + "CCITT V.36."; + } + identity g703at64k { + base iana-interface-type; + description + "CCITT G703 at 64Kbps."; + } + identity g703at2mb { + base iana-interface-type; + status obsolete; + description + "Obsolete; see DS1-MIB."; + } + identity qllc { + base iana-interface-type; + description + "SNA QLLC."; + } + identity fastEtherFX { + base iana-interface-type; + status deprecated; + description + "Obsoleted via RFC 3635. + ethernetCsmacd(6) should be used instead."; + reference + "RFC 3635 - Definitions of Managed Objects for the + Ethernet-like Interface Types"; + } + identity channel { + base iana-interface-type; + description + "Channel."; + } + identity ieee80211 { + base iana-interface-type; + description + "Radio spread spectrum."; + } + identity ibm370parChan { + base iana-interface-type; + description + "IBM System 360/370 OEMI Channel."; + } + identity escon { + base iana-interface-type; + description + "IBM Enterprise Systems Connection."; + } + identity dlsw { + base iana-interface-type; + description + "Data Link Switching."; + } + identity isdns { + base iana-interface-type; + description + "ISDN S/T interface."; + } + identity isdnu { + base iana-interface-type; + description + "ISDN U interface."; + } + identity lapd { + base iana-interface-type; + description + "Link Access Protocol D."; + } + identity ipSwitch { + base iana-interface-type; + description + "IP Switching Objects."; + } + identity rsrb { + base iana-interface-type; + description + "Remote Source Route Bridging."; + } + identity atmLogical { + base iana-interface-type; + description + "ATM Logical Port."; + reference + "RFC 3606 - Definitions of Supplemental Managed Objects + for ATM Interface"; + } + identity ds0 { + base iana-interface-type; + description + "Digital Signal Level 0."; + reference + "RFC 2494 - Definitions of Managed Objects for the DS0 + and DS0 Bundle Interface Type"; + } + identity ds0Bundle { + base iana-interface-type; + description + "Group of ds0s on the same ds1."; + reference + "RFC 2494 - Definitions of Managed Objects for the DS0 + and DS0 Bundle Interface Type"; + } + identity bsc { + base iana-interface-type; + description + "Bisynchronous Protocol."; + } + identity async { + base iana-interface-type; + description + "Asynchronous Protocol."; + } + identity cnr { + base iana-interface-type; + description + "Combat Net Radio."; + } + identity iso88025Dtr { + base iana-interface-type; + description + "ISO 802.5r DTR."; + } + identity eplrs { + base iana-interface-type; + description + "Ext Pos Loc Report Sys."; + } + identity arap { + base iana-interface-type; + description + "Appletalk Remote Access Protocol."; + } + identity propCnls { + base iana-interface-type; + description + "Proprietary Connectionless Protocol."; + } + identity hostPad { + base iana-interface-type; + description + "CCITT-ITU X.29 PAD Protocol."; + } + identity termPad { + base iana-interface-type; + description + "CCITT-ITU X.3 PAD Facility."; + } + identity frameRelayMPI { + base iana-interface-type; + description + "Multiproto Interconnect over FR."; + } + identity x213 { + base iana-interface-type; + description + "CCITT-ITU X213."; + } + identity adsl { + base iana-interface-type; + description + "Asymmetric Digital Subscriber Loop."; + } + identity radsl { + base iana-interface-type; + description + "Rate-Adapt. Digital Subscriber Loop."; + } + identity sdsl { + base iana-interface-type; + description + "Symmetric Digital Subscriber Loop."; + } + identity vdsl { + base iana-interface-type; + description + "Very H-Speed Digital Subscrib. Loop."; + } + identity iso88025CRFPInt { + base iana-interface-type; + description + "ISO 802.5 CRFP."; + } + identity myrinet { + base iana-interface-type; + description + "Myricom Myrinet."; + } + identity voiceEM { + base iana-interface-type; + description + "Voice recEive and transMit."; + } + identity voiceFXO { + base iana-interface-type; + description + "Voice Foreign Exchange Office."; + } + identity voiceFXS { + base iana-interface-type; + description + "Voice Foreign Exchange Station."; + } + identity voiceEncap { + base iana-interface-type; + description + "Voice encapsulation."; + } + identity voiceOverIp { + base iana-interface-type; + description + "Voice over IP encapsulation."; + } + identity atmDxi { + base iana-interface-type; + description + "ATM DXI."; + } + identity atmFuni { + base iana-interface-type; + description + "ATM FUNI."; + } + identity atmIma { + base iana-interface-type; + description + "ATM IMA."; + } + identity pppMultilinkBundle { + base iana-interface-type; + description + "PPP Multilink Bundle."; + } + identity ipOverCdlc { + base iana-interface-type; + description + "IBM ipOverCdlc."; + } + identity ipOverClaw { + base iana-interface-type; + description + "IBM Common Link Access to Workstn."; + } + identity stackToStack { + base iana-interface-type; + description + "IBM stackToStack."; + } + identity virtualIpAddress { + base iana-interface-type; + description + "IBM VIPA."; + } + identity mpc { + base iana-interface-type; + description + "IBM multi-protocol channel support."; + } + identity ipOverAtm { + base iana-interface-type; + description + "IBM ipOverAtm."; + reference + "RFC 2320 - Definitions of Managed Objects for Classical IP + and ARP Over ATM Using SMIv2 (IPOA-MIB)"; + } + identity iso88025Fiber { + base iana-interface-type; + description + "ISO 802.5j Fiber Token Ring."; + } + identity tdlc { + base iana-interface-type; + description + "IBM twinaxial data link control."; + } + identity gigabitEthernet { + base iana-interface-type; + status deprecated; + description + "Obsoleted via RFC 3635. + ethernetCsmacd(6) should be used instead."; + reference + "RFC 3635 - Definitions of Managed Objects for the + Ethernet-like Interface Types"; + } + identity hdlc { + base iana-interface-type; + description + "HDLC."; + } + identity lapf { + base iana-interface-type; + description + "LAP F."; + } + identity v37 { + base iana-interface-type; + description + "V.37."; + } + identity x25mlp { + base iana-interface-type; + description + "Multi-Link Protocol."; + } + identity x25huntGroup { + base iana-interface-type; + description + "X25 Hunt Group."; + } + identity transpHdlc { + base iana-interface-type; + description + "Transp HDLC."; + } + identity interleave { + base iana-interface-type; + description + "Interleave channel."; + } + identity fast { + base iana-interface-type; + description + "Fast channel."; + } + identity ip { + base iana-interface-type; + description + "IP (for APPN HPR in IP networks)."; + } + identity docsCableMaclayer { + base iana-interface-type; + description + "CATV Mac Layer."; + } + identity docsCableDownstream { + base iana-interface-type; + description + "CATV Downstream interface."; + } + identity docsCableUpstream { + base iana-interface-type; + description + "CATV Upstream interface."; + } + identity a12MppSwitch { + base iana-interface-type; + description + "Avalon Parallel Processor."; + } + identity tunnel { + base iana-interface-type; + description + "Encapsulation interface."; + } + identity coffee { + base iana-interface-type; + description + "Coffee pot."; + reference + "RFC 2325 - Coffee MIB"; + } + identity ces { + base iana-interface-type; + description + "Circuit Emulation Service."; + } + identity atmSubInterface { + base iana-interface-type; + description + "ATM Sub Interface."; + } + identity l2vlan { + base iana-interface-type; + description + "Layer 2 Virtual LAN using 802.1Q."; + } + identity l3ipvlan { + base iana-interface-type; + description + "Layer 3 Virtual LAN using IP."; + } + identity l3ipxvlan { + base iana-interface-type; + description + "Layer 3 Virtual LAN using IPX."; + } + identity digitalPowerline { + base iana-interface-type; + description + "IP over Power Lines."; + } + identity mediaMailOverIp { + base iana-interface-type; + description + "Multimedia Mail over IP."; + } + identity dtm { + base iana-interface-type; + description + "Dynamic synchronous Transfer Mode."; + } + identity dcn { + base iana-interface-type; + description + "Data Communications Network."; + } + identity ipForward { + base iana-interface-type; + description + "IP Forwarding Interface."; + } + identity msdsl { + base iana-interface-type; + description + "Multi-rate Symmetric DSL."; + } + identity ieee1394 { + base iana-interface-type; + + description + "IEEE1394 High Performance Serial Bus."; + } + identity if-gsn { + base iana-interface-type; + description + "HIPPI-6400."; + } + identity dvbRccMacLayer { + base iana-interface-type; + description + "DVB-RCC MAC Layer."; + } + identity dvbRccDownstream { + base iana-interface-type; + description + "DVB-RCC Downstream Channel."; + } + identity dvbRccUpstream { + base iana-interface-type; + description + "DVB-RCC Upstream Channel."; + } + identity atmVirtual { + base iana-interface-type; + description + "ATM Virtual Interface."; + } + identity mplsTunnel { + base iana-interface-type; + description + "MPLS Tunnel Virtual Interface."; + } + identity srp { + base iana-interface-type; + description + "Spatial Reuse Protocol."; + } + identity voiceOverAtm { + base iana-interface-type; + description + "Voice over ATM."; + } + identity voiceOverFrameRelay { + base iana-interface-type; + description + "Voice Over Frame Relay."; + } + identity idsl { + base iana-interface-type; + description + "Digital Subscriber Loop over ISDN."; + } + identity compositeLink { + base iana-interface-type; + description + "Avici Composite Link Interface."; + } + identity ss7SigLink { + base iana-interface-type; + description + "SS7 Signaling Link."; + } + identity propWirelessP2P { + base iana-interface-type; + description + "Prop. P2P wireless interface."; + } + identity frForward { + base iana-interface-type; + description + "Frame Forward Interface."; + } + identity rfc1483 { + base iana-interface-type; + description + "Multiprotocol over ATM AAL5."; + reference + "RFC 1483 - Multiprotocol Encapsulation over ATM + Adaptation Layer 5"; + } + identity usb { + base iana-interface-type; + description + "USB Interface."; + } + identity ieee8023adLag { + base iana-interface-type; + description + "IEEE 802.3ad Link Aggregate."; + } + identity bgppolicyaccounting { + base iana-interface-type; + description + "BGP Policy Accounting."; + } + identity frf16MfrBundle { + base iana-interface-type; + description + "FRF.16 Multilink Frame Relay."; + } + identity h323Gatekeeper { + base iana-interface-type; + description + "H323 Gatekeeper."; + } + identity h323Proxy { + base iana-interface-type; + description + "H323 Voice and Video Proxy."; + } + identity mpls { + base iana-interface-type; + description + "MPLS."; + } + identity mfSigLink { + base iana-interface-type; + description + "Multi-frequency signaling link."; + } + identity hdsl2 { + base iana-interface-type; + description + "High Bit-Rate DSL - 2nd generation."; + } + identity shdsl { + base iana-interface-type; + description + "Multirate HDSL2."; + } + identity ds1FDL { + base iana-interface-type; + description + "Facility Data Link (4Kbps) on a DS1."; + } + identity pos { + base iana-interface-type; + description + "Packet over SONET/SDH Interface."; + } + identity dvbAsiIn { + base iana-interface-type; + description + "DVB-ASI Input."; + } + identity dvbAsiOut { + base iana-interface-type; + description + "DVB-ASI Output."; + } + identity plc { + base iana-interface-type; + description + "Power Line Communications."; + } + identity nfas { + base iana-interface-type; + description + "Non-Facility Associated Signaling."; + } + identity tr008 { + base iana-interface-type; + description + "TR008."; + } + identity gr303RDT { + base iana-interface-type; + description + "Remote Digital Terminal."; + } + identity gr303IDT { + base iana-interface-type; + description + "Integrated Digital Terminal."; + } + identity isup { + base iana-interface-type; + description + "ISUP."; + } + identity propDocsWirelessMaclayer { + base iana-interface-type; + description + "Cisco proprietary Maclayer."; + } + identity propDocsWirelessDownstream { + base iana-interface-type; + description + "Cisco proprietary Downstream."; + } + identity propDocsWirelessUpstream { + base iana-interface-type; + description + "Cisco proprietary Upstream."; + } + identity hiperlan2 { + base iana-interface-type; + description + "HIPERLAN Type 2 Radio Interface."; + } + identity propBWAp2Mp { + base iana-interface-type; + description + "PropBroadbandWirelessAccesspt2Multipt (use of this value + for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f + is deprecated, and ieee80216WMAN(237) should be used + instead)."; + } + identity sonetOverheadChannel { + base iana-interface-type; + description + "SONET Overhead Channel."; + } + identity digitalWrapperOverheadChannel { + base iana-interface-type; + description + "Digital Wrapper."; + } + identity aal2 { + base iana-interface-type; + description + "ATM adaptation layer 2."; + } + identity radioMAC { + base iana-interface-type; + description + "MAC layer over radio links."; + } + identity atmRadio { + base iana-interface-type; + description + "ATM over radio links."; + } + identity imt { + base iana-interface-type; + description + "Inter-Machine Trunks."; + } + identity mvl { + base iana-interface-type; + description + "Multiple Virtual Lines DSL."; + } + identity reachDSL { + base iana-interface-type; + description + "Long Reach DSL."; + } + identity frDlciEndPt { + base iana-interface-type; + description + "Frame Relay DLCI End Point."; + } + identity atmVciEndPt { + base iana-interface-type; + description + "ATM VCI End Point."; + } + identity opticalChannel { + base iana-interface-type; + description + "Optical Channel."; + } + identity opticalTransport { + base iana-interface-type; + description + "Optical Transport."; + } + identity propAtm { + base iana-interface-type; + description + "Proprietary ATM."; + } + identity voiceOverCable { + base iana-interface-type; + description + "Voice Over Cable Interface."; + } + identity infiniband { + base iana-interface-type; + description + "Infiniband."; + } + identity teLink { + base iana-interface-type; + description + "TE Link."; + } + identity q2931 { + base iana-interface-type; + description + "Q.2931."; + } + identity virtualTg { + base iana-interface-type; + description + "Virtual Trunk Group."; + } + identity sipTg { + base iana-interface-type; + description + "SIP Trunk Group."; + } + identity sipSig { + base iana-interface-type; + description + "SIP Signaling."; + } + identity docsCableUpstreamChannel { + base iana-interface-type; + description + "CATV Upstream Channel."; + } + identity econet { + base iana-interface-type; + description + "Acorn Econet."; + } + identity pon155 { + base iana-interface-type; + description + "FSAN 155Mb Symetrical PON interface."; + } + identity pon622 { + base iana-interface-type; + description + "FSAN 622Mb Symetrical PON interface."; + } + identity bridge { + base iana-interface-type; + description + "Transparent bridge interface."; + } + identity linegroup { + base iana-interface-type; + description + "Interface common to multiple lines."; + } + identity voiceEMFGD { + base iana-interface-type; + description + "Voice E&M Feature Group D."; + } + identity voiceFGDEANA { + base iana-interface-type; + description + "Voice FGD Exchange Access North American."; + } + identity voiceDID { + base iana-interface-type; + description + "Voice Direct Inward Dialing."; + } + identity mpegTransport { + base iana-interface-type; + description + "MPEG transport interface."; + } + identity sixToFour { + base iana-interface-type; + status deprecated; + description + "6to4 interface (DEPRECATED)."; + reference + "RFC 4087 - IP Tunnel MIB"; + } + identity gtp { + base iana-interface-type; + description + "GTP (GPRS Tunneling Protocol)."; + } + identity pdnEtherLoop1 { + base iana-interface-type; + description + "Paradyne EtherLoop 1."; + } + identity pdnEtherLoop2 { + base iana-interface-type; + description + "Paradyne EtherLoop 2."; + } + identity opticalChannelGroup { + base iana-interface-type; + description + "Optical Channel Group."; + } + identity homepna { + base iana-interface-type; + description + "HomePNA ITU-T G.989."; + } + identity gfp { + base iana-interface-type; + description + "Generic Framing Procedure (GFP)."; + } + identity ciscoISLvlan { + base iana-interface-type; + description + "Layer 2 Virtual LAN using Cisco ISL."; + } + identity actelisMetaLOOP { + base iana-interface-type; + description + "Acteleis proprietary MetaLOOP High Speed Link."; + } + identity fcipLink { + base iana-interface-type; + description + "FCIP Link."; + } + identity rpr { + base iana-interface-type; + description + "Resilient Packet Ring Interface Type."; + } + identity qam { + base iana-interface-type; + description + "RF Qam Interface."; + } + identity lmp { + base iana-interface-type; + description + "Link Management Protocol."; + reference + "RFC 4327 - Link Management Protocol (LMP) Management + Information Base (MIB)"; + } + identity cblVectaStar { + base iana-interface-type; + description + "Cambridge Broadband Networks Limited VectaStar."; + } + identity docsCableMCmtsDownstream { + base iana-interface-type; + description + "CATV Modular CMTS Downstream Interface."; + } + identity adsl2 { + base iana-interface-type; + status deprecated; + description + "Asymmetric Digital Subscriber Loop Version 2 + (DEPRECATED/OBSOLETED - please use adsl2plus(238) + instead)."; + reference + "RFC 4706 - Definitions of Managed Objects for Asymmetric + Digital Subscriber Line 2 (ADSL2)"; + } + identity macSecControlledIF { + base iana-interface-type; + description + "MACSecControlled."; + } + identity macSecUncontrolledIF { + base iana-interface-type; + description + "MACSecUncontrolled."; + } + identity aviciOpticalEther { + base iana-interface-type; + description + "Avici Optical Ethernet Aggregate."; + } + identity atmbond { + base iana-interface-type; + description + "atmbond."; + } + identity voiceFGDOS { + base iana-interface-type; + description + "Voice FGD Operator Services."; + } + identity mocaVersion1 { + base iana-interface-type; + description + "MultiMedia over Coax Alliance (MoCA) Interface + as documented in information provided privately to IANA."; + } + identity ieee80216WMAN { + base iana-interface-type; + description + "IEEE 802.16 WMAN interface."; + } + identity adsl2plus { + base iana-interface-type; + description + "Asymmetric Digital Subscriber Loop Version 2 - + Version 2 Plus and all variants."; + } + identity dvbRcsMacLayer { + base iana-interface-type; + description + "DVB-RCS MAC Layer."; + reference + "RFC 5728 - The SatLabs Group DVB-RCS MIB"; + } + identity dvbTdm { + base iana-interface-type; + description + "DVB Satellite TDM."; + reference + "RFC 5728 - The SatLabs Group DVB-RCS MIB"; + } + identity dvbRcsTdma { + base iana-interface-type; + description + "DVB-RCS TDMA."; + reference + "RFC 5728 - The SatLabs Group DVB-RCS MIB"; + } + identity x86Laps { + base iana-interface-type; + description + "LAPS based on ITU-T X.86/Y.1323."; + } + identity wwanPP { + base iana-interface-type; + description + "3GPP WWAN."; + } + identity wwanPP2 { + base iana-interface-type; + description + "3GPP2 WWAN."; + } + identity voiceEBS { + base iana-interface-type; + description + "Voice P-phone EBS physical interface."; + } + identity ifPwType { + base iana-interface-type; + description + "Pseudowire interface type."; + reference + "RFC 5601 - Pseudowire (PW) Management Information Base (MIB)"; + } + identity ilan { + base iana-interface-type; + description + "Internal LAN on a bridge per IEEE 802.1ap."; + } + identity pip { + base iana-interface-type; + description + "Provider Instance Port on a bridge per IEEE 802.1ah PBB."; + } + identity aluELP { + base iana-interface-type; + description + "Alcatel-Lucent Ethernet Link Protection."; + } + identity gpon { + base iana-interface-type; + description + "Gigabit-capable passive optical networks (G-PON) as per + ITU-T G.948."; + } + identity vdsl2 { + base iana-interface-type; + description + "Very high speed digital subscriber line Version 2 + (as per ITU-T Recommendation G.993.2)."; + reference + "RFC 5650 - Definitions of Managed Objects for Very High + Speed Digital Subscriber Line 2 (VDSL2)"; + } + identity capwapDot11Profile { + base iana-interface-type; + description + "WLAN Profile Interface."; + reference + "RFC 5834 - Control and Provisioning of Wireless Access + Points (CAPWAP) Protocol Binding MIB for + IEEE 802.11"; + } + identity capwapDot11Bss { + base iana-interface-type; + description + "WLAN BSS Interface."; + reference + "RFC 5834 - Control and Provisioning of Wireless Access + Points (CAPWAP) Protocol Binding MIB for + IEEE 802.11"; + } + identity capwapWtpVirtualRadio { + base iana-interface-type; + description + "WTP Virtual Radio Interface."; + reference + "RFC 5833 - Control and Provisioning of Wireless Access + Points (CAPWAP) Protocol Base MIB"; + } + identity bits { + base iana-interface-type; + description + "bitsport."; + } + identity docsCableUpstreamRfPort { + base iana-interface-type; + description + "DOCSIS CATV Upstream RF Port."; + } + identity cableDownstreamRfPort { + base iana-interface-type; + description + "CATV downstream RF Port."; + } + identity vmwareVirtualNic { + base iana-interface-type; + description + "VMware Virtual Network Interface."; + } + identity ieee802154 { + base iana-interface-type; + description + "IEEE 802.15.4 WPAN interface."; + reference + "IEEE 802.15.4-2006"; + } + identity otnOdu { + base iana-interface-type; + description + "OTN Optical Data Unit."; + } + identity otnOtu { + base iana-interface-type; + description + "OTN Optical channel Transport Unit."; + } + identity ifVfiType { + base iana-interface-type; + description + "VPLS Forwarding Instance Interface Type."; + } + identity g9981 { + base iana-interface-type; + description + "G.998.1 bonded interface."; + } + identity g9982 { + base iana-interface-type; + description + "G.998.2 bonded interface."; + } + identity g9983 { + base iana-interface-type; + description + "G.998.3 bonded interface."; + } + + identity aluEpon { + base iana-interface-type; + description + "Ethernet Passive Optical Networks (E-PON)."; + } + identity aluEponOnu { + base iana-interface-type; + description + "EPON Optical Network Unit."; + } + identity aluEponPhysicalUni { + base iana-interface-type; + description + "EPON physical User to Network interface."; + } + identity aluEponLogicalLink { + base iana-interface-type; + description + "The emulation of a point-to-point link over the EPON + layer."; + } + identity aluGponOnu { + base iana-interface-type; + description + "GPON Optical Network Unit."; + reference + "ITU-T G.984.2"; + } + identity aluGponPhysicalUni { + base iana-interface-type; + description + "GPON physical User to Network interface."; + reference + "ITU-T G.984.2"; + } + identity vmwareNicTeam { + base iana-interface-type; + description + "VMware NIC Team."; + } + identity docsOfdmDownstream { + base iana-interface-type; + description + "CATV Downstream OFDM interface."; + } + identity docsOfdmaUpstream { + base iana-interface-type; + description + "CATV Upstream OFDMA interface."; + } + identity gfast { + base iana-interface-type; + description + "G.fast port."; + reference + "ITU-T G.9701"; + } + identity sdci { + base iana-interface-type; + description + "SDCI (IO-Link)."; + reference + "IEC 61131-9 Edition 1.0 2013-09"; + } + identity xboxWireless { + base iana-interface-type; + description + "Xbox wireless."; + } + identity fastdsl { + base iana-interface-type; + description + "FastDSL."; + reference + "BBF TR-355"; + } + identity docsCableScte55d1FwdOob { + base iana-interface-type; + description + "Cable SCTE 55-1 OOB Forward Channel."; + } + identity docsCableScte55d1RetOob { + base iana-interface-type; + description + "Cable SCTE 55-1 OOB Return Channel."; + } + identity docsCableScte55d2DsOob { + base iana-interface-type; + description + "Cable SCTE 55-2 OOB Downstream Channel."; + } + identity docsCableScte55d2UsOob { + base iana-interface-type; + description + "Cable SCTE 55-2 OOB Upstream Channel."; + } + identity docsCableNdf { + base iana-interface-type; + description + "Cable Narrowband Digital Forward."; + } + identity docsCableNdr { + base iana-interface-type; + description + "Cable Narrowband Digital Return."; + } + identity ptm { + base iana-interface-type; + description + "Packet Transfer Mode."; + } +} diff --git a/src/plugins/yang/ietf/ietf-interfaces.yang b/src/plugins/yang/ietf/ietf-interfaces.yang deleted file mode 100644 index f66c205..0000000 --- a/src/plugins/yang/ietf/ietf-interfaces.yang +++ /dev/null @@ -1,1123 +0,0 @@ -module ietf-interfaces { - yang-version 1.1; - namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - prefix if; - - import ietf-yang-types { - prefix yang; - } - - organization - "IETF NETMOD (Network Modeling) Working Group"; - - contact - "WG Web: - WG List: - - Editor: Martin Bjorklund - "; - - description - "This module contains a collection of YANG definitions for - managing network interfaces. - - Copyright (c) 2018 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (https://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 8343; see - the RFC itself for full legal notices."; - - revision 2018-02-20 { - description - "Updated to support NMDA."; - reference - "RFC 8343: A YANG Data Model for Interface Management"; - } - - revision 2014-05-08 { - description - "Initial revision."; - reference - "RFC 7223: A YANG Data Model for Interface Management"; - } - - /* - * Typedefs - */ - - typedef interface-ref { - type leafref { - path "/if:interfaces/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - interfaces."; - } - - /* - * Identities - */ - - identity interface-type { - description - "Base identity from which specific interface types are - derived."; - } - - /* - * Features - */ - - feature arbitrary-names { - description - "This feature indicates that the device allows user-controlled - interfaces to be named arbitrarily."; - } - feature pre-provisioning { - description - "This feature indicates that the device supports - pre-provisioning of interface configuration, i.e., it is - possible to configure an interface whose physical interface - hardware is not present on the device."; - } - feature if-mib { - description - "This feature indicates that the device implements - the IF-MIB."; - reference - "RFC 2863: The Interfaces Group MIB"; - } - - /* - * Data nodes - */ - - container interfaces { - description - "Interface parameters."; - - list interface { - key "name"; - - description - "The list of interfaces on the device. - - The status of an interface is available in this list in the - operational state. If the configuration of a - system-controlled interface cannot be used by the system - (e.g., the interface hardware present does not match the - interface type), then the configuration is not applied to - the system-controlled interface shown in the operational - state. If the configuration of a user-controlled interface - cannot be used by the system, the configured interface is - not instantiated in the operational state. - - System-controlled interfaces created by the system are - always present in this list in the operational state, - whether or not they are configured."; - - leaf name { - type string; - description - "The name of the interface. - - A device MAY restrict the allowed values for this leaf, - possibly depending on the type of the interface. - For system-controlled interfaces, this leaf is the - device-specific name of the interface. - - If a client tries to create configuration for a - system-controlled interface that is not present in the - operational state, the server MAY reject the request if - the implementation does not support pre-provisioning of - interfaces or if the name refers to an interface that can - never exist in the system. A Network Configuration - Protocol (NETCONF) server MUST reply with an rpc-error - with the error-tag 'invalid-value' in this case. - - If the device supports pre-provisioning of interface - configuration, the 'pre-provisioning' feature is - advertised. - - If the device allows arbitrarily named user-controlled - interfaces, the 'arbitrary-names' feature is advertised. - - When a configured user-controlled interface is created by - the system, it is instantiated with the same name in the - operational state. - - A server implementation MAY map this leaf to the ifName - MIB object. Such an implementation needs to use some - mechanism to handle the differences in size and characters - allowed between this leaf and ifName. The definition of - such a mechanism is outside the scope of this document."; - reference - "RFC 2863: The Interfaces Group MIB - ifName"; - } - - leaf description { - type string; - description - "A textual description of the interface. - - A server implementation MAY map this leaf to the ifAlias - MIB object. Such an implementation needs to use some - mechanism to handle the differences in size and characters - allowed between this leaf and ifAlias. The definition of - such a mechanism is outside the scope of this document. - - Since ifAlias is defined to be stored in non-volatile - storage, the MIB implementation MUST map ifAlias to the - value of 'description' in the persistently stored - configuration."; - reference - "RFC 2863: The Interfaces Group MIB - ifAlias"; - } - - leaf type { - type identityref { - base interface-type; - } - mandatory true; - description - "The type of the interface. - - When an interface entry is created, a server MAY - initialize the type leaf with a valid value, e.g., if it - is possible to derive the type from the name of the - interface. - - If a client tries to set the type of an interface to a - value that can never be used by the system, e.g., if the - type is not supported or if the type does not match the - name of the interface, the server MUST reject the request. - A NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf enabled { - type boolean; - default "true"; - description - "This leaf contains the configured, desired state of the - interface. - - Systems that implement the IF-MIB use the value of this - leaf in the intended configuration to set - IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry - has been initialized, as described in RFC 2863. - - Changes in this leaf in the intended configuration are - reflected in ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf link-up-down-trap-enable { - if-feature if-mib; - type enumeration { - enum enabled { - value 1; - description - "The device will generate linkUp/linkDown SNMP - notifications for this interface."; - } - enum disabled { - value 2; - description - "The device will not generate linkUp/linkDown SNMP - notifications for this interface."; - } - } - description - "Controls whether linkUp/linkDown SNMP notifications - should be generated for this interface. - - If this node is not configured, the value 'enabled' is - operationally used by the server for interfaces that do - not operate on top of any other interface (i.e., there are - no 'lower-layer-if' entries), and 'disabled' otherwise."; - reference - "RFC 2863: The Interfaces Group MIB - - ifLinkUpDownTrapEnable"; - } - - leaf admin-status { - if-feature if-mib; - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "Not ready to pass packets and not in some test mode."; - } - enum testing { - value 3; - description - "In some test mode."; - } - } - config false; - mandatory true; - description - "The desired state of the interface. - - This leaf has the same read semantics as ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf oper-status { - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - - description - "The interface does not pass any packets."; - } - enum testing { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum unknown { - value 4; - description - "Status cannot be determined for some reason."; - } - enum dormant { - value 5; - description - "Waiting for some external event."; - } - enum not-present { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum lower-layer-down { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - config false; - mandatory true; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - } - - leaf last-change { - type yang:date-and-time; - config false; - description - "The time the interface entered its current operational - state. If the current state was entered prior to the - last re-initialization of the local network management - subsystem, then this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifLastChange"; - } - - leaf if-index { - if-feature if-mib; - type int32 { - range "1..2147483647"; - } - config false; - mandatory true; - description - "The ifIndex value for the ifEntry represented by this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifIndex"; - } - - leaf phys-address { - type yang:phys-address; - config false; - description - "The interface's address at its protocol sub-layer. For - example, for an 802.x interface, this object normally - contains a Media Access Control (MAC) address. The - interface's media-specific modules must define the bit - and byte ordering and the format of the value of this - object. For interfaces that do not have such an address - (e.g., a serial line), this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; - } - - leaf-list higher-layer-if { - type interface-ref; - config false; - description - "A list of references to interfaces layered on top of this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf-list lower-layer-if { - type interface-ref; - config false; - - description - "A list of references to interfaces layered underneath this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf speed { - type yang:gauge64; - units "bits/second"; - config false; - description - "An estimate of the interface's current bandwidth in bits - per second. For interfaces that do not vary in - bandwidth or for those where no accurate estimation can - be made, this node should contain the nominal bandwidth. - For interfaces that have no concept of bandwidth, this - node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - - ifSpeed, ifHighSpeed"; - } - - container statistics { - config false; - description - "A collection of interface-related statistics objects."; - - leaf discontinuity-time { - type yang:date-and-time; - mandatory true; - description - "The time on the most recent occasion at which any one or - more of this interface's counters suffered a - discontinuity. If no such discontinuities have occurred - since the last re-initialization of the local management - subsystem, then this node contains the time the local - management subsystem re-initialized itself."; - } - - leaf in-octets { - type yang:counter64; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - } - - leaf in-unicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were not addressed to a - multicast or broadcast address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - } - - leaf in-broadcast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - } - - leaf in-multicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a multicast - address at this sub-layer. For a MAC-layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - } - - leaf in-discards { - type yang:counter32; - description - "The number of inbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - } - - leaf in-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - } - - leaf in-unknown-protos { - type yang:counter32; - - description - "For packet-oriented interfaces, the number of packets - received via the interface that were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing, the number of - transmission units received via the interface that were - discarded because of an unknown or unsupported protocol. - For any interface that does not support protocol - multiplexing, this counter is not present. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - } - - leaf out-octets { - type yang:counter64; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - } - - leaf out-unicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted and that were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - } - - leaf out-broadcast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted and that were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - } - - leaf out-multicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted and that were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC-layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - } - - leaf out-discards { - type yang:counter32; - description - "The number of outbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - } - - leaf out-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - } - } - - } - } - - /* - * Legacy typedefs - */ - - typedef interface-state-ref { - type leafref { - path "/if:interfaces-state/if:interface/if:name"; - } - status deprecated; - description - "This type is used by data models that need to reference - the operationally present interfaces."; - } - - /* - * Legacy operational state data nodes - */ - - container interfaces-state { - config false; - status deprecated; - description - "Data nodes for the operational state of interfaces."; - - list interface { - key "name"; - status deprecated; - - description - "The list of interfaces on the device. - - System-controlled interfaces created by the system are - always present in this list, whether or not they are - configured."; - - leaf name { - type string; - status deprecated; - description - "The name of the interface. - - A server implementation MAY map this leaf to the ifName - MIB object. Such an implementation needs to use some - mechanism to handle the differences in size and characters - allowed between this leaf and ifName. The definition of - such a mechanism is outside the scope of this document."; - reference - "RFC 2863: The Interfaces Group MIB - ifName"; - } - - leaf type { - type identityref { - base interface-type; - } - mandatory true; - status deprecated; - description - "The type of the interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf admin-status { - if-feature if-mib; - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "Not ready to pass packets and not in some test mode."; - } - enum testing { - value 3; - description - "In some test mode."; - } - } - mandatory true; - status deprecated; - description - "The desired state of the interface. - - This leaf has the same read semantics as ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf oper-status { - type enumeration { - enum up { - value 1; - description - "Ready to pass packets."; - } - enum down { - value 2; - description - "The interface does not pass any packets."; - } - enum testing { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum unknown { - value 4; - description - "Status cannot be determined for some reason."; - } - enum dormant { - value 5; - description - "Waiting for some external event."; - } - enum not-present { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum lower-layer-down { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - mandatory true; - status deprecated; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - } - - leaf last-change { - type yang:date-and-time; - status deprecated; - description - "The time the interface entered its current operational - state. If the current state was entered prior to the - last re-initialization of the local network management - subsystem, then this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifLastChange"; - } - - leaf if-index { - if-feature if-mib; - type int32 { - range "1..2147483647"; - } - mandatory true; - status deprecated; - description - "The ifIndex value for the ifEntry represented by this - interface."; - - reference - "RFC 2863: The Interfaces Group MIB - ifIndex"; - } - - leaf phys-address { - type yang:phys-address; - status deprecated; - description - "The interface's address at its protocol sub-layer. For - example, for an 802.x interface, this object normally - contains a Media Access Control (MAC) address. The - interface's media-specific modules must define the bit - and byte ordering and the format of the value of this - object. For interfaces that do not have such an address - (e.g., a serial line), this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; - } - - leaf-list higher-layer-if { - type interface-state-ref; - status deprecated; - description - "A list of references to interfaces layered on top of this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf-list lower-layer-if { - type interface-state-ref; - status deprecated; - description - "A list of references to interfaces layered underneath this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - } - - leaf speed { - type yang:gauge64; - units "bits/second"; - status deprecated; - description - "An estimate of the interface's current bandwidth in bits - per second. For interfaces that do not vary in - bandwidth or for those where no accurate estimation can - - be made, this node should contain the nominal bandwidth. - For interfaces that have no concept of bandwidth, this - node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - - ifSpeed, ifHighSpeed"; - } - - container statistics { - status deprecated; - description - "A collection of interface-related statistics objects."; - - leaf discontinuity-time { - type yang:date-and-time; - mandatory true; - status deprecated; - description - "The time on the most recent occasion at which any one or - more of this interface's counters suffered a - discontinuity. If no such discontinuities have occurred - since the last re-initialization of the local management - subsystem, then this node contains the time the local - management subsystem re-initialized itself."; - } - - leaf in-octets { - type yang:counter64; - status deprecated; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - } - - leaf in-unicast-pkts { - type yang:counter64; - status deprecated; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were not addressed to a - multicast or broadcast address at this sub-layer. - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - } - - leaf in-broadcast-pkts { - type yang:counter64; - status deprecated; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - } - - leaf in-multicast-pkts { - type yang:counter64; - status deprecated; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a multicast - address at this sub-layer. For a MAC-layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - } - - leaf in-discards { - type yang:counter32; - status deprecated; - - description - "The number of inbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - } - - leaf in-errors { - type yang:counter32; - status deprecated; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - } - - leaf in-unknown-protos { - type yang:counter32; - status deprecated; - description - "For packet-oriented interfaces, the number of packets - received via the interface that were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing, the number of - transmission units received via the interface that were - discarded because of an unknown or unsupported protocol. - For any interface that does not support protocol - multiplexing, this counter is not present. - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - } - - leaf out-octets { - type yang:counter64; - status deprecated; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - } - - leaf out-unicast-pkts { - type yang:counter64; - status deprecated; - description - "The total number of packets that higher-level protocols - requested be transmitted and that were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - } - - leaf out-broadcast-pkts { - type yang:counter64; - status deprecated; - - description - "The total number of packets that higher-level protocols - requested be transmitted and that were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - } - - leaf out-multicast-pkts { - type yang:counter64; - status deprecated; - description - "The total number of packets that higher-level protocols - requested be transmitted and that were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC-layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - } - - leaf out-discards { - type yang:counter32; - status deprecated; - description - "The number of outbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - } - - leaf out-errors { - type yang:counter32; - status deprecated; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - } - } - } - } -} diff --git a/src/plugins/yang/ietf/ietf-interfaces@2014-05-08.yang b/src/plugins/yang/ietf/ietf-interfaces@2014-05-08.yang deleted file mode 100644 index a0eb30e..0000000 --- a/src/plugins/yang/ietf/ietf-interfaces@2014-05-08.yang +++ /dev/null @@ -1,707 +0,0 @@ -module ietf-interfaces { - - yang-version 1; - - namespace - "urn:ietf:params:xml:ns:yang:ietf-interfaces"; - - prefix if; - - import ietf-yang-types { - prefix yang; - } - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: Thomas Nadeau - - - WG Chair: Juergen Schoenwaelder - - - Editor: Martin Bjorklund - "; - - description - "This module contains a collection of YANG definitions for - managing network interfaces. - - Copyright (c) 2014 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 7223; see - the RFC itself for full legal notices."; - - revision "2014-05-08" { - description "Initial revision."; - reference - "RFC 7223: A YANG Data Model for Interface Management"; - - } - - - typedef interface-ref { - type leafref { - path "/if:interfaces/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - configured interfaces."; - } - - typedef interface-state-ref { - type leafref { - path "/if:interfaces-state/if:interface/if:name"; - } - description - "This type is used by data models that need to reference - the operationally present interfaces."; - } - - identity interface-type { - description - "Base identity from which specific interface types are - derived."; - } - - feature arbitrary-names { - description - "This feature indicates that the device allows user-controlled - interfaces to be named arbitrarily."; - } - - feature pre-provisioning { - description - "This feature indicates that the device supports - pre-provisioning of interface configuration, i.e., it is - possible to configure an interface whose physical interface - hardware is not present on the device."; - } - - feature if-mib { - description - "This feature indicates that the device implements - the IF-MIB."; - reference - "RFC 2863: The Interfaces Group MIB"; - - } - - container interfaces { - description - "Interface configuration parameters."; - list interface { - key "name"; - description - "The list of configured interfaces on the device. - - The operational state of an interface is available in the - /interfaces-state/interface list. If the configuration of a - system-controlled interface cannot be used by the system - (e.g., the interface hardware present does not match the - interface type), then the configuration is not applied to - the system-controlled interface shown in the - /interfaces-state/interface list. If the configuration - of a user-controlled interface cannot be used by the system, - the configured interface is not instantiated in the - /interfaces-state/interface list."; - leaf name { - type string; - description - "The name of the interface. - - A device MAY restrict the allowed values for this leaf, - possibly depending on the type of the interface. - For system-controlled interfaces, this leaf is the - device-specific name of the interface. The 'config false' - list /interfaces-state/interface contains the currently - existing interfaces on the device. - - If a client tries to create configuration for a - system-controlled interface that is not present in the - /interfaces-state/interface list, the server MAY reject - the request if the implementation does not support - pre-provisioning of interfaces or if the name refers to - an interface that can never exist in the system. A - NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case. - - If the device supports pre-provisioning of interface - configuration, the 'pre-provisioning' feature is - advertised. - - If the device allows arbitrarily named user-controlled - interfaces, the 'arbitrary-names' feature is advertised. - - When a configured user-controlled interface is created by - the system, it is instantiated with the same name in the - /interface-state/interface list."; - } - - leaf description { - type string; - description - "A textual description of the interface. - - A server implementation MAY map this leaf to the ifAlias - MIB object. Such an implementation needs to use some - mechanism to handle the differences in size and characters - allowed between this leaf and ifAlias. The definition of - such a mechanism is outside the scope of this document. - - Since ifAlias is defined to be stored in non-volatile - storage, the MIB implementation MUST map ifAlias to the - value of 'description' in the persistently stored - datastore. - - Specifically, if the device supports ':startup', when - ifAlias is read the device MUST return the value of - 'description' in the 'startup' datastore, and when it is - written, it MUST be written to the 'running' and 'startup' - datastores. Note that it is up to the implementation to - - decide whether to modify this single leaf in 'startup' or - perform an implicit copy-config from 'running' to - 'startup'. - - If the device does not support ':startup', ifAlias MUST - be mapped to the 'description' leaf in the 'running' - datastore."; - reference - "RFC 2863: The Interfaces Group MIB - ifAlias"; - - } - - leaf type { - type identityref { - base interface-type; - } - mandatory true; - description - "The type of the interface. - - When an interface entry is created, a server MAY - initialize the type leaf with a valid value, e.g., if it - is possible to derive the type from the name of the - interface. - - If a client tries to set the type of an interface to a - value that can never be used by the system, e.g., if the - type is not supported or if the type does not match the - name of the interface, the server MUST reject the request. - A NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - - } - - leaf enabled { - type boolean; - default "true"; - description - "This leaf contains the configured, desired state of the - interface. - - Systems that implement the IF-MIB use the value of this - leaf in the 'running' datastore to set - IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry - has been initialized, as described in RFC 2863. - - - - Changes in this leaf in the 'running' datastore are - reflected in ifAdminStatus, but if ifAdminStatus is - changed over SNMP, this leaf is not affected."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - - } - - leaf link-up-down-trap-enable { - if-feature if-mib; - type enumeration { - enum "enabled" { - value 1; - } - enum "disabled" { - value 2; - } - } - description - "Controls whether linkUp/linkDown SNMP notifications - should be generated for this interface. - - If this node is not configured, the value 'enabled' is - operationally used by the server for interfaces that do - not operate on top of any other interface (i.e., there are - no 'lower-layer-if' entries), and 'disabled' otherwise."; - reference - "RFC 2863: The Interfaces Group MIB - - ifLinkUpDownTrapEnable"; - - } - } // list interface - } // container interfaces - - container interfaces-state { - config false; - description - "Data nodes for the operational state of interfaces."; - list interface { - key "name"; - description - "The list of interfaces on the device. - - System-controlled interfaces created by the system are - always present in this list, whether they are configured or - not."; - leaf name { - type string; - description - "The name of the interface. - - A server implementation MAY map this leaf to the ifName - MIB object. Such an implementation needs to use some - mechanism to handle the differences in size and characters - allowed between this leaf and ifName. The definition of - such a mechanism is outside the scope of this document."; - reference - "RFC 2863: The Interfaces Group MIB - ifName"; - - } - - leaf type { - type identityref { - base interface-type; - } - mandatory true; - description - "The type of the interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - - } - - leaf admin-status { - if-feature if-mib; - type enumeration { - enum "up" { - value 1; - description - "Ready to pass packets."; - } - enum "down" { - value 2; - description - "Not ready to pass packets and not in some test mode."; - } - enum "testing" { - value 3; - description - "In some test mode."; - } - } - mandatory true; - description - "The desired state of the interface. - - This leaf has the same read semantics as ifAdminStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - - } - - leaf oper-status { - type enumeration { - enum "up" { - value 1; - description - "Ready to pass packets."; - } - enum "down" { - value 2; - description - "The interface does not pass any packets."; - } - enum "testing" { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum "unknown" { - value 4; - description - "Status cannot be determined for some reason."; - } - enum "dormant" { - value 5; - description - "Waiting for some external event."; - } - enum "not-present" { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum "lower-layer-down" { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - mandatory true; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - - } - - leaf last-change { - type yang:date-and-time; - description - "The time the interface entered its current operational - state. If the current state was entered prior to the - last re-initialization of the local network management - subsystem, then this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifLastChange"; - - } - - leaf if-index { - if-feature if-mib; - type int32 { - range "1..2147483647"; - } - mandatory true; - description - "The ifIndex value for the ifEntry represented by this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifIndex"; - - } - - leaf phys-address { - type yang:phys-address; - description - "The interface's address at its protocol sub-layer. For - example, for an 802.x interface, this object normally - contains a Media Access Control (MAC) address. The - interface's media-specific modules must define the bit - - - and byte ordering and the format of the value of this - object. For interfaces that do not have such an address - (e.g., a serial line), this node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; - - } - - leaf-list higher-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered on top of this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - - } - - leaf-list lower-layer-if { - type interface-state-ref; - description - "A list of references to interfaces layered underneath this - interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifStackTable"; - - } - - leaf speed { - type yang:gauge64; - units "bits/second"; - description - "An estimate of the interface's current bandwidth in bits - per second. For interfaces that do not vary in - bandwidth or for those where no accurate estimation can - be made, this node should contain the nominal bandwidth. - For interfaces that have no concept of bandwidth, this - node is not present."; - reference - "RFC 2863: The Interfaces Group MIB - - ifSpeed, ifHighSpeed"; - - } - - container statistics { - description - "A collection of interface-related statistics objects."; - leaf discontinuity-time { - type yang:date-and-time; - mandatory true; - description - "The time on the most recent occasion at which any one or - more of this interface's counters suffered a - discontinuity. If no such discontinuities have occurred - since the last re-initialization of the local management - subsystem, then this node contains the time the local - management subsystem re-initialized itself."; - } - - leaf in-octets { - type yang:counter64; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - - } - - leaf in-unicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were not addressed to a - multicast or broadcast address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - - } - - leaf in-broadcast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - - } - - leaf in-multicast-pkts { - type yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a multicast - address at this sub-layer. For a MAC-layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - - } - - leaf in-discards { - type yang:counter32; - description - "The number of inbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - - } - - leaf in-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - - } - - leaf in-unknown-protos { - type yang:counter32; - description - "For packet-oriented interfaces, the number of packets - received via the interface that were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing, the number of - transmission units received via the interface that were - discarded because of an unknown or unsupported protocol. - For any interface that does not support protocol - multiplexing, this counter is not present. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - - } - - leaf out-octets { - type yang:counter64; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - - } - - leaf out-unicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and that were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - - } - - leaf out-broadcast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and that were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - - } - - leaf out-multicast-pkts { - type yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and that were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC-layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - - } - - leaf out-discards { - type yang:counter32; - description - "The number of outbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - - } - - leaf out-errors { - type yang:counter32; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - - - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'discontinuity-time'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - - } - } // container statistics - } // list interface - } // container interfaces-state - } // module ietf-interfaces diff --git a/src/plugins/yang/ietf/ietf-interfaces@2018-02-20.yang b/src/plugins/yang/ietf/ietf-interfaces@2018-02-20.yang new file mode 100644 index 0000000..f66c205 --- /dev/null +++ b/src/plugins/yang/ietf/ietf-interfaces@2018-02-20.yang @@ -0,0 +1,1123 @@ +module ietf-interfaces { + yang-version 1.1; + namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces"; + prefix if; + + import ietf-yang-types { + prefix yang; + } + + organization + "IETF NETMOD (Network Modeling) Working Group"; + + contact + "WG Web: + WG List: + + Editor: Martin Bjorklund + "; + + description + "This module contains a collection of YANG definitions for + managing network interfaces. + + Copyright (c) 2018 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8343; see + the RFC itself for full legal notices."; + + revision 2018-02-20 { + description + "Updated to support NMDA."; + reference + "RFC 8343: A YANG Data Model for Interface Management"; + } + + revision 2014-05-08 { + description + "Initial revision."; + reference + "RFC 7223: A YANG Data Model for Interface Management"; + } + + /* + * Typedefs + */ + + typedef interface-ref { + type leafref { + path "/if:interfaces/if:interface/if:name"; + } + description + "This type is used by data models that need to reference + interfaces."; + } + + /* + * Identities + */ + + identity interface-type { + description + "Base identity from which specific interface types are + derived."; + } + + /* + * Features + */ + + feature arbitrary-names { + description + "This feature indicates that the device allows user-controlled + interfaces to be named arbitrarily."; + } + feature pre-provisioning { + description + "This feature indicates that the device supports + pre-provisioning of interface configuration, i.e., it is + possible to configure an interface whose physical interface + hardware is not present on the device."; + } + feature if-mib { + description + "This feature indicates that the device implements + the IF-MIB."; + reference + "RFC 2863: The Interfaces Group MIB"; + } + + /* + * Data nodes + */ + + container interfaces { + description + "Interface parameters."; + + list interface { + key "name"; + + description + "The list of interfaces on the device. + + The status of an interface is available in this list in the + operational state. If the configuration of a + system-controlled interface cannot be used by the system + (e.g., the interface hardware present does not match the + interface type), then the configuration is not applied to + the system-controlled interface shown in the operational + state. If the configuration of a user-controlled interface + cannot be used by the system, the configured interface is + not instantiated in the operational state. + + System-controlled interfaces created by the system are + always present in this list in the operational state, + whether or not they are configured."; + + leaf name { + type string; + description + "The name of the interface. + + A device MAY restrict the allowed values for this leaf, + possibly depending on the type of the interface. + For system-controlled interfaces, this leaf is the + device-specific name of the interface. + + If a client tries to create configuration for a + system-controlled interface that is not present in the + operational state, the server MAY reject the request if + the implementation does not support pre-provisioning of + interfaces or if the name refers to an interface that can + never exist in the system. A Network Configuration + Protocol (NETCONF) server MUST reply with an rpc-error + with the error-tag 'invalid-value' in this case. + + If the device supports pre-provisioning of interface + configuration, the 'pre-provisioning' feature is + advertised. + + If the device allows arbitrarily named user-controlled + interfaces, the 'arbitrary-names' feature is advertised. + + When a configured user-controlled interface is created by + the system, it is instantiated with the same name in the + operational state. + + A server implementation MAY map this leaf to the ifName + MIB object. Such an implementation needs to use some + mechanism to handle the differences in size and characters + allowed between this leaf and ifName. The definition of + such a mechanism is outside the scope of this document."; + reference + "RFC 2863: The Interfaces Group MIB - ifName"; + } + + leaf description { + type string; + description + "A textual description of the interface. + + A server implementation MAY map this leaf to the ifAlias + MIB object. Such an implementation needs to use some + mechanism to handle the differences in size and characters + allowed between this leaf and ifAlias. The definition of + such a mechanism is outside the scope of this document. + + Since ifAlias is defined to be stored in non-volatile + storage, the MIB implementation MUST map ifAlias to the + value of 'description' in the persistently stored + configuration."; + reference + "RFC 2863: The Interfaces Group MIB - ifAlias"; + } + + leaf type { + type identityref { + base interface-type; + } + mandatory true; + description + "The type of the interface. + + When an interface entry is created, a server MAY + initialize the type leaf with a valid value, e.g., if it + is possible to derive the type from the name of the + interface. + + If a client tries to set the type of an interface to a + value that can never be used by the system, e.g., if the + type is not supported or if the type does not match the + name of the interface, the server MUST reject the request. + A NETCONF server MUST reply with an rpc-error with the + error-tag 'invalid-value' in this case."; + reference + "RFC 2863: The Interfaces Group MIB - ifType"; + } + + leaf enabled { + type boolean; + default "true"; + description + "This leaf contains the configured, desired state of the + interface. + + Systems that implement the IF-MIB use the value of this + leaf in the intended configuration to set + IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry + has been initialized, as described in RFC 2863. + + Changes in this leaf in the intended configuration are + reflected in ifAdminStatus."; + reference + "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; + } + + leaf link-up-down-trap-enable { + if-feature if-mib; + type enumeration { + enum enabled { + value 1; + description + "The device will generate linkUp/linkDown SNMP + notifications for this interface."; + } + enum disabled { + value 2; + description + "The device will not generate linkUp/linkDown SNMP + notifications for this interface."; + } + } + description + "Controls whether linkUp/linkDown SNMP notifications + should be generated for this interface. + + If this node is not configured, the value 'enabled' is + operationally used by the server for interfaces that do + not operate on top of any other interface (i.e., there are + no 'lower-layer-if' entries), and 'disabled' otherwise."; + reference + "RFC 2863: The Interfaces Group MIB - + ifLinkUpDownTrapEnable"; + } + + leaf admin-status { + if-feature if-mib; + type enumeration { + enum up { + value 1; + description + "Ready to pass packets."; + } + enum down { + value 2; + description + "Not ready to pass packets and not in some test mode."; + } + enum testing { + value 3; + description + "In some test mode."; + } + } + config false; + mandatory true; + description + "The desired state of the interface. + + This leaf has the same read semantics as ifAdminStatus."; + reference + "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; + } + + leaf oper-status { + type enumeration { + enum up { + value 1; + description + "Ready to pass packets."; + } + enum down { + value 2; + + description + "The interface does not pass any packets."; + } + enum testing { + value 3; + description + "In some test mode. No operational packets can + be passed."; + } + enum unknown { + value 4; + description + "Status cannot be determined for some reason."; + } + enum dormant { + value 5; + description + "Waiting for some external event."; + } + enum not-present { + value 6; + description + "Some component (typically hardware) is missing."; + } + enum lower-layer-down { + value 7; + description + "Down due to state of lower-layer interface(s)."; + } + } + config false; + mandatory true; + description + "The current operational state of the interface. + + This leaf has the same semantics as ifOperStatus."; + reference + "RFC 2863: The Interfaces Group MIB - ifOperStatus"; + } + + leaf last-change { + type yang:date-and-time; + config false; + description + "The time the interface entered its current operational + state. If the current state was entered prior to the + last re-initialization of the local network management + subsystem, then this node is not present."; + reference + "RFC 2863: The Interfaces Group MIB - ifLastChange"; + } + + leaf if-index { + if-feature if-mib; + type int32 { + range "1..2147483647"; + } + config false; + mandatory true; + description + "The ifIndex value for the ifEntry represented by this + interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifIndex"; + } + + leaf phys-address { + type yang:phys-address; + config false; + description + "The interface's address at its protocol sub-layer. For + example, for an 802.x interface, this object normally + contains a Media Access Control (MAC) address. The + interface's media-specific modules must define the bit + and byte ordering and the format of the value of this + object. For interfaces that do not have such an address + (e.g., a serial line), this node is not present."; + reference + "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; + } + + leaf-list higher-layer-if { + type interface-ref; + config false; + description + "A list of references to interfaces layered on top of this + interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifStackTable"; + } + + leaf-list lower-layer-if { + type interface-ref; + config false; + + description + "A list of references to interfaces layered underneath this + interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifStackTable"; + } + + leaf speed { + type yang:gauge64; + units "bits/second"; + config false; + description + "An estimate of the interface's current bandwidth in bits + per second. For interfaces that do not vary in + bandwidth or for those where no accurate estimation can + be made, this node should contain the nominal bandwidth. + For interfaces that have no concept of bandwidth, this + node is not present."; + reference + "RFC 2863: The Interfaces Group MIB - + ifSpeed, ifHighSpeed"; + } + + container statistics { + config false; + description + "A collection of interface-related statistics objects."; + + leaf discontinuity-time { + type yang:date-and-time; + mandatory true; + description + "The time on the most recent occasion at which any one or + more of this interface's counters suffered a + discontinuity. If no such discontinuities have occurred + since the last re-initialization of the local management + subsystem, then this node contains the time the local + management subsystem re-initialized itself."; + } + + leaf in-octets { + type yang:counter64; + description + "The total number of octets received on the interface, + including framing characters. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; + } + + leaf in-unicast-pkts { + type yang:counter64; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were not addressed to a + multicast or broadcast address at this sub-layer. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; + } + + leaf in-broadcast-pkts { + type yang:counter64; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were addressed to a broadcast + address at this sub-layer. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCInBroadcastPkts"; + } + + leaf in-multicast-pkts { + type yang:counter64; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were addressed to a multicast + address at this sub-layer. For a MAC-layer protocol, + this includes both Group and Functional addresses. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCInMulticastPkts"; + } + + leaf in-discards { + type yang:counter32; + description + "The number of inbound packets that were chosen to be + discarded even though no errors had been detected to + prevent their being deliverable to a higher-layer + protocol. One possible reason for discarding such a + packet could be to free up buffer space. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInDiscards"; + } + + leaf in-errors { + type yang:counter32; + description + "For packet-oriented interfaces, the number of inbound + packets that contained errors preventing them from being + deliverable to a higher-layer protocol. For character- + oriented or fixed-length interfaces, the number of + inbound transmission units that contained errors + preventing them from being deliverable to a higher-layer + protocol. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInErrors"; + } + + leaf in-unknown-protos { + type yang:counter32; + + description + "For packet-oriented interfaces, the number of packets + received via the interface that were discarded because + of an unknown or unsupported protocol. For + character-oriented or fixed-length interfaces that + support protocol multiplexing, the number of + transmission units received via the interface that were + discarded because of an unknown or unsupported protocol. + For any interface that does not support protocol + multiplexing, this counter is not present. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; + } + + leaf out-octets { + type yang:counter64; + description + "The total number of octets transmitted out of the + interface, including framing characters. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; + } + + leaf out-unicast-pkts { + type yang:counter64; + description + "The total number of packets that higher-level protocols + requested be transmitted and that were not addressed + to a multicast or broadcast address at this sub-layer, + including those that were discarded or not sent. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; + } + + leaf out-broadcast-pkts { + type yang:counter64; + description + "The total number of packets that higher-level protocols + requested be transmitted and that were addressed to a + broadcast address at this sub-layer, including those + that were discarded or not sent. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCOutBroadcastPkts"; + } + + leaf out-multicast-pkts { + type yang:counter64; + description + "The total number of packets that higher-level protocols + requested be transmitted and that were addressed to a + multicast address at this sub-layer, including those + that were discarded or not sent. For a MAC-layer + protocol, this includes both Group and Functional + addresses. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCOutMulticastPkts"; + } + + leaf out-discards { + type yang:counter32; + description + "The number of outbound packets that were chosen to be + discarded even though no errors had been detected to + prevent their being transmitted. One possible reason + for discarding such a packet could be to free up buffer + space. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; + } + + leaf out-errors { + type yang:counter32; + description + "For packet-oriented interfaces, the number of outbound + packets that could not be transmitted because of errors. + For character-oriented or fixed-length interfaces, the + number of outbound transmission units that could not be + transmitted because of errors. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifOutErrors"; + } + } + + } + } + + /* + * Legacy typedefs + */ + + typedef interface-state-ref { + type leafref { + path "/if:interfaces-state/if:interface/if:name"; + } + status deprecated; + description + "This type is used by data models that need to reference + the operationally present interfaces."; + } + + /* + * Legacy operational state data nodes + */ + + container interfaces-state { + config false; + status deprecated; + description + "Data nodes for the operational state of interfaces."; + + list interface { + key "name"; + status deprecated; + + description + "The list of interfaces on the device. + + System-controlled interfaces created by the system are + always present in this list, whether or not they are + configured."; + + leaf name { + type string; + status deprecated; + description + "The name of the interface. + + A server implementation MAY map this leaf to the ifName + MIB object. Such an implementation needs to use some + mechanism to handle the differences in size and characters + allowed between this leaf and ifName. The definition of + such a mechanism is outside the scope of this document."; + reference + "RFC 2863: The Interfaces Group MIB - ifName"; + } + + leaf type { + type identityref { + base interface-type; + } + mandatory true; + status deprecated; + description + "The type of the interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifType"; + } + + leaf admin-status { + if-feature if-mib; + type enumeration { + enum up { + value 1; + description + "Ready to pass packets."; + } + enum down { + value 2; + description + "Not ready to pass packets and not in some test mode."; + } + enum testing { + value 3; + description + "In some test mode."; + } + } + mandatory true; + status deprecated; + description + "The desired state of the interface. + + This leaf has the same read semantics as ifAdminStatus."; + reference + "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; + } + + leaf oper-status { + type enumeration { + enum up { + value 1; + description + "Ready to pass packets."; + } + enum down { + value 2; + description + "The interface does not pass any packets."; + } + enum testing { + value 3; + description + "In some test mode. No operational packets can + be passed."; + } + enum unknown { + value 4; + description + "Status cannot be determined for some reason."; + } + enum dormant { + value 5; + description + "Waiting for some external event."; + } + enum not-present { + value 6; + description + "Some component (typically hardware) is missing."; + } + enum lower-layer-down { + value 7; + description + "Down due to state of lower-layer interface(s)."; + } + } + mandatory true; + status deprecated; + description + "The current operational state of the interface. + + This leaf has the same semantics as ifOperStatus."; + reference + "RFC 2863: The Interfaces Group MIB - ifOperStatus"; + } + + leaf last-change { + type yang:date-and-time; + status deprecated; + description + "The time the interface entered its current operational + state. If the current state was entered prior to the + last re-initialization of the local network management + subsystem, then this node is not present."; + reference + "RFC 2863: The Interfaces Group MIB - ifLastChange"; + } + + leaf if-index { + if-feature if-mib; + type int32 { + range "1..2147483647"; + } + mandatory true; + status deprecated; + description + "The ifIndex value for the ifEntry represented by this + interface."; + + reference + "RFC 2863: The Interfaces Group MIB - ifIndex"; + } + + leaf phys-address { + type yang:phys-address; + status deprecated; + description + "The interface's address at its protocol sub-layer. For + example, for an 802.x interface, this object normally + contains a Media Access Control (MAC) address. The + interface's media-specific modules must define the bit + and byte ordering and the format of the value of this + object. For interfaces that do not have such an address + (e.g., a serial line), this node is not present."; + reference + "RFC 2863: The Interfaces Group MIB - ifPhysAddress"; + } + + leaf-list higher-layer-if { + type interface-state-ref; + status deprecated; + description + "A list of references to interfaces layered on top of this + interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifStackTable"; + } + + leaf-list lower-layer-if { + type interface-state-ref; + status deprecated; + description + "A list of references to interfaces layered underneath this + interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifStackTable"; + } + + leaf speed { + type yang:gauge64; + units "bits/second"; + status deprecated; + description + "An estimate of the interface's current bandwidth in bits + per second. For interfaces that do not vary in + bandwidth or for those where no accurate estimation can + + be made, this node should contain the nominal bandwidth. + For interfaces that have no concept of bandwidth, this + node is not present."; + reference + "RFC 2863: The Interfaces Group MIB - + ifSpeed, ifHighSpeed"; + } + + container statistics { + status deprecated; + description + "A collection of interface-related statistics objects."; + + leaf discontinuity-time { + type yang:date-and-time; + mandatory true; + status deprecated; + description + "The time on the most recent occasion at which any one or + more of this interface's counters suffered a + discontinuity. If no such discontinuities have occurred + since the last re-initialization of the local management + subsystem, then this node contains the time the local + management subsystem re-initialized itself."; + } + + leaf in-octets { + type yang:counter64; + status deprecated; + description + "The total number of octets received on the interface, + including framing characters. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; + } + + leaf in-unicast-pkts { + type yang:counter64; + status deprecated; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were not addressed to a + multicast or broadcast address at this sub-layer. + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; + } + + leaf in-broadcast-pkts { + type yang:counter64; + status deprecated; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were addressed to a broadcast + address at this sub-layer. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCInBroadcastPkts"; + } + + leaf in-multicast-pkts { + type yang:counter64; + status deprecated; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were addressed to a multicast + address at this sub-layer. For a MAC-layer protocol, + this includes both Group and Functional addresses. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCInMulticastPkts"; + } + + leaf in-discards { + type yang:counter32; + status deprecated; + + description + "The number of inbound packets that were chosen to be + discarded even though no errors had been detected to + prevent their being deliverable to a higher-layer + protocol. One possible reason for discarding such a + packet could be to free up buffer space. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInDiscards"; + } + + leaf in-errors { + type yang:counter32; + status deprecated; + description + "For packet-oriented interfaces, the number of inbound + packets that contained errors preventing them from being + deliverable to a higher-layer protocol. For character- + oriented or fixed-length interfaces, the number of + inbound transmission units that contained errors + preventing them from being deliverable to a higher-layer + protocol. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInErrors"; + } + + leaf in-unknown-protos { + type yang:counter32; + status deprecated; + description + "For packet-oriented interfaces, the number of packets + received via the interface that were discarded because + of an unknown or unsupported protocol. For + character-oriented or fixed-length interfaces that + support protocol multiplexing, the number of + transmission units received via the interface that were + discarded because of an unknown or unsupported protocol. + For any interface that does not support protocol + multiplexing, this counter is not present. + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; + } + + leaf out-octets { + type yang:counter64; + status deprecated; + description + "The total number of octets transmitted out of the + interface, including framing characters. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; + } + + leaf out-unicast-pkts { + type yang:counter64; + status deprecated; + description + "The total number of packets that higher-level protocols + requested be transmitted and that were not addressed + to a multicast or broadcast address at this sub-layer, + including those that were discarded or not sent. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; + } + + leaf out-broadcast-pkts { + type yang:counter64; + status deprecated; + + description + "The total number of packets that higher-level protocols + requested be transmitted and that were addressed to a + broadcast address at this sub-layer, including those + that were discarded or not sent. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCOutBroadcastPkts"; + } + + leaf out-multicast-pkts { + type yang:counter64; + status deprecated; + description + "The total number of packets that higher-level protocols + requested be transmitted and that were addressed to a + multicast address at this sub-layer, including those + that were discarded or not sent. For a MAC-layer + protocol, this includes both Group and Functional + addresses. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCOutMulticastPkts"; + } + + leaf out-discards { + type yang:counter32; + status deprecated; + description + "The number of outbound packets that were chosen to be + discarded even though no errors had been detected to + prevent their being transmitted. One possible reason + for discarding such a packet could be to free up buffer + space. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; + } + + leaf out-errors { + type yang:counter32; + status deprecated; + description + "For packet-oriented interfaces, the number of outbound + packets that could not be transmitted because of errors. + For character-oriented or fixed-length interfaces, the + number of outbound transmission units that could not be + transmitted because of errors. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system and at + other times as indicated by the value of + 'discontinuity-time'."; + reference + "RFC 2863: The Interfaces Group MIB - ifOutErrors"; + } + } + } + } +} diff --git a/src/plugins/yang/openconfig/openconfig-extensions.yang b/src/plugins/yang/openconfig/openconfig-extensions.yang deleted file mode 100644 index f39ecf6..0000000 --- a/src/plugins/yang/openconfig/openconfig-extensions.yang +++ /dev/null @@ -1,91 +0,0 @@ -module openconfig-extensions { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/openconfig-ext"; - - prefix "oc-ext"; - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - www.openconfig.net"; - - description - "This module provides extensions to the YANG language to allow - OpenConfig specific functionality and meta-data to be defined."; - - revision "2017-04-11" { - description - "rename password type to 'hashed' and clarify description"; - reference "0.3.0"; - } - - revision "2017-01-29" { - description - "Added extension for annotating encrypted values."; - reference "0.2.0"; - } - - revision "2015-10-09" { - description - "Initial OpenConfig public release"; - reference "0.1.0"; - } - - - // extension statements - extension openconfig-version { - argument "semver" { - yin-element false; - } - description - "The OpenConfig version number for the module. This is - expressed as a semantic version number of the form: - x.y.z - where: - * x corresponds to the major version, - * y corresponds to a minor version, - * z corresponds to a patch version. - This version corresponds to the model file within which it is - defined, and does not cover the whole set of OpenConfig models. - Where several modules are used to build up a single block of - functionality, the same module version is specified across each - file that makes up the module. - - A major version number of 0 indicates that this model is still - in development (whether within OpenConfig or with industry - partners), and is potentially subject to change. - - Following a release of major version 1, all modules will - increment major revision number where backwards incompatible - changes to the model are made. - - The minor version is changed when features are added to the - model that do not impact current clients use of the model. - - The patch-level version is incremented when non-feature changes - (such as bugfixes or clarifications to human-readable - descriptions that do not impact model functionality) are made - that maintain backwards compatibility. - - The version number is stored in the module meta-data."; - } - - extension openconfig-hashed-value { - description - "This extension provides an annotation on schema nodes to - indicate that the corresponding value should be stored and - reported in hashed form. - - Hash algorithms are by definition not reversible. Clients - reading the configuration or applied configuration for the node - should expect to receive only the hashed value. Values written - in cleartext will be hashed. This annotation may be used on - nodes such as secure passwords in which the device never reports - a cleartext value, even if the input is provided as cleartext."; - } -} diff --git a/src/plugins/yang/openconfig/openconfig-extensions@2017-04-11.yang b/src/plugins/yang/openconfig/openconfig-extensions@2017-04-11.yang new file mode 100644 index 0000000..f39ecf6 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-extensions@2017-04-11.yang @@ -0,0 +1,91 @@ +module openconfig-extensions { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/openconfig-ext"; + + prefix "oc-ext"; + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module provides extensions to the YANG language to allow + OpenConfig specific functionality and meta-data to be defined."; + + revision "2017-04-11" { + description + "rename password type to 'hashed' and clarify description"; + reference "0.3.0"; + } + + revision "2017-01-29" { + description + "Added extension for annotating encrypted values."; + reference "0.2.0"; + } + + revision "2015-10-09" { + description + "Initial OpenConfig public release"; + reference "0.1.0"; + } + + + // extension statements + extension openconfig-version { + argument "semver" { + yin-element false; + } + description + "The OpenConfig version number for the module. This is + expressed as a semantic version number of the form: + x.y.z + where: + * x corresponds to the major version, + * y corresponds to a minor version, + * z corresponds to a patch version. + This version corresponds to the model file within which it is + defined, and does not cover the whole set of OpenConfig models. + Where several modules are used to build up a single block of + functionality, the same module version is specified across each + file that makes up the module. + + A major version number of 0 indicates that this model is still + in development (whether within OpenConfig or with industry + partners), and is potentially subject to change. + + Following a release of major version 1, all modules will + increment major revision number where backwards incompatible + changes to the model are made. + + The minor version is changed when features are added to the + model that do not impact current clients use of the model. + + The patch-level version is incremented when non-feature changes + (such as bugfixes or clarifications to human-readable + descriptions that do not impact model functionality) are made + that maintain backwards compatibility. + + The version number is stored in the module meta-data."; + } + + extension openconfig-hashed-value { + description + "This extension provides an annotation on schema nodes to + indicate that the corresponding value should be stored and + reported in hashed form. + + Hash algorithms are by definition not reversible. Clients + reading the configuration or applied configuration for the node + should expect to receive only the hashed value. Values written + in cleartext will be hashed. This annotation may be used on + nodes such as secure passwords in which the device never reports + a cleartext value, even if the input is provided as cleartext."; + } +} diff --git a/src/plugins/yang/openconfig/openconfig-if-aggregate.yang b/src/plugins/yang/openconfig/openconfig-if-aggregate.yang deleted file mode 100644 index 5aa80bb..0000000 --- a/src/plugins/yang/openconfig/openconfig-if-aggregate.yang +++ /dev/null @@ -1,223 +0,0 @@ -module openconfig-if-aggregate { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/interfaces/aggregate"; - - prefix "oc-lag"; - - // import some basic types - import openconfig-interfaces { prefix oc-if; } - import openconfig-if-ethernet { prefix oc-eth; } - import iana-if-type { prefix ift; } - import openconfig-if-types { prefix oc-ift; } - import openconfig-extensions { prefix oc-ext; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "Model for managing aggregated (aka bundle, LAG) interfaces."; - - oc-ext:openconfig-version "2.3.1"; - - revision "2018-03-23" { - description - "Fix/cleanup when statements in aggregates model."; - reference "2.3.1"; - } - - revision "2018-01-05" { - description - "Add logical loopback to interface."; - reference "2.3.0"; - } - - revision "2017-12-22" { - description - "Add IPv4 proxy ARP configuration."; - reference "2.2.0"; - } - - revision "2017-12-21" { - description - "Added IPv6 router advertisement configuration."; - reference "2.1.0"; - } - - revision "2017-07-14" { - description - "Added Ethernet/IP state data; Add dhcp-client; - migrate to OpenConfig types modules; Removed or - renamed opstate values"; - reference "2.0.0"; - } - - revision "2016-12-22" { - description - "Fixes to Ethernet interfaces model"; - reference "1.1.0"; - } - - // extension statements - - // feature statements - - // identity statements - - // typedef statements - - - - typedef aggregation-type { - type enumeration { - enum LACP { - description "LAG managed by LACP"; - } - enum STATIC { - description "Statically configured bundle / LAG"; - } - } - description - "Type to define the lag-type, i.e., how the LAG is - defined and managed"; - } - - // grouping statements - - - grouping aggregation-logical-config { - description - "Configuration data for aggregate interfaces"; - - - leaf lag-type { - type aggregation-type; - description - "Sets the type of LAG, i.e., how it is - configured / maintained"; - } - - leaf min-links { - type uint16; - description - "Specifies the mininum number of member - interfaces that must be active for the aggregate interface - to be available"; - } - } - - grouping aggregation-logical-state { - description - "Operational state data for aggregate interfaces"; - - leaf lag-speed { - type uint32; - units Mbps; - description - "Reports effective speed of the aggregate interface, - based on speed of active member interfaces"; - } - - leaf-list member { - when "../../config/lag-type = 'STATIC'" { - description - "The simple list of member interfaces is active - when the aggregate is statically configured"; - } - type oc-if:base-interface-ref; - description - "List of current member interfaces for the aggregate, - expressed as references to existing interfaces"; - } - } - - grouping aggregation-logical-top { - description "Top-level data definitions for LAGs"; - - container aggregation { - - description - "Options for logical interfaces representing - aggregates"; - - container config { - description - "Configuration variables for logical aggregate / - LAG interfaces"; - - uses aggregation-logical-config; - } - - container state { - - config false; - description - "Operational state variables for logical - aggregate / LAG interfaces"; - - uses aggregation-logical-config; - uses aggregation-logical-state; - - } - } - } - - grouping ethernet-if-aggregation-config { - description - "Adds configuration items for Ethernet interfaces - belonging to a logical aggregate / LAG"; - - leaf aggregate-id { - type leafref { - path "/oc-if:interfaces/oc-if:interface/oc-if:name"; - } - description - "Specify the logical aggregate interface to which - this interface belongs"; - } - } - - // data definition statements - - // augment statements - - augment "/oc-if:interfaces/oc-if:interface" { - - description "Adds LAG configuration to the interface module"; - - uses aggregation-logical-top { - when "oc-if:state/oc-if:type = 'ift:ieee8023adLag' or " + - "oc-if:state/oc-if:type = 'oc-ift:IF_AGGREGATE'" { - description - "active when the interface is set to type LAG"; - } - } - } - - augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" + - "oc-eth:config" { - description - "Adds LAG settings to individual Ethernet interfaces"; - - uses ethernet-if-aggregation-config; - } - - augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" + - "oc-eth:state" { - description - "Adds LAG settings to individual Ethernet interfaces"; - - uses ethernet-if-aggregation-config; - } - - // rpc statements - - // notification statements - -} diff --git a/src/plugins/yang/openconfig/openconfig-if-aggregate@2018-03-23.yang b/src/plugins/yang/openconfig/openconfig-if-aggregate@2018-03-23.yang new file mode 100644 index 0000000..5aa80bb --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-if-aggregate@2018-03-23.yang @@ -0,0 +1,223 @@ +module openconfig-if-aggregate { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/interfaces/aggregate"; + + prefix "oc-lag"; + + // import some basic types + import openconfig-interfaces { prefix oc-if; } + import openconfig-if-ethernet { prefix oc-eth; } + import iana-if-type { prefix ift; } + import openconfig-if-types { prefix oc-ift; } + import openconfig-extensions { prefix oc-ext; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "Model for managing aggregated (aka bundle, LAG) interfaces."; + + oc-ext:openconfig-version "2.3.1"; + + revision "2018-03-23" { + description + "Fix/cleanup when statements in aggregates model."; + reference "2.3.1"; + } + + revision "2018-01-05" { + description + "Add logical loopback to interface."; + reference "2.3.0"; + } + + revision "2017-12-22" { + description + "Add IPv4 proxy ARP configuration."; + reference "2.2.0"; + } + + revision "2017-12-21" { + description + "Added IPv6 router advertisement configuration."; + reference "2.1.0"; + } + + revision "2017-07-14" { + description + "Added Ethernet/IP state data; Add dhcp-client; + migrate to OpenConfig types modules; Removed or + renamed opstate values"; + reference "2.0.0"; + } + + revision "2016-12-22" { + description + "Fixes to Ethernet interfaces model"; + reference "1.1.0"; + } + + // extension statements + + // feature statements + + // identity statements + + // typedef statements + + + + typedef aggregation-type { + type enumeration { + enum LACP { + description "LAG managed by LACP"; + } + enum STATIC { + description "Statically configured bundle / LAG"; + } + } + description + "Type to define the lag-type, i.e., how the LAG is + defined and managed"; + } + + // grouping statements + + + grouping aggregation-logical-config { + description + "Configuration data for aggregate interfaces"; + + + leaf lag-type { + type aggregation-type; + description + "Sets the type of LAG, i.e., how it is + configured / maintained"; + } + + leaf min-links { + type uint16; + description + "Specifies the mininum number of member + interfaces that must be active for the aggregate interface + to be available"; + } + } + + grouping aggregation-logical-state { + description + "Operational state data for aggregate interfaces"; + + leaf lag-speed { + type uint32; + units Mbps; + description + "Reports effective speed of the aggregate interface, + based on speed of active member interfaces"; + } + + leaf-list member { + when "../../config/lag-type = 'STATIC'" { + description + "The simple list of member interfaces is active + when the aggregate is statically configured"; + } + type oc-if:base-interface-ref; + description + "List of current member interfaces for the aggregate, + expressed as references to existing interfaces"; + } + } + + grouping aggregation-logical-top { + description "Top-level data definitions for LAGs"; + + container aggregation { + + description + "Options for logical interfaces representing + aggregates"; + + container config { + description + "Configuration variables for logical aggregate / + LAG interfaces"; + + uses aggregation-logical-config; + } + + container state { + + config false; + description + "Operational state variables for logical + aggregate / LAG interfaces"; + + uses aggregation-logical-config; + uses aggregation-logical-state; + + } + } + } + + grouping ethernet-if-aggregation-config { + description + "Adds configuration items for Ethernet interfaces + belonging to a logical aggregate / LAG"; + + leaf aggregate-id { + type leafref { + path "/oc-if:interfaces/oc-if:interface/oc-if:name"; + } + description + "Specify the logical aggregate interface to which + this interface belongs"; + } + } + + // data definition statements + + // augment statements + + augment "/oc-if:interfaces/oc-if:interface" { + + description "Adds LAG configuration to the interface module"; + + uses aggregation-logical-top { + when "oc-if:state/oc-if:type = 'ift:ieee8023adLag' or " + + "oc-if:state/oc-if:type = 'oc-ift:IF_AGGREGATE'" { + description + "active when the interface is set to type LAG"; + } + } + } + + augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" + + "oc-eth:config" { + description + "Adds LAG settings to individual Ethernet interfaces"; + + uses ethernet-if-aggregation-config; + } + + augment "/oc-if:interfaces/oc-if:interface/oc-eth:ethernet/" + + "oc-eth:state" { + description + "Adds LAG settings to individual Ethernet interfaces"; + + uses ethernet-if-aggregation-config; + } + + // rpc statements + + // notification statements + +} diff --git a/src/plugins/yang/openconfig/openconfig-if-ethernet.yang b/src/plugins/yang/openconfig/openconfig-if-ethernet.yang deleted file mode 100644 index cd6b526..0000000 --- a/src/plugins/yang/openconfig/openconfig-if-ethernet.yang +++ /dev/null @@ -1,428 +0,0 @@ -module openconfig-if-ethernet { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/interfaces/ethernet"; - - prefix "oc-eth"; - - // import some basic types - import openconfig-interfaces { prefix oc-if; } - import iana-if-type { prefix ift; } - import openconfig-yang-types { prefix oc-yang; } - import openconfig-extensions { prefix oc-ext; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "Model for managing Ethernet interfaces -- augments the OpenConfig - model for interface configuration and state."; - - oc-ext:openconfig-version "2.6.1"; - - revision "2018-09-04" { - description - "Remove in-crc-align-errors as it is a duplicate of - in-crc-errors"; - reference "2.6.1"; - } - - revision "2018-08-28" { - description - "Add Ethernet counter in-block-errors"; - reference "2.6.0"; - } - - revision "2018-07-02" { - description - "Add new ethernet counters of in-undersize-frames, - in-crc-align-errors and the distribution container"; - reference "2.5.0"; - } - - revision "2018-04-10" { - description - "Add identities for 2.5 and 5 Gbps."; - reference "2.4.0"; - } - - revision "2018-01-05" { - description - "Add logical loopback to interface."; - reference "2.3.0"; - } - - revision "2017-12-21" { - description - "Added IPv6 router advertisement configuration."; - reference "2.1.0"; - } - - revision "2017-07-14" { - description - "Added Ethernet/IP state data; Add dhcp-client; - migrate to OpenConfig types modules; Removed or - renamed opstate values"; - reference "2.0.0"; - } - - revision "2016-12-22" { - description - "Fixes to Ethernet interfaces model"; - reference "1.1.0"; - } - - - // identity statements - - identity ETHERNET_SPEED { - description "base type to specify available Ethernet link - speeds"; - } - - identity SPEED_10MB { - base ETHERNET_SPEED; - description "10 Mbps Ethernet"; - } - - identity SPEED_100MB { - base ETHERNET_SPEED; - description "100 Mbps Ethernet"; - } - - identity SPEED_1GB { - base ETHERNET_SPEED; - description "1 Gbps Ethernet"; - } - - identity SPEED_2500MB { - base ETHERNET_SPEED; - description "2.5 Gbps Ethernet"; - } - - identity SPEED_5GB { - base ETHERNET_SPEED; - description "5 Gbps Ethernet"; - } - - identity SPEED_10GB { - base ETHERNET_SPEED; - description "10 Gbps Ethernet"; - } - - identity SPEED_25GB { - base ETHERNET_SPEED; - description "25 Gbps Ethernet"; - } - - identity SPEED_40GB { - base ETHERNET_SPEED; - description "40 Gbps Ethernet"; - } - - identity SPEED_50GB { - base ETHERNET_SPEED; - description "50 Gbps Ethernet"; - } - - identity SPEED_100GB { - base ETHERNET_SPEED; - description "100 Gbps Ethernet"; - } - - identity SPEED_UNKNOWN { - base ETHERNET_SPEED; - description - "Interface speed is unknown. Systems may report - speed UNKNOWN when an interface is down or unpopuplated (e.g., - pluggable not present)."; - } - - // typedef statements - - - // grouping statements - - grouping ethernet-interface-config { - description "Configuration items for Ethernet interfaces"; - - leaf mac-address { - type oc-yang:mac-address; - description - "Assigns a MAC address to the Ethernet interface. If not - specified, the corresponding operational state leaf is - expected to show the system-assigned MAC address."; - } - - leaf auto-negotiate { - type boolean; - default true; - description - "Set to TRUE to request the interface to auto-negotiate - transmission parameters with its peer interface. When - set to FALSE, the transmission parameters are specified - manually."; - reference - "IEEE 802.3-2012 auto-negotiation transmission parameters"; - } - - leaf duplex-mode { - type enumeration { - enum FULL { - description "Full duplex mode"; - } - enum HALF { - description "Half duplex mode"; - } - } - description - "When auto-negotiate is TRUE, this optionally sets the - duplex mode that will be advertised to the peer. If - unspecified, the interface should negotiate the duplex mode - directly (typically full-duplex). When auto-negotiate is - FALSE, this sets the duplex mode on the interface directly."; - } - - leaf port-speed { - type identityref { - base ETHERNET_SPEED; - } - description - "When auto-negotiate is TRUE, this optionally sets the - port-speed mode that will be advertised to the peer for - negotiation. If unspecified, it is expected that the - interface will select the highest speed available based on - negotiation. When auto-negotiate is set to FALSE, sets the - link speed to a fixed value -- supported values are defined - by ETHERNET_SPEED identities"; - } - - leaf enable-flow-control { - type boolean; - default false; - description - "Enable or disable flow control for this interface. - Ethernet flow control is a mechanism by which a receiver - may send PAUSE frames to a sender to stop transmission for - a specified time. - - This setting should override auto-negotiated flow control - settings. If left unspecified, and auto-negotiate is TRUE, - flow control mode is negotiated with the peer interface."; - reference - "IEEE 802.3x"; - } - } - - grouping ethernet-interface-state-counters { - description - "Ethernet-specific counters and statistics"; - - // ingress counters - - leaf in-mac-control-frames { - type oc-yang:counter64; - description - "MAC layer control frames received on the interface"; - } - - leaf in-mac-pause-frames { - type oc-yang:counter64; - description - "MAC layer PAUSE frames received on the interface"; - } - - leaf in-oversize-frames { - type oc-yang:counter64; - description - "The total number of frames received that were - longer than 1518 octets (excluding framing bits, - but including FCS octets) and were otherwise - well formed."; - } - - leaf in-undersize-frames { - type oc-yang:counter64; - description - "The total number of frames received that were - less than 64 octets long (excluding framing bits, - but including FCS octets) and were otherwise well - formed."; - reference - "RFC 2819: Remote Network Monitoring MIB - - etherStatsUndersizePkts"; - } - - leaf in-jabber-frames { - type oc-yang:counter64; - description - "Number of jabber frames received on the - interface. Jabber frames are typically defined as oversize - frames which also have a bad CRC. Implementations may use - slightly different definitions of what constitutes a jabber - frame. Often indicative of a NIC hardware problem."; - } - - leaf in-fragment-frames { - type oc-yang:counter64; - description - "The total number of frames received that were less than - 64 octets in length (excluding framing bits but including - FCS octets) and had either a bad Frame Check Sequence - (FCS) with an integral number of octets (FCS Error) or a - bad FCS with a non-integral number of octets (Alignment - Error)."; - } - - leaf in-8021q-frames { - type oc-yang:counter64; - description - "Number of 802.1q tagged frames received on the interface"; - } - - leaf in-crc-errors { - type oc-yang:counter64; - description - "The total number of frames received that - had a length (excluding framing bits, but - including FCS octets) of between 64 and 1518 - octets, inclusive, but had either a bad - Frame Check Sequence (FCS) with an integral - number of octets (FCS Error) or a bad FCS with - a non-integral number of octets (Alignment Error)"; - reference - "RFC 2819: Remote Network Monitoring MIB - - etherStatsCRCAlignErrors"; - } - - leaf in-block-errors { - type oc-yang:counter64; - description - "The number of received errored blocks. Error detection codes - are capable of detecting whether one or more errors have - occurred in a given sequence of bits - the block. It is - normally not possible to determine the exact number of errored - bits within the block"; - } - - // egress counters - - leaf out-mac-control-frames { - type oc-yang:counter64; - description - "MAC layer control frames sent on the interface"; - } - - leaf out-mac-pause-frames { - type oc-yang:counter64; - description - "MAC layer PAUSE frames sent on the interface"; - } - - leaf out-8021q-frames { - type oc-yang:counter64; - description - "Number of 802.1q tagged frames sent on the interface"; - } - } - - grouping ethernet-interface-state { - description - "Grouping for defining Ethernet-specific operational state"; - - leaf hw-mac-address { - type oc-yang:mac-address; - description - "Represenets the 'burned-in', or system-assigned, MAC - address for the Ethernet interface."; - } - - leaf negotiated-duplex-mode { - type enumeration { - enum FULL { - description "Full duplex mode"; - } - enum HALF { - description "Half duplex mode"; - } - } - description - "When auto-negotiate is set to TRUE, and the interface has - completed auto-negotiation with the remote peer, this value - shows the duplex mode that has been negotiated."; - } - - leaf negotiated-port-speed { - type identityref { - base ETHERNET_SPEED; - } - description - "When auto-negotiate is set to TRUE, and the interface has - completed auto-negotiation with the remote peer, this value - shows the interface speed that has been negotiated."; - } - - container counters { - description "Ethernet interface counters"; - - uses ethernet-interface-state-counters; - - } - - } - - // data definition statements - - grouping ethernet-top { - description "top-level Ethernet config and state containers"; - - container ethernet { - description - "Top-level container for ethernet configuration - and state"; - - container config { - description "Configuration data for ethernet interfaces"; - - uses ethernet-interface-config; - - } - - container state { - - config false; - description "State variables for Ethernet interfaces"; - - uses ethernet-interface-config; - uses ethernet-interface-state; - - } - - } - } - - // augment statements - - augment "/oc-if:interfaces/oc-if:interface" { - description "Adds addtional Ethernet-specific configuration to - interfaces model"; - - uses ethernet-top { - when "oc-if:state/oc-if:type = 'ift:ethernetCsmacd'" { - description "Additional interface configuration parameters when - the interface type is Ethernet"; - } - } - } - - // rpc statements - - // notification statements - -} diff --git a/src/plugins/yang/openconfig/openconfig-if-ethernet@2018-09-04.yang b/src/plugins/yang/openconfig/openconfig-if-ethernet@2018-09-04.yang new file mode 100644 index 0000000..cd6b526 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-if-ethernet@2018-09-04.yang @@ -0,0 +1,428 @@ +module openconfig-if-ethernet { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/interfaces/ethernet"; + + prefix "oc-eth"; + + // import some basic types + import openconfig-interfaces { prefix oc-if; } + import iana-if-type { prefix ift; } + import openconfig-yang-types { prefix oc-yang; } + import openconfig-extensions { prefix oc-ext; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "Model for managing Ethernet interfaces -- augments the OpenConfig + model for interface configuration and state."; + + oc-ext:openconfig-version "2.6.1"; + + revision "2018-09-04" { + description + "Remove in-crc-align-errors as it is a duplicate of + in-crc-errors"; + reference "2.6.1"; + } + + revision "2018-08-28" { + description + "Add Ethernet counter in-block-errors"; + reference "2.6.0"; + } + + revision "2018-07-02" { + description + "Add new ethernet counters of in-undersize-frames, + in-crc-align-errors and the distribution container"; + reference "2.5.0"; + } + + revision "2018-04-10" { + description + "Add identities for 2.5 and 5 Gbps."; + reference "2.4.0"; + } + + revision "2018-01-05" { + description + "Add logical loopback to interface."; + reference "2.3.0"; + } + + revision "2017-12-21" { + description + "Added IPv6 router advertisement configuration."; + reference "2.1.0"; + } + + revision "2017-07-14" { + description + "Added Ethernet/IP state data; Add dhcp-client; + migrate to OpenConfig types modules; Removed or + renamed opstate values"; + reference "2.0.0"; + } + + revision "2016-12-22" { + description + "Fixes to Ethernet interfaces model"; + reference "1.1.0"; + } + + + // identity statements + + identity ETHERNET_SPEED { + description "base type to specify available Ethernet link + speeds"; + } + + identity SPEED_10MB { + base ETHERNET_SPEED; + description "10 Mbps Ethernet"; + } + + identity SPEED_100MB { + base ETHERNET_SPEED; + description "100 Mbps Ethernet"; + } + + identity SPEED_1GB { + base ETHERNET_SPEED; + description "1 Gbps Ethernet"; + } + + identity SPEED_2500MB { + base ETHERNET_SPEED; + description "2.5 Gbps Ethernet"; + } + + identity SPEED_5GB { + base ETHERNET_SPEED; + description "5 Gbps Ethernet"; + } + + identity SPEED_10GB { + base ETHERNET_SPEED; + description "10 Gbps Ethernet"; + } + + identity SPEED_25GB { + base ETHERNET_SPEED; + description "25 Gbps Ethernet"; + } + + identity SPEED_40GB { + base ETHERNET_SPEED; + description "40 Gbps Ethernet"; + } + + identity SPEED_50GB { + base ETHERNET_SPEED; + description "50 Gbps Ethernet"; + } + + identity SPEED_100GB { + base ETHERNET_SPEED; + description "100 Gbps Ethernet"; + } + + identity SPEED_UNKNOWN { + base ETHERNET_SPEED; + description + "Interface speed is unknown. Systems may report + speed UNKNOWN when an interface is down or unpopuplated (e.g., + pluggable not present)."; + } + + // typedef statements + + + // grouping statements + + grouping ethernet-interface-config { + description "Configuration items for Ethernet interfaces"; + + leaf mac-address { + type oc-yang:mac-address; + description + "Assigns a MAC address to the Ethernet interface. If not + specified, the corresponding operational state leaf is + expected to show the system-assigned MAC address."; + } + + leaf auto-negotiate { + type boolean; + default true; + description + "Set to TRUE to request the interface to auto-negotiate + transmission parameters with its peer interface. When + set to FALSE, the transmission parameters are specified + manually."; + reference + "IEEE 802.3-2012 auto-negotiation transmission parameters"; + } + + leaf duplex-mode { + type enumeration { + enum FULL { + description "Full duplex mode"; + } + enum HALF { + description "Half duplex mode"; + } + } + description + "When auto-negotiate is TRUE, this optionally sets the + duplex mode that will be advertised to the peer. If + unspecified, the interface should negotiate the duplex mode + directly (typically full-duplex). When auto-negotiate is + FALSE, this sets the duplex mode on the interface directly."; + } + + leaf port-speed { + type identityref { + base ETHERNET_SPEED; + } + description + "When auto-negotiate is TRUE, this optionally sets the + port-speed mode that will be advertised to the peer for + negotiation. If unspecified, it is expected that the + interface will select the highest speed available based on + negotiation. When auto-negotiate is set to FALSE, sets the + link speed to a fixed value -- supported values are defined + by ETHERNET_SPEED identities"; + } + + leaf enable-flow-control { + type boolean; + default false; + description + "Enable or disable flow control for this interface. + Ethernet flow control is a mechanism by which a receiver + may send PAUSE frames to a sender to stop transmission for + a specified time. + + This setting should override auto-negotiated flow control + settings. If left unspecified, and auto-negotiate is TRUE, + flow control mode is negotiated with the peer interface."; + reference + "IEEE 802.3x"; + } + } + + grouping ethernet-interface-state-counters { + description + "Ethernet-specific counters and statistics"; + + // ingress counters + + leaf in-mac-control-frames { + type oc-yang:counter64; + description + "MAC layer control frames received on the interface"; + } + + leaf in-mac-pause-frames { + type oc-yang:counter64; + description + "MAC layer PAUSE frames received on the interface"; + } + + leaf in-oversize-frames { + type oc-yang:counter64; + description + "The total number of frames received that were + longer than 1518 octets (excluding framing bits, + but including FCS octets) and were otherwise + well formed."; + } + + leaf in-undersize-frames { + type oc-yang:counter64; + description + "The total number of frames received that were + less than 64 octets long (excluding framing bits, + but including FCS octets) and were otherwise well + formed."; + reference + "RFC 2819: Remote Network Monitoring MIB - + etherStatsUndersizePkts"; + } + + leaf in-jabber-frames { + type oc-yang:counter64; + description + "Number of jabber frames received on the + interface. Jabber frames are typically defined as oversize + frames which also have a bad CRC. Implementations may use + slightly different definitions of what constitutes a jabber + frame. Often indicative of a NIC hardware problem."; + } + + leaf in-fragment-frames { + type oc-yang:counter64; + description + "The total number of frames received that were less than + 64 octets in length (excluding framing bits but including + FCS octets) and had either a bad Frame Check Sequence + (FCS) with an integral number of octets (FCS Error) or a + bad FCS with a non-integral number of octets (Alignment + Error)."; + } + + leaf in-8021q-frames { + type oc-yang:counter64; + description + "Number of 802.1q tagged frames received on the interface"; + } + + leaf in-crc-errors { + type oc-yang:counter64; + description + "The total number of frames received that + had a length (excluding framing bits, but + including FCS octets) of between 64 and 1518 + octets, inclusive, but had either a bad + Frame Check Sequence (FCS) with an integral + number of octets (FCS Error) or a bad FCS with + a non-integral number of octets (Alignment Error)"; + reference + "RFC 2819: Remote Network Monitoring MIB - + etherStatsCRCAlignErrors"; + } + + leaf in-block-errors { + type oc-yang:counter64; + description + "The number of received errored blocks. Error detection codes + are capable of detecting whether one or more errors have + occurred in a given sequence of bits - the block. It is + normally not possible to determine the exact number of errored + bits within the block"; + } + + // egress counters + + leaf out-mac-control-frames { + type oc-yang:counter64; + description + "MAC layer control frames sent on the interface"; + } + + leaf out-mac-pause-frames { + type oc-yang:counter64; + description + "MAC layer PAUSE frames sent on the interface"; + } + + leaf out-8021q-frames { + type oc-yang:counter64; + description + "Number of 802.1q tagged frames sent on the interface"; + } + } + + grouping ethernet-interface-state { + description + "Grouping for defining Ethernet-specific operational state"; + + leaf hw-mac-address { + type oc-yang:mac-address; + description + "Represenets the 'burned-in', or system-assigned, MAC + address for the Ethernet interface."; + } + + leaf negotiated-duplex-mode { + type enumeration { + enum FULL { + description "Full duplex mode"; + } + enum HALF { + description "Half duplex mode"; + } + } + description + "When auto-negotiate is set to TRUE, and the interface has + completed auto-negotiation with the remote peer, this value + shows the duplex mode that has been negotiated."; + } + + leaf negotiated-port-speed { + type identityref { + base ETHERNET_SPEED; + } + description + "When auto-negotiate is set to TRUE, and the interface has + completed auto-negotiation with the remote peer, this value + shows the interface speed that has been negotiated."; + } + + container counters { + description "Ethernet interface counters"; + + uses ethernet-interface-state-counters; + + } + + } + + // data definition statements + + grouping ethernet-top { + description "top-level Ethernet config and state containers"; + + container ethernet { + description + "Top-level container for ethernet configuration + and state"; + + container config { + description "Configuration data for ethernet interfaces"; + + uses ethernet-interface-config; + + } + + container state { + + config false; + description "State variables for Ethernet interfaces"; + + uses ethernet-interface-config; + uses ethernet-interface-state; + + } + + } + } + + // augment statements + + augment "/oc-if:interfaces/oc-if:interface" { + description "Adds addtional Ethernet-specific configuration to + interfaces model"; + + uses ethernet-top { + when "oc-if:state/oc-if:type = 'ift:ethernetCsmacd'" { + description "Additional interface configuration parameters when + the interface type is Ethernet"; + } + } + } + + // rpc statements + + // notification statements + +} diff --git a/src/plugins/yang/openconfig/openconfig-if-ip.yang b/src/plugins/yang/openconfig/openconfig-if-ip.yang deleted file mode 100644 index a20e21c..0000000 --- a/src/plugins/yang/openconfig/openconfig-if-ip.yang +++ /dev/null @@ -1,1312 +0,0 @@ -module openconfig-if-ip { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/interfaces/ip"; - - prefix "oc-ip"; - - // import some basic types - import openconfig-inet-types { prefix oc-inet; } - import openconfig-interfaces { prefix oc-if; } - import openconfig-vlan { prefix oc-vlan; } - import openconfig-yang-types { prefix oc-yang; } - import openconfig-extensions { prefix oc-ext; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "This model defines data for managing configuration and - operational state on IP (IPv4 and IPv6) interfaces. - - This model reuses data items defined in the IETF YANG model for - interfaces described by RFC 7277 with an alternate structure - (particularly for operational state data) and with - additional configuration items. - - Portions of this code were derived from IETF RFC 7277. - Please reproduce this note if possible. - - IETF code is subject to the following copyright and license: - Copyright (c) IETF Trust and the persons identified as authors of - the code. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in - Section 4.c of the IETF Trust's Legal Provisions Relating - to IETF Documents (http://trustee.ietf.org/license-info)."; - - oc-ext:openconfig-version "2.3.0"; - - revision "2018-01-05" { - description - "Add logical loopback to interface."; - reference "2.3.0"; - } - - revision "2017-12-21" { - description - "Added IPv6 router advertisement configuration."; - reference "2.1.0"; - } - - revision "2017-07-14" { - description - "Added Ethernet/IP state data; Add dhcp-client; - migrate to OpenConfig types modules; Removed or - renamed opstate values"; - reference "2.0.0"; - } - - revision "2017-04-03"{ - description - "Update copyright notice."; - reference "1.1.1"; - } - - revision "2016-12-22" { - description - "Fixes to Ethernet interfaces model"; - reference "1.1.0"; - } - - - // typedef statements - - typedef ip-address-origin { - type enumeration { - enum OTHER { - description - "None of the following."; - } - enum STATIC { - description - "Indicates that the address has been statically - configured - for example, using NETCONF or a Command Line - Interface."; - } - enum DHCP { - description - "Indicates an address that has been assigned to this - system by a DHCP server."; - } - enum LINK_LAYER { - description - "Indicates an address created by IPv6 stateless - autoconfiguration that embeds a link-layer address in its - interface identifier."; - } - enum RANDOM { - description - "Indicates an address chosen by the system at - random, e.g., an IPv4 address within 169.254/16, an - RFC 4941 temporary address, or an RFC 7217 semantically - opaque address."; - reference - "RFC 4941: Privacy Extensions for Stateless Address - Autoconfiguration in IPv6 - RFC 7217: A Method for Generating Semantically Opaque - Interface Identifiers with IPv6 Stateless - Address Autoconfiguration (SLAAC)"; - } - } - description - "The origin of an address."; - } - - typedef neighbor-origin { - type enumeration { - enum OTHER { - description - "None of the following."; - } - enum STATIC { - description - "Indicates that the mapping has been statically - configured - for example, using NETCONF or a Command Line - Interface."; - } - enum DYNAMIC { - description - "Indicates that the mapping has been dynamically resolved - using, e.g., IPv4 ARP or the IPv6 Neighbor Discovery - protocol."; - } - } - description - "The origin of a neighbor entry."; - } - - // grouping statements - - grouping ip-common-global-config { - description - "Shared configuration data for IPv4 or IPv6 assigned - globally on an interface."; - - leaf dhcp-client { - type boolean; - default false; - description - "Enables a DHCP client on the interface in order to request - an address"; - } - } - - grouping ip-common-counters-state { - description - "Operational state for IP traffic statistics for IPv4 and - IPv6"; - - container counters { - description - "Packet and byte counters for IP transmission and - reception for the address family."; - - - leaf in-pkts { - type oc-yang:counter64; - description - "The total number of IP packets received for the specified - address family, including those received in error"; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf in-octets { - type oc-yang:counter64; - description - "The total number of octets received in input IP packets - for the specified address family, including those received - in error."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf in-error-pkts { - // TODO: this counter combines several error conditions -- - // could consider breaking them out to separate leaf nodes - type oc-yang:counter64; - description - "Number of IP packets discarded due to errors for the - specified address family, including errors in the IP - header, no route found to the IP destination, invalid - address, unknown protocol, etc."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf in-forwarded-pkts { - type oc-yang:counter64; - description - "The number of input packets for which the device was not - their final IP destination and for which the device - attempted to find a route to forward them to that final - destination."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf in-forwarded-octets { - type oc-yang:counter64; - description - "The number of octets received in input IP packets - for the specified address family for which the device was - not their final IP destination and for which the - device attempted to find a route to forward them to that - final destination."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf in-discarded-pkts { - type oc-yang:counter64; - description - "The number of input IP packets for the - specified address family, for which no problems were - encountered to prevent their continued processing, but - were discarded (e.g., for lack of buffer space)."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf out-pkts { - type oc-yang:counter64; - description - "The total number of IP packets for the - specified address family that the device supplied - to the lower layers for transmission. This includes - packets generated locally and those forwarded by the - device."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf out-octets { - type oc-yang:counter64; - description - "The total number of octets in IP packets for the - specified address family that the device - supplied to the lower layers for transmission. This - includes packets generated locally and those forwarded by - the device."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf out-error-pkts { - // TODO: this counter combines several error conditions -- - // could consider breaking them out to separate leaf nodes - type oc-yang:counter64; - description - "Number of IP packets for the specified address family - locally generated and discarded due to errors, including - no route found to the IP destination."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf out-forwarded-pkts { - type oc-yang:counter64; - description - "The number of packets for which this entity was not their - final IP destination and for which it was successful in - finding a path to their final destination."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf out-forwarded-octets { - type oc-yang:counter64; - description - "The number of octets in packets for which this entity was - not their final IP destination and for which it was - successful in finding a path to their final destination."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - - leaf out-discarded-pkts { - type oc-yang:counter64; - description - "The number of output IP packets for the - specified address family for which no problem was - encountered to prevent their transmission to their - destination, but were discarded (e.g., for lack of - buffer space)."; - reference - "RFC 4293 - Management Information Base for the - Internet Protocol (IP)"; - } - } - - } - - - - grouping ipv4-global-config { - description - "Configuration data for IPv4 interfaces across - all addresses assigned to the interface"; - - leaf enabled { - type boolean; - default true; - description - "Controls whether IPv4 is enabled or disabled on this - interface. When IPv4 is enabled, this interface is - connected to an IPv4 stack, and the interface can send - and receive IPv4 packets."; - } - - leaf mtu { - type uint16 { - range "68..max"; - } - units octets; - description - "The size, in octets, of the largest IPv4 packet that the - interface will send and receive. - - The server may restrict the allowed values for this leaf, - depending on the interface's type. - - If this leaf is not configured, the operationally used MTU - depends on the interface's type."; - reference - "RFC 791: Internet Protocol"; - } - - uses ip-common-global-config; - - - } - - grouping ipv4-address-config { - - description - "Per IPv4 adresss configuration data for the - interface."; - - leaf ip { - type oc-inet:ipv4-address; - description - "The IPv4 address on the interface."; - } - - leaf prefix-length { - type uint8 { - range "0..32"; - } - description - "The length of the subnet prefix."; - } - } - - grouping ipv4-neighbor-config { - description - "Per IPv4 neighbor configuration data. Neighbor - entries are analagous to static ARP entries, i.e., they - create a correspondence between IP and link-layer addresses"; - - leaf ip { - type oc-inet:ipv4-address; - description - "The IPv4 address of the neighbor node."; - } - leaf link-layer-address { - type oc-yang:phys-address; - mandatory true; - description - "The link-layer address of the neighbor node."; - } - } - - grouping ipv4-address-state { - description - "State variables for IPv4 addresses on the interface"; - - leaf origin { - type ip-address-origin; - description - "The origin of this address, e.g., statically configured, - assigned by DHCP, etc.."; - } - } - - grouping ipv4-neighbor-state { - description - "State variables for IPv4 neighbor entries on the interface."; - - leaf origin { - type neighbor-origin; - description - "The origin of this neighbor entry, static or dynamic."; - } - } - - grouping ipv6-global-config { - description - "Configuration data at the global level for each - IPv6 interface"; - - leaf enabled { - type boolean; - default true; - description - "Controls whether IPv6 is enabled or disabled on this - interface. When IPv6 is enabled, this interface is - connected to an IPv6 stack, and the interface can send - and receive IPv6 packets."; - } - - leaf mtu { - type uint32 { - range "1280..max"; - } - units octets; - description - "The size, in octets, of the largest IPv6 packet that the - interface will send and receive. - - The server may restrict the allowed values for this leaf, - depending on the interface's type. - - If this leaf is not configured, the operationally used MTU - depends on the interface's type."; - reference - "RFC 2460: Internet Protocol, Version 6 (IPv6) Specification - Section 5"; - } - - leaf dup-addr-detect-transmits { - type uint32; - default 1; - description - "The number of consecutive Neighbor Solicitation messages - sent while performing Duplicate Address Detection on a - tentative address. A value of zero indicates that - Duplicate Address Detection is not performed on - tentative addresses. A value of one indicates a single - transmission with no follow-up retransmissions."; - reference - "RFC 4862: IPv6 Stateless Address Autoconfiguration"; - } - - uses ip-common-global-config; - } - - grouping ipv6-address-config { - description "Per-address configuration data for IPv6 interfaces"; - - leaf ip { - type oc-inet:ipv6-address; - description - "The IPv6 address on the interface."; - } - - leaf prefix-length { - type uint8 { - range "0..128"; - } - mandatory true; - description - "The length of the subnet prefix."; - } - } - - grouping ipv6-address-state { - description - "Per-address operational state data for IPv6 interfaces"; - - leaf origin { - type ip-address-origin; - description - "The origin of this address, e.g., static, dhcp, etc."; - } - - leaf status { - type enumeration { - enum PREFERRED { - description - "This is a valid address that can appear as the - destination or source address of a packet."; - } - enum DEPRECATED { - description - "This is a valid but deprecated address that should - no longer be used as a source address in new - communications, but packets addressed to such an - address are processed as expected."; - } - enum INVALID { - description - "This isn't a valid address, and it shouldn't appear - as the destination or source address of a packet."; - } - enum INACCESSIBLE { - description - "The address is not accessible because the interface - to which this address is assigned is not - operational."; - } - enum UNKNOWN { - description - "The status cannot be determined for some reason."; - } - enum TENTATIVE { - description - "The uniqueness of the address on the link is being - verified. Addresses in this state should not be - used for general communication and should only be - used to determine the uniqueness of the address."; - } - enum DUPLICATE { - description - "The address has been determined to be non-unique on - the link and so must not be used."; - } - enum OPTIMISTIC { - description - "The address is available for use, subject to - restrictions, while its uniqueness on a link is - being verified."; - } - } - description - "The status of an address. Most of the states correspond - to states from the IPv6 Stateless Address - Autoconfiguration protocol."; - reference - "RFC 4293: Management Information Base for the - Internet Protocol (IP) - - IpAddressStatusTC - RFC 4862: IPv6 Stateless Address Autoconfiguration"; - } - } - - grouping ipv6-neighbor-config { - description - "Per-neighbor configuration data for IPv6 interfaces"; - - leaf ip { - type oc-inet:ipv6-address; - description - "The IPv6 address of the neighbor node."; - } - - leaf link-layer-address { - type oc-yang:phys-address; - mandatory true; - description - "The link-layer address of the neighbor node."; - } - } - - grouping ipv6-neighbor-state { - description "Per-neighbor state variables for IPv6 interfaces"; - - leaf origin { - type neighbor-origin; - description - "The origin of this neighbor entry."; - } - leaf is-router { - type empty; - description - "Indicates that the neighbor node acts as a router."; - } - leaf neighbor-state { - type enumeration { - enum INCOMPLETE { - description - "Address resolution is in progress, and the link-layer - address of the neighbor has not yet been - determined."; - } - enum REACHABLE { - description - "Roughly speaking, the neighbor is known to have been - reachable recently (within tens of seconds ago)."; - } - enum STALE { - description - "The neighbor is no longer known to be reachable, but - until traffic is sent to the neighbor no attempt - should be made to verify its reachability."; - } - enum DELAY { - description - "The neighbor is no longer known to be reachable, and - traffic has recently been sent to the neighbor. - Rather than probe the neighbor immediately, however, - delay sending probes for a short while in order to - give upper-layer protocols a chance to provide - reachability confirmation."; - } - enum PROBE { - description - "The neighbor is no longer known to be reachable, and - unicast Neighbor Solicitation probes are being sent - to verify reachability."; - } - } - description - "The Neighbor Unreachability Detection state of this - entry."; - reference - "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - Section 7.3.2"; - } - } - - grouping ip-vrrp-ipv6-config { - description - "IPv6-specific configuration data for VRRP on IPv6 - interfaces"; - - leaf virtual-link-local { - type oc-inet:ip-address; - description - "For VRRP on IPv6 interfaces, sets the virtual link local - address"; - } - } - - grouping ip-vrrp-ipv6-state { - description - "IPv6-specific operational state for VRRP on IPv6 interfaces"; - - uses ip-vrrp-ipv6-config; - } - - grouping ip-vrrp-tracking-config { - description - "Configuration data for tracking interfaces - in a VRRP group"; - - leaf-list track-interface { - type leafref { - path "/oc-if:interfaces/oc-if:interface/oc-if:name"; - } - // TODO: we may need to add some restriction to ethernet - // or IP interfaces. - description - "Sets a list of one or more interfaces that should - be tracked for up/down events to dynamically change the - priority state of the VRRP group, and potentially - change the mastership if the tracked interface going - down lowers the priority sufficiently. Any of the tracked - interfaces going down will cause the priority to be lowered. - Some implementations may only support a single - tracked interface."; - } - - leaf priority-decrement { - type uint8 { - range 0..254; - } - default 0; - description "Set the value to subtract from priority when - the tracked interface goes down"; - } - } - - grouping ip-vrrp-tracking-state { - description - "Operational state data for tracking interfaces in a VRRP - group"; - } - - grouping ip-vrrp-tracking-top { - description - "Top-level grouping for VRRP interface tracking"; - - container interface-tracking { - description - "Top-level container for VRRP interface tracking"; - - container config { - description - "Configuration data for VRRP interface tracking"; - - uses ip-vrrp-tracking-config; - } - - container state { - - config false; - - description - "Operational state data for VRRP interface tracking"; - - uses ip-vrrp-tracking-config; - uses ip-vrrp-tracking-state; - } - } - } - - grouping ip-vrrp-config { - description - "Configuration data for VRRP on IP interfaces"; - - leaf virtual-router-id { - type uint8 { - range 1..255; - } - description - "Set the virtual router id for use by the VRRP group. This - usually also determines the virtual MAC address that is - generated for the VRRP group"; - } - - leaf-list virtual-address { - type oc-inet:ip-address; - description - "Configure one or more virtual addresses for the - VRRP group"; - } - - leaf priority { - type uint8 { - range 1..254; - } - default 100; - description - "Specifies the sending VRRP interface's priority - for the virtual router. Higher values equal higher - priority"; - } - - leaf preempt { - type boolean; - default true; - description - "When set to true, enables preemption by a higher - priority backup router of a lower priority master router"; - } - - leaf preempt-delay { - type uint16 { - range 0..3600; - } - default 0; - description - "Set the delay the higher priority router waits - before preempting"; - } - - leaf accept-mode { - type boolean; - // TODO: should we adopt the RFC default given the common - // operational practice of setting to true? - default false; - description - "Configure whether packets destined for - virtual addresses are accepted even when the virtual - address is not owned by the router interface"; - } - - leaf advertisement-interval { - type uint16 { - range 1..4095; - } - // TODO this range is theoretical -- needs to be validated - // against major implementations. - units "centiseconds"; - default 100; - description - "Sets the interval between successive VRRP - advertisements -- RFC 5798 defines this as a 12-bit - value expressed as 0.1 seconds, with default 100, i.e., - 1 second. Several implementation express this in units of - seconds"; - } - } - - grouping ip-vrrp-state { - description - "Operational state data for VRRP on IP interfaces"; - - leaf current-priority { - type uint8; - description "Operational value of the priority for the - interface in the VRRP group"; - } - } - - grouping ip-vrrp-top { - description - "Top-level grouping for Virtual Router Redundancy Protocol"; - - container vrrp { - description - "Enclosing container for VRRP groups handled by this - IP interface"; - - reference "RFC 5798 - Virtual Router Redundancy Protocol - (VRRP) Version 3 for IPv4 and IPv6"; - - list vrrp-group { - key "virtual-router-id"; - description - "List of VRRP groups, keyed by virtual router id"; - - leaf virtual-router-id { - type leafref { - path "../config/virtual-router-id"; - } - description - "References the configured virtual router id for this - VRRP group"; - } - - container config { - description - "Configuration data for the VRRP group"; - - uses ip-vrrp-config; - } - - container state { - - config false; - - description - "Operational state data for the VRRP group"; - - uses ip-vrrp-config; - uses ip-vrrp-state; - } - - uses ip-vrrp-tracking-top; - } - } - } - - grouping ipv6-ra-config { - description - "Configuration parameters for IPv6 router advertisements."; - - leaf interval { - type uint32; - units seconds; - description - "The interval between periodic router advertisement neighbor - discovery messages sent on this interface expressed in - seconds."; - } - - leaf lifetime { - type uint32; - units seconds; - description - "The lifetime advertised in the router advertisement neighbor - discovery message on this interface."; - } - - leaf suppress { - type boolean; - default false; - description - "When set to true, router advertisement neighbor discovery - messages are not transmitted on this interface."; - } - } - - grouping ipv4-proxy-arp-config { - description - "Configuration parameters for IPv4 proxy ARP"; - - leaf mode { - type enumeration { - enum DISABLE { - description - "The system should not respond to ARP requests that - do not specify an IP address configured on the local - subinterface as the target address."; - } - enum REMOTE_ONLY { - description - "The system responds to ARP requests only when the - sender and target IP addresses are in different - subnets."; - } - enum ALL { - description - "The system responds to ARP requests where the sender - and target IP addresses are in different subnets, as well - as those where they are in the same subnet."; - } - } - default "DISABLE"; - description - "When set to a value other than DISABLE, the local system should - respond to ARP requests that are for target addresses other than - those that are configured on the local subinterface using its own - MAC address as the target hardware address. If the REMOTE_ONLY - value is specified, replies are only sent when the target address - falls outside the locally configured subnets on the interface, - whereas with the ALL value, all requests, regardless of their - target address are replied to."; - reference "RFC1027: Using ARP to Implement Transparent Subnet Gateways"; - } - } - - grouping ipv4-top { - description "Top-level configuration and state for IPv4 - interfaces"; - - container ipv4 { - description - "Parameters for the IPv4 address family."; - - container addresses { - description - "Enclosing container for address list"; - - list address { - key "ip"; - description - "The list of configured IPv4 addresses on the interface."; - - leaf ip { - type leafref { - path "../config/ip"; - } - description "References the configured IP address"; - } - - container config { - description "Configuration data for each configured IPv4 - address on the interface"; - - uses ipv4-address-config; - - } - - container state { - - config false; - description "Operational state data for each IPv4 address - configured on the interface"; - - uses ipv4-address-config; - uses ipv4-address-state; - } - - } - } - - container proxy-arp { - description - "Configuration and operational state parameters - relating to proxy ARP. This functionality allows a - system to respond to ARP requests that are not - explicitly destined to the local system."; - - container config { - description - "Configuration parameters for proxy ARP"; - uses ipv4-proxy-arp-config; - } - - container state { - config false; - description - "Operational state parameters for proxy ARP"; - uses ipv4-proxy-arp-config; - } - } - - container neighbors { - description - "Enclosing container for neighbor list"; - - list neighbor { - key "ip"; - description - "A list of mappings from IPv4 addresses to - link-layer addresses. - - Entries in this list are used as static entries in the - ARP Cache."; - reference - "RFC 826: An Ethernet Address Resolution Protocol"; - - leaf ip { - type leafref { - path "../config/ip"; - } - description "References the configured IP address"; - } - - container config { - description "Configuration data for each configured IPv4 - address on the interface"; - - uses ipv4-neighbor-config; - - } - - container state { - - config false; - description "Operational state data for each IPv4 address - configured on the interface"; - - uses ipv4-neighbor-config; - uses ipv4-neighbor-state; - } - } - } - - uses oc-if:sub-unnumbered-top; - - container config { - description - "Top-level IPv4 configuration data for the interface"; - - uses ipv4-global-config; - } - - container state { - - config false; - description - "Top level IPv4 operational state data"; - - uses ipv4-global-config; - uses ip-common-counters-state; - } - } - } - - grouping ipv6-top { - description - "Top-level configuration and state for IPv6 interfaces"; - - container ipv6 { - description - "Parameters for the IPv6 address family."; - - container addresses { - description - "Enclosing container for address list"; - - list address { - key "ip"; - description - "The list of configured IPv6 addresses on the interface."; - - leaf ip { - type leafref { - path "../config/ip"; - } - description "References the configured IP address"; - } - - container config { - description - "Configuration data for each IPv6 address on - the interface"; - - uses ipv6-address-config; - - } - - container state { - - config false; - description - "State data for each IPv6 address on the - interface"; - - uses ipv6-address-config; - uses ipv6-address-state; - } - } - } - - container router-advertisement { - description - "Configuration and operational state parameters relating to - router advertisements."; - - container config { - description - "Configuration parameters relating to router advertisements - for IPv6."; - uses ipv6-ra-config; - } - - container state { - config false; - description - "Operational state parameters relating to router - advertisements for IPv6."; - uses ipv6-ra-config; - } - } - - container neighbors { - description - "Enclosing container for list of IPv6 neighbors"; - - list neighbor { - key "ip"; - description - "List of IPv6 neighbors"; - - leaf ip { - type leafref { - path "../config/ip"; - } - description - "References the configured IP neighbor address"; - } - - container config { - description "Configuration data for each IPv6 address on - the interface"; - - uses ipv6-neighbor-config; - - } - - container state { - - config false; - description "State data for each IPv6 address on the - interface"; - - uses ipv6-neighbor-config; - uses ipv6-neighbor-state; - } - } - } - uses oc-if:sub-unnumbered-top; - - container config { - description "Top-level config data for the IPv6 interface"; - - uses ipv6-global-config; - } - - container state { - config false; - description - "Top-level operational state data for the IPv6 interface"; - - uses ipv6-global-config; - uses ip-common-counters-state; - - } - } - } - - // augment statements - - augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + - "oc-if:subinterface" { - description - "IPv4 address family configuration for - interfaces"; - - uses ipv4-top; - - } - - augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + - "oc-if:subinterface" { - description - "IPv6 address family configuration for - interfaces"; - - uses ipv6-top; - - } - - // VRRP for IPv4 interfaces - - augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + - "oc-if:subinterface/oc-ip:ipv4/oc-ip:addresses/oc-ip:address" { - - description - "Additional IP addr family configuration for - interfaces"; - - uses ip-vrrp-top; - - } - - // VRRP for IPv6 interfaces - - augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + - "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address" { - description - "Additional IP addr family configuration for - interfaces"; - - uses ip-vrrp-top; - - } - - augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + - "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address/" + - "vrrp/vrrp-group/config" { - description - "Additional VRRP data for IPv6 interfaces"; - - uses ip-vrrp-ipv6-config; - } - - augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + - "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address/vrrp/" + - "vrrp-group/state" { - description - "Additional VRRP data for IPv6 interfaces"; - - uses ip-vrrp-ipv6-state; - } - - // Augments for for routed VLANs - - augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan" { - description - "IPv4 address family configuration for - interfaces"; - - uses ipv4-top; - } - - augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan" { - description - "IPv6 address family configuration for - interfaces"; - - uses ipv6-top; - } - - // VRRP for routed VLAN interfaces - - augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + - "oc-ip:ipv4/oc-ip:addresses/oc-ip:address" { - description - "Additional IP addr family configuration for - interfaces"; - - uses ip-vrrp-top; - - } - - augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + - "oc-ip:ipv6/oc-ip:addresses/oc-ip:address" { - description - "Additional IP addr family configuration for - interfaces"; - - uses ip-vrrp-top; - - } - - augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + - "oc-ip:ipv6/oc-ip:addresses/oc-ip:address/vrrp/vrrp-group/config" { - description - "Additional VRRP data for IPv6 interfaces"; - - uses ip-vrrp-ipv6-config; - } - - - augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + - "oc-ip:ipv6/oc-ip:addresses/oc-ip:address/vrrp/vrrp-group/state" { - description - "Additional VRRP data for IPv6 interfaces"; - - uses ip-vrrp-ipv6-state; - } - - // rpc statements - - // notification statements -} diff --git a/src/plugins/yang/openconfig/openconfig-if-ip@2018-01-05.yang b/src/plugins/yang/openconfig/openconfig-if-ip@2018-01-05.yang new file mode 100644 index 0000000..a20e21c --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-if-ip@2018-01-05.yang @@ -0,0 +1,1312 @@ +module openconfig-if-ip { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/interfaces/ip"; + + prefix "oc-ip"; + + // import some basic types + import openconfig-inet-types { prefix oc-inet; } + import openconfig-interfaces { prefix oc-if; } + import openconfig-vlan { prefix oc-vlan; } + import openconfig-yang-types { prefix oc-yang; } + import openconfig-extensions { prefix oc-ext; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "This model defines data for managing configuration and + operational state on IP (IPv4 and IPv6) interfaces. + + This model reuses data items defined in the IETF YANG model for + interfaces described by RFC 7277 with an alternate structure + (particularly for operational state data) and with + additional configuration items. + + Portions of this code were derived from IETF RFC 7277. + Please reproduce this note if possible. + + IETF code is subject to the following copyright and license: + Copyright (c) IETF Trust and the persons identified as authors of + the code. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, is permitted pursuant to, and subject to the license + terms contained in, the Simplified BSD License set forth in + Section 4.c of the IETF Trust's Legal Provisions Relating + to IETF Documents (http://trustee.ietf.org/license-info)."; + + oc-ext:openconfig-version "2.3.0"; + + revision "2018-01-05" { + description + "Add logical loopback to interface."; + reference "2.3.0"; + } + + revision "2017-12-21" { + description + "Added IPv6 router advertisement configuration."; + reference "2.1.0"; + } + + revision "2017-07-14" { + description + "Added Ethernet/IP state data; Add dhcp-client; + migrate to OpenConfig types modules; Removed or + renamed opstate values"; + reference "2.0.0"; + } + + revision "2017-04-03"{ + description + "Update copyright notice."; + reference "1.1.1"; + } + + revision "2016-12-22" { + description + "Fixes to Ethernet interfaces model"; + reference "1.1.0"; + } + + + // typedef statements + + typedef ip-address-origin { + type enumeration { + enum OTHER { + description + "None of the following."; + } + enum STATIC { + description + "Indicates that the address has been statically + configured - for example, using NETCONF or a Command Line + Interface."; + } + enum DHCP { + description + "Indicates an address that has been assigned to this + system by a DHCP server."; + } + enum LINK_LAYER { + description + "Indicates an address created by IPv6 stateless + autoconfiguration that embeds a link-layer address in its + interface identifier."; + } + enum RANDOM { + description + "Indicates an address chosen by the system at + random, e.g., an IPv4 address within 169.254/16, an + RFC 4941 temporary address, or an RFC 7217 semantically + opaque address."; + reference + "RFC 4941: Privacy Extensions for Stateless Address + Autoconfiguration in IPv6 + RFC 7217: A Method for Generating Semantically Opaque + Interface Identifiers with IPv6 Stateless + Address Autoconfiguration (SLAAC)"; + } + } + description + "The origin of an address."; + } + + typedef neighbor-origin { + type enumeration { + enum OTHER { + description + "None of the following."; + } + enum STATIC { + description + "Indicates that the mapping has been statically + configured - for example, using NETCONF or a Command Line + Interface."; + } + enum DYNAMIC { + description + "Indicates that the mapping has been dynamically resolved + using, e.g., IPv4 ARP or the IPv6 Neighbor Discovery + protocol."; + } + } + description + "The origin of a neighbor entry."; + } + + // grouping statements + + grouping ip-common-global-config { + description + "Shared configuration data for IPv4 or IPv6 assigned + globally on an interface."; + + leaf dhcp-client { + type boolean; + default false; + description + "Enables a DHCP client on the interface in order to request + an address"; + } + } + + grouping ip-common-counters-state { + description + "Operational state for IP traffic statistics for IPv4 and + IPv6"; + + container counters { + description + "Packet and byte counters for IP transmission and + reception for the address family."; + + + leaf in-pkts { + type oc-yang:counter64; + description + "The total number of IP packets received for the specified + address family, including those received in error"; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf in-octets { + type oc-yang:counter64; + description + "The total number of octets received in input IP packets + for the specified address family, including those received + in error."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf in-error-pkts { + // TODO: this counter combines several error conditions -- + // could consider breaking them out to separate leaf nodes + type oc-yang:counter64; + description + "Number of IP packets discarded due to errors for the + specified address family, including errors in the IP + header, no route found to the IP destination, invalid + address, unknown protocol, etc."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf in-forwarded-pkts { + type oc-yang:counter64; + description + "The number of input packets for which the device was not + their final IP destination and for which the device + attempted to find a route to forward them to that final + destination."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf in-forwarded-octets { + type oc-yang:counter64; + description + "The number of octets received in input IP packets + for the specified address family for which the device was + not their final IP destination and for which the + device attempted to find a route to forward them to that + final destination."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf in-discarded-pkts { + type oc-yang:counter64; + description + "The number of input IP packets for the + specified address family, for which no problems were + encountered to prevent their continued processing, but + were discarded (e.g., for lack of buffer space)."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf out-pkts { + type oc-yang:counter64; + description + "The total number of IP packets for the + specified address family that the device supplied + to the lower layers for transmission. This includes + packets generated locally and those forwarded by the + device."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf out-octets { + type oc-yang:counter64; + description + "The total number of octets in IP packets for the + specified address family that the device + supplied to the lower layers for transmission. This + includes packets generated locally and those forwarded by + the device."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf out-error-pkts { + // TODO: this counter combines several error conditions -- + // could consider breaking them out to separate leaf nodes + type oc-yang:counter64; + description + "Number of IP packets for the specified address family + locally generated and discarded due to errors, including + no route found to the IP destination."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf out-forwarded-pkts { + type oc-yang:counter64; + description + "The number of packets for which this entity was not their + final IP destination and for which it was successful in + finding a path to their final destination."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf out-forwarded-octets { + type oc-yang:counter64; + description + "The number of octets in packets for which this entity was + not their final IP destination and for which it was + successful in finding a path to their final destination."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + + leaf out-discarded-pkts { + type oc-yang:counter64; + description + "The number of output IP packets for the + specified address family for which no problem was + encountered to prevent their transmission to their + destination, but were discarded (e.g., for lack of + buffer space)."; + reference + "RFC 4293 - Management Information Base for the + Internet Protocol (IP)"; + } + } + + } + + + + grouping ipv4-global-config { + description + "Configuration data for IPv4 interfaces across + all addresses assigned to the interface"; + + leaf enabled { + type boolean; + default true; + description + "Controls whether IPv4 is enabled or disabled on this + interface. When IPv4 is enabled, this interface is + connected to an IPv4 stack, and the interface can send + and receive IPv4 packets."; + } + + leaf mtu { + type uint16 { + range "68..max"; + } + units octets; + description + "The size, in octets, of the largest IPv4 packet that the + interface will send and receive. + + The server may restrict the allowed values for this leaf, + depending on the interface's type. + + If this leaf is not configured, the operationally used MTU + depends on the interface's type."; + reference + "RFC 791: Internet Protocol"; + } + + uses ip-common-global-config; + + + } + + grouping ipv4-address-config { + + description + "Per IPv4 adresss configuration data for the + interface."; + + leaf ip { + type oc-inet:ipv4-address; + description + "The IPv4 address on the interface."; + } + + leaf prefix-length { + type uint8 { + range "0..32"; + } + description + "The length of the subnet prefix."; + } + } + + grouping ipv4-neighbor-config { + description + "Per IPv4 neighbor configuration data. Neighbor + entries are analagous to static ARP entries, i.e., they + create a correspondence between IP and link-layer addresses"; + + leaf ip { + type oc-inet:ipv4-address; + description + "The IPv4 address of the neighbor node."; + } + leaf link-layer-address { + type oc-yang:phys-address; + mandatory true; + description + "The link-layer address of the neighbor node."; + } + } + + grouping ipv4-address-state { + description + "State variables for IPv4 addresses on the interface"; + + leaf origin { + type ip-address-origin; + description + "The origin of this address, e.g., statically configured, + assigned by DHCP, etc.."; + } + } + + grouping ipv4-neighbor-state { + description + "State variables for IPv4 neighbor entries on the interface."; + + leaf origin { + type neighbor-origin; + description + "The origin of this neighbor entry, static or dynamic."; + } + } + + grouping ipv6-global-config { + description + "Configuration data at the global level for each + IPv6 interface"; + + leaf enabled { + type boolean; + default true; + description + "Controls whether IPv6 is enabled or disabled on this + interface. When IPv6 is enabled, this interface is + connected to an IPv6 stack, and the interface can send + and receive IPv6 packets."; + } + + leaf mtu { + type uint32 { + range "1280..max"; + } + units octets; + description + "The size, in octets, of the largest IPv6 packet that the + interface will send and receive. + + The server may restrict the allowed values for this leaf, + depending on the interface's type. + + If this leaf is not configured, the operationally used MTU + depends on the interface's type."; + reference + "RFC 2460: Internet Protocol, Version 6 (IPv6) Specification + Section 5"; + } + + leaf dup-addr-detect-transmits { + type uint32; + default 1; + description + "The number of consecutive Neighbor Solicitation messages + sent while performing Duplicate Address Detection on a + tentative address. A value of zero indicates that + Duplicate Address Detection is not performed on + tentative addresses. A value of one indicates a single + transmission with no follow-up retransmissions."; + reference + "RFC 4862: IPv6 Stateless Address Autoconfiguration"; + } + + uses ip-common-global-config; + } + + grouping ipv6-address-config { + description "Per-address configuration data for IPv6 interfaces"; + + leaf ip { + type oc-inet:ipv6-address; + description + "The IPv6 address on the interface."; + } + + leaf prefix-length { + type uint8 { + range "0..128"; + } + mandatory true; + description + "The length of the subnet prefix."; + } + } + + grouping ipv6-address-state { + description + "Per-address operational state data for IPv6 interfaces"; + + leaf origin { + type ip-address-origin; + description + "The origin of this address, e.g., static, dhcp, etc."; + } + + leaf status { + type enumeration { + enum PREFERRED { + description + "This is a valid address that can appear as the + destination or source address of a packet."; + } + enum DEPRECATED { + description + "This is a valid but deprecated address that should + no longer be used as a source address in new + communications, but packets addressed to such an + address are processed as expected."; + } + enum INVALID { + description + "This isn't a valid address, and it shouldn't appear + as the destination or source address of a packet."; + } + enum INACCESSIBLE { + description + "The address is not accessible because the interface + to which this address is assigned is not + operational."; + } + enum UNKNOWN { + description + "The status cannot be determined for some reason."; + } + enum TENTATIVE { + description + "The uniqueness of the address on the link is being + verified. Addresses in this state should not be + used for general communication and should only be + used to determine the uniqueness of the address."; + } + enum DUPLICATE { + description + "The address has been determined to be non-unique on + the link and so must not be used."; + } + enum OPTIMISTIC { + description + "The address is available for use, subject to + restrictions, while its uniqueness on a link is + being verified."; + } + } + description + "The status of an address. Most of the states correspond + to states from the IPv6 Stateless Address + Autoconfiguration protocol."; + reference + "RFC 4293: Management Information Base for the + Internet Protocol (IP) + - IpAddressStatusTC + RFC 4862: IPv6 Stateless Address Autoconfiguration"; + } + } + + grouping ipv6-neighbor-config { + description + "Per-neighbor configuration data for IPv6 interfaces"; + + leaf ip { + type oc-inet:ipv6-address; + description + "The IPv6 address of the neighbor node."; + } + + leaf link-layer-address { + type oc-yang:phys-address; + mandatory true; + description + "The link-layer address of the neighbor node."; + } + } + + grouping ipv6-neighbor-state { + description "Per-neighbor state variables for IPv6 interfaces"; + + leaf origin { + type neighbor-origin; + description + "The origin of this neighbor entry."; + } + leaf is-router { + type empty; + description + "Indicates that the neighbor node acts as a router."; + } + leaf neighbor-state { + type enumeration { + enum INCOMPLETE { + description + "Address resolution is in progress, and the link-layer + address of the neighbor has not yet been + determined."; + } + enum REACHABLE { + description + "Roughly speaking, the neighbor is known to have been + reachable recently (within tens of seconds ago)."; + } + enum STALE { + description + "The neighbor is no longer known to be reachable, but + until traffic is sent to the neighbor no attempt + should be made to verify its reachability."; + } + enum DELAY { + description + "The neighbor is no longer known to be reachable, and + traffic has recently been sent to the neighbor. + Rather than probe the neighbor immediately, however, + delay sending probes for a short while in order to + give upper-layer protocols a chance to provide + reachability confirmation."; + } + enum PROBE { + description + "The neighbor is no longer known to be reachable, and + unicast Neighbor Solicitation probes are being sent + to verify reachability."; + } + } + description + "The Neighbor Unreachability Detection state of this + entry."; + reference + "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) + Section 7.3.2"; + } + } + + grouping ip-vrrp-ipv6-config { + description + "IPv6-specific configuration data for VRRP on IPv6 + interfaces"; + + leaf virtual-link-local { + type oc-inet:ip-address; + description + "For VRRP on IPv6 interfaces, sets the virtual link local + address"; + } + } + + grouping ip-vrrp-ipv6-state { + description + "IPv6-specific operational state for VRRP on IPv6 interfaces"; + + uses ip-vrrp-ipv6-config; + } + + grouping ip-vrrp-tracking-config { + description + "Configuration data for tracking interfaces + in a VRRP group"; + + leaf-list track-interface { + type leafref { + path "/oc-if:interfaces/oc-if:interface/oc-if:name"; + } + // TODO: we may need to add some restriction to ethernet + // or IP interfaces. + description + "Sets a list of one or more interfaces that should + be tracked for up/down events to dynamically change the + priority state of the VRRP group, and potentially + change the mastership if the tracked interface going + down lowers the priority sufficiently. Any of the tracked + interfaces going down will cause the priority to be lowered. + Some implementations may only support a single + tracked interface."; + } + + leaf priority-decrement { + type uint8 { + range 0..254; + } + default 0; + description "Set the value to subtract from priority when + the tracked interface goes down"; + } + } + + grouping ip-vrrp-tracking-state { + description + "Operational state data for tracking interfaces in a VRRP + group"; + } + + grouping ip-vrrp-tracking-top { + description + "Top-level grouping for VRRP interface tracking"; + + container interface-tracking { + description + "Top-level container for VRRP interface tracking"; + + container config { + description + "Configuration data for VRRP interface tracking"; + + uses ip-vrrp-tracking-config; + } + + container state { + + config false; + + description + "Operational state data for VRRP interface tracking"; + + uses ip-vrrp-tracking-config; + uses ip-vrrp-tracking-state; + } + } + } + + grouping ip-vrrp-config { + description + "Configuration data for VRRP on IP interfaces"; + + leaf virtual-router-id { + type uint8 { + range 1..255; + } + description + "Set the virtual router id for use by the VRRP group. This + usually also determines the virtual MAC address that is + generated for the VRRP group"; + } + + leaf-list virtual-address { + type oc-inet:ip-address; + description + "Configure one or more virtual addresses for the + VRRP group"; + } + + leaf priority { + type uint8 { + range 1..254; + } + default 100; + description + "Specifies the sending VRRP interface's priority + for the virtual router. Higher values equal higher + priority"; + } + + leaf preempt { + type boolean; + default true; + description + "When set to true, enables preemption by a higher + priority backup router of a lower priority master router"; + } + + leaf preempt-delay { + type uint16 { + range 0..3600; + } + default 0; + description + "Set the delay the higher priority router waits + before preempting"; + } + + leaf accept-mode { + type boolean; + // TODO: should we adopt the RFC default given the common + // operational practice of setting to true? + default false; + description + "Configure whether packets destined for + virtual addresses are accepted even when the virtual + address is not owned by the router interface"; + } + + leaf advertisement-interval { + type uint16 { + range 1..4095; + } + // TODO this range is theoretical -- needs to be validated + // against major implementations. + units "centiseconds"; + default 100; + description + "Sets the interval between successive VRRP + advertisements -- RFC 5798 defines this as a 12-bit + value expressed as 0.1 seconds, with default 100, i.e., + 1 second. Several implementation express this in units of + seconds"; + } + } + + grouping ip-vrrp-state { + description + "Operational state data for VRRP on IP interfaces"; + + leaf current-priority { + type uint8; + description "Operational value of the priority for the + interface in the VRRP group"; + } + } + + grouping ip-vrrp-top { + description + "Top-level grouping for Virtual Router Redundancy Protocol"; + + container vrrp { + description + "Enclosing container for VRRP groups handled by this + IP interface"; + + reference "RFC 5798 - Virtual Router Redundancy Protocol + (VRRP) Version 3 for IPv4 and IPv6"; + + list vrrp-group { + key "virtual-router-id"; + description + "List of VRRP groups, keyed by virtual router id"; + + leaf virtual-router-id { + type leafref { + path "../config/virtual-router-id"; + } + description + "References the configured virtual router id for this + VRRP group"; + } + + container config { + description + "Configuration data for the VRRP group"; + + uses ip-vrrp-config; + } + + container state { + + config false; + + description + "Operational state data for the VRRP group"; + + uses ip-vrrp-config; + uses ip-vrrp-state; + } + + uses ip-vrrp-tracking-top; + } + } + } + + grouping ipv6-ra-config { + description + "Configuration parameters for IPv6 router advertisements."; + + leaf interval { + type uint32; + units seconds; + description + "The interval between periodic router advertisement neighbor + discovery messages sent on this interface expressed in + seconds."; + } + + leaf lifetime { + type uint32; + units seconds; + description + "The lifetime advertised in the router advertisement neighbor + discovery message on this interface."; + } + + leaf suppress { + type boolean; + default false; + description + "When set to true, router advertisement neighbor discovery + messages are not transmitted on this interface."; + } + } + + grouping ipv4-proxy-arp-config { + description + "Configuration parameters for IPv4 proxy ARP"; + + leaf mode { + type enumeration { + enum DISABLE { + description + "The system should not respond to ARP requests that + do not specify an IP address configured on the local + subinterface as the target address."; + } + enum REMOTE_ONLY { + description + "The system responds to ARP requests only when the + sender and target IP addresses are in different + subnets."; + } + enum ALL { + description + "The system responds to ARP requests where the sender + and target IP addresses are in different subnets, as well + as those where they are in the same subnet."; + } + } + default "DISABLE"; + description + "When set to a value other than DISABLE, the local system should + respond to ARP requests that are for target addresses other than + those that are configured on the local subinterface using its own + MAC address as the target hardware address. If the REMOTE_ONLY + value is specified, replies are only sent when the target address + falls outside the locally configured subnets on the interface, + whereas with the ALL value, all requests, regardless of their + target address are replied to."; + reference "RFC1027: Using ARP to Implement Transparent Subnet Gateways"; + } + } + + grouping ipv4-top { + description "Top-level configuration and state for IPv4 + interfaces"; + + container ipv4 { + description + "Parameters for the IPv4 address family."; + + container addresses { + description + "Enclosing container for address list"; + + list address { + key "ip"; + description + "The list of configured IPv4 addresses on the interface."; + + leaf ip { + type leafref { + path "../config/ip"; + } + description "References the configured IP address"; + } + + container config { + description "Configuration data for each configured IPv4 + address on the interface"; + + uses ipv4-address-config; + + } + + container state { + + config false; + description "Operational state data for each IPv4 address + configured on the interface"; + + uses ipv4-address-config; + uses ipv4-address-state; + } + + } + } + + container proxy-arp { + description + "Configuration and operational state parameters + relating to proxy ARP. This functionality allows a + system to respond to ARP requests that are not + explicitly destined to the local system."; + + container config { + description + "Configuration parameters for proxy ARP"; + uses ipv4-proxy-arp-config; + } + + container state { + config false; + description + "Operational state parameters for proxy ARP"; + uses ipv4-proxy-arp-config; + } + } + + container neighbors { + description + "Enclosing container for neighbor list"; + + list neighbor { + key "ip"; + description + "A list of mappings from IPv4 addresses to + link-layer addresses. + + Entries in this list are used as static entries in the + ARP Cache."; + reference + "RFC 826: An Ethernet Address Resolution Protocol"; + + leaf ip { + type leafref { + path "../config/ip"; + } + description "References the configured IP address"; + } + + container config { + description "Configuration data for each configured IPv4 + address on the interface"; + + uses ipv4-neighbor-config; + + } + + container state { + + config false; + description "Operational state data for each IPv4 address + configured on the interface"; + + uses ipv4-neighbor-config; + uses ipv4-neighbor-state; + } + } + } + + uses oc-if:sub-unnumbered-top; + + container config { + description + "Top-level IPv4 configuration data for the interface"; + + uses ipv4-global-config; + } + + container state { + + config false; + description + "Top level IPv4 operational state data"; + + uses ipv4-global-config; + uses ip-common-counters-state; + } + } + } + + grouping ipv6-top { + description + "Top-level configuration and state for IPv6 interfaces"; + + container ipv6 { + description + "Parameters for the IPv6 address family."; + + container addresses { + description + "Enclosing container for address list"; + + list address { + key "ip"; + description + "The list of configured IPv6 addresses on the interface."; + + leaf ip { + type leafref { + path "../config/ip"; + } + description "References the configured IP address"; + } + + container config { + description + "Configuration data for each IPv6 address on + the interface"; + + uses ipv6-address-config; + + } + + container state { + + config false; + description + "State data for each IPv6 address on the + interface"; + + uses ipv6-address-config; + uses ipv6-address-state; + } + } + } + + container router-advertisement { + description + "Configuration and operational state parameters relating to + router advertisements."; + + container config { + description + "Configuration parameters relating to router advertisements + for IPv6."; + uses ipv6-ra-config; + } + + container state { + config false; + description + "Operational state parameters relating to router + advertisements for IPv6."; + uses ipv6-ra-config; + } + } + + container neighbors { + description + "Enclosing container for list of IPv6 neighbors"; + + list neighbor { + key "ip"; + description + "List of IPv6 neighbors"; + + leaf ip { + type leafref { + path "../config/ip"; + } + description + "References the configured IP neighbor address"; + } + + container config { + description "Configuration data for each IPv6 address on + the interface"; + + uses ipv6-neighbor-config; + + } + + container state { + + config false; + description "State data for each IPv6 address on the + interface"; + + uses ipv6-neighbor-config; + uses ipv6-neighbor-state; + } + } + } + uses oc-if:sub-unnumbered-top; + + container config { + description "Top-level config data for the IPv6 interface"; + + uses ipv6-global-config; + } + + container state { + config false; + description + "Top-level operational state data for the IPv6 interface"; + + uses ipv6-global-config; + uses ip-common-counters-state; + + } + } + } + + // augment statements + + augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + + "oc-if:subinterface" { + description + "IPv4 address family configuration for + interfaces"; + + uses ipv4-top; + + } + + augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + + "oc-if:subinterface" { + description + "IPv6 address family configuration for + interfaces"; + + uses ipv6-top; + + } + + // VRRP for IPv4 interfaces + + augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + + "oc-if:subinterface/oc-ip:ipv4/oc-ip:addresses/oc-ip:address" { + + description + "Additional IP addr family configuration for + interfaces"; + + uses ip-vrrp-top; + + } + + // VRRP for IPv6 interfaces + + augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + + "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address" { + description + "Additional IP addr family configuration for + interfaces"; + + uses ip-vrrp-top; + + } + + augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + + "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address/" + + "vrrp/vrrp-group/config" { + description + "Additional VRRP data for IPv6 interfaces"; + + uses ip-vrrp-ipv6-config; + } + + augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" + + "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address/vrrp/" + + "vrrp-group/state" { + description + "Additional VRRP data for IPv6 interfaces"; + + uses ip-vrrp-ipv6-state; + } + + // Augments for for routed VLANs + + augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan" { + description + "IPv4 address family configuration for + interfaces"; + + uses ipv4-top; + } + + augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan" { + description + "IPv6 address family configuration for + interfaces"; + + uses ipv6-top; + } + + // VRRP for routed VLAN interfaces + + augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + + "oc-ip:ipv4/oc-ip:addresses/oc-ip:address" { + description + "Additional IP addr family configuration for + interfaces"; + + uses ip-vrrp-top; + + } + + augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + + "oc-ip:ipv6/oc-ip:addresses/oc-ip:address" { + description + "Additional IP addr family configuration for + interfaces"; + + uses ip-vrrp-top; + + } + + augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + + "oc-ip:ipv6/oc-ip:addresses/oc-ip:address/vrrp/vrrp-group/config" { + description + "Additional VRRP data for IPv6 interfaces"; + + uses ip-vrrp-ipv6-config; + } + + + augment "/oc-if:interfaces/oc-if:interface/oc-vlan:routed-vlan/" + + "oc-ip:ipv6/oc-ip:addresses/oc-ip:address/vrrp/vrrp-group/state" { + description + "Additional VRRP data for IPv6 interfaces"; + + uses ip-vrrp-ipv6-state; + } + + // rpc statements + + // notification statements +} diff --git a/src/plugins/yang/openconfig/openconfig-if-types.yang b/src/plugins/yang/openconfig/openconfig-if-types.yang deleted file mode 100644 index 3743878..0000000 --- a/src/plugins/yang/openconfig/openconfig-if-types.yang +++ /dev/null @@ -1,98 +0,0 @@ -module openconfig-if-types { - yang-version "1"; - - namespace "http://openconfig.net/yang/openconfig-if-types"; - - prefix "oc-ift"; - - // import statements - import openconfig-extensions { prefix oc-ext; } - - // meta - organization - "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "This module contains a set of interface type definitions that - are used across OpenConfig models. These are generally physical - or logical interfaces, distinct from hardware ports (which are - described by the OpenConfig platform model)."; - - oc-ext:openconfig-version "0.2.0"; - - revision "2018-01-05" { - description - "Add tunnel types into the INTERFACE_TYPE identity."; - reference "0.2.0"; - } - - revision "2016-11-14" { - description - "Initial version"; - reference "0.1.0"; - } - - - identity INTERFACE_TYPE { - description - "Base identity from which interface types are derived."; - } - - identity IF_ETHERNET { - base INTERFACE_TYPE; - description - "Ethernet interfaces based on IEEE 802.3 standards, as well - as FlexEthernet"; - reference - "IEEE 802.3-2015 - IEEE Standard for Ethernet - OIF Flex Ethernet Implementation Agreement 1.0"; - } - - identity IF_AGGREGATE { - base INTERFACE_TYPE; - description - "An aggregated, or bonded, interface forming a - Link Aggregation Group (LAG), or bundle, most often based on - the IEEE 802.1AX (or 802.3ad) standard."; - reference - "IEEE 802.1AX-2008"; - } - - identity IF_LOOPBACK { - base INTERFACE_TYPE; - description - "A virtual interface designated as a loopback used for - various management and operations tasks."; - } - - identity IF_ROUTED_VLAN { - base INTERFACE_TYPE; - description - "A logical interface used for routing services on a VLAN. - Such interfaces are also known as switch virtual interfaces - (SVI) or integrated routing and bridging interfaces (IRBs)."; - } - - identity IF_SONET { - base INTERFACE_TYPE; - description - "SONET/SDH interface"; - } - - identity IF_TUNNEL_GRE4 { - base INTERFACE_TYPE; - description - "A GRE tunnel over IPv4 transport."; - } - - identity IF_TUNNEL_GRE6 { - base INTERFACE_TYPE; - description - "A GRE tunnel over IPv6 transport."; - } - -} diff --git a/src/plugins/yang/openconfig/openconfig-if-types@2018-01-05.yang b/src/plugins/yang/openconfig/openconfig-if-types@2018-01-05.yang new file mode 100644 index 0000000..3743878 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-if-types@2018-01-05.yang @@ -0,0 +1,98 @@ +module openconfig-if-types { + yang-version "1"; + + namespace "http://openconfig.net/yang/openconfig-if-types"; + + prefix "oc-ift"; + + // import statements + import openconfig-extensions { prefix oc-ext; } + + // meta + organization + "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "This module contains a set of interface type definitions that + are used across OpenConfig models. These are generally physical + or logical interfaces, distinct from hardware ports (which are + described by the OpenConfig platform model)."; + + oc-ext:openconfig-version "0.2.0"; + + revision "2018-01-05" { + description + "Add tunnel types into the INTERFACE_TYPE identity."; + reference "0.2.0"; + } + + revision "2016-11-14" { + description + "Initial version"; + reference "0.1.0"; + } + + + identity INTERFACE_TYPE { + description + "Base identity from which interface types are derived."; + } + + identity IF_ETHERNET { + base INTERFACE_TYPE; + description + "Ethernet interfaces based on IEEE 802.3 standards, as well + as FlexEthernet"; + reference + "IEEE 802.3-2015 - IEEE Standard for Ethernet + OIF Flex Ethernet Implementation Agreement 1.0"; + } + + identity IF_AGGREGATE { + base INTERFACE_TYPE; + description + "An aggregated, or bonded, interface forming a + Link Aggregation Group (LAG), or bundle, most often based on + the IEEE 802.1AX (or 802.3ad) standard."; + reference + "IEEE 802.1AX-2008"; + } + + identity IF_LOOPBACK { + base INTERFACE_TYPE; + description + "A virtual interface designated as a loopback used for + various management and operations tasks."; + } + + identity IF_ROUTED_VLAN { + base INTERFACE_TYPE; + description + "A logical interface used for routing services on a VLAN. + Such interfaces are also known as switch virtual interfaces + (SVI) or integrated routing and bridging interfaces (IRBs)."; + } + + identity IF_SONET { + base INTERFACE_TYPE; + description + "SONET/SDH interface"; + } + + identity IF_TUNNEL_GRE4 { + base INTERFACE_TYPE; + description + "A GRE tunnel over IPv4 transport."; + } + + identity IF_TUNNEL_GRE6 { + base INTERFACE_TYPE; + description + "A GRE tunnel over IPv6 transport."; + } + +} diff --git a/src/plugins/yang/openconfig/openconfig-inet-types.yang b/src/plugins/yang/openconfig/openconfig-inet-types.yang deleted file mode 100644 index fbb872f..0000000 --- a/src/plugins/yang/openconfig/openconfig-inet-types.yang +++ /dev/null @@ -1,332 +0,0 @@ -module openconfig-inet-types { - - yang-version "1"; - namespace "http://openconfig.net/yang/types/inet"; - prefix "oc-inet"; - - import openconfig-extensions { prefix "oc-ext"; } - - organization - "OpenConfig working group"; - - contact - "OpenConfig working group - www.openconfig.net"; - - description - "This module contains a set of Internet address related - types for use in OpenConfig modules. - - Portions of this code were derived from IETF RFC 6021. - Please reproduce this note if possible. - - IETF code is subject to the following copyright and license: - Copyright (c) IETF Trust and the persons identified as authors of - the code. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in - Section 4.c of the IETF Trust's Legal Provisions Relating - to IETF Documents (http://trustee.ietf.org/license-info)."; - - oc-ext:openconfig-version "0.3.1"; - - revision 2017-08-24 { - description - "Minor formatting fixes."; - reference "0.3.1"; - } - - revision 2017-07-06 { - description - "Add domain-name and host typedefs"; - reference "0.3.0"; - } - - revision 2017-04-03 { - description - "Add ip-version typedef."; - reference "0.2.0"; - } - - revision 2017-04-03 { - description - "Update copyright notice."; - reference "0.1.1"; - } - - revision 2017-01-26 { - description - "Initial module for inet types"; - reference "0.1.0"; - } - - // IPv4 and IPv6 types. - - typedef ipv4-address { - type string { - pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + - '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + - '[0-9]|25[0-5])'; - } - description - "An IPv4 address in dotted quad notation using the default - zone."; - } - - typedef ipv4-address-zoned { - type string { - pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + - '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + - '[0-9]|25[0-5])(%[a-zA-Z0-9_]+)$'; - } - description - "An IPv4 address in dotted quad notation. This type allows - specification of a zone index to disambiguate identical - address values. For link-local addresses, the index is - typically the interface index or interface name."; - } - - typedef ipv6-address { - type string { - pattern - // Must support compression through different lengths - // therefore this regexp is complex. - '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + - '([0-9a-fA-F]{1,4}:){1,7}:|' + - '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + - '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + - '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + - '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + - '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + - '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + - ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + - ')$'; - } - description - "An IPv6 address represented as either a full address; shortened - or mixed-shortened formats, using the default zone."; - } - - typedef ipv6-address-zoned { - type string { - pattern - // Must support compression through different lengths - // therefore this regexp is complex. - '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + - '([0-9a-fA-F]{1,4}:){1,7}:|' + - '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + - '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + - '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + - '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + - '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + - '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + - ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + - ')(%[a-zA-Z0-9_]+)$'; - } - description - "An IPv6 address represented as either a full address; shortened - or mixed-shortened formats. This type allows specification of - a zone index to disambiguate identical address values. For - link-local addresses, the index is typically the interface - index or interface name."; - } - - typedef ipv4-prefix { - type string { - pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + - '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + - '[0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'; - } - description - "An IPv4 prefix represented in dotted quad notation followed by - a slash and a CIDR mask (0 <= mask <= 32)."; - } - - typedef ipv6-prefix { - type string { - pattern - '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + - '([0-9a-fA-F]{1,4}:){1,7}:|' + - '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}' + - '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + - '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + - '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + - '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + - '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + - ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + - ')/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$'; - } - description - "An IPv6 prefix represented in full, shortened, or mixed - shortened format followed by a slash and CIDR mask - (0 <= mask <= 128)."; - } - - typedef ip-address { - type union { - type ipv4-address; - type ipv6-address; - } - description - "An IPv4 or IPv6 address with no prefix specified."; - } - - typedef ip-prefix { - type union { - type ipv4-prefix; - type ipv6-prefix; - } - description - "An IPv4 or IPv6 prefix."; - } - - typedef ip-version { - type enumeration { - enum UNKNOWN { - value 0; - description - "An unknown or unspecified version of the Internet - protocol."; - } - enum IPV4 { - value 4; - description - "The IPv4 protocol as defined in RFC 791."; - } - enum IPV6 { - value 6; - description - "The IPv6 protocol as defined in RFC 2460."; - } - } - description - "This value represents the version of the IP protocol. - Note that integer representation of the enumerated values - are not specified, and are not required to follow the - InetVersion textual convention in SMIv2."; - reference - "RFC 791: Internet Protocol - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - typedef domain-name { - type string { - length "1..253"; - pattern - '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + - '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + - '|\.'; - } - description - "The domain-name type represents a DNS domain name. - Fully quallified left to the models which utilize this type. - - Internet domain names are only loosely specified. Section - 3.5 of RFC 1034 recommends a syntax (modified in Section - 2.1 of RFC 1123). The pattern above is intended to allow - for current practice in domain name use, and some possible - future expansion. It is designed to hold various types of - domain names, including names used for A or AAAA records - (host names) and other records, such as SRV records. Note - that Internet host names have a stricter syntax (described - in RFC 952) than the DNS recommendations in RFCs 1034 and - 1123, and that systems that want to store host names in - schema nodes using the domain-name type are recommended to - adhere to this stricter standard to ensure interoperability. - - The encoding of DNS names in the DNS protocol is limited - to 255 characters. Since the encoding consists of labels - prefixed by a length bytes and there is a trailing NULL - byte, only 253 characters can appear in the textual dotted - notation. - - Domain-name values use the US-ASCII encoding. Their canonical - format uses lowercase US-ASCII characters. Internationalized - domain names MUST be encoded in punycode as described in RFC - 3492"; - } - - typedef host { - type union { - type ip-address; - type domain-name; - } - description - "The host type represents either an unzoned IP address or a DNS - domain name."; - } - - typedef as-number { - type uint32; - description - "A numeric identifier for an autonomous system (AS). An AS is a - single domain, under common administrative control, which forms - a unit of routing policy. Autonomous systems can be assigned a - 2-byte identifier, or a 4-byte identifier which may have public - or private scope. Private ASNs are assigned from dedicated - ranges. Public ASNs are assigned from ranges allocated by IANA - to the regional internet registries (RIRs)."; - reference - "RFC 1930 Guidelines for creation, selection, and registration - of an Autonomous System (AS) - RFC 4271 A Border Gateway Protocol 4 (BGP-4)"; - } - - typedef dscp { - type uint8 { - range "0..63"; - } - description - "A differentiated services code point (DSCP) marking within the - IP header."; - reference - "RFC 2474 Definition of the Differentiated Services Field - (DS Field) in the IPv4 and IPv6 Headers"; - } - - typedef ipv6-flow-label { - type uint32 { - range "0..1048575"; - } - description - "The IPv6 flow-label is a 20-bit value within the IPv6 header - which is optionally used by the source of the IPv6 packet to - label sets of packets for which special handling may be - required."; - reference - "RFC 2460 Internet Protocol, Version 6 (IPv6) Specification"; - } - - typedef port-number { - type uint16; - description - "A 16-bit port number used by a transport protocol such as TCP - or UDP."; - reference - "RFC 768 User Datagram Protocol - RFC 793 Transmission Control Protocol"; - } - - typedef uri { - type string; - description - "An ASCII-encoded Uniform Resource Identifier (URI) as defined - in RFC 3986."; - reference - "RFC 3986 Uniform Resource Identifier (URI): Generic Syntax"; - } - - typedef url { - type string; - description - "An ASCII-encoded Uniform Resource Locator (URL) as defined - in RFC 3986, section 1.1.3"; - reference - "RFC 3986, paragraph 1.1.3"; - } - -} diff --git a/src/plugins/yang/openconfig/openconfig-inet-types@2017-08-24.yang b/src/plugins/yang/openconfig/openconfig-inet-types@2017-08-24.yang new file mode 100644 index 0000000..fbb872f --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-inet-types@2017-08-24.yang @@ -0,0 +1,332 @@ +module openconfig-inet-types { + + yang-version "1"; + namespace "http://openconfig.net/yang/types/inet"; + prefix "oc-inet"; + + import openconfig-extensions { prefix "oc-ext"; } + + organization + "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module contains a set of Internet address related + types for use in OpenConfig modules. + + Portions of this code were derived from IETF RFC 6021. + Please reproduce this note if possible. + + IETF code is subject to the following copyright and license: + Copyright (c) IETF Trust and the persons identified as authors of + the code. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, is permitted pursuant to, and subject to the license + terms contained in, the Simplified BSD License set forth in + Section 4.c of the IETF Trust's Legal Provisions Relating + to IETF Documents (http://trustee.ietf.org/license-info)."; + + oc-ext:openconfig-version "0.3.1"; + + revision 2017-08-24 { + description + "Minor formatting fixes."; + reference "0.3.1"; + } + + revision 2017-07-06 { + description + "Add domain-name and host typedefs"; + reference "0.3.0"; + } + + revision 2017-04-03 { + description + "Add ip-version typedef."; + reference "0.2.0"; + } + + revision 2017-04-03 { + description + "Update copyright notice."; + reference "0.1.1"; + } + + revision 2017-01-26 { + description + "Initial module for inet types"; + reference "0.1.0"; + } + + // IPv4 and IPv6 types. + + typedef ipv4-address { + type string { + pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + + '[0-9]|25[0-5])'; + } + description + "An IPv4 address in dotted quad notation using the default + zone."; + } + + typedef ipv4-address-zoned { + type string { + pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + + '[0-9]|25[0-5])(%[a-zA-Z0-9_]+)$'; + } + description + "An IPv4 address in dotted quad notation. This type allows + specification of a zone index to disambiguate identical + address values. For link-local addresses, the index is + typically the interface index or interface name."; + } + + typedef ipv6-address { + type string { + pattern + // Must support compression through different lengths + // therefore this regexp is complex. + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')$'; + } + description + "An IPv6 address represented as either a full address; shortened + or mixed-shortened formats, using the default zone."; + } + + typedef ipv6-address-zoned { + type string { + pattern + // Must support compression through different lengths + // therefore this regexp is complex. + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')(%[a-zA-Z0-9_]+)$'; + } + description + "An IPv6 address represented as either a full address; shortened + or mixed-shortened formats. This type allows specification of + a zone index to disambiguate identical address values. For + link-local addresses, the index is typically the interface + index or interface name."; + } + + typedef ipv4-prefix { + type string { + pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + + '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + + '[0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'; + } + description + "An IPv4 prefix represented in dotted quad notation followed by + a slash and a CIDR mask (0 <= mask <= 32)."; + } + + typedef ipv6-prefix { + type string { + pattern + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$'; + } + description + "An IPv6 prefix represented in full, shortened, or mixed + shortened format followed by a slash and CIDR mask + (0 <= mask <= 128)."; + } + + typedef ip-address { + type union { + type ipv4-address; + type ipv6-address; + } + description + "An IPv4 or IPv6 address with no prefix specified."; + } + + typedef ip-prefix { + type union { + type ipv4-prefix; + type ipv6-prefix; + } + description + "An IPv4 or IPv6 prefix."; + } + + typedef ip-version { + type enumeration { + enum UNKNOWN { + value 0; + description + "An unknown or unspecified version of the Internet + protocol."; + } + enum IPV4 { + value 4; + description + "The IPv4 protocol as defined in RFC 791."; + } + enum IPV6 { + value 6; + description + "The IPv6 protocol as defined in RFC 2460."; + } + } + description + "This value represents the version of the IP protocol. + Note that integer representation of the enumerated values + are not specified, and are not required to follow the + InetVersion textual convention in SMIv2."; + reference + "RFC 791: Internet Protocol + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification + RFC 4001: Textual Conventions for Internet Network Addresses"; + } + + typedef domain-name { + type string { + length "1..253"; + pattern + '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + + '|\.'; + } + description + "The domain-name type represents a DNS domain name. + Fully quallified left to the models which utilize this type. + + Internet domain names are only loosely specified. Section + 3.5 of RFC 1034 recommends a syntax (modified in Section + 2.1 of RFC 1123). The pattern above is intended to allow + for current practice in domain name use, and some possible + future expansion. It is designed to hold various types of + domain names, including names used for A or AAAA records + (host names) and other records, such as SRV records. Note + that Internet host names have a stricter syntax (described + in RFC 952) than the DNS recommendations in RFCs 1034 and + 1123, and that systems that want to store host names in + schema nodes using the domain-name type are recommended to + adhere to this stricter standard to ensure interoperability. + + The encoding of DNS names in the DNS protocol is limited + to 255 characters. Since the encoding consists of labels + prefixed by a length bytes and there is a trailing NULL + byte, only 253 characters can appear in the textual dotted + notation. + + Domain-name values use the US-ASCII encoding. Their canonical + format uses lowercase US-ASCII characters. Internationalized + domain names MUST be encoded in punycode as described in RFC + 3492"; + } + + typedef host { + type union { + type ip-address; + type domain-name; + } + description + "The host type represents either an unzoned IP address or a DNS + domain name."; + } + + typedef as-number { + type uint32; + description + "A numeric identifier for an autonomous system (AS). An AS is a + single domain, under common administrative control, which forms + a unit of routing policy. Autonomous systems can be assigned a + 2-byte identifier, or a 4-byte identifier which may have public + or private scope. Private ASNs are assigned from dedicated + ranges. Public ASNs are assigned from ranges allocated by IANA + to the regional internet registries (RIRs)."; + reference + "RFC 1930 Guidelines for creation, selection, and registration + of an Autonomous System (AS) + RFC 4271 A Border Gateway Protocol 4 (BGP-4)"; + } + + typedef dscp { + type uint8 { + range "0..63"; + } + description + "A differentiated services code point (DSCP) marking within the + IP header."; + reference + "RFC 2474 Definition of the Differentiated Services Field + (DS Field) in the IPv4 and IPv6 Headers"; + } + + typedef ipv6-flow-label { + type uint32 { + range "0..1048575"; + } + description + "The IPv6 flow-label is a 20-bit value within the IPv6 header + which is optionally used by the source of the IPv6 packet to + label sets of packets for which special handling may be + required."; + reference + "RFC 2460 Internet Protocol, Version 6 (IPv6) Specification"; + } + + typedef port-number { + type uint16; + description + "A 16-bit port number used by a transport protocol such as TCP + or UDP."; + reference + "RFC 768 User Datagram Protocol + RFC 793 Transmission Control Protocol"; + } + + typedef uri { + type string; + description + "An ASCII-encoded Uniform Resource Identifier (URI) as defined + in RFC 3986."; + reference + "RFC 3986 Uniform Resource Identifier (URI): Generic Syntax"; + } + + typedef url { + type string; + description + "An ASCII-encoded Uniform Resource Locator (URL) as defined + in RFC 3986, section 1.1.3"; + reference + "RFC 3986, paragraph 1.1.3"; + } + +} diff --git a/src/plugins/yang/openconfig/openconfig-interfaces.yang b/src/plugins/yang/openconfig/openconfig-interfaces.yang deleted file mode 100644 index d11e0b2..0000000 --- a/src/plugins/yang/openconfig/openconfig-interfaces.yang +++ /dev/null @@ -1,1040 +0,0 @@ -module openconfig-interfaces { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/interfaces"; - - prefix "oc-if"; - - // import some basic types - import ietf-interfaces { prefix ietf-if; } - import openconfig-yang-types { prefix oc-yang; } - import openconfig-types { prefix oc-types; } - import openconfig-extensions { prefix oc-ext; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "Model for managing network interfaces and subinterfaces. This - module also defines convenience types / groupings for other - models to create references to interfaces: - - base-interface-ref (type) - reference to a base interface - interface-ref (grouping) - container for reference to a - interface + subinterface - interface-ref-state (grouping) - container for read-only - (opstate) reference to interface + subinterface - - This model reuses data items defined in the IETF YANG model for - interfaces described by RFC 7223 with an alternate structure - (particularly for operational state data) and with - additional configuration items. - - Portions of this code were derived from IETF RFC 7223. - Please reproduce this note if possible. - - IETF code is subject to the following copyright and license: - Copyright (c) IETF Trust and the persons identified as authors of - the code. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, is permitted pursuant to, and subject to the license - terms contained in, the Simplified BSD License set forth in - Section 4.c of the IETF Trust's Legal Provisions Relating - to IETF Documents (http://trustee.ietf.org/license-info)."; - - oc-ext:openconfig-version "2.4.0"; - - revision "2018-08-07" { - description - "Add leaf to indicate whether an interface is physical or - logical."; - reference "2.4.0"; - } - - revision "2018-07-02" { - description - "Add in-pkts and out-pkts in counters"; - reference "2.3.2"; - } - - revision "2018-04-24" { - description - "Clarified behavior of last-change state leaf"; - reference "2.3.1"; - } - - revision "2018-01-05" { - description - "Add logical loopback to interface."; - reference "2.3.0"; - } - - revision "2017-12-22" { - description - "Add IPv4 proxy ARP configuration."; - reference "2.2.0"; - } - - revision "2017-12-21" { - description - "Added IPv6 router advertisement configuration."; - reference "2.1.0"; - } - - revision "2017-07-14" { - description - "Added Ethernet/IP state data; Add dhcp-client; - migrate to OpenConfig types modules; Removed or - renamed opstate values"; - reference "2.0.0"; - } - - revision "2017-04-03" { - description - "Update copyright notice."; - reference "1.1.1"; - } - - revision "2016-12-22" { - description - "Fixes to Ethernet interfaces model"; - reference "1.1.0"; - } - - - // typedef statements - - typedef base-interface-ref { - type leafref { - path "/oc-if:interfaces/oc-if:interface/oc-if:name"; - } - description - "Reusable type for by-name reference to a base interface. - This type may be used in cases where ability to reference - a subinterface is not required."; - } - - typedef interface-id { - type string; - description - "User-defined identifier for an interface, generally used to - name a interface reference. The id can be arbitrary but a - useful convention is to use a combination of base interface - name and subinterface index."; - } - - // grouping statements - - grouping interface-ref-common { - description - "Reference leafrefs to interface / subinterface"; - - leaf interface { - type leafref { - path "/oc-if:interfaces/oc-if:interface/oc-if:name"; - } - description - "Reference to a base interface. If a reference to a - subinterface is required, this leaf must be specified - to indicate the base interface."; - } - - leaf subinterface { - type leafref { - path "/oc-if:interfaces/" + - "oc-if:interface[oc-if:name=current()/../interface]/" + - "oc-if:subinterfaces/oc-if:subinterface/oc-if:index"; - } - description - "Reference to a subinterface -- this requires the base - interface to be specified using the interface leaf in - this container. If only a reference to a base interface - is requuired, this leaf should not be set."; - } - } - - grouping interface-ref-state-container { - description - "Reusable opstate w/container for a reference to an - interface or subinterface"; - - container state { - config false; - description - "Operational state for interface-ref"; - - uses interface-ref-common; - } - } - - grouping interface-ref { - description - "Reusable definition for a reference to an interface or - subinterface"; - - container interface-ref { - description - "Reference to an interface or subinterface"; - - container config { - description - "Configured reference to interface / subinterface"; - - uses interface-ref-common; - } - - uses interface-ref-state-container; - } - } - - grouping interface-ref-state { - description - "Reusable opstate w/container for a reference to an - interface or subinterface"; - - container interface-ref { - description - "Reference to an interface or subinterface"; - - uses interface-ref-state-container; - } - } - - grouping base-interface-ref-state { - description - "Reusable opstate w/container for a reference to a - base interface (no subinterface)."; - - container state { - config false; - description - "Operational state for base interface reference"; - - leaf interface { - type base-interface-ref; - description - "Reference to a base interface."; - } - } - } - - - grouping interface-common-config { - description - "Configuration data data nodes common to physical interfaces - and subinterfaces"; - - leaf description { - type string; - description - "A textual description of the interface. - - A server implementation MAY map this leaf to the ifAlias - MIB object. Such an implementation needs to use some - mechanism to handle the differences in size and characters - allowed between this leaf and ifAlias. The definition of - such a mechanism is outside the scope of this document. - - Since ifAlias is defined to be stored in non-volatile - storage, the MIB implementation MUST map ifAlias to the - value of 'description' in the persistently stored - datastore. - - Specifically, if the device supports ':startup', when - ifAlias is read the device MUST return the value of - 'description' in the 'startup' datastore, and when it is - written, it MUST be written to the 'running' and 'startup' - datastores. Note that it is up to the implementation to - - decide whether to modify this single leaf in 'startup' or - perform an implicit copy-config from 'running' to - 'startup'. - - If the device does not support ':startup', ifAlias MUST - be mapped to the 'description' leaf in the 'running' - datastore."; - reference - "RFC 2863: The Interfaces Group MIB - ifAlias"; - } - - leaf enabled { - type boolean; - default "true"; - description - "This leaf contains the configured, desired state of the - interface. - - Systems that implement the IF-MIB use the value of this - leaf in the 'running' datastore to set - IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry - has been initialized, as described in RFC 2863. - - Changes in this leaf in the 'running' datastore are - reflected in ifAdminStatus, but if ifAdminStatus is - changed over SNMP, this leaf is not affected."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - } - - grouping interface-phys-config { - description - "Configuration data for physical interfaces"; - - leaf name { - type string; - description - "The name of the interface. - - A device MAY restrict the allowed values for this leaf, - possibly depending on the type of the interface. - For system-controlled interfaces, this leaf is the - device-specific name of the interface. The 'config false' - list interfaces/interface[name]/state contains the currently - existing interfaces on the device. - - If a client tries to create configuration for a - system-controlled interface that is not present in the - corresponding state list, the server MAY reject - the request if the implementation does not support - pre-provisioning of interfaces or if the name refers to - an interface that can never exist in the system. A - NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case. - - The IETF model in RFC 7223 provides YANG features for the - following (i.e., pre-provisioning and arbitrary-names), - however they are omitted here: - - If the device supports pre-provisioning of interface - configuration, the 'pre-provisioning' feature is - advertised. - - If the device allows arbitrarily named user-controlled - interfaces, the 'arbitrary-names' feature is advertised. - - When a configured user-controlled interface is created by - the system, it is instantiated with the same name in the - /interfaces/interface[name]/state list."; - } - - leaf type { - type identityref { - base ietf-if:interface-type; - } - //mandatory true; - description - "The type of the interface. - - When an interface entry is created, a server MAY - initialize the type leaf with a valid value, e.g., if it - is possible to derive the type from the name of the - interface. - - If a client tries to set the type of an interface to a - value that can never be used by the system, e.g., if the - type is not supported or if the type does not match the - name of the interface, the server MUST reject the request. - A NETCONF server MUST reply with an rpc-error with the - error-tag 'invalid-value' in this case."; - reference - "RFC 2863: The Interfaces Group MIB - ifType"; - } - - leaf mtu { - type uint16; - description - "Set the max transmission unit size in octets - for the physical interface. If this is not set, the mtu is - set to the operational default -- e.g., 1514 bytes on an - Ethernet interface."; - } - - leaf loopback-mode { - type boolean; - default false; - description - "When set to true, the interface is logically looped back, - such that packets that are forwarded via the interface - are received on the same interface."; - } - - uses interface-common-config; - } - - grouping interface-phys-holdtime-config { - description - "Configuration data for interface hold-time settings -- - applies to physical interfaces."; - - leaf up { - type uint32; - units milliseconds; - default 0; - description - "Dampens advertisement when the interface - transitions from down to up. A zero value means dampening - is turned off, i.e., immediate notification."; - } - - leaf down { - type uint32; - units milliseconds; - default 0; - description - "Dampens advertisement when the interface transitions from - up to down. A zero value means dampening is turned off, - i.e., immediate notification."; - } - } - - grouping interface-phys-holdtime-state { - description - "Operational state data for interface hold-time."; - } - - grouping interface-phys-holdtime-top { - description - "Top-level grouping for setting link transition - dampening on physical and other types of interfaces."; - - container hold-time { - description - "Top-level container for hold-time settings to enable - dampening advertisements of interface transitions."; - - container config { - description - "Configuration data for interface hold-time settings."; - - uses interface-phys-holdtime-config; - } - - container state { - - config false; - - description - "Operational state data for interface hold-time."; - - uses interface-phys-holdtime-config; - uses interface-phys-holdtime-state; - } - } - } - - grouping interface-common-state { - description - "Operational state data (in addition to intended configuration) - at the global level for this interface"; - - leaf ifindex { - type uint32; - description - "System assigned number for each interface. Corresponds to - ifIndex object in SNMP Interface MIB"; - reference - "RFC 2863 - The Interfaces Group MIB"; - } - - leaf admin-status { - type enumeration { - enum UP { - description - "Ready to pass packets."; - } - enum DOWN { - description - "Not ready to pass packets and not in some test mode."; - } - enum TESTING { - //TODO: This is generally not supported as a configured - //admin state, though it's in the standard interfaces MIB. - //Consider removing it. - description - "In some test mode."; - } - } - //TODO:consider converting to an identity to have the - //flexibility to remove some values defined by RFC 7223 that - //are not used or not implemented consistently. - mandatory true; - description - "The desired state of the interface. In RFC 7223 this leaf - has the same read semantics as ifAdminStatus. Here, it - reflects the administrative state as set by enabling or - disabling the interface."; - reference - "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; - } - - leaf oper-status { - type enumeration { - enum UP { - value 1; - description - "Ready to pass packets."; - } - enum DOWN { - value 2; - description - "The interface does not pass any packets."; - } - enum TESTING { - value 3; - description - "In some test mode. No operational packets can - be passed."; - } - enum UNKNOWN { - value 4; - description - "Status cannot be determined for some reason."; - } - enum DORMANT { - value 5; - description - "Waiting for some external event."; - } - enum NOT_PRESENT { - value 6; - description - "Some component (typically hardware) is missing."; - } - enum LOWER_LAYER_DOWN { - value 7; - description - "Down due to state of lower-layer interface(s)."; - } - } - //TODO:consider converting to an identity to have the - //flexibility to remove some values defined by RFC 7223 that - //are not used or not implemented consistently. - mandatory true; - description - "The current operational state of the interface. - - This leaf has the same semantics as ifOperStatus."; - reference - "RFC 2863: The Interfaces Group MIB - ifOperStatus"; - } - - leaf last-change { - type oc-types:timeticks64; - units nanoseconds; - description - "This timestamp indicates the absolute time of the last - state change of the interface (e.g., up-to-down transition). - This is different than the SNMP ifLastChange object in the - standard interface MIB in that it is not relative to the - system boot time (i.e,. sysUpTime). - - The value is the timestamp in nanoseconds relative to - the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; - } - - leaf logical { - type boolean; - description - "When set to true, the interface is a logical interface - which does not have an associated physical port or - channel on the system."; - } - } - - - grouping interface-counters-state { - description - "Operational state representing interface counters - and statistics."; - - //TODO: we may need to break this list of counters into those - //that would appear for physical vs. subinterface or logical - //interfaces. For now, just replicating the full stats - //grouping to both interface and subinterface. - - container counters { - description - "A collection of interface-related statistics objects."; - - leaf in-octets { - type oc-yang:counter64; - description - "The total number of octets received on the interface, - including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; - } - - leaf in-pkts { - type oc-yang:counter64; - description - "The total number of packets received on the interface, - including all unicast, multicast, broadcast and bad packets - etc."; - reference - "RFC 2819: Remote Network Monitoring Management Information - Base"; - } - - leaf in-unicast-pkts { - type oc-yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were not addressed to a - multicast or broadcast address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; - } - - leaf in-broadcast-pkts { - type oc-yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a broadcast - address at this sub-layer. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInBroadcastPkts"; - } - - leaf in-multicast-pkts { - type oc-yang:counter64; - description - "The number of packets, delivered by this sub-layer to a - higher (sub-)layer, that were addressed to a multicast - address at this sub-layer. For a MAC-layer protocol, - this includes both Group and Functional addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCInMulticastPkts"; - } - - leaf in-discards { - type oc-yang:counter64; - description - "The number of inbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being deliverable to a higher-layer - protocol. One possible reason for discarding such a - packet could be to free up buffer space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - - - reference - "RFC 2863: The Interfaces Group MIB - ifInDiscards"; - } - - leaf in-errors { - type oc-yang:counter64; - description - "For packet-oriented interfaces, the number of inbound - packets that contained errors preventing them from being - deliverable to a higher-layer protocol. For character- - oriented or fixed-length interfaces, the number of - inbound transmission units that contained errors - preventing them from being deliverable to a higher-layer - protocol. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInErrors"; - } - - leaf in-unknown-protos { - type oc-yang:counter64; - description - "For packet-oriented interfaces, the number of packets - received via the interface that were discarded because - of an unknown or unsupported protocol. For - character-oriented or fixed-length interfaces that - support protocol multiplexing, the number of - transmission units received via the interface that were - discarded because of an unknown or unsupported protocol. - For any interface that does not support protocol - multiplexing, this counter is not present. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; - } - - leaf in-fcs-errors { - type oc-yang:counter64; - description - "Number of received packets which had errors in the - frame check sequence (FCS), i.e., framing errors. - - Discontinuities in the value of this counter can occur - when the device is re-initialization as indicated by the - value of 'last-clear'."; - } - - leaf out-octets { - type oc-yang:counter64; - description - "The total number of octets transmitted out of the - interface, including framing characters. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; - } - - leaf out-pkts { - type oc-yang:counter64; - description - "The total number of packets transmitted out of the - interface, including all unicast, multicast, broadcast, - and bad packets etc."; - reference - "RFC 2819: Remote Network Monitoring Management Information - Base"; - } - - leaf out-unicast-pkts { - type oc-yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and that were not addressed - to a multicast or broadcast address at this sub-layer, - including those that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; - } - - leaf out-broadcast-pkts { - type oc-yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and that were addressed to a - broadcast address at this sub-layer, including those - that were discarded or not sent. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutBroadcastPkts"; - } - - - leaf out-multicast-pkts { - type oc-yang:counter64; - description - "The total number of packets that higher-level protocols - requested be transmitted, and that were addressed to a - multicast address at this sub-layer, including those - that were discarded or not sent. For a MAC-layer - protocol, this includes both Group and Functional - addresses. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - - ifHCOutMulticastPkts"; - } - - leaf out-discards { - type oc-yang:counter64; - description - "The number of outbound packets that were chosen to be - discarded even though no errors had been detected to - prevent their being transmitted. One possible reason - for discarding such a packet could be to free up buffer - space. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; - } - - leaf out-errors { - type oc-yang:counter64; - description - "For packet-oriented interfaces, the number of outbound - packets that could not be transmitted because of errors. - For character-oriented or fixed-length interfaces, the - number of outbound transmission units that could not be - transmitted because of errors. - - Discontinuities in the value of this counter can occur - at re-initialization of the management system, and at - other times as indicated by the value of - 'last-clear'."; - reference - "RFC 2863: The Interfaces Group MIB - ifOutErrors"; - } - - leaf carrier-transitions { - type oc-yang:counter64; - description - "Number of times the interface state has transitioned - between up and down since the time the device restarted - or the last-clear time, whichever is most recent."; - } - - leaf last-clear { - type oc-types:timeticks64; - units nanoseconds; - description - "Timestamp of the last time the interface counters were - cleared. - - The value is the timestamp in nanoseconds relative to - the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; - } - } - } - - // data definition statements - - grouping sub-unnumbered-config { - description - "Configuration data for unnumbered subinterfaces"; - - leaf enabled { - type boolean; - default false; - description - "Indicates that the subinterface is unnumbered. By default - the subinterface is numbered, i.e., expected to have an - IP address configuration."; - } - } - - grouping sub-unnumbered-state { - description - "Operational state data unnumbered subinterfaces"; - } - - grouping sub-unnumbered-top { - description - "Top-level grouping unnumbered subinterfaces"; - - container unnumbered { - description - "Top-level container for setting unnumbered interfaces. - Includes reference the interface that provides the - address information"; - - container config { - description - "Configuration data for unnumbered interface"; - - uses sub-unnumbered-config; - } - - container state { - - config false; - - description - "Operational state data for unnumbered interfaces"; - - uses sub-unnumbered-config; - uses sub-unnumbered-state; - } - - uses oc-if:interface-ref; - } - } - - grouping subinterfaces-config { - description - "Configuration data for subinterfaces"; - - leaf index { - type uint32; - default 0; - description - "The index of the subinterface, or logical interface number. - On systems with no support for subinterfaces, or not using - subinterfaces, this value should default to 0, i.e., the - default subinterface."; - } - - uses interface-common-config; - - } - - grouping subinterfaces-state { - description - "Operational state data for subinterfaces"; - - leaf name { - type string; - description - "The system-assigned name for the sub-interface. This MAY - be a combination of the base interface name and the - subinterface index, or some other convention used by the - system."; - } - - uses interface-common-state; - uses interface-counters-state; - } - - grouping subinterfaces-top { - description - "Subinterface data for logical interfaces associated with a - given interface"; - - container subinterfaces { - description - "Enclosing container for the list of subinterfaces associated - with a physical interface"; - - list subinterface { - key "index"; - - description - "The list of subinterfaces (logical interfaces) associated - with a physical interface"; - - leaf index { - type leafref { - path "../config/index"; - } - description - "The index number of the subinterface -- used to address - the logical interface"; - } - - container config { - description - "Configurable items at the subinterface level"; - - uses subinterfaces-config; - } - - container state { - - config false; - description - "Operational state data for logical interfaces"; - - uses subinterfaces-config; - uses subinterfaces-state; - } - } - } - } - - grouping interfaces-top { - description - "Top-level grouping for interface configuration and - operational state data"; - - container interfaces { - description - "Top level container for interfaces, including configuration - and state data."; - - - list interface { - key "name"; - - description - "The list of named interfaces on the device."; - - leaf name { - type string; - //type leafref { - // path "../config/name"; - //} - description - "References the configured name of the interface"; - //TODO: need to consider whether this should actually - //reference the name in the state subtree, which - //presumably would be the system-assigned name, or the - //configured name. Points to the config/name now - //because of YANG 1.0 limitation that the list - //key must have the same "config" as the list, and - //also can't point to a non-config node. - } - - container config { - description - "Configurable items at the global, physical interface - level"; - - uses interface-phys-config; - } - - container state { - - config false; - description - "Operational state data at the global interface level"; - - uses interface-phys-config; - uses interface-common-state; - uses interface-counters-state; - } - - uses interface-phys-holdtime-top; - uses subinterfaces-top; - } - } - } - - uses interfaces-top; - - -} diff --git a/src/plugins/yang/openconfig/openconfig-interfaces@2018-08-07.yang b/src/plugins/yang/openconfig/openconfig-interfaces@2018-08-07.yang new file mode 100644 index 0000000..d11e0b2 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-interfaces@2018-08-07.yang @@ -0,0 +1,1040 @@ +module openconfig-interfaces { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/interfaces"; + + prefix "oc-if"; + + // import some basic types + import ietf-interfaces { prefix ietf-if; } + import openconfig-yang-types { prefix oc-yang; } + import openconfig-types { prefix oc-types; } + import openconfig-extensions { prefix oc-ext; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "Model for managing network interfaces and subinterfaces. This + module also defines convenience types / groupings for other + models to create references to interfaces: + + base-interface-ref (type) - reference to a base interface + interface-ref (grouping) - container for reference to a + interface + subinterface + interface-ref-state (grouping) - container for read-only + (opstate) reference to interface + subinterface + + This model reuses data items defined in the IETF YANG model for + interfaces described by RFC 7223 with an alternate structure + (particularly for operational state data) and with + additional configuration items. + + Portions of this code were derived from IETF RFC 7223. + Please reproduce this note if possible. + + IETF code is subject to the following copyright and license: + Copyright (c) IETF Trust and the persons identified as authors of + the code. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, is permitted pursuant to, and subject to the license + terms contained in, the Simplified BSD License set forth in + Section 4.c of the IETF Trust's Legal Provisions Relating + to IETF Documents (http://trustee.ietf.org/license-info)."; + + oc-ext:openconfig-version "2.4.0"; + + revision "2018-08-07" { + description + "Add leaf to indicate whether an interface is physical or + logical."; + reference "2.4.0"; + } + + revision "2018-07-02" { + description + "Add in-pkts and out-pkts in counters"; + reference "2.3.2"; + } + + revision "2018-04-24" { + description + "Clarified behavior of last-change state leaf"; + reference "2.3.1"; + } + + revision "2018-01-05" { + description + "Add logical loopback to interface."; + reference "2.3.0"; + } + + revision "2017-12-22" { + description + "Add IPv4 proxy ARP configuration."; + reference "2.2.0"; + } + + revision "2017-12-21" { + description + "Added IPv6 router advertisement configuration."; + reference "2.1.0"; + } + + revision "2017-07-14" { + description + "Added Ethernet/IP state data; Add dhcp-client; + migrate to OpenConfig types modules; Removed or + renamed opstate values"; + reference "2.0.0"; + } + + revision "2017-04-03" { + description + "Update copyright notice."; + reference "1.1.1"; + } + + revision "2016-12-22" { + description + "Fixes to Ethernet interfaces model"; + reference "1.1.0"; + } + + + // typedef statements + + typedef base-interface-ref { + type leafref { + path "/oc-if:interfaces/oc-if:interface/oc-if:name"; + } + description + "Reusable type for by-name reference to a base interface. + This type may be used in cases where ability to reference + a subinterface is not required."; + } + + typedef interface-id { + type string; + description + "User-defined identifier for an interface, generally used to + name a interface reference. The id can be arbitrary but a + useful convention is to use a combination of base interface + name and subinterface index."; + } + + // grouping statements + + grouping interface-ref-common { + description + "Reference leafrefs to interface / subinterface"; + + leaf interface { + type leafref { + path "/oc-if:interfaces/oc-if:interface/oc-if:name"; + } + description + "Reference to a base interface. If a reference to a + subinterface is required, this leaf must be specified + to indicate the base interface."; + } + + leaf subinterface { + type leafref { + path "/oc-if:interfaces/" + + "oc-if:interface[oc-if:name=current()/../interface]/" + + "oc-if:subinterfaces/oc-if:subinterface/oc-if:index"; + } + description + "Reference to a subinterface -- this requires the base + interface to be specified using the interface leaf in + this container. If only a reference to a base interface + is requuired, this leaf should not be set."; + } + } + + grouping interface-ref-state-container { + description + "Reusable opstate w/container for a reference to an + interface or subinterface"; + + container state { + config false; + description + "Operational state for interface-ref"; + + uses interface-ref-common; + } + } + + grouping interface-ref { + description + "Reusable definition for a reference to an interface or + subinterface"; + + container interface-ref { + description + "Reference to an interface or subinterface"; + + container config { + description + "Configured reference to interface / subinterface"; + + uses interface-ref-common; + } + + uses interface-ref-state-container; + } + } + + grouping interface-ref-state { + description + "Reusable opstate w/container for a reference to an + interface or subinterface"; + + container interface-ref { + description + "Reference to an interface or subinterface"; + + uses interface-ref-state-container; + } + } + + grouping base-interface-ref-state { + description + "Reusable opstate w/container for a reference to a + base interface (no subinterface)."; + + container state { + config false; + description + "Operational state for base interface reference"; + + leaf interface { + type base-interface-ref; + description + "Reference to a base interface."; + } + } + } + + + grouping interface-common-config { + description + "Configuration data data nodes common to physical interfaces + and subinterfaces"; + + leaf description { + type string; + description + "A textual description of the interface. + + A server implementation MAY map this leaf to the ifAlias + MIB object. Such an implementation needs to use some + mechanism to handle the differences in size and characters + allowed between this leaf and ifAlias. The definition of + such a mechanism is outside the scope of this document. + + Since ifAlias is defined to be stored in non-volatile + storage, the MIB implementation MUST map ifAlias to the + value of 'description' in the persistently stored + datastore. + + Specifically, if the device supports ':startup', when + ifAlias is read the device MUST return the value of + 'description' in the 'startup' datastore, and when it is + written, it MUST be written to the 'running' and 'startup' + datastores. Note that it is up to the implementation to + + decide whether to modify this single leaf in 'startup' or + perform an implicit copy-config from 'running' to + 'startup'. + + If the device does not support ':startup', ifAlias MUST + be mapped to the 'description' leaf in the 'running' + datastore."; + reference + "RFC 2863: The Interfaces Group MIB - ifAlias"; + } + + leaf enabled { + type boolean; + default "true"; + description + "This leaf contains the configured, desired state of the + interface. + + Systems that implement the IF-MIB use the value of this + leaf in the 'running' datastore to set + IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry + has been initialized, as described in RFC 2863. + + Changes in this leaf in the 'running' datastore are + reflected in ifAdminStatus, but if ifAdminStatus is + changed over SNMP, this leaf is not affected."; + reference + "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; + } + + } + + grouping interface-phys-config { + description + "Configuration data for physical interfaces"; + + leaf name { + type string; + description + "The name of the interface. + + A device MAY restrict the allowed values for this leaf, + possibly depending on the type of the interface. + For system-controlled interfaces, this leaf is the + device-specific name of the interface. The 'config false' + list interfaces/interface[name]/state contains the currently + existing interfaces on the device. + + If a client tries to create configuration for a + system-controlled interface that is not present in the + corresponding state list, the server MAY reject + the request if the implementation does not support + pre-provisioning of interfaces or if the name refers to + an interface that can never exist in the system. A + NETCONF server MUST reply with an rpc-error with the + error-tag 'invalid-value' in this case. + + The IETF model in RFC 7223 provides YANG features for the + following (i.e., pre-provisioning and arbitrary-names), + however they are omitted here: + + If the device supports pre-provisioning of interface + configuration, the 'pre-provisioning' feature is + advertised. + + If the device allows arbitrarily named user-controlled + interfaces, the 'arbitrary-names' feature is advertised. + + When a configured user-controlled interface is created by + the system, it is instantiated with the same name in the + /interfaces/interface[name]/state list."; + } + + leaf type { + type identityref { + base ietf-if:interface-type; + } + //mandatory true; + description + "The type of the interface. + + When an interface entry is created, a server MAY + initialize the type leaf with a valid value, e.g., if it + is possible to derive the type from the name of the + interface. + + If a client tries to set the type of an interface to a + value that can never be used by the system, e.g., if the + type is not supported or if the type does not match the + name of the interface, the server MUST reject the request. + A NETCONF server MUST reply with an rpc-error with the + error-tag 'invalid-value' in this case."; + reference + "RFC 2863: The Interfaces Group MIB - ifType"; + } + + leaf mtu { + type uint16; + description + "Set the max transmission unit size in octets + for the physical interface. If this is not set, the mtu is + set to the operational default -- e.g., 1514 bytes on an + Ethernet interface."; + } + + leaf loopback-mode { + type boolean; + default false; + description + "When set to true, the interface is logically looped back, + such that packets that are forwarded via the interface + are received on the same interface."; + } + + uses interface-common-config; + } + + grouping interface-phys-holdtime-config { + description + "Configuration data for interface hold-time settings -- + applies to physical interfaces."; + + leaf up { + type uint32; + units milliseconds; + default 0; + description + "Dampens advertisement when the interface + transitions from down to up. A zero value means dampening + is turned off, i.e., immediate notification."; + } + + leaf down { + type uint32; + units milliseconds; + default 0; + description + "Dampens advertisement when the interface transitions from + up to down. A zero value means dampening is turned off, + i.e., immediate notification."; + } + } + + grouping interface-phys-holdtime-state { + description + "Operational state data for interface hold-time."; + } + + grouping interface-phys-holdtime-top { + description + "Top-level grouping for setting link transition + dampening on physical and other types of interfaces."; + + container hold-time { + description + "Top-level container for hold-time settings to enable + dampening advertisements of interface transitions."; + + container config { + description + "Configuration data for interface hold-time settings."; + + uses interface-phys-holdtime-config; + } + + container state { + + config false; + + description + "Operational state data for interface hold-time."; + + uses interface-phys-holdtime-config; + uses interface-phys-holdtime-state; + } + } + } + + grouping interface-common-state { + description + "Operational state data (in addition to intended configuration) + at the global level for this interface"; + + leaf ifindex { + type uint32; + description + "System assigned number for each interface. Corresponds to + ifIndex object in SNMP Interface MIB"; + reference + "RFC 2863 - The Interfaces Group MIB"; + } + + leaf admin-status { + type enumeration { + enum UP { + description + "Ready to pass packets."; + } + enum DOWN { + description + "Not ready to pass packets and not in some test mode."; + } + enum TESTING { + //TODO: This is generally not supported as a configured + //admin state, though it's in the standard interfaces MIB. + //Consider removing it. + description + "In some test mode."; + } + } + //TODO:consider converting to an identity to have the + //flexibility to remove some values defined by RFC 7223 that + //are not used or not implemented consistently. + mandatory true; + description + "The desired state of the interface. In RFC 7223 this leaf + has the same read semantics as ifAdminStatus. Here, it + reflects the administrative state as set by enabling or + disabling the interface."; + reference + "RFC 2863: The Interfaces Group MIB - ifAdminStatus"; + } + + leaf oper-status { + type enumeration { + enum UP { + value 1; + description + "Ready to pass packets."; + } + enum DOWN { + value 2; + description + "The interface does not pass any packets."; + } + enum TESTING { + value 3; + description + "In some test mode. No operational packets can + be passed."; + } + enum UNKNOWN { + value 4; + description + "Status cannot be determined for some reason."; + } + enum DORMANT { + value 5; + description + "Waiting for some external event."; + } + enum NOT_PRESENT { + value 6; + description + "Some component (typically hardware) is missing."; + } + enum LOWER_LAYER_DOWN { + value 7; + description + "Down due to state of lower-layer interface(s)."; + } + } + //TODO:consider converting to an identity to have the + //flexibility to remove some values defined by RFC 7223 that + //are not used or not implemented consistently. + mandatory true; + description + "The current operational state of the interface. + + This leaf has the same semantics as ifOperStatus."; + reference + "RFC 2863: The Interfaces Group MIB - ifOperStatus"; + } + + leaf last-change { + type oc-types:timeticks64; + units nanoseconds; + description + "This timestamp indicates the absolute time of the last + state change of the interface (e.g., up-to-down transition). + This is different than the SNMP ifLastChange object in the + standard interface MIB in that it is not relative to the + system boot time (i.e,. sysUpTime). + + The value is the timestamp in nanoseconds relative to + the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; + } + + leaf logical { + type boolean; + description + "When set to true, the interface is a logical interface + which does not have an associated physical port or + channel on the system."; + } + } + + + grouping interface-counters-state { + description + "Operational state representing interface counters + and statistics."; + + //TODO: we may need to break this list of counters into those + //that would appear for physical vs. subinterface or logical + //interfaces. For now, just replicating the full stats + //grouping to both interface and subinterface. + + container counters { + description + "A collection of interface-related statistics objects."; + + leaf in-octets { + type oc-yang:counter64; + description + "The total number of octets received on the interface, + including framing characters. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCInOctets"; + } + + leaf in-pkts { + type oc-yang:counter64; + description + "The total number of packets received on the interface, + including all unicast, multicast, broadcast and bad packets + etc."; + reference + "RFC 2819: Remote Network Monitoring Management Information + Base"; + } + + leaf in-unicast-pkts { + type oc-yang:counter64; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were not addressed to a + multicast or broadcast address at this sub-layer. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts"; + } + + leaf in-broadcast-pkts { + type oc-yang:counter64; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were addressed to a broadcast + address at this sub-layer. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCInBroadcastPkts"; + } + + leaf in-multicast-pkts { + type oc-yang:counter64; + description + "The number of packets, delivered by this sub-layer to a + higher (sub-)layer, that were addressed to a multicast + address at this sub-layer. For a MAC-layer protocol, + this includes both Group and Functional addresses. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCInMulticastPkts"; + } + + leaf in-discards { + type oc-yang:counter64; + description + "The number of inbound packets that were chosen to be + discarded even though no errors had been detected to + prevent their being deliverable to a higher-layer + protocol. One possible reason for discarding such a + packet could be to free up buffer space. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + + + reference + "RFC 2863: The Interfaces Group MIB - ifInDiscards"; + } + + leaf in-errors { + type oc-yang:counter64; + description + "For packet-oriented interfaces, the number of inbound + packets that contained errors preventing them from being + deliverable to a higher-layer protocol. For character- + oriented or fixed-length interfaces, the number of + inbound transmission units that contained errors + preventing them from being deliverable to a higher-layer + protocol. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInErrors"; + } + + leaf in-unknown-protos { + type oc-yang:counter64; + description + "For packet-oriented interfaces, the number of packets + received via the interface that were discarded because + of an unknown or unsupported protocol. For + character-oriented or fixed-length interfaces that + support protocol multiplexing, the number of + transmission units received via the interface that were + discarded because of an unknown or unsupported protocol. + For any interface that does not support protocol + multiplexing, this counter is not present. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos"; + } + + leaf in-fcs-errors { + type oc-yang:counter64; + description + "Number of received packets which had errors in the + frame check sequence (FCS), i.e., framing errors. + + Discontinuities in the value of this counter can occur + when the device is re-initialization as indicated by the + value of 'last-clear'."; + } + + leaf out-octets { + type oc-yang:counter64; + description + "The total number of octets transmitted out of the + interface, including framing characters. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCOutOctets"; + } + + leaf out-pkts { + type oc-yang:counter64; + description + "The total number of packets transmitted out of the + interface, including all unicast, multicast, broadcast, + and bad packets etc."; + reference + "RFC 2819: Remote Network Monitoring Management Information + Base"; + } + + leaf out-unicast-pkts { + type oc-yang:counter64; + description + "The total number of packets that higher-level protocols + requested be transmitted, and that were not addressed + to a multicast or broadcast address at this sub-layer, + including those that were discarded or not sent. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts"; + } + + leaf out-broadcast-pkts { + type oc-yang:counter64; + description + "The total number of packets that higher-level protocols + requested be transmitted, and that were addressed to a + broadcast address at this sub-layer, including those + that were discarded or not sent. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCOutBroadcastPkts"; + } + + + leaf out-multicast-pkts { + type oc-yang:counter64; + description + "The total number of packets that higher-level protocols + requested be transmitted, and that were addressed to a + multicast address at this sub-layer, including those + that were discarded or not sent. For a MAC-layer + protocol, this includes both Group and Functional + addresses. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - + ifHCOutMulticastPkts"; + } + + leaf out-discards { + type oc-yang:counter64; + description + "The number of outbound packets that were chosen to be + discarded even though no errors had been detected to + prevent their being transmitted. One possible reason + for discarding such a packet could be to free up buffer + space. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifOutDiscards"; + } + + leaf out-errors { + type oc-yang:counter64; + description + "For packet-oriented interfaces, the number of outbound + packets that could not be transmitted because of errors. + For character-oriented or fixed-length interfaces, the + number of outbound transmission units that could not be + transmitted because of errors. + + Discontinuities in the value of this counter can occur + at re-initialization of the management system, and at + other times as indicated by the value of + 'last-clear'."; + reference + "RFC 2863: The Interfaces Group MIB - ifOutErrors"; + } + + leaf carrier-transitions { + type oc-yang:counter64; + description + "Number of times the interface state has transitioned + between up and down since the time the device restarted + or the last-clear time, whichever is most recent."; + } + + leaf last-clear { + type oc-types:timeticks64; + units nanoseconds; + description + "Timestamp of the last time the interface counters were + cleared. + + The value is the timestamp in nanoseconds relative to + the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; + } + } + } + + // data definition statements + + grouping sub-unnumbered-config { + description + "Configuration data for unnumbered subinterfaces"; + + leaf enabled { + type boolean; + default false; + description + "Indicates that the subinterface is unnumbered. By default + the subinterface is numbered, i.e., expected to have an + IP address configuration."; + } + } + + grouping sub-unnumbered-state { + description + "Operational state data unnumbered subinterfaces"; + } + + grouping sub-unnumbered-top { + description + "Top-level grouping unnumbered subinterfaces"; + + container unnumbered { + description + "Top-level container for setting unnumbered interfaces. + Includes reference the interface that provides the + address information"; + + container config { + description + "Configuration data for unnumbered interface"; + + uses sub-unnumbered-config; + } + + container state { + + config false; + + description + "Operational state data for unnumbered interfaces"; + + uses sub-unnumbered-config; + uses sub-unnumbered-state; + } + + uses oc-if:interface-ref; + } + } + + grouping subinterfaces-config { + description + "Configuration data for subinterfaces"; + + leaf index { + type uint32; + default 0; + description + "The index of the subinterface, or logical interface number. + On systems with no support for subinterfaces, or not using + subinterfaces, this value should default to 0, i.e., the + default subinterface."; + } + + uses interface-common-config; + + } + + grouping subinterfaces-state { + description + "Operational state data for subinterfaces"; + + leaf name { + type string; + description + "The system-assigned name for the sub-interface. This MAY + be a combination of the base interface name and the + subinterface index, or some other convention used by the + system."; + } + + uses interface-common-state; + uses interface-counters-state; + } + + grouping subinterfaces-top { + description + "Subinterface data for logical interfaces associated with a + given interface"; + + container subinterfaces { + description + "Enclosing container for the list of subinterfaces associated + with a physical interface"; + + list subinterface { + key "index"; + + description + "The list of subinterfaces (logical interfaces) associated + with a physical interface"; + + leaf index { + type leafref { + path "../config/index"; + } + description + "The index number of the subinterface -- used to address + the logical interface"; + } + + container config { + description + "Configurable items at the subinterface level"; + + uses subinterfaces-config; + } + + container state { + + config false; + description + "Operational state data for logical interfaces"; + + uses subinterfaces-config; + uses subinterfaces-state; + } + } + } + } + + grouping interfaces-top { + description + "Top-level grouping for interface configuration and + operational state data"; + + container interfaces { + description + "Top level container for interfaces, including configuration + and state data."; + + + list interface { + key "name"; + + description + "The list of named interfaces on the device."; + + leaf name { + type string; + //type leafref { + // path "../config/name"; + //} + description + "References the configured name of the interface"; + //TODO: need to consider whether this should actually + //reference the name in the state subtree, which + //presumably would be the system-assigned name, or the + //configured name. Points to the config/name now + //because of YANG 1.0 limitation that the list + //key must have the same "config" as the list, and + //also can't point to a non-config node. + } + + container config { + description + "Configurable items at the global, physical interface + level"; + + uses interface-phys-config; + } + + container state { + + config false; + description + "Operational state data at the global interface level"; + + uses interface-phys-config; + uses interface-common-state; + uses interface-counters-state; + } + + uses interface-phys-holdtime-top; + uses subinterfaces-top; + } + } + } + + uses interfaces-top; + + +} diff --git a/src/plugins/yang/openconfig/openconfig-local-routing.yang b/src/plugins/yang/openconfig/openconfig-local-routing.yang deleted file mode 100644 index 5184fe7..0000000 --- a/src/plugins/yang/openconfig/openconfig-local-routing.yang +++ /dev/null @@ -1,408 +0,0 @@ -module openconfig-local-routing { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/local-routing"; - - prefix "oc-loc-rt"; - - // import some basic types - import openconfig-inet-types { prefix inet; } - import openconfig-policy-types { prefix oc-pt; } - import openconfig-extensions { prefix oc-ext; } - import openconfig-interfaces { prefix oc-if; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - www.openconfig.net"; - - description - "This module describes configuration and operational state data - for routes that are locally generated, i.e., not created by - dynamic routing protocols. These include static routes, locally - created aggregate routes for reducing the number of constituent - routes that must be advertised, summary routes for IGPs, etc. - - This model expresses locally generated routes as generically as - possible, avoiding configuration of protocol-specific attributes - at the time of route creation. This is primarily to avoid - assumptions about how underlying router implementations handle - route attributes in various routing table data structures they - maintain. Hence, the definition of locally generated routes - essentially creates 'bare' routes that do not have any protocol- - specific attributes. - - When protocol-specific attributes must be attached to a route - (e.g., communities on a locally defined route meant to be - advertised via BGP), the attributes should be attached via a - protocol-specific policy after importing the route into the - protocol for distribution (again via routing policy)."; - - oc-ext:openconfig-version "1.0.1"; - - revision "2017-05-15" { - description - "Update to resolve style guide non-compliance."; - reference "1.0.1"; - } - - revision "2016-05-11" { - description - "OpenConfig public release"; - reference "1.0.0"; - } - - - // identity statements - - identity LOCAL_DEFINED_NEXT_HOP { - description - "A base identity type of local defined next-hops"; - } - - identity DROP { - base LOCAL_DEFINED_NEXT_HOP; - description - "Discard traffic for the corresponding destination"; - } - - identity LOCAL_LINK { - base LOCAL_DEFINED_NEXT_HOP; - description - "Treat traffic towards addresses within the specified - next-hop prefix as though they are connected to a local - link. When the LOCAL_LINK next-hop type is specified, - an interface must also be specified such that - the local system can determine which link to trigger - link-layer address discovery against"; - } - - // typedef statements - - typedef local-defined-next-hop { - type identityref { - base LOCAL_DEFINED_NEXT_HOP; - } - description - "Pre-defined next-hop designation for locally generated - routes"; - } - - // grouping statements - - grouping local-generic-settings { - description - "Generic options that can be set on local routes When - they are defined"; - - leaf set-tag { - type oc-pt:tag-type; - description - "Set a generic tag value on the route. This tag can be - used for filtering routes that are distributed to other - routing protocols."; - } - } - - grouping local-static-config { - description - "Configuration data for static routes."; - - leaf prefix { - type inet:ip-prefix; - description - "Destination prefix for the static route, either IPv4 or - IPv6."; - } - - uses local-generic-settings; - } - - grouping local-static-state { - description - "Operational state data for static routes"; - } - - - grouping local-static-nexthop-config { - description - "Configuration parameters related to each next-hop entry - specified for a static route"; - - leaf index { - type string; - description - "An user-specified identifier utilised to uniquely reference - the next-hop entry in the next-hop list. The value of this - index has no semantic meaning other than for referencing - the entry."; - } - - leaf next-hop { - type union { - type inet:ip-address; - type local-defined-next-hop; - } - description - "The next-hop that is to be used for the static route - - this may be specified as an IP address, an interface - or a pre-defined next-hop type - for instance, DROP or - LOCAL_LINK. When this leaf is not set, and the interface-ref - value is specified for the next-hop, then the system should - treat the prefix as though it is directly connected to the - interface."; - } - - leaf metric { - type uint32; - description - "A metric which is utilised to specify the preference of - the next-hop entry when it is injected into the RIB. The - lower the metric, the more preferable the prefix is. When - this value is not specified the metric is inherited from - the default metric utilised for static routes within the - network instance that the static routes are being - instantiated. When multiple next-hops are specified for a - static route, the metric is utilised to determine which of - the next-hops is to be installed in the RIB. When multiple - next-hops have the same metric (be it specified, or simply - the default) then these next-hops should all be installed - in the RIB"; - } - - leaf recurse { - type boolean; - default false; - description - "Determines whether the next-hop should be allowed to - be looked up recursively - i.e., via a RIB entry which has - been installed by a routing protocol, or another static route - - rather than needing to be connected directly to an - interface of the local system within the current network - instance. When the interface reference specified within the - next-hop entry is set (i.e., is not null) then forwarding is - restricted to being via the interface specified - and - recursion is hence disabled."; - } - } - - grouping local-static-nexthop-state { - description - "Operational state parameters relating to a next-hop entry - for a static route"; - } - - - grouping local-static-top { - description - "Top-level grouping for the list of static route definitions"; - - container static-routes { - description - "Enclosing container for the list of static routes"; - - list static { - key "prefix"; - description - "List of locally configured static routes"; - - leaf prefix { - type leafref { - path "../config/prefix"; - } - description - "Reference to the destination prefix list key."; - } - - container config { - description - "Configuration data for static routes"; - - uses local-static-config; - } - - container state { - - config false; - - description - "Operational state data for static routes"; - - uses local-static-config; - uses local-static-state; - } - - container next-hops { - description - "Configuration and state parameters relating to the - next-hops that are to be utilised for the static - route being specified"; - - list next-hop { - key "index"; - - description - "A list of next-hops to be utilised for the static - route being specified."; - - leaf index { - type leafref { - path "../config/index"; - } - description - "A reference to the index of the current next-hop. - The index is intended to be a user-specified value - which can be used to reference the next-hop in - question, without any other semantics being - assigned to it."; - } - - container config { - description - "Configuration parameters relating to the next-hop - entry"; - - uses local-static-nexthop-config; - } - - container state { - config false; - description - "Operational state parameters relating to the - next-hop entry"; - - uses local-static-nexthop-config; - uses local-static-nexthop-state; - } - - uses oc-if:interface-ref; - } - } - } - } - } - - grouping local-aggregate-config { - description - "Configuration data for aggregate routes"; - - leaf prefix { - type inet:ip-prefix; - description - "Aggregate prefix to be advertised"; - } - - leaf discard { - type boolean; - default false; - description - "When true, install the aggregate route with a discard - next-hop -- traffic destined to the aggregate will be - discarded with no ICMP message generated. When false, - traffic destined to an aggregate address when no - constituent routes are present will generate an ICMP - unreachable message."; - } - - uses local-generic-settings; - - } - - grouping local-aggregate-state { - description - "Operational state data for local aggregate advertisement - definitions"; - } - - grouping local-aggregate-top { - description - "Top-level grouping for local aggregates"; - - container local-aggregates { - description - "Enclosing container for locally-defined aggregate - routes"; - - list aggregate { - key "prefix"; - description - "List of aggregates"; - - leaf prefix { - type leafref { - path "../config/prefix"; - } - description - "Reference to the configured prefix for this aggregate"; - } - - container config { - description - "Configuration data for aggregate advertisements"; - - uses local-aggregate-config; - } - - container state { - - config false; - - description - "Operational state data for aggregate - advertisements"; - - uses local-aggregate-config; - uses local-aggregate-state; - } - } - } - } - - grouping local-routes-config { - description - "Configuration data for locally defined routes"; - } - - grouping local-routes-state { - description - "Operational state data for locally defined routes"; - } - - grouping local-routes-top { - description - "Top-level grouping for local routes"; - - container local-routes { - description - "Top-level container for local routes"; - - container config { - description - "Configuration data for locally defined routes"; - - uses local-routes-config; - } - - container state { - - config false; - - description - "Operational state data for locally defined routes"; - - uses local-routes-config; - uses local-routes-state; - } - - uses local-static-top; - uses local-aggregate-top; - } - } - - uses local-routes-top; - -} diff --git a/src/plugins/yang/openconfig/openconfig-local-routing@2017-05-15.yang b/src/plugins/yang/openconfig/openconfig-local-routing@2017-05-15.yang new file mode 100644 index 0000000..5184fe7 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-local-routing@2017-05-15.yang @@ -0,0 +1,408 @@ +module openconfig-local-routing { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/local-routing"; + + prefix "oc-loc-rt"; + + // import some basic types + import openconfig-inet-types { prefix inet; } + import openconfig-policy-types { prefix oc-pt; } + import openconfig-extensions { prefix oc-ext; } + import openconfig-interfaces { prefix oc-if; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module describes configuration and operational state data + for routes that are locally generated, i.e., not created by + dynamic routing protocols. These include static routes, locally + created aggregate routes for reducing the number of constituent + routes that must be advertised, summary routes for IGPs, etc. + + This model expresses locally generated routes as generically as + possible, avoiding configuration of protocol-specific attributes + at the time of route creation. This is primarily to avoid + assumptions about how underlying router implementations handle + route attributes in various routing table data structures they + maintain. Hence, the definition of locally generated routes + essentially creates 'bare' routes that do not have any protocol- + specific attributes. + + When protocol-specific attributes must be attached to a route + (e.g., communities on a locally defined route meant to be + advertised via BGP), the attributes should be attached via a + protocol-specific policy after importing the route into the + protocol for distribution (again via routing policy)."; + + oc-ext:openconfig-version "1.0.1"; + + revision "2017-05-15" { + description + "Update to resolve style guide non-compliance."; + reference "1.0.1"; + } + + revision "2016-05-11" { + description + "OpenConfig public release"; + reference "1.0.0"; + } + + + // identity statements + + identity LOCAL_DEFINED_NEXT_HOP { + description + "A base identity type of local defined next-hops"; + } + + identity DROP { + base LOCAL_DEFINED_NEXT_HOP; + description + "Discard traffic for the corresponding destination"; + } + + identity LOCAL_LINK { + base LOCAL_DEFINED_NEXT_HOP; + description + "Treat traffic towards addresses within the specified + next-hop prefix as though they are connected to a local + link. When the LOCAL_LINK next-hop type is specified, + an interface must also be specified such that + the local system can determine which link to trigger + link-layer address discovery against"; + } + + // typedef statements + + typedef local-defined-next-hop { + type identityref { + base LOCAL_DEFINED_NEXT_HOP; + } + description + "Pre-defined next-hop designation for locally generated + routes"; + } + + // grouping statements + + grouping local-generic-settings { + description + "Generic options that can be set on local routes When + they are defined"; + + leaf set-tag { + type oc-pt:tag-type; + description + "Set a generic tag value on the route. This tag can be + used for filtering routes that are distributed to other + routing protocols."; + } + } + + grouping local-static-config { + description + "Configuration data for static routes."; + + leaf prefix { + type inet:ip-prefix; + description + "Destination prefix for the static route, either IPv4 or + IPv6."; + } + + uses local-generic-settings; + } + + grouping local-static-state { + description + "Operational state data for static routes"; + } + + + grouping local-static-nexthop-config { + description + "Configuration parameters related to each next-hop entry + specified for a static route"; + + leaf index { + type string; + description + "An user-specified identifier utilised to uniquely reference + the next-hop entry in the next-hop list. The value of this + index has no semantic meaning other than for referencing + the entry."; + } + + leaf next-hop { + type union { + type inet:ip-address; + type local-defined-next-hop; + } + description + "The next-hop that is to be used for the static route + - this may be specified as an IP address, an interface + or a pre-defined next-hop type - for instance, DROP or + LOCAL_LINK. When this leaf is not set, and the interface-ref + value is specified for the next-hop, then the system should + treat the prefix as though it is directly connected to the + interface."; + } + + leaf metric { + type uint32; + description + "A metric which is utilised to specify the preference of + the next-hop entry when it is injected into the RIB. The + lower the metric, the more preferable the prefix is. When + this value is not specified the metric is inherited from + the default metric utilised for static routes within the + network instance that the static routes are being + instantiated. When multiple next-hops are specified for a + static route, the metric is utilised to determine which of + the next-hops is to be installed in the RIB. When multiple + next-hops have the same metric (be it specified, or simply + the default) then these next-hops should all be installed + in the RIB"; + } + + leaf recurse { + type boolean; + default false; + description + "Determines whether the next-hop should be allowed to + be looked up recursively - i.e., via a RIB entry which has + been installed by a routing protocol, or another static route + - rather than needing to be connected directly to an + interface of the local system within the current network + instance. When the interface reference specified within the + next-hop entry is set (i.e., is not null) then forwarding is + restricted to being via the interface specified - and + recursion is hence disabled."; + } + } + + grouping local-static-nexthop-state { + description + "Operational state parameters relating to a next-hop entry + for a static route"; + } + + + grouping local-static-top { + description + "Top-level grouping for the list of static route definitions"; + + container static-routes { + description + "Enclosing container for the list of static routes"; + + list static { + key "prefix"; + description + "List of locally configured static routes"; + + leaf prefix { + type leafref { + path "../config/prefix"; + } + description + "Reference to the destination prefix list key."; + } + + container config { + description + "Configuration data for static routes"; + + uses local-static-config; + } + + container state { + + config false; + + description + "Operational state data for static routes"; + + uses local-static-config; + uses local-static-state; + } + + container next-hops { + description + "Configuration and state parameters relating to the + next-hops that are to be utilised for the static + route being specified"; + + list next-hop { + key "index"; + + description + "A list of next-hops to be utilised for the static + route being specified."; + + leaf index { + type leafref { + path "../config/index"; + } + description + "A reference to the index of the current next-hop. + The index is intended to be a user-specified value + which can be used to reference the next-hop in + question, without any other semantics being + assigned to it."; + } + + container config { + description + "Configuration parameters relating to the next-hop + entry"; + + uses local-static-nexthop-config; + } + + container state { + config false; + description + "Operational state parameters relating to the + next-hop entry"; + + uses local-static-nexthop-config; + uses local-static-nexthop-state; + } + + uses oc-if:interface-ref; + } + } + } + } + } + + grouping local-aggregate-config { + description + "Configuration data for aggregate routes"; + + leaf prefix { + type inet:ip-prefix; + description + "Aggregate prefix to be advertised"; + } + + leaf discard { + type boolean; + default false; + description + "When true, install the aggregate route with a discard + next-hop -- traffic destined to the aggregate will be + discarded with no ICMP message generated. When false, + traffic destined to an aggregate address when no + constituent routes are present will generate an ICMP + unreachable message."; + } + + uses local-generic-settings; + + } + + grouping local-aggregate-state { + description + "Operational state data for local aggregate advertisement + definitions"; + } + + grouping local-aggregate-top { + description + "Top-level grouping for local aggregates"; + + container local-aggregates { + description + "Enclosing container for locally-defined aggregate + routes"; + + list aggregate { + key "prefix"; + description + "List of aggregates"; + + leaf prefix { + type leafref { + path "../config/prefix"; + } + description + "Reference to the configured prefix for this aggregate"; + } + + container config { + description + "Configuration data for aggregate advertisements"; + + uses local-aggregate-config; + } + + container state { + + config false; + + description + "Operational state data for aggregate + advertisements"; + + uses local-aggregate-config; + uses local-aggregate-state; + } + } + } + } + + grouping local-routes-config { + description + "Configuration data for locally defined routes"; + } + + grouping local-routes-state { + description + "Operational state data for locally defined routes"; + } + + grouping local-routes-top { + description + "Top-level grouping for local routes"; + + container local-routes { + description + "Top-level container for local routes"; + + container config { + description + "Configuration data for locally defined routes"; + + uses local-routes-config; + } + + container state { + + config false; + + description + "Operational state data for locally defined routes"; + + uses local-routes-config; + uses local-routes-state; + } + + uses local-static-top; + uses local-aggregate-top; + } + } + + uses local-routes-top; + +} diff --git a/src/plugins/yang/openconfig/openconfig-policy-types.yang b/src/plugins/yang/openconfig/openconfig-policy-types.yang deleted file mode 100644 index ef47f33..0000000 --- a/src/plugins/yang/openconfig/openconfig-policy-types.yang +++ /dev/null @@ -1,220 +0,0 @@ -module openconfig-policy-types { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/policy-types"; - - prefix "oc-pol-types"; - - // import some basic types - import ietf-yang-types { prefix yang; } - import openconfig-extensions { prefix oc-ext; } - - // meta - organization - "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "This module contains general data definitions for use in routing - policy. It can be imported by modules that contain protocol- - specific policy conditions and actions."; - - oc-ext:openconfig-version "3.1.0"; - - revision "2018-06-05" { - description - "Add PIM, IGMP to INSTALL_PROTOCOL_TYPES identity"; - reference "3.1.0"; - } - - revision "2017-07-14" { - description - "Replace policy choice node/type with policy-result - enumeration;simplified defined set naming;removed generic - IGP actions; migrate to OpenConfig types; added mode for - prefix sets"; - reference "3.0.0"; - } - - revision "2016-05-12" { - description - "OpenConfig public release"; - reference "2.0.1"; - } - - // identity statements - - identity ATTRIBUTE_COMPARISON { - description - "base type for supported comparison operators on route - attributes"; - } - - identity ATTRIBUTE_EQ { - base ATTRIBUTE_COMPARISON; - description "== comparison"; - } - - identity ATTRIBUTE_GE { - base ATTRIBUTE_COMPARISON; - description ">= comparison"; - } - - identity ATTRIBUTE_LE { - base ATTRIBUTE_COMPARISON; - description "<= comparison"; - } - - typedef match-set-options-type { - type enumeration { - enum ANY { - description "match is true if given value matches any member - of the defined set"; - } - enum ALL { - description "match is true if given value matches all - members of the defined set"; - } - enum INVERT { - description "match is true if given value does not match any - member of the defined set"; - } - } - default ANY; - description - "Options that govern the behavior of a match statement. The - default behavior is ANY, i.e., the given value matches any - of the members of the defined set"; - } - - typedef match-set-options-restricted-type { - type enumeration { - enum ANY { - description "match is true if given value matches any member - of the defined set"; - } - enum INVERT { - description "match is true if given value does not match any - member of the defined set"; - } - } - default ANY; - description - "Options that govern the behavior of a match statement. The - default behavior is ANY, i.e., the given value matches any - of the members of the defined set. Note this type is a - restricted version of the match-set-options-type."; - //TODO: restriction on enumerated types is only allowed in - //YANG 1.1. Until then, we will require this additional type - } - - grouping attribute-compare-operators { - description "common definitions for comparison operations in - condition statements"; - - leaf operator { - type identityref { - base ATTRIBUTE_COMPARISON; - } - description - "type of comparison to be performed"; - } - - leaf value { - type uint32; - description - "value to compare with the community count"; - } - } - - typedef tag-type { - type union { - type uint32; - type yang:hex-string; - } - description "type for expressing route tags on a local system, - including IS-IS and OSPF; may be expressed as either decimal or - hexidecimal integer"; - reference - "RFC 2178 OSPF Version 2 - RFC 5130 A Policy Control Mechanism in IS-IS Using - Administrative Tags"; - } - - identity INSTALL_PROTOCOL_TYPE { - description - "Base type for routing protocols, including those which may - install prefixes into the RIB"; - } - - identity BGP { - base INSTALL_PROTOCOL_TYPE; - description - "BGP"; - reference - "RFC 4271"; - } - - identity ISIS { - base INSTALL_PROTOCOL_TYPE; - description - "IS-IS"; - reference - "ISO/IEC 10589"; - } - - identity OSPF { - base INSTALL_PROTOCOL_TYPE; - description - "OSPFv2"; - reference - "RFC 2328"; - } - - identity OSPF3 { - base INSTALL_PROTOCOL_TYPE; - description - "OSPFv3"; - reference - "RFC 5340"; - } - - identity STATIC { - base INSTALL_PROTOCOL_TYPE; - description - "Locally-installed static route"; - } - - identity DIRECTLY_CONNECTED { - base INSTALL_PROTOCOL_TYPE; - description - "A directly connected route"; - } - - identity LOCAL_AGGREGATE { - base INSTALL_PROTOCOL_TYPE; - description - "Locally defined aggregate route"; - } - - identity PIM { - base INSTALL_PROTOCOL_TYPE; - description - "Protocol Independent Multicast"; - reference - "RFC 7761"; - } - - identity IGMP { - base INSTALL_PROTOCOL_TYPE; - description - "Internet Group Management Protocol"; - reference - "RFC 3376"; - } -} diff --git a/src/plugins/yang/openconfig/openconfig-policy-types@2018-06-05.yang b/src/plugins/yang/openconfig/openconfig-policy-types@2018-06-05.yang new file mode 100644 index 0000000..ef47f33 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-policy-types@2018-06-05.yang @@ -0,0 +1,220 @@ +module openconfig-policy-types { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/policy-types"; + + prefix "oc-pol-types"; + + // import some basic types + import ietf-yang-types { prefix yang; } + import openconfig-extensions { prefix oc-ext; } + + // meta + organization + "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "This module contains general data definitions for use in routing + policy. It can be imported by modules that contain protocol- + specific policy conditions and actions."; + + oc-ext:openconfig-version "3.1.0"; + + revision "2018-06-05" { + description + "Add PIM, IGMP to INSTALL_PROTOCOL_TYPES identity"; + reference "3.1.0"; + } + + revision "2017-07-14" { + description + "Replace policy choice node/type with policy-result + enumeration;simplified defined set naming;removed generic + IGP actions; migrate to OpenConfig types; added mode for + prefix sets"; + reference "3.0.0"; + } + + revision "2016-05-12" { + description + "OpenConfig public release"; + reference "2.0.1"; + } + + // identity statements + + identity ATTRIBUTE_COMPARISON { + description + "base type for supported comparison operators on route + attributes"; + } + + identity ATTRIBUTE_EQ { + base ATTRIBUTE_COMPARISON; + description "== comparison"; + } + + identity ATTRIBUTE_GE { + base ATTRIBUTE_COMPARISON; + description ">= comparison"; + } + + identity ATTRIBUTE_LE { + base ATTRIBUTE_COMPARISON; + description "<= comparison"; + } + + typedef match-set-options-type { + type enumeration { + enum ANY { + description "match is true if given value matches any member + of the defined set"; + } + enum ALL { + description "match is true if given value matches all + members of the defined set"; + } + enum INVERT { + description "match is true if given value does not match any + member of the defined set"; + } + } + default ANY; + description + "Options that govern the behavior of a match statement. The + default behavior is ANY, i.e., the given value matches any + of the members of the defined set"; + } + + typedef match-set-options-restricted-type { + type enumeration { + enum ANY { + description "match is true if given value matches any member + of the defined set"; + } + enum INVERT { + description "match is true if given value does not match any + member of the defined set"; + } + } + default ANY; + description + "Options that govern the behavior of a match statement. The + default behavior is ANY, i.e., the given value matches any + of the members of the defined set. Note this type is a + restricted version of the match-set-options-type."; + //TODO: restriction on enumerated types is only allowed in + //YANG 1.1. Until then, we will require this additional type + } + + grouping attribute-compare-operators { + description "common definitions for comparison operations in + condition statements"; + + leaf operator { + type identityref { + base ATTRIBUTE_COMPARISON; + } + description + "type of comparison to be performed"; + } + + leaf value { + type uint32; + description + "value to compare with the community count"; + } + } + + typedef tag-type { + type union { + type uint32; + type yang:hex-string; + } + description "type for expressing route tags on a local system, + including IS-IS and OSPF; may be expressed as either decimal or + hexidecimal integer"; + reference + "RFC 2178 OSPF Version 2 + RFC 5130 A Policy Control Mechanism in IS-IS Using + Administrative Tags"; + } + + identity INSTALL_PROTOCOL_TYPE { + description + "Base type for routing protocols, including those which may + install prefixes into the RIB"; + } + + identity BGP { + base INSTALL_PROTOCOL_TYPE; + description + "BGP"; + reference + "RFC 4271"; + } + + identity ISIS { + base INSTALL_PROTOCOL_TYPE; + description + "IS-IS"; + reference + "ISO/IEC 10589"; + } + + identity OSPF { + base INSTALL_PROTOCOL_TYPE; + description + "OSPFv2"; + reference + "RFC 2328"; + } + + identity OSPF3 { + base INSTALL_PROTOCOL_TYPE; + description + "OSPFv3"; + reference + "RFC 5340"; + } + + identity STATIC { + base INSTALL_PROTOCOL_TYPE; + description + "Locally-installed static route"; + } + + identity DIRECTLY_CONNECTED { + base INSTALL_PROTOCOL_TYPE; + description + "A directly connected route"; + } + + identity LOCAL_AGGREGATE { + base INSTALL_PROTOCOL_TYPE; + description + "Locally defined aggregate route"; + } + + identity PIM { + base INSTALL_PROTOCOL_TYPE; + description + "Protocol Independent Multicast"; + reference + "RFC 7761"; + } + + identity IGMP { + base INSTALL_PROTOCOL_TYPE; + description + "Internet Group Management Protocol"; + reference + "RFC 3376"; + } +} diff --git a/src/plugins/yang/openconfig/openconfig-types.yang b/src/plugins/yang/openconfig/openconfig-types.yang deleted file mode 100644 index 01713b3..0000000 --- a/src/plugins/yang/openconfig/openconfig-types.yang +++ /dev/null @@ -1,455 +0,0 @@ -module openconfig-types { - yang-version "1"; - - namespace "http://openconfig.net/yang/openconfig-types"; - - prefix "oc-types"; - - // import statements - import openconfig-extensions { prefix oc-ext; } - - // meta - organization - "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "This module contains a set of general type definitions that - are used across OpenConfig models. It can be imported by modules - that make use of these types."; - - oc-ext:openconfig-version "0.5.0"; - - revision "2018-05-05" { - description - "Add grouping of min-max-time and - included them to all stats with min/max/avg"; - reference "0.5.0"; - } - - revision "2018-01-16" { - description - "Add interval to min/max/avg stats; add percentage stat"; - reference "0.4.0"; - } - - revision "2017-08-16" { - description - "Apply fix for ieetfloat32 length parameter"; - reference "0.3.3"; - } - - revision "2017-01-13" { - description - "Add ADDRESS_FAMILY identity"; - reference "0.3.2"; - } - - revision "2016-11-14" { - description - "Correct length of ieeefloat32"; - reference "0.3.1"; - } - - revision "2016-11-11" { - description - "Additional types - ieeefloat32 and routing-password"; - reference "0.3.0"; - } - - revision "2016-05-31" { - description - "OpenConfig public release"; - reference "0.2.0"; - } - - typedef percentage { - type uint8 { - range "0..100"; - } - description - "Integer indicating a percentage value"; - } - - typedef std-regexp { - type string; - description - "This type definition is a placeholder for a standard - definition of a regular expression that can be utilised in - OpenConfig models. Further discussion is required to - consider the type of regular expressions that are to be - supported. An initial proposal is POSIX compatible."; - } - - typedef timeticks64 { - type uint64; - description - "This type is based on the timeticks type defined in - RFC 6991, but with 64-bit width. It represents the time, - modulo 2^64, in hundredths of a second between two epochs."; - reference - "RFC 6991 - Common YANG Data Types"; - } - - typedef ieeefloat32 { - type binary { - length "4"; - } - description - "An IEEE 32-bit floating point number. The format of this number - is of the form: - 1-bit sign - 8-bit exponent - 23-bit fraction - The floating point value is calculated using: - (-1)**S * 2**(Exponent-127) * (1+Fraction)"; - } - - typedef routing-password { - type string; - description - "This type is indicative of a password that is used within - a routing protocol which can be returned in plain text to the - NMS by the local system. Such passwords are typically stored - as encrypted strings. Since the encryption used is generally - well known, it is possible to extract the original value from - the string - and hence this format is not considered secure. - Leaves specified with this type should not be modified by - the system, and should be returned to the end-user in plain - text. This type exists to differentiate passwords, which - may be sensitive, from other string leaves. It could, for - example, be used by the NMS to censor this data when - viewed by particular users."; - } - - typedef stat-interval { - type uint64; - units nanoseconds; - description - "A time interval over which a set of statistics is computed. - A common usage is to report the interval over which - avg/min/max stats are computed and reported."; - } - - grouping stat-interval-state { - description - "Reusable leaf definition for stats computation interval"; - - leaf interval { - type oc-types:stat-interval; - description - "If supported by the system, this reports the time interval - over which the min/max/average statistics are computed by - the system."; - } - } - - grouping min-max-time { - description - "Common grouping for recording the absolute time at which - the minimum and maximum values occurred in the statistics"; - - leaf min-time { - type oc-types:timeticks64; - description - "The absolute time at which the minimum value occurred. - The value is the timestamp in nanoseconds relative to - the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; - } - - leaf max-time { - type oc-types:timeticks64; - description - "The absolute time at which the maximum value occurred. - The value is the timestamp in nanoseconds relative to - the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; - } - } - - grouping avg-min-max-stats-precision1 { - description - "Common nodes for recording average, minimum, and - maximum values for a statistic. These values all have - fraction-digits set to 1. Statistics are computed - and reported based on a moving time interval (e.g., the last - 30s). If supported by the device, the time interval over which - the statistics are computed is also reported."; - - leaf avg { - type decimal64 { - fraction-digits 1; - } - description - "The arithmetic mean value of the statistic over the - time interval."; - } - - leaf min { - type decimal64 { - fraction-digits 1; - } - description - "The minimum value of the statistic over the time - interval."; - } - - leaf max { - type decimal64 { - fraction-digits 1; - } - description - "The maximum value of the statitic over the time - interval."; - } - - uses stat-interval-state; - uses min-max-time; - } - - grouping avg-min-max-instant-stats-precision1 { - description - "Common grouping for recording an instantaneous statistic value - in addition to avg-min-max stats"; - - leaf instant { - type decimal64 { - fraction-digits 1; - } - description - "The instantaneous value of the statistic."; - } - - uses avg-min-max-stats-precision1; - } - - grouping avg-min-max-instant-stats-precision2-dB { - description - "Common grouping for recording dB values with 2 decimal - precision. Values include the instantaneous, average, - minimum, and maximum statistics. Statistics are computed - and reported based on a moving time interval (e.g., the last - 30s). If supported by the device, the time interval over which - the statistics are computed, and the times at which the minimum - and maximum values occurred, are also reported."; - - leaf instant { - type decimal64 { - fraction-digits 2; - } - units dB; - description - "The instantaneous value of the statistic."; - } - - leaf avg { - type decimal64 { - fraction-digits 2; - } - units dB; - description - "The arithmetic mean value of the statistic over the - time interval."; - } - - leaf min { - type decimal64 { - fraction-digits 2; - } - units dB; - description - "The minimum value of the statistic over the time interval."; - } - - leaf max { - type decimal64 { - fraction-digits 2; - } - units dB; - description - "The maximum value of the statistic over the time - interval."; - } - - uses stat-interval-state; - uses min-max-time; - } - - grouping avg-min-max-instant-stats-precision2-dBm { - description - "Common grouping for recording dBm values with 2 decimal - precision. Values include the instantaneous, average, - minimum, and maximum statistics. Statistics are computed - and reported based on a moving time interval (e.g., the last - 30s). If supported by the device, the time interval over which - the statistics are computed, and the times at which the minimum - and maximum values occurred, are also reported."; - - leaf instant { - type decimal64 { - fraction-digits 2; - } - units dBm; - description - "The instantaneous value of the statistic."; - } - - leaf avg { - type decimal64 { - fraction-digits 2; - } - units dBm; - description - "The arithmetic mean value of the statistic over the - time interval."; - } - - leaf min { - type decimal64 { - fraction-digits 2; - } - units dBm; - description - "The minimum value of the statistic over the time - interval."; - } - - leaf max { - type decimal64 { - fraction-digits 2; - } - units dBm; - description - "The maximum value of the statistic over the time interval."; - } - - uses stat-interval-state; - uses min-max-time; - } - - grouping avg-min-max-instant-stats-precision2-mA { - description - "Common grouping for recording mA values with 2 decimal - precision. Values include the instantaneous, average, - minimum, and maximum statistics. Statistics are computed - and reported based on a moving time interval (e.g., the last - 30s). If supported by the device, the time interval over which - the statistics are computed, and the times at which the minimum - and maximum values occurred, are also reported."; - - leaf instant { - type decimal64 { - fraction-digits 2; - } - units mA; - description - "The instantaneous value of the statistic."; - } - - leaf avg { - type decimal64 { - fraction-digits 2; - } - units mA; - description - "The arithmetic mean value of the statistic over the - time interval."; - } - - leaf min { - type decimal64 { - fraction-digits 2; - } - units mA; - description - "The minimum value of the statistic over the time - interval."; - } - - leaf max { - type decimal64 { - fraction-digits 2; - } - units mA; - description - "The maximum value of the statistic over the time - interval."; - } - - uses stat-interval-state; - uses min-max-time; - } - - grouping avg-min-max-instant-stats-pct { - description - "Common grouping for percentage statistics. - Values include the instantaneous, average, - minimum, and maximum statistics. Statistics are computed - and reported based on a moving time interval (e.g., the last - 30s). If supported by the device, the time interval over which - the statistics are computed, and the times at which the minimum - and maximum values occurred, are also reported."; - - leaf instant { - type oc-types:percentage; - description - "The instantaneous percentage value."; - } - - leaf avg { - type oc-types:percentage; - description - "The arithmetic mean value of the percentage measure of the - statistic over the time interval."; - } - - leaf min { - type oc-types:percentage; - description - "The minimum value of the percentage measure of the - statistic over the time interval."; - } - - leaf max { - type oc-types:percentage; - description - "The maximum value of the percentage measure of the - statistic over the time interval."; - } - - uses stat-interval-state; - uses min-max-time; - } - - identity ADDRESS_FAMILY { - description - "A base identity for all address families"; - } - - identity IPV4 { - base ADDRESS_FAMILY; - description - "The IPv4 address family"; - } - - identity IPV6 { - base ADDRESS_FAMILY; - description - "The IPv6 address family"; - } - - identity MPLS { - base ADDRESS_FAMILY; - description - "The MPLS address family"; - } - - identity L2_ETHERNET { - base ADDRESS_FAMILY; - description - "The 802.3 Ethernet address family"; - } - -} diff --git a/src/plugins/yang/openconfig/openconfig-types@2018-05-05.yang b/src/plugins/yang/openconfig/openconfig-types@2018-05-05.yang new file mode 100644 index 0000000..01713b3 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-types@2018-05-05.yang @@ -0,0 +1,455 @@ +module openconfig-types { + yang-version "1"; + + namespace "http://openconfig.net/yang/openconfig-types"; + + prefix "oc-types"; + + // import statements + import openconfig-extensions { prefix oc-ext; } + + // meta + organization + "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "This module contains a set of general type definitions that + are used across OpenConfig models. It can be imported by modules + that make use of these types."; + + oc-ext:openconfig-version "0.5.0"; + + revision "2018-05-05" { + description + "Add grouping of min-max-time and + included them to all stats with min/max/avg"; + reference "0.5.0"; + } + + revision "2018-01-16" { + description + "Add interval to min/max/avg stats; add percentage stat"; + reference "0.4.0"; + } + + revision "2017-08-16" { + description + "Apply fix for ieetfloat32 length parameter"; + reference "0.3.3"; + } + + revision "2017-01-13" { + description + "Add ADDRESS_FAMILY identity"; + reference "0.3.2"; + } + + revision "2016-11-14" { + description + "Correct length of ieeefloat32"; + reference "0.3.1"; + } + + revision "2016-11-11" { + description + "Additional types - ieeefloat32 and routing-password"; + reference "0.3.0"; + } + + revision "2016-05-31" { + description + "OpenConfig public release"; + reference "0.2.0"; + } + + typedef percentage { + type uint8 { + range "0..100"; + } + description + "Integer indicating a percentage value"; + } + + typedef std-regexp { + type string; + description + "This type definition is a placeholder for a standard + definition of a regular expression that can be utilised in + OpenConfig models. Further discussion is required to + consider the type of regular expressions that are to be + supported. An initial proposal is POSIX compatible."; + } + + typedef timeticks64 { + type uint64; + description + "This type is based on the timeticks type defined in + RFC 6991, but with 64-bit width. It represents the time, + modulo 2^64, in hundredths of a second between two epochs."; + reference + "RFC 6991 - Common YANG Data Types"; + } + + typedef ieeefloat32 { + type binary { + length "4"; + } + description + "An IEEE 32-bit floating point number. The format of this number + is of the form: + 1-bit sign + 8-bit exponent + 23-bit fraction + The floating point value is calculated using: + (-1)**S * 2**(Exponent-127) * (1+Fraction)"; + } + + typedef routing-password { + type string; + description + "This type is indicative of a password that is used within + a routing protocol which can be returned in plain text to the + NMS by the local system. Such passwords are typically stored + as encrypted strings. Since the encryption used is generally + well known, it is possible to extract the original value from + the string - and hence this format is not considered secure. + Leaves specified with this type should not be modified by + the system, and should be returned to the end-user in plain + text. This type exists to differentiate passwords, which + may be sensitive, from other string leaves. It could, for + example, be used by the NMS to censor this data when + viewed by particular users."; + } + + typedef stat-interval { + type uint64; + units nanoseconds; + description + "A time interval over which a set of statistics is computed. + A common usage is to report the interval over which + avg/min/max stats are computed and reported."; + } + + grouping stat-interval-state { + description + "Reusable leaf definition for stats computation interval"; + + leaf interval { + type oc-types:stat-interval; + description + "If supported by the system, this reports the time interval + over which the min/max/average statistics are computed by + the system."; + } + } + + grouping min-max-time { + description + "Common grouping for recording the absolute time at which + the minimum and maximum values occurred in the statistics"; + + leaf min-time { + type oc-types:timeticks64; + description + "The absolute time at which the minimum value occurred. + The value is the timestamp in nanoseconds relative to + the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; + } + + leaf max-time { + type oc-types:timeticks64; + description + "The absolute time at which the maximum value occurred. + The value is the timestamp in nanoseconds relative to + the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; + } + } + + grouping avg-min-max-stats-precision1 { + description + "Common nodes for recording average, minimum, and + maximum values for a statistic. These values all have + fraction-digits set to 1. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed is also reported."; + + leaf avg { + type decimal64 { + fraction-digits 1; + } + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 1; + } + description + "The minimum value of the statistic over the time + interval."; + } + + leaf max { + type decimal64 { + fraction-digits 1; + } + description + "The maximum value of the statitic over the time + interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-precision1 { + description + "Common grouping for recording an instantaneous statistic value + in addition to avg-min-max stats"; + + leaf instant { + type decimal64 { + fraction-digits 1; + } + description + "The instantaneous value of the statistic."; + } + + uses avg-min-max-stats-precision1; + } + + grouping avg-min-max-instant-stats-precision2-dB { + description + "Common grouping for recording dB values with 2 decimal + precision. Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The instantaneous value of the statistic."; + } + + leaf avg { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The minimum value of the statistic over the time interval."; + } + + leaf max { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The maximum value of the statistic over the time + interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-precision2-dBm { + description + "Common grouping for recording dBm values with 2 decimal + precision. Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The instantaneous value of the statistic."; + } + + leaf avg { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The minimum value of the statistic over the time + interval."; + } + + leaf max { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The maximum value of the statistic over the time interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-precision2-mA { + description + "Common grouping for recording mA values with 2 decimal + precision. Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The instantaneous value of the statistic."; + } + + leaf avg { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The minimum value of the statistic over the time + interval."; + } + + leaf max { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The maximum value of the statistic over the time + interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-pct { + description + "Common grouping for percentage statistics. + Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type oc-types:percentage; + description + "The instantaneous percentage value."; + } + + leaf avg { + type oc-types:percentage; + description + "The arithmetic mean value of the percentage measure of the + statistic over the time interval."; + } + + leaf min { + type oc-types:percentage; + description + "The minimum value of the percentage measure of the + statistic over the time interval."; + } + + leaf max { + type oc-types:percentage; + description + "The maximum value of the percentage measure of the + statistic over the time interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + identity ADDRESS_FAMILY { + description + "A base identity for all address families"; + } + + identity IPV4 { + base ADDRESS_FAMILY; + description + "The IPv4 address family"; + } + + identity IPV6 { + base ADDRESS_FAMILY; + description + "The IPv6 address family"; + } + + identity MPLS { + base ADDRESS_FAMILY; + description + "The MPLS address family"; + } + + identity L2_ETHERNET { + base ADDRESS_FAMILY; + description + "The 802.3 Ethernet address family"; + } + +} diff --git a/src/plugins/yang/openconfig/openconfig-vlan-types.yang b/src/plugins/yang/openconfig/openconfig-vlan-types.yang deleted file mode 100644 index 6d9ab55..0000000 --- a/src/plugins/yang/openconfig/openconfig-vlan-types.yang +++ /dev/null @@ -1,195 +0,0 @@ -module openconfig-vlan-types { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/vlan-types"; - - prefix "oc-vlan-types"; - - // import some basic types - import openconfig-extensions { prefix oc-ext; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "This module defines configuration and state variables for VLANs, - in addition to VLAN parameters associated with interfaces"; - - oc-ext:openconfig-version "3.0.0"; - - revision "2018-02-14" { - description - "Fix bug with name of 802.1ad identity."; - reference "3.0.0"; - } - - revision "2017-07-14" { - description - "Move top-level vlan data to network-instance; Update - identities to comply to style guide; fixed pattern - quoting; corrected trunk vlan types; added TPID config to - base interface."; - reference "2.0.0"; - } - - revision "2016-05-26" { - description - "OpenConfig public release"; - reference "1.0.2"; - } - - // extension statements - - // feature statements - - // identity statements - - identity TPID_TYPES { - description - "Base identity for TPID values that can override the VLAN - ethertype value"; - } - - identity TPID_0X8100 { - base TPID_TYPES; - description - "Default TPID value for 802.1q single-tagged VLANs."; - } - - identity TPID_0X88A8 { - base TPID_TYPES; - description - "TPID value for 802.1ad provider bridging, QinQ or - stacked VLANs."; - } - - identity TPID_0X9100 { - base TPID_TYPES; - description - "Alternate TPID value"; - } - - identity TPID_0X9200 { - base TPID_TYPES; - description - "Alternate TPID value"; - } - - // typedef statements - - // TODO: typedefs should be defined in a vlan-types.yang file. - typedef vlan-id { - type uint16 { - range 1..4094; - } - description - "Type definition representing a single-tagged VLAN"; - } - - typedef vlan-range { - type string { - // range specified as [lower]..[upper] - pattern '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|' + - '40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{1,2}|' + - '[1-9])$'; - } - description - "Type definition representing a range of single-tagged - VLANs. A range is specified as x..y where x and y are - valid VLAN IDs (1 <= vlan-id <= 4094). The range is - assumed to be inclusive, such that any VLAN-ID matching - x <= VLAN-ID <= y falls within the range."; - } - - typedef qinq-id { - type string { - pattern - '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])\.' + - '((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])|\*)$'; - } - description - "Type definition representing a single double-tagged/QinQ VLAN - identifier. The format of a QinQ VLAN-ID is x.y where X is the - 'outer' VLAN identifier, and y is the 'inner' VLAN identifier. - Both x and y must be valid VLAN IDs (1 <= vlan-id <= 4094) - with the exception that y may be equal to a wildcard (*). In - cases where y is set to the wildcard, this represents all inner - VLAN identifiers where the outer VLAN identifier is equal to - x"; - } - - typedef qinq-id-range { - type union { - type string { - // match cases where the range is specified as x..y.z - pattern - '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])\.\.' + - '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])\.' + - '((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])|\*)$'; - } - type string { - // match cases where the range is specified as x.y..z - pattern - '^(\*|(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9]))\.' + - '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])\.\.' + - '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + - '[1-9][0-9]{1,2}|[1-9])$'; - } - } - description - "A type definition representing a range of double-tagged/QinQ - VLAN identifiers. The format of a QinQ VLAN-ID range can be - specified in three formats. Where the range is outer VLAN IDs - the range is specified as x..y.z. In this case outer VLAN - identifiers meeting the criteria x <= outer-vlan-id <= y are - accepted iff the inner VLAN-ID is equal to y - or any inner-tag - if the wildcard is specified. Alternatively the range can be - specified as x.y..z. In this case only VLANs with an - outer-vlan-id qual to x are accepted (x may again be the - wildcard). Inner VLANs are accepted if they meet the inequality - y <= inner-vlan-id <= z."; - } - - typedef vlan-mode-type { - type enumeration { - enum ACCESS { - description "Access mode VLAN interface (No 802.1q header)"; - } - enum TRUNK { - description "Trunk mode VLAN interface"; - } - } - description - "VLAN interface mode (trunk or access)"; - } - - typedef vlan-ref { - type union { - type vlan-id; - type string; - // TODO: string should be changed to leafref to reference - // an existing VLAN. this is not allowed in YANG 1.0 but - // is expected to be in YANG 1.1. - // type leafref { - // path "vlan:vlans/vlan:vlan/vlan:config/vlan:name"; - // } - } - description - "Reference to a VLAN by name or id"; - } - -} diff --git a/src/plugins/yang/openconfig/openconfig-vlan-types@2018-02-14.yang b/src/plugins/yang/openconfig/openconfig-vlan-types@2018-02-14.yang new file mode 100644 index 0000000..6d9ab55 --- /dev/null +++ b/src/plugins/yang/openconfig/openconfig-vlan-types@2018-02-14.yang @@ -0,0 +1,195 @@ +module openconfig-vlan-types { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/vlan-types"; + + prefix "oc-vlan-types"; + + // import some basic types + import openconfig-extensions { prefix oc-ext; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "This module defines configuration and state variables for VLANs, + in addition to VLAN parameters associated with interfaces"; + + oc-ext:openconfig-version "3.0.0"; + + revision "2018-02-14" { + description + "Fix bug with name of 802.1ad identity."; + reference "3.0.0"; + } + + revision "2017-07-14" { + description + "Move top-level vlan data to network-instance; Update + identities to comply to style guide; fixed pattern + quoting; corrected trunk vlan types; added TPID config to + base interface."; + reference "2.0.0"; + } + + revision "2016-05-26" { + description + "OpenConfig public release"; + reference "1.0.2"; + } + + // extension statements + + // feature statements + + // identity statements + + identity TPID_TYPES { + description + "Base identity for TPID values that can override the VLAN + ethertype value"; + } + + identity TPID_0X8100 { + base TPID_TYPES; + description + "Default TPID value for 802.1q single-tagged VLANs."; + } + + identity TPID_0X88A8 { + base TPID_TYPES; + description + "TPID value for 802.1ad provider bridging, QinQ or + stacked VLANs."; + } + + identity TPID_0X9100 { + base TPID_TYPES; + description + "Alternate TPID value"; + } + + identity TPID_0X9200 { + base TPID_TYPES; + description + "Alternate TPID value"; + } + + // typedef statements + + // TODO: typedefs should be defined in a vlan-types.yang file. + typedef vlan-id { + type uint16 { + range 1..4094; + } + description + "Type definition representing a single-tagged VLAN"; + } + + typedef vlan-range { + type string { + // range specified as [lower]..[upper] + pattern '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|' + + '40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{1,2}|' + + '[1-9])$'; + } + description + "Type definition representing a range of single-tagged + VLANs. A range is specified as x..y where x and y are + valid VLAN IDs (1 <= vlan-id <= 4094). The range is + assumed to be inclusive, such that any VLAN-ID matching + x <= VLAN-ID <= y falls within the range."; + } + + typedef qinq-id { + type string { + pattern + '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])\.' + + '((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])|\*)$'; + } + description + "Type definition representing a single double-tagged/QinQ VLAN + identifier. The format of a QinQ VLAN-ID is x.y where X is the + 'outer' VLAN identifier, and y is the 'inner' VLAN identifier. + Both x and y must be valid VLAN IDs (1 <= vlan-id <= 4094) + with the exception that y may be equal to a wildcard (*). In + cases where y is set to the wildcard, this represents all inner + VLAN identifiers where the outer VLAN identifier is equal to + x"; + } + + typedef qinq-id-range { + type union { + type string { + // match cases where the range is specified as x..y.z + pattern + '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])\.\.' + + '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])\.' + + '((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])|\*)$'; + } + type string { + // match cases where the range is specified as x.y..z + pattern + '^(\*|(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9]))\.' + + '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])\.\.' + + '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' + + '[1-9][0-9]{1,2}|[1-9])$'; + } + } + description + "A type definition representing a range of double-tagged/QinQ + VLAN identifiers. The format of a QinQ VLAN-ID range can be + specified in three formats. Where the range is outer VLAN IDs + the range is specified as x..y.z. In this case outer VLAN + identifiers meeting the criteria x <= outer-vlan-id <= y are + accepted iff the inner VLAN-ID is equal to y - or any inner-tag + if the wildcard is specified. Alternatively the range can be + specified as x.y..z. In this case only VLANs with an + outer-vlan-id qual to x are accepted (x may again be the + wildcard). Inner VLANs are accepted if they meet the inequality + y <= inner-vlan-id <= z."; + } + + typedef vlan-mode-type { + type enumeration { + enum ACCESS { + description "Access mode VLAN interface (No 802.1q header)"; + } + enum TRUNK { + description "Trunk mode VLAN interface"; + } + } + description + "VLAN interface mode (trunk or access)"; + } + + typedef vlan-ref { + type union { + type vlan-id; + type string; + // TODO: string should be changed to leafref to reference + // an existing VLAN. this is not allowed in YANG 1.0 but + // is expected to be in YANG 1.1. + // type leafref { + // path "vlan:vlans/vlan:vlan/vlan:config/vlan:name"; + // } + } + description + "Reference to a VLAN by name or id"; + } + +} diff --git a/src/plugins/yang/openconfig/openconfig-vlan.yang b/src/plugins/yang/openconfig/openconfig-vlan.yang deleted file mode 100644 index 97348c0..0000000 --- a/src/plugins/yang/openconfig/openconfig-vlan.yang +++ /dev/null @@ -1,438 +0,0 @@ -module openconfig-vlan { - - yang-version "1"; - - // namespace - namespace "http://openconfig.net/yang/vlan"; - - prefix "oc-vlan"; - - // import some basic types - import openconfig-vlan-types { prefix oc-vlan-types; } - import openconfig-interfaces { prefix oc-if; } - import openconfig-if-ethernet { prefix oc-eth; } - import openconfig-if-aggregate { prefix oc-lag; } - import iana-if-type { prefix ift; } - import openconfig-extensions { prefix oc-ext; } - - // meta - organization "OpenConfig working group"; - - contact - "OpenConfig working group - netopenconfig@googlegroups.com"; - - description - "This module defines configuration and state variables for VLANs, - in addition to VLAN parameters associated with interfaces"; - - oc-ext:openconfig-version "3.0.1"; - - revision "2018-06-05" { - description - "Fix bugs in when statements."; - reference "3.0.1"; - } - - revision "2018-02-14" { - description - "Fix bug with name of 802.1ad identity."; - reference "3.0.0"; - } - - revision "2017-07-14" { - description - "Move top-level vlan data to network-instance; Update - identities to comply to style guide; fixed pattern - quoting; corrected trunk vlan types; added TPID config to - base interface."; - reference "2.0.0"; - } - - revision "2016-05-26" { - description - "OpenConfig public release"; - reference "1.0.2"; - } - - // grouping statements - - grouping vlan-config { - description "VLAN configuration container."; - - leaf vlan-id { - type oc-vlan-types:vlan-id; - description "Interface VLAN id."; - } - - leaf name { - type string; - description "Interface VLAN name."; - } - - leaf status { - type enumeration { - enum ACTIVE { - description "VLAN is active"; - } - enum SUSPENDED { - description "VLAN is inactive / suspended"; - } - } - default ACTIVE; - description "Admin state of the VLAN"; - } - - } - - grouping vlan-state { - description "State variables for VLANs"; - - // placeholder - - } - - grouping vlan-tpid-config { - description - "TPID configuration for dot1q-enabled interfaces"; - - leaf tpid { - type identityref { - base oc-vlan-types:TPID_TYPES; - } - default oc-vlan-types:TPID_0X8100; - description - "Optionally set the tag protocol identifier field (TPID) that - is accepted on the VLAN"; - } - } - - grouping vlan-tpid-state { - description - "TPID opstate for dot1q-enabled interfaces"; - - // placeholder - - } - - grouping vlan-members-state { - description - "List of interfaces / subinterfaces belonging to the VLAN."; - - container members { - description - "Enclosing container for list of member interfaces"; - - list member { - config false; - description - "List of references to interfaces / subinterfaces - associated with the VLAN."; - - uses oc-if:base-interface-ref-state; - } - } - } - - grouping vlan-switched-config { - description - "VLAN related configuration that is part of the physical - Ethernet interface."; - - leaf interface-mode { - type oc-vlan-types:vlan-mode-type; - description - "Set the interface to access or trunk mode for - VLANs"; - } - - leaf native-vlan { - when "../interface-mode = 'TRUNK'" { - description - "Native VLAN is valid for trunk mode interfaces"; - } - type oc-vlan-types:vlan-id; - description - "Set the native VLAN id for untagged frames arriving on - a trunk interface. Tagged frames sent on an interface - configured with a native VLAN should have their tags - stripped prior to transmission. This configuration is only - valid on a trunk interface."; - } - - leaf access-vlan { - when "../interface-mode = 'ACCESS'" { - description - "Access VLAN assigned to the interfaces"; - } - type oc-vlan-types:vlan-id; - description - "Assign the access vlan to the access port."; - } - - leaf-list trunk-vlans { - when "../interface-mode = 'TRUNK'" { - description - "Allowed VLANs may be specified for trunk mode - interfaces."; - } - type union { - type oc-vlan-types:vlan-id; - type oc-vlan-types:vlan-range; - } - description - "Specify VLANs, or ranges thereof, that the interface may - carry when in trunk mode. If not specified, all VLANs are - allowed on the interface. Ranges are specified in the form - x..y, where x + +#include +#include +#include + +typedef enum { + SCVPP_OK = 0, /* Success */ + SCVPP_EINVAL, /* Invalid value encountered */ + SCVPP_EAGAIN, /* Operation would block */ + SCVPP_ENOTSUP, /* Operation not supported */ + SCVPP_ENOMEM, /* Out of memory */ + SCVPP_NOT_FOUND, /* Required element can not be found */ +} scvpp_error_e; + +// Use VAPI macros to define symbols +DEFINE_VAPI_MSG_IDS_VPE_API_JSON; + +#define VPP_IP4_HOST_PREFIX_LEN 32 +#define VPP_INTFC_NAME_LEN 64 /* Interface name max length */ +#define VPP_IP4_ADDRESS_LEN 4 /* IPv4 length in VPP format */ +#define VPP_IP6_ADDRESS_LEN 16 /* IPv6 length in VPP format */ +#define VPP_MAC_ADDRESS_LEN 8 /* MAC length in VPP format */ +/* IPv4 and IPv6 length in string format */ +#define VPP_IP4_ADDRESS_STRING_LEN INET_ADDRSTRLEN //16, include '\0' +#define VPP_IP6_ADDRESS_STRING_LEN INET6_ADDRSTRLEN //46, include '\0' +#define VPP_IP4_PREFIX_STRING_LEN \ + INET_ADDRSTRLEN + sizeof('/') + 2 // include '\0' +#define VPP_IP6_PREFIX_STRING_LEN \ + INET6_ADDRSTRLEN + sizeof('/') + 3 // include '\0' + +/**********************************MACROS**********************************/ +#define ARG_CHECK(retval, arg) \ + do \ + { \ + if (NULL == (arg)) \ + { \ + return (retval); \ + } \ + } \ + while (0) + +#define ARG_CHECK2(retval, arg1, arg2) \ + ARG_CHECK(retval, arg1); \ + ARG_CHECK(retval, arg2) + +#define ARG_CHECK3(retval, arg1, arg2, arg3) \ + ARG_CHECK(retval, arg1); \ + ARG_CHECK(retval, arg2); \ + ARG_CHECK(retval, arg3) + +#define ARG_CHECK4(retval, arg1, arg2, arg3, arg4) \ + ARG_CHECK(retval, arg1); \ + ARG_CHECK(retval, arg2); \ + ARG_CHECK(retval, arg3); \ + ARG_CHECK(retval, arg4) + +/* Suppress compiler warning about unused variable. + * This must be used only for callback function else suppress your unused + * parameter in function prototype. */ +#define UNUSED(x) (void)x + +#define VAPI_RETVAL_CB(api_name) \ +static vapi_error_e \ +api_name##_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, \ + vapi_payload_##api_name##_reply * reply) \ +{ \ + UNUSED(ctx); UNUSED(caller_ctx); UNUSED(rv); UNUSED(is_last); \ + return reply->retval; \ +} + +#define VAPI_COPY_CB(api_name) \ +static vapi_error_e \ +api_name##_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, \ + vapi_payload_##api_name##_reply * reply) \ +{ \ + UNUSED(ctx); UNUSED(rv); UNUSED(is_last); \ + vapi_payload_##api_name##_reply * passed; \ + if (caller_ctx) \ + { \ + passed = (vapi_payload_##api_name##_reply *)caller_ctx; \ + *passed = *reply; \ + } \ + return VAPI_OK; \ +}\ + +#define VAPI_CALL_MODE(call_code, vapi_mode) \ + do \ + { \ + if (VAPI_MODE_BLOCKING == (vapi_mode)) \ + { \ + rv = call_code; \ + } \ + else \ + { \ + while (VAPI_EAGAIN == (rv = call_code)); \ + if (rv != VAPI_OK) { /* try once more to get reply */ \ + rv = vapi_dispatch (g_vapi_ctx); \ + } \ + } \ + } \ + while (0) + +#define VAPI_CALL(call_code) VAPI_CALL_MODE(call_code, g_vapi_mode) + +struct elt { + void *data; //vapi_payload structure + struct elt *next; + int id; //id of the stack element to count total nb of elements +}; + +static inline int push(struct elt **stack, void *data, int length) +{ + struct elt *el; + + //new stack node + el = malloc(sizeof(struct elt)); + if (!el) + return -ENOMEM; + el->data = malloc(length); + if (!el->data) + return -ENOMEM; + + memcpy(el->data, data, length); + if (*stack) + el->id = (*stack)->id++; + else + el->id = 0; + el->next = *stack; //point to old value of stack + *stack = el; //el is new stack head + + return 0; +} + +static inline void * pop(struct elt **stack) +{ + struct elt *prev; + void *data; + + if (!(*stack)) + return NULL; + + data = (*stack)->data; //get data at stack head + prev = *stack; //save stack to free memory later + *stack = (*stack)->next; //new stack + + free(prev); + prev = NULL; + + return data; +} + +#define VAPI_DUMP_LIST_CB(api_name) \ +static vapi_error_e \ +api_name##_all_cb(vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, \ + vapi_payload_##api_name##_details *reply) \ +{ \ + UNUSED(ctx); UNUSED(rv); UNUSED(is_last); \ + struct elt **stackp; \ + ARG_CHECK2(VAPI_EINVAL, caller_ctx, reply); \ + \ + stackp = (struct elt**) caller_ctx; \ + push(stackp, reply, sizeof(*reply)); \ + \ + return VAPI_OK; \ +} + +#define foreach_stack_elt(stack) \ + for(void *data = pop(&stack); data != NULL ; data = pop(&stack)) +//for(void *data = pop(&stack); stack != NULL ; data = pop(&stack)) // No!! + +int sc_aton(const char *cp, u8 * buf, size_t length); +char * sc_ntoa(const u8 * buf); + +/** + * @brief Function converts the u8 array from network byte order to host byte order. + * + * @param[in] host IPv4 address. + * @return host byte order value. + */ +uint32_t hardntohlu32(uint8_t host[4]); + +/* + * VPP + */ + +extern vapi_ctx_t g_vapi_ctx; +extern vapi_mode_e g_vapi_mode; + +int sc_connect_vpp(); +int sc_disconnect_vpp(); +int sc_end_with(const char* str, const char* end); + +#endif //__SC_VPP_COMMM_H__ diff --git a/src/scvpp/inc/scvpp/interface.h b/src/scvpp/inc/scvpp/interface.h new file mode 100644 index 0000000..86cd185 --- /dev/null +++ b/src/scvpp/inc/scvpp/interface.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __BAPI_INTERFACE_H__ +#define __BAPI_INTERFACE_H__ + +#include +#include + +typedef vapi_payload_sw_interface_details sw_interface_dump_t; + +/** + * @brief Change an interface state + * @param interface_name - name of target interface + * @param enable - true=state up, false=state down + * @return 0 for success, else negative SCVPP error code + */ +int interface_enable(const char *interface_name, const bool enable); + +/** + * @brief Dump details about all existing interfaces + * @return stack structure containing all interfaces or NULL if empty + */ +extern struct elt * interface_dump_all(); + + +/** + * @brief Dump details about a specific interface + * @param details - where answer will be written + * @param interface_name - name of the interface to dump + * @return 0 for success or negative SCVPP error code + */ +extern int interface_dump_iface(sw_interface_dump_t *details, + const char *interface_name); + +/* + * Library internal helper functions. Symbols should not be exported eventually + */ + +/* + * @brief Get VPP internal index for an interface + * @param interface_name - name of the interface to get id from + * @param sw_if_index - pointer to interface index to be returned + * @return 0 upon success or negative SCVPP error code + */ +extern int get_interface_id(const char *interface_name, uint32_t *sw_if_index); + +/* @brief Get interface name from an interface ID. This is a super expensive + * operation !!! Avoid using it. + * @param interface_name - pointer to string holding returned interface name + * @param sw_if_index - interface index provided + * @return 0 upon success or negative SCVPP error code + */ +extern int get_interface_name(char *interface_name, uint32_t sw_if_index); + +#endif /* __BAPI_INTERFACE_H__ */ diff --git a/src/scvpp/inc/scvpp/ip.h b/src/scvpp/inc/scvpp/ip.h new file mode 100644 index 0000000..f8805b3 --- /dev/null +++ b/src/scvpp/inc/scvpp/ip.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __BAPI_IP_H__ +#define __BAPI_IP_H__ + +#include +#include + +typedef vapi_payload_ip_fib_details fib_dump_t; + +/* + * @brief Dump IPv4/IPv6 address from an interface. + * @param interface_name - name of the interface to get ip from. + * @param ip_addr - where dump will store IP. If IP not found, returns 0.0.0.0 + * @param prefix_len - pointer where dump will store prefix + * @param is_ipv6 - true = IPv6, false = IPv4 + * @return 0 on success, or nergative SCVPP error code + */ +extern int ipv46_address_dump(const char *interface_name, char *ip_addr, + u8 *prefix_len, bool is_ipv6); + +/** + * @brief Add or remove IPv4/IPv6 address to/from an interface. + * @param interface_name - name of interface to configure + * @param addr - address to add + * @param prefix_len - prefix length of interface + * @param is_ipv6 - true if ipv6, false otherwise + * @param add - true to add, false to remove + */ +extern int ipv46_config_add_remove(const char *interface_name, const char *addr, + uint8_t prefix_len, bool is_ipv6, bool add); + +/* + * TODO should add a field is_ipv6 because it only do ipv4 now + * @brief Add or remove an IP route + * @param dst_address - subnet IP you wish to route + * @param dst_address_length - prefix length for subnet you wish to route + * @param next_address - Next hop IP (can use next_hop_interface instead) + * @param is_add - true to add, false to remove + * @param table_id - id of the tab in FIB + * @param next_hop_interface - Next hop interface (can use next_address instead) + */ +extern int +ipv46_config_add_del_route(const char* dst_address, u8 dst_address_length, + const char* next_address, u8 is_add, u32 table_id, + const char *next_hop_interface); + +/** + * @brief Dump all FIB tables entries + * @return stacked answers on success, or NULL on failure + */ +extern struct elt* ipv4_fib_dump_all(); + +/* + * @brief Dump information about a prefix, based on fib_dump_all + * @param prefix_xpath - prefix to look for in FIB + * @param reply - FIB entry dump replied + * @return SCVPP_OK if prefix found or SCVPP_NOT_FOUND + */ +extern int ipv4_fib_dump_prefix(const char *prefix_xpath, fib_dump_t **reply); + +#endif /* __BAPI_IP_H__ */ diff --git a/src/scvpp/inc/scvpp/nat.h b/src/scvpp/inc/scvpp/nat.h new file mode 100644 index 0000000..40e727e --- /dev/null +++ b/src/scvpp/inc/scvpp/nat.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __BAPI_NAT_H__ +#define __BAPI_NAT_H__ + +#include + +typedef vapi_payload_nat44_interface_details nat44_interface_details_t; +typedef vapi_payload_nat44_add_del_interface_addr nat44_add_del_interface_addr_t; +typedef vapi_payload_nat44_add_del_address_range nat44_add_del_address_range_t; +typedef vapi_payload_nat44_add_del_static_mapping nat44_add_del_static_mapping_t; +typedef vapi_payload_nat44_static_mapping_details nat44_static_mapping_details_t; +typedef vapi_payload_nat44_forwarding_enable_disable nat44_forwarding_enable_disable_t; +typedef vapi_payload_nat_set_workers nat_set_workers_t; + + +//Wrapper function, if we want hide the VAPI return value +extern int nat44_interface_dump(nat44_interface_details_t *reply); +extern int nat44_add_del_interface_addr( + const nat44_add_del_interface_addr_t *msg); +extern int nat44_add_del_addr_range(const nat44_add_del_address_range_t *range); +extern int nat44_add_del_static_mapping( + const nat44_add_del_static_mapping_t *msg); +extern int nat44_static_mapping_dump(nat44_static_mapping_details_t *reply); +extern int nat44_forwarding_enable_disable( + const nat44_forwarding_enable_disable_t *msg); +extern int nat_set_workers(const nat_set_workers_t *msg); + + +// Alternative, if we don't want hide VAPI return value + +// extern vapi_error_e bin_api_nat44_interface_dump(nat44_interface_details_t *reply); +// extern vapi_error_e bin_api_nat44_add_del_interface_addr( +// const nat44_add_del_interface_addr_t *msg); +// extern vapi_error_e bin_api_nat44_add_del_addr_range( +// const nat44_add_del_address_range_t *range); +// extern vapi_error_e bin_api_nat44_add_del_static_mapping( +// const nat44_add_del_static_mapping_t *msg); +// extern vapi_error_e bin_api_nat44_static_mapping_dump( +// nat44_static_mapping_details_t *reply); +// extern vapi_error_e bin_api_nat44_forwarding_enable_disable( +// const nat44_forwarding_enable_disable_t *msg); +// extern vapi_error_e bin_api_nat_set_workers(const nat_set_workers_t *msg); + + +#endif /* __BAPI_NAT_H__ */ + diff --git a/src/scvpp/inc/scvpp/v3po.h b/src/scvpp/inc/scvpp/v3po.h new file mode 100644 index 0000000..f876ab4 --- /dev/null +++ b/src/scvpp/inc/scvpp/v3po.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _V3PO__INTERFACE_H__ +#define _V3PO__INTERFACE_H__ + +#include +#include + +/** + * V3PO defines operations for specific interfaces used by VPP like: + * - tapv2 + */ + +/* tapv2 */ + +typedef vapi_payload_tap_create_v2 tapv2_create_t; +typedef vapi_payload_sw_interface_tap_v2_details tapv2_dump_t; + +/** + * TODO problem: vapi_payload_sw_interface_tap_v2_details reply is NULL + * @brief Dump information about a tap interface + * @param dump - where dump information will be stored + * @return 0 on success, or negative SCVPP error code + */ +extern int dump_tapv2(tapv2_dump_t *dump); + +/** + * @brief Create a tapv2 interface + * @param query - required structure for the creation of a VPP tapv2 interface + * @return 0 on success, or negative SCVPP error code + */ +extern int create_tapv2(tapv2_create_t *query); + +/** + * @brief Delete a tapv2 interface + * @param interface_name - name of the interface to delete + * @return 0 on success, or negative SCVPP error code + */ +extern int delete_tapv2(char *interface_name); + +#endif /* __V3PO_INTERFACE_H__ */ diff --git a/src/scvpp/src/CMakeLists.txt b/src/scvpp/src/CMakeLists.txt deleted file mode 100644 index 71a891f..0000000 --- a/src/scvpp/src/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright (c) 2018 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# scvpp sources -set(SCVPP_SOURCES - sc_vpp_comm.c - sc_vpp_interface.c - sc_vpp_ip.c - sc_vpp_v3po.c - sc_vpp_nat.c -) - -# scvpp public headers -set(SCVPP_HEADERS - sc_vpp_comm.h - sc_vpp_interface.h - sc_vpp_ip.h - sc_vpp_v3po.h - sc_vpp_nat.h -) - -# Generate a compile_commands.json with compile options -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) - -#set compiler and linker flags -set(RIGOROUS_C_FLAGS "-Wlogical-op -Wformat=2") -set(CMAKE_C_FLAGS "-Wall -Wextra -std=gnu99 ${RIGOROUS_C_FLAGS}") -set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -std=gnu99 -g -O0 ${RIGOROUS_C_FLAGS}") -#NDEBUG to skip assert checks -set(CMAKE_C_FLAGS_RELEASE "-Wall -Wextra -std=gnu99 -DNDEBUG -O2 ${RIGOROUS_C_FLAGS}") - -# libraries to link with -set(LINK_LIBRARIES vlibmemoryclient vapiclient vppapiclient svm vppinfra pthread rt dl) - -# build instructions -add_library(scvpp SHARED ${SCVPP_SOURCES}) -add_library(scvpp_a ${SCVPP_SOURCES}) - -# linker instructions -target_link_libraries(scvpp ${LINK_LIBRARIES}) -target_link_libraries(scvpp_a ${LINK_LIBRARIES}) - -# install rules -install(TARGETS scvpp DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES ${SCVPP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/src/scvpp/src/comm.c b/src/scvpp/src/comm.c new file mode 100644 index 0000000..a065b58 --- /dev/null +++ b/src/scvpp/src/comm.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018 HUACHENTEL and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include +#include +#include +#include +#include + +#define APP_NAME "sweetcomb_vpp" +#define MAX_OUTSTANDING_REQUESTS 4 +#define RESPONSE_QUEUE_SIZE 2 + +vapi_ctx_t g_vapi_ctx = NULL; +vapi_mode_e g_vapi_mode = VAPI_MODE_NONBLOCKING; + +int sc_connect_vpp() +{ + if (g_vapi_ctx == NULL) + { + vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx); + rv = vapi_connect(g_vapi_ctx, APP_NAME, NULL, + MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE, + VAPI_MODE_BLOCKING, true); + if (rv != VAPI_OK) + { + vapi_ctx_free(g_vapi_ctx); + g_vapi_ctx = NULL; + return -1; + } + } + + return 0; +} + +int sc_disconnect_vpp() +{ + if (NULL != g_vapi_ctx) + { + vapi_disconnect(g_vapi_ctx); + vapi_ctx_free(g_vapi_ctx); + g_vapi_ctx = NULL; + } + return 0; +} + +int sc_end_with(const char* str, const char* end) +{ + if (str != NULL && end != NULL) + { + int l1 = strlen(str); + int l2 = strlen(end); + if (l1 >= l2) + { + if (strcmp(str + l1 - l2, end) == 0) + return 1; + } + } + return 0; +} + +int sc_aton(const char *cp, u8 * buf, size_t length) +{ + ARG_CHECK2(false, cp, buf); + + struct in_addr addr; + int ret = inet_aton(cp, &addr); + + if (0 == ret) + return -EINVAL; + + if (sizeof(addr) > length) + return -EINVAL; + + memcpy(buf, &addr, sizeof (addr)); + + return 0; +} + +char* sc_ntoa(const u8 * buf) +{ + ARG_CHECK(NULL, buf); + + struct in_addr addr; + memcpy(&addr, buf, sizeof(addr)); + return inet_ntoa(addr); +} + +/** + * @brief Function converts the u8 array from network byte order to host byte order. + * + * @param[in] host IPv4 address. + * @return host byte order value. + */ +uint32_t hardntohlu32(uint8_t host[4]) +{ + uint32_t tmp = host[3] | host[2] | host[1] | host[0]; + + return ntohl(tmp); +} diff --git a/src/scvpp/src/interface.c b/src/scvpp/src/interface.c new file mode 100644 index 0000000..53cea1c --- /dev/null +++ b/src/scvpp/src/interface.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + +// Use VAPI macros to define symbols +DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON + +static vapi_error_e +sw_interface_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx, + vapi_error_e rv, bool is_last, + vapi_payload_sw_interface_details *reply) +{ + UNUSED(rv); UNUSED(ctx); UNUSED(is_last); + + vapi_payload_sw_interface_details *passed; + + ARG_CHECK2(VAPI_EINVAL, callback_ctx, reply); + + //copy + passed = (vapi_payload_sw_interface_details *) callback_ctx; + *passed = *reply; + + return VAPI_OK; +} + +static vapi_error_e +bin_api_sw_interface_dump(vapi_payload_sw_interface_details *details, + const char *iface_name) +{ + vapi_msg_sw_interface_dump *mp; + vapi_error_e rv; + + mp = vapi_alloc_sw_interface_dump(g_vapi_ctx); + assert(NULL != mp); + + /* Dump a specific interfaces */ + mp->payload.name_filter_valid = true; + strncpy((char *)mp->payload.name_filter, iface_name, VPP_INTFC_NAME_LEN); + + VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx, mp, + sw_interface_dump_cb, details)); + if (rv != VAPI_OK) + return -SCVPP_EINVAL; + + return rv; +} + +int get_interface_id(const char *if_name, uint32_t *sw_if_index) +{ + vapi_payload_sw_interface_details details = {0}; + vapi_error_e rv; + + ARG_CHECK2(-SCVPP_EINVAL, if_name, sw_if_index); + + rv = bin_api_sw_interface_dump(&details, if_name); + if (rv != VAPI_OK) + return -SCVPP_EINVAL; + + if (strncmp(if_name, (char*) details.interface_name, VPP_INTFC_NAME_LEN) + != 0) + return -SCVPP_NOT_FOUND; + + *sw_if_index = details.sw_if_index; + + return 0; +} + +/* + * dump only a specific interface + */ +int interface_dump_iface(sw_interface_dump_t *details, const char *iface_name) +{ + vapi_error_e rv; + + rv = bin_api_sw_interface_dump(details, iface_name); + if (rv != VAPI_OK) + return -SCVPP_EINVAL; + + if (strncmp(iface_name, (char*) details->interface_name, VPP_INTFC_NAME_LEN) + != 0) + return -SCVPP_NOT_FOUND; + + return SCVPP_OK; +} + +VAPI_DUMP_LIST_CB(sw_interface) + +struct elt* interface_dump_all() +{ + struct elt* stack = NULL; + vapi_msg_sw_interface_dump *mp; + vapi_error_e rv; + + mp = vapi_alloc_sw_interface_dump(g_vapi_ctx); + + /* Dump all */ + mp->payload.name_filter_valid = false; + memset(mp->payload.name_filter, 0, sizeof(mp->payload.name_filter)); + + VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx, mp, sw_interface_all_cb, + &stack)); + if (VAPI_OK != rv) + return NULL; + + return stack; +} + +VAPI_RETVAL_CB(sw_interface_set_flags); + +int interface_enable(const char *interface_name, const bool enable) +{ + vapi_msg_sw_interface_set_flags *mp; + uint32_t sw_if_index; + vapi_error_e rv; + int rc; + + ARG_CHECK(-SCVPP_EINVAL, interface_name); + + rc = get_interface_id(interface_name, &sw_if_index); + if (rc != 0) + return -SCVPP_NOT_FOUND; + + mp = vapi_alloc_sw_interface_set_flags(g_vapi_ctx); + assert(NULL != mp); + mp->payload.sw_if_index = sw_if_index; + mp->payload.admin_up_down = enable; + + VAPI_CALL(vapi_sw_interface_set_flags(g_vapi_ctx, mp, + sw_interface_set_flags_cb, NULL)); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return 0; +} + +int get_interface_name(char *interface_name, uint32_t sw_if_index) +{ + struct elt *stack= NULL; + sw_interface_dump_t *dump; + int rc = -SCVPP_NOT_FOUND; + + stack = interface_dump_all(); + if (!stack) + return -SCVPP_NOT_FOUND; + + foreach_stack_elt(stack) { + dump = (sw_interface_dump_t *) data; + + if (dump->sw_if_index == sw_if_index) { + strncpy(interface_name, (char *)dump->interface_name, VPP_INTFC_NAME_LEN); + rc = SCVPP_OK; + } + + free(dump); + } + + return rc; +} diff --git a/src/scvpp/src/ip.c b/src/scvpp/src/ip.c new file mode 100644 index 0000000..2dc991c --- /dev/null +++ b/src/scvpp/src/ip.c @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include + +// Use VAPI macros to define symbols +DEFINE_VAPI_MSG_IDS_IP_API_JSON + +VAPI_RETVAL_CB(sw_interface_add_del_address); + +static vapi_error_e +bin_api_sw_interface_add_del_address(u32 sw_if_index, bool is_add, bool is_ipv6, + bool del_all, u8 address_length, + const char *ip_address) +{ + vapi_msg_sw_interface_add_del_address *mp; + vapi_error_e rv; + + ARG_CHECK(VAPI_EINVAL, ip_address); + + mp = vapi_alloc_sw_interface_add_del_address(g_vapi_ctx); + assert(NULL != mp); + + mp->payload.sw_if_index = sw_if_index; + mp->payload.is_add = is_add; + mp->payload.is_ipv6 = is_ipv6; + mp->payload.del_all = del_all; + mp->payload.address_length = address_length; + if (sc_aton(ip_address, mp->payload.address, VPP_IP4_ADDRESS_LEN)) + return VAPI_EINVAL; + + VAPI_CALL(vapi_sw_interface_add_del_address(g_vapi_ctx, mp, + sw_interface_add_del_address_cb, NULL)); + + return rv; +} + +VAPI_COPY_CB(ip_add_del_route) + +static vapi_error_e +bin_api_ip_add_del_route(vapi_payload_ip_add_del_route_reply * reply, + const char* dst_address, uint8_t dst_address_length, + const char* next_hop, uint8_t is_add, + uint32_t table_id, const char *next_interface) +{ + vapi_msg_ip_add_del_route *mp; + uint32_t sw_if_index; + vapi_error_e rv ; + int rc; + + ARG_CHECK2(VAPI_EINVAL, reply, dst_address); + + //Require interface or next hop IP or both + if (!next_interface && !next_hop) + return VAPI_EINVAL; + + mp = vapi_alloc_ip_add_del_route(g_vapi_ctx, 1); + assert(NULL != mp); + + if (next_interface) { + rc = get_interface_id(next_interface, &sw_if_index); + if (rc < 0) + return VAPI_EINVAL; + } + + mp->payload.is_add = is_add; + mp->payload.table_id = table_id; + mp->payload.is_ipv6 = false; + mp->payload.is_local = false; + sc_aton(dst_address, mp->payload.dst_address, VPP_IP4_ADDRESS_LEN); + mp->payload.dst_address_length = dst_address_length; + if (next_interface) //interface is not mandatory + mp->payload.next_hop_sw_if_index = sw_if_index; + if (next_hop) //next hop ip is not mandatory + sc_aton(next_hop, mp->payload.next_hop_address, VPP_IP4_ADDRESS_LEN); + + VAPI_CALL(vapi_ip_add_del_route(g_vapi_ctx, mp, + ip_add_del_route_cb, reply)); + + return rv; +} + +static vapi_error_e +ip_address_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, + bool is_last, vapi_payload_ip_address_details *reply) +{ + UNUSED(rv); + vapi_payload_ip_address_details *passed; + + ARG_CHECK3(VAPI_EINVAL, ctx, callback_ctx, reply); + + //copy dump reply in callback context + if (!is_last) { + passed = (vapi_payload_ip_address_details *) callback_ctx; + *passed = *reply; + } + + return VAPI_OK; +} + +static vapi_error_e +bin_api_ip_address_dump(u32 sw_if_index, bool is_ipv6, + vapi_payload_ip_address_details *dctx) +{ + vapi_msg_ip_address_dump *mp; + vapi_error_e rv; + + mp = vapi_alloc_ip_address_dump(g_vapi_ctx); + assert(mp != NULL); + + mp->payload.sw_if_index = sw_if_index; + mp->payload.is_ipv6 = is_ipv6; + + VAPI_CALL(vapi_ip_address_dump(g_vapi_ctx, mp, ip_address_dump_cb, + dctx)); + if (rv != VAPI_OK) + return rv; + + return VAPI_OK; +} + +///VAPI_DUMP_LIST_CB(ip_fib); can not be used because of path flexible array + +static vapi_error_e +ip_fib_all_cb(vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, + vapi_payload_ip_fib_details *reply) +{ + UNUSED(ctx); UNUSED(rv); UNUSED(is_last); + struct elt **stackp; + ARG_CHECK2(VAPI_EINVAL, caller_ctx, reply); + + stackp = (struct elt**) caller_ctx; + push(stackp, reply, sizeof(*reply)+reply->count*sizeof(vapi_type_fib_path)); + + return VAPI_OK; +} + +struct elt* ipv4_fib_dump_all() +{ + struct elt *stack = NULL; + vapi_msg_ip_fib_dump *mp; + vapi_error_e rv; + + mp = vapi_alloc_ip_fib_dump(g_vapi_ctx); + assert(mp != NULL); + + VAPI_CALL(vapi_ip_fib_dump(g_vapi_ctx, mp, ip_fib_all_cb, &stack)); + if(VAPI_OK != rv) + return NULL; + + return stack; +} + +int ipv4_fib_dump_prefix(const char *prefix_xpath, fib_dump_t **reply) +{ + struct elt *stack = NULL; + char prefix[VPP_IP4_PREFIX_STRING_LEN]; + fib_dump_t *dump; + int rc = -SCVPP_NOT_FOUND; + + stack = ipv4_fib_dump_all(); + if (!stack) + return rc; + + foreach_stack_elt(stack) { + dump = (fib_dump_t *) data; + + if (rc == -SCVPP_NOT_FOUND) { + snprintf(prefix, VPP_IP4_PREFIX_STRING_LEN, "%s/%u", + sc_ntoa(dump->address), dump->address_length); + if (!strncmp(prefix_xpath, prefix, VPP_IP4_PREFIX_STRING_LEN)) { + *reply = dump; + rc = SCVPP_OK; + continue; + } + } + + free(dump); + } + + return rc; +} + +int ipv46_address_dump(const char *interface_name, char *ip_addr, + u8 *prefix_len, bool is_ipv6) +{ + vapi_payload_ip_address_details dctx = {0}; + uint32_t sw_if_index; + vapi_error_e rv; + int rc; + + rc = get_interface_id(interface_name, &sw_if_index); + if (rc < 0) + return rc; + + rv = bin_api_ip_address_dump(sw_if_index, is_ipv6, &dctx); + if (rv != VAPI_OK) + return -SCVPP_EINVAL; + + strcpy(ip_addr, sc_ntoa(dctx.ip)); //IP string + *prefix_len = dctx.prefix_length; //prefix length + + return SCVPP_OK; +} + +int ipv46_config_add_remove(const char *if_name, const char *addr, + uint8_t prefix, bool is_ipv6, bool add) +{ + vapi_error_e rv; + uint32_t sw_if_index; + int rc; + + ARG_CHECK2(-1, if_name, addr); + + rc = get_interface_id(if_name, &sw_if_index); + if (rc < 0) + return rc; + + /* add del addr */ + rv = bin_api_sw_interface_add_del_address(sw_if_index, add, is_ipv6, 0, + prefix, addr); + if (rv != VAPI_OK) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +int ipv46_config_add_del_route(const char* dst_address, u8 dst_address_length, + const char* next_address, u8 is_add, + u32 table_id, const char *interface) +{ + vapi_payload_ip_add_del_route_reply reply = {0}; + vapi_error_e rv; + + rv = bin_api_ip_add_del_route(&reply, dst_address, dst_address_length, + next_address, is_add, table_id, interface); + if (VAPI_OK != rv || reply.retval > 0) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} diff --git a/src/scvpp/src/nat.c b/src/scvpp/src/nat.c new file mode 100644 index 0000000..17ace64 --- /dev/null +++ b/src/scvpp/src/nat.c @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + + +DEFINE_VAPI_MSG_IDS_NAT_API_JSON + +static vapi_error_e +nat44_interface_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx, + vapi_error_e rv, bool is_last, + vapi_payload_nat44_interface_details *reply) +{ + UNUSED(ctx); UNUSED(rv); + vapi_payload_nat44_interface_details *dctx = callback_ctx; + assert(dctx); + + if (is_last) + { + assert(NULL == reply); + } + else + { + //TODO: Use LOG message for scvpp +// SC_LOG_DBG("NAT Interface dump entry: [%u]: %u\n", reply->sw_if_index, +// reply->is_inside); + *dctx = *reply; + } + + return VAPI_OK; +} + +static vapi_error_e +bin_api_nat44_interface_dump(vapi_payload_nat44_interface_details *reply) +{ + vapi_error_e rv; + vapi_msg_nat44_interface_dump *mp; + + ARG_CHECK(VAPI_EINVAL, reply); + + mp = vapi_alloc_nat44_interface_dump(g_vapi_ctx); + assert(NULL != mp); + + VAPI_CALL(vapi_nat44_interface_dump(g_vapi_ctx, mp, + nat44_interface_dump_cb, reply)); + + return rv; +} + +VAPI_RETVAL_CB(nat44_add_del_interface_addr); + +static vapi_error_e +bin_api_nat44_add_del_interface_addr( + const vapi_payload_nat44_add_del_interface_addr *msg) +{ + vapi_error_e rv; + vapi_msg_nat44_add_del_interface_addr *mp; + + ARG_CHECK(VAPI_EINVAL, msg); + + mp = vapi_alloc_nat44_add_del_interface_addr(g_vapi_ctx); + assert(NULL != mp); + + mp->payload = *msg; + + VAPI_CALL(vapi_nat44_add_del_interface_addr(g_vapi_ctx, mp, + nat44_add_del_interface_addr_cb, + NULL)); + + return rv; +} + +VAPI_RETVAL_CB(nat44_add_del_address_range); + +static vapi_error_e +bin_api_nat44_add_del_addr_range( + const vapi_payload_nat44_add_del_address_range *range) +{ + vapi_error_e rv; + vapi_msg_nat44_add_del_address_range *mp; + + ARG_CHECK(VAPI_EINVAL, range); + + mp = vapi_alloc_nat44_add_del_address_range(g_vapi_ctx); + + assert(NULL != mp); + + mp->payload = *range; + + VAPI_CALL(vapi_nat44_add_del_address_range(g_vapi_ctx, mp, + nat44_add_del_address_range_cb, + NULL)); + + return rv; +} + +VAPI_RETVAL_CB(nat44_add_del_static_mapping); + +static vapi_error_e +bin_api_nat44_add_del_static_mapping( + const vapi_payload_nat44_add_del_static_mapping *msg) +{ + vapi_error_e rv; + vapi_msg_nat44_add_del_static_mapping *mp; + + ARG_CHECK(VAPI_EINVAL, msg); + + mp = vapi_alloc_nat44_add_del_static_mapping(g_vapi_ctx); + assert(NULL != mp); + + mp->payload = *msg; + + VAPI_CALL(vapi_nat44_add_del_static_mapping(g_vapi_ctx, mp, + nat44_add_del_static_mapping_cb, + NULL)); + + return rv; +} + +static vapi_error_e nat44_static_mapping_dump_cb( + struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, + bool is_last,vapi_payload_nat44_static_mapping_details *reply) +{ + UNUSED(rv); UNUSED(ctx); + vapi_payload_nat44_static_mapping_details *dctx = callback_ctx; + assert(dctx); + + if (is_last) + { + assert(NULL == reply); + } + else + { + *dctx = *reply; + } + + return VAPI_OK; +} + +static vapi_error_e +bin_api_nat44_static_mapping_dump( + vapi_payload_nat44_static_mapping_details *reply) +{ + vapi_error_e rv; + vapi_msg_nat44_static_mapping_dump *msg; + + ARG_CHECK(VAPI_EINVAL, reply); + + msg = vapi_alloc_nat44_static_mapping_dump(g_vapi_ctx); + assert(NULL != msg); + + VAPI_CALL(vapi_nat44_static_mapping_dump(g_vapi_ctx, msg, + nat44_static_mapping_dump_cb, + reply)); + + return rv; +} + +VAPI_RETVAL_CB(nat44_forwarding_enable_disable); + +static vapi_error_e bin_api_nat44_forwarding_enable_disable( + const vapi_payload_nat44_forwarding_enable_disable *msg) +{ + vapi_error_e rv; + vapi_msg_nat44_forwarding_enable_disable *mp; + + ARG_CHECK(VAPI_EINVAL, msg); + + mp = vapi_alloc_nat44_forwarding_enable_disable(g_vapi_ctx); + assert(NULL != mp); + + mp->payload = *msg; + + VAPI_CALL(vapi_nat44_forwarding_enable_disable( + g_vapi_ctx, mp, nat44_forwarding_enable_disable_cb, NULL)); + + return rv; +} + +VAPI_RETVAL_CB(nat_set_workers); + +static vapi_error_e +bin_api_nat_set_workers(const vapi_payload_nat_set_workers *msg) +{ + vapi_error_e rv; + vapi_msg_nat_set_workers *mp; + + ARG_CHECK(VAPI_EINVAL, msg); + + mp = vapi_alloc_nat_set_workers(g_vapi_ctx); + assert(NULL != mp); + + mp->payload = *msg; + + VAPI_CALL(vapi_nat_set_workers(g_vapi_ctx, mp, nat_set_workers_cb, NULL)); + + return rv; +} + +int nat44_interface_dump(nat44_interface_details_t *reply) +{ + vapi_error_e rv; + + rv = bin_api_nat44_interface_dump(reply); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +int nat44_add_del_interface_addr(const nat44_add_del_interface_addr_t *msg) +{ + vapi_error_e rv; + + rv = bin_api_nat44_add_del_interface_addr(msg); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +int nat44_add_del_addr_range(const nat44_add_del_address_range_t *range) +{ + vapi_error_e rv; + + rv = bin_api_nat44_add_del_addr_range(range); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +int nat44_add_del_static_mapping(const nat44_add_del_static_mapping_t *msg) +{ + vapi_error_e rv; + + rv = bin_api_nat44_add_del_static_mapping(msg); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +int nat44_static_mapping_dump(nat44_static_mapping_details_t *reply) +{ + vapi_error_e rv; + + rv = bin_api_nat44_static_mapping_dump(reply); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +int +nat44_forwarding_enable_disable(const nat44_forwarding_enable_disable_t *msg) +{ + vapi_error_e rv; + + rv = bin_api_nat44_forwarding_enable_disable(msg); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return 0; +} + +int nat_set_workers(const nat_set_workers_t *msg) +{ + vapi_error_e rv; + + rv = bin_api_nat_set_workers(msg); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + diff --git a/src/scvpp/src/sc_vpp_comm.c b/src/scvpp/src/sc_vpp_comm.c deleted file mode 100644 index cd0b035..0000000 --- a/src/scvpp/src/sc_vpp_comm.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2018 HUACHENTEL and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "sc_vpp_comm.h" - -#include -#include -#include -#include -#include - -#define APP_NAME "sweetcomb_vpp" -#define MAX_OUTSTANDING_REQUESTS 4 -#define RESPONSE_QUEUE_SIZE 2 - -vapi_ctx_t g_vapi_ctx_instance = NULL; -vapi_mode_e g_vapi_mode = VAPI_MODE_NONBLOCKING; - -int sc_connect_vpp() -{ - if (g_vapi_ctx_instance == NULL) - { - vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx_instance); - rv = vapi_connect(g_vapi_ctx_instance, APP_NAME, NULL, - MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE, - VAPI_MODE_BLOCKING, true); - if (rv != VAPI_OK) - { - vapi_ctx_free(g_vapi_ctx_instance); - g_vapi_ctx_instance = NULL; - return -1; - } - } - - return 0; -} - -int sc_disconnect_vpp() -{ - if (NULL != g_vapi_ctx_instance) - { - vapi_disconnect(g_vapi_ctx_instance); - vapi_ctx_free(g_vapi_ctx_instance); - g_vapi_ctx_instance = NULL; - } - return 0; -} - -int sc_end_with(const char* str, const char* end) -{ - if (str != NULL && end != NULL) - { - int l1 = strlen(str); - int l2 = strlen(end); - if (l1 >= l2) - { - if (strcmp(str + l1 - l2, end) == 0) - return 1; - } - } - return 0; -} - -int sc_aton(const char *cp, u8 * buf, size_t length) -{ - ARG_CHECK2(false, cp, buf); - - struct in_addr addr; - int ret = inet_aton(cp, &addr); - - if (0 == ret) - return -EINVAL; - - if (sizeof(addr) > length) - return -EINVAL; - - memcpy(buf, &addr, sizeof (addr)); - - return 0; -} - -char* sc_ntoa(const u8 * buf) -{ - ARG_CHECK(NULL, buf); - - struct in_addr addr; - memcpy(&addr, buf, sizeof(addr)); - return inet_ntoa(addr); -} - -/** - * @brief Function converts the u8 array from network byte order to host byte order. - * - * @param[in] host IPv4 address. - * @return host byte order value. - */ -uint32_t hardntohlu32(uint8_t host[4]) -{ - uint32_t tmp = host[3] | host[2] | host[1] | host[0]; - - return ntohl(tmp); -} diff --git a/src/scvpp/src/sc_vpp_comm.h b/src/scvpp/src/sc_vpp_comm.h deleted file mode 100644 index eeeaaf9..0000000 --- a/src/scvpp/src/sc_vpp_comm.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2018 HUACHENTEL and/or its affiliates. - * Copyright (c) 2018 PANTHEON.tech - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __SC_VPP_COMMM_H__ -#define __SC_VPP_COMMM_H__ - -#include - -#include -#include -#include - -// Use VAPI macros to define symbols -DEFINE_VAPI_MSG_IDS_VPE_API_JSON; - -#define VPP_INTFC_NAME_LEN 64 -#define VPP_TAPV2_NAME_LEN VPP_INTFC_NAME_LEN -#define VPP_IP4_ADDRESS_LEN 4 -#define VPP_IP6_ADDRESS_LEN 16 -#define VPP_IP4_ADDRESS_STRING_LEN 16 -#define VPP_IP4_PREFIX_STRING_LEN 19 -#define VPP_IP4_HOST_PREFIX_LEN 32 -#define VPP_IP6_ADDRESS_STRING_LEN 46 -#define VPP_MAC_ADDRESS_LEN 8 -#define VPP_TAG_LEN VPP_INTFC_NAME_LEN -#define VPP_IKEV2_PROFILE_NAME_LEN VPP_INTFC_NAME_LEN -#define VPP_IKEV2_PSK_LEN VPP_INTFC_NAME_LEN -#define VPP_IKEV2_ID_LEN 32 - -/**********************************MACROS**********************************/ -#define ARG_CHECK(retval, arg) \ - do \ - { \ - if (NULL == (arg)) \ - { \ - return (retval); \ - } \ - } \ - while (0) - -#define ARG_CHECK2(retval, arg1, arg2) \ - ARG_CHECK(retval, arg1); \ - ARG_CHECK(retval, arg2) - -#define ARG_CHECK3(retval, arg1, arg2, arg3) \ - ARG_CHECK(retval, arg1); \ - ARG_CHECK(retval, arg2); \ - ARG_CHECK(retval, arg3) - -#define ARG_CHECK4(retval, arg1, arg2, arg3, arg4) \ - ARG_CHECK(retval, arg1); \ - ARG_CHECK(retval, arg2); \ - ARG_CHECK(retval, arg3); \ - ARG_CHECK(retval, arg4) - -/* Suppress compiler warning about unused variable. - * This must be used only for callback function else suppress your unused - * parameter in function prototype. */ -#define UNUSED(x) (void)x - -#define VAPI_RETVAL_CB(api_name) \ -static vapi_error_e \ -api_name##_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, \ - vapi_payload_##api_name##_reply * reply) \ -{ \ - UNUSED(ctx); UNUSED(caller_ctx); UNUSED(rv); UNUSED(is_last); \ - return reply->retval; \ -} - -#define VAPI_COPY_CB(api_name) \ -static vapi_error_e \ -api_name##_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, \ - vapi_payload_##api_name##_reply * reply) \ -{ \ - UNUSED(ctx); UNUSED(rv); UNUSED(is_last); \ - if (caller_ctx) \ - { \ - vapi_payload_##api_name##_reply * passed = (vapi_payload_##api_name##_reply *)caller_ctx; \ - *passed = *reply; \ - } \ - return VAPI_OK; \ -}\ - -#define VAPI_CALL_MODE(call_code, vapi_mode) \ - do \ - { \ - if (VAPI_MODE_BLOCKING == (vapi_mode)) \ - { \ - rv = call_code; \ - } \ - else \ - { \ - while (VAPI_EAGAIN == (rv = call_code)); \ - rv = vapi_dispatch (g_vapi_ctx_instance); \ - } \ - } \ - while (0) - -#define VAPI_CALL(call_code) VAPI_CALL_MODE(call_code, g_vapi_mode) - -int sc_aton(const char *cp, u8 * buf, size_t length); -char * sc_ntoa(const u8 * buf); - -/** - * @brief Function converts the u8 array from network byte order to host byte order. - * - * @param[in] host IPv4 address. - * @return host byte order value. - */ -uint32_t hardntohlu32(uint8_t host[4]); - -/* - * VPP - */ - -extern vapi_ctx_t g_vapi_ctx_instance; -extern vapi_mode_e g_vapi_mode; - -int sc_connect_vpp(); -int sc_disconnect_vpp(); -int sc_end_with(const char* str, const char* end); - -#endif //__SC_VPP_COMMM_H__ diff --git a/src/scvpp/src/sc_vpp_interface.c b/src/scvpp/src/sc_vpp_interface.c deleted file mode 100644 index bc5befc..0000000 --- a/src/scvpp/src/sc_vpp_interface.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include - -#include "sc_vpp_comm.h" -#include "sc_vpp_interface.h" - - -// Use VAPI macros to define symbols -DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON -DEFINE_VAPI_MSG_IDS_L2_API_JSON; - -void sw_interface_details_query_set_name(sw_interface_details_query_t * query, - const char * interface_name) -{ - assert(query && interface_name); - - memset(query, 0, sizeof(*query)); - - strncpy((char*) query->sw_interface_details.interface_name, interface_name, - sizeof(query->sw_interface_details.interface_name)); -} - -static vapi_error_e -sw_interface_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_sw_interface_details *reply) -{ - UNUSED(rv); UNUSED(ctx); UNUSED(is_last); - - vapi_payload_sw_interface_details *passed; - - ARG_CHECK(-EINVAL, callback_ctx); - - passed = (vapi_payload_sw_interface_details *) callback_ctx; - - //Interface is found if index of query equals index of reply - if (passed->sw_if_index != reply->sw_if_index) - return -EINVAL; - - //copy - *passed = *reply; - - return VAPI_OK; -} - -static vapi_error_e -bin_api_sw_interface_dump(vapi_payload_sw_interface_details *details) -{ - vapi_msg_sw_interface_dump *mp; - vapi_error_e rv; - - mp = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance); - - mp->payload.name_filter_valid = 0; - memset(mp->payload.name_filter, 0, sizeof(mp->payload.name_filter)); - assert(NULL != mp); - - VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, sw_interface_dump_cb, details)); - if (!rv) - return -EINVAL; - - return rv; -} - -static vapi_error_e -interface_dump_all_cb(struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_sw_interface_details * reply) -{ - UNUSED(ctx); UNUSED(rv); - dump_all_ctx *dctx = callback_ctx; - - if (is_last) - return VAPI_OK; - - if(dctx->capacity == 0 && dctx->intfcArray == NULL) { - dctx->capacity = 10; - dctx->intfcArray = (vpp_interface_t*)malloc( sizeof(vpp_interface_t)*dctx->capacity ); - } - if(dctx->num_ifs >= dctx->capacity-1) { - dctx->capacity += 10; - dctx->intfcArray = (vpp_interface_t*)realloc(dctx->intfcArray, sizeof(vpp_interface_t)*dctx->capacity ); - } - - vpp_interface_t * iface = &dctx->intfcArray[dctx->num_ifs]; - - iface->sw_if_index = reply->sw_if_index; - strncpy(iface->interface_name, (char*) reply->interface_name, - VPP_INTFC_NAME_LEN); - iface->l2_address_length = reply->l2_address_length; - memcpy(iface->l2_address, reply->l2_address, reply->l2_address_length ); - iface->link_speed = reply->link_speed; - - iface->link_mtu = reply->link_mtu; - iface->admin_up_down = reply->admin_up_down; - iface->link_up_down = reply->link_up_down; - - dctx->num_ifs += 1; - - return VAPI_OK; -} - -int interface_dump_all(dump_all_ctx * dctx) -{ - vapi_msg_sw_interface_dump *dump; - vapi_error_e rv; - - ARG_CHECK(-1, dctx); - - if(dctx == NULL) - return -1; - - dctx->intfcArray = NULL; - dctx->capacity = 0; - dctx->num_ifs = 0; - - dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance); - - dump->payload.name_filter_valid = 0; - memset(dump->payload.name_filter, 0, sizeof(dump->payload.name_filter)); - while (VAPI_EAGAIN == - (rv = - vapi_sw_interface_dump(g_vapi_ctx_instance, dump, interface_dump_all_cb, - dctx))); - - return dctx->num_ifs; -} - -static vapi_error_e -get_interface_id_cb (struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_sw_interface_details * reply) -{ - UNUSED(ctx); UNUSED(rv); - - sw_interface_details_query_t *dctx = callback_ctx; - assert(dctx); - - if (!dctx->interface_found) - { - if (is_last) - { - assert(NULL == reply); - } - else - { - assert(NULL != reply); - - if (0 == strcmp((const char*)dctx->sw_interface_details.interface_name, - (const char*)reply->interface_name)) - { - dctx->interface_found = true; - dctx->sw_interface_details = *reply; - } - } - } - - return VAPI_OK; -} - -// return error code instead of boolean -int get_interface_id(sw_interface_details_query_t * sw_interface_details_query) -{ - vapi_error_e rv; - - ARG_CHECK(false, sw_interface_details_query); - - sw_interface_details_query->interface_found = false; - - vapi_msg_sw_interface_dump *mp = vapi_alloc_sw_interface_dump (g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload.name_filter_valid = true; - memcpy(mp->payload.name_filter, sw_interface_details_query->sw_interface_details.interface_name, - sizeof(mp->payload.name_filter)); - - VAPI_CALL(vapi_sw_interface_dump(g_vapi_ctx_instance, mp, get_interface_id_cb, sw_interface_details_query)); - if (VAPI_OK != rv) - return false; - - return sw_interface_details_query->interface_found; -} - -int get_interface_name(sw_interface_details_query_t *query) -{ - vapi_error_e rv; - - ARG_CHECK(-EINVAL, query); - - query->interface_found = false; - - rv = bin_api_sw_interface_dump(&query->sw_interface_details); - if (rv == VAPI_OK) - query->interface_found = true; - - return query->interface_found; -} - -VAPI_RETVAL_CB(sw_interface_set_flags); - -static vapi_error_e -bin_api_sw_interface_set_flags(uint32_t if_index, uint8_t up) -{ - vapi_msg_sw_interface_set_flags *mp = vapi_alloc_sw_interface_set_flags (g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload.sw_if_index = if_index; - mp->payload.admin_up_down = up; - - vapi_error_e rv; - VAPI_CALL(vapi_sw_interface_set_flags(g_vapi_ctx_instance, mp, sw_interface_set_flags_cb, NULL)); - - return rv; -} - -int interface_enable(const char *interface_name, const bool enable) -{ - ARG_CHECK(-1, interface_name); - - int rc = 0; - sw_interface_details_query_t query = {0}; - sw_interface_details_query_set_name(&query, interface_name); - - rc = get_interface_id(&query); - if (!rc) - return -1; - - rc = bin_api_sw_interface_set_flags(query.sw_interface_details.sw_if_index, - enable); - if (VAPI_OK != rc) - return -1; - - return 0; -} diff --git a/src/scvpp/src/sc_vpp_interface.h b/src/scvpp/src/sc_vpp_interface.h deleted file mode 100644 index 32b61bc..0000000 --- a/src/scvpp/src/sc_vpp_interface.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __BAPI_INTERFACE_H__ -#define __BAPI_INTERFACE_H__ - -#include - -int interface_enable(const char *interface_name, const bool enable); - -//TODO remove the following structures ASAP -typedef struct { - bool interface_found; - vapi_payload_sw_interface_details sw_interface_details; -} sw_interface_details_query_t; - -typedef struct _vpp_interface_t -{ - u32 sw_if_index; - char interface_name[VPP_INTFC_NAME_LEN]; - u8 l2_address[VPP_MAC_ADDRESS_LEN]; - u32 l2_address_length; - u64 link_speed; - u16 link_mtu; - u8 admin_up_down; - u8 link_up_down; -} vpp_interface_t; - -typedef struct _dump_all_ctx -{ - int num_ifs; - int capacity; - vpp_interface_t * intfcArray; -} dump_all_ctx; - -/* return the number of interfaces or a negative error code */ -extern int interface_dump_all(dump_all_ctx * dctx); - -extern void sw_interface_details_query_set_name(sw_interface_details_query_t * query, - const char * interface_name); - -//input - sw_interface_details_query shall contain interface_name -extern int get_interface_id(sw_interface_details_query_t * sw_interface_details_query); - -//input - sw_interface_details_query shall contain sw_if_index -extern int get_interface_name(sw_interface_details_query_t * sw_interface_details_query); - -#endif /* __BAPI_INTERFACE_H__ */ diff --git a/src/scvpp/src/sc_vpp_ip.c b/src/scvpp/src/sc_vpp_ip.c deleted file mode 100644 index 0dfd108..0000000 --- a/src/scvpp/src/sc_vpp_ip.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sc_vpp_comm.h" -#include "sc_vpp_ip.h" - -#include "sc_vpp_interface.h" - -#include - -// Use VAPI macros to define symbols -DEFINE_VAPI_MSG_IDS_IP_API_JSON - -VAPI_RETVAL_CB(sw_interface_add_del_address); - -static vapi_error_e -bin_api_sw_interface_add_del_address(u32 sw_if_index, bool is_add, bool is_ipv6, - bool del_all, u8 address_length, - const char *ip_address) -{ - vapi_msg_sw_interface_add_del_address *mp; - vapi_error_e rv; - - ARG_CHECK(VAPI_EINVAL, ip_address); - - mp = vapi_alloc_sw_interface_add_del_address(g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload.sw_if_index = sw_if_index; - mp->payload.is_add = is_add; - mp->payload.is_ipv6 = is_ipv6; - mp->payload.del_all = del_all; - mp->payload.address_length = address_length; - if (sc_aton(ip_address, mp->payload.address, sizeof(mp->payload.address))) - return VAPI_EINVAL; - - VAPI_CALL(vapi_sw_interface_add_del_address(g_vapi_ctx_instance, mp, - sw_interface_add_del_address_cb, NULL)); - - return rv; -} - -VAPI_COPY_CB(ip_add_del_route) - -static vapi_error_e -bin_api_ip_add_del_route(vapi_payload_ip_add_del_route_reply * reply, - const char* dst_address, uint8_t dst_address_length, - const char* next_hop, uint8_t is_add, - uint32_t table_id, const char *interface_name) -{ - sw_interface_details_query_t query = {0}; - vapi_msg_ip_add_del_route *mp; - - ARG_CHECK4(VAPI_EINVAL, reply, dst_address, next_hop, interface_name); - - sw_interface_details_query_set_name(&query, interface_name); - - if (!get_interface_id(&query)) - return VAPI_EINVAL; - - mp = vapi_alloc_ip_add_del_route (g_vapi_ctx_instance, 1); - assert(NULL != mp); - - //ip route add 2.2.2.2/24 via 5.5.5.5 - //show ip fib table 0 2.2.2.0/24 detail - - mp->payload.is_add = is_add; - mp->payload.dst_address_length = dst_address_length; - mp->payload.table_id = table_id; - mp->payload.next_hop_sw_if_index = query.sw_interface_details.sw_if_index; - - if (sc_aton(dst_address, mp->payload.dst_address, - sizeof(mp->payload.dst_address))) - return VAPI_EINVAL; - if (sc_aton(next_hop, mp->payload.next_hop_address, - sizeof(mp->payload.next_hop_address))) - return VAPI_EINVAL; - - vapi_error_e rv ; - VAPI_CALL(vapi_ip_add_del_route(g_vapi_ctx_instance, mp, ip_add_del_route_cb, reply)); - - return rv; -} - -static vapi_error_e -ip_address_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, - bool is_last, vapi_payload_ip_address_details *reply) -{ - UNUSED(rv); - ARG_CHECK3(VAPI_EINVAL, ctx, callback_ctx, reply); - - //copy dump reply in callback context - if (!is_last && callback_ctx) { - vapi_payload_ip_address_details *passed = - (vapi_payload_ip_address_details *) callback_ctx; - *passed = *reply; - } - - return VAPI_OK; -} - -static vapi_error_e -bin_api_ip_address_dump(u32 sw_if_index, bool is_ipv6, - vapi_payload_ip_address_details *dctx) -{ - vapi_msg_ip_address_dump *mp; - vapi_error_e rv; - - mp = vapi_alloc_ip_address_dump(g_vapi_ctx_instance); - mp->payload.sw_if_index = sw_if_index; - mp->payload.is_ipv6 = is_ipv6; - - VAPI_CALL(vapi_ip_address_dump(g_vapi_ctx_instance, mp, ip_address_dump_cb, - dctx)); - if (rv != VAPI_OK) - return rv; - - return VAPI_OK; -} - -/* - * @brief Dump IPv4/IPv6 address from an interface. - * @param interface_name Name of the interface to dump. - * @param ip_addr pointer where dump will store IP. - * @param prefix_len pointer where dump will store prefix - */ -int ipv46_address_dump(const char *interface_name, char *ip_addr, - u8 *prefix_len, bool is_ipv6) -{ - vapi_payload_ip_address_details dctx = {0}; - sw_interface_details_query_t query = {0}; - vapi_error_e rv; - - sw_interface_details_query_set_name(&query, interface_name); - - if (!get_interface_id(&query)) - return -EINVAL; - - rv = bin_api_ip_address_dump(query.sw_interface_details.sw_if_index, is_ipv6, &dctx); - if (rv != VAPI_OK) - return -EAGAIN; - - strcpy(ip_addr, sc_ntoa(dctx.ip)); //IP string - *prefix_len = dctx.prefix_length; //prefix length - - return 0; -} - -/** - * @brief Add or remove IPv4/IPv6 address to/from an interface. - */ -int ipv46_config_add_remove(const char *if_name, const char *addr, - uint8_t prefix, bool is_ipv6, bool add) -{ - vapi_error_e rv; - int rc; - - ARG_CHECK2(-1, if_name, addr); - - /* get interface index */ - sw_interface_details_query_t query = {0}; - sw_interface_details_query_set_name(&query, if_name); - rc = get_interface_id(&query); - if (!rc) - return -EINVAL; - - /* add del addr */ - rv = bin_api_sw_interface_add_del_address(query.sw_interface_details.sw_if_index, - add, is_ipv6, 0, prefix, addr); - if (rv != VAPI_OK) - return -EINVAL; - - return 0; -} - -/* - * @brief Add or remove an IP route - */ -int ipv46_config_add_del_route(const char* dst_address, u8 dst_address_length, - const char* next_address, u8 is_add, - u32 table_id, const char *interface) -{ - vapi_payload_ip_add_del_route_reply reply = {0}; - vapi_error_e rv; - - rv = bin_api_ip_add_del_route(&reply, dst_address, dst_address_length, - next_address, is_add, table_id, interface); - if (VAPI_OK != rv || reply.retval > 0) { - return -EINVAL; - } - - return 0; -} diff --git a/src/scvpp/src/sc_vpp_ip.h b/src/scvpp/src/sc_vpp_ip.h deleted file mode 100644 index a9f19d4..0000000 --- a/src/scvpp/src/sc_vpp_ip.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __BAPI_IP_H__ -#define __BAPI_IP_H__ - -#include -#include - -/* If no IP has been found ip_addr will be "0.0.0.0" */ -extern int ipv46_address_dump(const char *interface_name, char *ip_addr, - u8 *prefix_len, bool is_ipv6); - -extern int ipv46_config_add_remove(const char *if_name, const char *addr, - uint8_t prefix, bool is_ipv6, bool add); - -extern int -ipv46_config_add_del_route(const char* dst_address, u8 dst_address_length, - const char* next_address, u8 is_add, u32 table_id, - const char *interface); - -#endif /* __BAPI_IP_H__ */ diff --git a/src/scvpp/src/sc_vpp_nat.c b/src/scvpp/src/sc_vpp_nat.c deleted file mode 100644 index e4bf2b7..0000000 --- a/src/scvpp/src/sc_vpp_nat.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sc_vpp_comm.h" -#include "sc_vpp_nat.h" - -#include -#include - - -DEFINE_VAPI_MSG_IDS_NAT_API_JSON - -static vapi_error_e -nat44_interface_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx, - vapi_error_e rv, bool is_last, - vapi_payload_nat44_interface_details *reply) -{ - UNUSED(ctx); - UNUSED(rv); - vapi_payload_nat44_interface_details *dctx = callback_ctx; - assert(dctx); - - if (is_last) - { - assert(NULL == reply); - } - else - { - //TODO: Use LOG message for scvpp -// SC_LOG_DBG("NAT Interface dump entry: [%u]: %u\n", reply->sw_if_index, -// reply->is_inside); - *dctx = *reply; - } - - return VAPI_OK; -} - -static vapi_error_e -bin_api_nat44_interface_dump(vapi_payload_nat44_interface_details *reply) -{ - vapi_error_e rv; - vapi_msg_nat44_interface_dump *mp; - - ARG_CHECK(VAPI_EINVAL, reply); - - mp = vapi_alloc_nat44_interface_dump(g_vapi_ctx_instance); - assert(NULL != mp); - - VAPI_CALL(vapi_nat44_interface_dump(g_vapi_ctx_instance, mp, - nat44_interface_dump_cb, reply)); - - return rv; -} - -VAPI_RETVAL_CB(nat44_add_del_interface_addr); - -static vapi_error_e -bin_api_nat44_add_del_interface_addr( - const vapi_payload_nat44_add_del_interface_addr *msg) -{ - vapi_error_e rv; - vapi_msg_nat44_add_del_interface_addr *mp; - - ARG_CHECK(VAPI_EINVAL, msg); - - mp = vapi_alloc_nat44_add_del_interface_addr(g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload = *msg; - - VAPI_CALL(vapi_nat44_add_del_interface_addr(g_vapi_ctx_instance, mp, - nat44_add_del_interface_addr_cb, - NULL)); - - return rv; -} - -VAPI_RETVAL_CB(nat44_add_del_address_range); - -static vapi_error_e -bin_api_nat44_add_del_addr_range( - const vapi_payload_nat44_add_del_address_range *range) -{ - vapi_error_e rv; - vapi_msg_nat44_add_del_address_range *mp; - - ARG_CHECK(VAPI_EINVAL, range); - - mp = vapi_alloc_nat44_add_del_address_range(g_vapi_ctx_instance); - - assert(NULL != mp); - - mp->payload = *range; - - VAPI_CALL(vapi_nat44_add_del_address_range(g_vapi_ctx_instance, mp, - nat44_add_del_address_range_cb, - NULL)); - - return rv; -} - -VAPI_RETVAL_CB(nat44_add_del_static_mapping); - -static vapi_error_e -bin_api_nat44_add_del_static_mapping( - const vapi_payload_nat44_add_del_static_mapping *msg) -{ - vapi_error_e rv; - vapi_msg_nat44_add_del_static_mapping *mp; - - ARG_CHECK(VAPI_EINVAL, msg); - - mp = vapi_alloc_nat44_add_del_static_mapping(g_vapi_ctx_instance); - - assert(NULL != mp); - - mp->payload = *msg; - - VAPI_CALL(vapi_nat44_add_del_static_mapping(g_vapi_ctx_instance, mp, - nat44_add_del_static_mapping_cb, - NULL)); - - return rv; -} - -static vapi_error_e nat44_static_mapping_dump_cb( - struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, - bool is_last,vapi_payload_nat44_static_mapping_details *reply) -{ - UNUSED(rv); - UNUSED(ctx); - vapi_payload_nat44_static_mapping_details *dctx = callback_ctx; - assert(dctx); - - if (is_last) - { - assert(NULL == reply); - } - else - { - *dctx = *reply; - } - - return VAPI_OK; -} - -static vapi_error_e -bin_api_nat44_static_mapping_dump( - vapi_payload_nat44_static_mapping_details *reply) -{ - vapi_error_e rv; - vapi_msg_nat44_static_mapping_dump *msg; - - ARG_CHECK(VAPI_EINVAL, reply); - - msg = vapi_alloc_nat44_static_mapping_dump(g_vapi_ctx_instance); - assert(NULL != msg); - - VAPI_CALL(vapi_nat44_static_mapping_dump(g_vapi_ctx_instance, msg, - nat44_static_mapping_dump_cb, - reply)); - - return rv; -} - -VAPI_RETVAL_CB(nat44_forwarding_enable_disable); - -static vapi_error_e bin_api_nat44_forwarding_enable_disable( - const vapi_payload_nat44_forwarding_enable_disable *msg) -{ - vapi_error_e rv; - vapi_msg_nat44_forwarding_enable_disable *mp; - - ARG_CHECK(VAPI_EINVAL, msg); - - mp = vapi_alloc_nat44_forwarding_enable_disable(g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload = *msg; - - VAPI_CALL(vapi_nat44_forwarding_enable_disable( - g_vapi_ctx_instance, mp, nat44_forwarding_enable_disable_cb, NULL)); - - return rv; -} - -VAPI_RETVAL_CB(nat_set_workers); - -static vapi_error_e -bin_api_nat_set_workers(const vapi_payload_nat_set_workers *msg) -{ - vapi_error_e rv; - vapi_msg_nat_set_workers *mp; - - ARG_CHECK(VAPI_EINVAL, msg); - - mp = vapi_alloc_nat_set_workers(g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload = *msg; - - VAPI_CALL(vapi_nat_set_workers(g_vapi_ctx_instance, mp, nat_set_workers_cb, - NULL)); - - return rv; -} - -int nat44_interface_dump(nat44_interface_details_t *reply) -{ - vapi_error_e rc; - - rc = bin_api_nat44_interface_dump(reply); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - -int nat44_add_del_interface_addr(const nat44_add_del_interface_addr_t *msg) -{ - vapi_error_e rc; - - rc = bin_api_nat44_add_del_interface_addr(msg); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - -int nat44_add_del_addr_range(const nat44_add_del_address_range_t *range) -{ - vapi_error_e rc; - - rc = bin_api_nat44_add_del_addr_range(range); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - -int nat44_add_del_static_mapping(const nat44_add_del_static_mapping_t *msg) -{ - vapi_error_e rc; - - rc = bin_api_nat44_add_del_static_mapping(msg); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - -int nat44_static_mapping_dump(nat44_static_mapping_details_t *reply) -{ - vapi_error_e rc; - - rc = bin_api_nat44_static_mapping_dump(reply); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - -int nat44_forwarding_enable_disable( - const nat44_forwarding_enable_disable_t *msg) -{ - vapi_error_e rc; - - rc = bin_api_nat44_forwarding_enable_disable(msg); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - -int nat_set_workers(const nat_set_workers_t *msg) -{ - vapi_error_e rc; - - rc = bin_api_nat_set_workers(msg); - if (VAPI_OK != rc) { - //TODO: Need implement log function -// ERROR("Error in nat44_interface_dump, error: %u", rc); - return -1; - } - - return 0; -} - diff --git a/src/scvpp/src/sc_vpp_nat.h b/src/scvpp/src/sc_vpp_nat.h deleted file mode 100644 index 40e727e..0000000 --- a/src/scvpp/src/sc_vpp_nat.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __BAPI_NAT_H__ -#define __BAPI_NAT_H__ - -#include - -typedef vapi_payload_nat44_interface_details nat44_interface_details_t; -typedef vapi_payload_nat44_add_del_interface_addr nat44_add_del_interface_addr_t; -typedef vapi_payload_nat44_add_del_address_range nat44_add_del_address_range_t; -typedef vapi_payload_nat44_add_del_static_mapping nat44_add_del_static_mapping_t; -typedef vapi_payload_nat44_static_mapping_details nat44_static_mapping_details_t; -typedef vapi_payload_nat44_forwarding_enable_disable nat44_forwarding_enable_disable_t; -typedef vapi_payload_nat_set_workers nat_set_workers_t; - - -//Wrapper function, if we want hide the VAPI return value -extern int nat44_interface_dump(nat44_interface_details_t *reply); -extern int nat44_add_del_interface_addr( - const nat44_add_del_interface_addr_t *msg); -extern int nat44_add_del_addr_range(const nat44_add_del_address_range_t *range); -extern int nat44_add_del_static_mapping( - const nat44_add_del_static_mapping_t *msg); -extern int nat44_static_mapping_dump(nat44_static_mapping_details_t *reply); -extern int nat44_forwarding_enable_disable( - const nat44_forwarding_enable_disable_t *msg); -extern int nat_set_workers(const nat_set_workers_t *msg); - - -// Alternative, if we don't want hide VAPI return value - -// extern vapi_error_e bin_api_nat44_interface_dump(nat44_interface_details_t *reply); -// extern vapi_error_e bin_api_nat44_add_del_interface_addr( -// const nat44_add_del_interface_addr_t *msg); -// extern vapi_error_e bin_api_nat44_add_del_addr_range( -// const nat44_add_del_address_range_t *range); -// extern vapi_error_e bin_api_nat44_add_del_static_mapping( -// const nat44_add_del_static_mapping_t *msg); -// extern vapi_error_e bin_api_nat44_static_mapping_dump( -// nat44_static_mapping_details_t *reply); -// extern vapi_error_e bin_api_nat44_forwarding_enable_disable( -// const nat44_forwarding_enable_disable_t *msg); -// extern vapi_error_e bin_api_nat_set_workers(const nat_set_workers_t *msg); - - -#endif /* __BAPI_NAT_H__ */ - diff --git a/src/scvpp/src/sc_vpp_v3po.c b/src/scvpp/src/sc_vpp_v3po.c deleted file mode 100644 index d312331..0000000 --- a/src/scvpp/src/sc_vpp_v3po.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "sc_vpp_comm.h" -#include "sc_vpp_v3po.h" -#include "sc_vpp_interface.h" - -/* - * tap-v2 interfaces - */ - -DEFINE_VAPI_MSG_IDS_TAPV2_API_JSON - -// Dump tapv2 - -//typedef struct __attribute__ ((__packed__)) { -// u32 sw_if_index; -// u32 id; -// u8 dev_name[64]; -// u16 tx_ring_sz; -// u16 rx_ring_sz; -// u8 host_mac_addr[6]; -// u8 host_if_name[64]; -// u8 host_namespace[64]; -// u8 host_bridge[64]; -// u8 host_ip4_addr[4]; -// u8 host_ip4_prefix_len; -// u8 host_ip6_addr[16]; -// u8 host_ip6_prefix_len; -// u32 tap_flags; -//} vapi_payload_sw_interface_tap_v2_details; - -// Delete tapv2 - -VAPI_RETVAL_CB(tap_delete_v2); - -static vapi_error_e bin_api_delete_tapv2(u32 sw_if_index) -{ - vapi_msg_tap_delete_v2 *mp; - vapi_error_e rv; - - mp = vapi_alloc_tap_delete_v2(g_vapi_ctx_instance); - assert(NULL != mp); - - mp->payload.sw_if_index = sw_if_index; - - VAPI_CALL(vapi_tap_delete_v2(g_vapi_ctx_instance, mp, tap_delete_v2_cb, - NULL)); - if (rv != VAPI_OK) - return -EAGAIN; - - return rv; -} - -int delete_tapv2(char *iface_name) -{ - int rc; - sw_interface_details_query_t query = {0}; - - sw_interface_details_query_set_name(&query, iface_name); - - rc = get_interface_id(&query); - if (!rc) - return -1; - - rc = bin_api_delete_tapv2(query.sw_interface_details.sw_if_index); - if (VAPI_OK != rc) - return -1; - - return 0; -} - -// Create tapv2 - -VAPI_RETVAL_CB(tap_create_v2); - -int create_tapv2(tapv2_create_t *query) -{ - vapi_msg_tap_create_v2 *mp; - vapi_error_e rv; - - mp = vapi_alloc_tap_create_v2(g_vapi_ctx_instance); - assert(NULL != mp); - - memcpy(&mp->payload, query, sizeof(tapv2_create_t)); - - VAPI_CALL(vapi_tap_create_v2(g_vapi_ctx_instance, mp, tap_create_v2_cb, - NULL)); - if (rv != VAPI_OK) - return -EAGAIN; - - return 0; -} diff --git a/src/scvpp/src/sc_vpp_v3po.h b/src/scvpp/src/sc_vpp_v3po.h deleted file mode 100644 index 9c13569..0000000 --- a/src/scvpp/src/sc_vpp_v3po.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _V3PO__INTERFACE_H__ -#define _V3PO__INTERFACE_H__ - -#include - -typedef vapi_payload_tap_create_v2 tapv2_create_t; - -int create_tapv2(tapv2_create_t *query); -int delete_tapv2(char *iface_name); - -#endif /* __V3PO_INTERFACE_H__ */ diff --git a/src/scvpp/src/v3po.c b/src/scvpp/src/v3po.c new file mode 100644 index 0000000..f0a41c5 --- /dev/null +++ b/src/scvpp/src/v3po.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (c) 2018 PANTHEON.tech. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include + +// Use VAPI macros to define symbols +DEFINE_VAPI_MSG_IDS_L2_API_JSON; +DEFINE_VAPI_MSG_IDS_TAPV2_API_JSON + +/* + * tap-v2 interfaces + */ + +// Delete tapv2 + +VAPI_RETVAL_CB(tap_delete_v2); + +static vapi_error_e bin_api_delete_tapv2(u32 sw_if_index) +{ + vapi_msg_tap_delete_v2 *mp; + vapi_error_e rv; + + mp = vapi_alloc_tap_delete_v2(g_vapi_ctx); + assert(NULL != mp); + + mp->payload.sw_if_index = sw_if_index; + + VAPI_CALL(vapi_tap_delete_v2(g_vapi_ctx, mp, tap_delete_v2_cb, NULL)); + if (rv != VAPI_OK) + return -rv; + + return VAPI_OK; +} + +int delete_tapv2(char *iface_name) +{ + uint32_t sw_if_index; + vapi_error_e rv; + int rc; + + rc = get_interface_id(iface_name, &sw_if_index); + if (rc < 0) + return rc; + + rv = bin_api_delete_tapv2(sw_if_index); + if (VAPI_OK != rv) + return -SCVPP_EINVAL; + + return SCVPP_OK; +} + +// Create tapv2 + +VAPI_RETVAL_CB(tap_create_v2); + +int create_tapv2(tapv2_create_t *query) +{ + vapi_msg_tap_create_v2 *mp; + vapi_error_e rv; + + mp = vapi_alloc_tap_create_v2(g_vapi_ctx); + assert(NULL != mp); + + memcpy(&mp->payload, query, sizeof(tapv2_create_t)); + + VAPI_CALL(vapi_tap_create_v2(g_vapi_ctx, mp, tap_create_v2_cb, NULL)); + if (rv != VAPI_OK) + return -EAGAIN; + + return 0; +} diff --git a/src/scvpp/tests/CMakeLists.txt b/src/scvpp/tests/CMakeLists.txt index 3153fe0..2b6de4a 100644 --- a/src/scvpp/tests/CMakeLists.txt +++ b/src/scvpp/tests/CMakeLists.txt @@ -18,24 +18,23 @@ include_directories ("${PROJECT_SOURCE_DIR}/src") # check whether valgrind is installed find_program(valgrind_FOUND valgrind) -# macro for adding of an unit test -macro(ADD_UNIT_TEST TEST_NAME) - set(TEST_SRC - ${TEST_NAME}.c - scvpp_nat_test.c - ) - add_executable(${TEST_NAME} ${TEST_SRC}) - target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} scvpp_a) - add_test(${TEST_NAME} ${TEST_NAME}) +set(TEST_SRC + scvpp_test.h + scvpp_test.c + scvpp_iface_test.c + scvpp_ip_test.c + scvpp_nat_test.c +) - if(valgrind_FOUND) - add_test(${TEST_NAME}_valgrind valgrind - --error-exitcode=1 --read-var-info=yes - --leak-check=full --show-leak-kinds=all - ./${TEST_NAME} - ) - endif(valgrind_FOUND) -endmacro(ADD_UNIT_TEST) +add_executable(scvpp_test ${TEST_SRC}) +target_link_libraries(scvpp_test ${CMOCKA_LIBRARIES} scvpp_a) +target_include_directories(scvpp_test PRIVATE ../inc) +add_test(scvpp_test scvpp_test) -# add individual unit-tests -ADD_UNIT_TEST(scvpp_test) +if(valgrind_FOUND) + add_test(${TEST_NAME}_valgrind valgrind + --error-exitcode=1 --read-var-info=yes + --leak-check=full --show-leak-kinds=all + ./${TEST_NAME} + ) +endif(valgrind_FOUND) diff --git a/src/scvpp/tests/scvpp_iface_test.c b/src/scvpp/tests/scvpp_iface_test.c new file mode 100644 index 0000000..6a96694 --- /dev/null +++ b/src/scvpp/tests/scvpp_iface_test.c @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "scvpp_test.h" + +#include +#include + +static void test_enable_disable(void **state) +{ + UNUSED(state); + sw_interface_dump_t dump = {0}; + int rc; + + rc = interface_enable("tap0", 1); + assert_int_equal(rc, SCVPP_OK); + + rc = interface_dump_iface(&dump, "tap0"); + assert_int_equal(rc, SCVPP_OK); + + assert_int_equal(dump.admin_up_down, true); + + rc = interface_enable("tap0", 0); + assert_int_equal(rc, SCVPP_OK); +} + +static void test_create_tapv2(void **state) +{ + UNUSED(state); + tapv2_create_t query = {0}; + sw_interface_dump_t dump = {0}; + int rc; + + query.id = 1; + query.use_random_mac = 1; + + rc = create_tapv2(&query); + assert_int_equal(rc, SCVPP_OK); + + rc = interface_dump_iface(&dump, "tap1"); + assert_int_equal(rc, SCVPP_OK); +} + +static int teardown_tapv2(void **state) +{ + UNUSED(state); + return delete_tapv2("tap1"); +} + +static void test_dump_iface_all(void **state) +{ + UNUSED(state); + struct elt *stack = NULL; + sw_interface_dump_t *dump; + bool exist = false; + + stack = interface_dump_all(); + assert_non_null(stack); + foreach_stack_elt(stack) { + dump = (sw_interface_dump_t *) data; + if (!strncmp((char*) dump->interface_name, "tap0", VPP_INTFC_NAME_LEN)) + exist = true; + free(dump); + } + assert_true(exist); +} + +static void test_dump_iface_exist(void **state) +{ + UNUSED(state); + vapi_payload_sw_interface_details details = {0}; + int rc; + + rc = interface_dump_iface(&details, "local0"); + assert_int_equal(rc, SCVPP_OK); + + assert_string_equal(details.interface_name, "local0"); +} + +static void test_dump_iface_unexist(void **state) +{ + UNUSED(state); + vapi_payload_sw_interface_details details = {0}; + int rc; + + rc = interface_dump_iface(&details, "unexisting"); + assert_int_equal(rc, -SCVPP_NOT_FOUND); +} + +static void test_get_interface_name(void **state) +{ + UNUSED(state); + char interface_name[VPP_INTFC_NAME_LEN]; + uint32_t tap0_if_index; + int rc; + + rc = get_interface_id("tap0", &tap0_if_index); + assert_int_equal(rc, SCVPP_OK); + + rc = get_interface_name(interface_name, tap0_if_index); + assert_int_equal(rc, SCVPP_OK); + + assert_string_equal(interface_name, "tap0"); +} + +const struct CMUnitTest iface_tests[IFACE_TEST_SIZE] = { + cmocka_unit_test_teardown(test_create_tapv2, teardown_tapv2), + cmocka_unit_test(test_enable_disable), + cmocka_unit_test(test_dump_iface_all), + cmocka_unit_test(test_dump_iface_exist), + cmocka_unit_test(test_dump_iface_unexist), + cmocka_unit_test(test_get_interface_name), +}; diff --git a/src/scvpp/tests/scvpp_ip_test.c b/src/scvpp/tests/scvpp_ip_test.c new file mode 100644 index 0000000..5e28123 --- /dev/null +++ b/src/scvpp/tests/scvpp_ip_test.c @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2019 Cisco + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "scvpp_test.h" + +#include +#include +#include + +static void test_add_remove_ipv4(void **state) +{ + UNUSED(state); + const char ip_q[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.144"; + char ip_r[VPP_IP4_ADDRESS_STRING_LEN]; + u8 prefix_q = 24; + u8 prefix_r; + int rc; + + //add ipv4 on tap0 + rc = ipv46_config_add_remove("tap0", ip_q, prefix_q, false, true); + assert_int_equal(rc, SCVPP_OK); + + //dump ipv4 on tap0 and check if it mach + rc = ipv46_address_dump("tap0", ip_r, &prefix_r, false); + assert_int_equal(rc, SCVPP_OK); + assert_string_equal(ip_q, ip_r); + assert_int_equal(prefix_q, prefix_r); + + //remove ipv4 on tap0 + rc = ipv46_config_add_remove("tap0", ip_q, prefix_q, false, false); + assert_int_equal(rc, SCVPP_OK); + + //dump ipv4 after removal and check if equals 0.0.0.0 + rc = ipv46_address_dump("tap0", ip_r, &prefix_r, false); + assert_int_equal(rc, SCVPP_OK); + assert_string_equal(ip_r, "0.0.0.0"); +} + +static void test_ipv4_add_del_route_no_iface(void **state) +{ + UNUSED(state); + int rc; + char dst_address[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.0"; + uint8_t prefix_len = 24; + char next_hop[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.100"; + uint32_t table_id = 0; + fib_dump_t *dump; + struct elt *stack; + bool route_found = false; + + /* Must fail, can not have both interface and next hop IP null */ + rc = ipv46_config_add_del_route(dst_address, prefix_len, NULL, true, + table_id, NULL); + assert_int_equal(rc, -SCVPP_EINVAL); + + rc = ipv46_config_add_del_route(dst_address, prefix_len, next_hop, true, + table_id, NULL); + assert_int_equal(rc, SCVPP_OK); + + /* Dump all FIB routes and check if we find ours */ + stack = ipv4_fib_dump_all(); + assert_non_null(stack); + foreach_stack_elt(stack) { + dump = (fib_dump_t *) data; + + if (strncmp(sc_ntoa(dump->address), dst_address, + VPP_IP4_ADDRESS_STRING_LEN) == 0 && + dump->address_length == prefix_len) { + route_found = true; + assert_int_equal(dump->table_id, table_id); + assert_int_equal(dump->count, 1); + assert_string_equal(sc_ntoa(dump->path[0].next_hop), next_hop); + } + free(dump); + } + assert_true(route_found); + + /* Delete previously set route */ + rc = ipv46_config_add_del_route(dst_address, prefix_len, next_hop, false, + table_id, NULL); + assert_int_equal(rc, SCVPP_OK); + + /* Check our route has been deleted */ + route_found = false; + stack = ipv4_fib_dump_all(); + assert_non_null(stack); + foreach_stack_elt(stack) { + dump = (fib_dump_t *) data; + if (strncmp(sc_ntoa(dump->address), dst_address, + VPP_IP4_ADDRESS_STRING_LEN) == 0 && + dump->address_length == prefix_len) { + route_found = true; + } + free(dump); + } + assert_false(route_found); +} + +static void test_ipv4_add_del_route_no_next_hop_ip(void **state) +{ + UNUSED(state); + int rc; + char dst_address[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.0"; + uint8_t prefix_len = 24; + char interface[VPP_IP4_ADDRESS_STRING_LEN] = "tap0"; + uint32_t table_id = 0; + uint32_t sw_if_index; + fib_dump_t *dump; + struct elt *stack; + bool route_found = false; + + //Add a new route + rc = ipv46_config_add_del_route(dst_address, prefix_len, NULL, true, + table_id, interface); + assert_int_equal(rc, SCVPP_OK); + + //Dump all FIB routes and check we find ours + stack = ipv4_fib_dump_all(); + assert_non_null(stack); + + rc = get_interface_id(interface, &sw_if_index); + assert_int_equal(rc, SCVPP_OK); + + foreach_stack_elt(stack) { + dump = (fib_dump_t *) data; + + if (strncmp(sc_ntoa(dump->address), dst_address, + VPP_IP4_ADDRESS_STRING_LEN) == 0 && + dump->address_length == prefix_len) { + route_found = true; + assert_int_equal(dump->table_id, table_id); + assert_int_equal(dump->count, 1); + assert_int_equal(dump->path[0].sw_if_index, sw_if_index); + } + free(dump); + } + assert_true(route_found); + + //Delete route + rc = ipv46_config_add_del_route(dst_address, prefix_len, NULL, false, + table_id, interface); + assert_int_equal(rc, SCVPP_OK); + + //Check our route has been deleted + route_found = false; + stack = ipv4_fib_dump_all(); + assert_non_null(stack); + + foreach_stack_elt(stack) { + dump = (fib_dump_t *) data; + if (strncmp(sc_ntoa(dump->address), dst_address, + VPP_IP4_ADDRESS_STRING_LEN) == 0 && + dump->address_length == prefix_len) { + route_found = true; + } + free(dump); + } + assert_false(route_found); +} + + +const struct CMUnitTest ip_tests[IP_TEST_SIZE] = { + cmocka_unit_test(test_add_remove_ipv4), + cmocka_unit_test(test_ipv4_add_del_route_no_next_hop_ip), + cmocka_unit_test(test_ipv4_add_del_route_no_iface), +}; diff --git a/src/scvpp/tests/scvpp_nat_test.c b/src/scvpp/tests/scvpp_nat_test.c index fae9615..044102e 100644 --- a/src/scvpp/tests/scvpp_nat_test.c +++ b/src/scvpp/tests/scvpp_nat_test.c @@ -20,36 +20,37 @@ #include #include -#include "scvpp_nat_test.h" -#include "sc_vpp_comm.h" -#include "sc_vpp_nat.h" +#include "scvpp_test.h" -void test_nat44_static_mapping(__attribute__((unused)) void **state) +#include +#include + + +void test_nat44_static_mapping(void **state) { + UNUSED(state); nat44_add_del_static_mapping_t map = {0}; nat44_static_mapping_details_t dump = {0}; u8 empty_ip[4] = {0}; + int rc; /*Configure the static mapping Alternative to this CLI command: nat44 add static mapping local 172.168.0.1 external 172.168.8.5 */ - sc_aton("172.168.0.1", map.local_ip_address, sizeof(map.local_ip_address)); - sc_aton("172.168.8.5", map.external_ip_address, sizeof(map.external_ip_address)); - map.addr_only = 1; - map.external_sw_if_index = ~0; - map.is_add = 1; - nat44_add_del_static_mapping(&map); + rc = nat44_add_del_static_mapping(&map); + assert_int_equal(rc, SCVPP_OK); - nat44_static_mapping_dump(&dump); + rc = nat44_static_mapping_dump(&dump); + assert_int_equal(rc, SCVPP_OK); assert_int_equal(dump.addr_only, map.addr_only); @@ -62,11 +63,13 @@ void test_nat44_static_mapping(__attribute__((unused)) void **state) /* Remove previous config*/ map.is_add = 0; - nat44_add_del_static_mapping(&map); + rc = nat44_add_del_static_mapping(&map); + assert_int_equal(rc, SCVPP_OK); memset(&dump, 0, sizeof(dump)); - nat44_static_mapping_dump(&dump); + rc = nat44_static_mapping_dump(&dump); + assert_int_equal(rc, SCVPP_OK); assert_int_equal(dump.addr_only, 0); @@ -77,14 +80,16 @@ void test_nat44_static_mapping(__attribute__((unused)) void **state) sizeof(dump.external_ip_address)); } -void test_nat44_static_mapping_with_ports(__attribute__((unused)) void **state) +void test_nat44_static_mapping_with_ports(void **state) { + UNUSED(state); nat44_add_del_static_mapping_t map = {0}; nat44_static_mapping_details_t dump = {0}; nat44_add_del_address_range_t range = {0}; u8 empty_ip[4] = {0}; const u16 lport = 77; const u16 eport = 88; + int rc; /*Configure address pool Alternative to this CLI: @@ -98,7 +103,8 @@ void test_nat44_static_mapping_with_ports(__attribute__((unused)) void **state) range.is_add = 1; - nat44_add_del_addr_range(&range); + rc = nat44_add_del_addr_range(&range); + assert_int_equal(rc, SCVPP_OK); /*Configure NAT with ports Alternative to this CLI: @@ -122,9 +128,11 @@ void test_nat44_static_mapping_with_ports(__attribute__((unused)) void **state) map.is_add = 1; - nat44_add_del_static_mapping(&map); + rc = nat44_add_del_static_mapping(&map); + assert_int_equal(rc, SCVPP_OK); - nat44_static_mapping_dump(&dump); + rc = nat44_static_mapping_dump(&dump); + assert_int_equal(rc, SCVPP_OK); assert_int_equal(dump.addr_only, map.addr_only); @@ -142,11 +150,13 @@ void test_nat44_static_mapping_with_ports(__attribute__((unused)) void **state) map.is_add = 0; - nat44_add_del_static_mapping(&map); + rc = nat44_add_del_static_mapping(&map); + assert_int_equal(rc, SCVPP_OK); memset(&dump, 0, sizeof(dump)); - nat44_static_mapping_dump(&dump); + rc = nat44_static_mapping_dump(&dump); + assert_int_equal(rc, SCVPP_OK); assert_int_equal(dump.addr_only, 0); @@ -162,7 +172,8 @@ void test_nat44_static_mapping_with_ports(__attribute__((unused)) void **state) range.is_add = 0; - nat44_add_del_addr_range(&range); + rc = nat44_add_del_addr_range(&range); + assert_int_equal(rc, SCVPP_OK); } const struct CMUnitTest nat_tests[] = { diff --git a/src/scvpp/tests/scvpp_nat_test.h b/src/scvpp/tests/scvpp_nat_test.h deleted file mode 100644 index 8a22f87..0000000 --- a/src/scvpp/tests/scvpp_nat_test.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2019 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* inclusion guard */ -#ifndef __SCVPP_NAT_TEST_H__ -#define __SCVPP_NAT_TEST_H__ - -#define NAT_TEST_SIZE 2 -extern const struct CMUnitTest nat_tests[NAT_TEST_SIZE]; - -#endif /* __SCVPP_NAT_TEST_H__ */ diff --git a/src/scvpp/tests/scvpp_test.c b/src/scvpp/tests/scvpp_test.c index cc23e43..f6e99a0 100644 --- a/src/scvpp/tests/scvpp_test.c +++ b/src/scvpp/tests/scvpp_test.c @@ -14,89 +14,19 @@ */ #include -#include #include +#include #include -#include - -#include "sc_vpp_comm.h" -#include "sc_vpp_interface.h" -#include "sc_vpp_ip.h" -#include "sc_vpp_v3po.h" -#include "scvpp_nat_test.h" - -//TODO Check with future function get_interface_state -static void test_enable_disable(void **state) -{ - int rc; - - rc = interface_enable("tap0", 1); - assert_int_equal(rc, 0); - - rc = interface_enable("tap0", 0); - assert_int_equal(rc, 0); -} - -//TODO would need to make sure tap0 is index 1 -//TODO delete eventually because get_interface_id will not be extern -static void test_name2index(void **state) -{ - int rc; - const char iface_name[] = "tap0"; - sw_interface_details_query_t query = {0}; - sw_interface_details_query_set_name(&query, iface_name); - - rc = get_interface_id(&query); - assert_int_equal(rc, 1); - - assert_string_equal(iface_name, query.sw_interface_details.interface_name); - assert_int_equal(query.sw_interface_details.sw_if_index, 1); -} - -static void test_add_ipv4(void **state) -{ - const char ip_q[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.144"; - char ip_r[VPP_IP4_ADDRESS_STRING_LEN]; - u8 prefix_q = 24; - u8 prefix_r; - int rc; - - //add ipv4 on tap0 - rc = ipv46_config_add_remove("tap0", ip_q, prefix_q, false, true); - assert_int_equal(rc, 0); - - rc = ipv46_address_dump("tap0", ip_r, &prefix_r, false); - assert_int_equal(rc, 0); - - assert_string_equal(ip_q, ip_r); - assert_int_equal(prefix_q, prefix_r); -} - -static void test_remove_ipv4(void **state) -{ - const char ip_q[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.144"; - char ip_r[VPP_IP4_ADDRESS_STRING_LEN]; - u8 prefix_q = 24; - u8 prefix_r; - int rc; - - //add ipv4 on tap0 - rc = ipv46_config_add_remove("tap0", ip_q, prefix_q, false, true); - assert_int_equal(rc, 0); - //remove ipv4 on tap0 - rc = ipv46_config_add_remove("tap0", ip_q, prefix_q, false, false); - assert_int_equal(rc, 0); - - //dump ipv4 - rc = ipv46_address_dump("tap0", ip_r, &prefix_r, false); - assert_int_equal(rc, 0); +#include +#include - assert_string_equal(ip_r, "0.0.0.0"); -} +#include "scvpp_test.h" +/* test "AAA.BBB.CCC.DDD" -> {A, B, C, D} */ static void test_sc_ntoa(void **state) { + UNUSED(state); u8 buf[4] = {192, 168, 100, 44}; char *res; @@ -104,52 +34,76 @@ static void test_sc_ntoa(void **state) assert_string_equal(res, "192.168.100.44"); } -static void test_create_tapv2(void **state) +/* test {A, B, C, D} -> "AAA.BBB.CCC.DDD" */ +static void test_sc_aton(void **state) { - tapv2_create_t query = {0}; + UNUSED(state); + char ip[VPP_IP4_ADDRESS_STRING_LEN] = "192.168.100.44"; + uint8_t buf[4]; int rc; - query.id = 1; - query.use_random_mac = 1; - - rc = create_tapv2(&query); + rc = sc_aton(ip, buf, VPP_IP4_ADDRESS_LEN); assert_int_equal(rc, 0); - //TODO dump_tav2 and compare values - - rc = delete_tapv2("tap1"); - assert_int_equal(rc, 0); + assert_int_equal(buf[0], 192); + assert_int_equal(buf[1], 168); + assert_int_equal(buf[2], 100); + assert_int_equal(buf[3], 44); } -int main() +static int setup(void **state) { + UNUSED(state); tapv2_create_t query = {0}; - const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(test_enable_disable, NULL, NULL), - cmocka_unit_test_setup_teardown(test_name2index, NULL, NULL), - cmocka_unit_test_setup_teardown(test_add_ipv4, NULL, NULL), - cmocka_unit_test_setup_teardown(test_remove_ipv4, NULL, NULL), - cmocka_unit_test_setup_teardown(test_sc_ntoa, NULL, NULL), - cmocka_unit_test_setup_teardown(test_create_tapv2, NULL, NULL), - }; - if (sc_connect_vpp() != 0) + if (sc_connect_vpp() != 0) { fprintf(stderr, "Error connecting to VPP\n"); + return -1; + } /* Create interface tap0 to test several functions */ query.id = 0; query.use_random_mac = 1; - if (create_tapv2(&query) != 0) + if (create_tapv2(&query) != 0) { fprintf(stderr, "Error creating tap0\n"); + return -1; + } - cmocka_run_group_tests(tests, NULL, NULL); - - print_message("\nNAT Tests\n"); - cmocka_run_group_tests(nat_tests, NULL, NULL); + return 0; +} +static int teardown(void **state) +{ + UNUSED(state); /* Delete tap0 */ - if (delete_tapv2("tap0") != 0) + if (delete_tapv2("tap0") != 0) { fprintf(stderr, "Failed deleting tap0\n"); + return -1; + } + + sc_disconnect_vpp(); + + return 0; +} + +/* return code for scvpp-test binary is the number of failed test */ +int main() +{ + int rc = 0; + + const struct CMUnitTest common_tests[] = { + cmocka_unit_test(test_sc_ntoa), + cmocka_unit_test(test_sc_aton), + }; + + print_message("Common tests\n"); + rc |= cmocka_run_group_tests(common_tests, NULL, NULL); + print_message("Interface tests\n"); + rc |= cmocka_run_group_tests(iface_tests, setup, teardown); + print_message("IP tests\n"); + rc |= cmocka_run_group_tests(ip_tests, setup, teardown); + print_message("NAT tests\n"); + rc |= cmocka_run_group_tests(nat_tests, setup, teardown); - return sc_disconnect_vpp(); + return rc; } diff --git a/src/scvpp/tests/scvpp_test.h b/src/scvpp/tests/scvpp_test.h new file mode 100644 index 0000000..28bd514 --- /dev/null +++ b/src/scvpp/tests/scvpp_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 Cisco + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SCVPP_TEST_H +#define __SCVPP_TEST_H__ + +#include + +#define IFACE_TEST_SIZE 6 +extern const struct CMUnitTest iface_tests[IFACE_TEST_SIZE]; + +#define IP_TEST_SIZE 3 +extern const struct CMUnitTest ip_tests[IP_TEST_SIZE]; + +#define NAT_TEST_SIZE 2 +extern const struct CMUnitTest nat_tests[NAT_TEST_SIZE]; + +#endif /* __SCVPP_TEST_H__ */ -- cgit 1.2.3-korg