Wireshark mailing list archives
dissection question
From: Brian Oleksa <oleksab () darkcornersoftware com>
Date: Tue, 16 Feb 2010 14:18:23 -0500
Hello All
What I am really looking to do is the following:
proto_tree_add_item(helen_sub_tree, hf_helen_routername, tvb, offset,
*sizeofroutername*, FALSE);
But putting in the "sizeofroutername" does not seem to work and does
indeed through off the rest of the packet.
When I "hardcode" the value (which in this case it is 2... as I can see
it in the hex dump window).. it appears to work ok....but I know that I
cannot hard code that value.
proto_tree_add_item(helen_sub_tree, hf_helen_routername, tvb, offset, 2,
FALSE);
Any thoughts..??
Code snippet is below
Thanks,
Brian
//Router Ext:
if (code == 1001) {
guint8 routercount;
guint8 interfacecount;
guint8 sizeofinterfacename;
guint8 sizeofroutername;
guint i;
guint k;
//router count
routercount = tvb_get_guint8(tvb, offset);
proto_tree_add_item(helen_sub_tree,
hf_helen_routerCount, tvb, offset, 1, FALSE);
offset += 1;
//Router Data
for (i = 0; i < routercount; i++) {
nstime_t t;
guint64 msecs_since_the_epoch;
struct tm *tmp;
//Size of router name
sizeofroutername = tvb_get_guint8(tvb, offset);
proto_tree_add_item(helen_sub_tree,
hf_helen_sizeofRouterName, tvb, offset, 2, FALSE);
offset += 2;
*Here is where the problem starts:*
//Router Name
//proto_tree_add_item(helen_sub_tree,
hf_helen_routername, tvb, offset, sizeofroutername, FALSE);
proto_tree_add_item(helen_sub_tree,
hf_helen_routername, tvb, offset, 2, FALSE);
offset += 2;
//offset += sizeofroutername;
//status
proto_tree_add_uint(helen_sub_tree,
hf_helen_routerstatus, tvb, offset, 1, FALSE);
offset += 1;
//update time
msecs_since_the_epoch = tvb_get_ntoh64(tvb, offset);
t.secs = msecs_since_the_epoch / 1000;
t.nsecs = (msecs_since_the_epoch %
1000)*1000000; /* milliseconds to nanoseconds */
tmp = gmtime(&t.secs);
proto_tree_add_time(helen_sub_tree,
hf_helen_time, tvb, offset, 8, &t);
offset += 8;
//cpu % used
proto_tree_add_uint(helen_sub_tree,
hf_helen_cpuusage, tvb, offset, 1, FALSE);
offset += 1;
//interface count
interfacecount = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(helen_sub_tree,
hf_helen_interface_count, tvb, offset, 1, FALSE);
offset += 1;
//Interface Data
for (k = 0; k < interfacecount; k++) {
proto_tree_add_item(helen_sub_tree,
hf_helen_sizeofInterfaceName, tvb, offset, 2, FALSE);
offset += 2;
//Interface Name
sizeofinterfacename = tvb_get_guint8(tvb,
offset);
proto_tree_add_item(helen_sub_tree,
hf_helen_interfacename, tvb, offset, 8, FALSE);
offset += sizeofinterfacename;
//incoming bytes
proto_tree_add_item(helen_sub_tree,
hf_helen_incomingBytes, tvb, offset, 4, FALSE);
offset += 4;
//outgoing bytes
proto_tree_add_item(helen_sub_tree,
hf_helen_outgoingBytes, tvb, offset, 4, FALSE);
offset += 4;
//interface active?
proto_tree_add_uint(helen_sub_tree,
hf_helen_interfaceActivity, tvb, offset, 1, FALSE);
offset += 1;
}
}
}
{ &hf_helen_routername,
{ "Router Name", "helen.routername", FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL}},
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- dissection question Brian Oleksa (Feb 16)
- Re: dissection question Guy Harris (Feb 16)
- Re: dissection question Brian Oleksa (Feb 16)
- Re: dissection question Guy Harris (Feb 16)
- Re: dissection question Brian Oleksa (Feb 16)
- Re: dissection question Jaap Keuter (Feb 16)
- Re: dissection question Guy Harris (Feb 16)
