Wireshark-dev: [Wireshark-dev] How to dissect bit information??

Date: Fri, 15 Dec 2006 13:47:32 +0530
Hello ,
 
While writing a dissector for my protocol I'm stuck up at a point .
The description of my problem is provided below :
    Suppose my packet is like :  
                    __________________________________________________________
                   |     7     |       6     |       5     |      4        |    3    |    2        |    1     |   0   |     Octet
                    ------------------------------------------------------------------------------------------------------
                   |     X     |                   Y                        |                Z                          |        1
                    ------------------------------------------------------------------------------------------------------
                   |               Number of Digits                                                               |        2
                    ------------------------------------------------------------------------------------------------------
                   |              digit 2                                  |            digit 1                        |        3
                    ------------------------------------------------------------------------------------------------------         
                   |             ..................................                                                       |     ...........
                    ------------------------------------------------------------------------------------------------------
                   |              digit 2n                                 |          digit 2n-1                    |        n+2
                    ----------------------------------------------------------------------------------------------------- 
 
I'm able to display the "digit" information using " proto_tree_add_string " function , but I'm not getting how to dissect octet 1 i.e X , Y and Z.
Reason for my confusion is that  the messages to be displayed depends upon the values of X , Y and Z .
Say the messages are as :    if X = 0 ; received 0 for X
                                              X = 1 ; received 1 for X
                                           if Y = 0 ; received y value as 0
                                              Y = 1 ; received y value as 1
                                              ............... and so on .
If I use  { &hf_protox_octet1 , {    "octet1 indicator",   "protox.octet1",       FT_UINT8,       BASE_DEC,       VALS(X),   0x0,    "",     HFILL }} and
    static const value_string X_values[] = {
     { 0, "received 0 for X" },
     { 1, "received 1 for X" },};
it gives the value of entire octet1 and NOT the value of X or Y or Z.
 
Please suggest how I may get the desired dissection .
Could you also explain in detail about the RANGE_STRING and the statement
length = tvb_length(tvb).
 
Regards ,
Vikash
 
 
 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com