Skip to content

Commit

Permalink
Seperate the sample Yang models and data files for libyang python API…
Browse files Browse the repository at this point in the history
… testing (sonic-net#16)
  • Loading branch information
li-pingmao authored and zhenggen-xu committed Jan 9, 2020
1 parent bf3ec05 commit 157fe9e
Show file tree
Hide file tree
Showing 8 changed files with 896 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
module sonic-acl {

yang-version 1.1;

namespace "http://github.com/Azure/sonic-acl";
prefix acl;

import ietf-yang-types {
prefix yang;
}

import ietf-inet-types {
prefix inet;
}

import sonic-head {
prefix head;
revision-date 2019-07-01;
}

import sonic-port {
prefix port;
revision-date 2019-07-01;
}

import sonic-portchannel {
prefix lag;
revision-date 2019-07-01;
}

organization "Linkedin Corporation";

contact "lnos_coders@linkedin.com";

description "ACL YANG Module for SONiC OS";

revision 2019-07-01 {
description "First Revision";
}

container sonic-acl {

container ACL_RULE {

description "ACL_RULE part of config_db.json";

list ACL_RULE_LIST {

key "ACL_TABLE_NAME RULE_NAME";

leaf ACL_TABLE_NAME {
type leafref {
path "/acl:sonic-acl/acl:ACL_TABLE/acl:ACL_TABLE_LIST/acl:ACL_TABLE_NAME";
}
}

leaf RULE_NAME {
type string {
length 1..255;
}
}

leaf PACKET_ACTION {
type head:packet_action;
}

leaf IP_TYPE {
type head:ip_type;
}

leaf PRIORITY {
type uint32 {
range 0..999999;
}
}

choice ip_prefix {

case ip4_prefix {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPV4ANY' or .='ARP'])";
leaf SRC_IP {
type inet:ipv4-prefix;
}

leaf DST_IP {
type inet:ipv4-prefix;
}
}

case ip6_prefix {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPV6ANY'])";
leaf SRC_IPV6 {
type inet:ipv6-prefix;
}

leaf DST_IPV6 {
type inet:ipv6-prefix;
}
}
}

leaf-list IN_PORTS {
/* Values in leaf list are UNIQUE */
type uint16;
}

leaf-list OUT_PORTS {
/* Values in leaf list are UNIQUE */
type uint16;
}

choice src_port {
case l4_src_port {
leaf L4_SRC_PORT {
type uint16;
}
}

case l4_src_port_range {
leaf L4_SRC_PORT_RANGE {
type string {
pattern '([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])-([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])';
}
}
}
}

choice dst_port {
case l4_dst_port {
leaf L4_DST_PORT {
type uint16;
}
}

case l4_dst_port_range {
leaf L4_DST_PORT_RANGE {
type string {
pattern '([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])-([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])';
}
}
}
}

leaf ETHER_TYPE {
type string {
pattern "(0x88CC|0x8100|0x8915|0x0806|0x0800|0x86DD|0x8847)";
}
}

leaf IP_PROTOCOL {
type uint8 {
range 1..143;
}
}

leaf TCP_FLAGS {
type string {
pattern '0[x][0-9a-fA-F]{1,2}|0[X][0-9a-fA-F]{1,2}';
}
}

leaf DSCP {
type uint8;
}

leaf TC {
type uint8;
}

choice icmp {

case icmp4 {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPV4ANY' or .='ARP'])";
leaf ICMP_TYPE {
type uint8 {
range 1..44;
}
}

leaf ICMP_CODE {
type uint8 {
range 1..16;
}
}
}

case icmp6 {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPV6ANY'])";
leaf ICMPV6_TYPE {
type uint8 {
range 1..44;
}
}

leaf ICMPV6_CODE {
type uint8 {
range 1..16;
}
}
}
}

leaf INNER_ETHER_TYPE {
type string {
pattern "(0x88CC|0x8100|0x8915|0x0806|0x0800|0x86DD|0x8847)";
}
}

leaf INNER_IP_PROTOCOL {
type uint8 {
range 1..143;
}
}

leaf INNER_L4_SRC_PORT {
type uint16;
}

leaf INNER_L4_DST_PORT {
type uint16;
}
}
/* end of ACL_RULE_LIST */
}
/* end of container ACL_RULE */

container ACL_TABLE {

description "ACL_TABLE part of config_db.json";

list ACL_TABLE_LIST {

key "ACL_TABLE_NAME";

leaf ACL_TABLE_NAME {
type string;
}

leaf policy_desc {
type string {
length 1..255;
}
}

leaf type {
type head:acl_table_type;
}

leaf stage {
type enumeration {
enum INGRESS;
enum EGRESS;
}
}

leaf-list ports {
/* union of leafref is allowed in YANG 1.1 */
type union {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
}
type leafref {
path /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:portchannel_name;
}
}
}
}
/* end of ACL_TABLE_LIST */
}
/* end of container ACL_TABLE */
}
/* end of container sonic-acl */
}
/* end of module sonic-acl */
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module sonic-head {

namespace "http://sonic-head";
prefix sonic-head;

organization "Linkedin Corporation";

contact "lnos_coders@linkedin.com";

description "Head yang Module for SONiC OS";

revision 2019-07-01 {
description "First Revision";
}

typedef ip-family {
type enumeration {
enum IPv4;
enum IPv6;
}
}

typedef admin_status {
type enumeration {
enum up;
enum down;
}
}

typedef packet_action{
type enumeration {
enum DROP;
enum FORWARD;
enum REDIRECT;
}
}

typedef ip_type {
type enumeration {
enum ANY;
enum IP;
enum NON_IP;
enum IPV4;
enum IPV6;
enum IPV4ANY;
enum NON_IPv4;
enum IPV6ANY;
enum NON_IPv6;
enum ARP;
}
}

typedef acl_table_type {
type enumeration {
enum L2;
enum L3;
enum L3V6;
enum MIRROR;
enum MIRRORV6;
enum MIRROR_DSCP;
enum CTRLPLANE;
}
}

typedef vlan_tagging_mode {
type enumeration {
enum tagged;
enum untagged;
enum priority_tagged;
}
}
}
Loading

0 comments on commit 157fe9e

Please sign in to comment.