aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGerasimos Dimitriadis <dimeg@intracom.gr>2010-01-26 18:21:17 +0000
committerGerasimos Dimitriadis <dimeg@intracom.gr>2010-01-26 18:21:17 +0000
commitc08fa6f3cf2ded7ff34393739c7b26c953f74ddb (patch)
tree8e6dfadc33670265be83256ef3eb7139de8e3b02 /epan
parent293ea61af2e8ff0fb166f1450df610ce8e483b21 (diff)
Move underscore escaping/unscaping function to strutil.c;
Update decoding of IS-801 Request GPS Acquisition Assistance svn path=/trunk/; revision=31685
Diffstat (limited to 'epan')
-rw-r--r--epan/column.c52
-rw-r--r--epan/column.h3
-rw-r--r--epan/dissectors/packet-ansi_801.c64
-rw-r--r--epan/prefs.c1
-rw-r--r--epan/strutil.c56
-rw-r--r--epan/strutil.h16
6 files changed, 104 insertions, 88 deletions
diff --git a/epan/column.c b/epan/column.c
index c0f5a9a9ca..17dbcb461e 100644
--- a/epan/column.c
+++ b/epan/column.c
@@ -728,55 +728,3 @@ build_column_format_array(column_info *cinfo, gint num_cols, gboolean reset_fenc
}
}
-/*
- * This function takes a string and copies it, inserting an underscore before
- * every underscore in it.
- */
-gchar*
-ws_strdup_escape_underscore (const gchar *str)
-{
- gchar *p, *q, *new_str;
-
- if(!str)
- return NULL;
-
- p = (gchar *)str;
- /* Worst case: A string that is full of underscores */
- q = new_str = g_malloc (strlen(str) * 2 + 1);
-
- while(*p != 0)
- {
- if(*p == '_')
- *q++ = '_';
-
- *q++ = *p++;
- }
- *q++ = '\0';
-
- return new_str;
-}
-
-gchar*
-ws_strdup_unescape_underscore (const gchar *str)
-{
- gchar *p, *q, *new_str;
-
- if(!str)
- return NULL;
-
- p = (gchar *)str;
- /* Worst case: A string that contains no underscores */
- q = new_str = g_malloc (strlen(str) + 1);
-
- while(*p != 0)
- {
- *q++ = *p;
- if ((*p == '_') && (*(p+1) == '_'))
- p += 2;
- else
- p++;
- }
- *q++ = '\0';
-
- return new_str;
-}
diff --git a/epan/column.h b/epan/column.h
index 99eb31b8f3..d8cf558bac 100644
--- a/epan/column.h
+++ b/epan/column.h
@@ -49,9 +49,6 @@ gint get_column_char_width(gint format);
void
build_column_format_array(column_info *cinfo, gint num_cols, gboolean reset_fences);
-gchar* ws_strdup_escape_underscore (const gchar *str);
-gchar* ws_strdup_unescape_underscore (const gchar *str);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/epan/dissectors/packet-ansi_801.c b/epan/dissectors/packet-ansi_801.c
index e82d3fa7b8..06f7812409 100644
--- a/epan/dissectors/packet-ansi_801.c
+++ b/epan/dissectors/packet-ansi_801.c
@@ -97,6 +97,10 @@ static int hf_ansi_801_spare_bits = -1;
static int hf_ansi_801_bad_sv_present = -1;
static int hf_ansi_801_num_bad_sv = -1;
static int hf_ansi_801_bad_sv_prn_num = -1;
+static int hf_ansi_801_dopp_req = -1;
+static int hf_ansi_801_add_dopp_req = -1;
+static int hf_ansi_801_code_ph_par_req = -1;
+static int hf_ansi_801_az_el_req = -1;
static char bigbuf[1024];
static dissector_handle_t data_handle;
@@ -970,44 +974,18 @@ for_pr_gps_sat_health(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset
static void
rev_req_gps_acq_ass(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
{
- guint8 oct;
guint32 saved_offset;
+ guint32 bit_offset;
SHORT_DATA_CHECK(len, 1);
-
saved_offset = offset;
+ bit_offset = offset << 3;
- oct = tvb_get_guint8(tvb, offset);
-
- other_decode_bitfield_value(bigbuf, oct, 0x80, 8);
- proto_tree_add_text(tree, tvb, offset, 1,
- "%s : Doppler (0th order) term %srequested",
- bigbuf,
- (oct & 0x80) ? "" : "not ");
-
- other_decode_bitfield_value(bigbuf, oct, 0x40, 8);
- proto_tree_add_text(tree, tvb, offset, 1,
- "%s : Additional Doppler terms %srequested",
- bigbuf,
- (oct & 0x40) ? "" : "not ");
-
- other_decode_bitfield_value(bigbuf, oct, 0x20, 8);
- proto_tree_add_text(tree, tvb, offset, 1,
- "%s : Code phase parameters %srequested",
- bigbuf,
- (oct & 0x20) ? "" : "not ");
-
- other_decode_bitfield_value(bigbuf, oct, 0x10, 8);
- proto_tree_add_text(tree, tvb, offset, 1,
- "%s : Azimuth and elevation angle %srequested",
- bigbuf,
- (oct & 0x10) ? "" : "not ");
-
- other_decode_bitfield_value(bigbuf, oct, 0x0f, 8);
- proto_tree_add_text(tree, tvb, offset, 1,
- "%s : Reserved",
- bigbuf);
-
+ proto_tree_add_bits_item(tree, hf_ansi_801_dopp_req, tvb, bit_offset++, 1, FALSE);
+ proto_tree_add_bits_item(tree, hf_ansi_801_add_dopp_req, tvb, bit_offset++, 1, FALSE);
+ proto_tree_add_bits_item(tree, hf_ansi_801_code_ph_par_req, tvb, bit_offset++, 1, FALSE);
+ proto_tree_add_bits_item(tree, hf_ansi_801_az_el_req, tvb, bit_offset++, 1, FALSE);
+ proto_tree_add_bits_item(tree, hf_ansi_801_spare_bits, tvb, bit_offset, 4, FALSE);
offset++;
EXTRANEOUS_DATA_CHECK(len, offset - saved_offset);
@@ -2351,6 +2329,26 @@ proto_register_ansi_801(void)
FT_UINT8, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
+ { &hf_ansi_801_dopp_req,
+ { "Doppler (0th order) term requested (DOPP_REQ)", "ansi_801.dopp_req",
+ FT_BOOLEAN, 8, NULL, 0x00,
+ NULL, HFILL }
+ },
+ { &hf_ansi_801_add_dopp_req,
+ { "Additional Doppler terms requested (ADD_DOPP_REQ)", "ansi_801.add_dopp_req",
+ FT_BOOLEAN, 8, NULL, 0x00,
+ NULL, HFILL }
+ },
+ { &hf_ansi_801_code_ph_par_req,
+ { "Code phase parameters requested (CODE_PH_PAR_REQ)", "ansi_801.code_ph_par_req",
+ FT_BOOLEAN, 8, NULL, 0x00,
+ NULL, HFILL }
+ },
+ { &hf_ansi_801_az_el_req,
+ { "Azimuth and elevation angle requested (AZ_EL_REQ)", "ansi_801.az_el_req",
+ FT_BOOLEAN, 8, NULL, 0x00,
+ NULL, HFILL }
+ },
};
diff --git a/epan/prefs.c b/epan/prefs.c
index 82556c2826..7feed06ad0 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -44,6 +44,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto.h>
+#include <epan/strutil.h>
#include "cfile.h"
#include <epan/column.h>
#include "print.h"
diff --git a/epan/strutil.c b/epan/strutil.c
index b2a77f54c7..f6b9b9e4d7 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -1077,3 +1077,59 @@ IA5_7BIT_decode(unsigned char * dest, const unsigned char* src, int len)
return;
}
+/*
+ * This function takes a string and copies it, inserting an underscore before
+ * every underscore in it.
+ */
+gchar*
+ws_strdup_escape_underscore (const gchar *str)
+{
+ gchar *p, *q, *new_str;
+
+ if(!str)
+ return NULL;
+
+ p = (gchar *)str;
+ /* Worst case: A string that is full of underscores */
+ q = new_str = g_malloc (strlen(str) * 2 + 1);
+
+ while(*p != 0)
+ {
+ if(*p == '_')
+ *q++ = '_';
+
+ *q++ = *p++;
+ }
+ *q++ = '\0';
+
+ return new_str;
+}
+
+/*
+ * This function takes a string and copies it, removing any occurences of double
+ * underscores with a single underscore.
+ */
+gchar*
+ws_strdup_unescape_underscore (const gchar *str)
+{
+ gchar *p, *q, *new_str;
+
+ if(!str)
+ return NULL;
+
+ p = (gchar *)str;
+ /* Worst case: A string that contains no underscores */
+ q = new_str = g_malloc (strlen(str) + 1);
+
+ while(*p != 0)
+ {
+ *q++ = *p;
+ if ((*p == '_') && (*(p+1) == '_'))
+ p += 2;
+ else
+ p++;
+ }
+ *q++ = '\0';
+
+ return new_str;
+}
diff --git a/epan/strutil.h b/epan/strutil.h
index b48f29863b..4303bf0c43 100644
--- a/epan/strutil.h
+++ b/epan/strutil.h
@@ -228,4 +228,20 @@ char * escape_string(char *dst, const char *string);
void IA5_7BIT_decode(unsigned char * dest, const unsigned char* src, int len);
+/** Copy a string, escaping the underscores in it
+ *
+ * @param str The string to be copied
+ * @return A copy of the string with every original underscore being
+ * transformed into double underscores.
+ */
+gchar* ws_strdup_escape_underscore (const gchar *str);
+
+/** Copy a string, unescaping the underscores in it
+ *
+ * @param str The string to be copied
+ * @return A copy of the string with every occurence of double underscores in
+ * the original string being copied as a single underscore.
+ */
+gchar* ws_strdup_unescape_underscore (const gchar *str);
+
#endif /* __STRUTIL_H__ */