static int dissect_returnData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
static int dissect_ansi_map_SystemMyTypeCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_);
+#if 0
+/* Moved to tvbuff.h
+ * XXX remove after trial period.
+ */
typedef struct dgt_set_t
{
unsigned char out[15];
}
dgt_set_t;
-
+#endif
static dgt_set_t Dgt_tbcd = {
{
/* 0 1 2 3 4 5 6 7 8 9 a b c d e */
static gboolean a_meid_configured = FALSE;
-typedef struct dgt_set_t
+typedef struct ansi_a_dgt_set_t
{
/*
* would typically be 15 but to allow MEID decoding this
*/
unsigned char out[16];
}
-dgt_set_t;
+ansi_a_dgt_set_t;
/*
* As per A.S0001 Called Party BCD Number
*/
-static dgt_set_t Dgt_tbcd = {
+static ansi_a_dgt_set_t Dgt_tbcd = {
{
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
'0','1','2','3','4','5','6','7','8','9','*','#','a','b','c', 0
}
};
-static dgt_set_t Dgt_msid = {
+static ansi_a_dgt_set_t Dgt_msid = {
{
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
'0','1','2','3','4','5','6','7','8','9','?','?','?','?','?', 0
}
};
-static dgt_set_t Dgt_meid = {
+static ansi_a_dgt_set_t Dgt_meid = {
{
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
char *out, /* ASCII pattern out */
guchar *in, /* packed pattern in */
int num_octs, /* Number of octets to unpack */
- dgt_set_t *dgt /* Digit definitions */
+ ansi_a_dgt_set_t *dgt /* Digit definitions */
)
{
int cnt = 0;
static int dissect_returnData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx);
static int dissect_ansi_map_SystemMyTypeCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_);
+#if 0
+/* Moved to tvbuff.h
+ * XXX remove after trial period.
+ */
typedef struct dgt_set_t
{
unsigned char out[15];
}
dgt_set_t;
-
+#endif
static dgt_set_t Dgt_tbcd = {
{
/* 0 1 2 3 4 5 6 7 8 9 a b c d e */
/*--- End of included file: packet-ansi_map-fn.c ---*/
-#line 3642 "packet-ansi_map-template.c"
+#line 3646 "packet-ansi_map-template.c"
/*
* 6.5.2.dk N.S0013-0 v 1.0,X.S0004-550-E v1.0 2.301
NULL, HFILL }},
/*--- End of included file: packet-ansi_map-hfarr.c ---*/
-#line 5291 "packet-ansi_map-template.c"
+#line 5295 "packet-ansi_map-template.c"
};
/* List of subtrees */
&ett_ansi_map_ReturnData,
/*--- End of included file: packet-ansi_map-ettarr.c ---*/
-#line 5324 "packet-ansi_map-template.c"
+#line 5328 "packet-ansi_map-template.c"
};
/* PROTOTYPES/FORWARDS */
typedef guint16 (*elem_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_string, int string_len);
typedef void (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len);
-
+#if 0
+/* XXX moved to tvbuff.h, clean up later */
typedef struct dgt_set_t
{
unsigned char out[15];
}
dgt_set_t;
-
+#endif
int my_dgt_tbcd_unpack(
char *out, /* ASCII pattern out */
guchar *in, /* packed pattern in */
return bytes_to_str_punct(tvb_get_ptr(tvb, offset, len), len, punct);
}
+
+/*
+ * Given a tvbuff, an offset into the tvbuff, and a length that starts
+ * at that offset (which may be -1 for "all the way to the end of the
+ * tvbuff"), fetch BCD encoded digits from a tvbuff starting from either
+ * the low or high half byte, formating the digits according to an input digit set,
+ * if NUll a default digit set of 0-9 returning "?" for overdecadic digits will be used.
+ * A pointer to the EP allocated string will be returned.
+ * Note a tvbuff content of 0xf is considered a 'filler' and will end the conversion.
+ */
+static dgt_set_t Dgt1_9_bcd = {
+ {
+ /* 0 1 2 3 4 5 6 7 8 9 a b c d e */
+ '0','1','2','3','4','5','6','7','8','9','?','?','?','?','?'
+ }
+};
+gchar *
+tvb_bcd_dig_to_ep_str(tvbuff_t *tvb, const gint offset, const gint len, dgt_set_t *dgt, gboolean skip_first)
+{
+ int length;
+ guint8 octet;
+ int i=0;
+ char *digit_str;
+ gint t_offset = offset;
+
+ if (!dgt)
+ dgt = &Dgt1_9_bcd;
+
+ if( len == -1){
+ length = tvb_length(tvb);
+ if (length < offset){
+ return "";
+ }
+ }else{
+ length = offset + len;
+ }
+ digit_str = ep_alloc((length - offset)*2+1);
+
+ while ( t_offset < length ){
+
+ octet = tvb_get_guint8(tvb,t_offset);
+ if (!skip_first){
+ digit_str[i] = dgt->out[octet & 0x0f];
+ i++;
+ }
+ skip_first = FALSE;
+
+ /*
+ * unpack second value in byte
+ */
+ octet = octet >> 4;
+
+ if (octet == 0x0f) /* odd number bytes - hit filler */
+ break;
+
+ digit_str[i] = dgt->out[octet & 0x0f];
+ i++;
+ t_offset++;
+
+ }
+ digit_str[i]= '\0';
+ return digit_str;
+
+}
+
/*
* Format a bunch of data from a tvbuff as bytes, returning a pointer
* to the string with the formatted data.
extern gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, const gint offset, const gint len,
const gchar punct);
-/*
+/**
* Format a bunch of data from a tvbuff as bytes, returning a pointer
* to the string with the formatted data.
*/
extern gchar *tvb_bytes_to_str(tvbuff_t *tvb, const gint offset, const gint len);
+/**
+ * Given a tvbuff, an offset into the tvbuff, and a length that starts
+ * at that offset (which may be -1 for "all the way to the end of the
+ * tvbuff"), fetch BCD encoded digits from a tvbuff starting from either
+ * the low or high half byte, formating the digits according to an input digit set,
+ * if NUll a default digit set of 0-9 returning "?" for overdecadic digits will be used.
+ * A pointer to the EP allocated string will be returned.
+ * Note a tvbuff content of 0xf is considered a 'filler' and will end the conversion.
+ */
+typedef struct dgt_set_t
+{
+ const unsigned char out[15];
+}
+dgt_set_t;
+
+extern gchar *tvb_bcd_dig_to_ep_str(tvbuff_t *tvb, const gint offset, const gint len, dgt_set_t *dgt, gboolean skip_first);
+
#define TVB_GET_DS_TVB(tvb) \
(tvb->ds_tvb)