04-02-2018 12:09 PM - edited 03-01-2019 04:07 AM
What is the correct data type inside yang for interface ip address with mask? Like Juniper or Alcatel uses on interface 192.168.0.1/24. I like that format most, because it is most condensed.
I tried to use "type inet:ipv4-prefix" but that applies only to network addresses, not host addresses.
Solved! Go to Solution.
04-02-2018 06:59 PM
If you are after a predefined YANG model, then you could try this one:
[nso/src/ncs/yang/tailf-common.yang]
type tailf:ip-address-and-prefix-length;
. . .
typedef ip-address-and-prefix-length {
type union {
type tailf:ipv4-address-and-prefix-length;
type tailf:ipv6-address-and-prefix-length;
}
. . .
typedef ipv4-address-and-prefix-length {
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
"The ipv4-address-and-prefix-length type represents a combination
of an IPv4 address and a prefix length. The prefix length is given
by the number following the slash character and must be less than
or equal to 32.";
}
04-02-2018 06:59 PM
If you are after a predefined YANG model, then you could try this one:
[nso/src/ncs/yang/tailf-common.yang]
type tailf:ip-address-and-prefix-length;
. . .
typedef ip-address-and-prefix-length {
type union {
type tailf:ipv4-address-and-prefix-length;
type tailf:ipv6-address-and-prefix-length;
}
. . .
typedef ipv4-address-and-prefix-length {
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
"The ipv4-address-and-prefix-length type represents a combination
of an IPv4 address and a prefix length. The prefix length is given
by the number following the slash character and must be less than
or equal to 32.";
}
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide