Put the IGMP type field value into the PIM tree, as is done for other
[obnox/wireshark/wip.git] / packet-wtp.c
index 84f404635bd5bbe16e7df6025ad4199e960065db..3b5143f79fcd3c76bb91f342534c1110f9eb8a37 100644 (file)
@@ -1,14 +1,17 @@
-/* packet-wtp.c (c) 2000 Neil Hunter
- * Base on original work by Ben Fowler
+/* packet-wtp.c
  *
  * Routines to dissect WTP component of WAP traffic.
  * 
- * $Id: packet-wtp.c,v 1.10 2001/01/22 08:03:46 guy Exp $
+ * $Id: packet-wtp.c,v 1.14 2001/06/18 02:17:54 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
  * Copyright 1998 Didier Jorand
  *
+ * WAP dissector based on original work by Ben Fowler
+ * Updated by Neil Hunter <neil.hunter@energis-squared.com>
+ * WTLS support by Alexandre P. Ferreira (Splice IP)
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -167,6 +170,7 @@ static int hf_wtp_header_missing_packets            = HF_EMPTY;
 static gint ett_wtp                                                    = ETT_EMPTY;
 static gint ett_header                                                         = ETT_EMPTY;
 
+/* Handle for WSP dissector */
 static dissector_handle_t wsp_handle;
 
 /* Declarations */
@@ -239,7 +243,8 @@ dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        pdut = pdu_type( b0 );
 
        /* Develop the string to put in the Info column */
-       cchInfo = snprintf( szInfo, sizeof( szInfo ), "WTP %s", vals_pdu_type[ ( int )pdut ].strptr  );
+       cchInfo = snprintf( szInfo, sizeof( szInfo ), "WTP %s",
+           val_to_str(pdut, vals_pdu_type, "Unknown PDU type 0x%x"));
 
        switch( pdut ) {
                case INVOKE:
@@ -424,10 +429,12 @@ dissect_wtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 #endif
        }
                
-       /* Any remaining data ought to be WSP data, so hand off to the WSP dissector */
+       /* Any remaining data ought to be WSP data,
+        * so hand off to the WSP dissector */
        if (tvb_reported_length (tvb) > cbHeader)
        {
-               wsp_tvb = tvb_new_subset(tvb, cbHeader, -1, tvb_reported_length (tvb)-cbHeader);
+               wsp_tvb = tvb_new_subset(tvb, cbHeader, -1,
+                       tvb_reported_length (tvb)-cbHeader);
                call_dissector(wsp_handle, wsp_tvb, pinfo, tree);
        }
 
@@ -451,8 +458,17 @@ static char transaction_class(unsigned char octet)
 
 static char retransmission_indicator(unsigned char octet)
 {
-       char ch = (octet >> 0) & 0x01; /* ......,X */
-       return ch;
+       switch ( pdu_type(octet) ) {
+               case INVOKE:
+               case RESULT:
+               case ACK:
+               case SEGMENTED_INVOKE:
+               case SEGMENTED_RESULT:
+               case NEGATIVE_ACK:
+                       return (octet >> 0) & 0x01; /* ......,X */
+               default:
+                       return 0;
+       }
 };
 
 /* Register the protocol with Ethereal */
@@ -466,105 +482,105 @@ proto_register_wtp(void)
                        {       "Header",           
                                "wtp.header_fixed_part",
                                FT_BYTES, BASE_HEX, NULL, 0x0,          
-                               "Fixed part of the header" 
+                               "Fixed part of the header", HFILL
                        }
                },
                { &hf_wtp_header_flag_continue,
                        {       "Continue Flag",           
-                               "wtp.continue-flag",
+                               "wtp.continue_flag",
                                FT_BOOLEAN, 8, TFS( &continue_truth ), 0x80,          
-                               "Continue Flag" 
+                               "Continue Flag", HFILL
                        }
                },
                { &hf_wtp_header_pdu_type,
                        {       "PDU Type",           
-                               "wtp.pdu-type",
+                               "wtp.pdu_type",
                                 FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x78,
-                               "PDU Type" 
+                               "PDU Type", HFILL
                        }
                },
                { &hf_wtp_header_flag_Trailer,
                        {       "Trailer Flags",           
-                               "wtp.trailer-flags",
+                               "wtp.trailer_flags",
                                 FT_UINT8, BASE_HEX, VALS( vals_transmission_trailer ), 0x06,
-                               "PDU Type" 
+                               "PDU Type", HFILL
                        }
                },
                { &hf_wtp_header_flag_RID,
                        {       "Re-transmission Indicator",           
                                "wtp.RID",
                                 FT_BOOLEAN, 8, TFS( &RID_truth ), 0x01,
-                               "Re-transmission Indicator" 
+                               "Re-transmission Indicator", HFILL
                        }
                },
                { &hf_wtp_header_flag_TID_response,
                        {       "TID Response",           
                                "wtp.TID.response",
                                FT_BOOLEAN, 16, TFS( &tid_response_truth ), 0x8000,
-                               "TID Response" 
+                               "TID Response", HFILL
                        }
                },
                { &hf_wtp_header_flag_TID,
                        {       "Transmission ID",           
                                "wtp.TID",
                                 FT_UINT16, BASE_HEX, NULL, 0x7FFF,
-                               "Transmission ID" 
+                               "Transmission ID", HFILL
                        }
                },
                { &hf_wtp_header_Inv_version,
                        {       "Version",           
                                "wtp.header.version",
                                 FT_UINT8, BASE_HEX, VALS( vals_version ), 0xC0,
-                               "Version" 
+                               "Version", HFILL
                        }
                },
                { &hf_wtp_header_Inv_flag_TIDNew,
                        {       "TIDNew",           
                                "wtp.header.TIDNew",
                                 FT_BOOLEAN, 8, TFS( &TIDNew_truth ), 0x20,
-                               "TIDNew" 
+                               "TIDNew", HFILL
                        }
                },
                { &hf_wtp_header_Inv_flag_UP,
                        {       "U/P flag",           
                                "wtp.header.UP",
                                 FT_BOOLEAN, 8, TFS( &UP_truth ), 0x10,
-                               "U/P Flag" 
+                               "U/P Flag", HFILL
                        }
                },
                { &hf_wtp_header_Inv_Reserved,
                        {       "Reserved",           
                                "wtp.inv.reserved",
                                 FT_UINT8, BASE_HEX, NULL, 0x0C,
-                               "Reserved" 
+                               "Reserved", HFILL
                        }
                },
                { &hf_wtp_header_Inv_TransactionClass,
                        {       "Transaction Class",           
-                               "wtp.inv.transaction-class",
+                               "wtp.inv.transaction_class",
                                 FT_UINT8, BASE_HEX, NULL, 0x03,
-                               "Transaction Class" 
+                               "Transaction Class", HFILL
                        }
                },
                { &hf_wtp_header_Ack_flag_TVETOK,
                        {       "Tve/Tok flag",           
                                "wtp.ack.tvetok",
                                 FT_BOOLEAN, 8, TFS( &TVETOK_truth ), 0x04,
-                               "Tve/Tok flag"
+                               "Tve/Tok flag", HFILL
                        }
                },
                { &hf_wtp_header_Abort_type,
                        {       "Abort Type",           
                                "wtp.abort.type",
                                 FT_UINT8, BASE_HEX, VALS ( vals_abort_type ), 0x07,
-                               "Abort Type" 
+                               "Abort Type", HFILL
                        }
                },
                { &hf_wtp_header_Abort_reason_provider,
                        {       "Abort Reason",           
                                "wtp.abort.reason.provider",
                                 FT_UINT8, BASE_HEX, VALS ( vals_abort_reason_provider ), 0x00,
-                               "Abort Reason" 
+                               "Abort Reason", HFILL
                        }
                },
                /* Assume WSP is the user and use its reason codes */
@@ -572,35 +588,35 @@ proto_register_wtp(void)
                        {       "Abort Reason",           
                                "wtp.abort.reason.user",
                                 FT_UINT8, BASE_HEX, VALS ( vals_wsp_reason_codes ), 0x00,
-                               "Abort Reason" 
+                               "Abort Reason", HFILL
                        }
                },
                { &hf_wtp_header_sequence_number,
                        {       "Packet Sequence Number",           
                                "wtp.header.sequence",
                                 FT_UINT8, BASE_HEX, NULL, 0x00,
-                               "Packet Sequence Number" 
+                               "Packet Sequence Number", HFILL
                        }
                },
                { &hf_wtp_header_missing_packets,
                        {       "Missing Packets",           
                                "wtp.header.missing_packets",
                                 FT_UINT8, BASE_HEX, NULL, 0x00,
-                               "Missing Packets" 
+                               "Missing Packets", HFILL
                        }
                },
                { &hf_wtp_header_variable_part,
                        {       "Header: Variable part",           
                                "wtp.header_variable_part",
                                FT_BYTES, BASE_HEX, NULL, 0x0,          
-                               "Variable part of the header" 
+                               "Variable part of the header", HFILL
                        }
                },
                { &hf_wtp_data,
                        {       "Data",           
                                "wtp.header_data",
                                FT_BYTES, BASE_HEX, NULL, 0x0,          
-                               "Data" 
+                               "Data", HFILL
                        }
                },
        };
@@ -615,7 +631,7 @@ proto_register_wtp(void)
        proto_wtp = proto_register_protocol(
                "Wireless Transaction Protocol",   /* protocol name for use by ethereal */ 
                "WTP",                             /* short version of name */
-               "wap-wsp-wtp"                    /* Abbreviated protocol name, should Match IANA 
+               "wap-wsp-wtp"                      /* Abbreviated protocol name, should Match IANA 
                                                    < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
                                                  */
        );
@@ -629,10 +645,9 @@ void
 proto_reg_handoff_wtp(void)
 {
        /*
-        * Get a handle for the IP WSP dissector.
+        * Get a handle for the IP WSP dissector - if WTP PDUs have data, it is WSP
         */
        wsp_handle = find_dissector("wsp");
 
        dissector_add("udp.port", UDP_PORT_WTP_WSP, dissect_wtp, proto_wtp);
-       /* dissector_add("udp.port", UDP_PORT_WTLS_WTP_WSP, dissect_wtp, proto_wtp); */
 }