diff options
author | Anders Broman <anders.broman@ericsson.com> | 2008-08-03 14:27:22 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2008-08-03 14:27:22 +0000 |
commit | 2b9d63a4b5ba6b10f596339a317ca36a8d66c460 (patch) | |
tree | 07312614ae843f729998c1214e2fb34511d69cba | |
parent | ea4fbda062c37643112842b07dc19b2144dfc2c7 (diff) |
Move common code to base64.c
svn path=/trunk/; revision=25908
-rw-r--r-- | epan/base64.c | 18 | ||||
-rw-r--r-- | epan/base64.h | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-http.c | 18 | ||||
-rw-r--r-- | epan/dissectors/packet-multipart.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-sdp.c | 19 |
5 files changed, 22 insertions, 46 deletions
diff --git a/epan/base64.c b/epan/base64.c index e48d941b1a..7a5966d843 100644 --- a/epan/base64.c +++ b/epan/base64.c @@ -66,3 +66,21 @@ size_t epan_base64_decode(char *s) return i*3/4; } + +/* Return a tvb that contains the binary representation of a base64 + string */ + +tvbuff_t * +base64_to_tvb(const char *base64) +{ + tvbuff_t *tvb; + char *data = g_strdup(base64); + size_t len; + + len = epan_base64_decode(data); + tvb = tvb_new_real_data((const guint8 *)data, len, len); + + tvb_set_free_cb(tvb, g_free); + + return tvb; +}
\ No newline at end of file diff --git a/epan/base64.h b/epan/base64.h index 46d060eadc..ffef8ebf17 100644 --- a/epan/base64.h +++ b/epan/base64.h @@ -28,9 +28,12 @@ extern "C" { #endif /* __cplusplus */ +#include "epan/tvbuff.h" /* In-place decoding of a base64 string. */ size_t epan_base64_decode(char *s); +extern tvbuff_t* base64_to_tvb(const char *base64); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index cd956eee57..41ebb96933 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -455,24 +455,6 @@ http_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* e return 1; } -/* Return a tvb that contains the binary representation of a base64 - string */ - -static tvbuff_t * -base64_to_tvb(const char *base64) -{ - tvbuff_t *tvb; - char *data = g_strdup(base64); - size_t len; - - len = epan_base64_decode(data); - tvb = tvb_new_real_data((const guint8 *)data, len, len); - - tvb_set_free_cb(tvb, g_free); - - return tvb; -} - static void dissect_http_ntlmssp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const char *line) diff --git a/epan/dissectors/packet-multipart.c b/epan/dissectors/packet-multipart.c index e9b9d2c4c5..7707deacd2 100644 --- a/epan/dissectors/packet-multipart.c +++ b/epan/dissectors/packet-multipart.c @@ -178,20 +178,12 @@ unfold_and_compact_mime_header(const char *lines, gint *first_colon_offset); static tvbuff_t * base64_decode(packet_info *pinfo, tvbuff_t *b64_tvb, char *name) { - tvbuff_t *tvb; char *data; - size_t len; data = g_strdup(tvb_get_ephemeral_string(b64_tvb, 0, tvb_length(b64_tvb))); - len = epan_base64_decode(data); - tvb = tvb_new_real_data((const guint8 *)data, len, len); - tvb_set_free_cb(tvb, g_free); - - add_new_data_source(pinfo, tvb, name); - - return tvb; + return base64_to_tvb(data); } /* diff --git a/epan/dissectors/packet-sdp.c b/epan/dissectors/packet-sdp.c index 97f7249591..9bb54ecd89 100644 --- a/epan/dissectors/packet-sdp.c +++ b/epan/dissectors/packet-sdp.c @@ -898,25 +898,6 @@ static void dissect_sdp_encryption_key(tvbuff_t *tvb, proto_item * ti){ tvb, offset, -1, FALSE); } -/* Return a tvb that contains the binary representation of a base64 - string */ - -static tvbuff_t * -base64_to_tvb(const char *base64) -{ - tvbuff_t *tvb; - char *data = g_strdup(base64); - size_t len; - - len = epan_base64_decode(data); - tvb = tvb_new_real_data((const guint8 *)data, len, len); - - tvb_set_free_cb(tvb, g_free); - - return tvb; -} - - static void dissect_key_mgmt(tvbuff_t *tvb, packet_info * pinfo, proto_item * ti){ gchar *data = NULL; gchar *prtcl_id = NULL; |