Skip to content

ADD support for .sid file generation and update - #2556

Open
HanzlikPetr wants to merge 2 commits into
CESNET:develfrom
HanzlikPetr:sid_generation
Open

ADD support for .sid file generation and update#2556
HanzlikPetr wants to merge 2 commits into
CESNET:develfrom
HanzlikPetr:sid_generation

Conversation

@HanzlikPetr

Copy link
Copy Markdown

Adds Schema Item Identifier (SID) file support per RFC 9595, enabling
libyang to generate, update, and extend .sid files for YANG modules.
The change spans the library (new ietf-sid-file module and
printer_sid.c) and the yanglint tool (new sid command).

Library (public API in tree_schema.h):

  • lys_sid_gen() - generate a new .sid file
  • lys_sid_update() - update a previous .sid file (reuse SIDs, mark removed items "obsolete", bump sid-file-version)
  • lys_sid_range_add() - append a new assignment range
  • LYS_SID_FILE_STATUS enum (UNPUBLISHED / PUBLISHED)

yanglint sid command (interactive and -g/--sid non-interactive):

  • generate EP:SIZE [published]
  • update <prev.sid> [published]
  • range-add EP:SIZE <prev.sid>

Comment on lines +6 to +10
import ietf-yang-types {
prefix yang;
reference
"RFC 6991: Common YANG Data Types";
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid file formatting, missing indents.

Comment thread src/printer_sid.c
"The assignment range [%" PRIu64 ", %" PRIu64 "] exceeds the SID data type bounds.",
entry_point, entry_point + size - 1), rc = LY_EINVAL), cleanup);

snprintf(ep_str, sizeof(ep_str), "%" PRIu64, entry_point);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant, you can directly perform this print when calling asprintf().

Comment thread src/printer_sid.c
}

if (version) {
snprintf(ver_str, sizeof(ver_str), "%" PRIu32, version);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting, we use just sizeof ver_str when referencing variables directly.

Comment thread src/printer_sid.c
Comment on lines +224 to +228
struct tm tm_utc;
char time_str[21];

gmtime_r(&now, &tm_utc);
strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", &tm_utc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use ly_time_time2str() instead.

Comment thread src/printer_sid.c
value = sid_child_value(child, "entry-point");
LY_CHECK_ERR_GOTO(!value,
(LOGERR(LYD_CTX(tree), LY_EINVAL, "Missing required data in the previous .sid file."), rc = LY_EINVAL), cleanup);
ep = strtoull(value, NULL, 10);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to convert from string, number can be directly accessed by casting the data node into struct lyd_node_term and then accessing value.

Comment thread tools/lint/main_ni.c
" Enable stricter YANG model validation according to IETF rules.\n\n");

printf(" -g OP, --sid=OP\n"
" Process a .sid file of the loaded schema modules, print it in the JSON format.\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be trivial to support any format, based on the existing format argument.

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