Don't do fcn calls in arg of g_?to??(); Macro may very well eval args multiple times.
[obnox/wireshark/wip.git] / epan / dissectors / packet-rmt-lct.h
1 /* packet-rmt-lct.h
2  * Reliable Multicast Transport (RMT)
3  * LCT Building Block function definitions
4  * Copyright 2005, Stefano Pettini <spettini@users.sourceforge.net>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25  */
26
27 #ifndef __PACKET_RMT_LCT__
28 #define __PACKET_RMT_LCT__
29
30 #include "packet-rmt-common.h"
31 #include "packet-rmt-fec.h"
32
33 /* Type definitions */
34 /* ================ */
35
36 /* Logical LCT header representation */
37 struct _lct
38 {
39         guint8 version;
40         guint8 cci_size;
41         guint8 tsi_size;
42         guint8 toi_size;
43         gboolean tsi_present;
44         gboolean toi_present;
45         gboolean sct_present;
46         gboolean ert_present;
47         gboolean close_session;
48         gboolean close_object;
49         guint16 hlen;
50         guint8 codepoint;
51         guint64 tsi;
52         guint64 toi;
53         const guint8 *toi_extended;
54         nstime_t sct;
55         nstime_t ert;
56         GArray *ext;
57 };
58
59 /* Wireshark stuff */
60 /* ============== */
61
62 /* LCT header field definitions */
63 struct _lct_hf
64 {
65         int header;
66         int version;
67         int fsize_header;
68         int fsize_cci;
69         int fsize_tsi;
70         int fsize_toi;
71         int flags_header;
72         int flags_sct_present;
73         int flags_ert_present;
74         int flags_close_session;
75         int flags_close_object;
76         int hlen;
77         int codepoint;
78         int cci;
79         int tsi;
80         int toi;
81         int toi_extended;
82         int sct;
83         int ert;
84         int ext;
85 };
86
87 /* LCT subtrees */
88 struct _lct_ett
89 {
90         gint main;
91
92         gint fsize;
93         gint flags;
94         gint ext;
95         gint ext_ext;
96 };
97
98 /* LCT preferences */
99
100 #define LCT_PREFS_EXT_192_NONE 0
101 #define LCT_PREFS_EXT_192_FLUTE 1
102
103 #define LCT_PREFS_EXT_193_NONE 0
104 #define LCT_PREFS_EXT_193_FLUTE 1
105
106 struct _lct_prefs
107 {
108         gboolean codepoint_as_fec_encoding;
109         gint ext_192;
110         gint ext_193;
111 };
112
113 /* LCT pointers */
114 struct _lct_ptr
115 {
116         struct _lct *lct;
117         struct _lct_hf *hf;
118         struct _lct_ett *ett;
119         struct _lct_prefs *prefs;
120 };
121
122 /* Macros to generate static arrays */
123
124 #define LCT_FIELD_ARRAY(base_structure, base_protocol)  \
125                 { &base_structure.header,       \
126                         { "Layered Coding Transport (LCT) header", base_protocol ".lct", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, \
127                 { &base_structure.version,      \
128                         { "Version", base_protocol ".lct.version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},       \
129                 { &base_structure.fsize_header, \
130                         { "Field sizes (bytes)", base_protocol ".lct.fsize", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},     \
131                 { &base_structure.fsize_cci,    \
132                         { "Congestion Control Information field size", base_protocol ".lct.fsize.cci", FT_UINT8,        BASE_DEC, NULL, 0x0, NULL, HFILL }},    \
133                 { &base_structure.fsize_tsi,    \
134                         { "Transport Session Identifier field size", base_protocol ".lct.fsize.tsi", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},     \
135                 { &base_structure.fsize_toi,    \
136                         { "Transport Object Identifier field size", base_protocol ".lct.fsize.toi", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},      \
137                 { &base_structure.flags_header, \
138                         { "Flags", base_protocol ".lct.flags", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},   \
139                 { &base_structure.flags_sct_present,    \
140                         { "Sender Current Time present flag", base_protocol ".lct.flags.sct_present", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0, NULL, HFILL }}, \
141                 { &base_structure.flags_ert_present,    \
142                         { "Expected Residual Time present flag", base_protocol ".lct.flags.ert_present", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0, NULL, HFILL }},      \
143                 { &base_structure.flags_close_session,  \
144                         { "Close Session flag", base_protocol ".lct.flags.close_session", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0, NULL, HFILL }},     \
145                 { &base_structure.flags_close_object,   \
146                         { "Close Object flag", base_protocol ".lct.flags.close_object", FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0, NULL, HFILL }},       \
147                 { &base_structure.hlen, \
148                         { "Header length", base_protocol ".lct.hlen", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},   \
149                 { &base_structure.codepoint,    \
150                         { "Codepoint", base_protocol ".lct.codepoint", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},   \
151                 { &base_structure.cci,  \
152                         { "Congestion Control Information", base_protocol ".lct.cci", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},   \
153                 { &base_structure.tsi,  \
154                         { "Transport Session Identifier", base_protocol ".lct.tsi", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},     \
155                 { &base_structure.toi,  \
156                         { "Transport Object Identifier (up to 64 bites)", base_protocol ".lct.toi", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},     \
157                 { &base_structure.toi_extended, \
158                         { "Transport Object Identifier (up to 112 bits)", base_protocol ".lct.toi_extended", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},    \
159                 { &base_structure.sct,  \
160                         { "Sender Current Time", base_protocol ".lct.sct", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }},      \
161                 { &base_structure.ert,  \
162                         { "Expected Residual Time", base_protocol ".lct.ert", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }},   \
163                 { &base_structure.ext,  \
164                         { "Extension count", base_protocol ".lct.ext", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}
165
166 #define LCT_SUBTREE_ARRAY(base_structure) \
167         &base_structure.main,   \
168         &base_structure.fsize,  \
169         &base_structure.flags,  \
170         &base_structure.ext,    \
171         &base_structure.ext_ext
172
173 /* LCT exported functions */
174 /* ====================== */
175
176 void lct_info_column(struct _lct *lct, packet_info *pinfo);
177
178 gboolean lct_dissector(struct _lct_ptr l, struct _fec_ptr f, tvbuff_t *tvb, proto_tree *tree, guint *offset);
179 void lct_dissector_free(struct _lct *lct);
180
181 void lct_prefs_set_default(struct _lct_prefs *prefs);
182 void lct_prefs_register(struct _lct_prefs *prefs, module_t *module);
183 gboolean lct_ext_decode(struct _ext *e, struct _lct_prefs *prefs, tvbuff_t *tvb, proto_tree *tree, gint ett, struct _fec_ptr f);
184
185 #endif