-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathof10.packet
938 lines (816 loc) · 33.3 KB
/
of10.packet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
# Copyright (C) 2013-2014, The Beehive project authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Implemented based on openflow.h version 1.
# Author: Soheil Hassas Yeganeh <[email protected]>
include <of.packet>;
# OpenFlow port numbers. Physical ports start from 1.
enum Ports {
PP_MAX = 0xff00,
# Fake output "ports".
PP_IN_PORT = 0xfff8, # Send the packet out the input port. This
# virtual port must be explicitly used
# in order to send back out of the input
# port.
PP_TABLE = 0xfff9, # Perform actions in flow table.
# NB: This can only be the destination
# port for packet-out messages.
PP_NORMAL = 0xfffa, # Process with normal L2/L3 switching.
PP_FLOOD = 0xfffb, # All physical ports except input port and
# those disabled by STP.
PP_ALL = 0xfffc, # All physical ports except input port.
PP_CONTROLLER = 0xfffd, # Send to controller.
PP_LOCAL = 0xfffe, # Local openflow "port".
PP_NONE = 0xffff # Not associated with a physical port.
}
enum Type {
# Asynchronous messages.
PT_PACKET_IN = 10, # Async message
PT_FLOW_REMOVED = 11, # Async message
PT_PORT_STATUS = 12, # Async message
# Controller command messages.
PT_PACKET_OUT = 13, # Controller/switch message
PT_FLOW_MOD = 14, # Controller/switch message
PT_PORT_MOD = 15, # Controller/switch message
# Statistics messages.
PT_STATS_REQUEST = 16, # Controller/switch message
PT_STATS_REPLY = 17, # Controller/switch message
# Barrier messages.
PT_BARRIER_REQUEST = 18, # Controller/switch message
PT_BARRIER_REPLY = 19, # Controller/switch message
# Queue Configuration messages.
PT_QUEUE_GET_CONFIG_REQUEST = 20, # Controller/switch message
PT_QUEUE_GET_CONFIG_REPLY = 21 # Controller/switch message
}
@type_selector(version = of.Versions.OPENFLOW_1_0)
packet Header10(of.Header) {
}
@type_selector(version = of.Versions.OPENFLOW_1_0)
packet Hello(of.Hello) {
}
@type_selector(type = of.Type.PT_ECHO_REQUEST)
packet EchoRequest(Header10) {
}
@type_selector(type = of.Type.PT_ECHO_REPLY)
packet EchoReply(Header10) {
}
@type_selector(type = of.Type.PT_FEATURES_REQUEST)
packet FeaturesRequest(Header10) {
}
# Get switch configuration.
@type_selector(type = of.Type.PT_GET_CONFIG_REQUEST)
packet GetConfigRequest(Header10) {
}
enum ConfigFlags {
# Handling of IP fragments.
PC_FRAG_NORMAL = 0, # No special handling for fragments.
PC_FRAG_DROP = 1, # Drop fragments.
PC_FRAG_REASM = 2, # Reassemble (only if PC_IP_REASM set).
PC_FRAG_MASK = 3
}
# Config request reply.
@type_selector(type = of.Type.PT_GET_CONFIG_REPLY)
packet SwitchGetConfigReply(Header10) {
uint16 flags; # PC_* flags.
uint16 miss_send_len; # Max bytes of new flow that datapath should
# send to the controller.
}
# Set switch config.
@type_selector(type = of.Type.PT_SET_CONFIG)
packet SwitchSetConfig(Header10) {
uint16 flags; # PC_* flags.
uint16 miss_send_len; # Max bytes of new flow that datapath should
# send to the controller.
}
# Capabilities supported by the datapath.
enum Capabilities {
PC_FLOW_STATS = 1, # Flow statistics.
PC_TABLE_STATS = 2, # Table statistics.
PC_PORT_STATS = 4, # Port statistics.
PC_STP = 8, # 802.1d spanning tree.
PC_RESERVED = 16, # Reserved, must be zero.
PC_IP_REASM = 32, # Can reassemble IP fragments.
PC_QUEUE_STATS = 64, # Queue statistics.
PC_ARP_MATCH_IP = 128 # Match IP addresses in ARP pkts.
}
# Flags to indicate behavior of the physical port. These flags are
# used in OpenflowPhysicalPort to describe the current configuration. They are
# used in the ofp_port_mod message to configure the port's behavior.
enum PortConfig {
PPC_PORT_DOWN = 1, # Port is administratively down.
PPC_NO_STP = 2, # Disable 802.1D spanning tree on port.
PPC_NO_RECV = 4, # Drop all packets except 802.1D spanning
# tree packets.
PPC_NO_RECV_STP = 8, # Drop received 802.1D STP packets.
PPC_NO_FLOOD = 16, # Do not include this port when flooding.
PPC_NO_FWD = 32, # Drop packets forwarded to port.
PPC_NO_PACKET_IN = 64 # Do not send packet-in msgs for port.
}
# Current state of the physical port. These are not configurable from
# the controller.
enum PortState {
PPS_LINK_DOWN = 1, # No physical link present.
# The PPS_STP_* bits have no effect on switch operation. The
# controller must adjust PPC_NO_RECV, PPC_NO_FWD, and
# PPC_NO_PACKET_IN appropriately to fully implement an 802.1D spanning
# tree.
PPS_STP_LISTEN = 0, # Not learning or relaying frames.
PPS_STP_LEARN = 256, # Learning but not relaying frames.
PPS_STP_FORWARD = 512, # Learning and relaying frames.
PPS_STP_BLOCK = 768, # Not part of spanning tree.
PPS_STP_MASK = 768 # Bit mask for PPS_STP_* values.
}
# Features of physical ports available in a datapath.
enum PortFeatures {
PPF_10MB_HD = 0, # 10 Mb half-duplex rate support.
PPF_10MB_FD = 2, # 10 Mb full-duplex rate support.
PPF_100MB_HD = 4, # 100 Mb half-duplex rate support.
PPF_100MB_FD = 8, # 100 Mb full-duplex rate support.
PPF_1GB_HD = 16, # 1 Gb half-duplex rate support.
PPF_1GB_FD = 32, # 1 Gb full-duplex rate support.
PPF_10GB_FD = 64, # 10 Gb full-duplex rate support.
PPF_COPPER = 128, # Copper medium.
PPF_FIBER = 256, # Fiber medium.
PPF_AUTONEG = 512, # Auto-negotiation.
PPF_PAUSE = 1024, # Pause.
PPF_PAUSE_ASYM = 2048 # Asymmetric pause.
}
# Represents a switch port.
@bigendian
packet PhysicalPort {
uint16 port_no;
@repeated(count = 6) uint8 hw_addr;
@repeated(count = 16) char name;
uint32 config; # Bitmap of OpenflowPortConfig
uint32 state; # Bitmap of OpenflowPortState
# All the followings are bitmaps of OpenflowPortFeatures.
uint32 curr;
uint32 advertised;
uint32 supported;
uint32 peer;
}
@type_selector(type = of.Type.PT_FEATURES_REPLY)
packet FeaturesReply(Header10) {
uint64 datapath_id;
uint32 n_buffers;
uint8 n_tables;
@repeated(count = 3) uint8 pad;
# Features.
uint32 capabilities;
uint32 actions;
# Port info.
@repeated PhysicalPort ports;
}
# What changed about the physical port.
enum PortReason {
PPR_ADD = 0, # The port was added.
PPR_DELETE = 1, # The port was removed.
PPR_MODIFY = 2 # Some attribute of the port has changed.
}
@type_selector(type = Type.PT_PORT_STATUS)
packet PortStatus(Header10) {
uint8 reason; # Set from OpenflowPortReason.
@repeated(count = 7) uint8 pad;
PhysicalPort desc;
}
# Modify behavior of the physical port.
@type_selector(type = Type.PT_PORT_MOD)
packet PortMod(Header10) {
uint16 port_no;
@repeated(count = 6) uint8 hw_addr; # The hardware address is not
# configurable. This is used to
# sanity-check the request, so it must
# be the same as returned in an
# OpenflowPhysicalPort packet.
uint32 config; # Bitmap of.PPC_* flags.
uint32 mask; # Bitmap of.PPC_* flags to be changed.
uint32 advertise; # Bitmap of "OpenflowPortFeatures"s. Zero all
# bits to prevent any action taking place.
@repeated(count = 4) uint8 pad; # Pad to 64-bits.
}
# Why is this packet being sent to the controller?
enum PacketInReason {
PR_NO_MATCH = 0, # No matching flow.
PR_ACTION = 1 # Action explicitly output to controller.
}
# Packet received on port (datapath -> controller).
@type_selector(type = Type.PT_PACKET_IN)
packet PacketIn(Header10) {
uint32 buffer_id; # ID assigned by datapath.
uint16 total_len; # Full length of frame.
uint16 in_port; # Port on which frame was received.
uint8 reason; # Reason packet is being sent (one of.PR_*)
uint8 pad;
@repeated
uint8 data; # Ethernet frame, halfway through 32-bit word,
# so the IP header is 32-bit aligned. The
# amount of data is inferred from the length
# field in the header. Because of padding,
# offsetof(packet PacketIn, data) ==
# sizeof(packet PacketIn) - 2.
}
enum ActionType {
PAT_OUTPUT = 0, # Output to switch port.
PAT_SET_VLAN_VID = 1, # Set the 802.1q VLAN id.
PAT_SET_VLAN_PCP = 2, # Set the 802.1q priority.
PAT_STRIP_VLAN = 3, # Strip the 802.1q header.
PAT_SET_DL_SRC = 4, # Ethernet source address.
PAT_SET_DL_DST = 5, # Ethernet destination address.
PAT_SET_NW_SRC = 6, # IP source address.
PAT_SET_NW_DST = 7, # IP destination address.
PAT_SET_NW_TOS = 8, # IP ToS (DSCP field, 6 bits).
PAT_SET_TP_SRC = 9, # TCP/UDP source port.
PAT_SET_TP_DST = 10, # TCP/UDP destination port.
PAT_ENQUEUE = 11, # Output to queue.
PAT_VENDOR = 0xffff
}
# Action header that is common to all actions. The length includes the
# header and any padding used to make the action 64-bit aligned.
# NB: The length of an action *must* always be a multiple of eight.
@bigendian
packet Action {
uint16 type; # One of.PAT_*.
@size
uint16 len; # Length of action, including this
# header. This is the length of action,
# including any padding to make it
# 64-bit aligned.
}
# Action packeture for PAT_OUTPUT, which sends packets out 'port'.
# When the 'port' is the PP_CONTROLLER, 'max_len' indicates the max
# number of bytes to send. A 'max_len' of zero means no bytes of the
# packet should be sent.
@type_selector(type = ActionType.PAT_OUTPUT)
packet ActionOutput(Action) {
uint16 port; # Output port.
uint16 max_len; # Max length to send to controller.
}
# The VLAN id is 12 bits, so we can use the entire 16 bits to indicate
# special conditions. All ones is used to match that no VLAN id was
# set.
enum VlanIds {
P_VLAN_NONE = 0xffff
}
@type_selector(type = ActionType.PAT_SET_VLAN_VID)
packet ActionVlanVid(Action) {
uint16 vlan_vid; # VLAN id.
@repeated(count = 2)
uint8 pad;
}
@type_selector(type = ActionType.PAT_SET_VLAN_PCP)
packet ActionVlanPcp(Action) {
uint8 vlan_pcp; # VLAN priority.
@repeated(count = 3) uint8 pad;
}
@type_selector(type = ActionType.PAT_SET_DL_SRC)
packet ActionDlSrcAddr(Action) {
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_addr; # Ethernet address.
@repeated(count = 6)
uint8 pad;
}
@type_selector(type = ActionType.PAT_SET_DL_DST)
packet ActionDlDstAddr(Action) {
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_addr; # Ethernet address.
@repeated(count = 6)
uint8 pad;
}
@type_selector(type = ActionType.PAT_SET_NW_SRC)
packet ActionNwSrcAddr(Action) {
uint32 nw_addr; # IP address.
}
@type_selector(type = ActionType.PAT_SET_NW_DST)
packet ActionNwDstAddr(Action) {
uint32 nw_addr; # IP address.
}
@type_selector(type = ActionType.PAT_SET_TP_SRC)
packet ActionTpSrcPort(Action) {
uint16 tp_port; # TCP/UDP port.
@repeated(count = 2)
uint8 pad;
}
@type_selector(type = ActionType.PAT_SET_TP_DST)
packet ActionTpDstPort(Action) {
uint16 tp_port; # TCP/UDP port.
@repeated(count = 2)
uint8 pad;
}
# Action packeture for PAT_SET_NW_TOS.
@type_selector(type = ActionType.PAT_SET_NW_TOS)
packet ActionNwTos(Action) {
uint8 nw_tos; # IP ToS (DSCP field, 6 bits).
@repeated(count = 3)
uint8 pad;
}
# Action header for PAT_VENDOR. The rest of the body is vendor-defined.
@type_selector(type = ActionType.PAT_VENDOR)
packet ActionVendorHeader(Action) {
uint32 vendor; # Vendor ID, which takes the same form
# as in "packet VendorHeader".
}
# Send packet (controller -> datapath).
@type_selector(type = Type.PT_PACKET_OUT)
packet PacketOut(Header10) {
uint32 buffer_id; # ID assigned by datapath (-1 if none).
uint16 in_port; # Packet's input port (PP_NONE if none).
@size(actions)
uint16 actions_len; # Size of action array in bytes.
@repeated
Action actions;
@repeated uint8 data; # Packet data. The length is inferred
# from the length field in the header.
# (Only meaningful if buffer_id == -1.)
}
enum FlowModCommand {
PFC_ADD = 0, # New flow.
PFC_MODIFY = 1, # Modify all matching flows.
PFC_MODIFY_STRICT = 2, # Modify entry strictly matching wildcards
PFC_DELETE = 3, # Delete all matching flows.
PFC_DELETE_STRICT = 4 # Strictly match wildcards and priority.
}
# Flow wildcards.
enum FlowWildcards {
PFW_IN_PORT = 1 << 0, # Switch input port.
PFW_DL_VLAN = 1 << 1, # VLAN id.
PFW_DL_SRC = 1 << 2, # Ethernet source address.
PFW_DL_DST = 1 << 3, # Ethernet destination address.
PFW_DL_TYPE = 1 << 4, # Ethernet frame type.
PFW_NW_PROTO = 1 << 5, # IP protocol.
PFW_TP_SRC = 1 << 6, # TCP/UDP source port.
PFW_TP_DST = 1 << 7, # TCP/UDP destination port.
# IP source address wildcard bit count. 0 is exact match, 1 ignores the
# LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
# the entire field. This is the *opposite* of the usual convention where
# e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded.
PFW_NW_SRC_SHIFT = 8,
PFW_NW_SRC_BITS = 6,
PFW_NW_SRC_MASK = ((1 << FlowWildcards.PFW_NW_SRC_BITS) - 1) <<
FlowWildcards.PFW_NW_SRC_SHIFT,
PFW_NW_SRC_ALL = 32 << FlowWildcards.PFW_NW_SRC_SHIFT,
# IP destination address wildcard bit count. Same format as source.
PFW_NW_DST_SHIFT = 14,
PFW_NW_DST_BITS = 6,
PFW_NW_DST_MASK = ((1 << FlowWildcards.PFW_NW_DST_BITS) - 1) <<
FlowWildcards.PFW_NW_DST_SHIFT,
PFW_NW_DST_ALL = 32 << FlowWildcards.PFW_NW_DST_SHIFT,
PFW_DL_VLAN_PCP = 1 << 20, # VLAN priority.
PFW_NW_TOS = 1 << 21, # IP ToS (DSCP field, 6 bits).
# Wildcard all fields.
PFW_ALL = ((1 << 22) - 1)
}
# The wildcards for ICMP type and code fields use the transport source
# and destination port fields, respectively.
#define PFW_ICMP_TYPE PFW_TP_SRC
#define PFW_ICMP_CODE PFW_TP_DST
# Values below this cutoff are 802.3 packets and the two bytes
# following MAC addresses are used as a frame length. Otherwise, the
# two bytes are used as the Ethernet type.
#define P_DL_TYPE_ETH2_CUTF 0x0600
# Value of dl_type to indicate that the frame does not include an
# Ethernet type.
#define P_DL_TYPE_NOT_ETH_TYPE 0x05ff
# The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
# special conditions. All ones indicates that no VLAN id was set.
#define P_VLAN_NONE 0xffff
# Fields to match against flows
@bigendian
packet Match {
uint32 wildcards; # Wildcard fields.
uint16 in_port; # Input switch port.
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_src; # Ethernet source address.
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_dst; # Ethernet destination address.
uint16 dl_vlan; # Input VLAN id.
uint8 dl_vlan_pcp; # Input VLAN priority.
@repeated(count = 1)
uint8 pad1; # Align to 64-bits
uint16 dl_type; # Ethernet frame type.
uint8 nw_tos; # IP ToS (actually DSCP field, 6 bits).
uint8 nw_proto; # IP protocol or lower 8 bits of
# ARP opcode.
@repeated(count = 2)
uint8 pad2; # Align to 64-bits
uint32 nw_src; # IP source address.
uint32 nw_dst; # IP destination address.
uint16 tp_src; # TCP/UDP source port.
uint16 tp_dst; # TCP/UDP destination port.
}
# The match fields for ICMP type and code use the transport source and
# destination port fields, respectively.
#define icmp_type tp_src
#define icmp_code tp_dst
# Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
# is permanent.
#define P_FLOW_PERMANENT 0
# By default, choose a priority in the middle.
#define P_DEFAULT_PRIORITY 0x8000
enum FlowModFlags {
PFF_SEND_FLOW_REM = 1 << 0, # Send flow removed message when flow
# expires or is deleted.
PFF_CHECK_OVERLAP = 1 << 1, # Check for overlapping entries first.
PFF_EMERG = 1 << 2 # Remark this is for emergency.
}
# Flow setup and teardown (controller -> datapath).
@type_selector(type = Type.PT_FLOW_MOD)
packet FlowMod(Header10) {
Match match; # Fields to match
uint64 cookie; # Opaque controller-issued identifier.
# Flow actions.
uint16 command; # One of.PFC_*.
uint16 idle_timeout; # Idle time before discarding (seconds).
uint16 hard_timeout; # Max time before discarding (seconds).
uint16 priority; # Priority level of flow entry.
uint32 buffer_id; # Buffered packet to apply to (or -1).
# Not meaningful for PFC_DELETE*.
uint16 out_port; # For PFC_DELETE* commands, require
# matching entries to include this as an
# output port. A value of.PP_NONE
# indicates no restriction.
uint16 flags; # One of.PFF_*.
@repeated
Action actions; # The action length is inferred
# from the length field in the
# header.
}
# Why was this flow removed?
enum FlowRemovedReason {
PRR_IDLE_TIMEOUT = 0, # Flow idle time exceeded idle_timeout.
PRR_HARD_TIMEOUT = 1, # Time exceeded hard_timeout.
PRR_DELETE = 2 # Evicted by a DELETE flow mod.
}
# Flow removed (datapath -> controller).
@type_selector(type = Type.PT_FLOW_REMOVED)
packet FlowRemoved(Header10) {
Match match; # Description of fields.
uint64 cookie; # Opaque controller-issued identifier.
uint16 priority; # Priority level of flow entry.
uint8 reason; # One of.PRR_*.
@repeated(count = 1)
uint8 pad; # Align to 32-bits.
uint32 duration_sec; # Time flow was alive in seconds.
uint32 duration_nsec; # Time flow was alive in nanoseconds beyond
# duration_sec.
uint16 idle_timeout; # Idle timeout from original flow mod.
@repeated(count = 2)
uint8 pad2; # Align to 64-bits.
uint64 packet_count;
uint64 byte_count;
}
# Values for 'type' in OpenflowErrorMessage. These values are immutable: they
# will not change in future versions of the protocol (although new values may
# be added).
enum ErrorType {
PET_HELLO_FAILED = 0, # Hello protocol failed.
PET_BAD_REQUEST = 1, # Request was not understood.
PET_BAD_ACTION = 2, # Error in action description.
PET_FLOW_MOD_FAILED = 3, # Problem modifying flow entry.
PET_PORT_MOD_FAILED = 4, # Port mod request failed.
PET_QUEUE_OP_FAILED = 5 # Queue operation failed.
}
# OpenflowErrorMsg 'code' values for PET_HELLO_FAILED. 'data' contains an
# ASCII text string that may give failure details.
enum HelloFailedCode {
PHFC_INCOMPATIBLE = 0, # No compatible version.
PHFC_EPERM = 1 # Permissions error.
}
# OpenflowErrorMsg 'code' values for PET_BAD_REQUEST. 'data' contains at least
# the first 64 bytes of the failed request.
enum BadRequestCode {
PBRC_BAD_VERSION = 0, # ofp_header.version not supported.
PBRC_BAD_TYPE = 1, # ofp_header.type not supported.
PBRC_BAD_STAT = 2, # OpenflowStatsRequest.type not supported.
PBRC_BAD_VENDOR = 3, # Vendor not supported (in OpenflowVendorHeader
# or OpenflowStatsRequest or OpenflowStatsReply).
PBRC_BAD_SUBTYPE = 4, # Vendor subtype not supported.
PBRC_EPERM = 5, # Permissions error.
PBRC_BAD_LEN = 6, # Wrong request length for type.
PBRC_BUFFER_EMPTY = 7, # Specified buffer has already been used.
PBRC_BUFFER_UNKNOWN = 8 # Specified buffer does not exist.
}
# OpenflowErrorMsg 'code' values for PET_BAD_ACTION. 'data' contains at least
# the first 64 bytes of the failed request.
enum BadActionCode {
PBAC_BAD_TYPE = 0, # Unknown action type.
PBAC_BAD_LEN = 1, # Length problem in actions.
PBAC_BAD_VENDOR = 2, # Unknown vendor id specified.
PBAC_BAD_VENDOR_TYPE = 3, # Unknown action type for vendor id.
PBAC_BAD_OUT_PORT = 4, # Problem validating output action.
PBAC_BAD_ARGUMENT = 5, # Bad action argument.
PBAC_EPERM = 6, # Permissions error.
PBAC_TOO_MANY = 7, # Can't handle this many actions.
PBAC_BAD_QUEUE = 8 # Problem validating output queue.
}
# OpenflowErrorMsg 'code' values for PET_FLOW_MOD_FAILED. 'data' contains
# at least the first 64 bytes of the failed request.
enum Flow_modFailedCode {
PFMFC_ALL_TABLES_FULL = 0, # Flow not added because of full tables.
PFMFC_OVERLAP = 1, # Attempted to add overlapping flow with
# CHECK_OVERLAP flag set.
PFMFC_EPERM = 2, # Permissions error.
PFMFC_BAD_EMERG_TIMEOUT = 3, # Flow not added because of non-zero idle/hard
# timeout.
PFMFC_BAD_COMMAND = 4, # Unknown command.
PFMFC_UNSUPPORTED = 5 # Unsupported action list - cannot process in
# the order specified.
}
# OpenflowErrorMsg 'code' values for PET_PORT_MOD_FAILED. 'data' contains
# at least the first 64 bytes of the failed request.
enum Port_modFailedCode {
PPMFC_BAD_PORT = 0, # Specified port does not exist.
PPMFC_BAD_HW_ADDR = 1 # Specified hardware address is wrong.
}
# ofp_error msg 'code' values for PET_QUEUE_OP_FAILED. 'data' contains
# at least the first 64 bytes of the failed request
enum QueueOpFailedCode {
PQC_BAD_PORT = 0, # Invalid port (or port does not exist).
PQC_BAD_QUEUE = 1, # Queue does not exist.
PQC_EPERM = 2 # Permissions error.
}
# PT_ERROR: Error message (datapath -> controller).
@type_selector(type = of.Type.PT_ERROR)
packet ErrorMsg(Header10) {
uint16 err_type;
uint16 code;
@repeated
uint8 data; # Variable-length data. Interpreted based
# on the type and code.
}
enum StatsTypes {
# Description of this OpenFlow switch.
# The request body is empty.
# The reply body is packet DescStats.
PST_DESC = 0,
# Individual flow statistics.
# The request body is packet FlowStatsRequest.
# The reply body is an array of packet FlowStats.
PST_FLOW = 1,
# Aggregate flow statistics.
# The request body is packet AggregateStatsRequest.
# The reply body is packet AggregateStatsReply.
PST_AGGREGATE = 2,
# Flow table statistics.
# The request body is empty.
# The reply body is an array of packet TableStats.
PST_TABLE = 3,
# Physical port statistics.
# The request body is packet PortStatsRequest.
# The reply body is an array of packet PortStats.
PST_PORT = 4,
# Queue statistics for a port
# The request body defines the port
# The reply body is an array of packet QueueStats
PST_QUEUE = 5,
# Vendor extension.
# The request and reply bodies begin with a 32-bit vendor ID, which takes
# the same form as in "packet VendorHeader". The request and reply
# bodies are otherwise vendor-defined.
PST_VENDOR = 0xffff
}
@type_selector(type = Type.PT_STATS_REQUEST)
packet StatsRequest(Header10) {
uint16 stats_type; # One of the PST_* constants.
uint16 flags; # PSF_REQ_* flags (none yet defined).
}
enum StatsReplyFlags {
PSF_REPLY_MORE = 1 << 0 # More replies to follow.
}
@type_selector(type = Type.PT_STATS_REPLY)
packet StatsReply(Header10) {
uint16 stats_type; # One of the PST_* constants.
uint16 flags; # PSF_REPLY_* flags.
}
enum DescStatsConstants {
SERIAL_NUM_LEN = 32,
DESC_STR_LEN = 256
}
#define DESC_STR_LEN 256
#define SERIAL_NUM_LEN 32
# Body of reply to PST_DESC request. Each entry is a NULL-terminated
# ASCII string.
@type_selector(stats_type = StatsTypes.PST_DESC)
packet DescStats(StatsReply) {
@repeated(count = DescStatsConstants.DESC_STR_LEN)
char mfr_desc; # Manufacturer description.
@repeated(count = DescStatsConstants.DESC_STR_LEN)
char hw_desc; # Hardware description.
@repeated(count = DescStatsConstants.DESC_STR_LEN)
char sw_desc; # Software description.
@repeated(count = DescStatsConstants.SERIAL_NUM_LEN)
char serial_num; # Serial number.
@repeated(count = DescStatsConstants.DESC_STR_LEN)
char dp_desc; # Human readable description of datapath.
}
# Body for OpenflowStatsRequest of type PST_FLOW.
@type_selector(stats_type = StatsTypes.PST_FLOW)
packet FlowStatsRequest(StatsRequest) {
Match match; # Fields to match.
uint8 table_id; # ID of table to read (from OpenflowTableStats),
# 0xff for all tables or 0xfe for emergency.
uint8 pad; # Align to 32 bits.
uint16 out_port; # Require matching entries to include this
# as an output port. A value of.PP_NONE
# indicates no restriction.
}
# The Openflow flow stats.
@bigendian
packet FlowStats {
@size
uint16 length; # Length of this entry.
uint8 table_id; # ID of table flow came from.
uint8 pad;
Match match; # Description of fields.
uint32 duration_sec; # Time flow has been alive in seconds.
uint32 duration_nsec; # Time flow has been alive in nanoseconds beyond
# duration_sec.
uint16 priority; # Priority of the entry. Only meaningful
# when this is not an exact-match entry.
uint16 idle_timeout; # Number of seconds idle before expiration.
uint16 hard_timeout; # Number of seconds before expiration.
@repeated(count = 6)
uint8 pad2; # Align to 64-bits.
uint64 cookie; # Opaque controller-issued identifier.
uint64 packet_count; # Number of packets in flow.
uint64 byte_count; # Number of bytes in flow.
@repeated
Action actions; # Actions.
}
# Body of reply to PST_FLOW request.
@type_selector(stats_type = StatsTypes.PST_FLOW)
packet FlowStatsReply(StatsReply) {
@repeated
FlowStats flow_stats;
}
# Body for OpenflowStatsRequest of type PST_AGGREGATE.
@type_selector(stats_type = StatsTypes.PST_AGGREGATE)
packet AggregateStatsRequest(StatsRequest) {
Match match; # Fields to match.
uint8 table_id; # ID of table to read (from OpenflowTableStats)
# 0xff for all tables or 0xfe for emergency.
uint8 pad; # Align to 32 bits.
uint16 out_port; # Require matching entries to include this
# as an output port. A value of.PP_NONE
# indicates no restriction.
}
# Body of reply to PST_AGGREGATE request.
@type_selector(stats_type = StatsTypes.PST_AGGREGATE)
packet AggregateStatsReply(StatsReply) {
uint64 packet_count; # Number of packets in flows.
uint64 byte_count; # Number of bytes in flows.
uint32 flow_count; # Number of flows.
@repeated(count = 4)
uint8 pad; # Align to 64 bits.
}
# Body of reply to PST_TABLE request.
@type_selector(stats_type = StatsTypes.PST_TABLE)
packet TableStats(StatsReply) {
uint8 table_id; # Identifier of table. Lower numbered tables
# are consulted first.
@repeated(count = 3)
uint8 pad; # Align to 32-bits.
@repeated(count = of.Constants.P_MAX_TABLE_NAME_LEN)
char name;
uint32 wildcards; # Bitmap of.PFW_* wildcards that are
# supported by the table.
uint32 max_entries; # Max number of entries supported.
uint32 active_count; # Number of active entries.
uint64 lookup_count; # Number of packets looked up in table.
uint64 matched_count; # Number of packets that hit table.
}
# Body for OpenflowStatsRequest of type PST_PORT.
@type_selector(stats_type = StatsTypes.PST_PORT)
packet PortStatsRequest(StatsRequest) {
uint16 port_no; # PST_PORT message must request statistics
# either for a single port (specified in
# port_no) or for all ports (if port_no ==
# PP_NONE).
@repeated(count = 6)
uint8 pad;
}
# Body of reply to PST_PORT request. If a counter is unsupported, set
# the field to all ones.
@type_selector(stats_type = StatsTypes.PST_PORT)
packet PortStats(StatsReply) {
uint16 port_no;
@repeated(count = 6)
uint8 pad; # Align to 64-bits.
uint64 rx_packets; # Number of received packets.
uint64 tx_packets; # Number of transmitted packets.
uint64 rx_bytes; # Number of received bytes.
uint64 tx_bytes; # Number of transmitted bytes.
uint64 rx_dropped; # Number of packets dropped by RX.
uint64 tx_dropped; # Number of packets dropped by TX.
uint64 rx_errors; # Number of receive errors. This is a super-set
# of more specific receive errors and should be
# greater than or equal to the sum of all
# rx_*_err values.
uint64 tx_errors; # Number of transmit errors. This is a super-set
# of more specific transmit errors and should be
# greater than or equal to the sum of all
# tx_*_err values (none currently defined.)
uint64 rx_frame_err; # Number of frame alignment errors.
uint64 rx_over_err; # Number of packets with RX overrun.
uint64 rx_crc_err; # Number of CRC errors.
uint64 collisions; # Number of collisions.
}
# Vendor extension.
@type_selector(type = of.Type.PT_VENDOR)
packet VendorHeader(Header10) {
uint32 vendor; # Vendor ID:
# - MSB 0: low-order bytes are IEEE OUI.
# - MSB != 0: defined by OpenFlow
# consortium.
# Vendor-defined arbitrary additional data.
}
# All ones is used to indicate all queues in a port (for stats retrieval).
#define PQ_ALL 0xffffffff
# Min rate > 1000 means not configured.
#define PQ_MIN_RATE_UNCFG 0xffff
enum QueueProperties {
PQT_NONE = 0, # No property defined for queue (default).
PQT_MIN_RATE = 1 # Minimum datarate guaranteed.
# Other types should be added here
# (i.e. max rate, precedence, etc).
}
# Common description for a queue.
@bigendian
packet QueuePropHeader {
uint16 property; # One of.PQT_.
@size
uint16 len; # Length of property, including this header.
@repeated(count = 4)
uint8 pad; # 64-bit alignemnt.
}
# Min-Rate queue property description.
@type_selector(property = QueueProperties.PQT_MIN_RATE)
packet QueuePropMinRate(QueuePropHeader) {
uint16 rate; # In 1/10 of a percent; >1000 -> disabled.
@repeated(count = 6)
uint8 pad; # 64-bit alignment
}
# Full description for a queue.
@bigendian
packet PacketQueue {
uint32 queue_id; # id for the specific queue.
@size
uint16 len; # Length in bytes of this queue desc.
@repeated(count = 2)
uint8 pad; # 64-bit alignment.
@repeated
QueuePropHeader properties; # List of properties.
}
# Query for port queue configuration.
@type_selector(type = Type.PT_QUEUE_GET_CONFIG_REPLY)
packet QueueGetConfigRequest(Header10) {
uint16 port; # Port to be queried. Should refer
# to a valid physical port (i.e. < PP_MAX)
@repeated
uint8 pad; # 32-bit alignment.
}
# Queue configuration for a given port.
@type_selector(type = Type.PT_QUEUE_GET_CONFIG_REPLY)
packet QueueGetConfigReply(Header10) {
uint16 port;
@repeated(count = 6)
uint8 pad;
@repeated
PacketQueue queues; # List of configured queues.
}
# PAT_ENQUEUE action packet: send packets to given queue on port.
@type_selector(type = ActionType.PAT_ENQUEUE)
packet ActionEnqueue(Action) {
uint16 port; # Port that queue belongs. Should
# refer to a valid physical port
# (i.e. < PP_MAX) or PP_IN_PORT.
@repeated(count = 6)
uint8 pad; # Pad for 64-bit alignment.
uint32 queue_id; # Where to enqueue the packets.
}
@type_selector(stats_type = StatsTypes.PST_QUEUE)
packet QueueStatsRequest(StatsRequest) {
uint16 port_no; # All ports if PT_ALL.
@repeated(count = 2)
uint8 pad; # Align to 32-bits.
uint32 queue_id; # All queues if PQ_ALL.
}
@type_selector(stats_type = StatsTypes.PST_QUEUE)
packet QueueStats(StatsReply) {
uint16 port_no;
@repeated(count = 2)
uint8 pad; # Align to 32-bits.
uint32 queue_id; # Queue i.d
uint64 tx_bytes; # Number of transmitted bytes.
uint64 tx_packets; # Number of transmitted packets.
uint64 tx_errors; # Number of packets dropped due to overrun.
}