Skip to content

Commit 913badb

Browse files
committed
printer sid UPDATE create functions for generation and update sid file
1 parent 7658afb commit 913badb

8 files changed

Lines changed: 1954 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ set(libsrc
149149
src/parser_yang.c
150150
src/parser_yin.c
151151
src/printer_schema.c
152+
src/printer_sid.c
152153
src/printer_yang.c
153154
src/printer_yin.c
154155
src/printer_tree.c
Lines changed: 364 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,364 @@
1+
module ietf-sid-file {
2+
yang-version 1.1;
3+
namespace "urn:ietf:params:xml:ns:yang:ietf-sid-file";
4+
prefix sid;
5+
6+
import ietf-yang-types {
7+
prefix yang;
8+
reference
9+
"RFC 6991: Common YANG Data Types";
10+
}
11+
import ietf-yang-structure-ext {
12+
prefix sx;
13+
reference
14+
"RFC 8791: YANG Data Structure Extensions";
15+
}
16+
17+
organization
18+
"IETF CORE Working Group";
19+
20+
contact
21+
"WG Web: <https://datatracker.ietf.org/wg/core/>
22+
23+
WG List: <mailto:core@ietf.org>
24+
25+
Editor: Michel Veillette
26+
<mailto:michel.veillette@trilliant.com>
27+
28+
Editor: Andy Bierman
29+
<mailto:andy@yumaworks.com>
30+
31+
Editor: Alexander Pelov
32+
<mailto:alexander.pelov@imt-atlantique.fr>
33+
34+
Editor: Ivaylo Petrov
35+
<mailto:ivaylopetrov@google.com>";
36+
37+
description
38+
"This module defines the structure of the '.sid' files.
39+
40+
Each '.sid' file contains the mapping between each
41+
string identifier defined by a YANG module and a
42+
corresponding numeric value called a YANG SID.
43+
44+
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
45+
NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
46+
'MAY', and 'OPTIONAL' in this document are to be interpreted as
47+
described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
48+
they appear in all capitals, as shown here.
49+
50+
Copyright (c) 2024 IETF Trust and the persons identified as
51+
authors of the code. All rights reserved.
52+
53+
Redistribution and use in source and binary forms, with or
54+
without modification, is permitted pursuant to, and subject to
55+
the license terms contained in, the Revised BSD License set
56+
forth in Section 4.c of the IETF Trust's Legal Provisions
57+
Relating to IETF Documents
58+
(https://trustee.ietf.org/license-info).
59+
60+
This version of this YANG module is part of RFC 9595; see
61+
the RFC itself for full legal notices.";
62+
63+
revision 2024-07-31 {
64+
description
65+
"Initial revision.";
66+
reference
67+
"RFC 9595: YANG Schema Item iDentifier (YANG SID)";
68+
}
69+
70+
typedef revision-identifier {
71+
type string {
72+
pattern '[0-9]{4}-[0-9]{2}-[0-9]{2}';
73+
}
74+
description
75+
"Represents a date in YYYY-MM-DD format.";
76+
}
77+
78+
typedef sid-file-version-identifier {
79+
type uint32;
80+
description
81+
"Represents the version of a '.sid' file.";
82+
}
83+
84+
typedef sid {
85+
type uint64 {
86+
range "0..9223372036854775807";
87+
}
88+
description
89+
"YANG Schema Item iDentifier.";
90+
reference
91+
"RFC 9595: YANG Schema Item iDentifier (YANG SID)";
92+
}
93+
94+
typedef schema-node-path {
95+
type string {
96+
pattern
97+
'/[a-zA-Z_][a-zA-Z0-9\-_.]*:[a-zA-Z_][a-zA-Z0-9\-_.]*' +
98+
'(/[a-zA-Z_][a-zA-Z0-9\-_.]*(:[a-zA-Z_][a-zA-Z0-9\-_.]*)?)*';
99+
}
100+
description
101+
"A schema-node path is an absolute YANG schema-node
102+
identifier as defined by the YANG ABNF rule
103+
'absolute-schema-nodeid', except that module names are used
104+
instead of prefixes.
105+
106+
This string additionally follows the following rules:
107+
108+
- The leftmost (top-level) data node name is always in the
109+
namespace-qualified form.
110+
- Any subsequent schema-node name is in the
111+
namespace-qualified form if the node is defined in a
112+
module other than its parent node. Otherwise, the
113+
simple form is used. No predicates are allowed.";
114+
reference
115+
"RFC 5234 (STD 68): Augmented BNF for Syntax Specifications:
116+
ABNF
117+
RFC 7950: The YANG 1.1 Data Modeling Language,
118+
Section 6.5: Schema Node Identifier";
119+
}
120+
121+
sx:structure sid-file {
122+
uses sid-file-contents;
123+
}
124+
125+
grouping sid-file {
126+
description
127+
"A grouping that contains a YANG container
128+
representing the file structure of a '.sid' file.";
129+
130+
container sid-file {
131+
description
132+
"A wrapper container that together with the 'sx:structure'
133+
extension marks the YANG data structures inside as not
134+
being intended to be implemented as part of a
135+
configuration datastore or as an operational state within
136+
the server.";
137+
uses sid-file-contents;
138+
}
139+
}
140+
141+
grouping sid-file-contents {
142+
description
143+
"A grouping that defines the contents of a container that
144+
represents the file structure of a '.sid' file.";
145+
146+
leaf module-name {
147+
type yang:yang-identifier;
148+
mandatory true;
149+
description
150+
"Name of the YANG module associated with this
151+
'.sid' file.";
152+
}
153+
154+
leaf module-revision {
155+
type revision-identifier;
156+
description
157+
"Revision of the YANG module associated with this '.sid'
158+
file.
159+
This leaf is not present if no revision statement is
160+
defined in the YANG module.";
161+
}
162+
163+
leaf sid-file-version {
164+
type sid-file-version-identifier;
165+
default 0;
166+
description
167+
"Optional leaf that specifies the version number of the
168+
'.sid' file. '.sid' files and the version sequence are
169+
specific to a given YANG module revision. This number
170+
starts at zero when there is a new YANG module revision
171+
and increases monotonically. This number can distinguish
172+
updates to the '.sid' file - for instance, as the result
173+
of new processing or reported errata.";
174+
}
175+
176+
leaf sid-file-status {
177+
type enumeration {
178+
enum unpublished {
179+
description
180+
"This '.sid' file is unpublished (BCP 216) and is
181+
also called a work-in-progress or workfile.
182+
This may be when it accompanies an unpublished YANG
183+
module or when only the '.sid' file itself is
184+
unpublished.
185+
The 'item' list MAY contain entries with a status
186+
value of 'unstable'.";
187+
reference
188+
"RFC 8407 (BCP 216): Guidelines for Authors and
189+
Reviewers of Documents Containing
190+
YANG Data Models";
191+
}
192+
enum published {
193+
description
194+
"This '.sid' file is published. This status
195+
applies to '.sid' files for published YANG modules.
196+
The 'item' list MUST NOT contain entries with a
197+
status value of 'unstable'.";
198+
}
199+
}
200+
default "published";
201+
description
202+
"Optional leaf that specifies the status of the
203+
'.sid' file.";
204+
}
205+
206+
leaf description {
207+
type string;
208+
description
209+
"Free-form meta-information about the generated file. It
210+
might include a '.sid' file generation tool and time,
211+
among other things.";
212+
}
213+
214+
list dependency-revision {
215+
key "module-name";
216+
217+
description
218+
"Information about the revision used during the
219+
'.sid' file generation of each dependency, i.e., each
220+
YANG module that the YANG module associated with this
221+
'.sid' file imported.";
222+
223+
leaf module-name {
224+
type yang:yang-identifier;
225+
description
226+
"YANG module name of this dependency.";
227+
}
228+
leaf module-revision {
229+
type revision-identifier;
230+
mandatory true;
231+
description
232+
"Revision of the YANG module of this dependency.";
233+
}
234+
}
235+
236+
list assignment-range {
237+
key "entry-point";
238+
description
239+
"YANG-SID Range(s) allocated to the YANG module
240+
identified by 'module-name' and 'module-revision'.
241+
242+
- The first available value in the YANG-SID Range is
243+
'entry-point', and the last available value in the
244+
range is ('entry-point' + size - 1).
245+
- The YANG-SID Ranges specified by all
246+
'assignment-range' entries MUST NOT overlap.";
247+
248+
leaf entry-point {
249+
type sid;
250+
description
251+
"Lowest YANG SID available for assignment.";
252+
}
253+
254+
leaf size {
255+
type uint64;
256+
mandatory true;
257+
description
258+
"Number of YANG SIDs available for assignment.";
259+
}
260+
}
261+
262+
list item {
263+
key "namespace identifier";
264+
unique "sid";
265+
266+
description
267+
"Each entry within this list defines the mapping between
268+
a YANG item string identifier and a YANG SID. This list
269+
MUST include a mapping entry for each YANG item defined
270+
by the YANG module identified by 'module-name' and
271+
'module-revision'.";
272+
273+
leaf status {
274+
type enumeration {
275+
enum stable {
276+
value 0;
277+
description
278+
"This SID allocation has been published as the
279+
stable allocation for the given namespace and
280+
identifier.";
281+
}
282+
enum unstable {
283+
value 1;
284+
description
285+
"This SID allocation has been done during a
286+
development process; it is not yet stable.";
287+
}
288+
enum obsolete {
289+
value 2;
290+
description
291+
"This SID allocation is no longer in use. It is
292+
recorded to avoid reallocation of its SID value.";
293+
}
294+
}
295+
default "stable";
296+
description
297+
"The status field contains information about the
298+
stability of the allocation. For each specific SID
299+
value, over time it can only transition from
300+
'unstable' to 'stable', and possibly from 'stable' to
301+
'obsolete'.";
302+
}
303+
304+
leaf namespace {
305+
type enumeration {
306+
enum module {
307+
value 0;
308+
description
309+
"All module and submodule names share the same
310+
global module identifier namespace.";
311+
}
312+
enum identity {
313+
value 1;
314+
description
315+
"All identity names defined in a module and its
316+
submodules share the same identity identifier
317+
namespace.";
318+
}
319+
enum feature {
320+
value 2;
321+
description
322+
"All feature names defined in a module and its
323+
submodules share the same feature identifier
324+
namespace.";
325+
}
326+
enum data {
327+
value 3;
328+
description
329+
"The namespace for all data nodes, as defined in
330+
YANG.";
331+
}
332+
}
333+
description
334+
"Namespace of the YANG item for this mapping entry.";
335+
}
336+
337+
leaf identifier {
338+
type union {
339+
type yang:yang-identifier;
340+
type schema-node-path;
341+
}
342+
description
343+
"String identifier of the YANG item for this mapping
344+
entry.
345+
346+
If the corresponding 'namespace' field is 'module',
347+
'feature', or 'identity', then this field MUST
348+
contain a valid YANG identifier string.
349+
350+
If the corresponding 'namespace' field is 'data',
351+
then this field MUST contain a valid schema-node
352+
path.";
353+
}
354+
355+
leaf sid {
356+
type sid;
357+
mandatory true;
358+
description
359+
"YANG SID assigned to the YANG item for this mapping
360+
entry.";
361+
}
362+
}
363+
}
364+
}

0 commit comments

Comments
 (0)