321e0540974e3ccc5838e1638e251d6e47fd4b26
[controller.git] / opendaylight / md-sal / model / model-flow-base / src / main / yang / opendaylight-match-types.yang
1 module opendaylight-match-types {
2     namespace "urn:opendaylight:model:match:types";
3     prefix "match";
4
5     import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
6     import ietf-yang-types {prefix yang; revision-date "2010-09-24";}
7     import opendaylight-l2-types {prefix l2t;revision-date "2013-08-27";}
8     import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
9
10     revision "2013-10-26" {
11         description "Initial revision of macth types";
12     }
13
14     grouping "mac-address-filter" {
15         leaf address {
16             mandatory true;
17             type yang:mac-address;
18         }
19         leaf mask {
20             type yang:mac-address;
21         }
22     }
23
24     grouping "of-metadata" {
25         leaf metadata {
26             type uint64;
27         }
28
29         leaf metadata-mask {
30             type uint64;
31         }
32     }
33
34      /** Match Groupings **/
35     grouping "ethernet-match-fields" {
36         container ethernet-source {
37             description "Ethernet source address.";
38             presence "Match field is active and set";
39             uses mac-address-filter;
40         }
41         container ethernet-destination {
42             description "Ethernet destination address.";
43             presence "Match field is active and set";
44             uses mac-address-filter;
45         }
46         container ethernet-type {
47             description "Ethernet frame type.";
48             presence "Match field is active and set";
49
50             leaf type {
51                 mandatory true;
52                 type l2t:ether-type; // Needs to define that as general model
53             }
54         }
55     }
56
57     grouping "vlan-match-fields" {
58         container vlan-id {
59             description "VLAN id.";
60             presence "Match field is active and set";
61
62             leaf vlan-id-present {
63                 type boolean;
64             }
65
66             leaf vlan-id {
67                 type l2t:vlan-id;
68             }
69         }
70         leaf vlan-pcp {
71             description "VLAN priority.";
72             type l2t:vlan-pcp;
73         }
74     }
75
76     grouping "ip-match-fields" {
77         leaf ip-protocol {
78                 description "IP protocol.";
79                 type uint8;
80         }
81
82         leaf ip-dscp {
83             description "IP DSCP (6 bits in ToS field).";
84             type inet:dscp;
85         }
86
87         leaf ip-ecn {
88             description "IP ECN (2 bits in ToS field).";
89             type uint8;
90         }
91
92         leaf ip-proto {
93            description "IP Proto (IPv4 or IPv6 Protocol Number).";
94                type inet:ip-version;
95                 }
96     }
97
98     grouping "ipv4-match-fields" {
99         leaf ipv4-source {
100             description "IPv4 source address.";
101             type inet:ipv4-prefix;
102         }
103
104         leaf ipv4-destination {
105             description "IPv4 destination address.";
106             type inet:ipv4-prefix;
107         }
108
109     }
110
111     grouping "ipv6-match-fields" {
112         leaf ipv6-source {
113             description "IPv6 source address.";
114             type inet:ipv6-prefix;
115         }
116
117         leaf ipv6-destination {
118             description "IPv6 destination address.";
119             type inet:ipv6-prefix;
120         }
121
122         leaf ipv6-nd-target {
123             description "IPv6 target address for neighbour discovery message";
124             type inet:ipv6-address;
125         }
126
127         container "ipv6-label" {
128             leaf ipv6-flabel {
129                 type inet:ipv6-flow-label;
130             }
131
132             leaf flabel-mask {
133                 type inet:ipv6-flow-label;
134             }
135         }
136
137         leaf ipv6-nd-sll {
138             description "Link layer source address for neighbour discovery message";
139             type yang:mac-address;
140         }
141
142         leaf ipv6-nd-tll {
143             description "Link layer target address for neighbour discovery message";
144             type yang:mac-address;
145         }
146
147         container "ipv6-ext-header" {
148             leaf ipv6-exthdr {
149                 description "IPv6 Extension Header field";
150                 type uint16;
151             }
152
153             leaf ipv6-exthdr-mask {
154                 type uint16 {
155                   range "0..512";
156                 }
157             }
158         }
159     }
160
161     grouping "udp-match-fields" {
162         leaf udp-source-port {
163             description "UDP source port.";
164             type inet:port-number;
165         }
166         leaf udp-destination-port {
167             description "UDP destination port.";
168                 type inet:port-number;
169         }
170     }
171
172     grouping "protocol-match-fields" {
173         leaf mpls-label {
174             description "Label in the first MPLS shim header";
175             type uint32;
176         }
177
178         leaf mpls-tc {
179             description "TC in the first MPLS shim header";
180             type uint8;
181         }
182
183         leaf mpls-bos {
184             description "BoS bit in the first MPLS shim header";
185             type uint8;
186         }
187
188         container "pbb" {
189             leaf pbb-isid {
190                 description "I-SID in the first PBB service instance tag";
191                 type uint32;
192             }
193
194             leaf pbb-mask {
195                 type uint32 {
196                   range "0..16777216";
197                 }
198             }
199         }
200     }
201
202     grouping "tcp-match-fields" {
203         leaf tcp-source-port {
204             description "TCP source port.";
205             type inet:port-number;
206         }
207         leaf tcp-destination-port {
208             description "TCP destination port.";
209             type inet:port-number;
210         }
211     }
212
213     grouping "sctp-match-fields" {
214         leaf sctp-source-port {
215             description "SCTP source port.";
216             type inet:port-number;
217         }
218         leaf sctp-destination-port {
219             description "SCTP destination port.";
220             type inet:port-number;
221         }
222     }
223
224     grouping "icmpv4-match-fields" {
225         leaf icmpv4-type {
226         description "ICMP type.";
227             type uint8; // Define ICMP Type
228         }
229         description "ICMP code.";
230         leaf icmpv4-code {
231             type uint8; // Define ICMP Code
232         }
233     }
234
235     grouping "icmpv6-match-fields" {
236         leaf icmpv6-type {
237         description "ICMP type.";
238             type uint8; // Define ICMP Type
239         }
240         description "ICMP code.";
241         leaf icmpv6-code {
242             type uint8; // Define ICMP Code
243         }
244     }
245
246     grouping "arp-match-fields" {
247         leaf arp-op {
248             type uint16;
249         }
250
251         leaf arp-source-transport-address {
252             description "ARP source IPv4 address.";
253             type inet:ipv4-prefix;
254         }
255
256         leaf arp-target-transport-address {
257             description "ARP target IPv4 address.";
258             type inet:ipv4-prefix;
259         }
260         container arp-source-hardware-address {
261             description "ARP source hardware address.";
262             presence "Match field is active and set";
263             uses mac-address-filter;
264         }
265         container arp-target-hardware-address {
266             description "ARP target hardware address.";
267             presence "Match field is active and set";
268             uses mac-address-filter;
269         }
270     }
271
272     grouping match {
273         leaf in-port {
274             type inv:node-connector-id;
275         }
276
277         leaf in-phy-port {
278             type inv:node-connector-id;
279         }
280
281         container "metadata" {
282             uses of-metadata;
283         }
284
285         container "tunnel" {
286             leaf tunnel-id {
287                 description "Metadata associated in the logical port";
288                 type uint64;
289             }
290
291             leaf tunnel-mask {
292                 type uint64;
293             }
294         }
295
296         container "ethernet-match" {
297             uses "ethernet-match-fields";
298         }
299
300         container "vlan-match" {
301             uses "vlan-match-fields";
302         }
303
304         container "ip-match" {
305             uses "ip-match-fields";
306         }
307
308         choice layer-3-match {
309             case "ipv4-match" {
310                 uses "ipv4-match-fields";
311             }
312             case "ipv6-match" {
313                 uses "ipv6-match-fields";
314             }
315             case "arp-match" {
316                 uses "arp-match-fields";
317             }
318         }
319
320         choice layer-4-match {
321             case "udp-match" {
322                 uses "udp-match-fields";
323             }
324             case "tcp-match" {
325                 uses "tcp-match-fields";
326             }
327             case "sctp-match" {
328                 uses "sctp-match-fields";
329             }
330         }
331
332         container "icmpv4-match" {
333             uses "icmpv4-match-fields";
334         }
335
336         container "icmpv6-match" {
337             uses "icmpv6-match-fields";
338         }
339
340         container "protocol-match-fields" {
341             uses "protocol-match-fields";
342         }
343     }
344 }