Add RFC8519 models
[mdsal.git] / model / ietf / rfc8519-ietf-packet-fields / src / main / yang / ietf-packet-fields@2019-03-04.yang
1 module ietf-packet-fields {
2   yang-version 1.1;
3   namespace "urn:ietf:params:xml:ns:yang:ietf-packet-fields";
4   prefix packet-fields;
5
6   import ietf-inet-types {
7     prefix inet;
8     reference
9       "RFC 6991 - Common YANG Data Types.";
10   }
11
12   import ietf-yang-types {
13     prefix yang;
14     reference
15       "RFC 6991 - Common YANG Data Types.";
16   }
17
18   import ietf-ethertypes {
19     prefix eth;
20     reference
21       "RFC 8519 - YANG Data Model for Network Access Control
22                   Lists (ACLs).";
23   }
24
25   organization
26     "IETF NETMOD (Network Modeling) Working Group.";
27
28   contact
29     "WG Web:  <https://datatracker.ietf.org/wg/netmod/>
30      WG List: netmod@ietf.org
31
32      Editor: Mahesh Jethanandani
33              mjethanandani@gmail.com
34      Editor: Lisa Huang
35              huangyi_99@yahoo.com
36      Editor: Sonal Agarwal
37              sagarwal12@gmail.com
38      Editor: Dana Blair
39              dana@blairhome.com";
40
41
42   description
43     "This YANG module defines groupings that are used by
44      the ietf-access-control-list YANG module.  Their usage
45      is not limited to ietf-access-control-list and can be
46      used anywhere as applicable.
47
48      Copyright (c) 2019 IETF Trust and the persons identified as
49      the document authors.  All rights reserved.
50
51      Redistribution and use in source and binary forms, with or
52      without modification, is permitted pursuant to, and subject
53      to the license terms contained in, the Simplified BSD
54      License set forth in Section 4.c of the IETF Trust's Legal
55      Provisions Relating to IETF Documents
56      (http://trustee.ietf.org/license-info).
57
58      This version of this YANG module is part of RFC 8519; see
59      the RFC itself for full legal notices.";
60
61   revision 2019-03-04 {
62     description
63       "Initial version.";
64     reference
65       "RFC 8519: YANG Data Model for Network Access Control
66                  Lists (ACLs).";
67   }
68
69   /*
70    * Typedefs
71    */
72   typedef operator {
73     type enumeration {
74       enum lte {
75         description
76           "Less than or equal to.";
77       }
78       enum gte {
79         description
80           "Greater than or equal to.";
81       }
82       enum eq {
83         description
84           "Equal to.";
85       }
86       enum neq {
87         description
88           "Not equal to.";
89       }
90     }
91     description
92       "The source and destination port range definitions
93        can be further qualified using an operator.  An
94        operator is needed only if the lower-port is specified
95        and the upper-port is not specified.  The operator
96        therefore further qualifies the lower-port only.";
97   }
98
99   /*
100    * Groupings
101    */
102   grouping port-range-or-operator {
103     choice port-range-or-operator {
104       case range {
105         leaf lower-port {
106           type inet:port-number;
107           must '. <= ../upper-port' {
108             error-message
109               "The lower-port must be less than or equal to
110                the upper-port.";
111           }
112           mandatory true;
113           description
114             "Lower boundary for a port.";
115         }
116         leaf upper-port {
117           type inet:port-number;
118           mandatory true;
119           description
120             "Upper boundary for a port.";
121         }
122       }
123       case operator {
124         leaf operator {
125           type operator;
126           default "eq";
127           description
128             "Operator to be applied on the port below.";
129         }
130         leaf port {
131           type inet:port-number;
132           mandatory true;
133           description
134             "Port number along with the operator on which to
135              match.";
136         }
137       }
138       description
139         "Choice of specifying a port range or a single
140          port along with an operator.";
141     }
142     description
143       "Grouping for port definitions in the form of a
144        choice statement.";
145   }
146
147   grouping acl-ip-header-fields {
148     description
149       "IP header fields common to IPv4 and IPv6";
150     reference
151       "RFC 791: Internet Protocol.";
152
153     leaf dscp {
154       type inet:dscp;
155       description
156         "Differentiated Services Code Point.";
157       reference
158         "RFC 2474: Definition of the Differentiated Services
159                    Field (DS Field) in the IPv4 and IPv6
160                    Headers.";
161     }
162
163     leaf ecn {
164       type uint8 {
165         range "0..3";
166       }
167       description
168         "Explicit Congestion Notification.";
169       reference
170         "RFC 3168: The Addition of Explicit Congestion
171                    Notification (ECN) to IP.";
172     }
173
174     leaf length {
175       type uint16;
176       description
177         "In the IPv4 header field, this field is known as the Total
178          Length.  Total Length is the length of the datagram, measured
179          in octets, including internet header and data.
180
181          In the IPv6 header field, this field is known as the Payload
182          Length, which is the length of the IPv6 payload, i.e., the rest
183          of the packet following the IPv6 header, in octets.";
184       reference
185         "RFC 791: Internet Protocol
186          RFC 8200: Internet Protocol, Version 6 (IPv6) Specification.";
187     }
188     leaf ttl {
189       type uint8;
190       description
191         "This field indicates the maximum time the datagram is allowed
192          to remain in the internet system.  If this field contains the
193          value zero, then the datagram must be dropped.
194
195          In IPv6, this field is known as the Hop Limit.";
196       reference
197         "RFC 791: Internet Protocol
198          RFC 8200: Internet Protocol, Version 6 (IPv6) Specification.";
199     }
200     leaf protocol {
201       type uint8;
202       description
203         "Internet Protocol number.  Refers to the protocol of the
204          payload.  In IPv6, this field is known as 'next-header',
205          and if extension headers are present, the protocol is
206          present in the 'upper-layer' header.";
207       reference
208         "RFC 791: Internet Protocol
209          RFC 8200: Internet Protocol, Version 6 (IPv6) Specification.";
210     }
211   }
212
213   grouping acl-ipv4-header-fields {
214     description
215       "Fields in the IPv4 header.";
216     leaf ihl {
217       type uint8 {
218         range "5..60";
219       }
220       description
221         "In an IPv4 header field, the Internet Header Length (IHL) is
222          the length of the internet header in 32-bit words and
223          thus points to the beginning of the data.  Note that the
224          minimum value for a correct header is 5.";
225     }
226     leaf flags {
227       type bits {
228         bit reserved {
229           position 0;
230           description
231             "Reserved.  Must be zero.";
232         }
233         bit fragment {
234           position 1;
235           description
236             "Setting the value to 0 indicates may fragment, while
237              setting the value to 1 indicates do not fragment.";
238         }
239         bit more {
240           position 2;
241           description
242             "Setting the value to 0 indicates this is the last fragment,
243              and setting the value to 1 indicates more fragments are
244              coming.";
245         }
246       }
247       description
248         "Bit definitions for the Flags field in the IPv4 header.";
249     }
250     leaf offset {
251       type uint16 {
252         range "20..65535";
253       }
254       description
255         "The fragment offset is measured in units of 8 octets (64 bits).
256          The first fragment has offset zero.  The length is 13 bits";
257     }
258     leaf identification {
259       type uint16;
260       description
261         "An identifying value assigned by the sender to aid in
262          assembling the fragments of a datagram.";
263     }
264
265     choice destination-network {
266       case destination-ipv4-network {
267         leaf destination-ipv4-network {
268           type inet:ipv4-prefix;
269           description
270             "Destination IPv4 address prefix.";
271         }
272       }
273       description
274         "Choice of specifying a destination IPv4 address or
275          referring to a group of IPv4 destination addresses.";
276     }
277
278     choice source-network {
279       case source-ipv4-network {
280         leaf source-ipv4-network {
281           type inet:ipv4-prefix;
282           description
283             "Source IPv4 address prefix.";
284         }
285       }
286       description
287         "Choice of specifying a source IPv4 address or
288          referring to a group of IPv4 source addresses.";
289     }
290   }
291
292   grouping acl-ipv6-header-fields {
293     description
294       "Fields in the IPv6 header.";
295
296     choice destination-network {
297       case destination-ipv6-network {
298         leaf destination-ipv6-network {
299           type inet:ipv6-prefix;
300           description
301             "Destination IPv6 address prefix.";
302         }
303       }
304       description
305         "Choice of specifying a destination IPv6 address
306          or referring to a group of IPv6 destination
307          addresses.";
308     }
309
310     choice source-network {
311       case source-ipv6-network {
312         leaf source-ipv6-network {
313           type inet:ipv6-prefix;
314           description
315             "Source IPv6 address prefix.";
316         }
317       }
318       description
319         "Choice of specifying a source IPv6 address or
320          referring to a group of IPv6 source addresses.";
321     }
322
323     leaf flow-label {
324       type inet:ipv6-flow-label;
325       description
326         "IPv6 Flow label.";
327     }
328     reference
329       "RFC 4291: IP Version 6 Addressing Architecture
330        RFC 4007: IPv6 Scoped Address Architecture
331        RFC 5952: A Recommendation for IPv6 Address Text
332                  Representation.";
333   }
334
335   grouping acl-eth-header-fields {
336     description
337       "Fields in the Ethernet header.";
338     leaf destination-mac-address {
339       type yang:mac-address;
340       description
341         "Destination IEEE 802 Media Access Control (MAC)
342          address.";
343     }
344     leaf destination-mac-address-mask {
345       type yang:mac-address;
346       description
347         "Destination IEEE 802 MAC address mask.";
348     }
349     leaf source-mac-address {
350       type yang:mac-address;
351       description
352         "Source IEEE 802 MAC address.";
353     }
354     leaf source-mac-address-mask {
355       type yang:mac-address;
356       description
357         "Source IEEE 802 MAC address mask.";
358     }
359     leaf ethertype {
360       type eth:ethertype;
361       description
362         "The Ethernet Type (or Length) value represented
363          in the canonical order defined by IEEE 802.
364          The canonical representation uses lowercase
365          characters.";
366       reference
367         "IEEE 802-2014, Clause 9.2.";
368     }
369     reference
370       "IEEE 802: IEEE Standard for Local and Metropolitan
371        Area Networks: Overview and Architecture.";
372   }
373
374   grouping acl-tcp-header-fields {
375     description
376       "Collection of TCP header fields that can be used to
377        set up a match filter.";
378     leaf sequence-number {
379       type uint32;
380       description
381         "Sequence number that appears in the packet.";
382     }
383     leaf acknowledgement-number {
384       type uint32;
385       description
386         "The acknowledgement number that appears in the
387          packet.";
388     }
389     leaf data-offset {
390       type uint8 {
391         range "5..15";
392       }
393       description
394         "Specifies the size of the TCP header in 32-bit
395          words.  The minimum size header is 5 words and
396          the maximum is 15 words; thus, this gives a
397          minimum size of 20 bytes and a maximum of 60
398          bytes, allowing for up to 40 bytes of options
399          in the header.";
400     }
401     leaf reserved {
402       type uint8;
403       description
404         "Reserved for future use.";
405     }
406     leaf flags {
407       type bits {
408         bit cwr {
409           position 1;
410           description
411             "The Congestion Window Reduced (CWR) flag is set
412              by the sending host to indicate that it received
413              a TCP segment with the ECN-Echo (ECE) flag set
414              and had responded in the congestion control
415              mechanism.";
416           reference
417             "RFC 3168: The Addition of Explicit Congestion
418                        Notification (ECN) to IP.";
419         }
420         bit ece {
421           position 2;
422           description
423             "ECN-Echo has a dual role, depending on the value
424              of the SYN flag.  It indicates the following: if
425              the SYN flag is set (1), the TCP peer is ECN
426              capable, and if the SYN flag is clear (0), a packet
427              with the Congestion Experienced flag set (ECN=11)
428              in the IP header was received during normal
429              transmission (added to the header by RFC 3168).
430              This serves as an indication of network congestion
431              (or impending congestion) to the TCP sender.";
432           reference
433             "RFC 3168: The Addition of Explicit Congestion
434                        Notification (ECN) to IP.";
435         }
436         bit urg {
437           position 3;
438           description
439             "Indicates that the Urgent Pointer field is significant.";
440         }
441         bit ack {
442           position 4;
443           description
444             "Indicates that the Acknowledgement field is significant.
445              All packets after the initial SYN packet sent by the
446              client should have this flag set.";
447         }
448         bit psh {
449           position 5;
450           description
451             "Push function.  Asks to push the buffered data to the
452              receiving application.";
453         }
454         bit rst {
455           position 6;
456           description
457             "Reset the connection.";
458         }
459         bit syn {
460           position 7;
461           description
462             "Synchronize sequence numbers.  Only the first packet
463              sent from each end should have this flag set.  Some
464              other flags and fields change meaning based on this
465              flag, and some are only valid for when it is set,
466              and others when it is clear.";
467         }
468         bit fin {
469           position 8;
470           description
471             "Last package from the sender.";
472         }
473       }
474       description
475         "Also known as Control Bits.  Contains nine 1-bit flags.";
476       reference
477         "RFC 793: Transmission Control Protocol.";
478     }
479     leaf window-size {
480       type uint16;
481       units "bytes";
482       description
483         "The size of the receive window, which specifies
484          the number of window size units beyond the segment
485          identified by the sequence number in the Acknowledgement
486          field that the sender of this segment is currently
487          willing to receive.";
488     }
489     leaf urgent-pointer {
490       type uint16;
491       description
492         "This field is an offset from the sequence number
493          indicating the last urgent data byte.";
494     }
495     leaf options {
496       type binary {
497         length "1..40";
498       }
499       description
500         "The length of this field is determined by the
501          Data Offset field.  Options have up to three
502          fields: Option-Kind (1 byte), Option-Length
503          (1 byte), and Option-Data (variable).  The Option-Kind
504          field indicates the type of option and is the
505          only field that is not optional.  Depending on
506          what kind of option we are dealing with,
507          the next two fields may be set: the Option-Length
508          field indicates the total length of the option,
509          and the Option-Data field contains the value of
510          the option, if applicable.";
511     }
512   }
513
514   grouping acl-udp-header-fields {
515     description
516       "Collection of UDP header fields that can be used
517        to set up a match filter.";
518     leaf length {
519       type uint16;
520       description
521         "A field that specifies the length in bytes of
522          the UDP header and UDP data.  The minimum
523          length is 8 bytes because that is the length of
524          the header.  The field size sets a theoretical
525          limit of 65,535 bytes (8-byte header plus 65,527
526          bytes of data) for a UDP datagram.  However, the
527          actual limit for the data length, which is
528          imposed by the underlying IPv4 protocol, is
529          65,507 bytes (65,535 minus 8-byte UDP header
530          minus 20-byte IP header).
531
532          In IPv6 jumbograms, it is possible to have
533          UDP packets of a size greater than 65,535 bytes.
534          RFC 2675 specifies that the Length field is set
535          to zero if the length of the UDP header plus
536          UDP data is greater than 65,535.";
537     }
538   }
539
540   grouping acl-icmp-header-fields {
541     description
542       "Collection of ICMP header fields that can be
543        used to set up a match filter.";
544     leaf type {
545       type uint8;
546       description
547         "Also known as control messages.";
548       reference
549         "RFC 792: Internet Control Message Protocol
550          RFC 4443: Internet Control Message Protocol (ICMPv6)
551                    for Internet Protocol Version 6 (IPv6)
552                    Specification.";
553     }
554     leaf code {
555       type uint8;
556       description
557         "ICMP subtype.  Also known as control messages.";
558       reference
559         "RFC 792: Internet Control Message Protocol
560          RFC 4443: Internet Control Message Protocol (ICMPv6)
561                    for Internet Protocol Version 6 (IPv6)
562                    Specification.";
563     }
564     leaf rest-of-header {
565       type binary;
566       description
567         "Unbounded in length, the contents vary based on the
568          ICMP type and code.  Also referred to as 'Message Body'
569          in ICMPv6.";
570       reference
571         "RFC 792: Internet Control Message Protocol
572          RFC 4443: Internet Control Message Protocol (ICMPv6)
573                    for Internet Protocol Version 6 (IPv6)
574                    Specification.";
575     }
576   }
577 }