The typedef YANG statement can be used to define
derived types from base types. In the following example,
a new data type called percent is created by limiting a
16-bit unsigned integer value to a range from 0 to 100:
Click here to view code image
typedef percent {
type uint16 {
range "0 .. 100";
}
Description "Percentage":
}
This new type of data can then be used when building the
YANG models. It is common practice to have definitions
of new types of data contained in a YANG submodule
that will then be imported in the main YANG module.
IETF has also defined in RFC 6021 a large number of
YANG types that are commonly used in networking.
These data types are organized in the inet-yang-types
module. The following are some of the many data types
defined in this RFC:
ipv4-address
ipv6-address
ip-prefix
domain-name
uri
mac-address
port-number
ip-version
phys-address
timestamp
date-and-time
flow-label
counter32/64
gauge32/64