cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1762
Views
4
Helpful
1
Replies

yang type for interface ip address with mask

rainnomm56
Level 1
Level 1

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.

1 Accepted Solution

Accepted Solutions

alam.bilal
Cisco Employee
Cisco Employee

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.";

  }

View solution in original post

1 Reply 1

alam.bilal
Cisco Employee
Cisco Employee

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.";

  }

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: