module ietf-dhcp { namespace "urn:ietf:params:xml:ns:yang:ietf-dhcp"; prefix "dhcp"; import ietf-inet-types { prefix "inet"; } import ietf-yang-types { prefix "yang"; } import ietf-interfaces { prefix "if"; } organization "IETF dhc (Dynamic Host Configuration Protocol) Working Group"; contact "leo.liubing@huawei.com loukunkun@huawei.com chin.chen@ericsson.com"; description "The module for implementing DHCP protocol"; revision 2017-03-02 { description "initial draft revision"; reference "rfc2131 rfc6020"; } /*--------------------*/ /* Features */ /*--------------------*/ feature dhcp-server { description "Feature DHCP server"; } feature dhcp-client { description "Feature DHCP client"; } feature dhcp-relay { description "Feature DHCP relay"; } /*--------------------*/ /* Types Defination */ /*--------------------*/ typedef allocate-type { type enumeration { enum automatic { description "DHCP assigns a permanent IP address to a client"; } enum dynamic { description "DHCP assigns an IP address to a client for a limited period of time"; } enum manual { description "a client's IP address is assigned by the network administrator, and DHCP is used simply to convey the assigned address to the client"; } } description "Mechanisms for IP address allocation"; } /*--------------------*/ /* Groupings */ /*--------------------*/ grouping server-packet { description "The packets are sent from server "; leaf offer-packet { type uint32; config "false"; description "Total number of DHCPOFFER packets"; } leaf ack-packet { type uint32; config "false"; description "Total number of DHCPACK packets"; } leaf nack-packet { type uint32; config "false"; description "Total number of DHCPNAK packets"; } } grouping client-packet { description "The packets are sent from client "; leaf decline-packet { type uint32; config "false"; description "Total number of DHCPDECLINE packets"; } leaf discover-packet { type uint32; config "false"; description "Total number of DHCPDISCOVER packets"; } leaf request-packet { type uint32; config "false"; description "Total number of DHCPREQUEST packets"; } leaf release-packet { type uint32; config "false"; description "Total number of DHCPRELEASE packets"; } leaf inform-packet { type uint32; config "false"; description "Total number of DHCPINFORM packets"; } } grouping sum-packet { description "All of commnicated packets between server and client"; uses server-packet; uses client-packet; } grouping dhcp-option { description "Configuration option"; leaf dhcp-server-identifier { type inet:ip-address; description "DHCP server identifier"; } leaf domain-name { type string; description "Name of the domain"; } leaf domain-name-server { type inet:ip-address; description "IPv4 address of the domain"; } leaf interface-mtu { type uint32 { range "0..65535"; } description "Minimum Transmission Unit (MTU) of the interface"; } leaf netbios-name-server { type inet:ip-address; description "NETBIOS name server"; } leaf netbios-node-type { type uint32 { range "0..65535"; } description "NETBIOS node type"; } leaf netbios-scope { type string; description "NETBIOS scope"; } } /*--------------------*/ /* Configuration Data */ /*--------------------*/ container dhcp { description "DHCP configuration"; container server { if-feature dhcp-server; description "DHCP server configuration"; leaf lease-time { type uint32{ range "180..31536000"; } description "Default network address lease time assigned to DHCP clients"; } leaf ping-packet-number{ type uint8 { range "0..10"; } default "0"; description "Number of ping packets"; } leaf ping-packet-timeout { type uint16 { range "0..10000"; } default "500"; description "Timeout of ping packet"; } container option { description "Configuration option"; uses dhcp-option; } list dhcp-ip-pool { key "ip-pool-name"; description "Global IP pool configuration"; leaf ip-pool-name { type string { length "1..64"; } description "Name of the IP pool"; } leaf interface { type if:interface-ref; description "Name of the interface"; } leaf gateway-ip { type inet:ip-address; description "IPv4 address of the gateway"; } leaf gateway-mask { type inet:ip-prefix; description "Network submask of the gateway"; } leaf lease-time { type uint32 { range "180..31536000"; } description "Default network address lease time assigned to DHCP clients"; } list manual-allocation { key "mac-address ip-address"; description "Mapping from MAC address to IP address"; leaf mac-address { type yang:mac-address; description "MAC address of the host"; } leaf ip-address { type inet:ip-address; description "IPv4 address of the host"; } } list section { key "section-index"; description "IPv4 address for the range"; leaf section-index { type uint16 { range "0..255"; } description "Index of IPv4 address range"; } leaf section-start-ip { type inet:ipv4-address; mandatory "true"; description "Starting IPv4 Address of a section"; } leaf section-end-ip { type inet:ipv4-address; description "Last IPv4 Address of a section"; } } container option { description "Configuration option"; uses dhcp-option; } } } container relay { if-feature dhcp-relay; description "DHCP relay agent configuration"; list server-group { key "server-group-name"; description "DHCP server group configuration that DHCP relays to"; leaf server-group-name { type string; description "Name of a DHCP server group"; } leaf interface { type if:interface-ref; description "Name of the interface"; } leaf gateway-address { type inet:ipv4-address; description "IPv4 address of the gateway"; } leaf-list server-address { type inet:ipv4-address; description "IPv4 address of the server"; } } } container client { if-feature dhcp-client; description "DHCP client configuration"; list interfaces { key "interface"; description "Interface configuration"; leaf interface { type if:interface-ref; description "Name of the interface"; } leaf client-id { type string; description "DHCP client identifier"; } leaf lease { type uint32 { range "1..4294967295"; } description "Default network address lease time assigned to DHCP clients"; } } } } /*--------------------------*/ /* Operational State Data */ /*--------------------------*/ container dhcp-state { config "false"; description "DHCP state data"; container server { if-feature dhcp-server; description "DHCP server state data"; container packet-statistics { description "Packet statistics"; leaf interface { type if:interface-state-ref; description "Name of the interface"; } container receive { description "Number of received packets"; uses client-packet; } container send { description "Number of sent packets"; uses server-packet; } } container host { description "Host status information"; leaf interface { type string; config "false"; description "Name of the interface"; } leaf host-ip { type string; config "false"; description "IPv4 address of the host"; } leaf host-hardware-address { type string; config "false"; description "MAC address of the host"; } leaf lease { type uint32; config "false"; description "Default network address lease time assigned to DHCP clients"; } leaf type { type allocate-type; config "false"; description "Mechanisms for IP address allocation"; } } list ip-pool { key "ip-pool-name"; description "Global IP pool configuration"; leaf ip-pool-name { type string { length "1..64"; } description "Name of an IP pool"; } leaf gateway-ip { type inet:ip-address; description "IPv4 address of the gateway"; } leaf gateway-mask { type inet:ip-prefix; description "Network submask of the gateway"; } leaf used-ip-count { type uint32; config "false"; description "Total number of used IPv4 addresses"; } leaf idle-ip-count { type uint32; config "false"; description "Total number of idle IPv4 addresses"; } leaf conflict-ip-count { type uint32; config "false"; description "Total number of conflict IPv4 addresses"; } leaf total-ip-count { type uint32; config "false"; description "Total number of IPv4 addresses"; } } } container relay { if-feature dhcp-relay; description "DHCP reply agent state data"; container packet-statistics { description "Packet statistics"; leaf interface { type if:interface-state-ref; description "Name of the interface"; } container receive { description "Number of received packets"; uses sum-packet; } container send { description "Number of sent packets"; uses sum-packet; } } } container client { if-feature dhcp-client; description "DHCP client state data"; container packet-statistics { description "Packet statistics"; leaf interface { type if:interface-state-ref; description "Name of the interface"; } container receive { description "Number of received packets"; uses server-packet; } container send { description "Number of sent packets"; uses client-packet; } } } } /*--------------------------*/ /* Define RPC for action */ /*--------------------------*/ rpc clean-server-statistics { if-feature dhcp-server; description "Clean server packet statistics"; input { leaf interface { type leafref { path "/dhcp:dhcp-state/dhcp:server/"+ "dhcp:packet-statistics/dhcp:interface"; } description "Name of the interface"; } leaf clean-at { type yang:date-and-time; description "The start time to clean packet statistics"; } } output { leaf clean-finished-at { type yang:date-and-time; description "The finish time to clean packet statistics"; } } } rpc clean-relay-statistics { if-feature dhcp-relay; description "Clean relay packet statistics"; input { leaf interface { type leafref { path "/dhcp:dhcp-state/dhcp:relay/"+ "dhcp:packet-statistics/dhcp:interface"; } description "Name of the interface"; } leaf clean-at { type yang:date-and-time; description "The start time to clean packet statistics"; } } output { leaf clean-finished-at { type yang:date-and-time; description "The finish time to clean packet statistics"; } } } rpc clean-client-statistics { if-feature dhcp-client; description "Clean client packet statistics"; input { leaf interface { type leafref { path "/dhcp:dhcp-state/dhcp:client/"+ "dhcp:packet-statistics/dhcp:interface"; } description "Name of the interface"; } leaf clean-at { type yang:date-and-time; description "The start time to clean packet statistics"; } } output { leaf clean-finished-at { type yang:date-and-time; description "The finish time to clean packet statistics"; } } } }