blob: 2eb11b77b8ef33431a965db7799082563e789230 [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#if !defined(_LOCI_DUMP_H_)
31#define _LOCI_DUMP_H_
32
33#include <loci/loci_base.h>
34#include <loci/of_match.h>
35#include <stdio.h>
36
37/* g++ requires this to pick up PRI, etc.
38 * See http://gcc.gnu.org/ml/gcc-help/2006-10/msg00223.html
39 */
40#if !defined(__STDC_FORMAT_MACROS)
41#define __STDC_FORMAT_MACROS
42#endif
43#include <inttypes.h>
44
45typedef int (*loci_obj_dump_f)(loci_writer_f writer, void *cookie, of_object_t *obj);
46
47/****************************************************************
48 *
49 * Per-datatype dump macros
50 *
51 ****************************************************************/
52#define LOCI_DUMP_u8(writer, cookie, val) writer(cookie, "%u", (val))
53#define LOCI_DUMP_u16(writer, cookie, val) writer(cookie, "%u (0x%x)", (val), (val))
54#define LOCI_DUMP_u32(writer, cookie, val) writer(cookie, "%u (0x%x)", (val), (val))
55#define LOCI_DUMP_u64(writer, cookie, val) writer(cookie, "%" PRIu64 "(0x%" PRIx64 ")", (val), (val))
56
57/* @todo Add checks for special port numbers */
58#define LOCI_DUMP_port_no(writer, cookie, val) LOCI_DUMP_u32(writer, cookie, val)
59#define LOCI_DUMP_fm_cmd(writer, cookie, val) LOCI_DUMP_u16(writer, cookie, val)
60
61/* @todo Decode wildcards */
62#define LOCI_DUMP_wc_bmap(writer, cookie, val) \
63 writer(cookie, "0x%" PRIx64, (val))
64#define LOCI_DUMP_match_bmap(writer, cookie, val) \
65 writer(cookie, "0x%" PRIx64, (val))
66
67/* @todo Dump first N bytes of data */
68#define LOCI_DUMP_octets(writer, cookie, val) \
69 writer(cookie, "%d bytes at location %p", (val).bytes, (val).data)
70
71#define LOCI_DUMP_mac(writer, cookie, val) \
72 writer(cookie, "%02x:%02x:%02x:%02x:%02x:%02x", \
73 (val).addr[0], (val).addr[1], (val).addr[2], \
74 (val).addr[3], (val).addr[4], (val).addr[5])
75
76#define LOCI_DUMP_ipv4(writer, cookie, val) \
77 writer(cookie, "%d.%d.%d.%d", val >> 24, (val >> 16) & 0xff, \
78 (val >> 8) & 0xff, val & 0xff)
79
80#define LOCI_DUMP_ipv6(writer, cookie, val) \
81 writer(cookie, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", \
82 (val).addr[0], (val).addr[1], (val).addr[2], (val).addr[3], \
83 (val).addr[4], (val).addr[5], (val).addr[6], (val).addr[7], \
84 (val).addr[8], (val).addr[9], (val).addr[10], (val).addr[11], \
85 (val).addr[12], (val).addr[13], (val).addr[14], (val).addr[15])
86
87#define LOCI_DUMP_string(writer, cookie, val) writer(cookie, "%s", val)
88
89#define LOCI_DUMP_port_name(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
90#define LOCI_DUMP_tab_name(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
91#define LOCI_DUMP_desc_str(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
92#define LOCI_DUMP_ser_num(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
Rich Lanef8a3d002014-03-19 13:33:52 -070093#define LOCI_DUMP_str64(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
Brian O'Connor58a73e32015-05-28 11:51:27 -070094#define LOCI_DUMP_str6(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
95#define LOCI_DUMP_str32(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
Rich Lanea06d0c32013-03-25 08:52:03 -070096
97int loci_dump_match(loci_writer_f writer, void* cookie, of_match_t *match);
98#define LOCI_DUMP_match(writer, cookie, val) loci_dump_match(writer, cookie, &val)
99
Rich Lane3b2fd832013-09-24 13:44:08 -0700100#define LOCI_DUMP_bitmap_128(writer, cookie, val) writer(cookie, "%" PRIx64 "%" PRIx64, (val).hi, (val).lo)
101
Rich Lanefab0c822013-12-30 11:46:48 -0800102#define LOCI_DUMP_checksum_128(writer, cookie, val) writer(cookie, "%016" PRIx64 "%016" PRIx64, (val).hi, (val).lo)
103
Rich Lane119289c2014-12-01 13:44:08 -0800104#define LOCI_DUMP_bitmap_512(writer, cookie, val) writer(cookie, "%" PRIx64 "%" PRIx64 "%" PRIx64 "%" PRIx64 "%" PRIx64 "%" PRIx64 "%" PRIx64 "%" PRIx64, (val).words[7], (val).words[6], (val).words[5], (val).words[4], (val).words[3], (val).words[2], (val).words[1], (val).words[0])
105
Rich Lanea06d0c32013-03-25 08:52:03 -0700106/**
107 * Generic version for any object
108 */
109int of_object_dump(loci_writer_f writer, void *cookie, of_object_t *obj);
110#endif /* _LOCI_DUMP_H_ */