module opendaylight-action-types {
    namespace "urn:opendaylight:action:types";
    prefix action;

    import ietf-inet-types {prefix inet; revision-date "2013-07-15";}
    import ietf-yang-types {prefix yang; revision-date "2013-07-15";}
    import opendaylight-l2-types {prefix l2t; revision-date "2013-08-27";}
    import opendaylight-match-types {prefix match; revision-date "2013-10-26";}

    revision "2013-11-12" {
        description "Initial revision of action service";
    }

    typedef vlan-cfi {
        type int32;
    }

    grouping address {
        choice address {
            case ipv4 {
                leaf ipv4-address {
                    type inet:ipv4-prefix;
                }
            }
            case ipv6 {
                leaf ipv6-address {
                    type inet:ipv6-prefix;
                }
            }
        }
    }

    container action-types {
       uses action-list;
    }

    grouping ordered {
        leaf order {
          type int32;
        }
    }

    grouping action-list {
        list action {
            key "order";
            uses ordered;
            uses action;
        }
    }

    grouping action {
        choice action {
            case output-action-case {
                container output-action {
                    leaf output-node-connector {
                        type inet:uri;
                    }

                    leaf max-length {
                        type uint16;
                    }
                }
            }

            case controller-action-case {
                container controller-action {
                 leaf max-length {
                     type uint16;
                 }
             }
            }



            case set-field-case {
                container set-field {
                     uses match:match;
                 }
             }


            case set-queue-action-case {
                container set-queue-action {
                 leaf queue {
                     type string;
                 }
                 leaf queue-id {
                     type uint32;
                 }
             }
            }

           case pop-mpls-action-case {
                container pop-mpls-action {
                 leaf ethernet-type {
                     type uint16; // TODO: define ethertype type
                 }
             }
            }


            case set-mpls-ttl-action-case {
                container set-mpls-ttl-action {
                 leaf mpls-ttl {
                     type uint8;
                 }
             }
            }


            case set-nw-ttl-action-case {
                container set-nw-ttl-action {
                 leaf nw-ttl {
                     type uint8;
                 }
             }
            }


            case push-pbb-action-case {
                container push-pbb-action {
                 leaf ethernet-type {
                     type uint16; // TODO: define ethertype type
                 }
             }
            }


            case pop-pbb-action-case {
                container pop-pbb-action {
                    presence "no content action";
                }
            }


            case push-mpls-action-case {
                container push-mpls-action {
                 leaf ethernet-type {
                     type uint16; // TODO: define ethertype type
                 }
             }
            }


            case dec-mpls-ttl-case {
                container dec-mpls-ttl {
                    presence "no content action";
                }
             }


            case dec-nw-ttl-case {
                container dec-nw-ttl {
                    presence "no content action";
                }
             }


            case drop-action-case {
                container drop-action {
                    presence "no content action";
                }
             }


            case flood-action-case {
                container flood-action {
                    presence "no content action";
                }
             }


            case flood-all-action-case {
                container flood-all-action {
                    presence "no content action";
                }
             }


            case hw-path-action-case {
                container hw-path-action {
                    presence "no content action";
                }
             }


            case loopback-action-case {
                container loopback-action {
                    presence "no content action";
                }
             }


            case pop-vlan-action-case {
                container pop-vlan-action {
                    presence "no content action";
                }
             }



            case push-vlan-action-case {
                container push-vlan-action {
                 leaf ethernet-type {
                     type uint16; // TODO: define ethertype type
                 }
                leaf tag {               // TPID - 16 bits
                    type int32;
                }
                leaf pcp {               // PCP - 3 bits
                    type int32;
                }
                leaf cfi {               // CFI - 1 bit (drop eligible)
                    type vlan-cfi;
                }
                leaf vlan-id {           // VID - 12 bits
                    type l2t:vlan-id;
                }
//                leaf tci {               //TCI = [PCP + CFI + VID]
//                }
//                leaf header {            //header = [TPID + TCI]
//                }
                }
             }

            case copy-ttl-out-case {
                container copy-ttl-out {
                    presence "no content action";
                }
             }


            case copy-ttl-in-case {
                container copy-ttl-in {
                    presence "no content action";
                }
             }


            case set-dl-dst-action-case {
                container set-dl-dst-action {
                 leaf address {
                     type yang:mac-address;
                 }
             }
            }


            case set-dl-src-action-case {
                container set-dl-src-action {
                 leaf address {
                     type yang:mac-address;
                 }
             }

            }
            case group-action-case {
                container group-action {
                 leaf group {
                     type string;
                 }

                leaf group-id {
                    type uint32;
                }
             }
            }

            case set-dl-type-action-case {
                container set-dl-type-action {
                 leaf dl-type {
                     type l2t:ether-type;
                 }
             }
            }


            case set-next-hop-action-case {
                container set-next-hop-action {
                 uses address;
             }
            }


            case set-nw-dst-action-case {
                container set-nw-dst-action {
                 uses address;
             }
            }


            case set-nw-src-action-case {
                container set-nw-src-action {
                 uses address;
             }
            }


            case set-nw-tos-action-case {
                container set-nw-tos-action {
                 leaf tos {
                     type int32;
                 }
             }
            }


            case set-tp-dst-action-case {
                container set-tp-dst-action {
                 leaf port {
                     type inet:port-number;
                 }
                 leaf ip-protocol {
                     description "IP protocol.";
                     type uint8;
                     default 0;
                 }
             }

            }
            case set-tp-src-action-case {
                container set-tp-src-action {
                 leaf port {
                     type inet:port-number;
                 }
                 leaf ip-protocol {
                     description "IP protocol.";
                     type uint8;
                     default 0;
                 }
             }

            }
            case set-vlan-cfi-action-case {
                container set-vlan-cfi-action {
                 leaf vlan-cfi {
                     type vlan-cfi;
                 }
             }
            }


            case set-vlan-id-action-case {
                container set-vlan-id-action {
                 leaf vlan-id {
                     type l2t:vlan-id;
                 }
             }
            }


            case set-vlan-pcp-action-case {
                container set-vlan-pcp-action {
                 leaf vlan-pcp {
                     type l2t:vlan-pcp;
                 }
             }
            }

	    case strip-vlan-action-case {
                container strip-vlan-action {
                    presence "no content action";
                }
             }

            case sw-path-action-case {
                container sw-path-action {
                    presence "no content action";
                }
             }
         }
     }
}