ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] help Ascii protocol

From: Pascal Quantin <pascal.quantin@xxxxxxxxx>
Date: Fri, 1 Feb 2019 19:07:14 +0100
Hi Anis,

Le ven. 1 févr. 2019 à 17:38, Anis Siad <anis.siad@xxxxxxxxxx> a écrit :

Hello,

 

So I need some help. I have ascii protocol (text based) but I don’t know how to dissect this protocol in C.

I explained the problem here: https://ask.wireshark.org/question/7093/ascii-dissector-non-constant-length/

 

So is there any function to transform a tvb into an ascii or string ? Or are they any function to split a tvb with a split liken “,”?


If you look at epan/tvbuff.h, you will find plenty of functions dedicated to string handling.
For example you can use tvb_find_guint8() to find the offset for the next comma. Or alternatively use tvb_get_string_enc() & co to fetch all the buffer in a single string from the tvb, and then wmem_strsplit() to get a list of tokens. I gues the tvb_get_guint8() + proto_tree_add_item for a FT_STRING field approach is probably the right one if you want to highlights the right bytes in the bytes view (but up to you, just explore our API in the file I mentionned).
Anders' advice was the right one: he pointed you text based dissectors that you can use to pick ideas. Parsing this NMEA command should be rather easy.

Best regards,
Pascal