Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Determine address type of string

From: "Maynard, Chris" <Christopher.Maynard@xxxxxxx>
Date: Mon, 9 Nov 2015 14:12:01 +0000
You could first call str_to_ip() and if it fails, call str_to_ip6(), and if that too fails then assume it's a FQDN.  The str_to_ip() and str_to_ip6() functions are just wrappers for inet_pton(); they are declared in epan/addr_resolv.h. 

- Chris

-----Original Message-----
From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Jo
Sent: Mon, November 09, 2015 4:14 AM
To: wireshark-dev@xxxxxxxxxxxxx
Subject: [Wireshark-dev] Determine address type of string

Hello,

I am writing a custom dissector as a plugin. There I need to determine the address type of a string in a TLV. It can be either an IPv4 address, IPv6 address or a FQDN.

What is the best way to parse this string into the Wireshark data types?

My idea was to check which delimieters occur ("." -> IPv4, ":" ->
IPv6) iand if there dots, to check whether the parts between the dots are numerical.

Bye,
Jo
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe


-- 



CONFIDENTIALITY NOTICE: This message is the property of International Game Technology PLC and/or its subsidiaries and may contain proprietary, confidential or trade secret information.  This message is intended solely for the use of the addressee.  If you are not the intended recipient and have received this message in error, please delete this message from your system. Any unauthorized reading, distribution, copying, or other use of this message or its attachments is strictly prohibited.