summaryrefslogtreecommitdiff
path: root/epan/strutil.h
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2007-01-11 02:42:34 +0000
committerGerald Combs <gerald@wireshark.org>2007-01-11 02:42:34 +0000
commit983f496f6944f27301f08017a89264077b9fcb7d (patch)
tree79057e0a71f586e0d34c79087bc9d39e18127c79 /epan/strutil.h
parent5223c8dfa6b285d0cf59f9fc30c3e42c1e255ab6 (diff)
downloadwireshark-983f496f6944f27301f08017a89264077b9fcb7d.tar.gz
Add uri_str_to_bytes(), byte_array_dup(), and byte_array_equal()
functions to strutil. Use GByteArrays to store SSIDs for decryption, and let the user specify arbitrary byte strings using percent-encoded strings. We should probably add percent encoding for pass phrases as well, so you can escape the ":" character. Move the key struct key conversion utilities to airpdcap.c, and remove duplicate code from packet-ieee80211.c. Fix a lot of indentation. svn path=/trunk/; revision=20388
Diffstat (limited to 'epan/strutil.h')
-rw-r--r--epan/strutil.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/epan/strutil.h b/epan/strutil.h
index 4c21035557..0f7b8b4b95 100644
--- a/epan/strutil.h
+++ b/epan/strutil.h
@@ -101,6 +101,15 @@ gchar* bytes_to_str_punct(const guint8 *bd, int bd_len, gchar punct);
gboolean hex_str_to_bytes(const char *hex_str, GByteArray *bytes,
gboolean force_separators);
+/** Turn an RFC 3986 percent-encoded string into a byte array.
+ *
+ * @param uri_str The string of hex digits.
+ * @param bytes The GByteArray that will receive the bytes. This
+ * must be initialized by the caller.
+ * @return True if the string was converted successfully
+ */
+gboolean uri_str_to_bytes(const char *uri_str, GByteArray *bytes);
+
/** Turn a OID string representation (dot notaion) into a byte array.
*
* @param oid_str The OID string (dot notaion).
@@ -110,6 +119,30 @@ gboolean hex_str_to_bytes(const char *hex_str, GByteArray *bytes,
*/
gboolean oid_str_to_bytes(const char *oid_str, GByteArray *bytes);
+/**
+ * Create a copy of a GByteArray
+ *
+ * @param ba The byte array to be copied.
+ * @return If ba exists, a freshly allocated copy. NULL otherwise.
+ *
+ * XXX - Should this be in strutil.c?
+ */
+GByteArray *byte_array_dup(GByteArray *ba);
+
+/**
+ * Compare the contents of two GByteArrays
+ *
+ * @param ba1 A byte array
+ * @param ba2 A byte array
+ * @return If both arrays are non-NULL and their lengths are equal and
+ * their contents are equal, returns TRUE. Otherwise, returns
+ * FALSE.
+ *
+ * XXX - Should this be in strutil.c?
+ */
+gboolean byte_array_equal(GByteArray *ba1, GByteArray *ba2);
+
+
/** Return a XML escaped representation of the unescaped string.
* The returned string must be freed when no longer in use.
*
@@ -118,7 +151,8 @@ gboolean oid_str_to_bytes(const char *oid_str, GByteArray *bytes);
*/
gchar* xml_escape(const gchar *unescaped);
-/* Return the first occurrence of needle in haystack.
+/**
+ * Return the first occurrence of needle in haystack.
* Algorithm copied from GNU's glibc 2.3.2 memcmp()
*
* @param haystack The data to search