blob: 7310988a68c0c5beb47726d4b60cc114d7f4f151 [file] [log] [blame]
Rich Lanea06d0c32013-03-25 08:52:03 -07001:: # Copyright 2013, Big Switch Networks, Inc.
2:: #
3:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
4:: # the following special exception:
5:: #
6:: # LOXI Exception
7:: #
8:: # As a special exception to the terms of the EPL, you may distribute libraries
9:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
10:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
11:: # from the LoxiGen Libraries and the notice provided below is (i) included in
12:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
13:: # documentation for the LoxiGen Libraries, if distributed in binary form.
14:: #
15:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
16:: #
17:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
18:: # a copy of the EPL at:
19:: #
20:: # http://www.eclipse.org/legal/epl-v10.html
21:: #
22:: # Unless required by applicable law or agreed to in writing, software
23:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
25:: # EPL for the specific language governing permissions and limitations
26:: # under the EPL.
27::
Rich Laned983aa52013-06-13 11:48:37 -070028:: include('_copyright.c')
Rich Lanea06d0c32013-03-25 08:52:03 -070029
30/****************************************************************
31 *
32 * Functions related to mapping wire values to object types
33 * and lengths
34 *
35 ****************************************************************/
36
37#include <loci/loci.h>
38#include <loci/of_message.h>
39
Rich Laneef7b9942013-11-18 16:29:28 -080040#define OF_INSTRUCTION_EXPERIMENTER_ID_OFFSET 4
41#define OF_INSTRUCTION_EXPERIMENTER_SUBTYPE_OFFSET 8
42
Rich Lanec0e20ff2013-12-15 23:40:31 -080043${legacy_code}
44
Rich Lanea06d0c32013-03-25 08:52:03 -070045/****************************************************************
46 * Top level OpenFlow message length functions
47 ****************************************************************/
48
49/**
50 * Get the length of a message object as reported on the wire
51 * @param obj The object to check
52 * @param bytes (out) Where the length is stored
53 * @returns OF_ERROR_ code
54 */
55void
56of_object_message_wire_length_get(of_object_t *obj, int *bytes)
57{
Rich Laneed79e0d2013-03-26 14:30:31 -070058 ASSERT(OF_OBJECT_TO_WBUF(obj) != NULL);
Rich Lanea06d0c32013-03-25 08:52:03 -070059 // ASSERT(obj is message)
60 *bytes = of_message_length_get(OF_OBJECT_TO_MESSAGE(obj));
61}
62
63/**
64 * Set the length of a message object as reported on the wire
65 * @param obj The object to check
66 * @param bytes The new length of the object
67 * @returns OF_ERROR_ code
68 */
69void
70of_object_message_wire_length_set(of_object_t *obj, int bytes)
71{
Rich Laneed79e0d2013-03-26 14:30:31 -070072 ASSERT(OF_OBJECT_TO_WBUF(obj) != NULL);
Rich Lanea06d0c32013-03-25 08:52:03 -070073 // ASSERT(obj is message)
74 of_message_length_set(OF_OBJECT_TO_MESSAGE(obj), bytes);
75}
76
77/****************************************************************
78 * TLV16 type/length functions
79 ****************************************************************/
80
81/**
82 * Many objects are TLVs and use uint16 for the type and length values
83 * stored on the wire at the beginning of the buffer.
84 */
85#define TLV16_WIRE_TYPE_OFFSET 0
86#define TLV16_WIRE_LENGTH_OFFSET 2
87
88/**
89 * Get the length field from the wire for a standard TLV
90 * object that uses uint16 for both type and length.
91 * @param obj The object being referenced
92 * @param bytes (out) Where to store the length
93 */
94
95void
96of_tlv16_wire_length_get(of_object_t *obj, int *bytes)
97{
98 uint16_t val16;
99 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
100 ASSERT(wbuf != NULL);
101
102 of_wire_buffer_u16_get(wbuf,
103 OF_OBJECT_ABSOLUTE_OFFSET(obj, TLV16_WIRE_LENGTH_OFFSET), &val16);
104 *bytes = val16;
105}
106
107/**
108 * Set the length field in the wire buffer for a standard TLV
109 * object that uses uint16 for both type and length.
110 * @param obj The object being referenced
111 * @param bytes The length value to use
112 */
113
114void
115of_tlv16_wire_length_set(of_object_t *obj, int bytes)
116{
117 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
118 ASSERT(wbuf != NULL);
119
120 of_wire_buffer_u16_set(wbuf,
121 OF_OBJECT_ABSOLUTE_OFFSET(obj, TLV16_WIRE_LENGTH_OFFSET), bytes);
122}
123
124/**
125 * Get the type field from the wire for a standard TLV object that uses
126 * uint16 for both type and length.
127 * @param obj The object being referenced
128 * @param wire_type (out) Where to store the type
129 */
130
131static void
132of_tlv16_wire_type_get(of_object_t *obj, int *wire_type)
133{
134 uint16_t val16;
135 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
136
137 of_wire_buffer_u16_get(wbuf, OF_OBJECT_ABSOLUTE_OFFSET(obj,
138 TLV16_WIRE_TYPE_OFFSET), &val16);
139
140 *wire_type = val16;
141}
142
143/**
Rich Lanea06d0c32013-03-25 08:52:03 -0700144 * Get the object ID of an extended action
145 * @param obj The object being referenced
146 * @param id Where to store the object ID
147 * @fixme: This should be auto generated
148 *
149 * If unable to map to known extension, set id to generic "experimenter"
150 */
151
152#define OF_ACTION_EXPERIMENTER_ID_OFFSET 4
153#define OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET 8
154
155
156static void
157extension_action_object_id_get(of_object_t *obj, of_object_id_t *id)
158{
159 uint32_t exp_id;
160 uint8_t *buf;
161
162 *id = OF_ACTION_EXPERIMENTER;
163
164 buf = OF_OBJECT_BUFFER_INDEX(obj, 0);
165
166 buf_u32_get(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET, &exp_id);
167
168 switch (exp_id) {
169 case OF_EXPERIMENTER_ID_BSN: {
170 uint32_t subtype;
171 buf_u32_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
172 switch (subtype) {
173 case 1: *id = OF_ACTION_BSN_MIRROR; break;
174 case 2: *id = OF_ACTION_BSN_SET_TUNNEL_DST; break;
175 }
176 break;
177 }
178 case OF_EXPERIMENTER_ID_NICIRA: {
179 uint16_t subtype;
180 buf_u16_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
181 switch (subtype) {
182 case 18: *id = OF_ACTION_NICIRA_DEC_TTL; break;
183 }
184 break;
185 }
186 }
187}
188
189/**
Rich Lanea06d0c32013-03-25 08:52:03 -0700190 * Get the object ID of an extended action
191 * @param obj The object being referenced
192 * @param id Where to store the object ID
193 * @fixme: This should be auto generated
194 *
195 * If unable to map to known extension, set id to generic "experimenter"
196 */
197
198static void
199extension_action_id_object_id_get(of_object_t *obj, of_object_id_t *id)
200{
201 uint32_t exp_id;
202 uint8_t *buf;
203
204 *id = OF_ACTION_ID_EXPERIMENTER;
205
206 buf = OF_OBJECT_BUFFER_INDEX(obj, 0);
207
208 buf_u32_get(buf + OF_ACTION_EXPERIMENTER_ID_OFFSET, &exp_id);
209
210 switch (exp_id) {
211 case OF_EXPERIMENTER_ID_BSN: {
212 uint32_t subtype;
213 buf_u32_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
214 switch (subtype) {
215 case 1: *id = OF_ACTION_ID_BSN_MIRROR; break;
216 case 2: *id = OF_ACTION_ID_BSN_SET_TUNNEL_DST; break;
217 }
218 break;
219 }
220 case OF_EXPERIMENTER_ID_NICIRA: {
221 uint16_t subtype;
222 buf_u16_get(buf + OF_ACTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
223 switch (subtype) {
224 case 18: *id = OF_ACTION_ID_NICIRA_DEC_TTL; break;
225 }
226 break;
227 }
228 }
229}
230
231
232/**
233 * Get the object ID based on the wire buffer for an action object
234 * @param obj The object being referenced
235 * @param id Where to store the object ID
236 */
237
238
239void
240of_action_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
241{
242 int wire_type;
243
244 of_tlv16_wire_type_get(obj, &wire_type);
245 if (wire_type == OF_EXPERIMENTER_TYPE) {
246 extension_action_object_id_get(obj, id);
247 return;
248 }
249
250 ASSERT(wire_type >= 0 && wire_type < OF_ACTION_ITEM_COUNT);
251
252 *id = of_action_type_to_id[obj->version][wire_type];
253 ASSERT(*id != OF_OBJECT_INVALID);
254}
255
256/**
257 * Get the object ID based on the wire buffer for an action ID object
258 * @param obj The object being referenced
259 * @param id Where to store the object ID
260 */
261
262
263void
264of_action_id_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
265{
266 int wire_type;
267
268 of_tlv16_wire_type_get(obj, &wire_type);
269 if (wire_type == OF_EXPERIMENTER_TYPE) {
270 extension_action_id_object_id_get(obj, id);
271 return;
272 }
273
274 ASSERT(wire_type >= 0 && wire_type < OF_ACTION_ID_ITEM_COUNT);
275
276 *id = of_action_id_type_to_id[obj->version][wire_type];
277 ASSERT(*id != OF_OBJECT_INVALID);
278}
279
280/**
281 * @fixme to do when we have instruction extensions
282 * See extension_action above
283 */
284
285static int
286extension_instruction_object_id_get(of_object_t *obj, of_object_id_t *id)
287{
Rich Laneef7b9942013-11-18 16:29:28 -0800288 uint32_t exp_id;
289 uint8_t *buf;
Rich Lanea06d0c32013-03-25 08:52:03 -0700290
291 *id = OF_INSTRUCTION_EXPERIMENTER;
292
Rich Laneef7b9942013-11-18 16:29:28 -0800293 buf = OF_OBJECT_BUFFER_INDEX(obj, 0);
294
295 buf_u32_get(buf + OF_INSTRUCTION_EXPERIMENTER_ID_OFFSET, &exp_id);
296
297 switch (exp_id) {
298 case OF_EXPERIMENTER_ID_BSN: {
299 uint32_t subtype;
300 buf_u32_get(buf + OF_INSTRUCTION_EXPERIMENTER_SUBTYPE_OFFSET, &subtype);
301 switch (subtype) {
302 case 0: *id = OF_INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK; break;
303 }
304 break;
305 }
306 }
307
Rich Lanea06d0c32013-03-25 08:52:03 -0700308 return OF_ERROR_NONE;
309}
310
311/**
312 * Get the object ID based on the wire buffer for an instruction object
313 * @param obj The object being referenced
314 * @param id Where to store the object ID
315 */
316
317void
318of_instruction_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
319{
320 int wire_type;
321
322 of_tlv16_wire_type_get(obj, &wire_type);
323 if (wire_type == OF_EXPERIMENTER_TYPE) {
324 extension_instruction_object_id_get(obj, id);
325 return;
326 }
327
328 ASSERT(wire_type >= 0 && wire_type < OF_INSTRUCTION_ITEM_COUNT);
329
330 *id = of_instruction_type_to_id[obj->version][wire_type];
331 ASSERT(*id != OF_OBJECT_INVALID);
332}
333
334
335/**
336 * @fixme to do when we have queue_prop extensions
337 * See extension_action above
338 */
339
340static void
341extension_queue_prop_object_id_get(of_object_t *obj, of_object_id_t *id)
342{
343 (void)obj;
344
345 *id = OF_QUEUE_PROP_EXPERIMENTER;
346}
347
348/**
349 * Get the object ID based on the wire buffer for an queue_prop object
350 * @param obj The object being referenced
351 * @param id Where to store the object ID
352 */
353
354void
355of_queue_prop_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
356{
357 int wire_type;
358
359 of_tlv16_wire_type_get(obj, &wire_type);
360 if (wire_type == OF_EXPERIMENTER_TYPE) {
361 extension_queue_prop_object_id_get(obj, id);
362 return;
363 }
364
365 ASSERT(wire_type >= 0 && wire_type < OF_QUEUE_PROP_ITEM_COUNT);
366
367 *id = of_queue_prop_type_to_id[obj->version][wire_type];
368 ASSERT(*id != OF_OBJECT_INVALID);
369}
370
371
372/**
373 * @fixme to do when we have table_feature_prop extensions
374 * See extension_action above
375 */
376
377static void
378extension_table_feature_prop_object_id_get(of_object_t *obj, of_object_id_t *id)
379{
380 (void)obj;
381
382 *id = OF_TABLE_FEATURE_PROP_EXPERIMENTER;
383}
384
385/**
386 * Table feature property object ID determination
387 *
388 * @param obj The object being referenced
389 * @param id Where to store the object ID
390 */
391
392void
393of_table_feature_prop_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
394{
395 int wire_type;
396
397 of_tlv16_wire_type_get(obj, &wire_type);
398 if (wire_type == OF_EXPERIMENTER_TYPE) {
399 extension_table_feature_prop_object_id_get(obj, id);
400 return;
401 }
402
403 ASSERT(wire_type >= 0 && wire_type < OF_TABLE_FEATURE_PROP_ITEM_COUNT);
404
405 *id = of_table_feature_prop_type_to_id[obj->version][wire_type];
406 ASSERT(*id != OF_OBJECT_INVALID);
407}
408
409/**
410 * Get the object ID based on the wire buffer for meter_band object
411 * @param obj The object being referenced
412 * @param id Where to store the object ID
413 */
414
415void
416of_meter_band_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
417{
418 int wire_type;
419
420 of_tlv16_wire_type_get(obj, &wire_type);
421 if (wire_type == OF_EXPERIMENTER_TYPE) {
422 *id = OF_METER_BAND_EXPERIMENTER;
423 return;
424 }
425
426 ASSERT(wire_type >= 0 && wire_type < OF_METER_BAND_ITEM_COUNT);
427
428 *id = of_meter_band_type_to_id[obj->version][wire_type];
429 ASSERT(*id != OF_OBJECT_INVALID);
430}
431
432/**
433 * Get the object ID based on the wire buffer for a hello_elem object
434 * @param obj The object being referenced
435 * @param id Where to store the object ID
436 */
437
438void
439of_hello_elem_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
440{
441 int wire_type;
442
443 of_tlv16_wire_type_get(obj, &wire_type);
444 ASSERT(wire_type >= 0 && wire_type < OF_HELLO_ELEM_ITEM_COUNT);
445 *id = of_hello_elem_type_to_id[obj->version][wire_type];
446 ASSERT(*id != OF_OBJECT_INVALID);
447}
448
449/****************************************************************
450 * OXM type/length functions.
451 ****************************************************************/
452
453/* Where does the OXM type-length header lie in the buffer */
454#define OXM_HDR_OFFSET 0
455
456/**
457 * Get the OXM header (type-length fields) from the wire buffer
458 * associated with an OXM object
459 *
460 * Will return if error; set hdr to the OXM header
461 */
462
463#define _GET_OXM_TYPE_LEN(obj, tl_p, wbuf) do { \
464 wbuf = OF_OBJECT_TO_WBUF(obj); \
465 ASSERT(wbuf != NULL); \
466 of_wire_buffer_u32_get(wbuf, \
467 OF_OBJECT_ABSOLUTE_OFFSET(obj, OXM_HDR_OFFSET), (tl_p)); \
468 } while (0)
469
470#define _SET_OXM_TYPE_LEN(obj, tl_p, wbuf) do { \
471 wbuf = OF_OBJECT_TO_WBUF(obj); \
472 ASSERT(wbuf != NULL); \
473 of_wire_buffer_u32_set(wbuf, \
474 OF_OBJECT_ABSOLUTE_OFFSET(obj, OXM_HDR_OFFSET), (tl_p)); \
475 } while (0)
476
477/**
478 * Get the length of an OXM object from the wire buffer
479 * @param obj The object whose wire buffer is an OXM type
480 * @param bytes (out) Where length is stored
481 */
482
483void
484of_oxm_wire_length_get(of_object_t *obj, int *bytes)
485{
486 uint32_t type_len;
487 of_wire_buffer_t *wbuf;
488
489 _GET_OXM_TYPE_LEN(obj, &type_len, wbuf);
490 *bytes = OF_OXM_LENGTH_GET(type_len);
491}
492
493/**
Rich Lanea06d0c32013-03-25 08:52:03 -0700494 * Get the object ID of an OXM object based on the wire buffer type
495 * @param obj The object whose wire buffer is an OXM type
496 * @param id (out) Where the ID is stored
497 */
498
499void
500of_oxm_wire_object_id_get(of_object_t *obj, of_object_id_t *id)
501{
502 uint32_t type_len;
Rich Lanea06d0c32013-03-25 08:52:03 -0700503 of_wire_buffer_t *wbuf;
504
505 _GET_OXM_TYPE_LEN(obj, &type_len, wbuf);
Rich Laned8d29c92013-09-24 13:46:42 -0700506 *id = of_oxm_to_object_id(type_len, obj->version);
Rich Lanea06d0c32013-03-25 08:52:03 -0700507}
508
Rich Lanea06d0c32013-03-25 08:52:03 -0700509#define OF_U16_LEN_LENGTH_OFFSET 0
510
511/**
512 * Get the wire length for an object with a uint16 length as first member
513 * @param obj The object being referenced
514 * @param bytes Pointer to location to store length
515 */
516void
517of_u16_len_wire_length_get(of_object_t *obj, int *bytes)
518{
519 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
520 uint16_t u16;
521
522 ASSERT(wbuf != NULL);
523
524 of_wire_buffer_u16_get(wbuf,
525 OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_U16_LEN_LENGTH_OFFSET),
526 &u16);
527
528 *bytes = u16;
529}
530
531/**
532 * Set the wire length for an object with a uint16 length as first member
533 * @param obj The object being referenced
534 * @param bytes The length of the object
535 */
536
537void
538of_u16_len_wire_length_set(of_object_t *obj, int bytes)
539{
540 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
541 ASSERT(wbuf != NULL);
542
543 /* ASSERT(obj is u16-len entry) */
544
545 of_wire_buffer_u16_set(wbuf,
546 OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_U16_LEN_LENGTH_OFFSET),
547 bytes);
548}
549
550
551#define OF_PACKET_QUEUE_LENGTH_OFFSET(ver) \
552 (((ver) >= OF_VERSION_1_2) ? 8 : 4)
553
554/**
555 * Get the wire length for a packet queue object
556 * @param obj The object being referenced
557 * @param bytes Pointer to location to store length
558 *
559 * The length is a uint16 at the offset indicated above
560 */
561void
562of_packet_queue_wire_length_get(of_object_t *obj, int *bytes)
563{
564 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
565 uint16_t u16;
566 int offset;
567
568 ASSERT(wbuf != NULL);
569
570 /* ASSERT(obj is packet queue obj) */
571 offset = OF_PACKET_QUEUE_LENGTH_OFFSET(obj->version);
572 of_wire_buffer_u16_get(wbuf, OF_OBJECT_ABSOLUTE_OFFSET(obj, offset),
573 &u16);
574
575 *bytes = u16;
576}
577
578/**
579 * Set the wire length for a 1.2 packet queue object
580 * @param obj The object being referenced
581 * @param bytes The length of the object
582 *
583 * The length is a uint16 at the offset indicated above
584 */
585
586void
587of_packet_queue_wire_length_set(of_object_t *obj, int bytes)
588{
589 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
590 int offset;
591
592 ASSERT(wbuf != NULL);
593
594 /* ASSERT(obj is packet queue obj) */
595 offset = OF_PACKET_QUEUE_LENGTH_OFFSET(obj->version);
596 of_wire_buffer_u16_set(wbuf, OF_OBJECT_ABSOLUTE_OFFSET(obj, offset),
597 bytes);
598}
599
600/**
601 * Get the wire length for a meter band stats list
602 * @param obj The object being referenced
603 * @param bytes Pointer to location to store length
604 *
605 * Must a meter_stats object as a parent
606 */
607
608void
609of_list_meter_band_stats_wire_length_get(of_object_t *obj, int *bytes)
610{
611 ASSERT(obj->parent != NULL);
612 ASSERT(obj->parent->object_id == OF_METER_STATS);
613
614 /* We're counting on the parent being properly initialized already.
615 * The length is stored in a uint16 at offset 4 of the parent.
616 */
617 *bytes = obj->parent->length - OF_OBJECT_FIXED_LENGTH(obj->parent);
618}
619
620#define OF_METER_STATS_LENGTH_OFFSET 4
621
622/**
623 * Get/set the wire length for a meter stats object
624 * @param obj The object being referenced
625 * @param bytes Pointer to location to store length
626 *
627 * It's almost a TLV....
628 */
629
630void
631of_meter_stats_wire_length_get(of_object_t *obj, int *bytes)
632{
633 uint16_t val16;
634 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
635 ASSERT(wbuf != NULL);
636 of_wire_buffer_u16_get(wbuf,
637 OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_METER_STATS_LENGTH_OFFSET),
638 &val16);
639 *bytes = val16;
640}
641
642void
643of_meter_stats_wire_length_set(of_object_t *obj, int bytes)
644{
645 of_wire_buffer_t *wbuf = OF_OBJECT_TO_WBUF(obj);
646 ASSERT(wbuf != NULL);
647
648 of_wire_buffer_u16_set(wbuf,
649 OF_OBJECT_ABSOLUTE_OFFSET(obj, OF_METER_STATS_LENGTH_OFFSET), bytes);
650}
651
652/*
653 * Non-message extension push wire values
654 */
655
656int
657of_extension_object_wire_push(of_object_t *obj)
658{
659 of_action_bsn_mirror_t *action_mirror;
660 of_action_id_bsn_mirror_t *action_id_mirror;
661 of_action_bsn_set_tunnel_dst_t *action_set_tunnel_dst;
662 of_action_id_bsn_set_tunnel_dst_t *action_id_set_tunnel_dst;
663 of_action_nicira_dec_ttl_t *action_nicira_dec_ttl;
664 of_action_id_nicira_dec_ttl_t *action_id_nicira_dec_ttl;
665
666 /* Push exp type, subtype */
667 switch (obj->object_id) {
668 case OF_ACTION_BSN_MIRROR:
669 action_mirror = (of_action_bsn_mirror_t *)obj;
670 of_action_bsn_mirror_experimenter_set(action_mirror,
671 OF_EXPERIMENTER_ID_BSN);
672 of_action_bsn_mirror_subtype_set(action_mirror, 1);
673 break;
674 case OF_ACTION_ID_BSN_MIRROR:
675 action_id_mirror = (of_action_id_bsn_mirror_t *)obj;
676 of_action_id_bsn_mirror_experimenter_set(action_id_mirror,
677 OF_EXPERIMENTER_ID_BSN);
678 of_action_id_bsn_mirror_subtype_set(action_id_mirror, 1);
679 break;
680 case OF_ACTION_BSN_SET_TUNNEL_DST:
681 action_set_tunnel_dst = (of_action_bsn_set_tunnel_dst_t *)obj;
682 of_action_bsn_set_tunnel_dst_experimenter_set(action_set_tunnel_dst,
683 OF_EXPERIMENTER_ID_BSN);
684 of_action_bsn_set_tunnel_dst_subtype_set(action_set_tunnel_dst, 2);
685 break;
686 case OF_ACTION_ID_BSN_SET_TUNNEL_DST:
687 action_id_set_tunnel_dst = (of_action_id_bsn_set_tunnel_dst_t *)obj;
688 of_action_id_bsn_set_tunnel_dst_experimenter_set(action_id_set_tunnel_dst,
689 OF_EXPERIMENTER_ID_BSN);
690 of_action_id_bsn_set_tunnel_dst_subtype_set(action_id_set_tunnel_dst, 2);
691 break;
692 case OF_ACTION_NICIRA_DEC_TTL:
693 action_nicira_dec_ttl = (of_action_nicira_dec_ttl_t *)obj;
694 of_action_nicira_dec_ttl_experimenter_set(action_nicira_dec_ttl,
695 OF_EXPERIMENTER_ID_NICIRA);
696 of_action_nicira_dec_ttl_subtype_set(action_nicira_dec_ttl, 18);
697 break;
698 case OF_ACTION_ID_NICIRA_DEC_TTL:
699 action_id_nicira_dec_ttl = (of_action_id_nicira_dec_ttl_t *)obj;
700 of_action_id_nicira_dec_ttl_experimenter_set(action_id_nicira_dec_ttl,
701 OF_EXPERIMENTER_ID_NICIRA);
702 of_action_id_nicira_dec_ttl_subtype_set(action_id_nicira_dec_ttl, 18);
703 break;
704 default:
705 break;
706 }
707
708 return OF_ERROR_NONE;
709}
Rich Lane353a79f2013-11-13 10:39:56 -0800710
711int
712of_experimenter_stats_request_to_object_id(uint32_t experimenter, uint32_t subtype, int ver)
713{
714 switch (experimenter) {
715 case OF_EXPERIMENTER_ID_BSN:
716 switch (subtype) {
717 case 1: return OF_BSN_LACP_STATS_REQUEST;
Wilson Ng45386fb2013-12-03 13:46:42 -0800718 case 6: return OF_BSN_SWITCH_PIPELINE_STATS_REQUEST;
xinwu54ceaca2013-12-04 17:02:27 -0800719 case 8: return OF_BSN_PORT_COUNTER_STATS_REQUEST;
720 case 9: return OF_BSN_VLAN_COUNTER_STATS_REQUEST;
Rich Lane353a79f2013-11-13 10:39:56 -0800721 }
722 }
723 return OF_OBJECT_INVALID;
724}
725
726int
727of_experimenter_stats_reply_to_object_id(uint32_t experimenter, uint32_t subtype, int ver)
728{
729 switch (experimenter) {
730 case OF_EXPERIMENTER_ID_BSN:
731 switch (subtype) {
732 case 1: return OF_BSN_LACP_STATS_REPLY;
Wilson Ng45386fb2013-12-03 13:46:42 -0800733 case 6: return OF_BSN_SWITCH_PIPELINE_STATS_REPLY;
xinwu54ceaca2013-12-04 17:02:27 -0800734 case 8: return OF_BSN_PORT_COUNTER_STATS_REPLY;
735 case 9: return OF_BSN_VLAN_COUNTER_STATS_REPLY;
Rich Lane353a79f2013-11-13 10:39:56 -0800736 }
737 }
738 return OF_OBJECT_INVALID;
739}