Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / asn1 / h248 / packet-h248-template.h
blobc7d3df1e36434450580855fe15243fcf502faf10
1 /* packet-h248.h
2 * Definitions for H.248/MEGACO packet dissection
4 * Ronnie Sahlberg 2004
5 * Luis Ontanon 2005
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #ifndef PACKET_H248_H
15 #define PACKET_H248_H
17 #include "ws_symbol_export.h"
19 #include <epan/packet.h>
20 #include <epan/expert.h>
21 #include <wsutil/nstime.h>
23 /* Gateway Control Protocol -- Context Tracking */
25 typedef struct _gcp_hf_ett_t {
26 struct {
27 int ctx;
28 int ctx_cmd;
29 int ctx_term;
30 int ctx_term_type;
31 int ctx_term_bir;
32 int ctx_term_nsap;
33 } hf;
35 struct {
36 int ctx;
37 int ctx_cmds;
38 int ctx_terms;
39 int ctx_term;
40 } ett;
41 } gcp_hf_ett_t;
43 #define NULL_CONTEXT 0
44 #define CHOOSE_CONTEXT 0xFFFFFFFE
45 #define ALL_CONTEXTS 0xFFFFFFFF
48 typedef enum {
49 GCP_CMD_NONE,
50 GCP_CMD_ADD_REQ,
51 GCP_CMD_MOVE_REQ,
52 GCP_CMD_MOD_REQ,
53 GCP_CMD_SUB_REQ,
54 GCP_CMD_AUDITCAP_REQ,
55 GCP_CMD_AUDITVAL_REQ,
56 GCP_CMD_NOTIFY_REQ,
57 GCP_CMD_SVCCHG_REQ,
58 GCP_CMD_TOPOLOGY_REQ,
59 GCP_CMD_CTX_ATTR_AUDIT_REQ,
60 GCP_CMD_OTHER_REQ,
61 GCP_CMD_ADD_REPLY,
62 GCP_CMD_MOVE_REPLY,
63 GCP_CMD_MOD_REPLY,
64 GCP_CMD_SUB_REPLY,
65 GCP_CMD_AUDITCAP_REPLY,
66 GCP_CMD_AUDITVAL_REPLY,
67 GCP_CMD_NOTIFY_REPLY,
68 GCP_CMD_SVCCHG_REPLY,
69 GCP_CMD_TOPOLOGY_REPLY,
70 GCP_CMD_REPLY
71 } gcp_cmd_type_t;
73 typedef enum {
74 GCP_TRX_NONE,
75 GCP_TRX_REQUEST,
76 GCP_TRX_PENDING,
77 GCP_TRX_REPLY,
78 GCP_TRX_ACK
79 } gcp_trx_type_t;
82 typedef struct _gcp_msg_t {
83 uint32_t lo_addr;
84 uint32_t hi_addr;
85 uint32_t framenum;
86 nstime_t frametime;
87 struct _gcp_trx_msg_t* trxs;
88 bool committed;
89 } gcp_msg_t;
91 typedef struct _gcp_trx_msg_t {
92 struct _gcp_trx_t* trx;
93 struct _gcp_trx_msg_t* next;
94 struct _gcp_trx_msg_t* last;
95 } gcp_trx_msg_t;
97 typedef struct _gcp_cmd_msg_t {
98 struct _gcp_cmd_t* cmd;
99 struct _gcp_cmd_msg_t* next;
100 struct _gcp_cmd_msg_t* last;
101 } gcp_cmd_msg_t;
103 typedef struct _gcp_trx_t {
104 gcp_msg_t* initial;
105 uint32_t id;
106 gcp_trx_type_t type;
107 unsigned pendings;
108 struct _gcp_cmd_msg_t* cmds;
109 struct _gcp_trx_ctx_t* ctxs;
110 unsigned error;
111 } gcp_trx_t;
113 #define GCP_TERM_TYPE_UNKNOWN 0
114 #define GCP_TERM_TYPE_AAL1 1
115 #define GCP_TERM_TYPE_AAL2 2
116 #define GCP_TERM_TYPE_AAL1_STRUCT 3
117 #define GCP_TERM_TYPE_IP_RTP 4
118 #define GCP_TERM_TYPE_TDM 5
120 typedef enum _gcp_wildcard_t {
121 GCP_WILDCARD_NONE,
122 GCP_WILDCARD_CHOOSE,
123 GCP_WILDCARD_ALL
124 } gcp_wildcard_t;
126 typedef struct _gcp_term_t {
127 const char* str;
129 const uint8_t* buffer;
130 unsigned len;
132 unsigned type;
133 char* bir;
134 char* nsap;
136 gcp_msg_t* start;
138 } gcp_term_t;
140 typedef struct _gcp_terms_t {
141 gcp_term_t* term;
142 struct _gcp_terms_t* next;
143 struct _gcp_terms_t* last;
144 } gcp_terms_t;
146 typedef struct _gcp_cmd_t {
147 unsigned offset;
148 const char* str;
149 gcp_cmd_type_t type;
150 gcp_terms_t terms;
151 struct _gcp_msg_t* msg;
152 struct _gcp_trx_t* trx;
153 struct _gcp_ctx_t* ctx;
154 unsigned error;
155 } gcp_cmd_t;
158 typedef struct _gcp_ctx_t {
159 gcp_msg_t* initial;
160 uint32_t id;
161 struct _gcp_cmd_msg_t* cmds;
162 struct _gcp_ctx_t* prev;
163 gcp_terms_t terms;
164 } gcp_ctx_t;
166 extern gcp_msg_t* gcp_msg(packet_info* pinfo, int o, bool persistent);
167 extern gcp_trx_t* gcp_trx(gcp_msg_t* m ,uint32_t t_id , gcp_trx_type_t type, packet_info *pinfo, bool persistent);
168 extern gcp_ctx_t* gcp_ctx(gcp_msg_t* m, gcp_trx_t* t, uint32_t c_id, packet_info *pinfo, bool persistent);
169 extern gcp_cmd_t* gcp_cmd(gcp_msg_t* m, gcp_trx_t* t, gcp_ctx_t* c, gcp_cmd_type_t type, unsigned offset, packet_info *pinfo, bool persistent);
170 extern gcp_term_t* gcp_cmd_add_term(gcp_msg_t* m, gcp_trx_t* tr, gcp_cmd_t* c, gcp_term_t* t, gcp_wildcard_t wildcard, packet_info *pinfo, bool persistent);
171 extern void gcp_analyze_msg(proto_tree* gcp_tree, packet_info* pinfo, tvbuff_t* gcp_tvb, gcp_msg_t* m, gcp_hf_ett_t* ids, expert_field* command_err);
173 #define GCP_ETT_ARR_ELEMS(gi) &(gi.ett.ctx),&(gi.ett.ctx_cmds),&(gi.ett.ctx_terms),&(gi.ett.ctx_term)
175 #define GCP_HF_ARR_ELEMS(n,gi) \
176 { &(gi.hf.ctx), { "Context", n ".ctx", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL }}, \
177 { &(gi.hf.ctx_term), { "Termination", n ".ctx.term", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
178 { &(gi.hf.ctx_term_type), { "Type", n ".ctx.term.type", FT_UINT32, BASE_HEX, VALS(gcp_term_types), 0, NULL, HFILL }}, \
179 { &(gi.hf.ctx_term_bir), { "BIR", n ".ctx.term.bir", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
180 { &(gi.hf.ctx_term_nsap), { "NSAP", n ".ctx.term.nsap", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
181 { &(gi.hf.ctx_cmd), { "Command in Frame", n ".ctx.cmd", FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }}
183 WS_DLL_PUBLIC const value_string gcp_cmd_type[];
184 WS_DLL_PUBLIC const value_string gcp_term_types[];
186 extern const char* gcp_msg_to_str(gcp_msg_t* m, wmem_allocator_t *scope, bool persistent);
188 #define gcp_cmd_set_error(c,e) (c->error = e)
189 #define gcp_trx_set_error(t,e) (t->error = e)
191 /* END Gateway Control Protocol -- Context Tracking */
193 typedef struct _h248_curr_info_t h248_curr_info_t;
195 typedef void (*h248_pkg_param_dissector_t)(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, int hfid, h248_curr_info_t*, void*);
197 extern void h248_param_bytes_item(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
198 extern void h248_param_uint_item(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
199 WS_DLL_PUBLIC void h248_param_ber_integer(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
200 extern void h248_param_ber_octetstring(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
201 extern void h248_param_ber_boolean(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
202 extern void external_dissector(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* dissector_handle);
203 extern void h248_param_PkgdName(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u _U_, void* dissector_hdl);
204 extern void h248_param_external_dissector(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u _U_, void* dissector_hdl);
206 typedef enum {
207 ADD_PKG, /* add package at registration ONLY if no matching package ID */
208 REPLACE_PKG, /* replace/add package at registration */
209 MERGE_PKG_HIGH, /* merge h248_package_t at registration favor new package */
210 MERGE_PKG_LOW /* merge h248_package_t at registration favor current package */
211 } pkg_reg_action;
213 typedef struct _h248_pkg_param_t {
214 uint32_t id;
215 int* hfid;
216 h248_pkg_param_dissector_t dissector;
217 void* data;
218 } h248_pkg_param_t;
220 typedef struct _h248_pkg_sig_t {
221 uint32_t id;
222 int* hfid;
223 int* ett;
224 const h248_pkg_param_t* parameters;
225 const value_string* param_names;
226 } h248_pkg_sig_t;
228 typedef struct _h248_pkg_evt_t {
229 uint32_t id;
230 int* hfid;
231 int* ett;
232 const h248_pkg_param_t* parameters;
233 const value_string* param_names;
234 } h248_pkg_evt_t;
236 typedef struct _h248_pkg_stat_t {
237 uint32_t id;
238 int* hfid;
239 int* ett;
240 const h248_pkg_param_t* parameters;
241 const value_string* param_names;
242 } h248_pkg_stat_t;
244 typedef struct _h248_package_t {
245 uint32_t id; /**< Package ID */
246 int* hfid; /**< hfid that will display the package name */
247 int* ett; /**< The ett for this item */
248 const value_string* param_names; /**< The parameter names, Value 00000 should be the package name */
249 const value_string* signal_names;
250 const value_string* event_names;
251 const value_string* stats_names;
252 const h248_pkg_param_t* properties;
253 const h248_pkg_sig_t* signals;
254 const h248_pkg_evt_t* events;
255 const h248_pkg_stat_t* statistics;
256 } h248_package_t;
258 typedef struct _save_h248_package_t {
259 h248_package_t *pkg;
260 bool is_default;
261 } s_h248_package_t;
263 struct _h248_curr_info_t {
264 gcp_ctx_t* ctx;
265 gcp_trx_t* trx;
266 gcp_msg_t* msg;
267 gcp_term_t* term;
268 gcp_cmd_t* cmd;
269 const h248_package_t* pkg;
270 const h248_pkg_evt_t* evt;
271 const h248_pkg_sig_t* sig;
272 const h248_pkg_stat_t* stat;
273 const h248_pkg_param_t* par;
276 typedef struct h248_term_info {
277 uint8_t wild_card;
278 char *str;
279 } h248_term_info_t;
281 WS_DLL_PUBLIC
282 void h248_register_package(h248_package_t* pkg, pkg_reg_action reg_action);
284 #endif /* PACKET_H248_H */