aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-alcap.c83
-rw-r--r--epan/dissectors/packet-k12.c5
-rw-r--r--epan/dissectors/packet-xml.c76
-rw-r--r--epan/uat.c7
-rw-r--r--wiretap/iseries.c4
-rw-r--r--wiretap/k12.c8
-rw-r--r--wsutil/Makefile.common6
-rw-r--r--wsutil/str_util.c50
-rw-r--r--wsutil/str_util.h60
9 files changed, 212 insertions, 87 deletions
diff --git a/epan/dissectors/packet-alcap.c b/epan/dissectors/packet-alcap.c
index fe3ca8887e..e0ec6e2da1 100644
--- a/epan/dissectors/packet-alcap.c
+++ b/epan/dissectors/packet-alcap.c
@@ -36,13 +36,14 @@
#include <string.h>
#include <glib.h>
+#include <wsutil/str_util.h>
+
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/prefs.h>
#include "packet-alcap.h"
#include <epan/dissectors/packet-isup.h>
#include <epan/expert.h>
-#include <epan/strutil.h>
#define ALCAP_MSG_HEADER_LEN 6
#define ALCAP_PARM_HEADER_LEN 3
@@ -592,7 +593,7 @@ static const gchar* dissect_fields_dnsea(packet_info* pinfo _U_, tvbuff_t *tvb,
msg_info->dest_nsap = tvb_bytes_to_str(tvb,offset,20);
proto_tree_add_item(tree, hf_alcap_dnsea, tvb, offset, 20, FALSE);
- dissect_nsap(tvb, offset,20, tree);
+ dissect_nsap(tvb, offset,20, tree);
return NULL;
}
@@ -613,7 +614,7 @@ static const gchar* dissect_fields_onsea(packet_info* pinfo _U_, tvbuff_t *tvb,
msg_info->orig_nsap = tvb_bytes_to_str(tvb,offset,20);
proto_tree_add_item(tree, hf_alcap_onsea, tvb, offset, 20, FALSE);
- dissect_nsap(tvb, offset,20, tree);
+ dissect_nsap(tvb, offset,20, tree);
return NULL;
}
@@ -1364,22 +1365,22 @@ extern void alcap_tree_from_bearer_key(proto_tree* tree, tvbuff_t* tvb, const g
#define GET_MSG_TYPE(id) ( array_length(msg_types) <= id ? &(msg_types[0]) : &(msg_types[id]) )
static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
- proto_tree *alcap_tree = NULL;
+ proto_tree *alcap_tree = NULL;
alcap_message_info_t* msg_info = ep_alloc0(sizeof(alcap_message_info_t));
- int len = tvb_length(tvb);
+ int len = tvb_length(tvb);
int offset;
proto_item* pi;
proto_tree* compat_tree;
const alcap_msg_type_info_t* msg_type;
if (check_col(pinfo->cinfo, COL_PROTOCOL))
- col_set_str(pinfo->cinfo, COL_PROTOCOL, alcap_proto_name_short);
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, alcap_proto_name_short);
if (tree) {
- proto_item *alcap_item = proto_tree_add_item(tree, proto_alcap, tvb, 0, -1, FALSE);
- alcap_tree = proto_item_add_subtree(alcap_item, ett_alcap);
+ proto_item *alcap_item = proto_tree_add_item(tree, proto_alcap, tvb, 0, -1, FALSE);
+ alcap_tree = proto_item_add_subtree(alcap_item, ett_alcap);
}
-
+
proto_tree_add_item(alcap_tree,hf_alcap_dsaid,tvb,0,4,FALSE);
pi = proto_tree_add_item(alcap_tree,hf_alcap_msg_id,tvb,4,1,FALSE);
@@ -1391,7 +1392,7 @@ static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
expert_add_info_format(pinfo, pi, PI_RESPONSE_CODE, msg_type->severity, " ");
if (check_col(pinfo->cinfo, COL_INFO))
- col_set_str(pinfo->cinfo, COL_INFO, msg_type->abbr);
+ col_set_str(pinfo->cinfo, COL_INFO, msg_type->abbr);
pi = proto_tree_add_item(alcap_tree,hf_alcap_compat,tvb,5,1,FALSE);
@@ -1433,7 +1434,7 @@ static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
len -= 3 + param_len;
offset += 3 + param_len;
}
-
+
if (keep_persistent_info) {
alcap_leg_info_t* leg = NULL;
switch (msg_info->msg_type) {
@@ -1446,26 +1447,26 @@ static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
leg->pathid = msg_info->pathid;
leg->cid = msg_info->cid;
leg->sugr = msg_info->sugr;
- leg->orig_nsap = NULL;
- leg->dest_nsap = NULL;
-
- if (msg_info->orig_nsap) {
+ leg->orig_nsap = NULL;
+ leg->dest_nsap = NULL;
+
+ if (msg_info->orig_nsap) {
gchar* key = se_strdup_printf("%s:%.8X",msg_info->orig_nsap,leg->sugr);
- g_ascii_strdown(key,strlen(key));
-
+ ascii_strdown_inplace(key);
+
leg->orig_nsap = se_strdup(msg_info->orig_nsap);
if (!se_tree_lookup_string(legs_by_bearer,key,0)) {
se_tree_insert_string(legs_by_bearer,key,leg,0);
}
- }
-
+ }
+
if (msg_info->dest_nsap) {
gchar* key = se_strdup_printf("%s:%.8X",msg_info->dest_nsap,leg->sugr);
- g_ascii_strdown(key,strlen(key));
-
+ ascii_strdown_inplace(key);
+
leg->dest_nsap = se_strdup(msg_info->dest_nsap);
-
+
if (!se_tree_lookup_string(legs_by_bearer,key,0)) {
se_tree_insert_string(legs_by_bearer,key,leg,0);
}
@@ -1480,7 +1481,7 @@ static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
case 4: /* ECF */
if(( leg = se_tree_lookup32(legs_by_osaid,msg_info->dsaid) )) {
leg->dsaid = msg_info->osaid;
- se_tree_insert32(legs_by_dsaid,leg->dsaid,leg);
+ se_tree_insert32(legs_by_dsaid,leg->dsaid,leg);
}
break;
case 6: /* RLC */
@@ -1505,7 +1506,7 @@ static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
}
break;
default:
- break;
+ break;
}
if (leg && ( (! leg->msgs) || leg->msgs->last->framenum < pinfo->fd->num ) ) {
@@ -1721,15 +1722,15 @@ proto_register_alcap(void)
{ &hf_alcap_vbwt_size_fw, { "Forward CPS Packet Size", "alcap.vbwt.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
{ &hf_alcap_vbwt_size_bw, { "Backwards CPS Packet Size", "alcap.vbwt.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
- { &hf_alcap_leg_osaid, { "Leg's ERQ OSA id", "alcap.leg.osaid", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_dsaid, { "Leg's ECF OSA id", "alcap.leg.dsaid", FT_UINT32, BASE_HEX, NULL, 0,"", HFILL } },
- { &hf_alcap_leg_pathid, { "Leg's path id", "alcap.leg.pathid", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_cid, { "Leg's channel id", "alcap.leg.cid", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_sugr, { "Leg's SUGR", "alcap.leg.sugr", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_dnsea, { "Leg's destination NSAP", "alcap.leg.dnsea", FT_STRING, BASE_NONE, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_onsea, { "Leg's originating NSAP", "alcap.leg.onsea", FT_STRING, BASE_NONE, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_frame, { "a message of this leg", "alcap.leg.msg", FT_FRAMENUM, BASE_DEC, NULL, 0, "", HFILL } },
- { &hf_alcap_leg_release_cause, { "Leg's cause value in REL", "alcap.leg.cause", FT_UINT8, BASE_DEC, VALS(cause_values_itu), 0, "", HFILL }},
+ { &hf_alcap_leg_osaid, { "Leg's ERQ OSA id", "alcap.leg.osaid", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_dsaid, { "Leg's ECF OSA id", "alcap.leg.dsaid", FT_UINT32, BASE_HEX, NULL, 0,"", HFILL } },
+ { &hf_alcap_leg_pathid, { "Leg's path id", "alcap.leg.pathid", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_cid, { "Leg's channel id", "alcap.leg.cid", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_sugr, { "Leg's SUGR", "alcap.leg.sugr", FT_UINT32, BASE_HEX, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_dnsea, { "Leg's destination NSAP", "alcap.leg.dnsea", FT_STRING, BASE_NONE, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_onsea, { "Leg's originating NSAP", "alcap.leg.onsea", FT_STRING, BASE_NONE, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_frame, { "a message of this leg", "alcap.leg.msg", FT_FRAMENUM, BASE_DEC, NULL, 0, "", HFILL } },
+ { &hf_alcap_leg_release_cause, { "Leg's cause value in REL", "alcap.leg.cause", FT_UINT8, BASE_DEC, VALS(cause_values_itu), 0, "", HFILL }},
};
@@ -1778,11 +1779,11 @@ proto_register_alcap(void)
proto_alcap = proto_register_protocol(alcap_proto_name, alcap_proto_name_short, "alcap");
- register_dissector("alcap", dissect_alcap, proto_alcap);
-
+ register_dissector("alcap", dissect_alcap, proto_alcap);
+
proto_register_field_array(proto_alcap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
+
alcap_module = prefs_register_protocol(proto_alcap, NULL);
prefs_register_bool_preference(alcap_module, "leg_info",
@@ -1790,16 +1791,16 @@ proto_register_alcap(void)
"Whether persistent call leg information is to be kept",
&keep_persistent_info);
- legs_by_dsaid = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_dsaid");
- legs_by_osaid = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_osaid");
- legs_by_bearer = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_bearer");
-
+ legs_by_dsaid = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_dsaid");
+ legs_by_osaid = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_osaid");
+ legs_by_bearer = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_bearer");
}
void
proto_reg_handoff_alcap(void)
{
- dissector_handle_t alcap_handle = create_dissector_handle(dissect_alcap, proto_alcap);
+ dissector_handle_t alcap_handle = create_dissector_handle(dissect_alcap, proto_alcap);
+
dissector_add("mtp3.service_indicator", ALCAP_SI, alcap_handle);
}
diff --git a/epan/dissectors/packet-k12.c b/epan/dissectors/packet-k12.c
index 0d982c38ed..39cf6dfef8 100644
--- a/epan/dissectors/packet-k12.c
+++ b/epan/dissectors/packet-k12.c
@@ -9,7 +9,6 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998
*
-*
* 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
@@ -32,13 +31,13 @@
#include <errno.h>
#include <glib.h>
#include <string.h>
+#include <wsutil/str_util.h>
#include <epan/packet.h>
#include <prefs.h>
#include <epan/report_err.h>
#include <epan/emem.h>
#include <epan/uat.h>
#include <epan/expert.h>
-#include <epan/strutil.h>
#include "packet-sscop.h"
#include "packet-umts_fp.h"
@@ -369,7 +368,7 @@ protos_chk_cb(void* r _U_, const char* p, unsigned len, void* u1 _U_, void* u2 _
guint num_protos, i;
g_strstrip(line);
- g_ascii_strdown(line,len);
+ ascii_strdown_inplace(line);
protos = ep_strsplit(line,":",0);
diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c
index 3ea4321225..9ca0d0d645 100644
--- a/epan/dissectors/packet-xml.c
+++ b/epan/dissectors/packet-xml.c
@@ -44,9 +44,11 @@
#include <stdio.h>
#include <glib.h>
+
+#include <wsutil/str_util.h>
+
#include <epan/emem.h>
#include <epan/packet.h>
-#include <epan/strutil.h>
#include <epan/tvbparse.h>
#include <epan/dtd.h>
#include <epan/report_err.h>
@@ -197,7 +199,7 @@ dissect_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
colinfo_str = "/XML";
} else {
colinfo_str = ep_strdup_printf("/%s",root_ns->name);
- g_ascii_strup(colinfo_str,strlen(colinfo_str));
+ ascii_strup_inplace(colinfo_str);
}
if (check_col(pinfo->cinfo, COL_PROTOCOL))
@@ -250,14 +252,14 @@ static void before_xmpli(void* tvbparse_data, const void* wanted_data _U_, tvbpa
proto_item* pi;
proto_tree* pt;
tvbparse_elem_t* name_tok = tok->sub->next;
- const gchar* name = (gchar*)tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len);
+ gchar* name = tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len);
xml_ns_t* ns = g_hash_table_lookup(xmpli_names,name);
xml_frame_t* new_frame;
int hf_tag;
gint ett;
- g_ascii_strdown(name,strlen(name));
+ ascii_strdown_inplace(name);
if (!ns) {
hf_tag = hf_xmlpi;
ett = ett_xmpli;
@@ -302,17 +304,17 @@ static void after_xmlpi(void* tvbparse_data, const void* wanted_data _U_, tvbpar
}
static void before_tag(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) {
- GPtrArray* stack = tvbparse_data;
- xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1);
- tvbparse_elem_t* name_tok = tok->sub->next;
+ GPtrArray* stack = tvbparse_data;
+ xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1);
+ tvbparse_elem_t* name_tok = tok->sub->next;
gchar* root_name;
- const gchar* name = NULL;
- xml_ns_t* ns;
- xml_frame_t* new_frame;
- proto_item* pi;
- proto_tree* pt;
+ gchar* name = NULL;
+ xml_ns_t* ns;
+ xml_frame_t* new_frame;
+ proto_item* pi;
+ proto_tree* pt;
- if (name_tok->sub->id == XML_SCOPED_NAME) {
+ if (name_tok->sub->id == XML_SCOPED_NAME) {
tvbparse_elem_t* root_tok = name_tok->sub->sub;
tvbparse_elem_t* leaf_tok = name_tok->sub->sub->next->next;
xml_ns_t* nameroot_ns;
@@ -332,38 +334,38 @@ static void before_tag(void* tvbparse_data, const void* wanted_data _U_, tvbpars
}
} else {
- name = (gchar*)tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len);
- g_ascii_strdown(name,strlen(name));
+ name = tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len);
+ ascii_strdown_inplace(name);
if(current_frame->ns) {
- ns = g_hash_table_lookup(current_frame->ns->elements,name);
+ ns = g_hash_table_lookup(current_frame->ns->elements,name);
- if (!ns) {
- if (! ( ns = g_hash_table_lookup(root_ns->elements,name) ) ) {
- ns = &unknown_ns;
- }
- }
- } else {
- ns = &unknown_ns;
- }
+ if (!ns) {
+ if (! ( ns = g_hash_table_lookup(root_ns->elements,name) ) ) {
+ ns = &unknown_ns;
+ }
+ }
+ } else {
+ ns = &unknown_ns;
+ }
}
pi = proto_tree_add_item(current_frame->tree,ns->hf_tag,tok->tvb,tok->offset,tok->len,FALSE);
- proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len));
+ proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len));
- pt = proto_item_add_subtree(pi,ns->ett);
+ pt = proto_item_add_subtree(pi,ns->ett);
- new_frame = ep_alloc(sizeof(xml_frame_t));
- new_frame->type = XML_FRAME_TAG;
- new_frame->name = name;
- insert_xml_frame(current_frame, new_frame);
- new_frame->item = pi;
- new_frame->last_item = pi;
- new_frame->tree = pt;
- new_frame->start_offset = tok->offset;
- new_frame->ns = ns;
+ new_frame = ep_alloc(sizeof(xml_frame_t));
+ new_frame->type = XML_FRAME_TAG;
+ new_frame->name = name;
+ insert_xml_frame(current_frame, new_frame);
+ new_frame->item = pi;
+ new_frame->last_item = pi;
+ new_frame->tree = pt;
+ new_frame->start_offset = tok->offset;
+ new_frame->ns = ns;
- g_ptr_array_add(stack,new_frame);
+ g_ptr_array_add(stack,new_frame);
}
@@ -464,7 +466,7 @@ static void after_attrib(void* tvbparse_data, const void* wanted_data _U_, tvbpa
int* hfidp;
int hfid;
- g_ascii_strdown(name,strlen(name));
+ ascii_strdown_inplace(name);
if(current_frame->ns && (hfidp = g_hash_table_lookup(current_frame->ns->attributes,name) )) {
hfid = *hfidp;
} else {
diff --git a/epan/uat.c b/epan/uat.c
index 61dc25b939..8bfd325195 100644
--- a/epan/uat.c
+++ b/epan/uat.c
@@ -38,12 +38,15 @@
#include <stdarg.h>
#include <glib.h>
+
+#include <wsutil/file_util.h>
+#include <wsutil/str_util.h>
+
#include <epan/emem.h>
#include <epan/report_err.h>
#include <epan/filesystem.h>
#include <epan/packet.h>
#include <epan/range.h>
-#include <wsutil/file_util.h>
#include "uat-int.h"
@@ -381,7 +384,7 @@ gboolean uat_fld_chk_str(void* u1 _U_, const char* strptr, unsigned len _U_, voi
gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, unsigned len, void* u2 _U_, void* u3 _U_, const char** err) {
if (len) {
char* name = ep_strndup(strptr,len);
- g_ascii_strdown(name,len);
+ ascii_strdown_inplace(name);
g_strchug(name);
if (find_dissector(name)) {
diff --git a/wiretap/iseries.c b/wiretap/iseries.c
index 4c31cf1724..f9ba4b303a 100644
--- a/wiretap/iseries.c
+++ b/wiretap/iseries.c
@@ -123,6 +123,8 @@
#include <ctype.h>
#include <errno.h>
+#include <wsutil/str_util.h>
+
#define ISERIES_HDR_MAGIC_STR " COMMUNICATIONS TRACE"
#define ISERIES_HDR_MAGIC_LEN 21
#define ISERIES_PKT_MAGIC_STR "ETHV2"
@@ -275,7 +277,7 @@ iseries_check_file_type (wtap * wth, int *err, int format)
{
iseries_UNICODE_to_ASCII ((guint8 *)buf, ISERIES_LINE_LENGTH);
}
- g_ascii_strup(buf,ISERIES_LINE_LENGTH);
+ ascii_strup_inplace(buf);
num_items_scanned = sscanf (buf,
" OBJECT PROTOCOL . . . . . . : %8s",
protocol);
diff --git a/wiretap/k12.c b/wiretap/k12.c
index fcb92a0373..4088b9a896 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -32,12 +32,15 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+
#include "wtap-int.h"
#include "wtap.h"
#include "file_wrappers.h"
#include "buffer.h"
#include "k12.h"
+#include <wsutil/str_util.h>
+
/*#define DEBUG_K12*/
#ifdef DEBUG_K12
#include <stdio.h>
@@ -681,10 +684,13 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) {
rec->input_type = K12_PORT_ATMPVC;
}
+ /* XXX - this is assumed, in a number of places (not just in the
+ ascii_strdown_inplace() call below) to be null-terminated;
+ is that guaranteed (even with a corrupt file)? */
rec->input_name = g_memdup(read_buffer + K12_SRCDESC_EXTRATYPE + extra_len, name_len);
rec->stack_file = g_memdup(read_buffer + K12_SRCDESC_EXTRATYPE + extra_len + name_len, stack_len);
- g_ascii_strdown (rec->stack_file,stack_len);
+ ascii_strdown_inplace (rec->stack_file);
g_hash_table_insert(file_data->src_by_id,GUINT_TO_POINTER(rec->input),rec);
g_hash_table_insert(file_data->src_by_name,rec->stack_file,rec);
diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common
index 284e62eee6..585213db52 100644
--- a/wsutil/Makefile.common
+++ b/wsutil/Makefile.common
@@ -30,9 +30,11 @@
# _SOURCES variables).
LIBWSUTIL_SRC = \
mpeg-audio.c \
- privileges.c
+ privileges.c \
+ str_util.c
# Header files that are not generated from other files
LIBWSUTIL_INCLUDES = \
mpeg-audio.h \
- privileges.h
+ privileges.h \
+ str_util.h
diff --git a/wsutil/str_util.c b/wsutil/str_util.c
new file mode 100644
index 0000000000..4b01956d28
--- /dev/null
+++ b/wsutil/str_util.c
@@ -0,0 +1,50 @@
+/* str_util.c
+ * String utility routines
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include "str_util.h"
+
+/* Convert all ASCII letters to lower case, in place. */
+void
+ascii_strdown_inplace(gchar *str)
+{
+ gchar *s;
+
+ for (s = str; *s; s++)
+ *s = g_ascii_tolower (*s);
+}
+
+/* Convert all ASCII letters to upper case, in place. */
+void
+ascii_strup_inplace(gchar *str)
+{
+ gchar *s;
+
+ for (s = str; *s; s++)
+ *s = g_ascii_toupper (*s);
+}
diff --git a/wsutil/str_util.h b/wsutil/str_util.h
new file mode 100644
index 0000000000..432e970e38
--- /dev/null
+++ b/wsutil/str_util.h
@@ -0,0 +1,60 @@
+/* str_util.h
+ * String utility definitions
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __STR_UTIL_H__
+#define __STR_UTIL_H__
+
+/** Convert all upper-case ASCII letters to their ASCII lower-case
+ * equivalents, in place, with a simple non-locale-dependent
+ * ASCII mapping (A-Z -> a-z).
+ * All other characters are left unchanged, as the mapping to
+ * lower case may be locale-dependent.
+ *
+ * The string is assumed to be in a character encoding, such as
+ * an ISO 8859 or other EUC encoding, or UTF-8, in which all
+ * bytes in the range 0x00 through 0x7F are ASCII characters and
+ * non-ASCII characters are constructed from one or more bytes in
+ * the range 0x80 through 0xFF.
+ *
+ * @param str The string to be lower-cased.
+ */
+void ascii_strdown_inplace(gchar *str);
+
+/** Convert all lower-case ASCII letters to their ASCII upper-case
+ * equivalents, in place, with a simple non-locale-dependent
+ * ASCII mapping (a-z -> A-Z).
+ * All other characters are left unchanged, as the mapping to
+ * lower case may be locale-dependent.
+ *
+ * The string is assumed to be in a character encoding, such as
+ * an ISO 8859 or other EUC encoding, or UTF-8, in which all
+ * bytes in the range 0x00 through 0x7F are ASCII characters and
+ * non-ASCII characters are constructed from one or more bytes in
+ * the range 0x80 through 0xFF.
+ *
+ * @param str The string to be upper-cased.
+ */
+void ascii_strup_inplace(gchar *str);
+
+#endif /* __STR_UTIL_H__ */