This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

How to write a dissector for a protocol that runs on top of TCP or UDP both

0

I'm a long time developer who is new to wireshark. I'm actually trying to update the built in C12.22 dissector that is for TCP currently to also use UDP as well, everything else the same. If someone could just send me a new x64 1.8.6 asn1.dll that would be super awesome. If not please tell me how to setup a new dissector or modify the C12.22 dissector to use both TCP and UDP underneath. Thanks.

asked 30 Apr '13, 23:10

AceHack's gravatar image

AceHack
11113
accept rate: 0%

edited 30 Apr '13, 23:12


One Answer:

2

Raise a bug report, including a small sample trace to try a patch with.

A patch would look something like:

Index: asn1/c1222/packet-c1222-template.c
===================================================================
--- asn1/c1222/packet-c1222-template.c  (revision 49103)
+++ asn1/c1222/packet-c1222-template.c  (working copy)
@@ -79,6 +79,7 @@
 #define C1222_CMD_TIMING_SETUP 0x71

static dissector_handle_t c1222_handle=NULL; +static dissector_handle_t c1222_udp_handle=NULL;

/* Initialize the protocol and registered fields */ static int proto_c1222 = -1; @@ -993,7 +994,7 @@

  • \param tree */ static void -dissect_c1222_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +dissect_c1222_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *c1222_item = NULL; proto_tree *c1222_tree = NULL; @@ -1041,7 +1042,7 @@ dissect_c1222(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { tcp_dissect_pdus(tvb, pinfo, tree, c1222_desegment, 5,
  •       get_c1222_message_len, dissect_c1222_full);
    
  •       get_c1222_message_len, dissect_c1222_common);
    

}

/— proto_register_c1222 ——————————————-/ @@ -1328,7 +1329,9 @@

 if( !initialized ) {
     c1222_handle = create_dissector_handle(dissect_c1222, proto_c1222);
  •           c1222_udp_handle = create_dissector_handle(dissect_c1222_common,
    

proto_c1222); dissector_add_uint("tcp.port", global_c1222_port, c1222_handle);

  •    dissector_add_uint("udp.port", global_c1222_port, c1222_udp_handle);
       initialized = TRUE;
    
    } }

and regenerate the dissector(run nmake in the asn1/c1222 dir and then in top dir).

answered 01 May ‘13, 00:31

Anders's gravatar image

Anders ♦
4.6k952
accept rate: 17%

edited 01 May ‘13, 01:37

grahamb's gravatar image

grahamb ♦
19.8k330206

Comitted the patch in Committed revision 49104. (Related bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8620)

(01 May ‘13, 01:39) Anders ♦