added new serialization factories and their tests
[openflowjava.git] / openflow-protocol-api / src / main / yang / openflow-extensible-match.yang
1 module openflow-extensible-match {
2     namespace "urn:openflowopenflow:oxm";
3     prefix "oxm";
4
5
6     
7     import ietf-yang-types {prefix yang;}
8     import ietf-inet-types {prefix inet;}
9     import openflow-types {prefix oft;}
10
11
12     revision "2013-07-31" {
13         description "Initial model";
14     }
15
16     identity oxm-match-type {
17         description 
18            "The OpenFlow Extensible Match type must be supported by all OpenFlow
19             switches.";
20         base oft:match-type-base;
21     }
22     
23
24     // oxm classes
25         identity class {
26             description "Base identity for OXM classes";
27         }
28
29
30         identity nxm-0-class {
31             description "Backward compatibility with NXM";
32             base class;
33         }
34         identity nxm-1-class {
35             description "Backward compatibility with NXM";
36             base class;
37         }
38         identity openflow-basic-class {
39             description "Basic class for OpenFlow";
40             base class;
41         }
42         identity experimenter-class {
43             description 
44                 "Marks Experimenter match type class.
45                 All experimenter match classes MUST use this class as a base.";
46             base class;
47         }
48
49
50
51     // field types
52         /*
53         identity match-field {
54             description "Base identity for OXM Fields";
55         }
56
57         identity in_port {
58             base match-field;
59             description "Match for Switch input port.";
60         }
61         identity in_phy_port {
62             base match-field;
63             description "Match for Switch physical input port.";
64         }
65         identity metadata {
66             base match-field;
67             description "Match for Metadata passed between tables.";
68         }
69         identity eth_dst {
70             base match-field;
71             description "Match for Ethernet destination address.";
72         }
73         identity eth_src {
74             base match-field;
75             description "Match for Ethernet source address.";
76         }
77         identity eth_type {
78             base match-field;
79             description "Match for Ethernet frame type.";
80         }
81         identity vlan_vid {
82             base match-field;
83             description "Match for VLAN id.";
84         }
85         identity vlan_pcp {
86             base match-field;
87             description "Match for VLAN priority.";
88         }
89         identity ip_dscp {
90             base match-field;
91             description "Match for IP DSCP (6 bits in ToS field).";
92         }
93         identity ip_ecn {
94             base match-field;
95             description "Match for IP ECN (2 bits in ToS field).";
96         }
97         identity ip_proto {
98             base match-field;
99             description "Match for IP protocol.";
100         }
101         identity ipv4_src {
102             base match-field;
103             description "Match for IPv4 source address.";
104         }
105         identity ipv4_dst {
106             base match-field;
107             description "Match for IPv4 destination address.";
108         }
109         identity tcp_src {
110             base match-field;
111             description "Match for TCP source port.";
112         }
113         identity tcp_dst {
114             base match-field;
115             description "Match for TCP destination port.";
116         }
117         identity udp_src {
118             base match-field;
119             description "Match for UDP source port.";
120         }
121         identity udp_dst {
122             base match-field;
123             description "Match for UDP destination port.";
124         }
125         identity sctp_src {
126             base match-field;
127             description "Match for SCTP source port.";
128         }
129         identity sctp_dst {
130             base match-field;
131             description "Match for SCTP destination port.";
132         }
133         identity icmpv4_type {
134             base match-field;
135             description "Match for ICMP type.";
136         }
137         identity icmpv4_code {
138             base match-field;
139             description "Match for ICMP code.";
140         }
141         identity arp_op {
142             base match-field;
143             description "Match for ARP opcode.";
144         }
145         identity arp_spa {
146             base match-field;
147             description "Match for ARP source IPv4 address.";
148         }
149         identity arp_tpa {
150             base match-field;
151             description "Match for ARP target IPv4 address.";
152         }
153         identity arp_sha {
154             base match-field;
155             description "Match for ARP source hardware address.";
156         }
157         identity arp_tha {
158             base match-field;
159             description "Match for ARP target hardware address.";
160         }
161         identity ipv6_src {
162             base match-field;
163             description "Match for IPv6 source address.";
164         }
165         identity ipv6_dst {
166             base match-field;
167             description "Match for IPv6 destination address.";
168         }
169         identity ipv6_flabel {
170             base match-field;
171             description "Match for IPv6 Flow Label";
172         }
173         identity icmpv6_type {
174             base match-field;
175             description "Match for ICMPv6 type.";
176         }
177         identity icmpv6_code {
178             base match-field;
179             description "Match for ICMPv6 code.";
180         }
181         identity ipv6_nd_target {
182             base match-field;
183             description "Match for Target address for ND.";
184         }
185         identity ipv6_nd_sll {
186             base match-field;
187             description "Match for Source link-layer for ND.";
188         }
189         identity ipv6_nd_tll {
190             base match-field;
191             description "Match for Target link-layer for ND.";
192         }
193         identity mpls_label {
194             base match-field;
195             description "Match for MPLS label.";
196         }
197         identity mpls_tc {
198             base match-field;
199             description "Match for MPLS TC.";
200         }
201         identity mpls_bos {
202             base match-field;
203             description "Match for MPLS BoS bit.";
204         }
205         identity pbb_isid {
206             base match-field;
207             description "Match for PBB I-SID.";
208         }
209         identity tunnel_id {
210             base match-field;
211             description "Match for Logical Port Metadata";
212         }
213         identity ipv6_exthdr {
214             base match-field;
215             description "Match for IPv6 Extension Header pseudo-field";
216         }
217         */
218     // Abstract definitions of fields structure
219
220         grouping in-port {
221             description 
222                 "Ingress port. Numerical representation of incoming port, starting at 1. This may be a physical or switch-defined logical port.";
223             leaf port-number {
224                 type oft:port-number;
225             }
226         }
227         grouping in-phy-port {
228             description "Physical port. In ofp_packet_in messages, underlying physical port when packet received on a logical port.";
229             leaf port-number {
230                 type oft:port-number;
231             }
232         }
233         grouping metadata {
234             description "Metadata passed between tables.";
235             leaf value {
236                 type oft:metadata;
237             }
238             leaf mask {
239                 type oft:metadata;
240             }
241         }
242         grouping eth-dst {
243             description "Ethernet destination address.";
244             leaf address {
245                 type yang:mac-address;
246             }
247         }
248         grouping eth-src {
249             description "Ethernet source address.";
250             leaf address {
251                 type yang:mac-address;
252             }
253             leaf mask {
254                 type binary;
255             }
256         }
257         grouping eth-type {
258             description "Ethernet frame type.";
259             leaf type {
260                 type oft:ether-type; // Needs to define that as general model
261             }
262             leaf mask {
263                 type binary;
264             }
265         }
266         grouping vlan-vid {
267             description "VLAN id.";
268             leaf vlan-id {
269                 type uint16; // TODO: Define proper vlan id type.
270             }
271             leaf mask {
272                 type binary;
273             }
274         }
275         grouping vlan-pcp {
276             description "VLAN priority.";
277             leaf vlan-pcp {
278                 type uint8; // TODO: Define PCP type
279             }
280         }
281         grouping ip-dscp {
282             description "IP DSCP (6 bits in ToS field).";
283
284             leaf dscp {
285                 type inet:dscp; // TODO: Define DSCP type
286             }
287         }
288         grouping ip-ecn {
289             description "IP ECN (2 bits in ToS field).";
290             leaf ecn {
291                 type uint8; // TODO define ECN
292             }
293         }
294         grouping ip-proto {
295             description "IP protocol.";
296             leaf protocol-number {
297                 type uint8; // TODO define IP protocol number
298             }
299         }
300         grouping ipv4-src {
301             description "IPv4 source address.";
302             leaf prefix {
303                 type inet:ipv4-prefix;
304             }
305         }
306         grouping ipv4-dst {
307             description "IPv4 destination address.";
308             leaf prefix {
309                 type inet:ipv4-prefix;
310             }
311         }
312         grouping tcp-src {
313             description "TCP source port.";
314             leaf port {
315                 type inet:port-number;
316             }
317         }
318         grouping tcp-dst {
319             description "TCP destination port.";
320                     leaf port {
321                 type inet:port-number;
322             }
323         }
324         grouping udp-src {
325             description "UDP source port.";
326             leaf port {
327                 type inet:port-number;
328             }
329         }
330         grouping udp-dst {
331             description "UDP destination port.";
332             leaf port {
333                 type inet:port-number;
334             }
335         }
336         grouping sctp-src {
337             description "SCTP source port.";
338             leaf port {
339                 type inet:port-number;
340             }
341         }
342         grouping sctp-dst {
343             description "SCTP destination port.";
344             leaf port {
345                 type inet:port-number;
346             }
347         }
348         grouping icmpv4-type {
349             description "ICMP type.";
350             leaf type {
351                 type uint8; // Define ICMP Type
352             }
353         }
354         grouping icmpv4-code {
355             description "ICMP code.";
356             leaf code {
357                 type uint8; // Define ICMP Code
358             }
359         }
360         grouping arp-op {
361             description "ARP opcode.";
362             leaf op-code {
363                 type uint16;
364             }
365         }
366         grouping arp-spa {
367             description "ARP source IPv4 address.";
368             leaf prefix {
369                 type inet:ipv4-prefix;
370             }
371         }
372         grouping arp-tpa {
373             description "ARP target IPv4 address.";
374             leaf prefix {
375                 type inet:ipv4-prefix;
376             }
377         }
378         grouping arp-sha {
379             description "ARP source hardware address.";
380             leaf address {
381                 type yang:mac-address;
382             }
383             leaf mask {
384                 type binary;
385             }
386         }
387         grouping arp-tha {
388             description "ARP target hardware address.";
389             leaf address {
390                 type yang:mac-address;
391             }
392             leaf mask {
393                 type binary;
394             }
395         }
396         grouping ipv6-src {
397             description "IPv6 source address.";
398             leaf prefix {
399                 type inet:ipv6-prefix;
400             }
401         }
402         grouping ipv6-dst {
403             description "IPv6 destination address.";
404             leaf prefix {
405                 type inet:ipv6-prefix;
406             }
407         }
408         grouping ipv6-flabel {
409             description "IPv6 Flow Label";
410             leaf label {
411                 type inet:ipv6-flow-label;
412             }
413         }
414         grouping icmpv6-type {
415             description "ICMPv6 type.";
416             leaf type {
417                 type uint8;
418             }
419         }
420         grouping icmpv6-code {
421             description "ICMPv6 code.";
422             leaf code {
423                 type uint8;
424             }
425         }
426         grouping ipv6-nd-target {
427             description "Target address for ND.";
428             leaf address {
429                 type inet:ipv6-address;
430             }
431         }
432         grouping ipv6-nd-sll {
433             description "Source link-layer for ND.";
434             leaf address {
435                 type yang:mac-address;
436             }
437         }
438         grouping ipv6-nd-tll {
439             description "Target link-layer for ND.";
440             leaf address {
441                 type yang:mac-address;
442             }
443         }
444         grouping mpls-label {
445             description "MPLS label.";
446             leaf label {
447                 type uint32; // TODO define type
448             }
449         }
450         grouping mpls-tc {
451             description "MPLS TC.";
452             leaf tc {
453                 type uint8;
454             }
455         }
456         grouping mpls-bos {
457             description "MPLS BoS bit.";
458             leaf bos {
459                 type boolean;
460             }
461         }
462         grouping pbb-isid {
463             description "PBB I-SID.";
464             leaf isid {
465                 type uint32;
466             }
467             leaf mask {
468                 type binary;
469             }
470         }
471         grouping tunnel-id {
472             description "Logical Port Metadata.";
473             leaf value {
474                 type oft:metadata; 
475             }
476             leaf mask {
477                 type oft:metadata;
478             }
479         }
480         grouping ipv6-exthdr {
481             description "IPv6 Extension Header pseudo-field";
482             leaf pseudo-field {
483                 type bits {
484                     bit nonext {
485                         description "<No next header> encountered.";
486                         position 0;
487                     }
488                     bit esp {
489                         description "Encrypted Sec Payload header present.";
490                         position 1;
491                     }
492                     bit auth {
493                         description "Authentication header present.";
494                         position 2;
495                     }
496                     bit dest {
497                         description "1 or 2 dest headers present.";
498                         position 3;
499                     }
500                     bit frag {
501                         description "Fragment header present.";
502                         position 4;
503                     }
504                     bit router {
505                         description "Router header present.";
506                         position 5;
507                     }
508                     bit hop {
509                         description "Hop-by-hop header present.";
510                         position 6;
511                     }
512                     bit unrep {
513                         description "Unexpected repeats encountered.";
514                         position 7;
515                     }
516                     bit unseq {
517                         description "Unexpected sequencing encountered.";
518                         position 8;
519                         }                    
520                 }
521             }
522             leaf mask {
523                 type binary;
524             }
525         }
526
527     /* Basic Match Fields : 
528        - Maybe it will be better to split into several groupings
529          based on protocol types:
530              - L2 match
531              - L3 match
532                 - IPv4 match
533                 - IPv6 match
534              - L4 match
535              - ARP match
536              etc...
537         Maybe this works belongs to other module.
538     */
539
540         grouping basic-match-fields {
541             container in-port {
542                 presence "";
543                 uses in-port; 
544         
545             }
546             container in-phy-port {
547                 presence "";
548                 uses in-phy-port; 
549                 
550             }
551             container metadata {
552                 presence "";
553                 uses metadata; 
554                 
555             }
556             container eth-dst {
557                 presence "";
558                 uses eth-dst; 
559                 
560             }
561             container eth-src {
562                 presence "";
563                 uses eth-src; 
564                 
565             }
566             container eth-type {
567                 presence "";
568                 uses eth-type; 
569                 
570             }
571             container vlan-vid {
572                 presence "";
573                 uses vlan-vid; 
574                 
575             }
576             container vlan-pcp {
577                 presence "";
578                 uses vlan-pcp; 
579                 
580             }
581             container ip-dscp {
582                 presence "";
583                 uses ip-dscp; 
584                 
585             }
586             container ip-ecn {
587                 presence "";
588                 uses ip-ecn; 
589                 
590             }
591             container ip-proto {
592                 presence "";
593                 uses ip-proto; 
594                 
595             }
596             container ipv4-src {
597                 presence "";
598                 uses ipv4-src; 
599                 
600             }
601             container ipv4-dst {
602                 presence "";
603                 uses ipv4-dst; 
604                 
605             }
606             container tcp-src {
607                 presence "";
608                 uses tcp-src; 
609                 
610             }
611             container tcp-dst {
612                 presence "";
613                 uses tcp-dst; 
614                 
615             }
616             container udp-src {
617                 presence "";
618                 uses udp-src; 
619                 
620             }
621             container udp-dst {
622                 presence "";
623                 uses udp-dst; 
624                 
625             }
626             container sctp-src {
627                 presence "";
628                 uses sctp-src; 
629                 
630             }
631             container sctp-dst {
632                 presence "";
633                 uses sctp-dst; 
634                 
635             }
636             container icmpv4-type {
637                 presence "";
638                 uses icmpv4-type; 
639                 
640             }
641             container icmpv4-code {
642                 presence "";
643                 uses icmpv4-code; 
644                 
645             }
646             container arp-op {
647                 presence "";
648                 uses arp-op; 
649                 
650             }
651             container arp-spa {
652                 presence "";
653                 uses arp-spa; 
654                 
655             }
656             container arp-tpa {
657                 presence "";
658                 uses arp-tpa; 
659                 
660             }
661             container arp-sha {
662                 presence "";
663                 uses arp-sha; 
664                 
665             }
666             container arp-tha {
667                 presence "";
668                 uses arp-tha; 
669                 
670             }
671             container ipv6-src {
672                 presence "";
673                 uses ipv6-src; 
674                 
675             }
676             container ipv6-dst {
677                 presence "";
678                 uses ipv6-dst; 
679                 
680             }
681             container ipv6-flabel {
682                 presence "";
683                 uses ipv6-flabel; 
684                 
685             }
686             container icmpv6-type {
687                 presence "";
688                 uses icmpv6-type; 
689                 
690             }
691             container icmpv6-code {
692                 presence "";
693                 uses icmpv6-code; 
694                 
695             }
696             container ipv6-nd-target {
697                 presence "";
698                 uses ipv6-nd-target; 
699                 
700             }
701             container ipv6-nd-sll {
702                 presence "";
703                 uses ipv6-nd-sll; 
704                 
705             }
706             container ipv6-nd-tll {
707                 presence "";
708                 uses ipv6-nd-tll; 
709                 
710             }
711             container mpls-label {
712                 presence "";
713                 uses mpls-label; 
714                 
715             }
716             container mpls-tc {
717                 presence "";
718                 uses mpls-tc; 
719                 
720             }
721             container mpls-bos {
722                 presence "";
723                 uses mpls-bos; 
724                 
725             }
726             container pbb-isid {
727                 presence "";
728                 uses pbb-isid; 
729                 
730             }
731             container tunnel-id {
732                 presence "";
733                 uses tunnel-id; 
734                 
735             }
736             container ipv6-exthdr {
737                 presence "";
738                 uses ipv6-exthdr; 
739                 
740             }
741         }
742 }