checkAPIs.pl: support for new-style dissectors in check_hf_entries
[metze/wireshark/wip.git] / epan / dissectors / packet-exported_pdu.c
1 /* packet-exported_pdu.c
2  * Routines for exported_pdu dissection
3  * Copyright 2013, Anders Broman <anders-broman@ericsson.com>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11
12 #include "config.h"
13
14 #include <epan/packet.h>
15 #include <wiretap/wtap.h>
16 #include <epan/to_str.h>
17 #include <epan/address_types.h>
18 #include <epan/exported_pdu.h>
19 #include "packet-mtp3.h"
20 #include "packet-dvbci.h"
21 #include "packet-tcp.h"
22
23 void proto_register_exported_pdu(void);
24 void proto_reg_handoff_exported_pdu(void);
25
26 static int hf_ip_addr = -1;
27 static int hf_ip_dst = -1;
28 static int hf_ip_src = -1;
29 static int hf_ipv6_addr = -1;
30 static int hf_ipv6_dst = -1;
31 static int hf_ipv6_src = -1;
32
33 static int proto_exported_pdu = -1;
34 static int hf_exported_pdu_tag = -1;
35 static int hf_exported_pdu_tag_len = -1;
36 static int hf_exported_pdu_unknown_tag_val = -1;
37 static int hf_exported_pdu_prot_name = -1;
38 static int hf_exported_pdu_heur_prot_name = -1;
39 static int hf_exported_pdu_dis_table_name = -1;
40 static int hf_exported_pdu_dissector_data = -1;
41 static int hf_exported_pdu_ipv4_src = -1;
42 static int hf_exported_pdu_ipv4_dst = -1;
43 static int hf_exported_pdu_ipv6_src = -1;
44 static int hf_exported_pdu_ipv6_dst = -1;
45 static int hf_exported_pdu_port_type = -1;
46 static int hf_exported_pdu_src_port = -1;
47 static int hf_exported_pdu_dst_port = -1;
48 /** static int hf_exported_pdu_sctp_ppid = -1; **/
49 static int hf_exported_pdu_ss7_opc = -1;
50 static int hf_exported_pdu_ss7_dpc = -1;
51 static int hf_exported_pdu_orig_fno = -1;
52 static int hf_exported_pdu_dvbci_evt = -1;
53 static int hf_exported_pdu_exported_pdu = -1;
54 static int hf_exported_pdu_dis_table_val = -1;
55 static int hf_exported_pdu_col_proto_str = -1;
56
57 /* Initialize the subtree pointers */
58 static gint ett_exported_pdu = -1;
59 static gint ett_exported_pdu_tag = -1;
60
61 static int ss7pc_address_type = -1;
62
63 static dissector_handle_t exported_pdu_handle;
64
65 #define EXPORTED_PDU_NEXT_PROTO_STR      0
66 #define EXPORTED_PDU_NEXT_HEUR_PROTO_STR 1
67 #define EXPORTED_PDU_NEXT_DIS_TABLE_STR  2
68
69 static const value_string exported_pdu_tag_vals[] = {
70    { EXP_PDU_TAG_END_OF_OPT,       "End-of-options" },
71 /* 1 - 9 reserved */
72    { EXP_PDU_TAG_OPTIONS_LENGTH,        "Total length of the options excluding this TLV" },
73    { EXP_PDU_TAG_LINKTYPE,              "Linktype value" },
74    { EXP_PDU_TAG_PROTO_NAME,            "PDU content protocol name" },
75    { EXP_PDU_TAG_HEUR_PROTO_NAME,       "PDU content heuristic protocol name" },
76    { EXP_PDU_TAG_DISSECTOR_TABLE_NAME,  "PDU content dissector table name" },
77     /* Add protocol type related tags here */
78 /* 14 - 19 reserved */
79    { EXP_PDU_TAG_IPV4_SRC,              "IPv4 Source Address" },
80    { EXP_PDU_TAG_IPV4_DST,              "IPv4 Destination Address" },
81    { EXP_PDU_TAG_IPV6_SRC,              "IPv6 Source Address" },
82    { EXP_PDU_TAG_IPV6_DST,              "IPv6 Destination Address" },
83
84    { EXP_PDU_TAG_PORT_TYPE,             "Port Type" },
85    { EXP_PDU_TAG_SRC_PORT,              "Source Port" },
86    { EXP_PDU_TAG_DST_PORT,              "Destination Port" },
87
88    { EXP_PDU_TAG_SS7_OPC,               "SS7 OPC" },
89    { EXP_PDU_TAG_SS7_DPC,               "SS7 DPC" },
90
91    { EXP_PDU_TAG_ORIG_FNO,              "Original Frame number" },
92
93    { EXP_PDU_TAG_DVBCI_EVT,             "DVB-CI event" },
94    { EXP_PDU_TAG_DISSECTOR_TABLE_NAME_NUM_VAL,  "Dissector table value" },
95    { EXP_PDU_TAG_COL_PROT_TEXT,         "Column Protocol String" },
96    { EXP_PDU_TAG_TCP_INFO_DATA,         "TCP Dissector Data" },
97
98    { 0,        NULL   }
99 };
100
101 static const value_string exported_pdu_port_type_vals[] = {
102    { OLD_PT_NONE,     "NONE" },
103    { OLD_PT_SCTP,     "SCTP" },
104    { OLD_PT_TCP,      "TCP" },
105    { OLD_PT_UDP,      "UDP" },
106    { OLD_PT_DCCP,     "DCCP" },
107    { OLD_PT_IPX,      "IPX" },
108    { OLD_PT_NCP,      "NCP" },
109    { OLD_PT_EXCHG,    "FC EXCHG" },
110    { OLD_PT_DDP,      "DDP" },
111    { OLD_PT_SBCCS,    "FICON SBCCS" },
112    { OLD_PT_IDP,      "IDP" },
113    { OLD_PT_TIPC,     "TIPC" },
114    { OLD_PT_USB,      "USB" },
115    { OLD_PT_I2C,      "I2C" },
116    { OLD_PT_IBQP,     "IBQP" },
117    { OLD_PT_BLUETOOTH,"BLUETOOTH" },
118    { OLD_PT_TDMOP,    "TDMOP" },
119
120    { 0,        NULL   }
121 };
122
123 static port_type exp_pdu_old_to_new_port_type(guint type)
124 {
125     switch (type)
126     {
127     case OLD_PT_NONE:
128         return PT_NONE;
129     case OLD_PT_SCTP:
130         return PT_SCTP;
131     case OLD_PT_TCP:
132         return PT_TCP;
133     case OLD_PT_UDP:
134         return PT_UDP;
135     case OLD_PT_DCCP:
136         return PT_DCCP;
137     case OLD_PT_IPX:
138         return PT_IPX;
139     case OLD_PT_DDP:
140         return PT_DDP;
141     case OLD_PT_IDP:
142         return PT_IDP;
143     case OLD_PT_USB:
144         return PT_USB;
145     case OLD_PT_I2C:
146         return PT_I2C;
147     case OLD_PT_IBQP:
148         return PT_IBQP;
149     case OLD_PT_BLUETOOTH:
150         return PT_BLUETOOTH;
151     case OLD_PT_EXCHG:
152     case OLD_PT_TIPC:
153     case OLD_PT_TDMOP:
154     case OLD_PT_NCP:
155     case OLD_PT_SBCCS:
156         //no longer supported
157         break;
158     }
159
160     DISSECTOR_ASSERT(FALSE);
161     return PT_NONE;
162 }
163
164 /* Code to actually dissect the packets */
165 static int
166 dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
167 {
168     proto_item *exported_pdu_ti, *ti, *item;
169     proto_tree *exported_pdu_tree, *tag_tree;
170     tvbuff_t * payload_tvb = NULL;
171     int offset = 0;
172     guint16 tag;
173     int tag_len;
174     int next_proto_type = -1;
175     const guint8 *proto_name = NULL;
176     const guint8 *dissector_table = NULL;
177     const guint8 *col_proto_str = NULL;
178     dissector_handle_t proto_handle;
179     mtp3_addr_pc_t *mtp3_addr;
180     guint8 dvb_ci_dir;
181     guint32 dissector_table_val=0;
182     dissector_table_t dis_tbl;
183     void* dissector_data = NULL;
184
185     col_set_str(pinfo->cinfo, COL_PROTOCOL, "Exported PDU");
186
187     /* create display subtree for the protocol */
188     exported_pdu_ti = proto_tree_add_item(tree, proto_exported_pdu, tvb, offset, -1, ENC_NA);
189     exported_pdu_tree = proto_item_add_subtree(exported_pdu_ti, ett_exported_pdu);
190
191     do {
192         tag = tvb_get_ntohs(tvb, offset);
193         ti = proto_tree_add_item(exported_pdu_tree, hf_exported_pdu_tag, tvb, offset, 2, ENC_BIG_ENDIAN);
194         offset+=2;
195         tag_tree = proto_item_add_subtree(ti, ett_exported_pdu_tag);
196         proto_tree_add_item(tag_tree, hf_exported_pdu_tag_len, tvb, offset, 2, ENC_BIG_ENDIAN);
197         tag_len = tvb_get_ntohs(tvb, offset);
198         proto_item_set_len(ti, 4 + tag_len);
199         offset+=2;
200
201         switch(tag) {
202             case EXP_PDU_TAG_PROTO_NAME:
203                 next_proto_type = EXPORTED_PDU_NEXT_PROTO_STR;
204                 proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &proto_name);
205                 break;
206             case EXP_PDU_TAG_HEUR_PROTO_NAME:
207                 next_proto_type = EXPORTED_PDU_NEXT_HEUR_PROTO_STR;
208                 proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_heur_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &proto_name);
209                 break;
210             case EXP_PDU_TAG_DISSECTOR_TABLE_NAME:
211                 next_proto_type = EXPORTED_PDU_NEXT_DIS_TABLE_STR;
212                 proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_dis_table_name, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA, wmem_packet_scope(), &dissector_table);
213                 break;
214             case EXP_PDU_TAG_IPV4_SRC:
215                 proto_tree_add_item(tag_tree, hf_exported_pdu_ipv4_src, tvb, offset, 4, ENC_BIG_ENDIAN);
216                 /* You can filter on IP by right clicking the Source/Destination columns make that work by filling the IP hf:s*/
217                 item = proto_tree_add_item(tag_tree, hf_ip_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
218                 PROTO_ITEM_SET_HIDDEN(item);
219                 item = proto_tree_add_item(tag_tree, hf_ip_src, tvb, offset, 4, ENC_BIG_ENDIAN);
220                 PROTO_ITEM_SET_HIDDEN(item);
221
222                 set_address_tvb(&pinfo->net_src, AT_IPv4, 4, tvb, offset);
223                 copy_address_shallow(&pinfo->src, &pinfo->net_src);
224                 break;
225             case EXP_PDU_TAG_IPV4_DST:
226                 proto_tree_add_item(tag_tree, hf_exported_pdu_ipv4_dst, tvb, offset, 4, ENC_BIG_ENDIAN);
227                 /* You can filter on IP by right clicking the Source/Destination columns make that work by filling the IP hf:s*/
228                 item = proto_tree_add_item(tag_tree, hf_ip_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
229                 PROTO_ITEM_SET_HIDDEN(item);
230                 item = proto_tree_add_item(tag_tree, hf_ip_dst, tvb, offset, 4, ENC_BIG_ENDIAN);
231                 PROTO_ITEM_SET_HIDDEN(item);
232                 set_address_tvb(&pinfo->net_dst, AT_IPv4, 4, tvb, offset);
233                 copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
234                 break;
235             case EXP_PDU_TAG_IPV6_SRC:
236                 proto_tree_add_item(tag_tree, hf_exported_pdu_ipv6_src, tvb, offset, 16, ENC_NA);
237                 /* You can filter on IP by right clicking the Source/Destination columns make that work by filling the IP hf:s*/
238                 item = proto_tree_add_item(tag_tree, hf_ipv6_addr, tvb, offset, 16, ENC_BIG_ENDIAN);
239                 PROTO_ITEM_SET_HIDDEN(item);
240                 item = proto_tree_add_item(tag_tree, hf_ipv6_src, tvb, offset, 16, ENC_BIG_ENDIAN);
241                 PROTO_ITEM_SET_HIDDEN(item);
242                 set_address_tvb(&pinfo->net_src, AT_IPv6, 16, tvb, offset);
243                 copy_address_shallow(&pinfo->src, &pinfo->net_src);
244                 break;
245             case EXP_PDU_TAG_IPV6_DST:
246                 proto_tree_add_item(tag_tree, hf_exported_pdu_ipv6_dst, tvb, offset, 16, ENC_NA);
247                 /* You can filter on IP by right clicking the Source/Destination columns make that work by filling the IP hf:s*/
248                 item = proto_tree_add_item(tag_tree, hf_ipv6_addr, tvb, offset, 16, ENC_BIG_ENDIAN);
249                 PROTO_ITEM_SET_HIDDEN(item);
250                 item = proto_tree_add_item(tag_tree, hf_ipv6_dst, tvb, offset, 16, ENC_BIG_ENDIAN);
251                 PROTO_ITEM_SET_HIDDEN(item);
252                 set_address_tvb(&pinfo->net_dst, AT_IPv6, 16, tvb, offset);
253                 copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
254                 break;
255             case EXP_PDU_TAG_PORT_TYPE:
256                 pinfo->ptype = exp_pdu_old_to_new_port_type(tvb_get_ntohl(tvb, offset));
257                 proto_tree_add_item(tag_tree, hf_exported_pdu_port_type, tvb, offset, 4, ENC_BIG_ENDIAN);
258                 break;
259             case EXP_PDU_TAG_SRC_PORT:
260                 proto_tree_add_item(tag_tree, hf_exported_pdu_src_port, tvb, offset, 4, ENC_BIG_ENDIAN);
261                 pinfo->srcport = tvb_get_ntohl(tvb, offset);
262                 break;
263             case EXP_PDU_TAG_DST_PORT:
264                 proto_tree_add_item(tag_tree, hf_exported_pdu_dst_port, tvb, offset, 4, ENC_BIG_ENDIAN);
265                 pinfo->destport = tvb_get_ntohl(tvb, offset);
266                 break;
267             case EXP_PDU_TAG_SS7_OPC:
268                 proto_tree_add_item(tag_tree, hf_exported_pdu_ss7_opc, tvb, offset, 4, ENC_BIG_ENDIAN);
269                 mtp3_addr = (mtp3_addr_pc_t *)wmem_alloc0(pinfo->pool, sizeof(mtp3_addr_pc_t));
270                 mtp3_addr->pc = tvb_get_ntohl(tvb, offset);
271                 mtp3_addr->type = (Standard_Type)tvb_get_ntohs(tvb, offset+4);
272                 mtp3_addr->ni = tvb_get_guint8(tvb, offset+6);
273                 set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr);
274                 break;
275             case EXP_PDU_TAG_SS7_DPC:
276                 proto_tree_add_item(tag_tree, hf_exported_pdu_ss7_dpc, tvb, offset, 4, ENC_BIG_ENDIAN);
277                 mtp3_addr = (mtp3_addr_pc_t *)wmem_alloc0(pinfo->pool, sizeof(mtp3_addr_pc_t));
278                 mtp3_addr->pc = tvb_get_ntohl(tvb, offset);
279                 mtp3_addr->type = (Standard_Type)tvb_get_ntohs(tvb, offset+4);
280                 mtp3_addr->ni = tvb_get_guint8(tvb, offset+6);
281                 set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr);
282                 break;
283             case EXP_PDU_TAG_ORIG_FNO:
284                 proto_tree_add_item(tag_tree, hf_exported_pdu_orig_fno, tvb, offset, 4, ENC_BIG_ENDIAN);
285                 break;
286             case EXP_PDU_TAG_DVBCI_EVT:
287                 dvb_ci_dir = tvb_get_guint8(tvb, offset);
288                 proto_tree_add_item(tag_tree, hf_exported_pdu_dvbci_evt,
289                         tvb, offset, 1, ENC_BIG_ENDIAN);
290                 dvbci_set_addrs(dvb_ci_dir, pinfo);
291                 break;
292             case EXP_PDU_TAG_DISSECTOR_TABLE_NAME_NUM_VAL:
293                 dissector_table_val = tvb_get_ntohl(tvb, offset);
294                 proto_tree_add_item(tag_tree, hf_exported_pdu_dis_table_val, tvb, offset, 4, ENC_BIG_ENDIAN);
295                 break;
296             case EXP_PDU_TAG_COL_PROT_TEXT:
297                 proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_col_proto_str, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA, wmem_packet_scope(), &col_proto_str);
298                 break;
299             case EXP_PDU_TAG_TCP_INFO_DATA:
300                 {
301                 struct tcpinfo* tcpdata = wmem_new0(wmem_packet_scope(), struct tcpinfo);
302                 guint16 version;
303                 proto_tree_add_item(tag_tree, hf_exported_pdu_dissector_data, tvb, offset, tag_len, ENC_NA);
304
305                 version = tvb_get_ntohs(tvb, offset);
306                 DISSECTOR_ASSERT(version == 1); /* Only version 1 is currently supported */
307
308                 tcpdata->seq = tvb_get_ntohl(tvb, offset+2);
309                 tcpdata->nxtseq = tvb_get_ntohl(tvb, offset+6);
310                 tcpdata->lastackseq = tvb_get_ntohl(tvb, offset+10);
311                 tcpdata->is_reassembled = tvb_get_guint8(tvb, offset+14);
312                 tcpdata->flags = tvb_get_ntohs(tvb, offset+15);
313                 tcpdata->urgent_pointer = tvb_get_ntohs(tvb, offset+17);
314
315                 dissector_data = tcpdata;
316                 }
317                 break;
318             case EXP_PDU_TAG_END_OF_OPT:
319                 break;
320             default:
321                 proto_tree_add_item(tag_tree, hf_exported_pdu_unknown_tag_val, tvb, offset, tag_len, ENC_NA);
322                 /* Add an expert item too? */
323                 break;
324         }
325
326         offset = offset + tag_len;
327
328     } while(tag != 0);
329
330     /* Limit the Exported PDU tree to the tags without payload. */
331     proto_item_set_len(exported_pdu_ti, offset);
332
333     payload_tvb = tvb_new_subset_remaining(tvb, offset);
334     proto_tree_add_item(exported_pdu_tree, hf_exported_pdu_exported_pdu, payload_tvb, 0, -1, ENC_NA);
335
336     switch(next_proto_type) {
337         case EXPORTED_PDU_NEXT_PROTO_STR:
338             proto_handle = find_dissector(proto_name);
339             if (proto_handle) {
340                 if (col_proto_str) {
341                     col_add_str(pinfo->cinfo, COL_PROTOCOL, col_proto_str);
342                 } else {
343                     col_clear(pinfo->cinfo, COL_PROTOCOL);
344                 }
345                 call_dissector_with_data(proto_handle, payload_tvb, pinfo, tree, dissector_data);
346             }
347             break;
348         case EXPORTED_PDU_NEXT_HEUR_PROTO_STR:
349         {
350             heur_dtbl_entry_t *heur_diss = find_heur_dissector_by_unique_short_name(proto_name);
351             if (heur_diss) {
352                 if (col_proto_str) {
353                     col_add_str(pinfo->cinfo, COL_PROTOCOL, col_proto_str);
354                 } else {
355                     col_clear(pinfo->cinfo, COL_PROTOCOL);
356                 }
357                 call_heur_dissector_direct(heur_diss, payload_tvb, pinfo, tree, dissector_data);
358             }
359             break;
360         }
361         case EXPORTED_PDU_NEXT_DIS_TABLE_STR:
362         {
363             dis_tbl = find_dissector_table(dissector_table);
364             if (dis_tbl) {
365                 if (col_proto_str) {
366                     col_add_str(pinfo->cinfo, COL_PROTOCOL, col_proto_str);
367                 } else {
368                     col_clear(pinfo->cinfo, COL_PROTOCOL);
369                 }
370                 dissector_try_uint_new(dis_tbl, dissector_table_val, payload_tvb, pinfo, tree, FALSE, dissector_data);
371             }
372         }
373         default:
374             break;
375     }
376
377     return tvb_captured_length(tvb);
378 }
379
380 /* Register the protocol with Wireshark.
381  *
382  */
383 void
384 proto_register_exported_pdu(void)
385 {
386     /*module_t *exported_pdu_module;*/
387
388     static hf_register_info hf[] = {
389         { &hf_exported_pdu_tag,
390             { "Tag", "exported_pdu.tag",
391                FT_UINT16, BASE_DEC, VALS(exported_pdu_tag_vals), 0,
392               NULL, HFILL }
393         },
394         { &hf_exported_pdu_tag_len,
395             { "Length", "exported_pdu.tag_len",
396                FT_UINT16, BASE_DEC, NULL, 0,
397               NULL, HFILL }
398         },
399         { &hf_exported_pdu_unknown_tag_val,
400             { "Unknown tags value", "exported_pdu.unknown_tag.val",
401                FT_BYTES, BASE_NONE, NULL, 0,
402               NULL, HFILL }
403         },
404         { &hf_exported_pdu_prot_name,
405             { "Protocol Name", "exported_pdu.prot_name",
406                FT_STRING, BASE_NONE, NULL, 0,
407               NULL, HFILL }
408         },
409         { &hf_exported_pdu_heur_prot_name,
410             { "Heuristic Protocol Name", "exported_pdu.heur_prot_name",
411                FT_STRING, BASE_NONE, NULL, 0,
412               NULL, HFILL }
413         },
414         { &hf_exported_pdu_dis_table_name,
415             { "Dissector Table Name", "exported_pdu.dis_table_name",
416                FT_STRING, BASE_NONE, NULL, 0,
417               NULL, HFILL }
418         },
419         { &hf_exported_pdu_dissector_data,
420             { "Dissector Data", "exported_pdu.dissector_data",
421                FT_BYTES, BASE_NONE, NULL, 0,
422               NULL, HFILL }
423         },
424         { &hf_exported_pdu_ipv4_src,
425             { "IPv4 Src", "exported_pdu.ipv4_src",
426                FT_IPv4, BASE_NONE, NULL, 0,
427               NULL, HFILL }
428         },
429         { &hf_exported_pdu_ipv4_dst,
430             { "IPv4 Dst", "exported_pdu.ipv4_dst",
431                FT_IPv4, BASE_NONE, NULL, 0,
432               NULL, HFILL }
433         },
434         { &hf_exported_pdu_ipv6_src,
435             { "IPv6 Src", "exported_pdu.ipv6_src",
436                FT_IPv6, BASE_NONE, NULL, 0,
437               NULL, HFILL }
438         },
439         { &hf_exported_pdu_ipv6_dst,
440             { "IPv6 Dst", "exported_pdu.ipv6_dst",
441                FT_IPv6, BASE_NONE, NULL, 0,
442               NULL, HFILL }
443         },
444         { &hf_exported_pdu_port_type,
445             { "Port Type", "exported_pdu.port_type",
446                FT_UINT32, BASE_DEC, VALS(exported_pdu_port_type_vals), 0,
447               NULL, HFILL }
448         },
449         { &hf_exported_pdu_src_port,
450             { "Src Port", "exported_pdu.src_port",
451                FT_UINT32, BASE_DEC, NULL, 0,
452               NULL, HFILL }
453         },
454         { &hf_exported_pdu_dst_port,
455             { "Dst Port", "exported_pdu.dst_port",
456                FT_UINT32, BASE_DEC, NULL, 0,
457               NULL, HFILL }
458         },
459         { &hf_exported_pdu_ss7_opc,
460             { "SS7 OPC", "exported_pdu.ss7_opc",
461                FT_UINT32, BASE_DEC, NULL, 0,
462               NULL, HFILL }
463         },
464         { &hf_exported_pdu_ss7_dpc,
465             { "SS7 DPC", "exported_pdu.ss7_dpc",
466                FT_UINT32, BASE_DEC, NULL, 0,
467               NULL, HFILL }
468         },
469         { &hf_exported_pdu_orig_fno,
470             { "Original Frame Number", "exported_pdu.orig_fno",
471                FT_UINT32, BASE_DEC, NULL, 0,
472               NULL, HFILL }
473         },
474         { &hf_exported_pdu_dvbci_evt,
475             { "DVB-CI event", "exported_pdu.dvb-ci.event",
476                FT_UINT8, BASE_HEX, VALS(dvbci_event), 0,
477               NULL, HFILL }
478         },
479         { &hf_exported_pdu_exported_pdu,
480             { "Exported PDU", "exported_pdu.exported_pdu",
481                FT_BYTES, BASE_NONE, NULL, 0,
482               NULL, HFILL }
483         },
484         { &hf_exported_pdu_dis_table_val,
485             { "Value to use when calling dissector table", "exported_pdu.dis_table_val",
486                FT_UINT32, BASE_DEC, NULL, 0,
487               NULL, HFILL }
488         },
489         { &hf_exported_pdu_col_proto_str,
490             { "Column protocol string", "exported_pdu.col_proto_str",
491                FT_STRING, BASE_NONE, NULL, 0,
492               NULL, HFILL }
493         },
494     };
495
496     /* Setup protocol subtree array */
497     static gint *ett[] = {
498         &ett_exported_pdu,
499         &ett_exported_pdu_tag
500     };
501
502     /* Register the protocol name and description */
503     proto_exported_pdu = proto_register_protocol("EXPORTED_PDU",
504             "exported_pdu", "exported_pdu");
505
506     exported_pdu_handle = register_dissector("exported_pdu", dissect_exported_pdu, proto_exported_pdu);
507
508     /* Required function calls to register the header fields and subtrees */
509     proto_register_field_array(proto_exported_pdu, hf, array_length(hf));
510     proto_register_subtree_array(ett, array_length(ett));
511
512     /* Register for tapping
513      * The tap is registered here but it is to be used by dissectors that
514      * want to export their PDUs, see packet-sip.c
515      */
516     register_export_pdu_tap(EXPORT_PDU_TAP_NAME_LAYER_3);
517     register_export_pdu_tap(EXPORT_PDU_TAP_NAME_LAYER_4);
518     register_export_pdu_tap(EXPORT_PDU_TAP_NAME_LAYER_7);
519 }
520
521 void
522 proto_reg_handoff_exported_pdu(void)
523 {
524     static gboolean initialized = FALSE;
525
526     if (!initialized) {
527         dissector_add_uint("wtap_encap", WTAP_ENCAP_WIRESHARK_UPPER_PDU, exported_pdu_handle);
528         initialized = TRUE;
529     }
530
531     ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
532
533     /* Get the hf id of some fields from the IP dissectors to be able to use them here*/
534     hf_ip_addr    = proto_registrar_get_id_byname("ip.addr");
535     hf_ip_dst     = proto_registrar_get_id_byname("ip.dst");
536     hf_ip_src     = proto_registrar_get_id_byname("ip.src");
537     hf_ipv6_addr  = proto_registrar_get_id_byname("ipv6.src");
538     hf_ipv6_dst   = proto_registrar_get_id_byname("ipv6.dst");
539     hf_ipv6_src   = proto_registrar_get_id_byname("ipv6.src");
540 }
541
542
543 /*
544  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
545  *
546  * Local variables:
547  * c-basic-offset: 4
548  * tab-width: 8
549  * indent-tabs-mode: nil
550  * End:
551  *
552  * vi: set shiftwidth=4 tabstop=8 expandtab:
553  * :indentSize=4:tabSize=8:noTabs=true:
554  */