Re-enable capture tests now that a a dumpcap problem has been corrected.
[obnox/wireshark/wip.git] / epan / gcp.h
1 /* gcp.h
2  * Gateway Control Protocol -- Context Tracking
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24 #ifndef __GCP_H_
25 #define __GCP_H_
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <glib.h>
32 #include <epan/packet.h>
33 #include <epan/conversation.h>
34 #include <epan/strutil.h>
35 #include <epan/emem.h>
36 #include <epan/expert.h>
37 #include <epan/prefs.h>
38 #include <epan/to_str.h>
39 #include <epan/asn1.h>
40
41 #include <stdio.h>
42 #include <string.h>
43
44 #include <epan/dissectors/packet-ber.h>
45 #include <epan/dissectors/packet-q931.h>
46 #include <epan/dissectors/packet-mtp3.h>
47 #include <epan/dissectors/packet-alcap.h>
48 #include <epan/dissectors/packet-isup.h>
49
50 #include <epan/sctpppids.h>
51
52 typedef struct _gcp_hf_ett_t {
53         struct {
54                 int ctx;
55                 int ctx_cmd;
56                 int ctx_term;
57                 int ctx_term_type;
58                 int ctx_term_bir;
59                 int ctx_term_nsap;
60         } hf;
61         
62         struct {
63                 gint ctx;
64                 gint ctx_cmds;
65                 gint ctx_terms;
66                 gint ctx_term;
67         } ett;
68 } gcp_hf_ett_t;
69
70 #define NULL_CONTEXT 0
71 #define CHOOSE_CONTEXT 0xFFFFFFFE
72 #define ALL_CONTEXTS 0xFFFFFFFF
73
74
75 typedef enum {
76     GCP_CMD_NONE,
77     GCP_CMD_ADD_REQ,
78     GCP_CMD_MOVE_REQ,
79     GCP_CMD_MOD_REQ,
80     GCP_CMD_SUB_REQ,
81     GCP_CMD_AUDITCAP_REQ,
82     GCP_CMD_AUDITVAL_REQ,
83     GCP_CMD_NOTIFY_REQ,
84     GCP_CMD_SVCCHG_REQ,
85     GCP_CMD_TOPOLOGY_REQ,
86     GCP_CMD_CTX_ATTR_AUDIT_REQ,
87     GCP_CMD_OTHER_REQ,
88     GCP_CMD_ADD_REPLY,
89     GCP_CMD_MOVE_REPLY,
90     GCP_CMD_MOD_REPLY,
91     GCP_CMD_SUB_REPLY,
92     GCP_CMD_AUDITCAP_REPLY,
93     GCP_CMD_AUDITVAL_REPLY,
94     GCP_CMD_NOTIFY_REPLY,
95     GCP_CMD_SVCCHG_REPLY,
96     GCP_CMD_TOPOLOGY_REPLY,
97     GCP_CMD_REPLY
98 } gcp_cmd_type_t;
99
100 typedef enum {
101     GCP_TRX_NONE,
102     GCP_TRX_REQUEST,
103     GCP_TRX_PENDING,
104     GCP_TRX_REPLY,
105     GCP_TRX_ACK
106 } gcp_trx_type_t;
107
108
109 typedef struct _gcp_msg_t {
110     guint32 lo_addr;
111     guint32 hi_addr;
112     guint32 framenum;
113     struct _gcp_trx_msg_t* trxs;
114     gboolean commited;
115 } gcp_msg_t;
116
117 typedef struct _gcp_trx_msg_t {
118     struct _gcp_trx_t* trx;
119     struct _gcp_trx_msg_t* next;
120     struct _gcp_trx_msg_t* last;
121 } gcp_trx_msg_t;
122
123 typedef struct _gcp_cmd_msg_t {
124     struct _gcp_cmd_t* cmd;
125     struct _gcp_cmd_msg_t* next;
126     struct _gcp_cmd_msg_t* last;
127 } gcp_cmd_msg_t;
128
129 typedef struct _gcp_trx_t {
130     gcp_msg_t* initial;
131     guint32 id;
132     gcp_trx_type_t type;
133     guint pendings;
134     struct _gcp_cmd_msg_t* cmds;
135     struct _gcp_trx_ctx_t* ctxs;
136     guint error;
137 } gcp_trx_t;
138
139 #define GCP_TERM_TYPE_UNKNOWN 0
140 #define GCP_TERM_TYPE_AAL1 1
141 #define GCP_TERM_TYPE_AAL2 2
142 #define GCP_TERM_TYPE_AAL1_STRUCT 3
143 #define GCP_TERM_TYPE_IP_RTP 4
144 #define GCP_TERM_TYPE_TDM 5
145
146 typedef enum _gcp_wildcard_t {
147     GCP_WILDCARD_NONE,
148     GCP_WILDCARD_CHOOSE,
149     GCP_WILDCARD_ALL
150 } gcp_wildcard_t;
151
152 typedef struct _gcp_term_t {
153     gchar* str;
154     
155     guint8* buffer;
156     guint len;
157
158     guint type;
159     gchar* bir;
160     gchar* nsap;
161
162     gcp_msg_t* start;
163     
164 } gcp_term_t;
165
166 typedef struct _gcp_terms_t {
167     gcp_term_t* term;
168     struct _gcp_terms_t* next;
169     struct _gcp_terms_t* last;
170 } gcp_terms_t;
171
172 typedef struct _gcp_cmd_t {
173     guint offset;
174         gchar* str;
175     gcp_cmd_type_t type;
176     gcp_terms_t terms;
177     struct _gcp_msg_t* msg;
178     struct _gcp_trx_t* trx;
179     struct _gcp_ctx_t* ctx;
180     guint error;
181 } gcp_cmd_t;
182
183
184 typedef struct _gcp_ctx_t {
185     gcp_msg_t* initial;
186     guint32 id;
187         struct _gcp_cmd_msg_t* cmds;
188     struct _gcp_ctx_t* prev;
189     gcp_terms_t terms;
190 } gcp_ctx_t;
191
192 WS_VAR_IMPORT const value_string gcp_cmd_type[];
193 WS_VAR_IMPORT const value_string gcp_term_types[];
194
195 extern void gcp_init(void);
196 extern gcp_msg_t* gcp_msg(packet_info* pinfo, int o, gboolean persistent);
197 extern gcp_trx_t* gcp_trx(gcp_msg_t* m ,guint32 t_id , gcp_trx_type_t type, gboolean persistent);
198 extern gcp_ctx_t* gcp_ctx(gcp_msg_t* m, gcp_trx_t* t, guint32 c_id, gboolean persistent);
199 extern gcp_cmd_t* gcp_cmd(gcp_msg_t* m, gcp_trx_t* t, gcp_ctx_t* c, gcp_cmd_type_t type, guint offset, gboolean persistent);
200 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, gboolean persistent);
201 extern void gcp_analyze_msg(proto_tree* gcp_tree, tvbuff_t* gcp_tvb, gcp_msg_t* m, gcp_hf_ett_t* ids);
202
203 extern gchar* gcp_cmd_to_str(gcp_cmd_t* c, gboolean persistent);
204 extern gchar* gcp_msg_to_str(gcp_msg_t* m, gboolean persistent);
205
206 #define gcp_cmd_set_error(c,e) (c->error = e)
207 #define gcp_trx_set_error(t,e) (t->error = e)
208
209 #define GCP_ETT_ARR_ELEMS(gi)     &(gi.ett.ctx),&(gi.ett.ctx_cmds),&(gi.ett.ctx_terms),&(gi.ett.ctx_term)
210
211 #define GCP_HF_ARR_ELEMS(n,gi) \
212   { &(gi.hf.ctx), { "Context", n ".ctx", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL }}, \
213   { &(gi.hf.ctx_term), { "Termination", n ".ctx.term", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }}, \
214   { &(gi.hf.ctx_term_type), { "Type", n ".ctx.term.type", FT_UINT32, BASE_HEX, VALS(gcp_term_types), 0, "", HFILL }}, \
215   { &(gi.hf.ctx_term_bir), { "BIR", n ".ctx.term.bir", FT_STRING, BASE_HEX, NULL, 0, "", HFILL }}, \
216   { &(gi.hf.ctx_term_nsap), { "NSAP", n ".ctx.term.nsap", FT_STRING, BASE_NONE, NULL, 0, "", HFILL }}, \
217   { &(gi.hf.ctx_cmd), { "Command in Frame", n ".ctx.cmd", FT_FRAMENUM, BASE_DEC, NULL, 0, "", HFILL }}
218
219 #endif