Ethereal-dev: Re: [Ethereal-dev] Problem with val_to_str
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: "Ronnie Sahlberg" <ronnie_sahlberg@xxxxxxxxxxxxxx>
Date: Thu, 3 Jul 2003 21:52:55 +1000
You must end the value_strings with a terminator field {0, NULL} See below ----- Original Message ----- From: "Chua Wee Leng" Sent: Thursday, July 03, 2003 6:39 PM Subject: [Ethereal-dev] Problem with val_to_str > > I encounter a problem with val_to_str function while doing my plugin. I'm > surrently using ethereal-0.9.11 on RedHat Linux 7.3. > The following is part of my code of protocol dis in packet-dis.c > > #define ENTITY_STATE_PDU 1 > #define FIRE_PDU 2 > #define DETONATION_PDU 3 > #define START_RESUME_PDU 13 > #define STOP_FREEZE_PDU 14 > #define ACKNOWLEDGE_PDU 15 > #define SET_DATA_PDU 19 > #define DATA_PDU 20 > > const value_string pdu[] = { > {ENTITY_STATE_PDU, > "ENTITY_STATE_PDU"}, > {FIRE_PDU, "FIRE_PDU"}, > {DETONATION_PDU, "DETONATION_PDU"}, > {START_RESUME_PDU, > "START_RESUME_PDU"}, > {STOP_FREEZE_PDU, "STOP_FREEZE_PDU"}, > {ACKNOWLEDGE_PDU, "ACKNOWLEDGE_PDU"}, {0, NULL} > }; > > static const value_string vs_Entity_Kind[] = { > {1, "Platform"}, > {2, "Munition"}, > {4, "Environment"}, > {9, "Sensor/Emitter"}, {0, NULL} > }; > . > . > . > . > . > if (tree) { > /* Adding DIS item and subtree */ > dis_ti = proto_tree_add_item(tree, proto_dis, tvb, 0, > tvb_length(tvb), FALSE); > dis_tree = proto_item_add_subtree(dis_ti, ett_dis); > proto_tree_add_uint_format (dis_tree, hf_pdu_type, tvb, > offset, 1 , pdu_type, > "PDU TYPE : %s", val_to_str > (pdu_type, pdu, "Unknown (%u)")); //here I try to get string value of > pdu_type from value_string pdu > . > . > . > . > . > void > proto_register_dis(void) > { > static hf_register_info hf[] = { > { &hf_protocol_version, { > "Protocol Version", "dis.protocol_version", FT_UINT8, > BASE_DEC, NULL, 0x0, "", HFILL}}, > { &hf_exercise_id, { > "Exercise ID", "dis.exercise_id", FT_UINT8, BASE_DEC, > NULL, 0x0, "", HFILL}}, > { &hf_pdu_type, { > "PDU Type", "dis.pdu_type", FT_UINT8, BASE_DEC, NULL, > 0x0, "", HFILL}}, // Here it define hf_pdu_type > { &hf_protocol_family, { > "Protocol Family", "dis.protocol_family", FT_UINT8, > BASE_DEC, NULL, 0x0, "", HFILL}}, > . > > > What had happen is when there is a unknown pdy_type value, I will take a > value 9 as an example. Looking at the valid value under string_value pdu, 9 > is not inside the array of pdu, logically the decode value should be > "Unknown (%u)". From what I understand val_to_str (pdu_type, pdu, "Unknown > (%u)")), if pdu_type value is not found under pdu array, the third > argument of val_to_str will be displayed. But for my case here is show > "Sensor/Emitter" from the value_string array of vs_Entity_Kind[], as it is > the the next set of value_string array where value 9 can be found. In this > case, my plugin is not decode the right value for my application which it > leads to incorrect info to be display. > > I would like to know that is this an common error in val_to_str package. Is > there any solution to counter this problem. > Thanks > > > _______________________________________________________________ > Reduce the paperwork in your company with JustLogin's office collaborative > applications at http://www.justlogin.com > > _______________________________________________ > Ethereal-dev mailing list > Ethereal-dev@xxxxxxxxxxxx > http://www.ethereal.com/mailman/listinfo/ethereal-dev
- References:
- [Ethereal-dev] Problem with val_to_str
- From: Chua Wee Leng
- [Ethereal-dev] Problem with val_to_str
- Prev by Date: [Ethereal-dev] Problem with val_to_str
- Next by Date: [Ethereal-dev] H.245 requesting help
- Previous by thread: [Ethereal-dev] Problem with val_to_str
- Next by thread: [Ethereal-dev] H.245 requesting help
- Index(es):