-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathof12.packet
1167 lines (1005 loc) · 37.7 KB
/
of12.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
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 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.2.
# Author: Soheil Hassas Yeganeh <[email protected]>
#
# TODO(soheil): When we add support for 1.1, 1.3, and 1.4, we need to refactor
# common, unchanged messages in openflow.packet. Note: After 1.1 most messages
# are backward compatible. So, maybe we need to create an openflow1.1+ packet
# definition.
include <of.packet>;
# OpenFlow port numbers. Physical ports start from 1.
enum Ports {
PP_MAX = 0xffffff00,
PP_IN_PORT = 0xfffffff8,
PP_TABLE = 0xfffffff9,
PP_NORMAL = 0xfffffffa,
PP_FLOOD = 0xfffffffb,
PP_ALL = 0xfffffffc,
PP_CONTROLLER = 0xfffffffd,
PP_LOCAL = 0xfffffffe,
PP_ANY = 0xffffffff
}
enum Groups {
PG_MAX = 0xffffff00,
PG_ALL = 0xfffffffc, # Represents all groups for group delete commands.
PG_ANY = 0xffffffff # Wildcard group used only for flow stats
# requests. Selects all flows regardless
# of group (including flows with no group).
}
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_GROUP_MOD = 15, # Controller/switch message.
PT_PORT_MOD = 16, # Controller/switch message.
PT_TABLE_MOD = 17, # Controller/switch message.
# Statistics messages.
PT_STATS_REQUEST = 18, # Controller/switch message.
PT_STATS_REPLY = 19, # Controller/switch message.
# Barrier messages.
PT_BARRIER_REQUEST = 20, # Controller/switch message.
PT_BARRIER_REPLY = 21, # Controller/switch message.
# Queue Configuration messages.
PT_QUEUE_GET_CONFIG_REQUEST = 22, # Controller/switch message.
PT_QUEUE_GET_CONFIG_REPLY = 23, # Controller/switch message.
# Controller role change request messages.
PT_ROLE_REQUEST = 24, # Controller/switch message.
PT_ROLE_REPLY = 25 # Controller/switch message.
}
@type_selector(version = of.Versions.OPENFLOW_1_2)
packet Header12(of.Header) {
}
@type_selector(version = of.Versions.OPENFLOW_1_2)
packet Hello(of.Hello) {
}
@type_selector(type = of.Type.PT_ECHO_REQUEST)
packet EchoRequest(Header12) {
}
@type_selector(type = of.Type.PT_ECHO_REPLY)
packet EchoReply(Header12) {
}
@type_selector(type = of.Type.PT_FEATURES_REQUEST)
packet FeaturesRequest(Header12) {
}
# Get switch configuration.
@type_selector(type = of.Type.PT_GET_CONFIG_REQUEST)
packet GetConfigRequest(Header12) {
}
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,
# TTL processing - applicable for IP and MPLS packets.
PC_INVALID_TTL_TO_CONTROLLER = 1 << 2
}
# Config request reply.
@type_selector(type = of.Type.PT_GET_CONFIG_REPLY)
packet SwitchGetConfigReply(Header12) {
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(Header12) {
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 OpenflowPort 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 << 0,
PPC_NO_RECV = 1 << 2,
PPC_NO_FWD = 1 << 5,
PPC_NO_PACKET_IN = 1 << 6
}
# Current state of the physical port. These are not configurable from
# the controller.
enum PortState {
PPS_LINK_DOWN = 1 << 0, # No physical link present.
PPS_BLOCKED = 1 << 1, # Port is blocked.
PPS_LIVE = 1 << 2 # Live for fast failover group.
}
# Features of physical ports available in a datapath.
enum PortFeatures {
PPF_10MB_HD = 1 << 0, # 10 Mb half-duplex rate support.
PPF_10MB_FD = 1 << 1, # 10 Mb full-duplex rate support.
PPF_100MB_HD = 1 << 2, # 100 Mb half-duplex rate support.
PPF_100MB_FD = 1 << 3, # 100 Mb full-duplex rate support.
PPF_1GB_HD = 1 << 4, # 1 Gb half-duplex rate support.
PPF_1GB_FD = 1 << 5, # 1 Gb full-duplex rate support.
PPF_10GB_FD = 1 << 6, # 10 Gb full-duplex rate support.
PPF_40GB_FD = 1 << 7, # 40 Gb full-duplex rate support.
PPF_100GB_FD = 1 << 8, # 100 Gb full-duplex rate support.
PPF_1TB_FD = 1 << 9, # 1 Tb full-duplex rate support.
PPF_OTHER = 1 << 10, # Other rate, not in the list.
PPF_COPPER = 1 << 11, # Copper medium.
PPF_FIBER = 1 << 12, # Fiber medium.
PPF_AUTONEG = 1 << 13, # Auto-negotiation.
PPF_PAUSE = 1 << 14, # Pause.
PPF_PAUSE_ASYM = 1 << 15 # Asymmetric pause.
}
# Represents a switch port.
@bigendian
packet Port {
uint32 port_no;
@repeated(count = 4) uint8 pad;
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 hw_addr;
@repeated(count = 2) uint8 pad2;
@repeated(count = of.Constants.P_MAX_PORT_NAME_LEN)
char name;
uint32 config;
uint32 state;
uint32 curr;
uint32 advertised;
uint32 supported;
uint32 peer;
uint32 curr_speed;
uint32 max_speed;
}
@type_selector(type = of.Type.PT_FEATURES_REPLY)
packet FeaturesReply(Header12) {
uint64 datapath_id;
uint32 n_buffers;
uint8 n_tables;
@repeated(count = 3) uint8 pad;
# Features.
uint32 capabilities;
uint32 actions;
# Port info.
@repeated Port 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(Header12) {
uint8 reason; # Set from OpenflowPortReason.
@repeated(count = 7) uint8 pad;
Port desc;
}
# Modify behavior of the physical port.
@type_selector(type = Type.PT_PORT_MOD)
packet PortMod(Header12) {
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
# OpenflowPort 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.
}
enum ActionType {
PAT_OUTPUT = 0,
PAT_COPY_TTL_OUT = 11,
PAT_COPY_TTL_IN = 12,
PAT_SET_MPLS_TTL = 15,
PAT_DEC_MPLS_TTL = 16,
PAT_PUSH_VLAN = 17,
PAT_POP_VLAN = 18,
PAT_PUSH_MPLS = 19,
PAT_POP_MPLS = 20,
PAT_SET_QUEUE = 21,
PAT_GROUP = 22,
PAT_SET_NW_TTL = 23,
PAT_DEC_NW_TTL = 24,
PAT_SET_FIELD = 25,
PAT_EXPERIMENTER = 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) {
uint32 port; # Output port.
uint16 max_len; # Max length to send to controller.
@repeated(count = 6) uint8 pad;
}
enum InstructionType {
PIT_GOTO_TABLE = 1,
PIT_WRITE_METADATA = 2,
PIT_WRITE_ACTIONS = 3,
PIT_APPLY_ACTIONS = 4,
PIT_CLEAR_ACTIONS = 5,
PIT_EXPERIMENTER = 0xFFFF
}
@bigendian
packet Instruction {
uint16 type;
@size uint16 len;
}
@type_selector(type = InstructionType.PIT_APPLY_ACTIONS)
packet ApplyActions(Instruction) {
@repeated(count = 4) uint8 pad;
@repeated Action actions;
}
enum Buffers {
P_NO_BUFFER=0xffffffff
}
# Send packet (controller -> datapath).
@type_selector(type = Type.PT_PACKET_OUT)
packet PacketOut(Header12) {
uint32 buffer_id; # ID assigned by datapath (-1 if none).
uint32 in_port; # Packet's input port (PP_NONE if none).
@size(actions)
uint16 actions_len; # Size of action array in bytes.
@repeated(count = 6) uint8 pad;
@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 - 1),
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)
}
enum OxmClass {
PXMC_NXM_0 = 0x0000,
PXMC_NXM_1 = 0x0001,
PXMC_OPENFLOW_BASIC = 0x8000,
PXMC_EXPERIMENTER = 0xFFFF
}
enum OXMatchFields {
PXMT_IN_PORT = 0, # Switch input port.
PXMT_IN_PHY_PORT = 1 << 1, # Switch physical input port.
PXMT_METADATA = 2 << 1, # Metadata passed between tables.
PXMT_ETH_DST = 3 << 1, # Ethernet destination address.
PXMT_ETH_DST_MASKED = (3 << 1) + 1,
PXMT_ETH_SRC = 4 << 1, # Ethernet source address.
PXMT_ETH_SRC_MASKED = (4 << 1) + 1,
PXMT_ETH_TYPE = 5 << 1, # Ethernet frame type.
PXMT_VLAN_VID = 6 << 1, # VLAN id.
PXMT_VLAN_PCP = 7 << 1, # VLAN priority.
PXMT_IP_DSCP = 8 << 1, # IP DSCP (6 bits in ToS field).
PXMT_IP_ECN = 9 << 1, # IP ECN (2 bits in ToS field).
PXMT_IP_PROTO = 10 << 1, # IP protocol.
PXMT_IPV4_SRC = 11 << 1, # IPv4 source address.
PXMT_IPV4_SRC_MASKED = (11 << 1) + 1,
PXMT_IPV4_DST = 12 << 1, # IPv4 destination address.
PXMT_IPV4_DST_MASKED = (12 << 1) + 1,
PXMT_TCP_SRC = 13 << 1, # TCP source port.
PXMT_TCP_DST = 14 << 1, # TCP destination port.
PXMT_UDP_SRC = 15 << 1, # UDP source port.
PXMT_UDP_DST = 16 << 1, # UDP destination port.
PXMT_SCTP_SRC = 17 << 1, # SCTP source port.
PXMT_SCTP_DST = 18 << 1, # SCTP destination port.
PXMT_ICMPV4_TYPE = 19 << 1, # ICMP type.
PXMT_ICMPV4_CODE = 20 << 1, # ICMP code.
PXMT_ARP_OP = 21 << 1, # ARP opcode.
PXMT_ARP_SPA = 22 << 1, # ARP source IPv4 address.
PXMT_ARP_TPA = 23 << 1, # ARP target IPv4 address.
PXMT_ARP_SHA = 24 << 1, # ARP source hardware address.
PXMT_ARP_THA = 25 << 1, # ARP target hardware address.
PXMT_IPV6_SRC = 26 << 1, # IPv6 source address.
PXMT_IPV6_SRC_MASKED = (26 << 1) + 1,
PXMT_IPV6_DST = 27 << 1, # IPv6 destination address.
PXMT_IPV6_DST_MASKED = (27 << 1) + 1,
PXMT_IPV6_FLABEL = 28 << 1, # IPv6 Flow Label
PXMT_ICMPV6_TYPE = 29 << 1, # ICMPv6 type.
PXMT_ICMPV6_CODE = 30 << 1, # ICMPv6 code.
PXMT_IPV6_ND_TARGET = 31 << 1, # Target address for ND.
PXMT_IPV6_ND_SLL = 32 << 1, # Source link-layer for ND.
PXMT_IPV6_ND_TLL = 33 << 1, # Target link-layer for ND.
PXMT_MPLS_LABEL = 34 << 1, # MPLS label.
PXMT_MPLS_TC = 35 << 1 # MPLS TC.
}
@bigendian
@padded(constant = 4, excluded = 1)
packet OxmField {
uint16 oxm_class;
uint8 oxm_field;
@size
uint8 oxm_length;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IN_PORT,
oxm_length = 4)
packet OxmInPort(OxmField) {
uint32 in_port;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_ETH_DST,
oxm_length = 6)
packet OxmEthDst(OxmField) {
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 mac_addr;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_ETH_DST_MASKED,
oxm_length = 12)
packet OxmEthDstMasked(OxmField) {
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 mac_addr;
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_ETH_SRC,
oxm_length = 6)
packet OxmEthSrc(OxmField) {
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 mac_addr;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_ETH_SRC_MASKED,
oxm_length = 12)
packet OxmEthSrcMasked(OxmField) {
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 mac_addr;
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_ETH_TYPE,
oxm_length = 2)
packet OxmEthType(OxmField) {
uint16 type;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IP_PROTO,
oxm_length = 1)
packet OxmIpProto(OxmField) {
uint8 proto;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV4_SRC,
oxm_length = 4)
packet OxmIpV4Src(OxmField) {
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 addr;
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV4_SRC_MASKED,
oxm_length = 8)
packet OxmIpV4SrcMasked(OxmField) {
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 addr;
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV4_DST,
oxm_length = 4)
packet OxmIpV4Dst(OxmField) {
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 addr;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV4_DST_MASKED,
oxm_length = 8)
packet OxmIpV4DstMasked(OxmField) {
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 addr;
@repeated(count = of.Constants.P_IPV4_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV6_SRC,
oxm_length = 16)
packet OxmIpV6Src(OxmField) {
@repeated(count = of.Constants.P_IPV6_ALEN)
uint8 addr;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV6_SRC_MASKED,
oxm_length = 32)
packet OxmIpV6SrcMasked(OxmField) {
@repeated(count = of.Constants.P_IPV6_ALEN)
uint8 addr;
@repeated(count = of.Constants.P_IPV6_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV6_DST,
oxm_length = 16)
packet OxmIpV6Dst(OxmField) {
@repeated(count = of.Constants.P_IPV6_ALEN)
uint8 addr;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_IPV6_DST_MASKED,
oxm_length = 32)
packet OxmIpV6DstMasked(OxmField) {
@repeated(count = of.Constants.P_IPV6_ALEN)
uint8 addr;
@repeated(count = of.Constants.P_IPV6_ALEN)
uint8 mask;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_TCP_SRC,
oxm_length = 2)
packet OxmTcpSrc(OxmField) {
uint16 port;
}
@type_selector(oxm_class = OxmClass.PXMC_OPENFLOW_BASIC,
oxm_field = OXMatchFields.PXMT_TCP_DST,
oxm_length = 2)
packet OxmTcpDst(OxmField) {
uint16 port;
}
# Valid MatchType.
enum MatchType {
PMT_STANDARD = 0, # Deprecated.
PMT_OXM = 1 # OpenFlow Extensible Match.
}
# Fields to match against flows
@bigendian
@padded(multiple = 8, excluded = 1)
packet Match {
uint16 type;
@size uint16 length;
}
@type_selector(type = MatchType.PMT_STANDARD)
packet StdMatch(Match) {
uint32 in_port; # Input switch port.
uint32 wildcards; # Wildcard fields.
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_src; # Ethernet source address.
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_src_mask; # Ethernet source address mask.
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_dst; # Ethernet destination address.
@repeated(count = of.Constants.P_ETH_ALEN)
uint8 dl_dst_mask; # Ethernet destination address mask.
uint16 dl_vlan; # Input VLAN id.
uint8 dl_vlan_pcp; # Input VLAN priority.
uint8 pad1; # Align to 32-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.
uint32 nw_src; # IP source address.
uint32 nw_src_mask; # IP source address mask.
uint32 nw_dst; # IP destination address.
uint32 nw_dst_mask; # IP destination address mask.
uint16 tp_src; # TCP/UDP/SCTP source port.
uint16 tp_dst; # TCP/UDP/SCTP destination port.
uint32 mpls_label; # MPLS label.
uint8 mpls_tc; # MPLS TC.
@repeated(count = 3)
uint8 pad2; # Align to 64-bits
uint64 metadata; # Metadata passed between tables.
uint64 metadata_mask; # Mask for metadata.
}
@type_selector(type = MatchType.PMT_OXM)
packet OXMatch(Match) {
@repeated OxmField fields;
}
# 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(Header12) {
uint32 buffer_id; # ID assigned by datapath.
uint16 total_len; # Full length of frame.
uint8 reason; # Reason packet is being sent (one of.PR_*).
uint8 table_id; # ID of the table that was looked up.
Match match; # Packet metadata. Variable Size.
@repeated(count=2)
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 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(Header12) {
uint64 cookie;
uint64 cookie_mask;
uint8 table_id;
uint8 command;
uint16 idle_timeout;
uint16 hard_timeout;
uint16 priority;
uint32 buffer_id;
uint32 out_port;
uint32 out_group;
uint16 flags;
@repeated(count = 2) uint8 pad;
Match match;
@repeated
Instruction instructions;
}
# 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(Header12) {
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(Header12) {
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,
# Group counter statistics.
# The request body is empty.
# The reply is struct ofp_group_stats.
OFPST_GROUP = 6,
# Group description statistics.
# The request body is empty.
# The reply body is struct ofp_group_desc_stats.
OFPST_GROUP_DESC = 7,
# 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_EXPERIMENTER = 0xffff
}
@type_selector(type = Type.PT_STATS_REQUEST)
packet StatsRequest(Header12) {
uint16 stats_type; # One of the PST_* constants.
uint16 flags; # PSF_REQ_* flags (none yet defined).
@repeated(count = 4)
uint8 pad;
}
enum StatsReplyFlags {
PSF_REPLY_MORE = 1 << 0 # More replies to follow.
}
@type_selector(type = Type.PT_STATS_REPLY)
packet StatsReply(Header12) {
uint16 stats_type; # One of the PST_* constants.
uint16 flags; # PSF_REPLY_* flags.
@repeated(count = 4)
uint8 pad;
}
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) {
uint8 table_id; # ID of table to read (from OpenflowTableStats),
# 0xff for all tables or 0xfe for emergency.
@repeated(count = 3)
uint8 pad1; # Align to 32 bits.
uint32 out_port; # Require matching entries to include this
# as an output port. A value of PP_NONE.
# indicates no restriction.
uint32 out_group; # Require matching entries to include this
# as an output group. A value of PG_ANY
# indicates no restriction.
@repeated(count = 4)
uint8 pad2;
uint64 cookie;
uint64 cookie_mask;
Match match; # Fields to match.
}
# 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;
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.
Match match; # Description of fields.
@repeated
Instruction instructions; # Instruction set.
}
# 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