Move common code to base64.c

svn path=/trunk/; revision=25908
This commit is contained in:
Anders Broman 2008-08-03 14:27:22 +00:00
parent ea4fbda062
commit 2b9d63a4b5
5 changed files with 22 additions and 46 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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)

View File

@ -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);
}
/*

View File

@ -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;