Wireshark-dev: Re: [Wireshark-dev] 4bytes to IP number (string)

From: "Anders Broman" <a.broman@xxxxxxxxx>
Date: Thu, 28 Aug 2008 18:36:59 +0200

Hi,

A few examples From README.developer

Accessors for IPv4 and IPv6 addresses:

 

guint32 tvb_get_ipv4(tvbuff_t*, gint offset);

void tvb_get_ipv6(tvbuff_t*, gint offset, struct e_in6_addr *addr);

 

NOTE: IPv4 addresses are not to be converted to host byte order before

being passed to "proto_tree_add_ipv4()".  You should use "tvb_get_ipv4()"

to fetch them, not "tvb_get_ntohl()" *OR* "tvb_get_letohl()" - don't,

for example, try to use "tvb_get_ntohl()", find that it gives you the

wrong answer on the PC on which you're doing development, and try

"tvb_get_letohl()" instead, as "tvb_get_letohl()" will give the wrong

answer on big-endian machines.

:

                      proto_item *

                      proto_tree_add_ipv4(tree, id, tvb, start, length, value);

 

                      proto_item *

                      proto_tree_add_ipv4_format(tree, id, tvb, start, length, value,

                          format, ...);

 

                      proto_item *

                      proto_tree_add_ipv4_format_value(tree, id, tvb, start, length,

                          value, format, ...);

Continue to search for IPv4

 

To just add it to the tre use proto_tree_add_item() and use FT_IPv4

 

Regards

Anders

 


Från: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] För Tom Stevens
Skickat: den 28 augusti 2008 18:28
Till: Wireshark-dev@xxxxxxxxxxxxx
Ämne: [Wireshark-dev] 4bytes to IP number (string)

 

Hi!


Is there a built-in function that converts 4 bytes to a string, according to the generally accepted IP Notation?
Example: C0 A8 D3 0D --->  192.168.211.13
Or, do i have to write my own function? Although it's not tough, but why reinvent the wheel?

Greetings Tom(Germany)