Skip to content

parser cbor FEATURE RESTCONF notification envelope - #2616

Merged
michalvasko merged 4 commits into
develfrom
cbor-restconf-notif
Nov 2, 2026
Merged

michalvasko merged 4 commits into
develfrom
cbor-restconf-notif

Conversation

@Roytak

@Roytak Roytak commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Adds CBOR support for RESTCONF notifications, which sysrepo needs to parse CBOR-encoded UDP-Notif messages.

It contains 4 changes:

  • lyd_parse_op() with LYD_TYPE_NOTIF_RESTCONF accepts LYD_CBOR,
  • a public LY_HAVE_CBOR macro in ly_config.h, defined when libyang is built with libcbor, so applications can tell whether LYD_CBOR works,
  • LYD_TYPE_RPC_RESTCONF and LYD_TYPE_REPLY_RESTCONF reject formats other than XML and JSON instead of passing them to the JSON parser,
  • indefinite-length CBOR strings are parsed, they were read as empty strings.

The CBOR format is built only when libcbor is found, but this was
recorded in the private ENABLE_CBOR_SUPPORT definition, so an
application had no way to tell whether LYD_CBOR works.

Replace the private definition with LY_HAVE_CBOR in the installed
ly_config.h so that both libyang and its users test the same macro.
lyd_parse_op() accepted only JSON for LYD_TYPE_NOTIF_RESTCONF, so a
CBOR-encoded notification (RFC 8040 envelope in RFC 9254 encoding,
as sent by UDP-Notif) could not be parsed with its eventTime.

The CBOR input is decoded as a whole, so the envelope is checked
directly in the loaded map and eventTime is created in the envelope
wherever it is placed, unlike the streaming JSON parser.

Also cover a notification nested in a list and one with an anydata
payload in the CBOR round-trip tests.
LYD_TYPE_RPC_RESTCONF and LYD_TYPE_REPLY_RESTCONF did not check the
format, so LYB or CBOR input was passed to the JSON RESTCONF parser.
Only XML and JSON are documented and supported, reject the rest.
lydcbor_item_to_string() read only definite-length strings, an
indefinite-length (chunked) text or byte string, valid per RFC 8949,
was read as an empty string. Concatenate its chunks.
@michalvasko
michalvasko merged commit e5b8c59 into devel Nov 2, 2026
13 checks passed
@michalvasko
michalvasko deleted the cbor-restconf-notif branch November 2, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants