Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ endif()
# Generic version of not only the library. Major version is reserved for really big changes of the project,
# minor version changes with added functionality (new tool, functionality of the tool or library, ...) and
# micro version is changed with a set of small changes or bugfixes anywhere in the project.
set(NP2SRV_VERSION 2.8.10)
set(NP2SRV_VERSION 2.8.11)

# libyang required version
set(LIBYANG_DEP_VERSION 5.1.3)
Expand Down
146 changes: 146 additions & 0 deletions modules/ietf-yp-transport-capabilities@2026-05-15.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
module ietf-yp-transport-capabilities {
yang-version 1.1;
namespace
"urn:ietf:params:xml:ns:yang:ietf-yp-transport-capabilities";
prefix ntc;

import ietf-subscribed-notifications {
prefix sn;
reference
"RFC 8639: Subscription to YANG Notifications";
}
import ietf-system-capabilities {
prefix sysc;
reference
"RFC 9196: YANG Modules Describing Capabilities for
Systems and Datastore Update Notifications";
}
import ietf-notification-capabilities {
prefix notc;
reference
"RFC 9196: YANG Modules Describing Capabilities for
Systems and Datastore Update Notifications";
}
import ietf-tls-common {
prefix tlscmn;
reference
"RFC 9645: YANG Groupings for TLS Clients and TLS Servers";
}

organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web: <https://datatracker.ietf.org/group/netconf/>
WG List: <mailto:netconf@ietf.org>

Authors: Qin Wu
<mailto:bill.wu@huawei.com>
Qiufang Ma
<mailto:maqiufang1@huawei.com>
Alex Huang Feng
<mailto:alex.huang-feng@insa-lyon.fr>
Thomas Graf
<mailto:thomas.graf@swisscom.com>";
description
"This module defines an extension to YANG-Push
Notification Capabilities model that provides additional
transport specific capabilities for YANG notifications.

The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
'MAY', and 'OPTIONAL' in this document are to be interpreted as
described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
they appear in all capitals, as shown here.

Copyright (c) 2026 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 Revised 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 XXXX
(https://www.rfc-editor.org/info/rfcXXXX); see the RFC itself
for full legal notices.";

revision 2026-05-15 {
description
"Initial revision.";
reference
"RFC XXXX: YANG Notifications Transport Capabilities";
}

identity security-protocol {
description
"Identity for YANG notifications security protocols.";
}

identity dtls12 {
base security-protocol;
description
"Indicates DTLS Protocol Version 1.2. DTLS 1.2 is obsolete,
and thus it is NOT RECOMMENDED to enable this feature.";
reference
"RFC 6347: The Datagram Transport Layer Security (DTLS)
Protocol Version 1.2.";
}

identity dtls13 {
base security-protocol;
description
"Indicates DTLS Protocol Version 1.3.";
reference
"RFC 9147: The Datagram Transport Layer Security (DTLS)
Protocol Version 1.3.";
}

augment "/sysc:system-capabilities"
+ "/notc:subscription-capabilities" {
description
"Adds subscription-related system level capabilities.";
container transport-capabilities {
description
"Specifies capabilities related to YANG-Push transports.";
list transport-capability {
key "transport-protocol";
description
"Indicates supported YANG notifications transport protocol
for Subscribed Notifications [RFC8639] and YANG-Push
[RFC8641]. Defines the supported transports, security
protocols and supported notification encodings.";
leaf transport-protocol {
type identityref {
base sn:transport;
}
description
"Indicates the supported YANG notifications transport
protocol for Subscribed Notifications [RFC8639] and
YANG-Push [RFC8641].";
}
leaf-list security-protocol {
type union {
type identityref {
base security-protocol;
}
type identityref {
base tlscmn:tls-version-base;
}
}
description
"Indicates the supported YANG notifications transport
encryption protocols.";
}
leaf-list encoding-format {
type identityref {
base sn:encoding;
}
description
"Indicates supported encoding formats for YANG notifications.";
}
}
}
}
}
1 change: 1 addition & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ NP2_MODULES=(
"netopeer-notifications@2026-01-05.yang"
"ietf-system-capabilities@2022-02-17.yang"
"ietf-notification-capabilities@2022-02-17.yang"
"ietf-yp-transport-capabilities@2026-05-15.yang"
"ietf-netconf-private-candidate@2026-02-03.yang -e private-candidate"
)

Expand Down
120 changes: 119 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,114 @@ np2srv_content_id_cb(void *UNUSED(user_data))
return strdup(buf);
}

/**
* @brief Add UDP-Notif transport capability to the transport-capabilities node.
*
* @param[in] transport_capas transport-capabilities container node.
* @param[in] yptc_mod ietf-yp-transport-capabilities module.
* @param[in] unt_mod ietf-udp-notif-transport module.
* @param[in] sn_mod ietf-subscribed-notifications module, may be NULL.
* @return 0 on success, -1 on error.
*/
static int
np2srv_add_udp_notif_transport_capability(struct lyd_node *transport_capas,
const struct lys_module *yptc_mod, const struct lys_module *unt_mod,
const struct lys_module *sn_mod)
{
struct lyd_node *cap = NULL;
int rc = 0;

if (lyd_new_list(transport_capas, yptc_mod, "transport-capability", 0, &cap,
"ietf-udp-notif-transport:udp-notif")) {
ERR("Failed to create transport-capability.");
rc = -1;
goto cleanup;
}

/* security-protocol */
if (lys_feature_value(unt_mod, "dtls") == LY_SUCCESS) {
if (lyd_new_term(cap, yptc_mod, "security-protocol", "ietf-yp-transport-capabilities:dtls12", 0, NULL)) {
ERR("Failed to create security-protocol dtls12.");
rc = -1;
goto cleanup;
}
if (lyd_new_term(cap, yptc_mod, "security-protocol", "ietf-yp-transport-capabilities:dtls13", 0, NULL)) {
ERR("Failed to create security-protocol dtls13.");
rc = -1;
goto cleanup;
}
}

/* encoding-format */
if (sn_mod && (lys_feature_value(sn_mod, "encode-xml") == LY_SUCCESS)) {
if (lyd_new_term(cap, yptc_mod, "encoding-format", "ietf-subscribed-notifications:encode-xml", 0, NULL)) {
ERR("Failed to create encoding-format encode-xml.");
rc = -1;
goto cleanup;
}
}
if (sn_mod && (lys_feature_value(sn_mod, "encode-json") == LY_SUCCESS)) {
if (lyd_new_term(cap, yptc_mod, "encoding-format", "ietf-subscribed-notifications:encode-json", 0, NULL)) {
ERR("Failed to create encoding-format encode-json.");
rc = -1;
goto cleanup;
}
}
if (lys_feature_value(unt_mod, "encode-cbor") == LY_SUCCESS) {
if (lyd_new_term(cap, yptc_mod, "encoding-format", "ietf-udp-notif-transport:encode-cbor", 0, NULL)) {
ERR("Failed to create encoding-format encode-cbor.");
rc = -1;
goto cleanup;
}
}

cleanup:
return rc;
}

/**
* @brief Add transport capabilities to a subscription-capabilities node.
*
* @param[in] subs_capas subscription-capabilities node.
* @param[in] ly_ctx libyang context.
* @return SR_ERR_OK on success, -1 on error.
*/
static int
np2srv_add_transport_capabilities(struct lyd_node *subs_capas, const struct ly_ctx *ly_ctx)
{
const struct lys_module *yptc_mod, *unt_mod, *sn_mod;
struct lyd_node *transport_capas = NULL;
int rc = SR_ERR_OK;

yptc_mod = ly_ctx_get_module_implemented(ly_ctx, "ietf-yp-transport-capabilities");
if (!yptc_mod) {
goto cleanup;
}

unt_mod = ly_ctx_get_module_implemented(ly_ctx, "ietf-udp-notif-transport");
if (!unt_mod) {
/* no transport module implemented, do not create an empty container */
goto cleanup;
}

/* transport-capabilities */
if (lyd_new_path(subs_capas, ly_ctx, "ietf-yp-transport-capabilities:transport-capabilities",
NULL, 0, &transport_capas)) {
ERR("Failed to create transport-capabilities.");
rc = -1;
goto cleanup;
}

sn_mod = ly_ctx_get_module_implemented(ly_ctx, "ietf-subscribed-notifications");

if ((rc = np2srv_add_udp_notif_transport_capability(transport_capas, yptc_mod, unt_mod, sn_mod))) {
goto cleanup;
}

cleanup:
return rc;
}

/**
* @brief Add subscription capabilities to a node
* @param[in,out] node is a part of ietf-system-capabilities.
Expand Down Expand Up @@ -568,6 +676,7 @@ np2srv_add_subscription_capabilities(struct lyd_node *node, const struct ly_ctx
goto cleanup;
}
}

cleanup:
return rc;
}
Expand All @@ -580,7 +689,7 @@ np2srv_capabilities_oper_cb(sr_session_ctx_t *session, uint32_t sub_id,
const char *module_name, const char *path, const char *request_xpath,
uint32_t request_id, struct lyd_node **parent, void *private_data)
{
struct lyd_node *sys_capas = NULL, *datastore_capas, *per_node_capas;
struct lyd_node *sys_capas = NULL, *datastore_capas, *per_node_capas, *global_subs_capas;
const struct ly_ctx *ly_ctx;
int rc = SR_ERR_OK;
uint32_t ds;
Expand Down Expand Up @@ -645,6 +754,15 @@ np2srv_capabilities_oper_cb(sr_session_ctx_t *session, uint32_t sub_id,
goto cleanup;
}

/* transport capabilities (subscription-capabilities was just created above, so it must be found) */
lyd_find_path(sys_capas, "ietf-notification-capabilities:subscription-capabilities", 0, &global_subs_capas);
assert(global_subs_capas);
if (np2srv_add_transport_capabilities(global_subs_capas, ly_ctx)) {
ERR("Failed to add transport-capabilities.");
rc = -1;
goto cleanup;
}

cleanup:
if (rc) {
lyd_free_tree(sys_capas);
Expand Down
Loading