Fix dissection of IP addresses in unaligned PER.

Add dissection of MSISDN and IMSI to the ULP dissector.

svn path=/trunk/; revision=22233
This commit is contained in:
Anders Broman 2007-07-03 09:08:31 +00:00
parent 8d3fd802e3
commit 44a41824c3
4 changed files with 110 additions and 17 deletions

View File

@ -42,6 +42,7 @@
#include "packet-per.h"
#include <epan/emem.h>
#include "packet-tcp.h"
#include "packet-gsm_map.h"
#define PNAME "OMA UserPlane Location Protocol"
#define PSNAME "ULP"

View File

@ -1,6 +1,6 @@
# upl.cnf
# upl conformation file
# Copyright 2006 Anders Broman
# Copyright 2006-2007 Anders Broman
# $Id$
#.OPT
@ -55,7 +55,34 @@ guint32 UlpMessage;
call_dissector(rrlp_handle, rrlp_tvb, %(ACTX)s->pinfo, tree);
}
#.FN_BODY SETId/msisdn VAL_PTR = &parameter_tvb
tvbuff_t *parameter_tvb;
asn1_ctx_t asn1_ctx;
/* "Hide" the first dissection to avoid double tree entries */
hf_index = -1;
%(DEFAULT_BODY)s
if(!parameter_tvb)
return offset;
/* msisdn is ISDN-addressstring */
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, actx->pinfo);
dissect_gsm_map_ISDN_AddressString(TRUE, parameter_tvb, 0, &asn1_ctx, tree, hf_ulp_msisdn);
#.FN_BODY SETId/imsi VAL_PTR = &parameter_tvb
tvbuff_t *parameter_tvb;
asn1_ctx_t asn1_ctx;
/* "Hide" the first dissection to avoid double tree entries */
hf_index = -1;
%(DEFAULT_BODY)s
if(!parameter_tvb)
return offset;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, actx->pinfo);
dissect_gsm_map_IMSI(TRUE, parameter_tvb, 0, &asn1_ctx, tree, hf_ulp_imsi);
#.TYPE_ATTR
IPAddress/ipv4Address TYPE = FT_IPv6 DISPLAY = BASE_NONE STRINGS = NULL
IPAddress/ipv4Address TYPE = FT_IPv4 DISPLAY = BASE_NONE STRINGS = NULL
IPAddress/ipv6Address TYPE = FT_IPv6 DISPLAY = BASE_NONE STRINGS = NULL
#.END

View File

@ -1762,7 +1762,11 @@ DEBUG_ENTRY("dissect_per_octet_string");
gboolean bit;
val_start = offset>>3;
val_length = min_len;
buff = ep_alloc(min_len);
if (display_internal_per_fields)
proto_tree_add_text(tree, tvb, val_start, min_len, "min=max=%u",min_len);
while (j < (guint32)min_len){
for(i=0;i<8;i++){
offset=dissect_per_boolean(tvb, offset, actx, tree, -1, &bit);
@ -1771,8 +1775,13 @@ DEBUG_ENTRY("dissect_per_octet_string");
j = j+1;
}
pbytes = buff;
val_length = min_len;
/* XXX should we return a new tvb with the octetstring? */
out_tvb = tvb_new_real_data(buff,min_len,min_len);
/* Arrange that the allocated packet data copy be freed when the
* tvbuff is freed.
*/
tvb_set_free_cb(out_tvb, g_free );
tvb_set_child_real_data_tvbuff(tvb,out_tvb);
add_new_data_source(actx->pinfo, out_tvb, "PER unaligned decoded OCTET STRING");
}
} else { /* 16.8 */
@ -1835,7 +1844,13 @@ DEBUG_ENTRY("dissect_per_octet_string");
actx->created_item = proto_tree_add_string(tree, hf_index, tvb, val_start, val_length, (char*)pbytes);
} else if (hfi->type==FT_BYTES) {
actx->created_item = proto_tree_add_bytes(tree, hf_index, tvb, val_start, val_length, pbytes);
} else if (hfi->type==FT_IPv4) {
actx->created_item = proto_tree_add_ipv4(tree, hf_index, tvb, val_start, val_length, (guint32)pbytes);
} else if (hfi->type==FT_IPv6) {
actx->created_item = proto_tree_add_ipv6(tree, hf_index, tvb, val_start, val_length, pbytes);
} else {
if (display_internal_per_fields)
proto_tree_add_text(tree, tvb, val_start, min_len, "hf field is not FT_STRING, FT_BYTES or FT_IPv4/6 %s",hfi->name);
THROW(ReportedBoundsError);
}
} else {

View File

@ -50,6 +50,7 @@
#include "packet-per.h"
#include <epan/emem.h>
#include "packet-tcp.h"
#include "packet-gsm_map.h"
#define PNAME "OMA UserPlane Location Protocol"
#define PSNAME "ULP"
@ -159,10 +160,10 @@ static int hf_ulp_setSessionID = -1; /* SetSessionID */
static int hf_ulp_slpSessionID = -1; /* SlpSessionID */
static int hf_ulp_sessionId = -1; /* INTEGER_0_65535 */
static int hf_ulp_setId = -1; /* SETId */
static int hf_ulp_msisdn = -1; /* OCTET_STRING_SIZE_8 */
static int hf_ulp_msisdn = -1; /* T_msisdn */
static int hf_ulp_mdn = -1; /* OCTET_STRING_SIZE_8 */
static int hf_ulp_minsi = -1; /* BIT_STRING_SIZE_34 */
static int hf_ulp_imsi = -1; /* OCTET_STRING_SIZE_8 */
static int hf_ulp_imsi = -1; /* T_imsi */
static int hf_ulp_nai = -1; /* IA5String_SIZE_1_1000 */
static int hf_ulp_iPAddress = -1; /* IPAddress */
static int hf_ulp_sessionSlpID = -1; /* OCTET_STRING_SIZE_4 */
@ -251,7 +252,7 @@ static int hf_ulp_horuncertspeed = -1; /* BIT_STRING_SIZE_8 */
static int hf_ulp_veruncertspeed = -1; /* BIT_STRING_SIZE_8 */
/*--- End of included file: packet-ulp-hf.c ---*/
#line 68 "packet-ulp-template.c"
#line 69 "packet-ulp-template.c"
/* Initialize the subtree pointers */
static gint ett_ulp = -1;
@ -318,7 +319,7 @@ static gint ett_ulp_Horveluncert = -1;
static gint ett_ulp_Horandveruncert = -1;
/*--- End of included file: packet-ulp-ett.c ---*/
#line 72 "packet-ulp-template.c"
#line 73 "packet-ulp-template.c"
/* Include constants */
@ -331,7 +332,7 @@ static gint ett_ulp_Horandveruncert = -1;
#define maxTS 14
/*--- End of included file: packet-ulp-val.h ---*/
#line 75 "packet-ulp-template.c"
#line 76 "packet-ulp-template.c"
@ -375,6 +376,31 @@ dissect_ulp_Version(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, pro
static int
dissect_ulp_T_msisdn(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 59 "ulp.cnf"
tvbuff_t *parameter_tvb;
asn1_ctx_t asn1_ctx;
/* "Hide" the first dissection to avoid double tree entries */
hf_index = -1;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
8, 8, &parameter_tvb);
if(!parameter_tvb)
return offset;
/* msisdn is ISDN-addressstring */
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, actx->pinfo);
dissect_gsm_map_ISDN_AddressString(TRUE, parameter_tvb, 0, &asn1_ctx, tree, hf_ulp_msisdn);
return offset;
}
static int
dissect_ulp_OCTET_STRING_SIZE_8(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
@ -395,6 +421,30 @@ dissect_ulp_BIT_STRING_SIZE_34(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac
static int
dissect_ulp_T_imsi(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 73 "ulp.cnf"
tvbuff_t *parameter_tvb;
asn1_ctx_t asn1_ctx;
/* "Hide" the first dissection to avoid double tree entries */
hf_index = -1;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
8, 8, &parameter_tvb);
if(!parameter_tvb)
return offset;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, actx->pinfo);
dissect_gsm_map_IMSI(TRUE, parameter_tvb, 0, &asn1_ctx, tree, hf_ulp_imsi);
return offset;
}
static int
dissect_ulp_IA5String_SIZE_1_1000(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_IA5String(tvb, offset, actx, tree, hf_index,
@ -457,10 +507,10 @@ static const value_string ulp_SETId_vals[] = {
};
static const per_choice_t SETId_choice[] = {
{ 0, &hf_ulp_msisdn , ASN1_EXTENSION_ROOT , dissect_ulp_OCTET_STRING_SIZE_8 },
{ 0, &hf_ulp_msisdn , ASN1_EXTENSION_ROOT , dissect_ulp_T_msisdn },
{ 1, &hf_ulp_mdn , ASN1_EXTENSION_ROOT , dissect_ulp_OCTET_STRING_SIZE_8 },
{ 2, &hf_ulp_minsi , ASN1_EXTENSION_ROOT , dissect_ulp_BIT_STRING_SIZE_34 },
{ 3, &hf_ulp_imsi , ASN1_EXTENSION_ROOT , dissect_ulp_OCTET_STRING_SIZE_8 },
{ 3, &hf_ulp_imsi , ASN1_EXTENSION_ROOT , dissect_ulp_T_imsi },
{ 4, &hf_ulp_nai , ASN1_EXTENSION_ROOT , dissect_ulp_IA5String_SIZE_1_1000 },
{ 5, &hf_ulp_iPAddress , ASN1_EXTENSION_ROOT , dissect_ulp_IPAddress },
{ 0, NULL, 0, NULL }
@ -2138,7 +2188,7 @@ static void dissect_ULP_PDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto
/*--- End of included file: packet-ulp-fn.c ---*/
#line 78 "packet-ulp-template.c"
#line 79 "packet-ulp-template.c"
static guint
@ -2505,7 +2555,7 @@ void proto_register_ulp(void) {
{ &hf_ulp_msisdn,
{ "msisdn", "ulp.msisdn",
FT_BYTES, BASE_HEX, NULL, 0,
"ulp.OCTET_STRING_SIZE_8", HFILL }},
"ulp.T_msisdn", HFILL }},
{ &hf_ulp_mdn,
{ "mdn", "ulp.mdn",
FT_BYTES, BASE_HEX, NULL, 0,
@ -2517,7 +2567,7 @@ void proto_register_ulp(void) {
{ &hf_ulp_imsi,
{ "imsi", "ulp.imsi",
FT_BYTES, BASE_HEX, NULL, 0,
"ulp.OCTET_STRING_SIZE_8", HFILL }},
"ulp.T_imsi", HFILL }},
{ &hf_ulp_nai,
{ "nai", "ulp.nai",
FT_STRING, BASE_NONE, NULL, 0,
@ -2536,7 +2586,7 @@ void proto_register_ulp(void) {
"ulp.SLPAddress", HFILL }},
{ &hf_ulp_ipv4Address,
{ "ipv4Address", "ulp.ipv4Address",
FT_IPv6, BASE_NONE, NULL, 0,
FT_IPv4, BASE_NONE, NULL, 0,
"ulp.OCTET_STRING_SIZE_4", HFILL }},
{ &hf_ulp_ipv6Address,
{ "ipv6Address", "ulp.ipv6Address",
@ -2864,7 +2914,7 @@ void proto_register_ulp(void) {
"ulp.BIT_STRING_SIZE_8", HFILL }},
/*--- End of included file: packet-ulp-hfarr.c ---*/
#line 103 "packet-ulp-template.c"
#line 104 "packet-ulp-template.c"
};
/* List of subtrees */
@ -2933,7 +2983,7 @@ void proto_register_ulp(void) {
&ett_ulp_Horandveruncert,
/*--- End of included file: packet-ulp-ettarr.c ---*/
#line 109 "packet-ulp-template.c"
#line 110 "packet-ulp-template.c"
};
module_t *ulp_module;