Remove a bunch of duplicate semicolons.
[obnox/wireshark/wip.git] / packet-gtp.c
index 6125a72de9bb088e566d2b785b7eecb7806a0d4c..2a31e0f7f6d792759898a3269a4bea605cb98fcc 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright 2001, Michal Melerowicz <michal.melerowicz@nokia.com>
  *                 Nicolas Balkota <balkota@mac.com>
  *
- * $Id: packet-gtp.c,v 1.55 2003/07/09 07:12:23 guy Exp $
+ * $Id: packet-gtp.c,v 1.63 2003/09/21 20:06:00 gerald Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #include <glib.h>
 
 #include <epan/packet.h>
+#include "prefs.h"
 #include "packet-gtp.h"
 #include "packet-ipv6.h"
 #include "packet-ppp.h"
-#include "prefs.h"
 
 static dissector_table_t ppp_subdissector_table;
 
@@ -1667,63 +1667,55 @@ col_append_str_gtp(column_info *cinfo, gint el, gchar *proto_name) {
 static gchar *
 id_to_str(const guint8 *ad) {
 
-       static gchar    *str[17];
-       gchar           *p;
-       guint8          bits8to5, bits4to1, i;
+       static gchar    str[17] = "                ";
+       guint8          bits8to5, bits4to1;
+       int             i;
        static const    gchar hex_digits[10] = "0123456789";
 
-       p = (gchar *)&str[17];
-       *--p = '\0';
-       i = 7;
-       for (;;) {
+       str[16] = '\0';
+       for (i = 15; i >= 0; i--) {
                bits8to5 = (ad[i] >> 4) & 0x0F;
                bits4to1 = ad[i] & 0x0F;
-               if (bits8to5 < 0xA) *--p = hex_digits[bits8to5];
-               if (bits4to1 < 0xA) *--p = hex_digits[bits4to1];
-               if (i == 0) break;
+               if (bits8to5 < 0xA) str[i] = hex_digits[bits8to5];
                i--;
+               if (bits4to1 < 0xA) str[i] = hex_digits[bits4to1];
        }
-       return p;
+       return str;
 }
 
 static gchar *
 imsi_to_str(const guint8 *ad) {
 
-       static gchar    *str[16];
-       gchar           *p;
-       guint8          i, j = 0;
-       
-       p = (gchar *)&str[0];
-       for (i=0;i<8;i++) {
-               if ((ad[i] & 0x0F) <= 9) p[j++] = (ad[i] & 0x0F) + 0x30;
-               if (((ad[i] >> 4) & 0x0F) <= 9) p[j++] = ((ad[i] >> 4) & 0x0F) + 0x30;
+       static gchar    str[17] = "                ";
+       int             i, j = 0;
+
+       for (i = 0; i < 8; i++) {
+               if ((ad[i] & 0x0F) <= 9) str[j++] = (ad[i] & 0x0F) + 0x30;
+               if (((ad[i] >> 4) & 0x0F) <= 9) str[j++] = ((ad[i] >> 4) & 0x0F) + 0x30;
        }
-       p[j] = 0;
-       
-       return p;
+       str[j] = '\0';
+
+       return str;
 }
 
 static gchar *
 msisdn_to_str(const guint8 *ad, int len) {
 
-       static gchar    *str[17];
+       static gchar    str[18] = "+                ";
        gchar           *p;
-       guint8          bits8to5, bits4to1, i;
+       guint8          bits8to5, bits4to1;
+       int             i;
        static const    gchar hex_digits[16] = "0123456789      ";
 
-       p = (gchar *)&str[0];
-       *p = '+';
-       i = 1;
-       for (;;) {
+       p = &str[0];
+       for (i = 1; i < len && i < 9; i++) {
                bits8to5 = (ad[i] >> 4) & 0x0F;
                bits4to1 = ad[i] & 0x0F;
                if (bits4to1 < 0xA) *++p = hex_digits[bits4to1];
                if (bits8to5 < 0xA) *++p = hex_digits[bits8to5];
-               if (i == len-1) break;
-               i++;
        }
-       *++p = '\0';
-       return (gchar *)&str[0];
+       *p = '\0';
+       return str;
 }
 
 static gchar *
@@ -2910,7 +2902,7 @@ decode_gtp_ranap_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_
        if(ranap > 112 && ranap <=128)
        proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Miscellaneous Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
 
-       if(ranap > 128 && ranap <=255)
+       if(ranap > 128 /* && ranap <=255 */)
        proto_tree_add_uint_format(tree, hf_gtpv1_ranap_cause, tvb, offset, 2, ranap, "%s (Non-standard Cause) : %s (%u)", val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"), val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
 
        return 2;
@@ -3435,7 +3427,7 @@ decode_qos_umts(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, gui
        /* Will keep the value that will be returned
         * */
        int             retval = 0;
-       
+
        switch (type) {
                case 1:
                        length = tvb_get_guint8 (tvb, offset);
@@ -3474,7 +3466,7 @@ decode_qos_umts(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, gui
                                proto_tree_add_text (ext_tree_qos, tvb, offset + 3, 1, "Hyphen separator: -");
                                offset++; /* "Get rid" of hyphen */
                        }
-                       
+
                        /* Now, we modify offset here and in order to use type later
                         * effectively.*/
                        offset += 2;
@@ -4114,7 +4106,7 @@ decode_gtp_tft(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tr
                                                break;
                                        /* flow label type = 3 bytes */
                                        case 0x80:
-                                               label = tvb_get_ntoh24(tvb, offset + pf_offset + 1) & 0x0FFFFF;;
+                                               label = tvb_get_ntoh24(tvb, offset + pf_offset + 1) & 0x0FFFFF;
                                                proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 4, "ID 0x80: Flow Label: %u (%x)", label, label);
                                                pf_offset = pf_offset + 4;
                                                break;
@@ -4983,15 +4975,15 @@ dissect_gtpv0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        if ((gtpv0_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
                 guint8 sub_proto;
-            
+
                sub_proto = tvb_get_guint8(tvb,GTPv0_HDR_LENGTH);
 
                 if ((sub_proto >= 0x45) &&  (sub_proto <= 0x4e)) {
                     /* this is most likely an IPv4 packet */
                     /* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets */
-                    /* 0x4f is excluded because PPP protocol type "IPv6 header compression" 
-                       with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */    
-                    
+                    /* 0x4f is excluded because PPP protocol type "IPv6 header compression"
+                       with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
+
                     next_tvb = tvb_new_subset(tvb, GTPv0_HDR_LENGTH, -1, -1);
                     call_dissector(ip_handle, next_tvb, pinfo, tree);
                 } else
@@ -5137,9 +5129,9 @@ dissect_gtpv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
                 if ((sub_proto >= 0x45) &&  (sub_proto <= 0x4e)) {
                     /* this is most likely an IPv4 packet */
                     /* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets */
-                    /* 0x4f is excluded because PPP protocol type "IPv6 header compression" 
-                       with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */    
-                    
+                    /* 0x4f is excluded because PPP protocol type "IPv6 header compression"
+                       with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
+
                     next_tvb = tvb_new_subset(tvb, GTPv1_HDR_LENGTH - hdr_offset, -1, -1);
                     call_dissector(ip_handle, next_tvb, pinfo, tree);
                 } else
@@ -5154,7 +5146,7 @@ dissect_gtpv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
 
                     if (sub_proto == 0xff) {
                         /* this might be an address field, even it shouldn't be here */
-                        guint8 control_field; 
+                        guint8 control_field;
                         control_field = tvb_get_guint8(tvb,GTPv1_HDR_LENGTH - hdr_offset + 1);
                         if (control_field == 0x03)
                         {