diff options
author | Bill Meier <wmeier@newsguy.com> | 2012-11-28 22:41:07 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2012-11-28 22:41:07 +0000 |
commit | a8112e652975ae9e626e15ade4e85370c965df47 (patch) | |
tree | 3105e7fc230def18471bd597db5bc4f84428ff2e | |
parent | 84afa22969e1ce3dd2d30ebf585c468559e6ff7b (diff) |
Fix [-Wshadow] warnings;
Also (for one or more of the files):
- create/use one or more extended variable strings;
- remove some uneeded variable initializers;
- reformat some long lines;
- reformat hf[] entries;
- convert apparent 4-space tabs to spaces;
- do some whitespace and formatting changes to use a consistent style.
svn path=/trunk/; revision=46265
-rw-r--r-- | epan/dissectors/packet-iso7816.c | 50 | ||||
-rw-r--r-- | epan/dissectors/packet-netrom.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-sasp.c | 985 | ||||
-rw-r--r-- | epan/dissectors/packet-sgsap.c | 1599 | ||||
-rw-r--r-- | epan/dissectors/packet-wai.c | 899 | ||||
-rw-r--r-- | epan/dissectors/packet-xml.c | 2365 |
6 files changed, 3134 insertions, 2770 deletions
diff --git a/epan/dissectors/packet-iso7816.c b/epan/dissectors/packet-iso7816.c index 953e9c4a65..03c384cc6b 100644 --- a/epan/dissectors/packet-iso7816.c +++ b/epan/dissectors/packet-iso7816.c @@ -42,7 +42,7 @@ static int proto_iso7816 = -1; static int proto_iso7816_atr = -1; -static dissector_handle_t iso7816_atr_handle = NULL; +static dissector_handle_t iso7816_atr_handle; static int ett_iso7816 = -1; static int ett_iso7816_class = -1; @@ -129,6 +129,7 @@ static const value_string iso7816_ins[] = { { INS_APPEND_REC, "Append record" }, { 0, NULL } }; +static value_string_ext iso7816_ins_ext = VALUE_STRING_EXT_INIT(iso7816_ins); static const range_string iso7816_sw1[] = { { 0x61, 0x61, "Normal processing" }, @@ -146,8 +147,8 @@ dissect_iso7816_atr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d gint offset=0; guint8 init_char; guint i=0; /* loop index for TA(i)...TD(i) */ - proto_item *proto_it = NULL, *td_it; - proto_tree *proto_tree = NULL, *td_tree=NULL; + proto_item *proto_it; + proto_tree *proto_tr; guint8 ta, tb, tc, td, k=0; gint tck_len; proto_item *err_it; @@ -158,25 +159,28 @@ dissect_iso7816_atr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d proto_it = proto_tree_add_protocol_format(tree, proto_iso7816_atr, tvb, 0, -1, "ISO 7816 ATR"); - proto_tree = proto_item_add_subtree(proto_it, ett_iso7816_atr); - + proto_tr = proto_item_add_subtree(proto_it, ett_iso7816_atr); + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ATR"); /* ISO 7816-4, section 4 indicates that concatenations are big endian */ - proto_tree_add_item(proto_tree, hf_iso7816_atr_init_char, + proto_tree_add_item(proto_tr, hf_iso7816_atr_init_char, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; do { + proto_item *td_it; + proto_tree *td_tree; + /* for i==0, this is the T0 byte, otherwise it's the TD(i) byte in each loop, we dissect T0/TD(i) and TA(i+1), TB(i+1), TC(i+1) */ td = tvb_get_guint8(tvb, offset); if (i==0) { - td_it = proto_tree_add_item(proto_tree, hf_iso7816_atr_t0, + td_it = proto_tree_add_item(proto_tr, hf_iso7816_atr_t0, tvb, offset, 1, ENC_BIG_ENDIAN); } else { - td_it = proto_tree_add_uint_format(proto_tree, hf_iso7816_atr_td, + td_it = proto_tree_add_uint_format(proto_tr, hf_iso7816_atr_td, tvb, offset, 1, td, "Interface character TD(%d): 0x%02x", i, td); } @@ -216,21 +220,21 @@ dissect_iso7816_atr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d if (td&0x10) { ta = tvb_get_guint8(tvb, offset); /* we read TA(i+1), see comment above */ - proto_tree_add_uint_format(proto_tree, hf_iso7816_atr_ta, + proto_tree_add_uint_format(proto_tr, hf_iso7816_atr_ta, tvb, offset, 1, ta, "Interface character TA(%d): 0x%02x", i+1, ta); offset++; } if (td&0x20) { tb = tvb_get_guint8(tvb, offset); - proto_tree_add_uint_format(proto_tree, hf_iso7816_atr_tb, + proto_tree_add_uint_format(proto_tr, hf_iso7816_atr_tb, tvb, offset, 1, tb, "Interface character TB(%d): 0x%02x", i+1, tb); offset++; } if (td&0x40) { tc = tvb_get_guint8(tvb, offset); - proto_tree_add_uint_format(proto_tree, hf_iso7816_atr_tc, + proto_tree_add_uint_format(proto_tr, hf_iso7816_atr_tc, tvb, offset, 1, tc, "Interface character TC(%d): 0x%02x", i+1, tc); offset++; @@ -240,7 +244,7 @@ dissect_iso7816_atr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d } while (td&0x80); if (k>0) { - proto_tree_add_item(proto_tree, hf_iso7816_atr_hist_bytes, + proto_tree_add_item(proto_tr, hf_iso7816_atr_hist_bytes, tvb, offset, k, ENC_NA); offset += k; } @@ -248,12 +252,12 @@ dissect_iso7816_atr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d tck_len = tvb_reported_length_remaining(tvb, offset); /* tck is either absent or exactly one byte */ if (tck_len==1) { - proto_tree_add_item(proto_tree, hf_iso7816_atr_tck, + proto_tree_add_item(proto_tr, hf_iso7816_atr_tck, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; } else if (tck_len>1) { - err_it = proto_tree_add_text(proto_tree, tvb, offset, tck_len, + err_it = proto_tree_add_text(proto_tr, tvb, offset, tck_len, "Invalid TCK byte"); expert_add_info_format(pinfo, err_it, PI_PROTOCOL, PI_WARN, "TCK byte must either be absent or exactly one byte"); @@ -271,9 +275,9 @@ dissect_iso7816_class(tvbuff_t *tvb, gint offset, { gint ret_fct = 1; proto_item *class_item; - proto_tree *class_tree = NULL; + proto_tree *class_tree; guint8 class; - proto_item *enc_item = NULL; + proto_item *enc_item; guint8 channel; proto_item *ch_item; @@ -363,7 +367,7 @@ dissect_iso7816_cmd_apdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ins = tvb_get_guint8(tvb, offset); proto_tree_add_item(tree, hf_iso7816_ins, tvb, offset, 1, ENC_BIG_ENDIAN); col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "%s", - val_to_str_const(ins, iso7816_ins, "Unknown instruction")); + val_to_str_ext_const(ins, &iso7816_ins_ext, "Unknown instruction")); offset++; proto_tree_add_item(tree, hf_iso7816_p1, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -424,14 +428,14 @@ dissect_iso7816_resp_apdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return offset; } - + static int dissect_iso7816(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - gint offset = 0; - proto_item *tree_ti = NULL; - proto_tree *iso7816_tree = NULL; - gboolean is_atr = FALSE; + gint offset = 0; + proto_item *tree_ti = NULL; + proto_tree *iso7816_tree = NULL; + gboolean is_atr = FALSE; if (pinfo->p2p_dir!=P2P_DIR_SENT && pinfo->p2p_dir!=P2P_DIR_RECV) return 0; @@ -552,7 +556,7 @@ proto_register_iso7816(void) }, { &hf_iso7816_ins, { "Instruction", "iso7816.apdu.ins", - FT_UINT8, BASE_HEX, VALS(iso7816_ins), 0, NULL, HFILL } + FT_UINT8, BASE_HEX | BASE_EXT_STRING, &iso7816_ins_ext, 0, NULL, HFILL } }, { &hf_iso7816_p1, { "Parameter 1", "iso7816.apdu.p1", diff --git a/epan/dissectors/packet-netrom.c b/epan/dissectors/packet-netrom.c index d4e7ecee4c..669fbf8127 100644 --- a/epan/dissectors/packet-netrom.c +++ b/epan/dissectors/packet-netrom.c @@ -152,7 +152,7 @@ static gint ett_netrom_type = -1; static void dissect_netrom_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, - int hf_netrom_type, gint ett_netrom_type, const netrom_tf_items *type_items ) + int hf_netrom_type_param, gint ett_netrom_type_param, const netrom_tf_items *type_items ) { proto_tree *tc; proto_tree *type_tree; @@ -174,7 +174,7 @@ dissect_netrom_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *t if ( tree ) { tc = proto_tree_add_uint_format( tree, - hf_netrom_type, + hf_netrom_type_param, tvb, offset, 1, @@ -182,7 +182,7 @@ dissect_netrom_type(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *t "Type field: %s", info_buffer ); - type_tree = proto_item_add_subtree( tc, ett_netrom_type ); + type_tree = proto_item_add_subtree( tc, ett_netrom_type_param ); proto_tree_add_item( type_tree, *type_items->hf_tf_op, tvb, offset, 1, FALSE ); proto_tree_add_item( type_tree, *type_items->hf_tf_choke, tvb, offset, 1, FALSE ); diff --git a/epan/dissectors/packet-sasp.c b/epan/dissectors/packet-sasp.c index 9680b77712..88930359e5 100644 --- a/epan/dissectors/packet-sasp.c +++ b/epan/dissectors/packet-sasp.c @@ -36,24 +36,24 @@ /* forward reference */ static void dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); -static void dissect_reg_req(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static void dissect_dereg_req(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static void dissect_reg_rep(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static void dissect_dereg_rep(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static void dissect_sendwt(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static void dissect_setmemstate_req(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static void dissect_setmemstate_rep(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static void dissect_setlbstate_req(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static void dissect_setlbstate_rep(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static void dissect_wt_req(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static void dissect_wt_rep(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static guint32 dissect_grpdatacomp(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb, proto_tree *tree,guint32 offset); -static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static guint32 dissect_memstatedatacomp(tvbuff_t *tvb,proto_tree *tree,guint32 offset); -static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset); -static guint32 dissect_grp_wt_entry_datacomp(tvbuff_t *tvb,proto_tree *tree,guint32 offset); +static void dissect_reg_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_dereg_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_reg_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_dereg_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_sendwt(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_setmemstate_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_setmemstate_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_setlbstate_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_setlbstate_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_wt_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static void dissect_wt_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, proto_tree **mdct_p); +static guint32 dissect_grpdatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static guint32 dissect_memstatedatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset); +static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset); +static guint32 dissect_grp_wt_entry_datacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset); @@ -158,21 +158,21 @@ static int hf_sasp_grp_memstatedatacomp_sz = -1; static int hf_sasp_grp_memstatedatacomp_cnt = -1; /*mem state data comp*/ -static int hf_sasp_memstatedatacomp_instance =-1; -static int hf_sasp_memstatedatacomp_sz =-1; -static int hf_sasp_memstatedatacomp_state =-1; -static int hf_sasp_memstatedatacomp_quiesce_flag =-1; +static int hf_sasp_memstatedatacomp_instance = -1; +static int hf_sasp_memstatedatacomp_sz = -1; +static int hf_sasp_memstatedatacomp_state = -1; +static int hf_sasp_memstatedatacomp_quiesce_flag = -1; /*wt entry dat comp*/ -static int hf_sasp_weight_entry_data_comp_type =-1; -static int hf_sasp_weight_entry_data_comp_sz =-1; -static int hf_sasp_weight_entry_data_comp_state =-1; +static int hf_sasp_weight_entry_data_comp_type = -1; +static int hf_sasp_weight_entry_data_comp_sz = -1; +static int hf_sasp_weight_entry_data_comp_state = -1; static int hf_wtstate_flag = -1; -static int hf_sasp_wed_contactsuccess_flag =-1; -static int hf_sasp_wed_quiesce_flag =-1; -static int hf_sasp_wed_registration_flag =-1; -static int hf_sasp_wed_confident_flag =-1; -static int hf_sasp_weight_entry_data_comp_weight =-1; +static int hf_sasp_wed_contactsuccess_flag = -1; +static int hf_sasp_wed_quiesce_flag = -1; +static int hf_sasp_wed_registration_flag = -1; +static int hf_sasp_wed_confident_flag = -1; +static int hf_sasp_weight_entry_data_comp_weight = -1; /*grp wt entry data comp */ static int hf_sasp_grp_wt_entry_datacomp_type = -1; @@ -188,23 +188,23 @@ static gint ett_sasp_payload = -1; static gint ett_sasp_reg_req = -1; static gint ett_sasp_reg_rep = -1; static gint ett_sasp_reg_req_sz = -1; -static gint ett_sasp_dereg_req_sz=-1; +static gint ett_sasp_dereg_req_sz= -1; static gint ett_sasp_dereg_rep = -1; static gint ett_sasp_sendwt = -1; static gint ett_sasp_setmemstate_rep = -1; static gint ett_sasp_memdatacomp = -1; static gint ett_sasp_grpdatacomp = -1; static gint ett_sasp_grp_memdatacomp = -1; -static gint ett_sasp_setlbstate_req =-1; -static gint ett_sasp_setlbstate_rep =-1; +static gint ett_sasp_setlbstate_req = -1; +static gint ett_sasp_setlbstate_rep = -1; static gint ett_sasp_getwt= -1; static gint ett_sasp_setmemstate_req = -1; static gint ett_setlbstate_req_lbflag = -1; -static gint ett_sasp_grp_memstatedatacomp =-1; -static gint ett_sasp_memstatedatacomp =-1; +static gint ett_sasp_grp_memstatedatacomp = -1; +static gint ett_sasp_memstatedatacomp = -1; /*static gint ett_dereg_req_reason_flag = -1;*/ static gint ett_sasp_grp_wt_entry_datacomp = -1; -static gint ett_sasp_weight_entry_data_comp =-1; +static gint ett_sasp_weight_entry_data_comp = -1; static gint ett_wt_entry_data_flag = -1; static gint ett_sasp_wt_rep = -1; @@ -232,6 +232,7 @@ static const value_string msg_table[] = { { 0x4012, "Group of Member State Data" }, { 0, NULL }, }; +static value_string_ext msg_table_ext = VALUE_STRING_EXT_INIT(msg_table); static const value_string protocol_table[] = { { 0x06, "TCP" }, @@ -257,7 +258,8 @@ static const value_string reg_reply_response_code[] = { { 0x45, "Invalid Group (determined by the GWM)"}, { 0x50, "Invalid Group Name Size (size == 0)"}, { 0x51, "Invalid LB uid Size (size == 0 or > max)"}, - { 0x61, "Member is registering itself, but LB hasn't yet contacted the GWM. This registration will not be processed."}, + { 0x61, "Member is registering itself, but LB hasn't yet contacted the GWM." + " This registration will not be processed."}, { 0, NULL }, }; @@ -271,7 +273,8 @@ static const value_string dereg_reply_response_code[] = { { 0x44, "Duplicate Member in Request"}, { 0x46, "Duplicate Group in Request (for remove all members/groups requests)"}, { 0x51, "Invalid LB uid Size (size == 0 or > max)"}, - { 0x61, "Member is deregistering itself, but LB hasn't yet contacted the GWM. This deregistration will not be processed."}, + { 0x61, "Member is deregistering itself, but LB hasn't yet contacted the GWM." + " This deregistration will not be processed."}, { 0, NULL }, }; @@ -309,25 +312,20 @@ static const value_string set_mem_state_reply_response_code[] = { }; -static proto_item *memdatacomp = NULL; -static proto_tree *memdatacomp_tree = NULL; - - - #define SASP_GLOBAL_PORT 3860 #define SASP_MIN_PACKET_LEN 13 -#define SASP_DEREG_REQ_REASON_LEARNED 0x01 -#define SASP_DEREG_REQ_NOREASON_FLAG 0x00 -#define SASP_HDR_TYPE 0x2010 -#define SASP_WED_CONTACT_SUCCESS_FLAG 0x01 -#define SASP_WED_QUIESCE_FLAG 0x02 -#define SASP_WED_REG_FLAG 0x04 -#define SASP_WED_CONF_FLAG 0x08 -#define SASP_PUSH_FLAG 0x01 -#define SASP_TRUST_FLAG 0x02 -#define SASP_NOCHANGE_FLAG 0x04 -#define SASP_QUIESCE_FLAG 0x01 +#define SASP_DEREG_REQ_REASON_LEARNED 0x01 +#define SASP_DEREG_REQ_NOREASON_FLAG 0x00 +#define SASP_HDR_TYPE 0x2010 +#define SASP_WED_CONTACT_SUCCESS_FLAG 0x01 +#define SASP_WED_QUIESCE_FLAG 0x02 +#define SASP_WED_REG_FLAG 0x04 +#define SASP_WED_CONF_FLAG 0x08 +#define SASP_PUSH_FLAG 0x01 +#define SASP_TRUST_FLAG 0x02 +#define SASP_NOCHANGE_FLAG 0x04 +#define SASP_QUIESCE_FLAG 0x01 @@ -379,12 +377,12 @@ dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, "SASP"); col_clear(pinfo->cinfo, COL_INFO); - ti = proto_tree_add_item(tree,proto_sasp,tvb,offset,-1,ENC_NA); - sasp_tree = proto_item_add_subtree(ti,ett_sasp_header); + ti = proto_tree_add_item(tree, proto_sasp, tvb, offset, -1, ENC_NA); + sasp_tree = proto_item_add_subtree(ti, ett_sasp_header); hdr_type = tvb_get_ntohs(tvb, offset); - hti = proto_tree_add_uint_format(sasp_tree,hf_sasp_type,tvb,offset,2,hdr_type, - "Type: %s", (hdr_type==SASP_HDR_TYPE) ? "SASP" : "[Invalid]"); + hti = proto_tree_add_uint_format(sasp_tree, hf_sasp_type, tvb, offset, 2, hdr_type, + "Type: %s", (hdr_type == SASP_HDR_TYPE) ? "SASP" : "[Invalid]"); if (hdr_type != SASP_HDR_TYPE) { expert_add_info_format(pinfo, hti, PI_MALFORMED, PI_ERROR, "Invalid SASP Header Type [0x%04x]", hdr_type); @@ -392,32 +390,32 @@ dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_set_str(pinfo->cinfo, COL_INFO, "[Malformed: Invalid SASP Header Type]"); return; } - offset+=2; + offset += 2; /*length*/ - proto_tree_add_item(sasp_tree,hf_sasp_length,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(sasp_tree, hf_sasp_length, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /*Header Version */ - proto_tree_add_item(sasp_tree,hf_sasp_vrsn,tvb,offset,1,ENC_BIG_ENDIAN); - offset++; + proto_tree_add_item(sasp_tree, hf_sasp_vrsn, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /*Message*/ - msg_tree = proto_item_add_subtree(ti,ett_sasp_msg); + msg_tree = proto_item_add_subtree(ti, ett_sasp_msg); /*Message Len*/ - proto_tree_add_item(msg_tree,hf_msg_len,tvb,offset,4,ENC_BIG_ENDIAN); - offset+=4; + proto_tree_add_item(msg_tree, hf_msg_len, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; /*Message Id*/ - proto_tree_add_item(msg_tree,hf_msg_id,tvb,offset,4,ENC_BIG_ENDIAN); - offset+=4; + proto_tree_add_item(msg_tree, hf_msg_id, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; /*Message Type*/ msg_type = tvb_get_ntohs(tvb, offset); - mti = proto_tree_add_item(msg_tree,hf_msg_type,tvb,offset,2,ENC_BIG_ENDIAN); - pay_load = proto_item_add_subtree(ti,ett_sasp_payload); - offset+=2; + mti = proto_tree_add_item(msg_tree, hf_msg_type, tvb, offset, 2, ENC_BIG_ENDIAN); + pay_load = proto_item_add_subtree(ti, ett_sasp_payload); + offset += 2; @@ -426,83 +424,84 @@ dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case 0x1010: /* Registration Request */ col_set_str(pinfo->cinfo, COL_INFO, "Registration Request"); - dissect_reg_req(tvb,pay_load,offset); + dissect_reg_req(tvb, pay_load, offset); return; case 0x1015: /* Registration Reply */ col_set_str(pinfo->cinfo, COL_INFO, "Registration Reply"); - dissect_reg_rep(tvb,pay_load,offset); + dissect_reg_rep(tvb, pay_load, offset); return; case 0x1020: /* Deregistration Request */ col_set_str(pinfo->cinfo, COL_INFO, "Deregistration Request"); - dissect_dereg_req(tvb,pay_load,offset); + dissect_dereg_req(tvb, pay_load, offset); return; case 0x1025: /* Deregistration Reply */ col_set_str(pinfo->cinfo, COL_INFO, "Deregistration Reply"); - dissect_dereg_rep(tvb,pay_load,offset); + dissect_dereg_rep(tvb, pay_load, offset); return; case 0x1030: /* Get Weights Request */ col_set_str(pinfo->cinfo, COL_INFO, "Get Weights Request"); - dissect_wt_req(tvb,pay_load,offset); + dissect_wt_req(tvb, pay_load, offset); return; case 0x1035: /* Get Weights Response */ col_set_str(pinfo->cinfo, COL_INFO, "Get Weights Response"); - dissect_wt_rep(tvb,pay_load,offset); + dissect_wt_rep(tvb, pay_load, offset); return; case 0x1040: /* Send Weights Request */ col_set_str(pinfo->cinfo, COL_INFO, "Send Weights Request"); - dissect_sendwt(tvb,pay_load,offset); + dissect_sendwt(tvb, pay_load, offset); return; case 0x1050: /* Set LB State Request */ col_set_str(pinfo->cinfo, COL_INFO, "Set LB State Request"); - dissect_setlbstate_req(tvb,pay_load,offset); + dissect_setlbstate_req(tvb, pay_load, offset); return; case 0x1055: /* Set LB state Reply */ col_set_str(pinfo->cinfo, COL_INFO, "Set LB State Reply"); - dissect_setlbstate_rep(tvb,pay_load,offset); + dissect_setlbstate_rep(tvb, pay_load, offset); return; case 0x1060: /* Set Member State Request*/ col_set_str(pinfo->cinfo, COL_INFO, "Set Member State Request"); - dissect_setmemstate_req(tvb,pay_load,offset); + dissect_setmemstate_req(tvb, pay_load, offset); return; case 0x1065: /* Set Member State Reply */ col_set_str(pinfo->cinfo, COL_INFO, "Set Member State Reply"); - dissect_setmemstate_rep(tvb,pay_load,offset); + dissect_setmemstate_rep(tvb, pay_load, offset); return; default: /* Unknown SASP Message Type */ - col_add_fstr(pinfo->cinfo, COL_INFO, "[Malformed: Unknown Message Type [0x%04x]", msg_type); + col_add_fstr(pinfo->cinfo, COL_INFO, + "[Malformed: Unknown Message Type [0x%04x]", msg_type); expert_add_info_format(pinfo, mti, PI_MALFORMED, PI_WARN, "Unknown SASP Message Type: 0x%4x", msg_type); return; @@ -511,74 +510,73 @@ dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } -static void dissect_reg_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_reg_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 gmd_cnt,i; - proto_item *reg_tree; proto_tree *reg_req_data; + guint16 gmd_cnt, i; + - reg_tree = proto_tree_add_text(pay_load,tvb,offset,-1,"Reg Request"); + reg_tree = proto_tree_add_text(pay_load, tvb, offset, -1, "Reg Request"); reg_req_data = proto_item_add_subtree(reg_tree, ett_sasp_reg_req_sz); /* Reg Req Size */ proto_tree_add_item(reg_req_data, hf_sasp_reg_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN); - offset+=2; + offset += 2; /* Reg Req LB Flag */ - proto_tree_add_item(reg_req_data,hf_reg_req_lbflag,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(reg_req_data, hf_reg_req_lbflag, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; - gmd_cnt=tvb_get_ntohs(tvb, offset); + gmd_cnt = tvb_get_ntohs(tvb, offset); /* Group MEM Data Count */ - proto_tree_add_item(reg_req_data,hf_sasp_gmd_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(reg_req_data, hf_sasp_gmd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - for( i=0; i<gmd_cnt; i++) + for ( i=0; i<gmd_cnt; i++) { - offset = dissect_grp_memdatacomp(tvb,reg_req_data,offset); + offset = dissect_grp_memdatacomp(tvb, reg_req_data, offset); } } -static void dissect_reg_rep(tvbuff_t *tvb, proto_tree *pay_load,guint32 offset) +static void dissect_reg_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_item *reg_rep; proto_tree *reg_rep_tree; - reg_rep = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Reg Reply"); - reg_rep_tree = proto_item_add_subtree(reg_rep,ett_sasp_reg_rep); + reg_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Reg Reply"); + reg_rep_tree = proto_item_add_subtree(reg_rep, ett_sasp_reg_rep); /* Size */ - proto_tree_add_item(reg_rep_tree, hf_sasp_reg_rep_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(reg_rep_tree, hf_sasp_reg_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Response Code */ - proto_tree_add_item(reg_rep_tree, hf_sasp_reg_rep_rcode,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(reg_rep_tree, hf_sasp_reg_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; } -static void dissect_dereg_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_dereg_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 gmd_cnt,i; - proto_item *dereg_tree; - proto_tree *dereg_req_data; - /*proto_item *dereg_req_reason_flag;*/ /*proto_tree *dereg_req_reason_flag_tree;*/ + guint16 gmd_cnt, i; + proto_item *dereg_tree; + proto_tree *dereg_req_data; - guint8 reason_flag; + guint8 reason_flag; gboolean first_flag = TRUE; @@ -586,209 +584,215 @@ static void dissect_dereg_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) const gchar *fstr[] = {"No Reason", "Learned & Purposeful" }; - dereg_tree = proto_tree_add_text(pay_load,tvb,offset,-1 ,"DeReg Request"); - dereg_req_data = proto_item_add_subtree(dereg_tree,ett_sasp_dereg_req_sz); + dereg_tree = proto_tree_add_text(pay_load, tvb, offset, -1 , "DeReg Request"); + dereg_req_data = proto_item_add_subtree(dereg_tree, ett_sasp_dereg_req_sz); /* Size */ proto_tree_add_item(dereg_req_data, hf_sasp_dereg_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN); - offset+=2; + offset += 2; /* LB Flag */ - proto_tree_add_item(dereg_req_data,hf_dereg_req_lbflag,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(dereg_req_data, hf_dereg_req_lbflag, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /* Reason */ ep_strbuf_truncate(reasonflags_strbuf, 0); reason_flag = tvb_get_guint8(tvb, offset); - if((reason_flag & SASP_DEREG_REQ_REASON_LEARNED) == 0) + if ((reason_flag & SASP_DEREG_REQ_REASON_LEARNED) == 0) { - ep_strbuf_append_printf(reasonflags_strbuf, "%s%s",first_flag ? "" : ", ",fstr[0]); - first_flag=FALSE; + ep_strbuf_append_printf(reasonflags_strbuf, "%s%s", first_flag ? "" : ", ", fstr[0]); + first_flag = FALSE; } else { - ep_strbuf_append_printf(reasonflags_strbuf, "%s%s",first_flag ? "" : ", ",fstr[1]); - first_flag=FALSE; + ep_strbuf_append_printf(reasonflags_strbuf, "%s%s", first_flag ? "" : ", ", fstr[1]); + first_flag = FALSE; } - /*dereg_req_reason_flag =*/ proto_tree_add_uint_format(dereg_req_data,hf_dereg_req_reason_flag,tvb, - offset,1,reason_flag,"Reason: 0x%02x (%s)",reason_flag, - reasonflags_strbuf->str); + /*dereg_req_reason_flag =*/ proto_tree_add_uint_format(dereg_req_data, hf_dereg_req_reason_flag, tvb, + offset, 1, reason_flag, + "Reason: 0x%02x (%s)", reason_flag, + reasonflags_strbuf->str); #if 0 /* XXX: ToDo?? Flags to be displayed under a subtree ? */ - dereg_req_reason_flag_tree = proto_item_add_subtree(dereg_req_reason_flag,ett_dereg_req_reason_flag); + dereg_req_reason_flag_tree = proto_item_add_subtree(dereg_req_reason_flag, ett_dereg_req_reason_flag); #endif - offset+=1; + offset += 1; gmd_cnt = tvb_get_ntohs(tvb, offset); /* Group Mem Data Count */ - proto_tree_add_item(dereg_req_data,hf_sasp_gmd_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(dereg_req_data, hf_sasp_gmd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /*Group Mem Data */ - for( i=0; i<gmd_cnt; i++) + for ( i=0; i<gmd_cnt; i++) { - offset = dissect_grp_memdatacomp(tvb,dereg_req_data,offset); + offset = dissect_grp_memdatacomp(tvb, dereg_req_data, offset); } } -static void dissect_dereg_rep(tvbuff_t *tvb, proto_tree *pay_load,guint32 offset) +static void dissect_dereg_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_item *dereg_rep; proto_tree *dereg_rep_tree; - dereg_rep = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Dereg Reply"); - dereg_rep_tree = proto_item_add_subtree(dereg_rep,ett_sasp_dereg_rep); + dereg_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Dereg Reply"); + dereg_rep_tree = proto_item_add_subtree(dereg_rep, ett_sasp_dereg_rep); /* Size */ - proto_tree_add_item(dereg_rep_tree, hf_sasp_dereg_rep_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(dereg_rep_tree, hf_sasp_dereg_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Return Code */ - proto_tree_add_item(dereg_rep_tree, hf_sasp_dereg_rep_rcode,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(dereg_rep_tree, hf_sasp_dereg_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; } -static void dissect_sendwt(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_sendwt(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 gwed_cnt,i; - proto_item *sendwt; proto_tree *sendwt_tree; - sendwt = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Send Weight"); - sendwt_tree = proto_item_add_subtree(sendwt,ett_sasp_sendwt); + guint16 gwed_cnt, i; + + sendwt = proto_tree_add_text(pay_load, tvb, offset, -1 , "Send Weight"); + sendwt_tree = proto_item_add_subtree(sendwt, ett_sasp_sendwt); /* Size */ - proto_tree_add_item(sendwt_tree, hf_sasp_sendwt_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(sendwt_tree, hf_sasp_sendwt_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - gwed_cnt=tvb_get_ntohs(tvb, offset); + gwed_cnt = tvb_get_ntohs(tvb, offset); /* Group Wt Entry Data Count */ - proto_tree_add_item(sendwt_tree, hf_sasp_sendwt_gwedcnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(sendwt_tree, hf_sasp_sendwt_gwedcnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - for( i=0; i<gwed_cnt; i++) + for (i=0; i<gwed_cnt; i++) { - offset =dissect_grp_wt_entry_datacomp(tvb,sendwt_tree,offset); + offset = dissect_grp_wt_entry_datacomp(tvb, sendwt_tree, offset); } } -static void dissect_setmemstate_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_setmemstate_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 gmsd_cnt, i; - proto_item *setmemstate; proto_tree *setmemstate_req_data; - setmemstate = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Set Mem State Request"); - setmemstate_req_data = proto_item_add_subtree(setmemstate,ett_sasp_setmemstate_req); + guint16 gmsd_cnt, i; + + setmemstate = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set Mem State Request"); + setmemstate_req_data = proto_item_add_subtree(setmemstate, ett_sasp_setmemstate_req); /* Size */ proto_tree_add_item(setmemstate_req_data, hf_sasp_setmemstate_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN); - offset+=2; + offset += 2; /*LB Flag*/ - proto_tree_add_item(setmemstate_req_data,hf_setmemstate_req_lbflag,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(setmemstate_req_data, hf_setmemstate_req_lbflag, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /*Group Data Count*/ - gmsd_cnt=tvb_get_ntohs(tvb, offset); - proto_tree_add_item(setmemstate_req_data,hf_sasp_setmemstate_req_gmsd_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + gmsd_cnt = tvb_get_ntohs(tvb, offset); + proto_tree_add_item(setmemstate_req_data, hf_sasp_setmemstate_req_gmsd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - for( i=0; i<gmsd_cnt; i++) + for ( i=0; i<gmsd_cnt; i++) { - offset =dissect_grp_memstatedatacomp(tvb,setmemstate_req_data,offset); + offset = dissect_grp_memstatedatacomp(tvb, setmemstate_req_data, offset); } } -static void dissect_setmemstate_rep(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_setmemstate_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_item *setmemstate_rep; proto_tree *setmemstate_rep_tree; - setmemstate_rep = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Set Mem State Reply"); - setmemstate_rep_tree = proto_item_add_subtree(setmemstate_rep,ett_sasp_setmemstate_rep); + setmemstate_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set Mem State Reply"); + setmemstate_rep_tree = proto_item_add_subtree(setmemstate_rep, ett_sasp_setmemstate_rep); /* Size */ - proto_tree_add_item(setmemstate_rep_tree, hf_sasp_setmemstate_rep_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(setmemstate_rep_tree, hf_sasp_setmemstate_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Response Code */ - proto_tree_add_item(setmemstate_rep_tree, hf_sasp_setmemstate_rep_rcode,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(setmemstate_rep_tree, hf_sasp_setmemstate_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; } -static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *pay_load,guint32 offset) +static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset, proto_tree **mdct_p) { + proto_item *memdatacomp; + proto_tree *memdatacomp_tree; - guint8 lab_len; - struct e_in6_addr ipv6_addr; - const gchar *ip_str; + guint8 lab_len; + struct e_in6_addr ipv6_address; + const gchar *ip_str; - tvb_get_ipv6(tvb,offset+7,&ipv6_addr); - ip_str = ip6_to_str(&ipv6_addr); + tvb_get_ipv6(tvb, offset+7, &ipv6_address); + ip_str = ip6_to_str(&ipv6_address); lab_len = tvb_get_guint8(tvb, offset+23); - memdatacomp = proto_tree_add_ipv6_format(pay_load,hf_sasp_memdatacomp_ip, - tvb,offset,24+lab_len,(guint8*)&ipv6_addr, - "Member Data Comp (%s)",ip_str); + memdatacomp = proto_tree_add_ipv6_format(pay_load, hf_sasp_memdatacomp_ip, + tvb, offset, 24+lab_len, (guint8*)&ipv6_address, + "Member Data Comp (%s)", ip_str); - memdatacomp_tree = proto_item_add_subtree(memdatacomp,ett_sasp_memdatacomp); + memdatacomp_tree = proto_item_add_subtree(memdatacomp, ett_sasp_memdatacomp); /* Message Type */ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_type, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_type, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Size */ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Protocol */ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_protocol,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_protocol, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /* Port */ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_port, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_port, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /*Ip*/ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_ip, tvb, offset,16, ENC_NA); - offset+=16; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_ip, tvb, offset, 16, ENC_NA); + offset += 16; /*Label Len*/ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_lab_len,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_lab_len, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /*Label*/ - proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_label,tvb,offset,lab_len,ENC_ASCII|ENC_NA); - offset+=lab_len; + proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_label, tvb, offset, lab_len, ENC_ASCII|ENC_NA); + offset += lab_len; + + if (mdct_p != NULL) + *mdct_p = memdatacomp_tree; return offset; @@ -796,84 +800,89 @@ static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *pay_load,guint32 o -static guint32 dissect_grpdatacomp(tvbuff_t *tvb, proto_tree *pay_load,guint32 offset) +static guint32 dissect_grpdatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { + proto_item *grpdatacomp; + proto_tree *grpdatacomp_tree; + guint8 LB_uid_len; guint8 grp_name_len; - proto_item *grpdatacomp; - proto_tree *grpdatacomp_tree; - - grpdatacomp = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Group Data Component"); - grpdatacomp_tree = proto_item_add_subtree(grpdatacomp,ett_sasp_grpdatacomp); + grpdatacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group Data Component"); + grpdatacomp_tree = proto_item_add_subtree(grpdatacomp, ett_sasp_grpdatacomp); /*Type*/ - proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /*Size*/ - proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; LB_uid_len = tvb_get_guint8(tvb, offset); /* LB UID Len*/ - proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_LB_uid_len, tvb, offset,1, ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_LB_uid_len, + tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; - proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_LB_uid, tvb,offset,LB_uid_len,ENC_ASCII|ENC_NA); - offset+=(guint8)LB_uid_len; + proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_LB_uid, + tvb, offset, LB_uid_len, ENC_ASCII|ENC_NA); + offset += (guint8)LB_uid_len; grp_name_len = tvb_get_guint8(tvb, offset); /*Group Name Len */ - proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_grp_name_len,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_grp_name_len, + tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /*Group Name*/ - proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_grp_name,tvb,offset,grp_name_len,ENC_ASCII|ENC_NA); - offset+=grp_name_len; + proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_grp_name, + tvb, offset, grp_name_len, ENC_ASCII|ENC_NA); + offset += grp_name_len; return offset; } -static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 mem_cnt; - guint16 i; proto_item *grp_memdatacomp; proto_tree *grp_memdatacomp_tree; - grp_memdatacomp = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Group Of Member Data"); - grp_memdatacomp_tree = proto_item_add_subtree(grp_memdatacomp,ett_sasp_grp_memdatacomp); + guint16 mem_cnt; + guint16 i; + + grp_memdatacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group Of Member Data"); + grp_memdatacomp_tree = proto_item_add_subtree(grp_memdatacomp, ett_sasp_grp_memdatacomp); /* Group MEM Data */ - proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Group MEM Data Size*/ - proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - mem_cnt=tvb_get_ntohs(tvb, offset); + mem_cnt = tvb_get_ntohs(tvb, offset); /* Group MEM Data Count*/ - proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp_cnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - offset = dissect_grpdatacomp(tvb,grp_memdatacomp_tree, offset); + offset = dissect_grpdatacomp(tvb, grp_memdatacomp_tree, offset); /* array of memdata */ - for( i=0; i< mem_cnt; i++) + for ( i=0; i<mem_cnt; i++) { - offset=dissect_memdatacomp(tvb,grp_memdatacomp_tree, offset); + offset = dissect_memdatacomp(tvb, grp_memdatacomp_tree, offset, NULL); } return offset; @@ -882,80 +891,80 @@ static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb,proto_tree *pay_load,guint3 -static void dissect_wt_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_wt_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_item *get_wt_data; proto_tree *get_wt_tree; - guint16 gd_cnt,i; + guint16 gd_cnt, i; - get_wt_data = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Get Wt Req"); - get_wt_tree = proto_item_add_subtree(get_wt_data,ett_sasp_getwt); + get_wt_data = proto_tree_add_text(pay_load, tvb, offset, -1 , "Get Wt Req"); + get_wt_tree = proto_item_add_subtree(get_wt_data, ett_sasp_getwt); /* Size */ proto_tree_add_item(get_wt_tree, hf_sasp_wt_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN); - offset+=2; + offset += 2; - gd_cnt=tvb_get_ntohs(tvb, offset); + gd_cnt = tvb_get_ntohs(tvb, offset); /* Group Data Count */ - proto_tree_add_item(get_wt_tree,hf_sasp_wt_req_gd_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(get_wt_tree, hf_sasp_wt_req_gd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - for( i=0; i<gd_cnt; i++) + for (i=0; i<gd_cnt; i++) { - offset = dissect_grpdatacomp(tvb,get_wt_tree,offset); + offset = dissect_grpdatacomp(tvb, get_wt_tree, offset); } } -static void dissect_wt_rep(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_wt_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 gwed_cnt,i; - proto_item *wt_rep; proto_tree *wt_rep_tree; - wt_rep = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Get Weights Reply"); - wt_rep_tree = proto_item_add_subtree(wt_rep,ett_sasp_wt_rep); + guint16 gwed_cnt, i; + + wt_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Get Weights Reply"); + wt_rep_tree = proto_item_add_subtree(wt_rep, ett_sasp_wt_rep); /* Size */ - proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Response Code */ - proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_rcode,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /* Interval */ - proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_interval,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_interval, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - gwed_cnt=tvb_get_ntohs(tvb, offset); + gwed_cnt = tvb_get_ntohs(tvb, offset); /* Count of Group of Wt Entry Data */ - proto_tree_add_item(wt_rep_tree,hf_sasp_wt_rep_gwed_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_gwed_cnt, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - for( i=0; i<gwed_cnt; i++) + for (i=0; i<gwed_cnt; i++) { - offset =dissect_grp_wt_entry_datacomp(tvb,wt_rep_tree,offset); + offset = dissect_grp_wt_entry_datacomp(tvb, wt_rep_tree, offset); } } -static void dissect_setlbstate_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_setlbstate_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint8 LB_uid_len; + guint8 LB_uid_len; static const int *lbflags[] = { &hf_sasp_pushflag, @@ -968,96 +977,105 @@ static void dissect_setlbstate_req(tvbuff_t *tvb,proto_tree *pay_load,guint32 of proto_item *setlbstate_req; proto_tree *setlbstate_req_tree; - setlbstate_req = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Set LB State Req"); - setlbstate_req_tree = proto_item_add_subtree(setlbstate_req,ett_sasp_setlbstate_req); + setlbstate_req = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set LB State Req"); + setlbstate_req_tree = proto_item_add_subtree(setlbstate_req, ett_sasp_setlbstate_req); /* Size*/ - proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_sz, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; LB_uid_len = tvb_get_guint8(tvb, offset); /* LB UID Len */ - proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_uid_len, tvb, offset,1, ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_uid_len, + tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /*LB UID*/ - proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_uid, tvb,offset,LB_uid_len,ENC_ASCII|ENC_NA); - offset+=(guint8)LB_uid_len; + proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_uid, + tvb, offset, LB_uid_len, ENC_ASCII|ENC_NA); + offset += (guint8)LB_uid_len; /*LB Health*/ - proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_health, tvb, offset,1, ENC_BIG_ENDIAN); + proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_health, + tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - proto_tree_add_bitmask_text(setlbstate_req_tree,tvb,offset, 1, "LB Flags:", NULL, + proto_tree_add_bitmask_text(setlbstate_req_tree, tvb, offset, 1, "LB Flags:", NULL, ett_setlbstate_req_lbflag, lbflags, ENC_BIG_ENDIAN, 0); - offset+=1; + offset += 1; } -static void dissect_setlbstate_rep(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static void dissect_setlbstate_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_item *setlbstate_rep; proto_tree *setlbstate_rep_tree; - setlbstate_rep = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Set LB State Rep"); - setlbstate_rep_tree = proto_item_add_subtree(setlbstate_rep,ett_sasp_setlbstate_rep); + setlbstate_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set LB State Rep"); + setlbstate_rep_tree = proto_item_add_subtree(setlbstate_rep, ett_sasp_setlbstate_rep); /* Size */ - proto_tree_add_item(setlbstate_rep_tree, hf_sasp_setlbstate_rep_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(setlbstate_rep_tree, hf_sasp_setlbstate_rep_sz, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Response Code */ - proto_tree_add_item(setlbstate_rep_tree, hf_sasp_setlbstate_rep_rcode,tvb,offset,1,ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(setlbstate_rep_tree, hf_sasp_setlbstate_rep_rcode, + tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; } -static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 mem_cnt; - guint16 i; - proto_item *grp_memstatedatacomp; proto_tree *grp_memstatedatacomp_tree; + guint16 mem_cnt; + guint16 i; - grp_memstatedatacomp = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Group Mem State Comp"); - grp_memstatedatacomp_tree = proto_item_add_subtree(grp_memstatedatacomp,ett_sasp_grp_memstatedatacomp); + grp_memstatedatacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group Mem State Comp"); + grp_memstatedatacomp_tree = proto_item_add_subtree(grp_memstatedatacomp, + ett_sasp_grp_memstatedatacomp); /* Type */ - proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Size */ - proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp_sz, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - mem_cnt=tvb_get_ntohs(tvb, offset); + mem_cnt = tvb_get_ntohs(tvb, offset); /* Count */ - proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp_cnt, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Group Data TLV */ - offset = dissect_grpdatacomp(tvb,grp_memstatedatacomp_tree, offset); + offset = dissect_grpdatacomp(tvb, grp_memstatedatacomp_tree, offset); /* Array of Mem State Data */ - for( i=0; i< mem_cnt; i++) + for (i=0; i<mem_cnt; i++) { - offset=dissect_memstatedatacomp(tvb,grp_memstatedatacomp_tree, offset); + offset = dissect_memstatedatacomp(tvb, grp_memstatedatacomp_tree, offset); } return offset; @@ -1065,41 +1083,49 @@ static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb,proto_tree *pay_load,g } -static guint32 dissect_memstatedatacomp(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static guint32 dissect_memstatedatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_tree *memstatedatacomp_tree; proto_item *memstatedatacomp; - guint8 memstate_flag; + proto_tree *memdatacomp_tree; + + guint8 memstate_flag; - offset=dissect_memdatacomp(tvb,pay_load, offset); - memstatedatacomp = proto_tree_add_text(memdatacomp_tree,tvb,offset,-1 ,"Member State Data"); + offset = dissect_memdatacomp(tvb, pay_load, offset, &memdatacomp_tree); + + memstatedatacomp = proto_tree_add_text(memdatacomp_tree, tvb, offset, -1 , "Member State Data"); memstatedatacomp_tree = proto_item_add_subtree(memstatedatacomp, ett_sasp_memstatedatacomp); + /* Type */ - proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_instance, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_instance, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Size */ - proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_sz, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* State */ - proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_state, tvb, offset,1, ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_state, + tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; /* Quiesce flag*/ memstate_flag = tvb_get_guint8(tvb, offset); - proto_tree_add_boolean(memstatedatacomp_tree,hf_sasp_memstatedatacomp_quiesce_flag,tvb,offset,1,memstate_flag); - offset+=1; + proto_tree_add_boolean(memstatedatacomp_tree, hf_sasp_memstatedatacomp_quiesce_flag, + tvb, offset, 1, memstate_flag); + offset += 1; return offset; } -static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { proto_tree *weight_entry_data_comp_tree; @@ -1114,71 +1140,81 @@ static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb,proto_tree *pay_load }; - offset=dissect_memdatacomp(tvb,pay_load, offset); + offset = dissect_memdatacomp(tvb, pay_load, offset, NULL); - weight_entry_data_comp = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Weight Entry Data"); - weight_entry_data_comp_tree = proto_item_add_subtree(weight_entry_data_comp,ett_sasp_weight_entry_data_comp); + weight_entry_data_comp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Weight Entry Data"); + weight_entry_data_comp_tree = proto_item_add_subtree(weight_entry_data_comp, + ett_sasp_weight_entry_data_comp); /* Type */ - proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_type, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_type, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Size */ - proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_sz, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_state, tvb, offset,1, ENC_BIG_ENDIAN); - offset+=1; + proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_state, + tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; - proto_tree_add_bitmask_text(weight_entry_data_comp_tree,tvb,offset, 1, "Flags:", NULL, + proto_tree_add_bitmask_text(weight_entry_data_comp_tree, tvb, offset, 1, "Flags:", NULL, ett_wt_entry_data_flag, wtflags, ENC_BIG_ENDIAN, 0); - offset+=1; + offset += 1; /* Weight */ - proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_weight, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_weight, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; return offset; } -static guint32 dissect_grp_wt_entry_datacomp(tvbuff_t *tvb,proto_tree *pay_load,guint32 offset) +static guint32 dissect_grp_wt_entry_datacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset) { - guint16 wt_entry_cnt; - guint16 i; proto_item *grp_wt_entry_datacomp; proto_tree *grp_wt_entry_datacomp_tree; - grp_wt_entry_datacomp = proto_tree_add_text(pay_load,tvb,offset,-1 ,"Group of Wt Entry Data"); - grp_wt_entry_datacomp_tree = proto_item_add_subtree(grp_wt_entry_datacomp, ett_sasp_grp_wt_entry_datacomp); + guint16 wt_entry_cnt; + guint16 i; + + grp_wt_entry_datacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group of Wt Entry Data"); + grp_wt_entry_datacomp_tree = proto_item_add_subtree(grp_wt_entry_datacomp, + ett_sasp_grp_wt_entry_datacomp); /* Type */ - proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_type, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_type, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Size */ - proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_sz, tvb, offset,2, ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_sz, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - wt_entry_cnt=tvb_get_ntohs(tvb, offset); + wt_entry_cnt = tvb_get_ntohs(tvb, offset); /* Wt Entry Count*/ - proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_cnt,tvb,offset,2,ENC_BIG_ENDIAN); - offset+=2; + proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_cnt, + tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* Group Data */ - offset = dissect_grpdatacomp(tvb,grp_wt_entry_datacomp_tree, offset); + offset = dissect_grpdatacomp(tvb, grp_wt_entry_datacomp_tree, offset); /* Member Data */ - for( i=0; i<wt_entry_cnt; i++) + for (i=0; i<wt_entry_cnt; i++) { - offset=dissect_weight_entry_data_comp(tvb,grp_wt_entry_datacomp_tree, offset); + offset = dissect_weight_entry_data_comp(tvb, grp_wt_entry_datacomp_tree, offset); } return offset; @@ -1195,351 +1231,435 @@ void proto_register_sasp(void) /*SASP Header */ { &hf_sasp_type, - { "Type", "sasp.msg.type", FT_UINT16, BASE_HEX, NULL, 0x0, - "SASP Header", HFILL } }, + { "Type", "sasp.msg.type", + FT_UINT16, BASE_HEX, NULL, 0x0, + "SASP Header", HFILL } + }, { &hf_sasp_length, - { "Length", "sasp.header.Len", FT_UINT16, BASE_DEC, NULL, 0x0, - "SASP Header Length", HFILL } }, + { "Length", "sasp.header.Len", + FT_UINT16, BASE_DEC, NULL, 0x0, + "SASP Header Length", HFILL } + }, { &hf_sasp_vrsn, - { "Version", "sasp.version", FT_UINT8, BASE_DEC, NULL, 0x0, - "SASP Version", HFILL } }, + { "Version", "sasp.version", + FT_UINT8, BASE_DEC, NULL, 0x0, + "SASP Version", HFILL } + }, { &hf_msg_len, - { "Message Len", "sasp.msg.len", FT_UINT32, BASE_DEC, NULL, 0x0, - "SASP Msg Len", HFILL } }, + { "Message Len", "sasp.msg.len", + FT_UINT32, BASE_DEC, NULL, 0x0, + "SASP Msg Len", HFILL } + }, { &hf_msg_id, - { "Message Id", "sasp.msg.id", FT_UINT32, BASE_DEC, NULL, 0x0, - "SASP Msg Id", HFILL } }, + { "Message Id", "sasp.msg.id", + FT_UINT32, BASE_DEC, NULL, 0x0, + "SASP Msg Id", HFILL } + }, /*Message Type*/ { &hf_msg_type, - { "Message Type", "sasp.msg.type", FT_UINT16, BASE_HEX,VALS(msg_table), 0x0, - "SASP Msg Type", HFILL } }, + { "Message Type", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, + "SASP Msg Type", HFILL } + }, /*Reg Request*/ { &hf_sasp_reg_req_sz, - { "Reg Req-Size", "sasp.reg-req.size", FT_UINT32, BASE_DEC, NULL, 0x0, - "SASP Reg Req Size", HFILL } }, + { "Reg Req-Size", "sasp.reg-req.size", + FT_UINT32, BASE_DEC, NULL, 0x0, + "SASP Reg Req Size", HFILL } + }, { &hf_reg_req_lbflag, - { "Reg Req-LB Flag", "sasp.reg-req.lbflag", FT_BOOLEAN, BASE_NONE, NULL, 0x0, + { "Reg Req-LB Flag", "sasp.reg-req.lbflag", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, "SASP Reg Req LB Flag", HFILL } }, { &hf_sasp_gmd_cnt, - { "Grp Mem Data-Count", "sasp.grp-mem-data.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Mem Data-Count", "sasp.grp-mem-data.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Mem Data Count", HFILL } }, /* Reg Reply */ { &hf_sasp_reg_rep_sz, - { "Reg Reply-Size", "sasp.reg-rep.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Reg Reply-Size", "sasp.reg-rep.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Reg Reply size", HFILL } }, { &hf_sasp_reg_rep_rcode, - { "Reg Reply-Return Code", "sasp.reg-rep.retcode", FT_UINT8, BASE_HEX, VALS(reg_reply_response_code), 0x0, + { "Reg Reply-Return Code", "sasp.reg-rep.retcode", + FT_UINT8, BASE_HEX, VALS(reg_reply_response_code), 0x0, "SASP Reg Rep Return Code", HFILL } }, /* Dereg Req */ { &hf_sasp_dereg_req_sz, - { "Dereg Req-Size", "sasp.dereg-req.size", FT_UINT32, BASE_DEC, NULL, 0x0, + { "Dereg Req-Size", "sasp.dereg-req.size", + FT_UINT32, BASE_DEC, NULL, 0x0, "SASP Dereg Req Size", HFILL } }, { &hf_dereg_req_lbflag, - { "Dereg Req-LB Flag", "sasp.dereg-req.lbflag", FT_BOOLEAN, BASE_NONE, NULL, 0x0, + { "Dereg Req-LB Flag", "sasp.dereg-req.lbflag", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, "SASP Dereg Req LB Flag", HFILL } }, { &hf_dereg_req_reason_flag, - { "Reason Flags","sasp.flags.reason", FT_UINT8, BASE_HEX, NULL, 0x0, - NULL, HFILL }}, + { "Reason Flags", "sasp.flags.reason", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } }, { &hf_dereg_req_reason, - { "Dereg Req-Reason", "sasp.dereg-req.reason", FT_UINT8, BASE_HEX, NULL, 0x0, + { "Dereg Req-Reason", "sasp.dereg-req.reason", + FT_UINT8, BASE_HEX, NULL, 0x0, "SASP Dereg Req Reason", HFILL } }, /* Dereg Rep */ { &hf_sasp_dereg_rep_sz, - { "Dereg Rep-Size", "sasp.dereg-rep.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Dereg Rep-Size", "sasp.dereg-rep.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Dereg Rep Size", HFILL } }, { &hf_sasp_dereg_rep_rcode, - { "Dereg Rep-Return Code", "sasp.dereg-rep.retcode", FT_UINT8, BASE_HEX, VALS(dereg_reply_response_code), 0x0, + { "Dereg Rep-Return Code", "sasp.dereg-rep.retcode", + FT_UINT8, BASE_HEX, VALS(dereg_reply_response_code), 0x0, "SASP Dereg Rep Return Code", HFILL } }, /* Send weight */ { &hf_sasp_sendwt_sz, - { "Sendwt-Size", "sasp.sendwt.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Sendwt-Size", "sasp.sendwt.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Sendwt-Size", HFILL } }, { &hf_sasp_sendwt_gwedcnt, - { "Sendwt-Grp Wt EntryData Count", "sasp.sendwt-grp-wtentrydata.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Sendwt-Grp Wt EntryData Count", "sasp.sendwt-grp-wtentrydata.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Sendwt Grp Wt Entry Data Count", HFILL } }, /*Set Mem State Req*/ { &hf_sasp_setmemstate_req_sz, - { "Set Memstate Req-Size", "sasp.setmemstate-req.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Set Memstate Req-Size", "sasp.setmemstate-req.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Set Memstate Req Size", HFILL } }, { &hf_setmemstate_req_lbflag, - { "Set Memstate Req-LB Flag", "sasp.setmemstate-req.lbflag", FT_BOOLEAN, BASE_NONE, NULL, 0x0, + { "Set Memstate Req-LB Flag", "sasp.setmemstate-req.lbflag", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, "SASP Set Memstate Req LB Flag", HFILL } }, { &hf_sasp_setmemstate_req_gmsd_cnt, - { "Set Memstate Req-Gmsd Count", "sasp.group-memstate.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Set Memstate Req-Gmsd Count", "sasp.group-memstate.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "Group Of Member State Data Count", HFILL } }, /* Set Mem State Reply */ { &hf_sasp_setmemstate_rep, - { "Set Memstate Reply", "sasp.setmemstate-rep", FT_UINT32, BASE_HEX, NULL, 0x0, + { "Set Memstate Reply", "sasp.setmemstate-rep", + FT_UINT32, BASE_HEX, NULL, 0x0, "SASP Set Memstate Reply", HFILL } }, { &hf_sasp_setmemstate_rep_sz, - { "Set Memstate Rep-Size", "sasp.setmemstate-rep.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Set Memstate Rep-Size", "sasp.setmemstate-rep.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Set Memstate Rep Size", HFILL } }, { &hf_sasp_setmemstate_rep_rcode, - { "Set Memstate Rep-Return Code", "sasp.setmemstate-rep.retcode", FT_UINT8, BASE_HEX, VALS(set_mem_state_reply_response_code), 0x0, + { "Set Memstate Rep-Return Code", "sasp.setmemstate-rep.retcode", + FT_UINT8, BASE_HEX, VALS(set_mem_state_reply_response_code), 0x0, "SASP Set Memstate Rep Return Code", HFILL } }, /*Mem Data Component*/ { &hf_sasp_memdatacomp_type, - { "Message Type", "sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Message Type", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Mem Data Comp", HFILL } }, { &hf_sasp_memdatacomp_sz, - { "Mem Data Comp-Size", "sasp.memdatacomp.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Mem Data Comp-Size", "sasp.memdatacomp.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Mem Data Comp Size", HFILL } }, { &hf_sasp_memdatacomp_protocol, - { "Mem Data Comp-Protocol", "sasp.memdatacomp.protocol", FT_UINT8, BASE_HEX, VALS(protocol_table), 0x0, + { "Mem Data Comp-Protocol", "sasp.memdatacomp.protocol", + FT_UINT8, BASE_HEX, VALS(protocol_table), 0x0, "SASP Mem Data Comp Protocol", HFILL } }, { &hf_sasp_memdatacomp_port, - { "Mem Data Comp-Port", "sasp.memdatacomp.port", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Mem Data Comp-Port", "sasp.memdatacomp.port", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Mem Data Comp Port", HFILL } }, { &hf_sasp_memdatacomp_ip, - { "Mem Data Comp-Ip", "sasp.memdatacomp.ip", FT_IPv6, BASE_NONE, NULL, 0x0, + { "Mem Data Comp-Ip", "sasp.memdatacomp.ip", + FT_IPv6, BASE_NONE, NULL, 0x0, "SASP Mem Data Comp Ip", HFILL } }, { &hf_sasp_memdatacomp_lab_len, - { "Mem Data Comp-Label Len", "sasp.memdatacomp.label.len", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Mem Data Comp-Label Len", "sasp.memdatacomp.label.len", + FT_UINT8, BASE_DEC, NULL, 0x0, "SASP Mem Data Comp Label Length", HFILL } }, { &hf_sasp_memdatacomp_label, - { "Mem Data Comp-Label", "sasp.memdatacomp.label", FT_STRING, BASE_NONE, NULL, 0x0, + { "Mem Data Comp-Label", "sasp.memdatacomp.label", + FT_STRING, BASE_NONE, NULL, 0x0, "SASP Mem Data Comp Label", HFILL } }, /*Get Weight Request*/ { &hf_sasp_wt_req_sz, - { "Get Wt Req-Size", "sasp.getwt.req.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Get Wt Req-Size", "sasp.getwt.req.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Get Wt Req Size", HFILL } }, { &hf_sasp_wt_req_gd_cnt, - { "Get Wt Req-Grp Data Count", "sasp.getwt-req-grpdata.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Get Wt Req-Grp Data Count", "sasp.getwt-req-grpdata.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Get Wt Grp Data Count", HFILL } }, /*Get Weight Reply*/ { &hf_sasp_wt_rep_sz, - { "Get Wt Rep-Size", "sasp.getwt.rep.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Get Wt Rep-Size", "sasp.getwt.rep.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Get Wt Rep Size", HFILL } }, { &hf_sasp_wt_rep_rcode, - { "Get Wt Rep-Return Code", "sasp.getwt-rep.retcode", FT_UINT8, BASE_HEX, VALS(get_weights_reply_response_code), 0x0, + { "Get Wt Rep-Return Code", "sasp.getwt-rep.retcode", + FT_UINT8, BASE_HEX, VALS(get_weights_reply_response_code), 0x0, "SASP Get Wt Rep Return Code", HFILL } }, { &hf_sasp_wt_rep_interval, - { "Get Wt Rep-Interval", "sasp.getwt-rep.interval", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Get Wt Rep-Interval", "sasp.getwt-rep.interval", + FT_UINT8, BASE_DEC, NULL, 0x0, "SASP Get Wt Rep Interval", HFILL } }, { &hf_sasp_wt_rep_gwed_cnt, - { "Get Wt Rep-Grp WtEntry Data Cnt", "sasp.getwt-rep-grpwtentrydata.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Get Wt Rep-Grp WtEntry Data Cnt", "sasp.getwt-rep-grpwtentrydata.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Get Wt Rep Grp Wt Entry Data Cnt", HFILL } }, /*Set LB State Rep */ { &hf_sasp_setlbstate_rep, - { "Set Lbstate Rep", "sasp.msg.type", FT_UINT32, BASE_HEX, NULL, 0x0, + { "Set Lbstate Rep", "sasp.msg.type", + FT_UINT32, BASE_HEX, NULL, 0x0, "SASP Set Lbstate Rep", HFILL } }, { &hf_sasp_setlbstate_rep_sz, - { "Set Lbstate Rep-Size", "sasp.setlbstate-rep.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Set Lbstate Rep-Size", "sasp.setlbstate-rep.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Set Lbstate Rep Size", HFILL } }, { &hf_sasp_setlbstate_rep_rcode, - { "Set Lbstate Rep-Return Code", "sasp.setlbstate-rep.retcode", FT_UINT8, BASE_HEX, VALS(set_lb_state_reply_response_code), 0x0, + { "Set Lbstate Rep-Return Code", "sasp.setlbstate-rep.retcode", + FT_UINT8, BASE_HEX, VALS(set_lb_state_reply_response_code), 0x0, "SASP Set Lbstate Rep Return Code", HFILL } }, /*grp data comp */ { &hf_sasp_grpdatacomp, - { "Message Type", "sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Message Type", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Grp Data Comp", HFILL } }, { &hf_sasp_grpdatacomp_sz, - { "Grp Data Comp-Size","sasp.grpdatacomp.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Data Comp-Size", "sasp.grpdatacomp.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Data Comp size", HFILL } }, { &hf_sasp_grpdatacomp_LB_uid_len, - { "Grp Data Comp-Label UID Len","sasp.grpdatacomp.label.uid.len", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Grp Data Comp-Label UID Len", "sasp.grpdatacomp.label.uid.len", + FT_UINT8, BASE_DEC, NULL, 0x0, "SASP Grp Data Comp Label Uid Len", HFILL } }, { &hf_sasp_grpdatacomp_LB_uid, - { "Grp Data Comp-Label UID","sasp.grpdatacomp.label.uid", FT_STRING, BASE_NONE, NULL, 0x0, - "SASP Grp Data Comp Label Uid",HFILL } }, + { "Grp Data Comp-Label UID", "sasp.grpdatacomp.label.uid", + FT_STRING, BASE_NONE, NULL, 0x0, + "SASP Grp Data Comp Label Uid", HFILL } }, { &hf_sasp_grpdatacomp_grp_name_len, - { "Grp Data Comp-Grp Name Len","sasp.grpdatacomp.grpname.len", FT_UINT8, BASE_DEC, NULL, 0x0, - "SASP Grp Data Comp Grp Name Len",HFILL } }, + { "Grp Data Comp-Grp Name Len", "sasp.grpdatacomp.grpname.len", + FT_UINT8, BASE_DEC, NULL, 0x0, + "SASP Grp Data Comp Grp Name Len", HFILL } }, { &hf_sasp_grpdatacomp_grp_name, - { "Grp Data Comp-Grp Name","sasp.grpdatacomp.grpname", FT_STRING, BASE_NONE, NULL, 0x0, + { "Grp Data Comp-Grp Name", "sasp.grpdatacomp.grpname", + FT_STRING, BASE_NONE, NULL, 0x0, "SASP Grp Data Comp Grp Name", HFILL } }, /*grp mem data comp */ { &hf_sasp_grp_memdatacomp, - { "Message Type","sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Message Type", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Grp Mem Data Comp", HFILL } }, { &hf_sasp_grp_memdatacomp_sz, - { "Grp Mem Data Comp-Size","sasp.grp-memdatacomp.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Mem Data Comp-Size", "sasp.grp-memdatacomp.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Mem Data Comp Size", HFILL } }, { &hf_sasp_grp_memdatacomp_cnt, - { "Grp Mem Data Comp-Count","sasp.grp.memdatacomp.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Mem Data Comp-Count", "sasp.grp.memdatacomp.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Mem Data Comp Cnt", HFILL } }, /*set LB state req*/ { &hf_sasp_setlbstate_req_sz, - { "Set LB State Req-Size", "sasp.setlbstate-req.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Set LB State Req-Size", "sasp.setlbstate-req.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Set LB State Req Size", HFILL } }, { &hf_sasp_setlbstate_req_LB_uid_len, - { "Set LB State Req-LB UID Len", "sasp.setlbstate-req.lbuid.len", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Set LB State Req-LB UID Len", "sasp.setlbstate-req.lbuid.len", + FT_UINT8, BASE_DEC, NULL, 0x0, "SASP Set LB State Req LB Uid Len", HFILL } }, { &hf_sasp_setlbstate_req_LB_uid, - { "Set LB State Req-LB UID", "sasp.setlbstate-req.lbuid", FT_STRING, BASE_NONE, NULL, 0x0, + { "Set LB State Req-LB UID", "sasp.setlbstate-req.lbuid", + FT_STRING, BASE_NONE, NULL, 0x0, "SASP Set LB State Req LB UID", HFILL } }, { &hf_sasp_setlbstate_req_LB_health, - { "Set LB State Req-LB Health", "sasp.setlbstate-req.lbhealth", FT_UINT8, BASE_HEX, VALS(lbstate_healthtable), 0x0, + { "Set LB State Req-LB Health", "sasp.setlbstate-req.lbhealth", + FT_UINT8, BASE_HEX, VALS(lbstate_healthtable), 0x0, "SASP Set LB State Req LB Health", HFILL } }, { &hf_lbstate_flag, - { "Flags","sasp.flags.lbstate", FT_UINT8, BASE_HEX, NULL, 0x0, - NULL, HFILL }}, + { "Flags", "sasp.flags.lbstate", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } }, { &hf_sasp_pushflag, - { "PUSH", "sasp.flags.push", FT_BOOLEAN, 8, NULL, SASP_PUSH_FLAG, - "SASP Push Flag", HFILL }}, + { "PUSH", "sasp.flags.push", + FT_BOOLEAN, 8, NULL, SASP_PUSH_FLAG, + "SASP Push Flag", HFILL } }, { &hf_sasp_trustflag, - { "TRUST", "sasp.flags.trust", FT_BOOLEAN, 8, NULL, SASP_TRUST_FLAG, - "SASP Trust Flag", HFILL }}, + { "TRUST", "sasp.flags.trust", + FT_BOOLEAN, 8, NULL, SASP_TRUST_FLAG, + "SASP Trust Flag", HFILL } }, { &hf_sasp_nochangeflag, - { "NOCHANGE", "sasp.flags.nochange", FT_BOOLEAN, 8, NULL, SASP_NOCHANGE_FLAG, - "SASP Nochange Flag", HFILL }}, + { "NOCHANGE", "sasp.flags.nochange", + FT_BOOLEAN, 8, NULL, SASP_NOCHANGE_FLAG, + "SASP Nochange Flag", HFILL } }, /*grp mem state data comp */ { &hf_sasp_grp_memstatedatacomp, - { "Message Type", "sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Message Type", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Message Type", HFILL } }, { &hf_sasp_grp_memstatedatacomp_sz, - { "Grp Mem State-Size", "sasp.grp.memstate.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Mem State-Size", "sasp.grp.memstate.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Mem State Data Comp Size", HFILL } }, { &hf_sasp_grp_memstatedatacomp_cnt, - { "Grp Mem State-Count", "sasp.grp.memstate.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Mem State-Count", "sasp.grp.memstate.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Mem State Data Comp Count", HFILL } }, /*mem state instance */ { &hf_sasp_memstatedatacomp_instance, - { "Message Type", "sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Message Type", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Message Type", HFILL } }, { &hf_sasp_memstatedatacomp_sz, - { "Mem State-Size", "sasp.memstate.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Mem State-Size", "sasp.memstate.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Mem State Data Comp Size", HFILL } }, { &hf_sasp_memstatedatacomp_state, - { "Mem State-State", "sasp.memstate.state", FT_UINT8, BASE_HEX, NULL, 0x0, + { "Mem State-State", "sasp.memstate.state", + FT_UINT8, BASE_HEX, NULL, 0x0, "SASP Mem State Data Comp State", HFILL } }, { &hf_sasp_memstatedatacomp_quiesce_flag, - { "Mem State-Quiesce Flag", "sasp.flags.quiesce", FT_BOOLEAN, 8, NULL, SASP_QUIESCE_FLAG, - "SASP Quiesce Flag", HFILL }}, + { "Mem State-Quiesce Flag", "sasp.flags.quiesce", + FT_BOOLEAN, 8, NULL, SASP_QUIESCE_FLAG, + "SASP Quiesce Flag", HFILL } }, /*weight entry data comp*/ { &hf_sasp_weight_entry_data_comp_type, - { "Wt Entry Data Comp", "sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Wt Entry Data Comp", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Wt Entry Data Comp", HFILL } }, { &hf_sasp_weight_entry_data_comp_sz, - { "Wt Entry Data Comp-Size", "sasp.wtentry.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Wt Entry Data Comp-Size", "sasp.wtentry.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Wt Entry Data Comp Size", HFILL } }, { &hf_sasp_weight_entry_data_comp_state, - { "Wt Entry Data Comp-state", "sasp.wtentry.state", FT_UINT8, BASE_HEX, NULL, 0x0, + { "Wt Entry Data Comp-state", "sasp.wtentry.state", + FT_UINT8, BASE_HEX, NULL, 0x0, "SASP Wt Entry Data Comp State", HFILL } }, { &hf_wtstate_flag, - { "Flags","sasp.flags.wtstate", FT_UINT8, BASE_HEX, NULL, 0x0, - NULL, HFILL }}, + { "Flags", "sasp.flags.wtstate", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } }, { &hf_sasp_wed_contactsuccess_flag, - { "Contact Success", "sasp.flags.contactsuccess", FT_BOOLEAN, 8, NULL, SASP_WED_CONTACT_SUCCESS_FLAG, - "SASP Contact Success Flag", HFILL }}, + { "Contact Success", "sasp.flags.contactsuccess", + FT_BOOLEAN, 8, NULL, SASP_WED_CONTACT_SUCCESS_FLAG, + "SASP Contact Success Flag", HFILL } }, { &hf_sasp_wed_quiesce_flag, - { "Quiesce", "sasp.flags.quiesce", FT_BOOLEAN, 8, NULL, SASP_WED_QUIESCE_FLAG, - "SASP Quiesce Flag", HFILL }}, + { "Quiesce", "sasp.flags.quiesce", + FT_BOOLEAN, 8, NULL, SASP_WED_QUIESCE_FLAG, + "SASP Quiesce Flag", HFILL } }, { &hf_sasp_wed_registration_flag, - { "Registration", "sasp.flags.registration", FT_BOOLEAN, 8, NULL, SASP_WED_REG_FLAG, - "SASP Registration Flag", HFILL }}, + { "Registration", "sasp.flags.registration", + FT_BOOLEAN, 8, NULL, SASP_WED_REG_FLAG, + "SASP Registration Flag", HFILL } }, { &hf_sasp_wed_confident_flag, - { "Confident", "sasp.flags.confident", FT_BOOLEAN, 8, NULL, SASP_WED_CONF_FLAG, - "SASP Confident Flag", HFILL }}, + { "Confident", "sasp.flags.confident", + FT_BOOLEAN, 8, NULL, SASP_WED_CONF_FLAG, + "SASP Confident Flag", HFILL } }, { &hf_sasp_weight_entry_data_comp_weight, - { "Wt Entry Data Comp-weight", "sasp.wtentrydatacomp.weight", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Wt Entry Data Comp-weight", "sasp.wtentrydatacomp.weight", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Wt Entry Data Comp weight", HFILL } }, /*grp wt entry data comp */ { &hf_sasp_grp_wt_entry_datacomp_type, - { "Grp Wt Entry Data Comp", "sasp.msg.type", FT_UINT16, BASE_HEX, VALS(msg_table), 0x0, + { "Grp Wt Entry Data Comp", "sasp.msg.type", + FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0, "SASP Grp Wt Entry Data Comp", HFILL } }, { &hf_sasp_grp_wt_entry_datacomp_sz, - { "Grp Wt Entry Data Comp Size", "sasp.grp-wtentrydata.size", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Wt Entry Data Comp Size", "sasp.grp-wtentrydata.size", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Wt Entry Data Comp Size", HFILL } }, { &hf_sasp_grp_wt_entry_datacomp_cnt, - { "Grp Wt Entry Data Comp Cnt", "sasp.grp-wtentrydata.count", FT_UINT16, BASE_DEC, NULL, 0x0, + { "Grp Wt Entry Data Comp Cnt", "sasp.grp-wtentrydata.count", + FT_UINT16, BASE_DEC, NULL, 0x0, "SASP Grp Wt Entry Data Comp Cnt", HFILL } }, }; @@ -1568,7 +1688,7 @@ void proto_register_sasp(void) &ett_setlbstate_req_lbflag, &ett_sasp_grp_memstatedatacomp, &ett_sasp_memstatedatacomp, -/* &ett_dereg_req_reason_flag,*/ +/* &ett_dereg_req_reason_flag, */ &ett_sasp_grp_wt_entry_datacomp, &ett_sasp_weight_entry_data_comp, &ett_wt_entry_data_flag, @@ -1577,22 +1697,21 @@ void proto_register_sasp(void) module_t *sasp_module; - proto_sasp = proto_register_protocol("Server/Application State Protocol","SASP","sasp"); + proto_sasp = proto_register_protocol("Server/Application State Protocol", "SASP", "sasp"); - proto_register_field_array(proto_sasp, hf, array_length(hf)); /*Registering Field Array */ - proto_register_subtree_array(ett, array_length(ett)); /*registering subtree*/ + proto_register_field_array(proto_sasp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); sasp_module = prefs_register_protocol(proto_sasp, NULL); prefs_register_bool_preference(sasp_module, "desegment_sasp_messages", "Reassemble SASP messages spanning multiple TCP segments", - "Whether the SASP dissector should reassemble messages spanning multiple TCP segments." - " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\"" - " in the TCP protocol settings.", + "Whether the SASP dissector should reassemble messages" + " spanning multiple TCP segments." + " To use this option, you must also enable" + " \"Allow subdissectors to reassemble TCP streams\"" + " in the TCP protocol settings.", &sasp_desegment); - - - } /* Handing off to TCP */ diff --git a/epan/dissectors/packet-sgsap.c b/epan/dissectors/packet-sgsap.c index 728222d201..1d78093524 100644 --- a/epan/dissectors/packet-sgsap.c +++ b/epan/dissectors/packet-sgsap.c @@ -42,7 +42,7 @@ /* The registered SCTP port number for SGsAP is 29118. * The payload protocol identifier to be used for SGsAP is 0. */ -#define SCTP_PORT_SGSAP 29118 +#define SCTP_PORT_SGSAP 29118 /* Global variables */ @@ -60,7 +60,7 @@ static int hf_sgsap_eps_location_update_type = -1; static int hf_sgsap_service_indicator_value = -1; static int hf_sgsap_sgs_cause = -1; static int hf_sgsap_ue_emm_mode = -1; -static int hf_sgsap_eci = -1; +static int hf_sgsap_eci = -1; static int hf_sgsap_cn_id = -1; static int hf_sgsap_imsi_det_eps = -1; static int hf_sgsap_lcs_indic = -1; @@ -71,10 +71,10 @@ static int hf_sgsap_imeisv = -1; static int ett_sgsap = -1; /* - * 9.4 Information elements + * 9.4 Information elements */ /* - * 9.4.1 CLI + * 9.4.1 CLI */ /* @@ -84,55 +84,55 @@ static int ett_sgsap = -1; * ( packet-gsm_a_dtap.c ) */ /* - * 9.4.2 EPS location update type + * 9.4.2 EPS location update type */ /* EPS location update type value (octet 3) */ static const value_string sgsap_eps_location_update_type_values[] = { - { 0x00, "Shall not be sent in this version of the protocol" }, - { 0x01, "IMSI attach" }, - { 0x02, "Normal location update" }, - { 0, NULL } + { 0x00, "Shall not be sent in this version of the protocol" }, + { 0x01, "IMSI attach" }, + { 0x02, "Normal location update" }, + { 0, NULL } }; static guint16 de_sgsap_eps_loc_upd_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; - guint8 oct; + guint32 curr_offset; + guint8 oct; - curr_offset = offset; + curr_offset = offset; - /* Octet 3 EPS location update type value */ - proto_tree_add_item(tree, hf_sgsap_eps_location_update_type, tvb, offset, 1, ENC_BIG_ENDIAN); - if(add_string){ - oct = tvb_get_guint8(tvb,curr_offset); - g_snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_eps_location_update_type_values, "Reserved")); - } + /* Octet 3 EPS location update type value */ + proto_tree_add_item(tree, hf_sgsap_eps_location_update_type, tvb, offset, 1, ENC_BIG_ENDIAN); + if (add_string) { + oct = tvb_get_guint8(tvb, curr_offset); + g_snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_eps_location_update_type_values, "Reserved")); + } - curr_offset++; + curr_offset++; - return(curr_offset - offset); + return(curr_offset - offset); } /* - * 9.4.3 Erroneous message + * 9.4.3 Erroneous message * * See subclause 18.4.5 in 3GPP TS 29.018 [16]. */ static guint16 de_sgsap_err_msg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - /* 18.4.5 Erroneous message - * The Erroneous message IE is a TLV IE that encapsulates the message in error. - * Octet 3 - Octet n - * Erroneous message including the message type. - */ - proto_tree_add_item(tree, hf_sgsap_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN); - - return(len); + /* 18.4.5 Erroneous message + * The Erroneous message IE is a TLV IE that encapsulates the message in error. + * Octet 3 - Octet n + * Erroneous message including the message type. + */ + proto_tree_add_item(tree, hf_sgsap_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN); + + return(len); } /* - * 9.4.3a E-UTRAN Cell Global Identity + * 9.4.3a E-UTRAN Cell Global Identity * * The coding of the E-UTRAN Cell Global Identity value is according to ECGI field information element * as specified in subclause 8.21.5 of 3GPP TS 29.274 [17A] (GTPv2-C) @@ -145,15 +145,15 @@ de_sgsap_ecgi(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 o curr_offset = offset; dissect_e212_mcc_mnc(tvb, gpinfo, tree, offset, TRUE); - curr_offset+=3; + curr_offset += 3; proto_tree_add_item(tree, hf_sgsap_eci, tvb, curr_offset, 4, ENC_BIG_ENDIAN); - curr_offset+=4; + curr_offset += 4; return(curr_offset-offset); } /* - * 9.4.4 Global CN-Id + * 9.4.4 Global CN-Id * * See subclause 18.4.27 in 3GPP TS 29.018 [16]. * 18.4.27 Global CN-Id @@ -170,15 +170,15 @@ de_sgsap_g_cn_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint3 curr_offset = offset; dissect_e212_mcc_mnc(tvb, gpinfo, tree, offset, TRUE); - curr_offset+=3; + curr_offset += 3; proto_tree_add_item(tree, hf_sgsap_cn_id, tvb, curr_offset, 2, ENC_BIG_ENDIAN); - curr_offset+=2; + curr_offset += 2; return(curr_offset-offset); } /* - * 9.4.5 IMEISV + * 9.4.5 IMEISV * See subclause 18.4.9 in 3GPP TS 29.018 [16]. * The IMEISV is coded as a sequence of BCD digits, compressed two into each octet. * The IMEISV consists of 16 digits @@ -187,23 +187,23 @@ de_sgsap_g_cn_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint3 static guint16 de_sgsap_imeisv(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - const char *imeisv_str; - guint32 curr_offset; + const char *imeisv_str; + guint32 curr_offset; curr_offset = offset; - imeisv_str = tvb_bcd_dig_to_ep_str( tvb, curr_offset, len, NULL, FALSE); - proto_tree_add_string(tree, hf_sgsap_imeisv, tvb, curr_offset, len, imeisv_str); - if (add_string){ - /* (len<<2)+4 = the maximum number of bytes to produce (including the terminating nul character). */ - g_snprintf(add_string, (len<<2)+4, " - %s", imeisv_str); - } + imeisv_str = tvb_bcd_dig_to_ep_str( tvb, curr_offset, len, NULL, FALSE); + proto_tree_add_string(tree, hf_sgsap_imeisv, tvb, curr_offset, len, imeisv_str); + if (add_string) { + /* (len<<2)+4 = the maximum number of bytes to produce (including the terminating nul character). */ + g_snprintf(add_string, (len<<2)+4, " - %s", imeisv_str); + } return(len); } /* - * 9.4.6 IMSI + * 9.4.6 IMSI * See subclause 18.4.10 in 3GPP TS 29.018 [16]. */ /* The IMSI is coded as a sequence of BCD digits, compressed two into each octet. @@ -211,90 +211,90 @@ de_sgsap_imeisv(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 * The IMSI is defined in 3GPP TS 23.003. It shall not exceed 15 digits (see 3GPP TS 23.003). */ /* - * 9.4.7 IMSI detach from EPS service type + * 9.4.7 IMSI detach from EPS service type */ /* IMSI detach from EPS service type value (octet 3) */ static const value_string sgsap_imsi_det_from_eps_serv_type_values[] = { - { 0x00, "Interpreted as reserved in this version of the protocol" }, - { 0x01, "Network initiated IMSI detach from EPS services" }, - { 0x02, "UE initiated IMSI detach from EPS services" }, - { 0x03, "EPS services not allowed" }, - { 0, NULL } + { 0x00, "Interpreted as reserved in this version of the protocol" }, + { 0x01, "Network initiated IMSI detach from EPS services" }, + { 0x02, "UE initiated IMSI detach from EPS services" }, + { 0x03, "EPS services not allowed" }, + { 0, NULL } }; static guint16 de_sgsap_imsi_det_eps(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; + guint32 curr_offset; - curr_offset = offset; + curr_offset = offset; - proto_tree_add_item(tree, hf_sgsap_imsi_det_eps, tvb, curr_offset, 1, ENC_BIG_ENDIAN); - curr_offset+=1; + proto_tree_add_item(tree, hf_sgsap_imsi_det_eps, tvb, curr_offset, 1, ENC_BIG_ENDIAN); + curr_offset += 1; - return(curr_offset-offset); + return(curr_offset-offset); } /* - * 9.4.8 IMSI detach from non-EPS service type + * 9.4.8 IMSI detach from non-EPS service type */ /* IMSI detach from non-EPS service type value (octet 3)*/ static const value_string sgsap_imsi_det_from_non_eps_serv_type_values[] = { - { 0x00, "Interpreted as reserved in this version of the protocol" }, - { 0x01, "Explicit UE initiated IMSI detach from non-EPS services" }, - { 0x02, "Combined UE initiated IMSI detach from EPS and non-EPS services" }, - { 0x03, "Implicit network initiated IMSI detach from non-EPS services" }, - { 0, NULL } + { 0x00, "Interpreted as reserved in this version of the protocol" }, + { 0x01, "Explicit UE initiated IMSI detach from non-EPS services" }, + { 0x02, "Combined UE initiated IMSI detach from EPS and non-EPS services" }, + { 0x03, "Implicit network initiated IMSI detach from non-EPS services" }, + { 0, NULL } }; static guint16 de_sgsap_imsi_det_non_eps(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; + guint32 curr_offset; - curr_offset = offset; + curr_offset = offset; - proto_tree_add_item(tree, hf_sgsap_imsi_det_eps, tvb, curr_offset, 1, ENC_BIG_ENDIAN); - curr_offset+=1; + proto_tree_add_item(tree, hf_sgsap_imsi_det_eps, tvb, curr_offset, 1, ENC_BIG_ENDIAN); + curr_offset += 1; - return(curr_offset-offset); + return(curr_offset-offset); } /* - * 9.4.9 LCS client identity + * 9.4.9 LCS client identity * The coding of the LCS client identity value is according to LCS-ClientID * as specified in subclause 17.7.13 of 3GPP TS 29.002 [15] * (packet-nas_eps.c) */ /* - * 9.4.10 LCS indicator + * 9.4.10 LCS indicator */ static const value_string sgsap_lcs_indic_values[] = { - { 0x00, "Normal, unspecified in this version of the protocol" }, - { 0x01, "MT-LR" }, - { 0, NULL } + { 0x00, "Normal, unspecified in this version of the protocol" }, + { 0x01, "MT-LR" }, + { 0, NULL } }; static guint16 de_sgsap_lcs_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; + guint32 curr_offset; - curr_offset = offset; + curr_offset = offset; - proto_tree_add_item(tree, hf_sgsap_lcs_indic, tvb, curr_offset, 1, ENC_BIG_ENDIAN); - curr_offset+=1; + proto_tree_add_item(tree, hf_sgsap_lcs_indic, tvb, curr_offset, 1, ENC_BIG_ENDIAN); + curr_offset += 1; - return(curr_offset-offset); + return(curr_offset-offset); } /* - * 9.4.11 Location area identifier + * 9.4.11 Location area identifier * * Octets 3 to 7 contain the value part of the Location area identification information element * defined in 3GPP TS 24.008 [8] (starting with octet 2, i.e. not including 3GPP TS 24.008 IEI) *(packet-gsm_a_common.c) */ /* - * 9.4.12 MM information + * 9.4.12 MM information * For the coding see subclause 18.4.16 in 3GPP TS 29.018 [16]. * User information: This field is composed of one or more of the * information elements of the MM information message as defined in @@ -305,87 +305,87 @@ de_sgsap_lcs_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guin static guint16 de_sgsap_mm_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; + guint32 curr_offset; - curr_offset = offset; + curr_offset = offset; - dtap_mm_mm_info(tvb, tree, pinfo, curr_offset, len); + dtap_mm_mm_info(tvb, tree, pinfo, curr_offset, len); - return(len); + return(len); } /* - * 9.4.13 MME name + * 9.4.13 MME name */ static guint16 de_sgsap_mme_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint name_len, tmp; - guint8 *fqdn = NULL; - - /* The MME name information element specifies the MME name and is coded as shown in figure 9.4.13.1. Octets 3 - * through n contain the name in the form of a fully qualified domain name (FQDN) as specified in 3GPP TS 23.003 [3]. - * The value part of the MME name information element (not including IEI and length indicator) shall have a length of 55 - * octets. - */ - if (len > 0) { - name_len = tvb_get_guint8(tvb, offset); - - if (name_len < 0x20) { - fqdn = tvb_get_ephemeral_string(tvb, offset + 1, len - 1); - for (;;) { - if (name_len >= len - 1) - break; - tmp = name_len; - name_len = name_len + fqdn[tmp] + 1; - fqdn[tmp] = '.'; - } - } else{ - fqdn = tvb_get_ephemeral_string(tvb, offset, len); - } - proto_tree_add_string(tree, hf_sgsap_mme_name, tvb, offset, len, fqdn); - if (add_string) - g_snprintf(add_string, string_len, " - %s", fqdn); - - } - - return(len); + guint name_len, tmp; + guint8 *fqdn = NULL; + + /* The MME name information element specifies the MME name and is coded as shown in figure 9.4.13.1. Octets 3 + * through n contain the name in the form of a fully qualified domain name (FQDN) as specified in 3GPP TS 23.003 [3]. + * The value part of the MME name information element (not including IEI and length indicator) shall have a length of 55 + * octets. + */ + if (len > 0) { + name_len = tvb_get_guint8(tvb, offset); + + if (name_len < 0x20) { + fqdn = tvb_get_ephemeral_string(tvb, offset + 1, len - 1); + for (;;) { + if (name_len >= len - 1) + break; + tmp = name_len; + name_len = name_len + fqdn[tmp] + 1; + fqdn[tmp] = '.'; + } + } else{ + fqdn = tvb_get_ephemeral_string(tvb, offset, len); + } + proto_tree_add_string(tree, hf_sgsap_mme_name, tvb, offset, len, fqdn); + if (add_string) + g_snprintf(add_string, string_len, " - %s", fqdn); + + } + + return(len); } /* - * 9.4.14 Mobile identity + * 9.4.14 Mobile identity * See subclause 18.4.17 in 3GPP TS 29.018 [16]. * (packet-gsm_a_common.c) */ /* - * 9.4.14a Mobile Station Classmark 2 + * 9.4.14a Mobile Station Classmark 2 * With the exception of the IEI, the contents are specified in subclause 10.5.1.6 in 3GPP TS 24.008 [8]. * (packet-gsm_a_common.c) */ /* - * 9.4.15 NAS message container + * 9.4.15 NAS message container * Octets 3 to 253 contain the SMS message (i.e. CP DATA, CP ACK or CP ERROR) * as defined in subclause 7.2 of 3GPP TS 24.011 [10] */ static guint16 de_sgsap_nas_msg_container(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_) { - tvbuff_t *new_tvb; - guint32 curr_offset; + tvbuff_t *new_tvb; + guint32 curr_offset; - curr_offset = offset; + curr_offset = offset; - /* Octets 3 to 253 contain the SMS message (i.e. CP DATA, CP ACK or CP ERROR) - * as defined in subclause 7.2 of 3GPP TS 24.011 [10] - */ - new_tvb = tvb_new_subset(tvb, curr_offset,len, len); - if(gsm_a_dtap_handle){ - call_dissector(gsm_a_dtap_handle,new_tvb,gpinfo, tree); - } + /* Octets 3 to 253 contain the SMS message (i.e. CP DATA, CP ACK or CP ERROR) + * as defined in subclause 7.2 of 3GPP TS 24.011 [10] + */ + new_tvb = tvb_new_subset(tvb, curr_offset, len, len); + if (gsm_a_dtap_handle) { + call_dissector(gsm_a_dtap_handle, new_tvb, gpinfo, tree); + } - return(len); + return(len); } /* - * 9.4.16 Reject cause + * 9.4.16 Reject cause * See subclause 18.4.21 in 3GPP TS 29.018 [16]. * The rest of the information element is coded as the value part of * the reject cause IE defined in 3GPP TS 24.008, not including @@ -393,56 +393,56 @@ de_sgsap_nas_msg_container(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _ * (packet-gsm_a_dtap.c) */ /* - * 9.4.17 Service indicator + * 9.4.17 Service indicator */ -/* Octet 3 Service indicator value */ +/* Octet 3 Service indicator value */ static const value_string sgsap_service_indicator_values[] = { - { 0x00, "Shall not be sent in this version of the protocol" }, - { 0x01, "CS call indicator" }, - { 0x02, "SMS indicator" }, - { 0, NULL } + { 0x00, "Shall not be sent in this version of the protocol" }, + { 0x01, "CS call indicator" }, + { 0x02, "SMS indicator" }, + { 0, NULL } }; static guint16 de_sgsap_serv_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; - guint8 oct; + guint32 curr_offset; + guint8 oct; - curr_offset = offset; + curr_offset = offset; - /* Octet 3 Service indicator value */ - proto_tree_add_item(tree, hf_sgsap_service_indicator_value, tvb, offset, 1, ENC_BIG_ENDIAN); - if(add_string){ - oct = tvb_get_guint8(tvb,curr_offset); - g_snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_service_indicator_values, "Reserved")); - } - curr_offset++; + /* Octet 3 Service indicator value */ + proto_tree_add_item(tree, hf_sgsap_service_indicator_value, tvb, offset, 1, ENC_BIG_ENDIAN); + if (add_string) { + oct = tvb_get_guint8(tvb, curr_offset); + g_snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_service_indicator_values, "Reserved")); + } + curr_offset++; - return(curr_offset - offset); + return(curr_offset - offset); } /* - * 9.4.18 SGs cause + * 9.4.18 SGs cause */ /* SGs cause value (octet 3) */ static const value_string sgsap_sgs_cause_values[] = { - { 0x00, "Normal, unspecified in this version of the protocol" }, - { 0x01, "IMSI detached for EPS services" }, - { 0x02, "IMSI detached for EPS and non-EPS services" }, - { 0x03, "IMSI unknown" }, - { 0x04, "IMSI detached for non-EPS services" }, - { 0x05, "IMSI implicitly detached for non-EPS services" }, - { 0x06, "UE unreachable" }, - { 0x07, "Message not compatible with the protocol state" }, - { 0x08, "Missing mandatory information element" }, - { 0x09, "Invalid mandatory information" }, - { 0x0a, "Conditional information element error" }, - { 0x0b, "Semantically incorrect message" }, - { 0x0c, "Message unknown" }, - { 0x0d, "Mobile terminating CS fallback call rejected by the user" }, - { 0, NULL } + { 0x00, "Normal, unspecified in this version of the protocol" }, + { 0x01, "IMSI detached for EPS services" }, + { 0x02, "IMSI detached for EPS and non-EPS services" }, + { 0x03, "IMSI unknown" }, + { 0x04, "IMSI detached for non-EPS services" }, + { 0x05, "IMSI implicitly detached for non-EPS services" }, + { 0x06, "UE unreachable" }, + { 0x07, "Message not compatible with the protocol state" }, + { 0x08, "Missing mandatory information element" }, + { 0x09, "Invalid mandatory information" }, + { 0x0a, "Conditional information element error" }, + { 0x0b, "Semantically incorrect message" }, + { 0x0c, "Message unknown" }, + { 0x0d, "Mobile terminating CS fallback call rejected by the user" }, + { 0, NULL } }; static value_string_ext sgsap_sgs_cause_values_ext = VALUE_STRING_EXT_INIT(sgsap_sgs_cause_values); @@ -450,116 +450,116 @@ static value_string_ext sgsap_sgs_cause_values_ext = VALUE_STRING_EXT_INIT(sgsap static guint16 de_sgsap_sgs_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; - guint8 oct; + guint32 curr_offset; + guint8 oct; - curr_offset = offset; + curr_offset = offset; - proto_tree_add_item(tree, hf_sgsap_sgs_cause, tvb, offset, 1, ENC_BIG_ENDIAN); - if(add_string){ - oct = tvb_get_guint8(tvb,curr_offset); - g_snprintf(add_string, string_len, " - %s", val_to_str_ext_const(oct, &sgsap_sgs_cause_values_ext, "Reserved")); - } - curr_offset++; + proto_tree_add_item(tree, hf_sgsap_sgs_cause, tvb, offset, 1, ENC_BIG_ENDIAN); + if (add_string) { + oct = tvb_get_guint8(tvb, curr_offset); + g_snprintf(add_string, string_len, " - %s", val_to_str_ext_const(oct, &sgsap_sgs_cause_values_ext, "Reserved")); + } + curr_offset++; - return(curr_offset - offset); + return(curr_offset - offset); } /* - * 9.4.19 SS code + * 9.4.19 SS code * The coding of the SS code value is according to SS-Code as specified in * subclause 17.7.5 of 3GPP TS 29.002 [15] * ( packet-nas_eps.c) */ /* - * 9.4.20 TMSI + * 9.4.20 TMSI * See subclause 18.4.23 in 3GPP TS 29.018 [16]. * (packet-gsm_a_bssmap.c) */ /* - * 9.4.21 TMSI status + * 9.4.21 TMSI status * * See subclause 18.4.24 in 3GPP TS 29.018 [16]. * (packet-gsm_a_gm.c) */ /* - * 9.4.21a Tracking Area Identity + * 9.4.21a Tracking Area Identity * Octets 3 to 7 contain the value part of the Tracking Area Identity information element defined in 3GPP TS 24.301 [14] * (starting with octet 2, i.e. not including 3GPP TS 24.301 IEI) * (packet-nas_eps.c) */ /* - * 9.4.21b UE Time Zone + * 9.4.21b UE Time Zone * The coding of the UE Time Zone value is according to value part of the Time Zone information element as specified * in subclause 10.5.3.8 of 3GPP TS 24.008 [8] (i.e. not including 3GPP TS 24.008 IEI) * (packet-gsm_a_dtap.c) */ /* - * 9.4.21c UE EMM mode + * 9.4.21c UE EMM mode */ static const value_string sgsap_ue_emm_mode_values[] = { - { 0x00, "EMM-IDLE" }, - { 0x01, "EMM-CONNECTED" }, - { 0, NULL } + { 0x00, "EMM-IDLE" }, + { 0x01, "EMM-CONNECTED" }, + { 0, NULL } }; static guint16 de_sgsap_ue_emm_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint32 curr_offset; + guint32 curr_offset; - curr_offset = offset; + curr_offset = offset; - proto_tree_add_item(tree, hf_sgsap_ue_emm_mode, tvb, offset, 1, ENC_BIG_ENDIAN); - curr_offset+=1; + proto_tree_add_item(tree, hf_sgsap_ue_emm_mode, tvb, offset, 1, ENC_BIG_ENDIAN); + curr_offset += 1; - return(curr_offset - offset); + return(curr_offset - offset); } /* - * 9.4.22 VLR name + * 9.4.22 VLR name */ static guint16 de_sgsap_vlr_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint name_len, tmp; - guint8 *fqdn = NULL; - - /* The VLR name information element specifies the VLR name and is coded as shown in figure 9.4.22.1. - * Octets 3 through n contain the VLR name in the form of a fully qualified domain name (FQDN) - * as specified in IETF RFC 1035 [21]. - */ - if (len > 0) { - name_len = tvb_get_guint8(tvb, offset); - - if (name_len < 0x20) { - fqdn = tvb_get_ephemeral_string(tvb, offset + 1, len - 1); - for (;;) { - if (name_len >= len - 1) - break; - tmp = name_len; - name_len = name_len + fqdn[tmp] + 1; - fqdn[tmp] = '.'; - } - } else{ - fqdn = tvb_get_ephemeral_string(tvb, offset, len); - } - proto_tree_add_string(tree, hf_sgsap_vlr_name, tvb, offset, len, fqdn); - if (add_string) - g_snprintf(add_string, string_len, " - %s", fqdn); - } - - return(len); + guint name_len, tmp; + guint8 *fqdn = NULL; + + /* The VLR name information element specifies the VLR name and is coded as shown in figure 9.4.22.1. + * Octets 3 through n contain the VLR name in the form of a fully qualified domain name (FQDN) + * as specified in IETF RFC 1035 [21]. + */ + if (len > 0) { + name_len = tvb_get_guint8(tvb, offset); + + if (name_len < 0x20) { + fqdn = tvb_get_ephemeral_string(tvb, offset + 1, len - 1); + for (;;) { + if (name_len >= len - 1) + break; + tmp = name_len; + name_len = name_len + fqdn[tmp] + 1; + fqdn[tmp] = '.'; + } + } else{ + fqdn = tvb_get_ephemeral_string(tvb, offset, len); + } + proto_tree_add_string(tree, hf_sgsap_vlr_name, tvb, offset, len, fqdn); + if (add_string) + g_snprintf(add_string, string_len, " - %s", fqdn); + } + + return(len); } /* - * 9.4.23 Channel needed + * 9.4.23 Channel needed * See subclause 18.4.2 in 3GPP TS 29.018 [16]. * The rest of the information element is coded as the IEI part and the * value part of the Channel Needed IE defined in 3GPP TS 44.018 * (packet-gsm_a_bssmap.c) */ /* - * 9.4.24 eMLPP priority + * 9.4.24 eMLPP priority * See subclause 18.4.4 in 3GPP TS 29.018 [16]. * The rest of the information element is coded as the value part of * the eMLPP-Priority IE defined in 3GPP TS 48.008 (not including @@ -568,50 +568,50 @@ de_sgsap_vlr_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint */ const value_string sgsap_elem_strings[] = { - { 0x01, "IMSI" }, /* 9.4.6 */ - { 0x02, "VLR name" }, /* 9.4.22 */ - { 0x03, "TMSI" }, /* 9.4.20 */ - { 0x04, "Location area identifier" }, /* 9.4.11 */ - { 0x05, "Channel Needed" }, /* 9.4.23 */ - { 0x06, "eMLPP Priority" }, /* 9.4.24 */ - { 0x07, "TMSI status" }, /* 9.4.21 */ - { 0x08, "SGs cause" }, /* 9.4.18 */ - { 0x09, "MME name" }, /* 9.4.13 */ - { 0x0a, "EPS location update type" }, /* 9.4.2 */ - { 0x0b, "Global CN-Id" }, /* 9.4.4 */ - - { 0x0c, "Undefined" }, /* */ - { 0x0d, "Undefined" }, /* */ - - { 0x0e, "Mobile identity" }, /* 9.4.14 */ - { 0x0f, "Reject cause" }, /* 9.4.16 */ - { 0x10, "IMSI detach from EPS service type" }, /* 9.4.7 */ - { 0x11, "IMSI detach from non-EPS service type" }, /* 9.4.8 */ - - { 0x15, "IMEISV" }, /* 9.4.5 */ - { 0x16, "NAS message container" }, /* 9.4.15 */ - { 0x17, "MM information" }, /* 9.4.12 */ - - { 0x18, "Undefined" }, /* */ - { 0x19, "Undefined" }, /* */ - { 0x1a, "Undefined" }, /* */ - - { 0x1b, "Erroneous message" }, /* 9.4.3 */ - { 0x1c, "CLI" }, /* 9.4.1 */ - { 0x1d, "LCS client identity" }, /* 9.4.9 */ - { 0x1e, "LCS indicator" }, /* 9.4.10 */ - { 0x1f, "SS code" }, /* 9.4.19 */ - { 0x20, "Service indicator" }, /* 9.4.17 */ - { 0x21, "UE Time Zone" }, /* 9.4.21b */ - { 0x22, "Mobile Station Classmark 2" }, /* 9.4.14a */ - { 0x23, "Tracking Area Identity" }, /* 9.4.21a */ - { 0x24, "E-UTRAN Cell Global Identity" }, /* 9.4.3a */ - { 0x25, "UE EMM mode" }, /* 9.4.21c */ - - { 0, NULL } + { 0x01, "IMSI" }, /* 9.4.6 */ + { 0x02, "VLR name" }, /* 9.4.22 */ + { 0x03, "TMSI" }, /* 9.4.20 */ + { 0x04, "Location area identifier" }, /* 9.4.11 */ + { 0x05, "Channel Needed" }, /* 9.4.23 */ + { 0x06, "eMLPP Priority" }, /* 9.4.24 */ + { 0x07, "TMSI status" }, /* 9.4.21 */ + { 0x08, "SGs cause" }, /* 9.4.18 */ + { 0x09, "MME name" }, /* 9.4.13 */ + { 0x0a, "EPS location update type" }, /* 9.4.2 */ + { 0x0b, "Global CN-Id" }, /* 9.4.4 */ + + { 0x0c, "Undefined" }, /* */ + { 0x0d, "Undefined" }, /* */ + + { 0x0e, "Mobile identity" }, /* 9.4.14 */ + { 0x0f, "Reject cause" }, /* 9.4.16 */ + { 0x10, "IMSI detach from EPS service type" }, /* 9.4.7 */ + { 0x11, "IMSI detach from non-EPS service type" }, /* 9.4.8 */ + + { 0x15, "IMEISV" }, /* 9.4.5 */ + { 0x16, "NAS message container" }, /* 9.4.15 */ + { 0x17, "MM information" }, /* 9.4.12 */ + + { 0x18, "Undefined" }, /* */ + { 0x19, "Undefined" }, /* */ + { 0x1a, "Undefined" }, /* */ + + { 0x1b, "Erroneous message" }, /* 9.4.3 */ + { 0x1c, "CLI" }, /* 9.4.1 */ + { 0x1d, "LCS client identity" }, /* 9.4.9 */ + { 0x1e, "LCS indicator" }, /* 9.4.10 */ + { 0x1f, "SS code" }, /* 9.4.19 */ + { 0x20, "Service indicator" }, /* 9.4.17 */ + { 0x21, "UE Time Zone" }, /* 9.4.21b */ + { 0x22, "Mobile Station Classmark 2" }, /* 9.4.14a */ + { 0x23, "Tracking Area Identity" }, /* 9.4.21a */ + { 0x24, "E-UTRAN Cell Global Identity" }, /* 9.4.3a */ + { 0x25, "UE EMM mode" }, /* 9.4.21c */ + + { 0, NULL } }; -#define NUM_SGSAP_ELEM (sizeof(sgsap_elem_strings)/sizeof(value_string)) +#define NUM_SGSAP_ELEM (sizeof(sgsap_elem_strings)/sizeof(value_string)) gint ett_sgsap_elem[NUM_SGSAP_ELEM]; #if 0 This enum has been moved to packet-gsm_a_common to @@ -624,817 +624,817 @@ Note this enum must be of the same size as the element decoding list typedef enum { - DE_SGSAP_IMSI, /. 9.4.6 IMSI./ - DE_SGSAP_VLR_NAME, /. 9.4.22 VLR name./ - DE_SGSAP_TMSI, /. 9.4.20 TMSI ./ - DE_SGSAP_LOC_AREA_ID, /. 9.4.11 Location area identifier ./ - DE_SGSAP_CH_NEEDED, /. 9.4.23 Channel Needed ./ - DE_SGSAP_EMLPP_PRIO, /. 9.4.24 eMLPP Priority./ - DE_SGSAP_TMSI_STATUS, /. 9.4.21 TMSI status ./ - DE_SGSAP_SGS_CAUSE, /. 9.4.18 SGs cause./ - DE_SGSAP_MME_NAME, /. 9.4.13 MME name./ - DE_SGSAP_EPS_LOC_UPD_TYPE, /. 9.4.2 EPS location update type./ - DE_SGSAP_GLOBAL_CN_ID, /. 9.4.4 Global CN-Id./ - - DE_SGSAP_UDEF_12, /. Undefined ./ - DE_SGSAP_UDEF_13, /. Undefined ./ - - DE_SGSAP_MID, /. 9.4.14 Mobile identity./ - DE_SGSAP_REJ_CAUSE, /. 9.4.16 Reject cause ./ - DE_SGSAP_IMSI_DET_EPS, /. 9.4.7 IMSI detach from EPS service type ./ - DE_SGSAP_IMSI_DET_NON_EPS, /. 9.4.8 IMSI detach from non-EPS service type ./ - - DE_SGSAP_IMEISV, /. 9.4.5 IMEISV ./ - DE_SGSAP_NAS_MSG_CONTAINER, /. 9.4.15 NAS message container./ - DE_SGSAP_MM_INFO, /. 9.4.12 MM information./ - - DE_SGSAP_UDEF_24, /. Undefined ./ - DE_SGSAP_UDEF_25, /. Undefined ./ - DE_SGSAP_UDEF_26, /. Undefined ./ - - DE_SGSAP_ERR_MSG, /. 9.4.3 Erroneous message./ - DE_SGSAP_CLI, /. 9.4.1 CLI ./ - DE_SGSAP_LCS_CLIENT_ID, /. 9.4.9 LCS client identity ./ - DE_SGSAP_LCS_INDIC, /. 9.4.10 LCS indicator ./ - DE_SGSAP_SS_CODE, /. 9.4.19 SS code ./ - DE_SGSAP_SERV_INDIC, /. 9.4.17 Service indicator ./ - DE_SGSAP_UE_TZ, /. 9.4.21b UE Time Zone ./ - DE_SGSAP_MSC_2, /. 9.4.14a Mobile Station Classmark 2 ./ - DE_SGSAP_TAID, /. 9.4.21a Tracking Area Identity ./ - DE_SGSAP_ECGI, /. 9.4.3a E-UTRAN Cell Global Identity ./ - DE_SGSAP_UE_EMM_MODE, /. 9.4.21c UE EMM mode./ - - DE_SGAP_NONE /. NONE ./ + DE_SGSAP_IMSI, /. 9.4.6 IMSI./ + DE_SGSAP_VLR_NAME, /. 9.4.22 VLR name./ + DE_SGSAP_TMSI, /. 9.4.20 TMSI ./ + DE_SGSAP_LOC_AREA_ID, /. 9.4.11 Location area identifier ./ + DE_SGSAP_CH_NEEDED, /. 9.4.23 Channel Needed ./ + DE_SGSAP_EMLPP_PRIO, /. 9.4.24 eMLPP Priority./ + DE_SGSAP_TMSI_STATUS, /. 9.4.21 TMSI status ./ + DE_SGSAP_SGS_CAUSE, /. 9.4.18 SGs cause./ + DE_SGSAP_MME_NAME, /. 9.4.13 MME name./ + DE_SGSAP_EPS_LOC_UPD_TYPE, /. 9.4.2 EPS location update type./ + DE_SGSAP_GLOBAL_CN_ID, /. 9.4.4 Global CN-Id./ + + DE_SGSAP_UDEF_12, /. Undefined ./ + DE_SGSAP_UDEF_13, /. Undefined ./ + + DE_SGSAP_MID, /. 9.4.14 Mobile identity./ + DE_SGSAP_REJ_CAUSE, /. 9.4.16 Reject cause ./ + DE_SGSAP_IMSI_DET_EPS, /. 9.4.7 IMSI detach from EPS service type ./ + DE_SGSAP_IMSI_DET_NON_EPS, /. 9.4.8 IMSI detach from non-EPS service type ./ + + DE_SGSAP_IMEISV, /. 9.4.5 IMEISV ./ + DE_SGSAP_NAS_MSG_CONTAINER, /. 9.4.15 NAS message container./ + DE_SGSAP_MM_INFO, /. 9.4.12 MM information./ + + DE_SGSAP_UDEF_24, /. Undefined ./ + DE_SGSAP_UDEF_25, /. Undefined ./ + DE_SGSAP_UDEF_26, /. Undefined ./ + + DE_SGSAP_ERR_MSG, /. 9.4.3 Erroneous message./ + DE_SGSAP_CLI, /. 9.4.1 CLI ./ + DE_SGSAP_LCS_CLIENT_ID, /. 9.4.9 LCS client identity ./ + DE_SGSAP_LCS_INDIC, /. 9.4.10 LCS indicator ./ + DE_SGSAP_SS_CODE, /. 9.4.19 SS code ./ + DE_SGSAP_SERV_INDIC, /. 9.4.17 Service indicator ./ + DE_SGSAP_UE_TZ, /. 9.4.21b UE Time Zone ./ + DE_SGSAP_MSC_2, /. 9.4.14a Mobile Station Classmark 2 ./ + DE_SGSAP_TAID, /. 9.4.21a Tracking Area Identity ./ + DE_SGSAP_ECGI, /. 9.4.3a E-UTRAN Cell Global Identity ./ + DE_SGSAP_UE_EMM_MODE, /. 9.4.21c UE EMM mode./ + + DE_SGAP_NONE /. NONE ./ } sgsap_elem_idx_t; #endif /* 0 */ guint16 (*sgsap_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = { - NULL/*DE_SGSAP_IMSI*/, /* 9.4.6 IMSI*/ - de_sgsap_vlr_name, /* 9.4.22 VLR name*/ - NULL/*DE_SGSAP_TMSI*/, /* 9.4.20 TMSI */ - NULL/*DE_SGSAP_LOC_AREA_ID*/, /* 9.4.11 Location area identifier */ - NULL/*DE_SGSAP_CH_NEEDED*/, /* 9.4.23 Channel Needed */ - NULL/*DE_SGSAP_EMLPP_PRIO*/, /* 9.4.24 eMLPP Priority*/ - NULL/*DE_SGSAP_TMSI_STATUS*/, /* 9.4.21 TMSI status */ - de_sgsap_sgs_cause, /* 9.4.18 SGs cause*/ - de_sgsap_mme_name, /* 9.4.13 MME name*/ - de_sgsap_eps_loc_upd_type, /* 9.4.2 EPS location update type*/ - de_sgsap_g_cn_id, /* 9.4.4 Global CN-Id*/ - - NULL/*DE_SGSAP_UDEF_12*/, /* Undefined */ - NULL/*DE_SGSAP_UDEF_13*/, /* Undefined */ - - NULL/*DE_SGSAP_MID*/, /* 9.4.14 Mobile identity*/ - NULL/*DE_SGSAP_REJ_CAUSE*/, /* 9.4.16 Reject cause */ - de_sgsap_imsi_det_eps, /* 9.4.7 IMSI detach from EPS service type */ - de_sgsap_imsi_det_non_eps, /* 9.4.8 IMSI detach from non-EPS service type */ - - de_sgsap_imeisv, /* 9.4.5 IMEISV */ - de_sgsap_nas_msg_container, /* 9.4.15 NAS message container*/ - de_sgsap_mm_info, /* 9.4.12 MM information*/ - - NULL/*DE_SGSAP_UDEF_24*/, /* Undefined */ - NULL/*DE_SGSAP_UDEF_25*/, /* Undefined */ - NULL/*DE_SGSAP_UDEF_26*/, /* Undefined */ - - de_sgsap_err_msg, /* 9.4.3 Erroneous message*/ - NULL/*DE_SGSAP_CLI*/, /* 9.4.1 CLI */ - NULL/*DE_SGSAP_LCS_CLIENT_ID*/, /* 9.4.9 LCS client identity */ - de_sgsap_lcs_indic, /* 9.4.10 LCS indicator */ - NULL/*DE_SGSAP_SS_CODE*/, /* 9.4.19 SS code */ - de_sgsap_serv_indic, /* 9.4.17 Service indicator */ - NULL/*DE_SGSAP_UE_TZ*/, /* 9.4.21b UE Time Zone */ - NULL/*DE_SGSAP_MSC_2*/, /* 9.4.14a Mobile Station Classmark 2 */ - NULL/*DE_SGSAP_TAID*/, /* 9.4.21a Tracking Area Identity */ - de_sgsap_ecgi, /* 9.4.3a E-UTRAN Cell Global Identity */ - de_sgsap_ue_emm_mode , /* 9.4.21c UE EMM mode*/ - - NULL, /* NONE */ + NULL/*DE_SGSAP_IMSI*/, /* 9.4.6 IMSI*/ + de_sgsap_vlr_name, /* 9.4.22 VLR name*/ + NULL/*DE_SGSAP_TMSI*/, /* 9.4.20 TMSI */ + NULL/*DE_SGSAP_LOC_AREA_ID*/, /* 9.4.11 Location area identifier */ + NULL/*DE_SGSAP_CH_NEEDED*/, /* 9.4.23 Channel Needed */ + NULL/*DE_SGSAP_EMLPP_PRIO*/, /* 9.4.24 eMLPP Priority*/ + NULL/*DE_SGSAP_TMSI_STATUS*/, /* 9.4.21 TMSI status */ + de_sgsap_sgs_cause, /* 9.4.18 SGs cause*/ + de_sgsap_mme_name, /* 9.4.13 MME name*/ + de_sgsap_eps_loc_upd_type, /* 9.4.2 EPS location update type*/ + de_sgsap_g_cn_id, /* 9.4.4 Global CN-Id*/ + + NULL/*DE_SGSAP_UDEF_12*/, /* Undefined */ + NULL/*DE_SGSAP_UDEF_13*/, /* Undefined */ + + NULL/*DE_SGSAP_MID*/, /* 9.4.14 Mobile identity*/ + NULL/*DE_SGSAP_REJ_CAUSE*/, /* 9.4.16 Reject cause */ + de_sgsap_imsi_det_eps, /* 9.4.7 IMSI detach from EPS service type */ + de_sgsap_imsi_det_non_eps, /* 9.4.8 IMSI detach from non-EPS service type */ + + de_sgsap_imeisv, /* 9.4.5 IMEISV */ + de_sgsap_nas_msg_container, /* 9.4.15 NAS message container*/ + de_sgsap_mm_info, /* 9.4.12 MM information*/ + + NULL/*DE_SGSAP_UDEF_24*/, /* Undefined */ + NULL/*DE_SGSAP_UDEF_25*/, /* Undefined */ + NULL/*DE_SGSAP_UDEF_26*/, /* Undefined */ + + de_sgsap_err_msg, /* 9.4.3 Erroneous message*/ + NULL/*DE_SGSAP_CLI*/, /* 9.4.1 CLI */ + NULL/*DE_SGSAP_LCS_CLIENT_ID*/, /* 9.4.9 LCS client identity */ + de_sgsap_lcs_indic, /* 9.4.10 LCS indicator */ + NULL/*DE_SGSAP_SS_CODE*/, /* 9.4.19 SS code */ + de_sgsap_serv_indic, /* 9.4.17 Service indicator */ + NULL/*DE_SGSAP_UE_TZ*/, /* 9.4.21b UE Time Zone */ + NULL/*DE_SGSAP_MSC_2*/, /* 9.4.14a Mobile Station Classmark 2 */ + NULL/*DE_SGSAP_TAID*/, /* 9.4.21a Tracking Area Identity */ + de_sgsap_ecgi, /* 9.4.3a E-UTRAN Cell Global Identity */ + de_sgsap_ue_emm_mode , /* 9.4.21c UE EMM mode*/ + + NULL, /* NONE */ }; /* MESSAGE FUNCTIONS */ /* - * 8.1 SGsAP-ALERT-ACK message + * 8.1 SGsAP-ALERT-ACK message */ static void sgsap_alert_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.2 SGsAP-ALERT-REJECT message + * 8.2 SGsAP-ALERT-REJECT message */ static void sgsap_alert_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* SGs Cause SGs cause 9.4.18 M TLV 3 */ - ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* SGs Cause SGs cause 9.4.18 M TLV 3 */ + ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.3 SGsAP-ALERT-REQUEST message + * 8.3 SGsAP-ALERT-REQUEST message */ static void sgsap_alert_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.4 SGsAP-DOWNLINK-UNITDATA message + * 8.4 SGsAP-DOWNLINK-UNITDATA message */ static void sgsap_dl_unitdata(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* NAS message container NAS message container 9.4.15 M TLV 4-253 */ - ELEM_MAND_TLV(0x16, SGSAP_PDU_TYPE, DE_SGSAP_NAS_MSG_CONTAINER, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* NAS message container NAS message container 9.4.15 M TLV 4-253 */ + ELEM_MAND_TLV(0x16, SGSAP_PDU_TYPE, DE_SGSAP_NAS_MSG_CONTAINER, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.5 SGsAP-EPS-DETACH-ACK message + * 8.5 SGsAP-EPS-DETACH-ACK message */ static void sgsap_eps_det_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.6 SGsAP-EPS-DETACH-INDICATION message + * 8.6 SGsAP-EPS-DETACH-INDICATION message */ static void sgsap_eps_det_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* MME name MME name 9.4.13 M TLV 57 */ - ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); - /* IMSI detach from EPS service type IMSI detach from EPS service type 9.4.7 M TLV 3 */ - ELEM_MAND_TLV(0x10, SGSAP_PDU_TYPE, DE_SGSAP_IMSI_DET_EPS, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* MME name MME name 9.4.13 M TLV 57 */ + ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); + /* IMSI detach from EPS service type IMSI detach from EPS service type 9.4.7 M TLV 3 */ + ELEM_MAND_TLV(0x10, SGSAP_PDU_TYPE, DE_SGSAP_IMSI_DET_EPS, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.7 SGsAP-IMSI-DETACH-ACK message + * 8.7 SGsAP-IMSI-DETACH-ACK message */ static void sgsap_imsi_det_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.8 SGsAP-IMSI-DETACH-INDICATION message + * 8.8 SGsAP-IMSI-DETACH-INDICATION message */ static void sgsap_imsi_det_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* MME name MME name 9.4.13 M TLV 57 */ - ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); - /* IMSI Detach from non-EPS service type IMSI detach from non-EPS service type 9.4.8 M TLV 3 */ - ELEM_MAND_TLV(0x11, SGSAP_PDU_TYPE, DE_SGSAP_IMSI_DET_NON_EPS, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* MME name MME name 9.4.13 M TLV 57 */ + ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); + /* IMSI Detach from non-EPS service type IMSI detach from non-EPS service type 9.4.8 M TLV 3 */ + ELEM_MAND_TLV(0x11, SGSAP_PDU_TYPE, DE_SGSAP_IMSI_DET_NON_EPS, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.9 SGsAP-LOCATION-UPDATE-ACCEPT message + * 8.9 SGsAP-LOCATION-UPDATE-ACCEPT message */ static void sgsap_imsi_loc_update_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* Location area identifier Location area identifier 9.4.11 M TLV 7 */ - ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); - /* New TMSI, or IMSI Mobile identity 9.4.14 O TLV 6-10 */ - ELEM_OPT_TLV(0x0e,GSM_A_PDU_TYPE_COMMON, DE_MID, " - New TMSI, or IMSI"); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* Location area identifier Location area identifier 9.4.11 M TLV 7 */ + ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); + /* New TMSI, or IMSI Mobile identity 9.4.14 O TLV 6-10 */ + ELEM_OPT_TLV(0x0e, GSM_A_PDU_TYPE_COMMON, DE_MID, " - New TMSI, or IMSI"); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.10 SGsAP-LOCATION-UPDATE-REJECT message + * 8.10 SGsAP-LOCATION-UPDATE-REJECT message */ static void sgsap_imsi_loc_update_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* Reject cause Reject cause 9.4.16 M TLV 3 */ - ELEM_MAND_TLV(0x0f,GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL); - /* Location area identifier Location area identifier 9.4.11 O TLV 7 */ - ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* Reject cause Reject cause 9.4.16 M TLV 3 */ + ELEM_MAND_TLV(0x0f, GSM_A_PDU_TYPE_DTAP, DE_REJ_CAUSE, NULL); + /* Location area identifier Location area identifier 9.4.11 O TLV 7 */ + ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.11 SGsAP-LOCATION-UPDATE-REQUEST message + * 8.11 SGsAP-LOCATION-UPDATE-REQUEST message */ static void sgsap_imsi_loc_update_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; - - curr_offset = offset; - curr_len = len; - - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* MME name MME name 9.4.13 M TLV 57 */ - ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); - /* EPS location update type EPS location update type 9.4.2 M TLV 3 */ - ELEM_MAND_TLV(0x0a, SGSAP_PDU_TYPE, DE_SGSAP_EPS_LOC_UPD_TYPE, NULL); - /* New location area identifier Location area identifier 9.4.11 M TLV 7 */ - ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); - /* Old location area identifier Location area identifier 9.4.11 O TLV 7 */ - ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, " - Old location area identifier"); - /* TMSI status TMSI status 9.4.21 O TLV 3 */ - ELEM_OPT_TLV( 0x07 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL ); - /* IMEISV IMEISV 9.4.5 O TLV 10 */ - ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL); - - EXTRANEOUS_DATA_CHECK(curr_len, 0); + guint32 curr_offset; + guint32 consumed; + guint curr_len; + + curr_offset = offset; + curr_len = len; + + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* MME name MME name 9.4.13 M TLV 57 */ + ELEM_MAND_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); + /* EPS location update type EPS location update type 9.4.2 M TLV 3 */ + ELEM_MAND_TLV(0x0a, SGSAP_PDU_TYPE, DE_SGSAP_EPS_LOC_UPD_TYPE, NULL); + /* New location area identifier Location area identifier 9.4.11 M TLV 7 */ + ELEM_MAND_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); + /* Old location area identifier Location area identifier 9.4.11 O TLV 7 */ + ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, " - Old location area identifier"); + /* TMSI status TMSI status 9.4.21 O TLV 3 */ + ELEM_OPT_TLV( 0x07 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL ); + /* IMEISV IMEISV 9.4.5 O TLV 10 */ + ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL); + + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.12 SGsAP-MM-INFORMATION-REQUEST + * 8.12 SGsAP-MM-INFORMATION-REQUEST */ static void sgsap_mm_info_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* MM information MM information 9.4.12 M TLV 3-n */ - ELEM_MAND_TLV(0x17, SGSAP_PDU_TYPE, DE_SGSAP_MM_INFO, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* MM information MM information 9.4.12 M TLV 3-n */ + ELEM_MAND_TLV(0x17, SGSAP_PDU_TYPE, DE_SGSAP_MM_INFO, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.13 SGsAP-PAGING-REJECT message + * 8.13 SGsAP-PAGING-REJECT message */ static void sgsap_paging_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* SGs Cause SGs Cause 9.4.18 M TLV 3 */ - ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* SGs Cause SGs Cause 9.4.18 M TLV 3 */ + ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.14 SGsAP-PAGING-REQUEST message + * 8.14 SGsAP-PAGING-REQUEST message */ static void sgsap_paging_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; - - curr_offset = offset; - curr_len = len; - - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* VLR name VLR name 9.4.22 M TLV 3-n */ - ELEM_MAND_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL); - /* Service indicator Service indicator 9.4.17 M TLV 3 */ - ELEM_MAND_TLV(0x20, SGSAP_PDU_TYPE, DE_SGSAP_SERV_INDIC, NULL); - /* TMSI TMSI 9.4.20 O TLV 6 */ - ELEM_OPT_TLV(0x03, GSM_A_PDU_TYPE_BSSMAP, BE_TMSI, NULL); - /* CLI CLI 9.4.1 O TLV 3-14 */ - ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_CLG_PARTY_BCD_NUM, " - CLI"); - /* Location area identifier Location area identifier 9.4.11 O TLV 7 */ - ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); - /* Global CN-Id Global CN-Id 9.4.4 O TLV 7 */ - ELEM_OPT_TLV(0x0b, SGSAP_PDU_TYPE, DE_SGSAP_GLOBAL_CN_ID, NULL); - /* SS code SS code 9.4.19 O TLV 3 */ - ELEM_OPT_TLV(0x1f, NAS_PDU_TYPE_EMM, DE_EMM_SS_CODE, NULL); - /* LCS indicator LCS indicator 9.4.10 O TLV 3 */ - ELEM_OPT_TLV(0x1e, SGSAP_PDU_TYPE, DE_SGSAP_LCS_INDIC, NULL); - /* LCS client identity LCS client identity 9.4.9 O TLV 3-n */ - ELEM_OPT_TLV(0x1d, NAS_PDU_TYPE_EMM, DE_EMM_LCS_CLIENT_ID, NULL); - /* Channel needed Channel needed 9.4.23 O TLV 3 */ - ELEM_OPT_TLV(0x05, GSM_A_PDU_TYPE_BSSMAP, BE_CHAN_NEEDED, NULL); - /* eMLPP Priority eMLPP Priority 9.4.24 O TLV 3 */ - ELEM_OPT_TLV(0x06, GSM_A_PDU_TYPE_BSSMAP, BE_EMLPP_PRIO, NULL); - - EXTRANEOUS_DATA_CHECK(curr_len, 0); + guint32 curr_offset; + guint32 consumed; + guint curr_len; + + curr_offset = offset; + curr_len = len; + + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* VLR name VLR name 9.4.22 M TLV 3-n */ + ELEM_MAND_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL); + /* Service indicator Service indicator 9.4.17 M TLV 3 */ + ELEM_MAND_TLV(0x20, SGSAP_PDU_TYPE, DE_SGSAP_SERV_INDIC, NULL); + /* TMSI TMSI 9.4.20 O TLV 6 */ + ELEM_OPT_TLV(0x03, GSM_A_PDU_TYPE_BSSMAP, BE_TMSI, NULL); + /* CLI CLI 9.4.1 O TLV 3-14 */ + ELEM_OPT_TLV(0x1c, GSM_A_PDU_TYPE_DTAP, DE_CLG_PARTY_BCD_NUM, " - CLI"); + /* Location area identifier Location area identifier 9.4.11 O TLV 7 */ + ELEM_OPT_TLV(0x04, GSM_A_PDU_TYPE_COMMON, DE_LAI, NULL); + /* Global CN-Id Global CN-Id 9.4.4 O TLV 7 */ + ELEM_OPT_TLV(0x0b, SGSAP_PDU_TYPE, DE_SGSAP_GLOBAL_CN_ID, NULL); + /* SS code SS code 9.4.19 O TLV 3 */ + ELEM_OPT_TLV(0x1f, NAS_PDU_TYPE_EMM, DE_EMM_SS_CODE, NULL); + /* LCS indicator LCS indicator 9.4.10 O TLV 3 */ + ELEM_OPT_TLV(0x1e, SGSAP_PDU_TYPE, DE_SGSAP_LCS_INDIC, NULL); + /* LCS client identity LCS client identity 9.4.9 O TLV 3-n */ + ELEM_OPT_TLV(0x1d, NAS_PDU_TYPE_EMM, DE_EMM_LCS_CLIENT_ID, NULL); + /* Channel needed Channel needed 9.4.23 O TLV 3 */ + ELEM_OPT_TLV(0x05, GSM_A_PDU_TYPE_BSSMAP, BE_CHAN_NEEDED, NULL); + /* eMLPP Priority eMLPP Priority 9.4.24 O TLV 3 */ + ELEM_OPT_TLV(0x06, GSM_A_PDU_TYPE_BSSMAP, BE_EMLPP_PRIO, NULL); + + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.15 SGsAP-RESET-ACK message + * 8.15 SGsAP-RESET-ACK message */ static void sgsap_reset_ack(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* MME name MME name 9.4.13 C TLV 57 */ - ELEM_OPT_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); - /* VLR name VLR name 9.4.22 C TLV 3-n */ - ELEM_OPT_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL); + /* MME name MME name 9.4.13 C TLV 57 */ + ELEM_OPT_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); + /* VLR name VLR name 9.4.22 C TLV 3-n */ + ELEM_OPT_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.16 SGsAP-RESET-INDICATION message + * 8.16 SGsAP-RESET-INDICATION message */ static void sgsap_reset_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* MME name MME name 9.4.13 C TLV 57 */ - ELEM_OPT_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); - /* VLR name VLR name 9.4.22 C TLV 3-n */ - ELEM_OPT_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL); + /* MME name MME name 9.4.13 C TLV 57 */ + ELEM_OPT_TLV(0x09, SGSAP_PDU_TYPE, DE_SGSAP_MME_NAME, NULL); + /* VLR name VLR name 9.4.22 C TLV 3-n */ + ELEM_OPT_TLV(0x02, SGSAP_PDU_TYPE, DE_SGSAP_VLR_NAME, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.17 SGsAP-SERVICE-REQUEST message + * 8.17 SGsAP-SERVICE-REQUEST message */ static void sgsap_service_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; - - curr_offset = offset; - curr_len = len; - - /*IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* Service indicator Service indicator 9.4.17 M TLV 3 */ - ELEM_MAND_TLV(0x20, SGSAP_PDU_TYPE, DE_SGSAP_SERV_INDIC, NULL); - /* IMEISV IMEISV 9.4.5 O TLV 10 */ - ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL); - /* UE Time Zone UE Time Zone 9.4.21b O TLV 3 */ - ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - UE Time Zone"); - /* Mobile Station Classmark 2 Mobile Station Classmark 2 9.4.14a O TLV 5 */ - ELEM_OPT_TLV(0x22 ,GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL); - /* TAI Tracking Area Identity 9.4.21a O TLV 7 */ - ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL); - /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */ - ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL); - /* UE EMM Mode UE EMM mode 9.4.21c O TLV 3 */ - ELEM_OPT_TLV(0x25, SGSAP_PDU_TYPE, DE_SGSAP_UE_EMM_MODE, NULL); - - EXTRANEOUS_DATA_CHECK(curr_len, 0); + guint32 curr_offset; + guint32 consumed; + guint curr_len; + + curr_offset = offset; + curr_len = len; + + /*IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* Service indicator Service indicator 9.4.17 M TLV 3 */ + ELEM_MAND_TLV(0x20, SGSAP_PDU_TYPE, DE_SGSAP_SERV_INDIC, NULL); + /* IMEISV IMEISV 9.4.5 O TLV 10 */ + ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL); + /* UE Time Zone UE Time Zone 9.4.21b O TLV 3 */ + ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - UE Time Zone"); + /* Mobile Station Classmark 2 Mobile Station Classmark 2 9.4.14a O TLV 5 */ + ELEM_OPT_TLV(0x22 , GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL); + /* TAI Tracking Area Identity 9.4.21a O TLV 7 */ + ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL); + /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */ + ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL); + /* UE EMM Mode UE EMM mode 9.4.21c O TLV 3 */ + ELEM_OPT_TLV(0x25, SGSAP_PDU_TYPE, DE_SGSAP_UE_EMM_MODE, NULL); + + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.18 SGsAP-STATUS message + * 8.18 SGsAP-STATUS message */ static void sgsap_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 O TLV 6-10 */ - ELEM_OPT_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* SGs cause SGs cause 9.4.18 M TLV 3 */ - ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); - /* Erroneous message Erroneous message 9.4.3 M TLV 3-n */ - ELEM_OPT_TLV(0x1e, SGSAP_PDU_TYPE, DE_SGSAP_ERR_MSG, NULL); + /* IMSI IMSI 9.4.6 O TLV 6-10 */ + ELEM_OPT_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* SGs cause SGs cause 9.4.18 M TLV 3 */ + ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); + /* Erroneous message Erroneous message 9.4.3 M TLV 3-n */ + ELEM_OPT_TLV(0x1e, SGSAP_PDU_TYPE, DE_SGSAP_ERR_MSG, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.19 SGsAP-TMSI-REALLOCATION-COMPLETE message + * 8.19 SGsAP-TMSI-REALLOCATION-COMPLETE message */ static void sgsap_tmsi_realloc_comp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /*IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /*IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.20 SGsAP-UE-ACTIVITY-INDICATION message + * 8.20 SGsAP-UE-ACTIVITY-INDICATION message */ static void sgsap_ue_act_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.21 SGsAP-UE-UNREACHABLE message + * 8.21 SGsAP-UE-UNREACHABLE message */ static void sgsap_ue_unreachable(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* SGs cause SGs cause 9.4.18 M TLV 3 */ - ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* SGs cause SGs cause 9.4.18 M TLV 3 */ + ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.22 SGsAP-UPLINK-UNITDATA message + * 8.22 SGsAP-UPLINK-UNITDATA message */ static void sgsap_ue_ul_unitdata(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; - - curr_offset = offset; - curr_len = len; - - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* NAS message container NAS message container 9.4.15 M TLV 4-253 */ - ELEM_MAND_TLV(0x16, SGSAP_PDU_TYPE, DE_SGSAP_NAS_MSG_CONTAINER, NULL); - /* IMEISV IMEISV 9.4.5 O TLV 10 */ - ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL); - /* UE Time Zone UE Time Zone 9.4.21b O TLV 3 */ - ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - UE Time Zone"); - /* Mobile Station Classmark 2 Mobile Station Classmark 2 9.4.14a O TLV 5 */ - ELEM_OPT_TLV(0x22 ,GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL); - /* TAI Tracking Area Identity 9.4.21a O TLV 7 */ - ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL); - /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */ - ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL); - - EXTRANEOUS_DATA_CHECK(curr_len, 0); + guint32 curr_offset; + guint32 consumed; + guint curr_len; + + curr_offset = offset; + curr_len = len; + + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* NAS message container NAS message container 9.4.15 M TLV 4-253 */ + ELEM_MAND_TLV(0x16, SGSAP_PDU_TYPE, DE_SGSAP_NAS_MSG_CONTAINER, NULL); + /* IMEISV IMEISV 9.4.5 O TLV 10 */ + ELEM_OPT_TLV(0x15, SGSAP_PDU_TYPE, DE_SGSAP_IMEISV, NULL); + /* UE Time Zone UE Time Zone 9.4.21b O TLV 3 */ + ELEM_OPT_TLV(0x21, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - UE Time Zone"); + /* Mobile Station Classmark 2 Mobile Station Classmark 2 9.4.14a O TLV 5 */ + ELEM_OPT_TLV(0x22 , GSM_A_PDU_TYPE_COMMON, DE_MS_CM_2, NULL); + /* TAI Tracking Area Identity 9.4.21a O TLV 7 */ + ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, NULL); + /* E-CGI E-UTRAN Cell Global Identity 9.4.3a O TLV 9 */ + ELEM_OPT_TLV(0x24, SGSAP_PDU_TYPE, DE_SGSAP_ECGI, NULL); + + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.23 SGsAP-RELEASE-REQUEST message + * 8.23 SGsAP-RELEASE-REQUEST message */ static void sgsap_release_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) { - guint32 curr_offset; - guint32 consumed; - guint curr_len; + guint32 curr_offset; + guint32 consumed; + guint curr_len; - curr_offset = offset; - curr_len = len; + curr_offset = offset; + curr_len = len; - /* IMSI IMSI 9.4.6 M TLV 6-10 */ - ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); - /* SGs cause SGs cause 9.4.18 O TLV 3 */ - ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); + /* IMSI IMSI 9.4.6 M TLV 6-10 */ + ELEM_MAND_TLV(0x01, GSM_A_PDU_TYPE_BSSMAP, BE_IMSI, NULL); + /* SGs cause SGs cause 9.4.18 O TLV 3 */ + ELEM_MAND_TLV(0x08, SGSAP_PDU_TYPE, DE_SGSAP_SGS_CAUSE, NULL); - EXTRANEOUS_DATA_CHECK(curr_len, 0); + EXTRANEOUS_DATA_CHECK(curr_len, 0); } /* - * 8.24 SGsAP-SERVICE-ABORT-REQUEST message + * 8.24 SGsAP-SERVICE-ABORT-REQUEST message */ /* No IE's */ /* - * 9.2 Message type + * 9.2 Message type */ static const value_string sgsap_msg_strings[] = { - { 0x01, "SGsAP-PAGING-REQUEST"}, /* 8.14 */ - { 0x02, "SGsAP-PAGING-REJECT"}, /* 8.13 */ + { 0x01, "SGsAP-PAGING-REQUEST"}, /* 8.14 */ + { 0x02, "SGsAP-PAGING-REJECT"}, /* 8.13 */ /* * 0 0 0 0 0 0 1 1 * to * 0 0 0 0 0 1 0 1 * Unassigned: treated as an unknown Message type */ - { 0x03, "Unassigned"}, /* 7 */ - { 0x04, "Unassigned"}, /* 7 */ - { 0x05, "Unassigned"}, /* 7 */ - - { 0x06, "SGsAP-SERVICE-REQUEST"}, /* 8.17 */ - { 0x07, "SGsAP-DOWNLINK-UNITDATA"}, /* 8.4 */ - { 0x08, "SGsAP-UPLINK-UNITDATA"}, /* 8.22 */ - { 0x09, "SGsAP-LOCATION-UPDATE-REQUEST"}, /* 8.11 */ - { 0x0a, "SGsAP-LOCATION-UPDATE-ACCEPT"}, /* 8.9 */ - { 0x0b, "SGsAP-LOCATION-UPDATE-REJECT"}, /* 8.10 */ - { 0x0c, "SGsAP-TMSI-REALLOCATION-COMPLETE"}, /* 8.19 */ - { 0x0d, "SGsAP-ALERT-REQUEST"}, /* 8.3 */ - { 0x0e, "SGsAP-ALERT-ACK"}, /* 8.1 */ - { 0x0f, "SGsAP-ALERT-REJECT"}, /* 8.2 */ - { 0x10, "SGsAP-UE-ACTIVITY-INDICATION"}, /* 8.20 */ - { 0x11, "SGsAP-EPS-DETACH-INDICATION"}, /* 8.6 */ - { 0x12, "SGsAP-EPS-DETACH-ACK"}, /* 8.5 */ - { 0x13, "SGsAP-IMSI-DETACH-INDICATION"}, /* 8.8 */ - { 0x14, "SGsAP-IMSI-DETACH-ACK"}, /* 8.7 */ - { 0x15, "SGsAP-RESET-INDICATION"}, /* 8.16 */ - { 0x16, "SGsAP-RESET-ACK"}, /* 8.15 */ - { 0x17, "SGsAP-SERVICE-ABORT-REQUEST"}, /* 8.24 */ + { 0x03, "Unassigned"}, /* 7 */ + { 0x04, "Unassigned"}, /* 7 */ + { 0x05, "Unassigned"}, /* 7 */ + + { 0x06, "SGsAP-SERVICE-REQUEST"}, /* 8.17 */ + { 0x07, "SGsAP-DOWNLINK-UNITDATA"}, /* 8.4 */ + { 0x08, "SGsAP-UPLINK-UNITDATA"}, /* 8.22 */ + { 0x09, "SGsAP-LOCATION-UPDATE-REQUEST"}, /* 8.11 */ + { 0x0a, "SGsAP-LOCATION-UPDATE-ACCEPT"}, /* 8.9 */ + { 0x0b, "SGsAP-LOCATION-UPDATE-REJECT"}, /* 8.10 */ + { 0x0c, "SGsAP-TMSI-REALLOCATION-COMPLETE"}, /* 8.19 */ + { 0x0d, "SGsAP-ALERT-REQUEST"}, /* 8.3 */ + { 0x0e, "SGsAP-ALERT-ACK"}, /* 8.1 */ + { 0x0f, "SGsAP-ALERT-REJECT"}, /* 8.2 */ + { 0x10, "SGsAP-UE-ACTIVITY-INDICATION"}, /* 8.20 */ + { 0x11, "SGsAP-EPS-DETACH-INDICATION"}, /* 8.6 */ + { 0x12, "SGsAP-EPS-DETACH-ACK"}, /* 8.5 */ + { 0x13, "SGsAP-IMSI-DETACH-INDICATION"}, /* 8.8 */ + { 0x14, "SGsAP-IMSI-DETACH-ACK"}, /* 8.7 */ + { 0x15, "SGsAP-RESET-INDICATION"}, /* 8.16 */ + { 0x16, "SGsAP-RESET-ACK"}, /* 8.15 */ + { 0x17, "SGsAP-SERVICE-ABORT-REQUEST"}, /* 8.24 */ /* * 0 0 0 1 1 0 0 0 * to * 0 0 0 1 1 0 0 1 * Unassigned: treated as an unknown Message type */ - { 0x18, "Unassigned"}, - { 0x19, "Unassigned"}, + { 0x18, "Unassigned"}, + { 0x19, "Unassigned"}, - { 0x1a, "SGsAP-MM-INFORMATION-REQUEST"}, /* 8.12 */ - { 0x1b, "SGsAP-RELEASE-REQUEST"}, /* 8.23 */ + { 0x1a, "SGsAP-MM-INFORMATION-REQUEST"}, /* 8.12 */ + { 0x1b, "SGsAP-RELEASE-REQUEST"}, /* 8.23 */ /* - * 0 0 0 1 1 1 0 0 Unassigned: treated as an unknown Message type 7 + * 0 0 0 1 1 1 0 0 Unassigned: treated as an unknown Message type 7 */ - { 0x1c, "Unassigned"}, /* 8.12 */ + { 0x1c, "Unassigned"}, /* 8.12 */ - { 0x1d, "SGsAP-STATUS"}, /* 8.18 */ - { 0x1e, "Unassigned"}, - { 0x1f, "SGsAP-UE-UNREACHABLE"}, /* 8.21 */ - { 0, NULL } + { 0x1d, "SGsAP-STATUS"}, /* 8.18 */ + { 0x1e, "Unassigned"}, + { 0x1f, "SGsAP-UE-UNREACHABLE"}, /* 8.21 */ + { 0, NULL } }; static value_string_ext sgsap_msg_strings_ext = VALUE_STRING_EXT_INIT(sgsap_msg_strings); -#define NUM_SGSAP_MSG (sizeof(sgsap_msg_strings)/sizeof(value_string)) +#define NUM_SGSAP_MSG (sizeof(sgsap_msg_strings)/sizeof(value_string)) static gint ett_sgsap_msg[NUM_SGSAP_MSG]; static void (*sgsap_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = { - sgsap_paging_req, /* 0x01, "SGsAP-PAGING-REQUEST" 8.14 */ - sgsap_paging_rej, /* 0x02, "SGsAP-PAGING-REJECT" 8.13 */ + sgsap_paging_req, /* 0x01, "SGsAP-PAGING-REQUEST" 8.14 */ + sgsap_paging_rej, /* 0x02, "SGsAP-PAGING-REJECT" 8.13 */ /* * 0 0 0 0 0 0 1 1 * to * 0 0 0 0 0 1 0 1 * Unassigned: treated as an unknown Message type */ - NULL, /* 0x03, "Unassigned" 7 */ - NULL, /* 0x04, "Unassigned" 7 */ - NULL, /* 0x05, "Unassigned" 7 */ - - sgsap_service_req, /* 0x06, "SGsAP-SERVICE-REQUEST" 8.17 */ - sgsap_dl_unitdata, /* 0x07, "SGsAP-DOWNLINK-UNITDATA" 8.4 */ - sgsap_ue_ul_unitdata, /* 0x08, "SGsAP-UPLINK-UNITDATA" 8.22 */ - sgsap_imsi_loc_update_req, /* 0x09, "SGsAP-LOCATION-UPDATE-REQUEST" 8.11 */ - sgsap_imsi_loc_update_acc, /* 0x0a, "SGsAP-LOCATION-UPDATE-ACCEPT" 8.9 */ - sgsap_imsi_loc_update_rej, /* 0x0b, "SGsAP-LOCATION-UPDATE-REJECT" 8.10 */ - sgsap_tmsi_realloc_comp, /* 0x0c, "SGsAP-TMSI-REALLOCATION-COMPLETE" 8.19 */ - sgsap_alert_req, /* 0x0d, "SGsAP-ALERT-REQUEST" 8.3 */ - sgsap_alert_ack, /* 0x0e, "SGsAP-ALERT-ACK" 8.1 */ - sgsap_alert_rej, /* 0x0f, "SGsAP-ALERT-REJECT" 8.2 */ - sgsap_ue_act_ind, /* 0x10, "SGsAP-UE-ACTIVITY-INDICATION" 8.20 */ - sgsap_eps_det_ind, /* 0x11, "SGsAP-EPS-DETACH-INDICATION" 8.6 */ - sgsap_eps_det_ack, /* 0x12, "SGsAP-EPS-DETACH-ACK" 8.5 */ - sgsap_imsi_det_ind, /* 0x13, "SGsAP-IMSI-DETACH-INDICATION" 8.8 */ - sgsap_imsi_det_ack, /* 0x14, "SGsAP-IMSI-DETACH-ACK" 8.7 */ - sgsap_reset_ind, /* 0x15, "SGsAP-RESET-INDICATION" 8.16 */ - sgsap_reset_ack, /* 0x16, "SGsAP-RESET-ACK" 8.15 */ - NULL,/* No IE's */ /* 0x17, "SGsAP-SERVICE-ABORT-REQUEST" 8.24 */ + NULL, /* 0x03, "Unassigned" 7 */ + NULL, /* 0x04, "Unassigned" 7 */ + NULL, /* 0x05, "Unassigned" 7 */ + + sgsap_service_req, /* 0x06, "SGsAP-SERVICE-REQUEST" 8.17 */ + sgsap_dl_unitdata, /* 0x07, "SGsAP-DOWNLINK-UNITDATA" 8.4 */ + sgsap_ue_ul_unitdata, /* 0x08, "SGsAP-UPLINK-UNITDATA" 8.22 */ + sgsap_imsi_loc_update_req, /* 0x09, "SGsAP-LOCATION-UPDATE-REQUEST" 8.11 */ + sgsap_imsi_loc_update_acc, /* 0x0a, "SGsAP-LOCATION-UPDATE-ACCEPT" 8.9 */ + sgsap_imsi_loc_update_rej, /* 0x0b, "SGsAP-LOCATION-UPDATE-REJECT" 8.10 */ + sgsap_tmsi_realloc_comp, /* 0x0c, "SGsAP-TMSI-REALLOCATION-COMPLETE" 8.19 */ + sgsap_alert_req, /* 0x0d, "SGsAP-ALERT-REQUEST" 8.3 */ + sgsap_alert_ack, /* 0x0e, "SGsAP-ALERT-ACK" 8.1 */ + sgsap_alert_rej, /* 0x0f, "SGsAP-ALERT-REJECT" 8.2 */ + sgsap_ue_act_ind, /* 0x10, "SGsAP-UE-ACTIVITY-INDICATION" 8.20 */ + sgsap_eps_det_ind, /* 0x11, "SGsAP-EPS-DETACH-INDICATION" 8.6 */ + sgsap_eps_det_ack, /* 0x12, "SGsAP-EPS-DETACH-ACK" 8.5 */ + sgsap_imsi_det_ind, /* 0x13, "SGsAP-IMSI-DETACH-INDICATION" 8.8 */ + sgsap_imsi_det_ack, /* 0x14, "SGsAP-IMSI-DETACH-ACK" 8.7 */ + sgsap_reset_ind, /* 0x15, "SGsAP-RESET-INDICATION" 8.16 */ + sgsap_reset_ack, /* 0x16, "SGsAP-RESET-ACK" 8.15 */ + NULL,/* No IE's */ /* 0x17, "SGsAP-SERVICE-ABORT-REQUEST" 8.24 */ /* * 0 0 0 1 1 0 0 0 * to * 0 0 0 1 1 0 0 1 * Unassigned: treated as an unknown Message type */ - NULL, /* 0x18, "Unassigned" */ - NULL, /* 0x19, "Unassigned" */ + NULL, /* 0x18, "Unassigned" */ + NULL, /* 0x19, "Unassigned" */ - sgsap_mm_info_req, /* 0x1a, "SGsAP-MM-INFORMATION-REQUEST" 8.12 */ - sgsap_release_req, /* 0x1b, "SGsAP-RELEASE-REQUEST" 8.23 */ + sgsap_mm_info_req, /* 0x1a, "SGsAP-MM-INFORMATION-REQUEST" 8.12 */ + sgsap_release_req, /* 0x1b, "SGsAP-RELEASE-REQUEST" 8.23 */ /* - * 0 0 0 1 1 1 0 0 Unassigned: treated as an unknown Message type 7 + * 0 0 0 1 1 1 0 0 Unassigned: treated as an unknown Message type 7 */ - NULL, /* 0x1c, "Unassigned" */ + NULL, /* 0x1c, "Unassigned" */ - sgsap_status, /* 0x1d, "SGsAP-STATUS" 8.18 */ - NULL, /* 0x1e, "Unassigned" */ - sgsap_ue_unreachable, /* 0x1f, "SGsAP-UE-UNREACHABLE" 8.21 */ + sgsap_status, /* 0x1d, "SGsAP-STATUS" 8.18 */ + NULL, /* 0x1e, "Unassigned" */ + sgsap_ue_unreachable, /* 0x1f, "SGsAP-UE-UNREACHABLE" 8.21 */ - NULL, /* NONE */ + NULL, /* NONE */ }; -static void get_sgsap_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn) +static void get_sgsap_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn_p) { - gint idx; + gint idx; - *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &sgsap_msg_strings_ext, &idx); - *ett_tree = ett_sgsap_msg[idx]; - *hf_idx = hf_sgsap_msg_type; - *msg_fcn = sgsap_msg_fcn[idx]; + *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &sgsap_msg_strings_ext, &idx); + *ett_tree = ett_sgsap_msg[idx]; + *hf_idx = hf_sgsap_msg_type; + *msg_fcn_p = sgsap_msg_fcn[idx]; - return; + return; } static void dissect_sgsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *item; - proto_tree *sgsap_tree; - int offset = 0; - guint32 len; - const gchar *msg_str; - gint ett_tree; - int hf_idx; - void (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len); - guint8 oct; - - /* Save pinfo */ - gpinfo = pinfo; - len = tvb_length(tvb); - - /* Make entry in the Protocol column on summary display */ - col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME); - - item = proto_tree_add_item(tree, proto_sgsap, tvb, 0, -1, ENC_NA); - sgsap_tree = proto_item_add_subtree(item, ett_sgsap); - - /* Messge type IE*/ - oct = tvb_get_guint8(tvb,offset); - msg_fcn = NULL; - ett_tree = -1; - hf_idx = -1; - msg_str = NULL; - - get_sgsap_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn); - - if(msg_str){ - col_add_fstr(pinfo->cinfo, COL_INFO, "%s", msg_str); - }else{ - proto_tree_add_text(tree, tvb, offset, 1,"Unknown message 0x%x",oct); - return; - } - - /* - * Add SGSAP message name - */ - proto_tree_add_item(sgsap_tree, hf_idx, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - - - /* - * decode elements - */ - if (msg_fcn == NULL) - { - proto_tree_add_text(sgsap_tree, tvb, offset, len - offset, - "Message Elements"); - } - else - { - (*msg_fcn)(tvb, sgsap_tree, pinfo, offset, len - offset); - } + proto_item *item; + proto_tree *sgsap_tree; + int offset = 0; + guint32 len; + const gchar *msg_str; + gint ett_tree; + int hf_idx; + void (*msg_fcn_p)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len); + guint8 oct; + + /* Save pinfo */ + gpinfo = pinfo; + len = tvb_length(tvb); + + /* Make entry in the Protocol column on summary display */ + col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME); + + item = proto_tree_add_item(tree, proto_sgsap, tvb, 0, -1, ENC_NA); + sgsap_tree = proto_item_add_subtree(item, ett_sgsap); + + /* Messge type IE*/ + oct = tvb_get_guint8(tvb, offset); + msg_fcn_p = NULL; + ett_tree = -1; + hf_idx = -1; + msg_str = NULL; + + get_sgsap_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p); + + if (msg_str) { + col_add_fstr(pinfo->cinfo, COL_INFO, "%s", msg_str); + }else{ + proto_tree_add_text(tree, tvb, offset, 1, "Unknown message 0x%x", oct); + return; + } + + /* + * Add SGSAP message name + */ + proto_tree_add_item(sgsap_tree, hf_idx, tvb, offset, 1, ENC_BIG_ENDIAN); + offset++; + + + /* + * decode elements + */ + if (msg_fcn_p == NULL) + { + proto_tree_add_text(sgsap_tree, tvb, offset, len - offset, + "Message Elements"); + } + else + { + (*msg_fcn_p)(tvb, sgsap_tree, pinfo, offset, len - offset); + } } @@ -1459,22 +1459,22 @@ void proto_register_sgsap(void) { }, { &hf_sgsap_eps_location_update_type, { "EPS location update type", "sgsap.eps_location_update_type", - FT_UINT8, BASE_DEC, VALS(sgsap_eps_location_update_type_values),0x0, + FT_UINT8, BASE_DEC, VALS(sgsap_eps_location_update_type_values), 0x0, NULL, HFILL } }, { &hf_sgsap_service_indicator_value, { "Service indicator", "sgsap.service_indicator", - FT_UINT8, BASE_DEC, VALS(sgsap_service_indicator_values),0x0, + FT_UINT8, BASE_DEC, VALS(sgsap_service_indicator_values), 0x0, NULL, HFILL } }, { &hf_sgsap_sgs_cause, { "SGs cause", "sgsap.sgs_cause", - FT_UINT8, BASE_DEC|BASE_EXT_STRING, &sgsap_sgs_cause_values_ext,0x0, + FT_UINT8, BASE_DEC|BASE_EXT_STRING, &sgsap_sgs_cause_values_ext, 0x0, NULL, HFILL } }, { &hf_sgsap_ue_emm_mode, { "UE EMM mode", "sgsap.ue_emm_mode", - FT_UINT8, BASE_DEC, VALS(sgsap_ue_emm_mode_values),0x0, + FT_UINT8, BASE_DEC, VALS(sgsap_ue_emm_mode_values), 0x0, NULL, HFILL } }, { &hf_sgsap_eci, @@ -1489,12 +1489,12 @@ void proto_register_sgsap(void) { }, { &hf_sgsap_imsi_det_eps, { "IMSI detach from EPS service type", "sgsap.imsi_det_eps", - FT_UINT8, BASE_DEC, VALS(sgsap_imsi_det_from_eps_serv_type_values),0x0, + FT_UINT8, BASE_DEC, VALS(sgsap_imsi_det_from_eps_serv_type_values), 0x0, NULL, HFILL } }, { &hf_sgsap_lcs_indic, { "LCS indicator", "sgsap.lcs_indicator", - FT_UINT8, BASE_DEC, VALS(sgsap_lcs_indic_values),0x0, + FT_UINT8, BASE_DEC, VALS(sgsap_lcs_indic_values), 0x0, NULL, HFILL } }, { &hf_sgsap_mme_name, @@ -1507,7 +1507,7 @@ void proto_register_sgsap(void) { FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} }, - { &hf_sgsap_imeisv, + { &hf_sgsap_imeisv, {"IMEISV", "sgsap.imeisv", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} @@ -1515,7 +1515,7 @@ void proto_register_sgsap(void) { }; /* Setup protocol subtree array */ -#define NUM_INDIVIDUAL_ELEMS 1 +#define NUM_INDIVIDUAL_ELEMS 1 gint *ett[NUM_INDIVIDUAL_ELEMS + NUM_SGSAP_ELEM + NUM_SGSAP_MSG]; @@ -1552,7 +1552,7 @@ proto_reg_handoff_sgsap(void) /* The registered SCTP port number for SGsAP is 29118. * The payload protocol identifier to be used for SGsAP is 0. */ - static gboolean Initialized=FALSE; + static gboolean Initialized = FALSE; static dissector_handle_t sgsap_handle; static guint SctpPort; @@ -1568,8 +1568,9 @@ proto_reg_handoff_sgsap(void) } } - SctpPort=gbl_sgsapSctpPort; + SctpPort = gbl_sgsapSctpPort; if (SctpPort != 0) { dissector_add_uint("sctp.port", SctpPort, sgsap_handle); } } + diff --git a/epan/dissectors/packet-wai.c b/epan/dissectors/packet-wai.c index 7b633d11e4..56ed1fd998 100644 --- a/epan/dissectors/packet-wai.c +++ b/epan/dissectors/packet-wai.c @@ -39,29 +39,29 @@ #include <epan/etypes.h> #include <epan/reassemble.h> -#define WAI_SUB_PRE_AUTHENTICATION 0x01 /* pre-authentication start */ -#define WAI_SUB_STAKEY_REQ 0x02 /* STAKey request */ -#define WAI_SUB_AUTH_ACTIVATION 0x03 /* authentication activation */ -#define WAI_SUB_ACCESS_AUTH_REQ 0x04 /* access authentication request */ -#define WAI_SUB_ACCESS_AUTH_RESP 0x05 /* access authentication response */ -#define WAI_SUB_CERT_AUTH_REQ 0x06 /* certificate authentication request */ -#define WAI_SUB_CERT_AUTH_RESP 0x07 /* certificate authentication response */ -#define WAI_SUB_UNICAST_KEY_REQ 0x08 /* unicast key negotiation request */ -#define WAI_SUB_UNICAST_KEY_RESP 0x09 /* unicast key negotiation response */ -#define WAI_SUB_UNICAST_KEY_CONFIRM 0x0A /* unicast key negotiation confirmation */ -#define WAI_SUB_MULTICAST_ANNOUNCE 0x0B /* multicast key/STAKey announcement */ -#define WAI_SUB_MULTICAST_ANNOUNCE_RESP 0x0C /* multicast key/STAKey announcement response */ - -#define FLAG_BIT0 0x01 -#define FLAG_BIT1 0x02 -#define FLAG_BIT2 0x04 -#define FLAG_BIT3 0x08 -#define FLAG_BIT4 0x10 -#define FLAG_BIT5 0x20 -#define FLAG_BIT6 0x40 -#define FLAG_BIT7 0x80 - -static GHashTable *wai_fragment_table = NULL; +#define WAI_SUB_PRE_AUTHENTICATION 0x01 /* pre-authentication start */ +#define WAI_SUB_STAKEY_REQ 0x02 /* STAKey request */ +#define WAI_SUB_AUTH_ACTIVATION 0x03 /* authentication activation */ +#define WAI_SUB_ACCESS_AUTH_REQ 0x04 /* access authentication request */ +#define WAI_SUB_ACCESS_AUTH_RESP 0x05 /* access authentication response */ +#define WAI_SUB_CERT_AUTH_REQ 0x06 /* certificate authentication request */ +#define WAI_SUB_CERT_AUTH_RESP 0x07 /* certificate authentication response */ +#define WAI_SUB_UNICAST_KEY_REQ 0x08 /* unicast key negotiation request */ +#define WAI_SUB_UNICAST_KEY_RESP 0x09 /* unicast key negotiation response */ +#define WAI_SUB_UNICAST_KEY_CONFIRM 0x0A /* unicast key negotiation confirmation */ +#define WAI_SUB_MULTICAST_ANNOUNCE 0x0B /* multicast key/STAKey announcement */ +#define WAI_SUB_MULTICAST_ANNOUNCE_RESP 0x0C /* multicast key/STAKey announcement response */ + +#define FLAG_BIT0 0x01 +#define FLAG_BIT1 0x02 +#define FLAG_BIT2 0x04 +#define FLAG_BIT3 0x08 +#define FLAG_BIT4 0x10 +#define FLAG_BIT5 0x20 +#define FLAG_BIT6 0x40 +#define FLAG_BIT7 0x80 + +static GHashTable *wai_fragment_table = NULL; static GHashTable *wai_reassembled_table = NULL; static int proto_wai = -1; @@ -187,20 +187,21 @@ static const fragment_items wai_frag_items = { }; static const value_string wai_subtype_names[] = { - { WAI_SUB_PRE_AUTHENTICATION, "Pre-Authentication start" }, - { WAI_SUB_STAKEY_REQ, "STAKey request" }, - { WAI_SUB_AUTH_ACTIVATION, "Authentication activation" }, - { WAI_SUB_ACCESS_AUTH_REQ, "Access authentication request" }, - { WAI_SUB_ACCESS_AUTH_RESP, "Access authentication response" }, - { WAI_SUB_CERT_AUTH_REQ, "Certificate authentication request" }, - { WAI_SUB_CERT_AUTH_RESP, "Certificate authentication response" }, - { WAI_SUB_UNICAST_KEY_REQ, "Unicast key negotiation request" }, - { WAI_SUB_UNICAST_KEY_RESP, "Unicast key negotiation response" }, - { WAI_SUB_UNICAST_KEY_CONFIRM, "Unicast key negotiation confirmation" }, - { WAI_SUB_MULTICAST_ANNOUNCE, "Multicast key/STAKey announcement" }, - { WAI_SUB_MULTICAST_ANNOUNCE_RESP, "Multicast key/STAKey announcement response" }, + { WAI_SUB_PRE_AUTHENTICATION, "Pre-Authentication start" }, + { WAI_SUB_STAKEY_REQ, "STAKey request" }, + { WAI_SUB_AUTH_ACTIVATION, "Authentication activation" }, + { WAI_SUB_ACCESS_AUTH_REQ, "Access authentication request" }, + { WAI_SUB_ACCESS_AUTH_RESP, "Access authentication response" }, + { WAI_SUB_CERT_AUTH_REQ, "Certificate authentication request" }, + { WAI_SUB_CERT_AUTH_RESP, "Certificate authentication response" }, + { WAI_SUB_UNICAST_KEY_REQ, "Unicast key negotiation request" }, + { WAI_SUB_UNICAST_KEY_RESP, "Unicast key negotiation response" }, + { WAI_SUB_UNICAST_KEY_CONFIRM, "Unicast key negotiation confirmation" }, + { WAI_SUB_MULTICAST_ANNOUNCE, "Multicast key/STAKey announcement" }, + { WAI_SUB_MULTICAST_ANNOUNCE_RESP, "Multicast key/STAKey announcement response" }, { 0, NULL } }; +static value_string_ext wai_subtype_names_ext = VALUE_STRING_EXT_INIT(wai_subtype_names); static const true_false_string wai_bk_rekeying_flag = { "Packet is a BK rekeying packet", @@ -245,20 +246,20 @@ static const true_false_string wai_reserved_flag = { static void dissect_flag(tvbuff_t *tvb, guint offset, proto_tree *tree) { - proto_item *flag_item; - proto_tree *flag_tree; + proto_item *flag_item; + proto_tree *flag_tree; flag_item = proto_tree_add_item(tree, hf_wai_flag, tvb, offset, 1, ENC_BIG_ENDIAN); flag_tree = proto_item_add_subtree (flag_item, ett_wai_flags); - proto_tree_add_item (flag_tree, hf_wai_bk_rekeying_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_bk_rekeying_flag, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item (flag_tree, hf_wai_preauthentication_flag, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (flag_tree, hf_wai_certificate_flag, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (flag_tree, hf_wai_optional_flag, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (flag_tree, hf_wai_usk_rekeying_flag, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (flag_tree, hf_wai_negotiation_flag, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (flag_tree, hf_wai_revoking_flag, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item (flag_tree, hf_wai_reserved_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_certificate_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_optional_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_usk_rekeying_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_negotiation_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_revoking_flag, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item (flag_tree, hf_wai_reserved_flag, tvb, offset, 1, ENC_BIG_ENDIAN); } inline static void @@ -311,13 +312,13 @@ dissect_authentication_id(tvbuff_t *tvb, guint offset, proto_tree *tree) static void dissect_addid(tvbuff_t *tvb, guint offset, proto_tree *tree) { - proto_item *mac_item; - proto_tree *mac_tree; + proto_item *mac_item; + proto_tree *mac_tree; mac_item = proto_tree_add_string(tree, hf_wai_addid, tvb, offset, 12, "AE MAC and ASUE MAC addresses"); mac_tree = proto_item_add_subtree(mac_item, ett_wai_mac); - proto_tree_add_item(mac_tree, hf_wai_ae_mac, tvb, offset, 6, ENC_NA); + proto_tree_add_item(mac_tree, hf_wai_ae_mac, tvb, offset, 6, ENC_NA); proto_tree_add_item(mac_tree, hf_wai_asue_mac, tvb, offset+6, 6, ENC_NA); } @@ -325,17 +326,17 @@ static guint16 dissect_identity(tvbuff_t * tvb, const guint16 offset, proto_tree * tree, const char * const label) { - proto_tree *id_tree; - proto_item *id_item; - guint16 length; + proto_tree *id_tree; + proto_item *id_item; + guint16 length; length = tvb_get_ntohs(tvb, offset+2); id_item = proto_tree_add_item(tree, hf_wai_identity, tvb, offset, length+4, ENC_NA); id_tree = proto_item_add_subtree(id_item, ett_wai_identity); proto_item_set_text(id_item, "%sIdentity", ((label==NULL)?"":label)); - proto_tree_add_item(id_tree, hf_wai_identity_id, tvb, offset, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(id_tree, hf_wai_identity_len, tvb, offset+2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(id_tree, hf_wai_identity_id, tvb, offset, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(id_tree, hf_wai_identity_len, tvb, offset+2, 2, ENC_BIG_ENDIAN); proto_tree_add_item(id_tree, hf_wai_identity_data, tvb, offset+4, length, ENC_NA); return length + 4; @@ -345,12 +346,12 @@ static gint16 dissect_certificate(tvbuff_t * tvb, const gint offset, proto_tree * tree, const gchar * const label) { - proto_item *certificate_item; - proto_tree *certificate_tree; - proto_item *id_item; - guint16 length; - guint16 id; - const gchar *id_name = "unknown"; + proto_item *certificate_item; + proto_tree *certificate_tree; + proto_item *id_item; + guint16 length; + guint16 id; + const gchar *id_name = "unknown"; id = tvb_get_ntohs(tvb, offset); @@ -368,7 +369,7 @@ dissect_certificate(tvbuff_t * tvb, const gint offset, proto_tree * tree, id_item = proto_tree_add_item(certificate_tree, hf_wai_cert_id, tvb, offset, 2, ENC_BIG_ENDIAN); proto_item_set_text(id_item, "Certificate Identifier: %s (%#x)", id_name, id); - proto_tree_add_item(certificate_tree, hf_wai_cert_len, tvb, offset+2, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(certificate_tree, hf_wai_cert_len, tvb, offset+2, 2, ENC_BIG_ENDIAN); proto_tree_add_item(certificate_tree, hf_wai_cert_data, tvb, offset+4, length, ENC_NA); return length + 4; @@ -377,12 +378,12 @@ dissect_certificate(tvbuff_t * tvb, const gint offset, proto_tree * tree, static guint16 dissect_ecdh_parameter(tvbuff_t * tvb, const gint offset, proto_tree * tree) { - proto_item *ecdh_item; - proto_tree *ecdh_tree; - proto_item *ecdh_id_item; - guint8 ecdh_id; - guint16 ecdh_len; - const gchar *id_name = "unknown"; + proto_item *ecdh_item; + proto_tree *ecdh_tree; + proto_item *ecdh_id_item; + guint8 ecdh_id; + guint16 ecdh_len; + const gchar *id_name = "unknown"; ecdh_id = tvb_get_guint8(tvb, offset); @@ -394,11 +395,11 @@ dissect_ecdh_parameter(tvbuff_t * tvb, const gint offset, proto_tree * tree) ecdh_len = tvb_get_ntohs(tvb, offset+1); - ecdh_item = proto_tree_add_item(tree, hf_wai_ecdh, tvb, offset, ecdh_len+3, ENC_NA); + ecdh_item = proto_tree_add_item(tree, hf_wai_ecdh, tvb, offset, ecdh_len+3, ENC_NA); ecdh_tree = proto_item_add_subtree(ecdh_item, ett_wai_ecdh_param); ecdh_id_item = proto_tree_add_item(ecdh_tree, hf_wai_ecdh_id, tvb, offset, 1, ENC_BIG_ENDIAN); proto_item_set_text(ecdh_id_item, "ID: %s (%#x)", id_name, ecdh_id); - proto_tree_add_item(ecdh_tree, hf_wai_ecdh_len, tvb, offset+1, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(ecdh_tree, hf_wai_ecdh_len, tvb, offset+1, 2, ENC_BIG_ENDIAN); proto_tree_add_item(ecdh_tree, hf_wai_ecdh_content, tvb, offset+3, ecdh_len, ENC_NA); return ecdh_len + 3; @@ -407,8 +408,8 @@ dissect_ecdh_parameter(tvbuff_t * tvb, const gint offset, proto_tree * tree) static guint16 dissect_challenge(tvbuff_t *tvb, guint offset, proto_tree *tree, const gchar * const label) { - proto_item *challenge_item; - const guint16 challenge_length = 32; + proto_item *challenge_item; + const guint16 challenge_length = 32; challenge_item = proto_tree_add_item(tree, hf_wai_challenge, tvb, offset, 32, ENC_NA); proto_item_append_text(challenge_item, "(%schallenge)", ((label==NULL)?"":label)); @@ -419,9 +420,9 @@ dissect_challenge(tvbuff_t *tvb, guint offset, proto_tree *tree, const gchar * c static guint16 dissect_key_data(tvbuff_t *tvb, guint offset, proto_tree *tree, const gchar *const label) { - proto_item *key_data_item; - proto_tree *key_data_tree; - guint8 length; + proto_item *key_data_item; + proto_tree *key_data_tree; + guint8 length; length = tvb_get_guint8(tvb, offset); @@ -440,17 +441,17 @@ dissect_key_data(tvbuff_t *tvb, guint offset, proto_tree *tree, const gchar *con static guint dissect_multiple_certificate(tvbuff_t * tvb, guint offset, proto_tree *tree) { - proto_item *multicert_item; - proto_tree *multicert_tree; - proto_item *nonce_1_item; - proto_item *nonce_2_item; - guint length; + proto_item *multicert_item; + proto_tree *multicert_tree; + proto_item *nonce_1_item; + proto_item *nonce_2_item; + guint length; length = tvb_get_ntohs(tvb, offset+1); multicert_item = proto_tree_add_item(tree, hf_wai_cert_ver, tvb, offset, length+3, ENC_NA); multicert_tree = proto_item_add_subtree(multicert_item, ett_wai_certificate_verification); proto_tree_add_item(multicert_tree, hf_wai_type, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; proto_tree_add_item(multicert_tree, hf_wai_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; nonce_1_item = proto_tree_add_item(multicert_tree, hf_wai_nonce, tvb, offset, 32, ENC_NA); @@ -460,10 +461,10 @@ dissect_multiple_certificate(tvbuff_t * tvb, guint offset, proto_tree *tree) offset += 32; proto_item_append_text(nonce_2_item, " 2"); proto_tree_add_item(multicert_tree, hf_wai_ver_res, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; offset += dissect_certificate(tvb, offset, multicert_tree, "1 "); proto_tree_add_item(multicert_tree, hf_wai_ver_res, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; offset += dissect_certificate(tvb, offset, multicert_tree, "2 "); return length + 3; @@ -472,21 +473,21 @@ dissect_multiple_certificate(tvbuff_t * tvb, guint offset, proto_tree *tree) static guint dissect_identity_list(tvbuff_t *tvb, guint offset, proto_tree *tree) { - proto_item *id_list_item; - proto_tree *id_list_tree; - guint16 length; - guint16 no_of_ids; - guint16 i; + proto_item *id_list_item; + proto_tree *id_list_tree; + guint16 length; + guint16 no_of_ids; + guint16 i; length = tvb_get_ntohs(tvb, offset+1); id_list_item = proto_tree_add_item(tree, hf_wai_identity_list, tvb, offset, length+3, ENC_NA); id_list_tree = proto_item_add_subtree(id_list_item, ett_wai_identity_list); proto_tree_add_item(id_list_tree, hf_wai_type, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; proto_tree_add_item(id_list_tree, hf_wai_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(id_list_tree, hf_wai_reserved_byte, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; proto_tree_add_item(id_list_tree, hf_wai_no_of_ids, tvb, offset, 2, ENC_BIG_ENDIAN); no_of_ids = tvb_get_ntohs(tvb, offset); offset += 2; @@ -504,18 +505,18 @@ dissect_identity_list(tvbuff_t *tvb, guint offset, proto_tree *tree) static guint16 dissect_signature_algorithm(tvbuff_t *tvb, guint offset, proto_tree *tree) { - proto_item *sa_item; - proto_tree *sa_tree; - proto_item *param_item; - proto_tree *param_tree; - proto_item *alg_name_item; - proto_item *sig_name_item; - guint16 length; - guint8 alg_id; - guint8 sig_id; - guint16 param_len; - - length = tvb_get_ntohs(tvb, offset); + proto_item *sa_item; + proto_tree *sa_tree; + proto_item *param_item; + proto_tree *param_tree; + proto_item *alg_name_item; + proto_item *sig_name_item; + guint16 length; + guint8 alg_id; + guint8 sig_id; + guint16 param_len; + + length = tvb_get_ntohs(tvb, offset); sa_item = proto_tree_add_item(tree, hf_wai_sign_alg, tvb, offset, length+2, ENC_NA); sa_tree = proto_item_add_subtree(sa_item, ett_wai_sign_alg); @@ -539,7 +540,7 @@ dissect_signature_algorithm(tvbuff_t *tvb, guint offset, proto_tree *tree) } offset += 1; - param_len = tvb_get_ntohs(tvb, offset+1); + param_len = tvb_get_ntohs(tvb, offset+1); param_item = proto_tree_add_item(sa_tree, hf_wai_param, tvb, offset, param_len+3, ENC_NA); param_tree = proto_item_add_subtree(param_item, ett_wai_parameter); proto_tree_add_item(param_tree, hf_wai_param_id, tvb, offset, 1, ENC_NA); @@ -554,11 +555,11 @@ dissect_signature_algorithm(tvbuff_t *tvb, guint offset, proto_tree *tree) static guint16 dissect_signature_value(tvbuff_t *tvb, guint offset, proto_tree *tree) { - proto_item *sv_item; - proto_tree *sv_tree; - guint16 length = 0; + proto_item *sv_item; + proto_tree *sv_tree; + guint16 length = 0; - length = tvb_get_ntohs(tvb, offset); + length = tvb_get_ntohs(tvb, offset); sv_item = proto_tree_add_item(tree, hf_wai_sign_val, tvb, offset, length+2, ENC_NA); sv_tree = proto_item_add_subtree(sv_item, ett_wai_sign_val); @@ -574,18 +575,18 @@ dissect_signature_value(tvbuff_t *tvb, guint offset, proto_tree *tree) static guint16 dissect_signature(tvbuff_t *tvb, guint offset, proto_tree *tree, const gchar *const label) { - proto_item *ss_item; - proto_tree *ss_tree; - guint length = 0; + proto_item *ss_item; + proto_tree *ss_tree; + guint length = 0; - length = tvb_get_ntohs(tvb, offset+1); + length = tvb_get_ntohs(tvb, offset+1); ss_item = proto_tree_add_item(tree, hf_wai_sign, tvb, offset, length+3, ENC_NA); proto_item_set_text(ss_item, "%s", (label==NULL)?"Signature":label); ss_tree = proto_item_add_subtree(ss_item, ett_wai_sign); proto_tree_add_item(ss_tree, hf_wai_type, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; proto_tree_add_item(ss_tree, hf_wai_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; @@ -599,18 +600,18 @@ dissect_signature(tvbuff_t *tvb, guint offset, proto_tree *tree, const gchar *co static void -dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length) +dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 lenx) { - proto_item *data_item; - proto_tree *data_tree; - const gchar *type_name; + proto_item *data_item; + proto_tree *data_tree; + const gchar *type_name; - data_item = proto_tree_add_item(tree, hf_wai_data, tvb, 0, length, ENC_NA); + data_item = proto_tree_add_item(tree, hf_wai_data, tvb, 0, lenx, ENC_NA); data_tree = proto_item_add_subtree (data_item, ett_wai_data); - type_name = val_to_str_const(subtype, wai_subtype_names, "Unknown type"); + type_name = val_to_str_ext_const(subtype, &wai_subtype_names_ext, "Unknown type"); - proto_item_set_text(data_item, "%s data (%d bytes)", type_name, length); + proto_item_set_text(data_item, "%s data (%d bytes)", type_name, lenx); switch (subtype) { case WAI_SUB_PRE_AUTHENTICATION: @@ -640,7 +641,7 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length guint16 offset = 0; dissect_flag(tvb, offset, data_tree); - offset++; + offset += 1; dissect_authentication_id(tvb, offset, data_tree); offset += 32; offset += dissect_identity(tvb, offset, data_tree, "Local ASU "); @@ -657,7 +658,7 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length optional_field = tvb_get_guint8(tvb, 0) & FLAG_BIT3; dissect_flag(tvb, offset, data_tree); - offset++; + offset += 1; dissect_authentication_id(tvb, offset, data_tree); offset += 32; offset += dissect_challenge(tvb, offset, data_tree, "ASUE "); @@ -682,11 +683,11 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length optional_field = tvb_get_guint8(tvb, 0) & FLAG_BIT3; dissect_flag(tvb, offset, data_tree); - offset++; + offset += 1; offset += dissect_challenge(tvb, offset, data_tree, "ASUE "); offset += dissect_challenge(tvb, offset, data_tree, "AE "); proto_tree_add_item(data_tree, hf_wai_access_res, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; + offset += 1; offset += dissect_key_data(tvb, offset, data_tree, "ASUE "); offset += dissect_key_data(tvb, offset, data_tree, "AE "); offset += dissect_identity(tvb, offset, data_tree, "STA AE "); @@ -705,7 +706,7 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length guint16 offset = 0; dissect_addid(tvb, offset, data_tree); - offset+=12; + offset += 12; offset += dissect_challenge(tvb, offset, data_tree, "AE "); offset += dissect_challenge(tvb, offset, data_tree, "ASUE "); offset += dissect_certificate(tvb, offset, data_tree, "STE ASUE "); @@ -732,14 +733,14 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length dissect_bkid(tvb, 1, data_tree); dissect_uskid(tvb, 17, data_tree); dissect_addid(tvb, 18, data_tree); - dissect_challenge(tvb, 30, data_tree ,"AE "); + dissect_challenge(tvb, 30, data_tree , "AE "); break; } case WAI_SUB_UNICAST_KEY_RESP: { /* Chapter 8.1.4.3.2 Unicast Key Negotiation Response [ref: 1] */ - tvbuff_t *next_tvb; - guint length = 0; + tvbuff_t *next_tvb; + guint length = 0; dissect_flag(tvb, 0, data_tree); dissect_bkid(tvb, 1, data_tree); @@ -758,8 +759,8 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length case WAI_SUB_UNICAST_KEY_CONFIRM: { /* Chapter 8.1.4.3.3 Unicast Key Negotiation Confirmation [ref: 1] */ - tvbuff_t *next_tvb; - guint length = 0; + tvbuff_t *next_tvb; + guint length = 0; dissect_flag(tvb, 0, data_tree); dissect_bkid(tvb, 1, data_tree); @@ -798,7 +799,7 @@ dissect_wai_data(tvbuff_t *tvb, proto_tree *tree, guint8 subtype, guint16 length case WAI_SUB_MULTICAST_ANNOUNCE_RESP: { /* Chapter 8.1.4.4.2 Multicast Key/STAKey Announcement Response [ref: 1] */ - dissect_flag(tvb, 0, data_tree); + dissect_flag(tvb, 0, data_tree); dissect_mskid(tvb, 1, data_tree); dissect_uskid(tvb, 2, data_tree); dissect_addid(tvb, 3, data_tree); @@ -823,69 +824,70 @@ dissect_wai(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |-----------------------------------------------------------------------------| Figure 18 from [ref:1] */ -#define WAI_MESSAGE_LENGTH 12 /*Length of all fields without 'Data' field*/ -#define WAI_DATA_OFFSET WAI_MESSAGE_LENGTH - guint16 version; - guint8 subtype; - guint16 length; - guint16 packet_num; - guint8 fragment_num; - guint8 flags; - fragment_data *frag_msg; - proto_tree *wai_tree = NULL; - tvbuff_t *next_tvb; - tvbuff_t *new_tvb; - const gchar *subtype_name = "Unknown type"; +#define WAI_MESSAGE_LENGTH 12 /*Length of all fields without 'Data' field*/ +#define WAI_DATA_OFFSET WAI_MESSAGE_LENGTH + guint16 version; + guint8 subtype; + guint16 length; + guint16 packet_num; + guint8 fragment_num; + guint8 flags; + fragment_data *frag_msg; + proto_tree *wai_tree = NULL; + tvbuff_t *next_tvb; + tvbuff_t *new_tvb; + const gchar *subtype_name = "Unknown type"; length = tvb_get_ntohs(tvb, 6)-WAI_MESSAGE_LENGTH; subtype = tvb_get_guint8(tvb, 3); /* quick sanity check */ - if ((length != tvb_reported_length (tvb)-WAI_MESSAGE_LENGTH) || (subtype > WAI_SUB_MULTICAST_ANNOUNCE_RESP)) { + if ((length != tvb_reported_length (tvb)-WAI_MESSAGE_LENGTH) || + (subtype > WAI_SUB_MULTICAST_ANNOUNCE_RESP)) { return; } col_set_str(pinfo->cinfo, COL_PROTOCOL, "WAI"); - col_clear (pinfo->cinfo, COL_INFO); + col_clear(pinfo->cinfo, COL_INFO); version = tvb_get_ntohs(tvb, 0); if (version == 1) { - subtype_name = val_to_str_const(subtype, wai_subtype_names, "Unknown type"); + subtype_name = val_to_str_ext_const(subtype, &wai_subtype_names_ext, "Unknown type"); } col_append_fstr(pinfo->cinfo, COL_INFO, "%s", subtype_name); /* Field lengths and offsets in WAI protocol described above */ - packet_num = tvb_get_ntohs(tvb, 8); + packet_num = tvb_get_ntohs(tvb, 8); fragment_num = tvb_get_guint8(tvb, 10); - flags = tvb_get_guint8(tvb, 11); + flags = tvb_get_guint8(tvb, 11); if (tree) { - proto_item *wai_item; + proto_item *wai_item; wai_item = proto_tree_add_item(tree, proto_wai, tvb, 0, -1, ENC_NA); proto_item_set_text (wai_item, "WAI Protocol (%s)", - val_to_str_const(subtype, wai_subtype_names, "Unknown type")); + val_to_str_ext_const(subtype, &wai_subtype_names_ext, "Unknown type")); wai_tree = proto_item_add_subtree(wai_item, ett_wai); /* Field lengths and offsets in WAI protocol described above */ - proto_tree_add_item(wai_tree, hf_wai_version, tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(wai_tree, hf_wai_type, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(wai_tree, hf_wai_subtype, tvb, 3, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(wai_tree, hf_wai_reserved, tvb, 4, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(wai_tree, hf_wai_length, tvb, 6,2, ENC_BIG_ENDIAN); - proto_tree_add_item(wai_tree, hf_wai_seq, tvb, 8, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_version, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_type, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_subtype, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_reserved, tvb, 4, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_length, tvb, 6, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_seq, tvb, 8, 2, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_fragm_seq, tvb, 10, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(wai_tree, hf_wai_flag, tvb, 11, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(wai_tree, hf_wai_flag, tvb, 11, 1, ENC_BIG_ENDIAN); } frag_msg = fragment_add_seq_check (tvb, WAI_DATA_OFFSET, pinfo, - packet_num, - wai_fragment_table, - wai_reassembled_table, - fragment_num, - length, - flags); + packet_num, + wai_fragment_table, + wai_reassembled_table, + fragment_num, + length, + flags); next_tvb = tvb_new_subset_remaining(tvb, WAI_DATA_OFFSET); @@ -903,7 +905,8 @@ Figure 18 from [ref:1] /* If this is the last fragment of fragmented message, then reassamble and dissect otherwise only dissect */ if (fragment_num > 0) { - new_tvb = process_reassembled_data(tvb, WAI_DATA_OFFSET, pinfo, "Reassembled WAI", frag_msg, &wai_frag_items, + new_tvb = process_reassembled_data(tvb, WAI_DATA_OFFSET, pinfo, + "Reassembled WAI", frag_msg, &wai_frag_items, NULL, wai_tree); if (new_tvb) { @@ -931,221 +934,365 @@ void proto_register_wai(void) { static hf_register_info hf[] = { - { &hf_wai_version, { "Version", "wai.version", FT_UINT16, BASE_DEC, NULL, - 0x0, "Version of authentication infrastructure", HFILL }}, - - { &hf_wai_type, { "Type", "wai.type", FT_UINT8, BASE_HEX, VALS(wai_type_names), - 0x0, "Protocol type", HFILL }}, - - { &hf_wai_subtype, { "Subtype", "wai.subtype", FT_UINT8, BASE_DEC, VALS(wai_subtype_names), - 0x0, NULL, HFILL }}, - - { &hf_wai_reserved, { "Reserved", "wai.reserved", FT_UINT16, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_length, { "Length", "wai.length", FT_UINT16, BASE_DEC, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_seq, { "Sequence number", "wai.seq", FT_UINT16, BASE_DEC, NULL, - 0x0, "Packet sequence number", HFILL }}, - - { &hf_wai_fragm_seq, { "Fragment sequence number", "wai.fragm.seq", FT_UINT8, BASE_DEC, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_flag, { "Flag", "wai.flag", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_data, { "Data", "wai.data", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_bk_rekeying_flag, {"BK rekeying", "wai.bk.rekeying.flag", FT_BOOLEAN, 8, TFS (&wai_bk_rekeying_flag), - FLAG_BIT0, "BK rekeying flag", HFILL }}, - - { &hf_wai_preauthentication_flag,{"Pre-Authentication", "wai.preauthentication.flag", FT_BOOLEAN, 8, TFS (&wai_preauthentication_flag), - FLAG_BIT1, "Pre-Authentication flag", HFILL }}, - - { &hf_wai_certificate_flag,{"Certificate", "wai.certificate.flag", FT_BOOLEAN, 8, TFS (&wai_certificate_flag), - FLAG_BIT2, "Certificate flag", HFILL }}, - - { &hf_wai_optional_flag,{"Optional", "wai.optional.flag", FT_BOOLEAN, 8, TFS (&wai_optional_flag), - FLAG_BIT3, "Optional flag", HFILL }}, - - { &hf_wai_usk_rekeying_flag,{"USK rekeying", "wai.usk.rekeying.flag", FT_BOOLEAN, 8, TFS (&wai_usk_rekeying_flag), - FLAG_BIT4, "USK rekeying flag", HFILL }}, - - { &hf_wai_negotiation_flag,{"STA negotiation", "wai.negotiation.flag", FT_BOOLEAN, 8, TFS (&wai_negotiation_flag), - FLAG_BIT5, "STA negotiation flag", HFILL }}, - - { &hf_wai_revoking_flag,{"STA revoking", "wai.revoking.flag", FT_BOOLEAN, 8, TFS (&wai_revoking_flag), - FLAG_BIT6, "STA revoking flag", HFILL }}, - - { &hf_wai_reserved_flag,{"Reserved", "wai.reserved.flag", FT_BOOLEAN, 8, TFS (&wai_reserved_flag), - FLAG_BIT7, "Reserved flag", HFILL }}, - - { &hf_wai_cert, {"Certificate", "wai.cert", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_cert_id, {"Id", "wai.cert.id", FT_UINT16, BASE_HEX, NULL, - 0x0, "Certificate Id", HFILL }}, - - { &hf_wai_cert_data, {"Data", "wai.cert.data", FT_BYTES, BASE_NONE, NULL, - 0x0, "Certificate data", HFILL }}, - - { &hf_wai_cert_len, {"Length", "wai.cert.len", FT_UINT16, BASE_DEC, NULL, - 0x0, "Certificate length", HFILL }}, - - { &hf_wai_addid, {"ADDID", "wai.addid", FT_STRING, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_ae_mac, {"AE MAC", "wai.ae.mac", FT_ETHER, BASE_NONE, NULL, - 0x0, "AE MAC address", HFILL }}, - - { &hf_wai_asue_mac, {"ASUE MAC", "wai.asue.mac", FT_ETHER, BASE_NONE, NULL, - 0x0, "ASUE MAC address", HFILL }}, - - { &hf_wai_bkid, {"BKID", "wai.bkid", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_uskid, {"USKID", "wai.uskid", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_wie, {"WIE from ASUE", "wai.wie", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_message_auth_code, {"Message Authentication Code", "wai.message.auth.code", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_mskid, {"MSKID/STAKeyID", "wai.mskid", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_data_pack_num, {"Data packet number", "wai.data.packet.num", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_key_data, {"Key Data", "wai.key.data", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_key_data_len, {"Length", "wai.key.data.len", FT_UINT8, BASE_DEC, NULL, - 0x0, "Key data length", HFILL }}, - - { &hf_wai_key_data_content, {"Content", "wai.key.data.content", FT_BYTES, BASE_NONE, NULL, - 0x0, "Key data content", HFILL }}, - - { &hf_wai_key_ann_id, {"Key Announcement Identifier", "wai.key.ann.id", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_auth_id, {"Authentication Identifier", "wai.auth.id", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_identity, {"Identifier", "wai.identity", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_identity_id, {"Id", "wai.identity.id", FT_UINT16, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_identity_len, {"Length", "wai.identity.len", FT_UINT16, BASE_DEC, NULL, - 0x0, "Identity length", HFILL }}, - - { &hf_wai_identity_data, {"Data", "wai.identity.data", FT_BYTES, BASE_NONE, NULL, - 0x0, "Identity data", HFILL }}, - - { &hf_wai_ecdh, {"ECDH Parameter", "wai.ecdhp", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_ecdh_id, {"ID", "wai.edch.id", FT_UINT8, BASE_HEX, NULL, - 0x0, "ECDH Parameter Identifier", HFILL }}, - - { &hf_wai_ecdh_len, {"Length", "wai.ecdh.len", FT_UINT16, BASE_DEC, NULL, - 0x0, "ECDH Parameter Length", HFILL }}, - - { &hf_wai_ecdh_content, {"Content", "wai.ecdh.content", FT_BYTES, BASE_NONE, NULL, - 0x0, "ECDH Parameter Content", HFILL }}, - - { &hf_wai_counter, {"Replay counter", "wai.counter", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_sta_key_id, {"STAKeyID", "wai.sta.key.id", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_challenge, {"Challenge", "wai.challenge", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_cert_ver, {"Multiple Certificate Verification Result", "wai.cert.ver", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_nonce, {"Nonce", "wai.nonce", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_ver_res, {"Verification result", "wai.ver.res", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_sign_alg, {"Signature Algorithm", "wai.sign.alg", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_hash_alg_id, {"Hash Algorithm Identifier", "wai.hash.alg.id", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_sign_alg_id, {"Signature Algorithm Identifier", "wai.sign.alg.id", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_param, {"Parameter", "wai.param", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_param_id, {"Parameter Identifier", "wai.param.id", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_param_content, {"Parameter Content", "wai.param.content", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_sign_val, {"Signature Value", "wai.sign.val", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_sign_content, {"Signature Content", "wai.sign.content", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_sign, {"Signature", "wai.sign", FT_BYTES, BASE_NONE, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_identity_list, {"ASU List trusted by ASUE", "wai.identity_list", FT_BYTES, BASE_NONE, NULL, - 0x0, "Identity list", HFILL }}, - - { &hf_wai_reserved_byte, {"Reserved", "wai.reserved.byte", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_no_of_ids, {"Number of Identities", "wai.no.of.ids", FT_UINT16, BASE_DEC, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_access_res, {"Access result", "wai.access_result", FT_UINT8, BASE_HEX, NULL, - 0x0, NULL, HFILL }}, - - { &hf_wai_fragments,{"Message fragments", "wai.fragments",FT_NONE, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment,{"Message fragment", "wai.fragment",FT_FRAMENUM, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment_overlap,{"Message fragment overlap", "wai.fragment.overlap",FT_BOOLEAN, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment_overlap_conflicts,{"Message fragment overlapping with conflicting data","wai.fragment.overlap.conflicts",FT_BOOLEAN, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment_multiple_tails,{"Message has multiple tail fragments","wai.fragment.multiple_tails",FT_BOOLEAN, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment_too_long_fragment,{"Message fragment too long", "wai.fragment.too_long_fragment",FT_BOOLEAN, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment_error,{"Message defragmentation error", "wai.fragment.error",FT_FRAMENUM, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_fragment_count,{"Message fragment count", "wai.fragment.count",FT_UINT32, BASE_DEC, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_reassembled_in,{"Reassembled in", "wai.reassembled.in",FT_FRAMENUM, BASE_NONE, NULL, - 0x00, NULL, HFILL }}, - - { &hf_wai_reassembled_length,{"Reassembled length", "wai.reassembled.length",FT_UINT32, BASE_DEC, NULL, - 0x00, NULL, HFILL }} + { &hf_wai_version, + { "Version", "wai.version", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Version of authentication infrastructure", HFILL }}, + + { &hf_wai_type, + { "Type", "wai.type", + FT_UINT8, BASE_HEX, VALS(wai_type_names), 0x0, + "Protocol type", HFILL }}, + + { &hf_wai_subtype, + { "Subtype", "wai.subtype", + FT_UINT8, BASE_DEC|BASE_EXT_STRING, &wai_subtype_names_ext, 0x0, + NULL, HFILL }}, + + { &hf_wai_reserved, + { "Reserved", "wai.reserved", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_length, + { "Length", "wai.length", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_seq, + { "Sequence number", "wai.seq", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Packet sequence number", HFILL }}, + + { &hf_wai_fragm_seq, + { "Fragment sequence number", "wai.fragm.seq", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_flag, + { "Flag", "wai.flag", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_data, + { "Data", "wai.data", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_bk_rekeying_flag, + {"BK rekeying", "wai.bk.rekeying.flag", + FT_BOOLEAN, 8, TFS (&wai_bk_rekeying_flag), FLAG_BIT0, + "BK rekeying flag", HFILL }}, + + { &hf_wai_preauthentication_flag, + {"Pre-Authentication", "wai.preauthentication.flag", + FT_BOOLEAN, 8, TFS (&wai_preauthentication_flag), FLAG_BIT1, + "Pre-Authentication flag", HFILL }}, + + { &hf_wai_certificate_flag, + {"Certificate", "wai.certificate.flag", + FT_BOOLEAN, 8, TFS (&wai_certificate_flag), FLAG_BIT2, + "Certificate flag", HFILL }}, + + { &hf_wai_optional_flag, + {"Optional", "wai.optional.flag", + FT_BOOLEAN, 8, TFS (&wai_optional_flag), FLAG_BIT3, + "Optional flag", HFILL }}, + + { &hf_wai_usk_rekeying_flag, + {"USK rekeying", "wai.usk.rekeying.flag", + FT_BOOLEAN, 8, TFS (&wai_usk_rekeying_flag), FLAG_BIT4, + "USK rekeying flag", HFILL }}, + + { &hf_wai_negotiation_flag, + {"STA negotiation", "wai.negotiation.flag", + FT_BOOLEAN, 8, TFS (&wai_negotiation_flag), FLAG_BIT5, + "STA negotiation flag", HFILL }}, + + { &hf_wai_revoking_flag, + {"STA revoking", "wai.revoking.flag", + FT_BOOLEAN, 8, TFS (&wai_revoking_flag), FLAG_BIT6, + "STA revoking flag", HFILL }}, + + { &hf_wai_reserved_flag, + {"Reserved", "wai.reserved.flag", + FT_BOOLEAN, 8, TFS (&wai_reserved_flag), FLAG_BIT7, + "Reserved flag", HFILL }}, + + { &hf_wai_cert, + {"Certificate", "wai.cert", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_cert_id, + {"Id", "wai.cert.id", + FT_UINT16, BASE_HEX, NULL, 0x0, + "Certificate Id", HFILL }}, + + { &hf_wai_cert_data, + {"Data", "wai.cert.data", + FT_BYTES, BASE_NONE, NULL, 0x0, + "Certificate data", HFILL }}, + + { &hf_wai_cert_len, + {"Length", "wai.cert.len", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Certificate length", HFILL }}, + + { &hf_wai_addid, + {"ADDID", "wai.addid", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_ae_mac, + {"AE MAC", "wai.ae.mac", + FT_ETHER, BASE_NONE, NULL, 0x0, + "AE MAC address", HFILL }}, + + { &hf_wai_asue_mac, + {"ASUE MAC", "wai.asue.mac", + FT_ETHER, BASE_NONE, NULL, 0x0, + "ASUE MAC address", HFILL }}, + + { &hf_wai_bkid, + {"BKID", "wai.bkid", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_uskid, + {"USKID", "wai.uskid", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_wie, + {"WIE from ASUE", "wai.wie", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_message_auth_code, + {"Message Authentication Code", "wai.message.auth.code", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_mskid, + {"MSKID/STAKeyID", "wai.mskid", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_data_pack_num, + {"Data packet number", "wai.data.packet.num", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_key_data, + {"Key Data", "wai.key.data", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_key_data_len, + {"Length", "wai.key.data.len", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Key data length", HFILL }}, + + { &hf_wai_key_data_content, + {"Content", "wai.key.data.content", + FT_BYTES, BASE_NONE, NULL, 0x0, + "Key data content", HFILL }}, + + { &hf_wai_key_ann_id, + {"Key Announcement Identifier", "wai.key.ann.id", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_auth_id, + {"Authentication Identifier", "wai.auth.id", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_identity, + {"Identifier", "wai.identity", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_identity_id, + {"Id", "wai.identity.id", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_identity_len, + {"Length", "wai.identity.len", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Identity length", HFILL }}, + + { &hf_wai_identity_data, + {"Data", "wai.identity.data", + FT_BYTES, BASE_NONE, NULL, 0x0, + "Identity data", HFILL }}, + + { &hf_wai_ecdh, + {"ECDH Parameter", "wai.ecdhp", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_ecdh_id, + {"ID", "wai.edch.id", + FT_UINT8, BASE_HEX, NULL, 0x0, + "ECDH Parameter Identifier", HFILL }}, + + { &hf_wai_ecdh_len, + {"Length", "wai.ecdh.len", + FT_UINT16, BASE_DEC, NULL, 0x0, + "ECDH Parameter Length", HFILL }}, + + { &hf_wai_ecdh_content, + {"Content", "wai.ecdh.content", + FT_BYTES, BASE_NONE, NULL, 0x0, + "ECDH Parameter Content", HFILL }}, + + { &hf_wai_counter, + {"Replay counter", "wai.counter", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_sta_key_id, + {"STAKeyID", "wai.sta.key.id", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_challenge, + {"Challenge", "wai.challenge", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_cert_ver, + {"Multiple Certificate Verification Result", "wai.cert.ver", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_nonce, + {"Nonce", "wai.nonce", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_ver_res, + {"Verification result", "wai.ver.res", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_sign_alg, + {"Signature Algorithm", "wai.sign.alg", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_hash_alg_id, + {"Hash Algorithm Identifier", "wai.hash.alg.id", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_sign_alg_id, + {"Signature Algorithm Identifier", "wai.sign.alg.id", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_param, + {"Parameter", "wai.param", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_param_id, + {"Parameter Identifier", "wai.param.id", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_param_content, + {"Parameter Content", "wai.param.content", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_sign_val, + {"Signature Value", "wai.sign.val", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_sign_content, + {"Signature Content", "wai.sign.content", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_sign, + {"Signature", "wai.sign", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_identity_list, + {"ASU List trusted by ASUE", "wai.identity_list", + FT_BYTES, BASE_NONE, NULL, 0x0, + "Identity list", HFILL }}, + + { &hf_wai_reserved_byte, + {"Reserved", "wai.reserved.byte", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_no_of_ids, + {"Number of Identities", "wai.no.of.ids", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_access_res, + {"Access result", "wai.access_result", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_wai_fragments, + {"Message fragments", "wai.fragments", + FT_NONE, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment, + {"Message fragment", "wai.fragment", + FT_FRAMENUM, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment_overlap, + {"Message fragment overlap", "wai.fragment.overlap", + FT_BOOLEAN, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment_overlap_conflicts, + {"Message fragment overlapping with conflicting data", "wai.fragment.overlap.conflicts", + FT_BOOLEAN, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment_multiple_tails, + {"Message has multiple tail fragments", "wai.fragment.multiple_tails", + FT_BOOLEAN, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment_too_long_fragment, + {"Message fragment too long", "wai.fragment.too_long_fragment", + FT_BOOLEAN, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment_error, + {"Message defragmentation error", "wai.fragment.error", + FT_FRAMENUM, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_fragment_count, + {"Message fragment count", "wai.fragment.count", + FT_UINT32, BASE_DEC, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_reassembled_in, + {"Reassembled in", "wai.reassembled.in", + FT_FRAMENUM, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + { &hf_wai_reassembled_length, + {"Reassembled length", "wai.reassembled.length", + FT_UINT32, BASE_DEC, NULL, 0x00, + NULL, HFILL }} }; static gint *ett[] = { diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c index ca72de33cc..2ff61f0896 100644 --- a/epan/dissectors/packet-xml.c +++ b/epan/dissectors/packet-xml.c @@ -52,8 +52,8 @@ #include "packet-xml.h" struct _attr_reg_data { - GArray* hf; - gchar* basename; + GArray *hf; + gchar *basename; }; @@ -70,1132 +70,1184 @@ static int hf_doctype = -1; static dissector_handle_t xml_handle; /* parser definitions */ -static tvbparse_wanted_t* want; -static tvbparse_wanted_t* want_ignore; -static tvbparse_wanted_t* want_heur; +static tvbparse_wanted_t *want; +static tvbparse_wanted_t *want_ignore; +static tvbparse_wanted_t *want_heur; -static GHashTable* xmpli_names; -static GHashTable* media_types; +static GHashTable *xmpli_names; +static GHashTable *media_types; -static xml_ns_t xml_ns = {"xml","/",-1,-1,-1,NULL,NULL,NULL}; -static xml_ns_t unknown_ns = {"unknown","?",-1,-1,-1,NULL,NULL,NULL}; -static xml_ns_t* root_ns; +static xml_ns_t xml_ns = {"xml", "/", -1, -1, -1, NULL, NULL, NULL}; +static xml_ns_t unknown_ns = {"unknown", "?", -1, -1, -1, NULL, NULL, NULL}; +static xml_ns_t *root_ns; -static gboolean pref_heuristic_media = FALSE; -static gboolean pref_heuristic_tcp = FALSE; -static gboolean pref_heuristic_udp = FALSE; +static gboolean pref_heuristic_media = FALSE; +static gboolean pref_heuristic_tcp = FALSE; +static gboolean pref_heuristic_udp = FALSE; static gboolean pref_heuristic_media_save = FALSE; -static gboolean pref_heuristic_tcp_save = FALSE; -static gboolean pref_heuristic_udp_save = FALSE; +static gboolean pref_heuristic_tcp_save = FALSE; +static gboolean pref_heuristic_udp_save = FALSE; +static gboolean pref_heuristic_unicode = FALSE; + static range_t *global_xml_tcp_range = NULL; -static range_t *xml_tcp_range = NULL; +static range_t *xml_tcp_range = NULL; -static gboolean pref_heuristic_unicode = FALSE; -#define XML_CDATA -1000 +#define XML_CDATA -1000 #define XML_SCOPED_NAME -1001 -static GArray* hf_arr; -static GArray* ett_arr; - -static const gchar* default_media_types[] = { - "text/xml", - "text/vnd.wap.wml", - "text/vnd.wap.si", - "text/vnd.wap.sl", - "text/vnd.wap.co", - "text/vnd.wap.emn", - "application/auth-policy+xml", - "application/ccmp+xml", - "application/cpim-pidf+xml", - "application/cpl+xml", - "application/mathml+xml", - "application/media_control+xml", - "application/note+xml", - "application/pidf+xml", - "application/poc-settings+xml", - "application/rdf+xml", - "application/reginfo+xml", - "application/resource-lists+xml", - "application/rlmi+xml", - "application/rls-services+xml", - "application/rss+xml", - "application/smil", - "application/simple-filter+xml", - "application/simservs+xml", - "application/soap+xml", - "application/vnd.etsi.aoc+xml", - "application/vnd.etsi.cug+xml", - "application/vnd.etsi.iptvcommand+xml", - "application/vnd.etsi.iptvdiscovery+xml", - "application/vnd.etsi.iptvprofile+xml", - "application/vnd.etsi.iptvsad-bc+xml", - "application/vnd.etsi.iptvsad-cod+xml", - "application/vnd.etsi.iptvsad-npvr+xml", - "application/vnd.etsi.iptvueprofile+xml", - "application/vnd.etsi.mcid+xml", - "application/vnd.etsi.sci+xml", - "application/vnd.etsi.simservs+xml", - "application/vnd.3gpp.cw+xml", - "application/vnd.3gpp.SRVCC-info+xml", - "application/vnd.wv.csp+xml", - "application/vnd.wv.csp.xml", - "application/watcherinfo+xml", - "application/xcap-att+xml", - "application/xcap-caps+xml", - "application/xcap-diff+xml", - "application/xcap-el+xml", - "application/xcap-error+xml", - "application/xcap-ns+xml", - "application/xml", - "application/xml-dtd", - "application/xpidf+xml", - "application/xslt+xml", - "application/x-wms-logconnectstats", - "application/x-wms-logplaystats", - "application/x-wms-sendevent", - "image/svg+xml", +static GArray *hf_arr; +static GArray *ett_arr; + +static const gchar *default_media_types[] = { + "text/xml", + "text/vnd.wap.wml", + "text/vnd.wap.si", + "text/vnd.wap.sl", + "text/vnd.wap.co", + "text/vnd.wap.emn", + "application/auth-policy+xml", + "application/ccmp+xml", + "application/cpim-pidf+xml", + "application/cpl+xml", + "application/mathml+xml", + "application/media_control+xml", + "application/note+xml", + "application/pidf+xml", + "application/poc-settings+xml", + "application/rdf+xml", + "application/reginfo+xml", + "application/resource-lists+xml", + "application/rlmi+xml", + "application/rls-services+xml", + "application/rss+xml", + "application/smil", + "application/simple-filter+xml", + "application/simservs+xml", + "application/soap+xml", + "application/vnd.etsi.aoc+xml", + "application/vnd.etsi.cug+xml", + "application/vnd.etsi.iptvcommand+xml", + "application/vnd.etsi.iptvdiscovery+xml", + "application/vnd.etsi.iptvprofile+xml", + "application/vnd.etsi.iptvsad-bc+xml", + "application/vnd.etsi.iptvsad-cod+xml", + "application/vnd.etsi.iptvsad-npvr+xml", + "application/vnd.etsi.iptvueprofile+xml", + "application/vnd.etsi.mcid+xml", + "application/vnd.etsi.sci+xml", + "application/vnd.etsi.simservs+xml", + "application/vnd.3gpp.cw+xml", + "application/vnd.3gpp.SRVCC-info+xml", + "application/vnd.wv.csp+xml", + "application/vnd.wv.csp.xml", + "application/watcherinfo+xml", + "application/xcap-att+xml", + "application/xcap-caps+xml", + "application/xcap-diff+xml", + "application/xcap-el+xml", + "application/xcap-error+xml", + "application/xcap-ns+xml", + "application/xml", + "application/xml-dtd", + "application/xpidf+xml", + "application/xslt+xml", + "application/x-wms-logconnectstats", + "application/x-wms-logplaystats", + "application/x-wms-sendevent", + "image/svg+xml", }; -static void insert_xml_frame(xml_frame_t *parent, xml_frame_t *new_child) { - new_child->first_child = NULL; - new_child->last_child = NULL; - - new_child->parent = parent; - new_child->next_sibling = NULL; - new_child->prev_sibling = NULL; - if (parent == NULL) return; /* root */ - - if (parent->first_child == NULL) { /* the 1st child */ - parent->first_child = new_child; - } else { /* following children */ - parent->last_child->next_sibling = new_child; - new_child->prev_sibling = parent->last_child; - } - parent->last_child = new_child; +static void insert_xml_frame(xml_frame_t *parent, xml_frame_t *new_child) +{ + new_child->first_child = NULL; + new_child->last_child = NULL; + + new_child->parent = parent; + new_child->next_sibling = NULL; + new_child->prev_sibling = NULL; + if (parent == NULL) return; /* root */ + + if (parent->first_child == NULL) { /* the 1st child */ + parent->first_child = new_child; + } else { /* following children */ + parent->last_child->next_sibling = new_child; + new_child->prev_sibling = parent->last_child; + } + parent->last_child = new_child; } static void dissect_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - tvbparse_t* tt; - static GPtrArray* stack = NULL; - xml_frame_t* current_frame; - char* colinfo_str; + tvbparse_t *tt; + static GPtrArray *stack; + xml_frame_t *current_frame; + char *colinfo_str; - if (stack != NULL) - g_ptr_array_free(stack,TRUE); + if (stack != NULL) + g_ptr_array_free(stack, TRUE); - stack = g_ptr_array_new(); - current_frame = ep_alloc(sizeof(xml_frame_t)); - current_frame->type = XML_FRAME_ROOT; - current_frame->name = NULL; - current_frame->name_orig_case = NULL; - current_frame->value = NULL; - insert_xml_frame(NULL, current_frame); - g_ptr_array_add(stack,current_frame); + stack = g_ptr_array_new(); + current_frame = ep_alloc(sizeof(xml_frame_t)); + current_frame->type = XML_FRAME_ROOT; + current_frame->name = NULL; + current_frame->name_orig_case = NULL; + current_frame->value = NULL; + insert_xml_frame(NULL, current_frame); + g_ptr_array_add(stack, current_frame); - tt = tvbparse_init(tvb,0,-1,stack,want_ignore); - current_frame->start_offset = 0; + tt = tvbparse_init(tvb, 0, -1, stack, want_ignore); + current_frame->start_offset = 0; - root_ns = NULL; + root_ns = NULL; - if (pinfo->match_string) - root_ns = g_hash_table_lookup(media_types,pinfo->match_string); + if (pinfo->match_string) + root_ns = g_hash_table_lookup(media_types, pinfo->match_string); - if (! root_ns ) { - root_ns = &xml_ns; - colinfo_str = "/XML"; - } else { - colinfo_str = ep_strdup_printf("/%s",root_ns->name); - ascii_strup_inplace(colinfo_str); - } + if (! root_ns ) { + root_ns = &xml_ns; + colinfo_str = "/XML"; + } else { + colinfo_str = ep_strdup_printf("/%s", root_ns->name); + ascii_strup_inplace(colinfo_str); + } - col_append_str(pinfo->cinfo, COL_PROTOCOL, colinfo_str); + col_append_str(pinfo->cinfo, COL_PROTOCOL, colinfo_str); - current_frame->ns = root_ns; + current_frame->ns = root_ns; - current_frame->item = proto_tree_add_item(tree,current_frame->ns->hf_tag,tvb,0,-1,ENC_UTF_8|ENC_NA); - current_frame->tree = proto_item_add_subtree(current_frame->item,current_frame->ns->ett); - current_frame->last_item = current_frame->item; + current_frame->item = proto_tree_add_item(tree, current_frame->ns->hf_tag, tvb, 0, -1, ENC_UTF_8|ENC_NA); + current_frame->tree = proto_item_add_subtree(current_frame->item, current_frame->ns->ett); + current_frame->last_item = current_frame->item; - while(tvbparse_get(tt, want)) ; + while(tvbparse_get(tt, want)) ; - pinfo->private_data = current_frame; /* pass XML structure to the dissector calling XML */ + pinfo->private_data = current_frame; /* pass XML structure to the dissector calling XML */ } -static gboolean dissect_xml_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - if (tvbparse_peek(tvbparse_init(tvb,0,-1,NULL,want_ignore), want_heur)) { - dissect_xml(tvb, pinfo, tree); - return TRUE; - } else if (pref_heuristic_unicode) { - const guint8 *data = tvb_get_ephemeral_unicode_string(tvb, 0, tvb_length(tvb), ENC_LITTLE_ENDIAN); - tvbuff_t *unicode_tvb = tvb_new_child_real_data(tvb, data, tvb_length(tvb)/2, tvb_length(tvb)/2); - if (tvbparse_peek(tvbparse_init(unicode_tvb,0,-1,NULL,want_ignore), want_heur)) { - add_new_data_source(pinfo, unicode_tvb, "UTF8"); - dissect_xml(unicode_tvb, pinfo, tree); - return TRUE; - } - } - return FALSE; +static gboolean dissect_xml_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +{ + if (tvbparse_peek(tvbparse_init(tvb, 0, -1, NULL, want_ignore), want_heur)) { + dissect_xml(tvb, pinfo, tree); + return TRUE; + } else if (pref_heuristic_unicode) { + const guint8 *data_str = tvb_get_ephemeral_unicode_string(tvb, 0, tvb_length(tvb), ENC_LITTLE_ENDIAN); + tvbuff_t *unicode_tvb = tvb_new_child_real_data(tvb, data_str, tvb_length(tvb)/2, tvb_length(tvb)/2); + if (tvbparse_peek(tvbparse_init(unicode_tvb, 0, -1, NULL, want_ignore), want_heur)) { + add_new_data_source(pinfo, unicode_tvb, "UTF8"); + dissect_xml(unicode_tvb, pinfo, tree); + return TRUE; + } + } + return FALSE; } -xml_frame_t *xml_get_tag(xml_frame_t *frame, const gchar *name) { - xml_frame_t *tag = NULL; - - xml_frame_t *xml_item = frame->first_child; - while (xml_item) { - if (xml_item->type == XML_FRAME_TAG) { - if (!name) { /* get the 1st tag */ - tag = xml_item; - break; - } else if (xml_item->name_orig_case && !strcmp(xml_item->name_orig_case, name)) { - tag = xml_item; - break; - } - } - xml_item = xml_item->next_sibling; - } - - return tag; +xml_frame_t *xml_get_tag(xml_frame_t *frame, const gchar *name) +{ + xml_frame_t *tag = NULL; + + xml_frame_t *xml_item = frame->first_child; + while (xml_item) { + if (xml_item->type == XML_FRAME_TAG) { + if (!name) { /* get the 1st tag */ + tag = xml_item; + break; + } else if (xml_item->name_orig_case && !strcmp(xml_item->name_orig_case, name)) { + tag = xml_item; + break; + } + } + xml_item = xml_item->next_sibling; + } + + return tag; } -xml_frame_t *xml_get_attrib(xml_frame_t *frame, const gchar *name) { - xml_frame_t *attr = NULL; - - xml_frame_t *xml_item = frame->first_child; - while (xml_item) { - if ((xml_item->type == XML_FRAME_ATTRIB) && - xml_item->name_orig_case && !strcmp(xml_item->name_orig_case, name)) { - attr = xml_item; - break; - } - xml_item = xml_item->next_sibling; - } - - return attr; +xml_frame_t *xml_get_attrib(xml_frame_t *frame, const gchar *name) +{ + xml_frame_t *attr = NULL; + + xml_frame_t *xml_item = frame->first_child; + while (xml_item) { + if ((xml_item->type == XML_FRAME_ATTRIB) && + xml_item->name_orig_case && !strcmp(xml_item->name_orig_case, name)) { + attr = xml_item; + break; + } + xml_item = xml_item->next_sibling; + } + + return attr; } -xml_frame_t *xml_get_cdata(xml_frame_t *frame) { - xml_frame_t *cdata = NULL; - - xml_frame_t *xml_item = frame->first_child; - while (xml_item) { - if (xml_item->type == XML_FRAME_CDATA) { - cdata = xml_item; - break; - } - xml_item = xml_item->next_sibling; - } - - return cdata; +xml_frame_t *xml_get_cdata(xml_frame_t *frame) +{ + xml_frame_t *cdata = NULL; + + xml_frame_t *xml_item = frame->first_child; + while (xml_item) { + if (xml_item->type == XML_FRAME_CDATA) { + cdata = xml_item; + break; + } + xml_item = xml_item->next_sibling; + } + + return cdata; } -static void after_token(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - int hfid; - gboolean is_cdata = FALSE; - proto_item* pi; - xml_frame_t* new_frame; - - if (tok->id == XML_CDATA) { - hfid = current_frame->ns ? current_frame->ns->hf_cdata : xml_ns.hf_cdata; - is_cdata = TRUE; - } else if ( tok->id > 0) { - hfid = tok->id; - } else { - hfid = xml_ns.hf_cdata; - } - - pi = proto_tree_add_item(current_frame->tree, hfid, tok->tvb, tok->offset, tok->len, ENC_UTF_8|ENC_NA); - - proto_item_set_text(pi, "%s", - tvb_format_text(tok->tvb,tok->offset,tok->len)); - - if (is_cdata) { - new_frame = ep_alloc(sizeof(xml_frame_t)); - new_frame->type = XML_FRAME_CDATA; - new_frame->name = NULL; - new_frame->name_orig_case = NULL; - new_frame->value = tvb_new_subset(tok->tvb, tok->offset, tok->len, tok->len); - insert_xml_frame(current_frame, new_frame); - new_frame->item = pi; - new_frame->last_item = pi; - new_frame->tree = NULL; - new_frame->start_offset = tok->offset; - new_frame->ns = NULL; - } +static void after_token(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + int hfid; + gboolean is_cdata = FALSE; + proto_item *pi; + xml_frame_t *new_frame; + + if (tok->id == XML_CDATA) { + hfid = current_frame->ns ? current_frame->ns->hf_cdata : xml_ns.hf_cdata; + is_cdata = TRUE; + } else if ( tok->id > 0) { + hfid = tok->id; + } else { + hfid = xml_ns.hf_cdata; + } + + pi = proto_tree_add_item(current_frame->tree, hfid, tok->tvb, tok->offset, tok->len, ENC_UTF_8|ENC_NA); + + proto_item_set_text(pi, "%s", + tvb_format_text(tok->tvb, tok->offset, tok->len)); + + if (is_cdata) { + new_frame = ep_alloc(sizeof(xml_frame_t)); + new_frame->type = XML_FRAME_CDATA; + new_frame->name = NULL; + new_frame->name_orig_case = NULL; + new_frame->value = tvb_new_subset(tok->tvb, tok->offset, tok->len, tok->len); + insert_xml_frame(current_frame, new_frame); + new_frame->item = pi; + new_frame->last_item = pi; + new_frame->tree = NULL; + new_frame->start_offset = tok->offset; + new_frame->ns = NULL; + } } -static void before_xmpli(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - proto_item* pi; - proto_tree* pt; - tvbparse_elem_t* name_tok = tok->sub->next; - gchar* name = tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len); - xml_ns_t* ns = g_hash_table_lookup(xmpli_names,name); - xml_frame_t* new_frame; - - int hf_tag; - gint ett; - - ascii_strdown_inplace(name); - if (!ns) { - hf_tag = hf_xmlpi; - ett = ett_xmpli; - } else { - hf_tag = ns->hf_tag; - ett = ns->ett; - } - - pi = proto_tree_add_item(current_frame->tree,hf_tag,tok->tvb,tok->offset,tok->len,ENC_UTF_8|ENC_NA); - - proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len)); - - pt = proto_item_add_subtree(pi,ett); - - new_frame = ep_alloc(sizeof(xml_frame_t)); - new_frame->type = XML_FRAME_XMPLI; - new_frame->name = name; - new_frame->name_orig_case = name; - new_frame->value = NULL; - insert_xml_frame(current_frame, new_frame); - new_frame->item = pi; - new_frame->last_item = pi; - new_frame->tree = pt; - new_frame->start_offset = tok->offset; - new_frame->ns = ns; - - g_ptr_array_add(stack,new_frame); +static void before_xmpli(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + proto_item *pi; + proto_tree *pt; + tvbparse_elem_t *name_tok = tok->sub->next; + gchar *name = tvb_get_ephemeral_string(name_tok->tvb, name_tok->offset, name_tok->len); + xml_ns_t *ns = g_hash_table_lookup(xmpli_names, name); + xml_frame_t *new_frame; + + int hf_tag; + gint ett; + + ascii_strdown_inplace(name); + if (!ns) { + hf_tag = hf_xmlpi; + ett = ett_xmpli; + } else { + hf_tag = ns->hf_tag; + ett = ns->ett; + } + + pi = proto_tree_add_item(current_frame->tree, hf_tag, tok->tvb, tok->offset, tok->len, ENC_UTF_8|ENC_NA); + + proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb, tok->offset, (name_tok->offset - tok->offset) + name_tok->len)); + + pt = proto_item_add_subtree(pi, ett); + + new_frame = ep_alloc(sizeof(xml_frame_t)); + new_frame->type = XML_FRAME_XMPLI; + new_frame->name = name; + new_frame->name_orig_case = name; + new_frame->value = NULL; + insert_xml_frame(current_frame, new_frame); + new_frame->item = pi; + new_frame->last_item = pi; + new_frame->tree = pt; + new_frame->start_offset = tok->offset; + new_frame->ns = ns; + + g_ptr_array_add(stack, new_frame); } -static void after_xmlpi(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - - proto_tree_add_text(current_frame->tree, - tok->tvb, tok->offset, tok->len, "%s", - tvb_format_text(tok->tvb,tok->offset,tok->len)); - - if (stack->len > 1) { - g_ptr_array_remove_index_fast(stack,stack->len - 1); - } else { - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"[ ERROR: Closing an unopened xmpli tag ]"); - } +static void after_xmlpi(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + + proto_tree_add_text(current_frame->tree, + tok->tvb, tok->offset, tok->len, "%s", + tvb_format_text(tok->tvb, tok->offset, tok->len)); + + if (stack->len > 1) { + g_ptr_array_remove_index_fast(stack, stack->len - 1); + } else { + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, + "[ ERROR: Closing an unopened xmpli tag ]"); + } } -static void before_tag(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - tvbparse_elem_t* name_tok = tok->sub->next; - gchar* root_name; - gchar *name = NULL, *name_orig_case = NULL; - xml_ns_t* ns; - xml_frame_t* new_frame; - proto_item* pi; - proto_tree* pt; - - if (name_tok->sub->id == XML_SCOPED_NAME) { - tvbparse_elem_t* root_tok = name_tok->sub->sub; - tvbparse_elem_t* leaf_tok = name_tok->sub->sub->next->next; - xml_ns_t* nameroot_ns; - - root_name = (gchar*)tvb_get_ephemeral_string(root_tok->tvb,root_tok->offset,root_tok->len); - name = (gchar*)tvb_get_ephemeral_string(leaf_tok->tvb,leaf_tok->offset,leaf_tok->len); - name_orig_case = name; - - nameroot_ns = g_hash_table_lookup(xml_ns.elements,root_name); - - if(nameroot_ns) { - ns = g_hash_table_lookup(nameroot_ns->elements,name); - if (!ns) { - ns = &unknown_ns; - } - } else { - ns = &unknown_ns; - } - - } else { - name = tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len); - name_orig_case = ep_strdup(name); - ascii_strdown_inplace(name); - - if(current_frame->ns) { - ns = g_hash_table_lookup(current_frame->ns->elements,name); - - if (!ns) { - if (! ( ns = g_hash_table_lookup(root_ns->elements,name) ) ) { - ns = &unknown_ns; - } - } - } else { - ns = &unknown_ns; - } - } - - pi = proto_tree_add_item(current_frame->tree,ns->hf_tag,tok->tvb,tok->offset,tok->len,ENC_UTF_8|ENC_NA); - proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,(name_tok->offset - tok->offset) + name_tok->len)); - - pt = proto_item_add_subtree(pi,ns->ett); - - new_frame = ep_alloc(sizeof(xml_frame_t)); - new_frame->type = XML_FRAME_TAG; - new_frame->name = name; - new_frame->name_orig_case = name_orig_case; - new_frame->value = NULL; - insert_xml_frame(current_frame, new_frame); - new_frame->item = pi; - new_frame->last_item = pi; - new_frame->tree = pt; - new_frame->start_offset = tok->offset; - new_frame->ns = ns; - - g_ptr_array_add(stack,new_frame); +static void before_tag(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + tvbparse_elem_t *name_tok = tok->sub->next; + gchar *root_name; + gchar *name = NULL, *name_orig_case = NULL; + xml_ns_t *ns; + xml_frame_t *new_frame; + proto_item *pi; + proto_tree *pt; + + if (name_tok->sub->id == XML_SCOPED_NAME) { + tvbparse_elem_t *root_tok = name_tok->sub->sub; + tvbparse_elem_t *leaf_tok = name_tok->sub->sub->next->next; + xml_ns_t *nameroot_ns; + + root_name = (gchar *)tvb_get_ephemeral_string(root_tok->tvb, root_tok->offset, root_tok->len); + name = (gchar *)tvb_get_ephemeral_string(leaf_tok->tvb, leaf_tok->offset, leaf_tok->len); + name_orig_case = name; + + nameroot_ns = g_hash_table_lookup(xml_ns.elements, root_name); + + if(nameroot_ns) { + ns = g_hash_table_lookup(nameroot_ns->elements, name); + if (!ns) { + ns = &unknown_ns; + } + } else { + ns = &unknown_ns; + } + + } else { + name = tvb_get_ephemeral_string(name_tok->tvb, name_tok->offset, name_tok->len); + name_orig_case = ep_strdup(name); + ascii_strdown_inplace(name); + + if(current_frame->ns) { + ns = g_hash_table_lookup(current_frame->ns->elements, name); + + if (!ns) { + if (! ( ns = g_hash_table_lookup(root_ns->elements, name) ) ) { + ns = &unknown_ns; + } + } + } else { + ns = &unknown_ns; + } + } + + pi = proto_tree_add_item(current_frame->tree, ns->hf_tag, tok->tvb, tok->offset, tok->len, ENC_UTF_8|ENC_NA); + proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb, + tok->offset, + (name_tok->offset - tok->offset) + name_tok->len)); + + pt = proto_item_add_subtree(pi, ns->ett); + + new_frame = ep_alloc(sizeof(xml_frame_t)); + new_frame->type = XML_FRAME_TAG; + new_frame->name = name; + new_frame->name_orig_case = name_orig_case; + new_frame->value = NULL; + insert_xml_frame(current_frame, new_frame); + new_frame->item = pi; + new_frame->last_item = pi; + new_frame->tree = pt; + new_frame->start_offset = tok->offset; + new_frame->ns = ns; + + g_ptr_array_add(stack, new_frame); } -static void after_open_tag(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok _U_) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); +static void after_open_tag(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok _U_) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); - proto_item_append_text(current_frame->last_item,">"); + proto_item_append_text(current_frame->last_item, ">"); } -static void after_closed_tag(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); +static void after_closed_tag(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); - proto_item_append_text(current_frame->last_item,"/>"); + proto_item_append_text(current_frame->last_item, "/>"); - if (stack->len > 1) { - g_ptr_array_remove_index_fast(stack,stack->len - 1); - } else { - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"[ ERROR: Closing an unopened tag ]"); - } + if (stack->len > 1) { + g_ptr_array_remove_index_fast(stack, stack->len - 1); + } else { + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, "[ ERROR: Closing an unopened tag ]"); + } } -static void after_untag(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok){ - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); +static void after_untag(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); - proto_item_set_len(current_frame->item, (tok->offset - current_frame->start_offset) + tok->len); + proto_item_set_len(current_frame->item, (tok->offset - current_frame->start_offset) + tok->len); - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"%s", - tvb_format_text(tok->tvb,tok->offset,tok->len)); + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, "%s", + tvb_format_text(tok->tvb, tok->offset, tok->len)); - if (stack->len > 1) { - g_ptr_array_remove_index_fast(stack,stack->len - 1); - } else { - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len, - "[ ERROR: Closing an unopened tag ]"); - } + if (stack->len > 1) { + g_ptr_array_remove_index_fast(stack, stack->len - 1); + } else { + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, + "[ ERROR: Closing an unopened tag ]"); + } } -static void before_dtd_doctype(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok){ - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - xml_frame_t* new_frame; - tvbparse_elem_t* name_tok = tok->sub->next->next->next->sub->sub; - proto_tree* dtd_item = proto_tree_add_item(current_frame->tree, hf_doctype, - name_tok->tvb, name_tok->offset, name_tok->len, ENC_ASCII|ENC_NA); - - proto_item_set_text(dtd_item,"%s",tvb_format_text(tok->tvb,tok->offset,tok->len)); - - new_frame = ep_alloc(sizeof(xml_frame_t)); - new_frame->type = XML_FRAME_DTD_DOCTYPE; - new_frame->name = (gchar*)tvb_get_ephemeral_string(name_tok->tvb,name_tok->offset,name_tok->len); - new_frame->name_orig_case = new_frame->name; - new_frame->value = NULL; - insert_xml_frame(current_frame, new_frame); - new_frame->item = dtd_item; - new_frame->last_item = dtd_item; - new_frame->tree = proto_item_add_subtree(dtd_item,ett_dtd); - new_frame->start_offset = tok->offset; - new_frame->ns = NULL; - - g_ptr_array_add(stack,new_frame); +static void before_dtd_doctype(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + xml_frame_t *new_frame; + tvbparse_elem_t *name_tok = tok->sub->next->next->next->sub->sub; + proto_tree *dtd_item = proto_tree_add_item(current_frame->tree, hf_doctype, + name_tok->tvb, name_tok->offset, + name_tok->len, ENC_ASCII|ENC_NA); + + proto_item_set_text(dtd_item, "%s", tvb_format_text(tok->tvb, tok->offset, tok->len)); + + new_frame = ep_alloc(sizeof(xml_frame_t)); + new_frame->type = XML_FRAME_DTD_DOCTYPE; + new_frame->name = (gchar *)tvb_get_ephemeral_string(name_tok->tvb, + name_tok->offset, + name_tok->len); + new_frame->name_orig_case = new_frame->name; + new_frame->value = NULL; + insert_xml_frame(current_frame, new_frame); + new_frame->item = dtd_item; + new_frame->last_item = dtd_item; + new_frame->tree = proto_item_add_subtree(dtd_item, ett_dtd); + new_frame->start_offset = tok->offset; + new_frame->ns = NULL; + + g_ptr_array_add(stack, new_frame); } -static void pop_stack(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok _U_) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - - if (stack->len > 1) { - g_ptr_array_remove_index_fast(stack,stack->len - 1); - } else { - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len, - "[ ERROR: Closing an unopened tag ]"); - } +static void pop_stack(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok _U_) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + + if (stack->len > 1) { + g_ptr_array_remove_index_fast(stack, stack->len - 1); + } else { + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, + "[ ERROR: Closing an unopened tag ]"); + } } -static void after_dtd_close(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok){ - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"%s", - tvb_format_text(tok->tvb,tok->offset,tok->len)); - if (stack->len > 1) { - g_ptr_array_remove_index_fast(stack,stack->len - 1); - } else { - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"[ ERROR: Closing an unopened tag ]"); - } +static void after_dtd_close(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, "%s", + tvb_format_text(tok->tvb, tok->offset, tok->len)); + if (stack->len > 1) { + g_ptr_array_remove_index_fast(stack, stack->len - 1); + } else { + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, "[ ERROR: Closing an unopened tag ]"); + } } -static void get_attrib_value(void* tvbparse_data _U_, const void* wanted_data _U_, tvbparse_elem_t* tok) { - tok->data = tok->sub; +static void get_attrib_value(void *tvbparse_data _U_, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + tok->data = tok->sub; } -static void after_attrib(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok) { - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); - gchar *name = NULL, *name_orig_case = NULL; - tvbparse_elem_t* value; - tvbparse_elem_t* value_part = tok->sub->next->next->data; - int* hfidp; - int hfid; - proto_item* pi; - xml_frame_t* new_frame; - - name = tvb_get_ephemeral_string(tok->sub->tvb,tok->sub->offset,tok->sub->len); - name_orig_case = ep_strdup(name); - ascii_strdown_inplace(name); - - if(current_frame->ns && (hfidp = g_hash_table_lookup(current_frame->ns->attributes,name) )) { - hfid = *hfidp; - value = value_part; - } else { - hfid = hf_unknowwn_attrib; - value = tok; - } - - pi = proto_tree_add_item(current_frame->tree,hfid,value->tvb,value->offset,value->len,ENC_UTF_8|ENC_NA); - proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb,tok->offset,tok->len)); - - current_frame->last_item = pi; - - new_frame = ep_alloc(sizeof(xml_frame_t)); - new_frame->type = XML_FRAME_ATTRIB; - new_frame->name = name; - new_frame->name_orig_case = name_orig_case; - new_frame->value = tvb_new_subset(value_part->tvb, value_part->offset, value_part->len, value_part->len); - insert_xml_frame(current_frame, new_frame); - new_frame->item = pi; - new_frame->last_item = pi; - new_frame->tree = NULL; - new_frame->start_offset = tok->offset; - new_frame->ns = NULL; +static void after_attrib(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); + gchar *name, *name_orig_case; + tvbparse_elem_t *value; + tvbparse_elem_t *value_part = tok->sub->next->next->data; + int *hfidp; + int hfid; + proto_item *pi; + xml_frame_t *new_frame; + + name = tvb_get_ephemeral_string(tok->sub->tvb, tok->sub->offset, tok->sub->len); + name_orig_case = ep_strdup(name); + ascii_strdown_inplace(name); + + if(current_frame->ns && (hfidp = g_hash_table_lookup(current_frame->ns->attributes, name) )) { + hfid = *hfidp; + value = value_part; + } else { + hfid = hf_unknowwn_attrib; + value = tok; + } + + pi = proto_tree_add_item(current_frame->tree, hfid, value->tvb, value->offset, value->len, ENC_UTF_8|ENC_NA); + proto_item_set_text(pi, "%s", tvb_format_text(tok->tvb, tok->offset, tok->len)); + + current_frame->last_item = pi; + + new_frame = ep_alloc(sizeof(xml_frame_t)); + new_frame->type = XML_FRAME_ATTRIB; + new_frame->name = name; + new_frame->name_orig_case = name_orig_case; + new_frame->value = tvb_new_subset(value_part->tvb, value_part->offset, + value_part->len, value_part->len); + insert_xml_frame(current_frame, new_frame); + new_frame->item = pi; + new_frame->last_item = pi; + new_frame->tree = NULL; + new_frame->start_offset = tok->offset; + new_frame->ns = NULL; } -static void unrecognized_token(void* tvbparse_data, const void* wanted_data _U_, tvbparse_elem_t* tok _U_){ - GPtrArray* stack = tvbparse_data; - xml_frame_t* current_frame = g_ptr_array_index(stack,stack->len - 1); +static void unrecognized_token(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *tok _U_) +{ + GPtrArray *stack = tvbparse_data; + xml_frame_t *current_frame = g_ptr_array_index(stack, stack->len - 1); - proto_tree_add_text(current_frame->tree,tok->tvb,tok->offset,tok->len,"[ ERROR: Unrecognized text ]"); + proto_tree_add_text(current_frame->tree, tok->tvb, tok->offset, tok->len, "[ ERROR: Unrecognized text ]"); } -static void init_xml_parser(void) { - tvbparse_wanted_t* want_name = tvbparse_chars(-1,1,0,"abcdefghijklmnopqrstuvwxyz.-_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",NULL,NULL,NULL); - tvbparse_wanted_t* want_attr_name = tvbparse_chars(-1,1,0,"abcdefghijklmnopqrstuvwxyz.-_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:",NULL,NULL,NULL); - - tvbparse_wanted_t* want_scoped_name = tvbparse_set_seq(XML_SCOPED_NAME, NULL, NULL, NULL, - want_name, - tvbparse_char(-1,":",NULL,NULL,NULL), - want_name, - NULL); - - tvbparse_wanted_t* want_tag_name = tvbparse_set_oneof(0, NULL, NULL, NULL, - want_scoped_name, - want_name, - NULL); - - tvbparse_wanted_t* want_attrib_value = tvbparse_set_oneof(0, NULL, NULL, get_attrib_value, - tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb,'\"','\\'), - tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb,'\'','\\'), - tvbparse_chars(-1,1,0,"0123456789",NULL,NULL,NULL), - want_name, - NULL); - - tvbparse_wanted_t* want_attributes = tvbparse_one_or_more(-1, NULL, NULL, NULL, - tvbparse_set_seq(-1, NULL, NULL, after_attrib, - want_attr_name, - tvbparse_char(-1,"=",NULL,NULL,NULL), - want_attrib_value, - NULL)); - - tvbparse_wanted_t* want_stoptag = tvbparse_set_oneof(-1,NULL,NULL,NULL, - tvbparse_char(-1, ">", NULL, NULL, after_open_tag), - tvbparse_string(-1, "/>", NULL, NULL, after_closed_tag), - NULL); - - tvbparse_wanted_t* want_stopxmlpi = tvbparse_string(-1,"?>",NULL,NULL,after_xmlpi); - - tvbparse_wanted_t* want_comment = tvbparse_set_seq(hf_comment,NULL,NULL,after_token, - tvbparse_string(-1,"<!--",NULL,NULL,NULL), - tvbparse_until(-1,NULL,NULL,NULL, - tvbparse_string(-1,"-->",NULL,NULL,NULL), - TP_UNTIL_INCLUDE), - NULL); - - tvbparse_wanted_t* want_xmlpi = tvbparse_set_seq(hf_xmlpi,NULL,before_xmpli,NULL, - tvbparse_string(-1,"<?",NULL,NULL,NULL), - want_name, - tvbparse_set_oneof(-1,NULL,NULL,NULL, - want_stopxmlpi, - tvbparse_set_seq(-1,NULL,NULL,NULL, - want_attributes, - want_stopxmlpi, - NULL), - NULL), - NULL); - - tvbparse_wanted_t* want_closing_tag = tvbparse_set_seq(0,NULL,NULL,after_untag, - tvbparse_char(-1, "<", NULL, NULL, NULL), - tvbparse_char(-1, "/", NULL, NULL, NULL), - want_tag_name, - tvbparse_char(-1, ">", NULL, NULL, NULL), - NULL); - - tvbparse_wanted_t* want_doctype_start = tvbparse_set_seq(-1,NULL,before_dtd_doctype,NULL, - tvbparse_char(-1,"<",NULL,NULL,NULL), - tvbparse_char(-1,"!",NULL,NULL,NULL), - tvbparse_casestring(-1,"DOCTYPE",NULL,NULL,NULL), - tvbparse_set_oneof(-1,NULL,NULL,NULL, - tvbparse_set_seq(-1,NULL,NULL,NULL, - want_name, - tvbparse_char(-1,"[",NULL,NULL,NULL), - NULL), - tvbparse_set_seq(-1,NULL,NULL,pop_stack, - want_name, - tvbparse_set_oneof(-1,NULL,NULL,NULL, - tvbparse_casestring(-1,"PUBLIC",NULL,NULL,NULL), - tvbparse_casestring(-1,"SYSTEM",NULL,NULL,NULL), - NULL), - tvbparse_until(-1,NULL,NULL,NULL, - tvbparse_char(-1,">",NULL,NULL,NULL), - TP_UNTIL_INCLUDE), - NULL), - NULL), - NULL); - - tvbparse_wanted_t* want_dtd_tag = tvbparse_set_seq(hf_dtd_tag,NULL,NULL,after_token, - tvbparse_char(-1,"<",NULL,NULL,NULL), - tvbparse_char(-1,"!",NULL,NULL,NULL), - tvbparse_until(-1,NULL,NULL,NULL, - tvbparse_char(-1, ">", NULL, NULL, NULL), - TP_UNTIL_INCLUDE), - NULL); - - tvbparse_wanted_t* want_tag = tvbparse_set_seq(-1, NULL, before_tag, NULL, - tvbparse_char(-1,"<",NULL,NULL,NULL), - want_tag_name, - tvbparse_set_oneof(-1,NULL,NULL,NULL, - tvbparse_set_seq(-1,NULL,NULL,NULL, - want_attributes, - want_stoptag, - NULL), - want_stoptag, - NULL), - NULL); - - tvbparse_wanted_t* want_dtd_close = tvbparse_set_seq(-1,NULL,NULL,after_dtd_close, - tvbparse_char(-1,"]",NULL,NULL,NULL), - tvbparse_char(-1,">",NULL,NULL,NULL), - NULL); - - want_ignore = tvbparse_chars(-1,1,0," \t\r\n",NULL,NULL,NULL); - - - want = tvbparse_set_oneof(-1, NULL, NULL, NULL, - want_comment, - want_xmlpi, - want_closing_tag, - want_doctype_start, - want_dtd_close, - want_dtd_tag, - want_tag, - tvbparse_not_chars(XML_CDATA,1,0,"<",NULL,NULL,after_token), - tvbparse_not_chars(-1,1,0," \t\r\n",NULL,NULL,unrecognized_token), - NULL); - - want_heur = tvbparse_set_oneof(-1, NULL, NULL, NULL, - want_comment, - want_xmlpi, - want_doctype_start, - want_dtd_tag, - want_tag, - NULL); +static void init_xml_parser(void) +{ + tvbparse_wanted_t *want_name = + tvbparse_chars(-1, 1, 0, + "abcdefghijklmnopqrstuvwxyz.-_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", + NULL, NULL, NULL); + tvbparse_wanted_t *want_attr_name = + tvbparse_chars(-1, 1, 0, + "abcdefghijklmnopqrstuvwxyz.-_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:", + NULL, NULL, NULL); + + tvbparse_wanted_t *want_scoped_name = tvbparse_set_seq(XML_SCOPED_NAME, NULL, NULL, NULL, + want_name, + tvbparse_char(-1, ":", NULL, NULL, NULL), + want_name, + NULL); + + tvbparse_wanted_t *want_tag_name = tvbparse_set_oneof(0, NULL, NULL, NULL, + want_scoped_name, + want_name, + NULL); + + tvbparse_wanted_t *want_attrib_value = tvbparse_set_oneof(0, NULL, NULL, get_attrib_value, + tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb, '\"', '\\'), + tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb, '\'', '\\'), + tvbparse_chars(-1, 1, 0, "0123456789", NULL, NULL, NULL), + want_name, + NULL); + + tvbparse_wanted_t *want_attributes = tvbparse_one_or_more(-1, NULL, NULL, NULL, + tvbparse_set_seq(-1, NULL, NULL, after_attrib, + want_attr_name, + tvbparse_char(-1, "=", NULL, NULL, NULL), + want_attrib_value, + NULL)); + + tvbparse_wanted_t *want_stoptag = tvbparse_set_oneof(-1, NULL, NULL, NULL, + tvbparse_char(-1, ">", NULL, NULL, after_open_tag), + tvbparse_string(-1, "/>", NULL, NULL, after_closed_tag), + NULL); + + tvbparse_wanted_t *want_stopxmlpi = tvbparse_string(-1, "?>", NULL, NULL, after_xmlpi); + + tvbparse_wanted_t *want_comment = tvbparse_set_seq(hf_comment, NULL, NULL, after_token, + tvbparse_string(-1, "<!--", NULL, NULL, NULL), + tvbparse_until(-1, NULL, NULL, NULL, + tvbparse_string(-1, "-->", NULL, NULL, NULL), + TP_UNTIL_INCLUDE), + NULL); + + tvbparse_wanted_t *want_xmlpi = tvbparse_set_seq(hf_xmlpi, NULL, before_xmpli, NULL, + tvbparse_string(-1, "<?", NULL, NULL, NULL), + want_name, + tvbparse_set_oneof(-1, NULL, NULL, NULL, + want_stopxmlpi, + tvbparse_set_seq(-1, NULL, NULL, NULL, + want_attributes, + want_stopxmlpi, + NULL), + NULL), + NULL); + + tvbparse_wanted_t *want_closing_tag = tvbparse_set_seq(0, NULL, NULL, after_untag, + tvbparse_char(-1, "<", NULL, NULL, NULL), + tvbparse_char(-1, "/", NULL, NULL, NULL), + want_tag_name, + tvbparse_char(-1, ">", NULL, NULL, NULL), + NULL); + + tvbparse_wanted_t *want_doctype_start = tvbparse_set_seq(-1, NULL, before_dtd_doctype, NULL, + tvbparse_char(-1, "<", NULL, NULL, NULL), + tvbparse_char(-1, "!", NULL, NULL, NULL), + tvbparse_casestring(-1, "DOCTYPE", NULL, NULL, NULL), + tvbparse_set_oneof(-1, NULL, NULL, NULL, + tvbparse_set_seq(-1, NULL, NULL, NULL, + want_name, + tvbparse_char(-1, "[", NULL, NULL, NULL), + NULL), + tvbparse_set_seq(-1, NULL, NULL, pop_stack, + want_name, + tvbparse_set_oneof(-1, NULL, NULL, NULL, + tvbparse_casestring(-1, "PUBLIC", NULL, NULL, NULL), + tvbparse_casestring(-1, "SYSTEM", NULL, NULL, NULL), + NULL), + tvbparse_until(-1, NULL, NULL, NULL, + tvbparse_char(-1, ">", NULL, NULL, NULL), + TP_UNTIL_INCLUDE), + NULL), + NULL), + NULL); + + tvbparse_wanted_t *want_dtd_tag = tvbparse_set_seq(hf_dtd_tag, NULL, NULL, after_token, + tvbparse_char(-1, "<", NULL, NULL, NULL), + tvbparse_char(-1, "!", NULL, NULL, NULL), + tvbparse_until(-1, NULL, NULL, NULL, + tvbparse_char(-1, ">", NULL, NULL, NULL), + TP_UNTIL_INCLUDE), + NULL); + + tvbparse_wanted_t *want_tag = tvbparse_set_seq(-1, NULL, before_tag, NULL, + tvbparse_char(-1, "<", NULL, NULL, NULL), + want_tag_name, + tvbparse_set_oneof(-1, NULL, NULL, NULL, + tvbparse_set_seq(-1, NULL, NULL, NULL, + want_attributes, + want_stoptag, + NULL), + want_stoptag, + NULL), + NULL); + + tvbparse_wanted_t *want_dtd_close = tvbparse_set_seq(-1, NULL, NULL, after_dtd_close, + tvbparse_char(-1, "]", NULL, NULL, NULL), + tvbparse_char(-1, ">", NULL, NULL, NULL), + NULL); + + want_ignore = tvbparse_chars(-1, 1, 0, " \t\r\n", NULL, NULL, NULL); + + + want = tvbparse_set_oneof(-1, NULL, NULL, NULL, + want_comment, + want_xmlpi, + want_closing_tag, + want_doctype_start, + want_dtd_close, + want_dtd_tag, + want_tag, + tvbparse_not_chars(XML_CDATA, 1, 0, "<", NULL, NULL, after_token), + tvbparse_not_chars(-1, 1, 0, " \t\r\n", NULL, NULL, unrecognized_token), + NULL); + + want_heur = tvbparse_set_oneof(-1, NULL, NULL, NULL, + want_comment, + want_xmlpi, + want_doctype_start, + want_dtd_tag, + want_tag, + NULL); } -static xml_ns_t* xml_new_namespace(GHashTable* hash, gchar* name, ...) { - xml_ns_t* ns = g_malloc(sizeof(xml_ns_t)); - va_list ap; - gchar* attr_name; - - ns->name = g_strdup(name); - ns->hf_tag = -1; - ns->hf_cdata = -1; - ns->ett = -1; - ns->attributes = g_hash_table_new(g_str_hash,g_str_equal); - ns->elements = g_hash_table_new(g_str_hash,g_str_equal); - - va_start(ap,name); - - while(( attr_name = va_arg(ap,gchar*) )) { - int* hfp = g_malloc(sizeof(int)); - *hfp = -1; - g_hash_table_insert(ns->attributes,g_strdup(attr_name),hfp); - }; +static xml_ns_t *xml_new_namespace(GHashTable *hash, gchar *name, ...) +{ + xml_ns_t *ns = g_malloc(sizeof(xml_ns_t)); + va_list ap; + gchar *attr_name; + + ns->name = g_strdup(name); + ns->hf_tag = -1; + ns->hf_cdata = -1; + ns->ett = -1; + ns->attributes = g_hash_table_new(g_str_hash, g_str_equal); + ns->elements = g_hash_table_new(g_str_hash, g_str_equal); + + va_start(ap, name); + + while(( attr_name = va_arg(ap, gchar *) )) { + int *hfp = g_malloc(sizeof(int)); + *hfp = -1; + g_hash_table_insert(ns->attributes, g_strdup(attr_name), hfp); + }; - va_end(ap); + va_end(ap); - g_hash_table_insert(hash,ns->name,ns); + g_hash_table_insert(hash, ns->name, ns); - return ns; + return ns; } -static void add_xml_field(GArray* hfs, int* p_id, gchar* name, gchar* fqn) { - hf_register_info hfri; - - hfri.p_id = p_id; - hfri.hfinfo.name = name; - hfri.hfinfo.abbrev = fqn; - hfri.hfinfo.type = FT_STRING; - hfri.hfinfo.display = BASE_NONE; - hfri.hfinfo.strings = NULL; - hfri.hfinfo.bitmask = 0x0; - hfri.hfinfo.blurb = NULL; - hfri.hfinfo.id = 0; - hfri.hfinfo.parent = 0; - hfri.hfinfo.ref_type = HF_REF_TYPE_NONE; - hfri.hfinfo.bitshift = 0; - hfri.hfinfo.same_name_next = NULL; - hfri.hfinfo.same_name_prev = NULL; - - g_array_append_val(hfs,hfri); +static void add_xml_field(GArray *hfs, int *p_id, gchar *name, gchar *fqn) +{ + hf_register_info hfri; + + hfri.p_id = p_id; + hfri.hfinfo.name = name; + hfri.hfinfo.abbrev = fqn; + hfri.hfinfo.type = FT_STRING; + hfri.hfinfo.display = BASE_NONE; + hfri.hfinfo.strings = NULL; + hfri.hfinfo.bitmask = 0x0; + hfri.hfinfo.blurb = NULL; + hfri.hfinfo.id = 0; + hfri.hfinfo.parent = 0; + hfri.hfinfo.ref_type = HF_REF_TYPE_NONE; + hfri.hfinfo.bitshift = 0; + hfri.hfinfo.same_name_next = NULL; + hfri.hfinfo.same_name_prev = NULL; + + g_array_append_val(hfs, hfri); } -static void add_xml_attribute_names(gpointer k, gpointer v, gpointer p) { - struct _attr_reg_data* d = p; - gchar* basename = g_strdup_printf("%s.%s",d->basename,(gchar*)k); - add_xml_field(d->hf, (int*) v, (gchar*)k, basename); +static void add_xml_attribute_names(gpointer k, gpointer v, gpointer p) +{ + struct _attr_reg_data *d = p; + gchar *basename = g_strdup_printf("%s.%s", d->basename, (gchar *)k); + + add_xml_field(d->hf, (int*) v, (gchar *)k, basename); } -static void add_xmlpi_namespace(gpointer k _U_, gpointer v, gpointer p) { - xml_ns_t* ns = v; - gchar* basename = g_strdup_printf("%s.%s",(gchar*)p,ns->name); - gint* ett_p = &(ns->ett); - struct _attr_reg_data d; +static void add_xmlpi_namespace(gpointer k _U_, gpointer v, gpointer p) +{ + xml_ns_t *ns = v; + gchar *basename = g_strdup_printf("%s.%s", (gchar *)p, ns->name); + gint *ett_p = &(ns->ett); + struct _attr_reg_data d; - add_xml_field(hf_arr, &(ns->hf_tag), basename, basename); + add_xml_field(hf_arr, &(ns->hf_tag), basename, basename); - g_array_append_val(ett_arr,ett_p); + g_array_append_val(ett_arr, ett_p); - d.basename = basename; - d.hf = hf_arr; + d.basename = basename; + d.hf = hf_arr; - g_hash_table_foreach(ns->attributes,add_xml_attribute_names,&d); + g_hash_table_foreach(ns->attributes, add_xml_attribute_names, &d); } -static void destroy_dtd_data(dtd_build_data_t* dtd_data) { - g_free(dtd_data->proto_name); - g_free(dtd_data->media_type); - g_free(dtd_data->description); - g_free(dtd_data->proto_root); +static void destroy_dtd_data(dtd_build_data_t *dtd_data) +{ + g_free(dtd_data->proto_name); + g_free(dtd_data->media_type); + g_free(dtd_data->description); + g_free(dtd_data->proto_root); - g_string_free(dtd_data->error,TRUE); + g_string_free(dtd_data->error, TRUE); - while(dtd_data->elements->len) { - dtd_named_list_t* nl = g_ptr_array_remove_index_fast(dtd_data->elements,0); - g_ptr_array_free(nl->list,TRUE); - g_free(nl); - } + while(dtd_data->elements->len) { + dtd_named_list_t *nl = g_ptr_array_remove_index_fast(dtd_data->elements, 0); + g_ptr_array_free(nl->list, TRUE); + g_free(nl); + } - g_ptr_array_free(dtd_data->elements,TRUE); + g_ptr_array_free(dtd_data->elements, TRUE); - while(dtd_data->attributes->len) { - dtd_named_list_t* nl = g_ptr_array_remove_index_fast(dtd_data->attributes,0); - g_ptr_array_free(nl->list,TRUE); - g_free(nl); - } + while(dtd_data->attributes->len) { + dtd_named_list_t *nl = g_ptr_array_remove_index_fast(dtd_data->attributes, 0); + g_ptr_array_free(nl->list, TRUE); + g_free(nl); + } - g_ptr_array_free(dtd_data->attributes,TRUE); + g_ptr_array_free(dtd_data->attributes, TRUE); - g_free(dtd_data); + g_free(dtd_data); } -static void copy_attrib_item(gpointer k, gpointer v _U_, gpointer p) { - gchar* key = g_strdup(k); - int* value = g_malloc(sizeof(int)); - GHashTable* dst = p; +static void copy_attrib_item(gpointer k, gpointer v _U_, gpointer p) +{ + gchar *key = g_strdup(k); + int *value = g_malloc(sizeof(int)); + GHashTable *dst = p; - *value = -1; - g_hash_table_insert(dst,key,value); + *value = -1; + g_hash_table_insert(dst, key, value); } -static GHashTable* copy_attributes_hash(GHashTable* src) { - GHashTable* dst = g_hash_table_new(g_str_hash,g_str_equal); +static GHashTable *copy_attributes_hash(GHashTable *src) +{ + GHashTable *dst = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_foreach(src,copy_attrib_item,dst); + g_hash_table_foreach(src, copy_attrib_item, dst); - return dst; + return dst; } -static xml_ns_t* duplicate_element(xml_ns_t* orig) { - xml_ns_t* new_item = g_malloc(sizeof(xml_ns_t)); - guint i; +static xml_ns_t *duplicate_element(xml_ns_t *orig) +{ + xml_ns_t *new_item = g_malloc(sizeof(xml_ns_t)); + guint i; + + new_item->name = g_strdup(orig->name); + new_item->hf_tag = -1; + new_item->hf_cdata = -1; + new_item->ett = -1; + new_item->attributes = copy_attributes_hash(orig->attributes); + new_item->elements = g_hash_table_new(g_str_hash, g_str_equal); + new_item->element_names = g_ptr_array_new(); + + for(i=0; i < orig->element_names->len; i++) { + g_ptr_array_add(new_item->element_names, + g_ptr_array_index(orig->element_names, i)); + } + + return new_item; +} - new_item->name = g_strdup(orig->name); - new_item->hf_tag = -1; - new_item->hf_cdata = -1; - new_item->ett = -1; - new_item->attributes = copy_attributes_hash(orig->attributes); - new_item->elements = g_hash_table_new(g_str_hash,g_str_equal); - new_item->element_names = g_ptr_array_new(); +static gchar *fully_qualified_name(GPtrArray *hier, gchar *name, gchar *proto_name) +{ + guint i; + GString *s = g_string_new(proto_name); + gchar *str; + + g_string_append(s, "."); - for(i=0; i < orig->element_names->len; i++) { - g_ptr_array_add(new_item->element_names, - g_ptr_array_index(orig->element_names,i)); - } + for (i = 1; i < hier->len; i++) { + g_string_append_printf(s, "%s.", (gchar *)g_ptr_array_index(hier, i)); + } - return new_item; + g_string_append(s, name); + str = s->str; + g_string_free(s, FALSE); + + return str; } -static gchar* fully_qualified_name(GPtrArray* hier, gchar* name, gchar* proto_name) { - guint i; - GString* s = g_string_new(proto_name); - gchar* str; - g_string_append(s,"."); - for (i = 1; i < hier->len; i++) { - g_string_append_printf(s, "%s.",(gchar*)g_ptr_array_index(hier,i)); - } +static xml_ns_t *make_xml_hier(gchar *elem_name, + xml_ns_t *root, + GHashTable *elements, + GPtrArray *hier, + GString *error, + GArray *hfs, + GArray *etts, + char *proto_name) +{ + xml_ns_t *new; + xml_ns_t *orig; + gchar *fqn; + gint *ett_p; + gboolean recurred = FALSE; + guint i; + struct _attr_reg_data d; + + if ( g_str_equal(elem_name, root->name) ) { + return NULL; + } - g_string_append(s,name); - str = s->str; - g_string_free(s,FALSE); + if (! ( orig = g_hash_table_lookup(elements, elem_name) )) { + g_string_append_printf(error, "element '%s' is not defined\n", elem_name); + return NULL; + } - return str; -} + for (i = 0; i < hier->len; i++) { + if( strcmp(elem_name, (gchar *) g_ptr_array_index(hier, i) ) == 0 ) { + recurred = TRUE; + } + } + if (recurred) { + return NULL; + } -static xml_ns_t* make_xml_hier(gchar* elem_name, - xml_ns_t* root, - GHashTable* elements, - GPtrArray* hier, - GString* error, - GArray* hfs, - GArray* etts, - char* proto_name) { - xml_ns_t* new; - xml_ns_t* orig; - gchar* fqn; - gint* ett_p; - struct _attr_reg_data d; - gboolean recurred = FALSE; - guint i; - - if ( g_str_equal(elem_name,root->name) ) { - return NULL; - } - - if (! ( orig = g_hash_table_lookup(elements,elem_name) )) { - g_string_append_printf(error,"element '%s' is not defined\n", elem_name); - return NULL; - } - - for (i = 0; i < hier->len; i++) { - if( strcmp(elem_name,(gchar*) g_ptr_array_index(hier,i) ) == 0 ) { - recurred = TRUE; - } - } - - if (recurred) { - return NULL; - } - - fqn = fully_qualified_name(hier,elem_name,proto_name); - - new = duplicate_element(orig); - new->fqn = fqn; - - add_xml_field(hfs, &(new->hf_tag), g_strdup(elem_name), fqn); - add_xml_field(hfs, &(new->hf_cdata), g_strdup(elem_name), fqn); - - ett_p = &new->ett; - g_array_append_val(etts,ett_p); - - d.basename = fqn; - d.hf = hfs; - - g_hash_table_foreach(new->attributes,add_xml_attribute_names,&d); - - while(new->element_names->len) { - gchar* child_name = g_ptr_array_remove_index(new->element_names,0); - xml_ns_t* child_element = NULL; - - g_ptr_array_add(hier,elem_name); - child_element = make_xml_hier(child_name, root, elements, hier,error,hfs,etts,proto_name); - g_ptr_array_remove_index_fast(hier,hier->len - 1); - - if (child_element) { - g_hash_table_insert(new->elements,child_element->name,child_element); - } - } - - g_ptr_array_free(new->element_names,TRUE); - new->element_names = NULL; - return new; -} + fqn = fully_qualified_name(hier, elem_name, proto_name); -static gboolean free_both(gpointer k, gpointer v, gpointer p _U_) { - g_free(k); - g_free(v); - return TRUE; -} + new = duplicate_element(orig); + new->fqn = fqn; + + add_xml_field(hfs, &(new->hf_tag), g_strdup(elem_name), fqn); + add_xml_field(hfs, &(new->hf_cdata), g_strdup(elem_name), fqn); -static gboolean free_elements(gpointer k _U_, gpointer v, gpointer p _U_) { - xml_ns_t* e = v; - g_free(e->name); - g_hash_table_foreach_remove(e->attributes,free_both,NULL); - g_hash_table_destroy(e->attributes); - g_hash_table_destroy(e->elements); + ett_p = &new->ett; + g_array_append_val(etts, ett_p); - while (e->element_names->len) { - g_free(g_ptr_array_remove_index(e->element_names,0)); - } + d.basename = fqn; + d.hf = hfs; - g_ptr_array_free(e->element_names,TRUE); - g_free(e); + g_hash_table_foreach(new->attributes, add_xml_attribute_names, &d); - return TRUE; + while(new->element_names->len) { + gchar *child_name = g_ptr_array_remove_index(new->element_names, 0); + xml_ns_t *child_element = NULL; + + g_ptr_array_add(hier, elem_name); + child_element = make_xml_hier(child_name, root, elements, hier, error, hfs, etts, proto_name); + g_ptr_array_remove_index_fast(hier, hier->len - 1); + + if (child_element) { + g_hash_table_insert(new->elements, child_element->name, child_element); + } + } + + g_ptr_array_free(new->element_names, TRUE); + new->element_names = NULL; + return new; } -static void register_dtd(dtd_build_data_t* dtd_data, GString* errors) { - GHashTable* elements = g_hash_table_new(g_str_hash,g_str_equal); - gchar* root_name = NULL; - xml_ns_t* root_element = NULL; - GArray* hfs; - GArray* etts; - GPtrArray* hier; - gchar* curr_name; - GPtrArray* element_names = g_ptr_array_new(); - - /* we first populate elements with the those coming from the parser */ - while(dtd_data->elements->len) { - dtd_named_list_t* nl = g_ptr_array_remove_index(dtd_data->elements,0); - xml_ns_t* element = g_malloc(sizeof(xml_ns_t)); - - /* we will use the first element found as root in case no other one was given. */ - if (root_name == NULL) - root_name = g_strdup(nl->name); - - element->name = nl->name; - element->element_names = nl->list; - element->hf_tag = -1; - element->hf_cdata = -1; - element->ett = -1; - element->attributes = g_hash_table_new(g_str_hash,g_str_equal); - element->elements = g_hash_table_new(g_str_hash,g_str_equal); - - if( g_hash_table_lookup(elements,element->name) ) { - g_string_append_printf(errors,"element %s defined more than once\n", element->name); - free_elements(NULL,element,NULL); - } else { - g_hash_table_insert(elements,element->name,element); - g_ptr_array_add(element_names,g_strdup(element->name)); - } - - g_free(nl); - } - - /* then we add the attributes to its relative elements */ - while(dtd_data->attributes->len) { - dtd_named_list_t* nl = g_ptr_array_remove_index(dtd_data->attributes,0); - xml_ns_t* element = g_hash_table_lookup(elements,nl->name); - - if (element) { - while(nl->list->len) { - gchar* name = g_ptr_array_remove_index(nl->list,0); - int* id_p = g_malloc(sizeof(int)); - - *id_p = -1; - g_hash_table_insert(element->attributes,name,id_p); - } - } - else { - g_string_append_printf(errors,"element %s is not defined\n", nl->name); - } - - g_free(nl->name); - g_ptr_array_free(nl->list,TRUE); - g_free(nl); - } - - /* if a proto_root is defined in the dtd we'll use that as root */ - if( dtd_data->proto_root ) { - g_free(root_name); - root_name = g_strdup(dtd_data->proto_root); - } - - /* we use a stack with the names to avoid recurring infinitelly */ - hier = g_ptr_array_new(); - - /* - * if a proto name was given in the dtd the dtd will be used as a protocol - * or else the dtd will be loaded as a branch of the xml namespace - */ - if( ! dtd_data->proto_name ) { - hfs = hf_arr; - etts = ett_arr; - g_ptr_array_add(hier,g_strdup("xml")); - } else { - /* - * if we were given a proto_name the namespace will be registered - * as an independent protocol with its own hf and ett arrays. - */ - hfs = g_array_new(FALSE,FALSE,sizeof(hf_register_info)); - etts = g_array_new(FALSE,FALSE,sizeof(gint*)); - } - - /* the root element of the dtd's namespace */ - root_element = g_malloc(sizeof(xml_ns_t)); - root_element->name = g_strdup(root_name); - root_element->fqn = dtd_data->proto_name ? g_strdup(dtd_data->proto_name) : root_element->name; - root_element->hf_tag = -1; - root_element->hf_cdata = -1; - root_element->ett = -1; - root_element->elements = g_hash_table_new(g_str_hash,g_str_equal); - root_element->element_names = element_names; - - /* - * we can either create a namespace as a flat namespace - * in which all the elements are at the root level - * or we can create a recursive namespace - */ - if (dtd_data->recursion) { - xml_ns_t* orig_root; - - make_xml_hier(root_name, root_element, elements,hier,errors,hfs,etts,dtd_data->proto_name); - - g_hash_table_insert(root_element->elements,root_element->name,root_element); - - orig_root = g_hash_table_lookup(elements,root_name); - - /* if the root element was defined copy its attrlist to the child */ - if(orig_root) { - struct _attr_reg_data d; - - d.basename = dtd_data->proto_name; - d.hf = hfs; - - root_element->attributes = copy_attributes_hash(orig_root->attributes); - g_hash_table_foreach(root_element->attributes,add_xml_attribute_names,&d); - } else { - root_element->attributes = g_hash_table_new(g_str_hash,g_str_equal); - } - - /* we then create all the sub hierachies to catch the recurred cases */ - g_ptr_array_add(hier,root_name); - - while(root_element->element_names->len) { - curr_name = g_ptr_array_remove_index(root_element->element_names,0); - - if( ! g_hash_table_lookup(root_element->elements,curr_name) ) { - xml_ns_t* new = make_xml_hier(curr_name, root_element, elements,hier,errors,hfs,etts,dtd_data->proto_name); - g_hash_table_insert(root_element->elements,new->name,new); - } - - g_free(curr_name); - } - - } else { - /* a flat namespace */ - g_ptr_array_add(hier,root_name); - - root_element->attributes = g_hash_table_new(g_str_hash,g_str_equal); - - while(root_element->element_names->len) { - xml_ns_t* new; - gint* ett_p; - struct _attr_reg_data d; - - curr_name = g_ptr_array_remove_index(root_element->element_names,0); - new = duplicate_element(g_hash_table_lookup(elements,curr_name)); - new->fqn = fully_qualified_name(hier, curr_name, root_name); - - add_xml_field(hfs, &(new->hf_tag), curr_name, new->fqn); - add_xml_field(hfs, &(new->hf_cdata), curr_name, new->fqn); - - d.basename = new->fqn; - d.hf = hfs; - - g_hash_table_foreach(new->attributes,add_xml_attribute_names,&d); - - ett_p = &new->ett; - g_array_append_val(etts,ett_p); - - g_ptr_array_free(new->element_names,TRUE); +static gboolean free_both(gpointer k, gpointer v, gpointer p _U_) +{ + g_free(k); + g_free(v); + return TRUE; +} - g_hash_table_insert(root_element->elements,new->name,new); - } - } +static gboolean free_elements(gpointer k _U_, gpointer v, gpointer p _U_) +{ + xml_ns_t *e = v; - g_ptr_array_free(element_names,TRUE); - - g_ptr_array_free(hier,TRUE); + g_free(e->name); + g_hash_table_foreach_remove(e->attributes, free_both, NULL); + g_hash_table_destroy(e->attributes); + g_hash_table_destroy(e->elements); - /* - * if we were given a proto_name the namespace will be registered - * as an independent protocol. - */ - if( dtd_data->proto_name ) { - gint* ett_p; + while (e->element_names->len) { + g_free(g_ptr_array_remove_index(e->element_names, 0)); + } - if ( ! dtd_data->description) { - dtd_data->description = g_strdup(root_name); - } + g_ptr_array_free(e->element_names, TRUE); + g_free(e); - ett_p = &root_element->ett; - g_array_append_val(etts,ett_p); + return TRUE; +} + +static void register_dtd(dtd_build_data_t *dtd_data, GString *errors) +{ + GHashTable *elements = g_hash_table_new(g_str_hash, g_str_equal); + gchar *root_name = NULL; + xml_ns_t *root_element = NULL; + GArray *hfs; + GArray *etts; + GPtrArray *hier; + gchar *curr_name; + GPtrArray *element_names = g_ptr_array_new(); + + /* we first populate elements with the those coming from the parser */ + while(dtd_data->elements->len) { + dtd_named_list_t *nl = g_ptr_array_remove_index(dtd_data->elements, 0); + xml_ns_t *element = g_malloc(sizeof(xml_ns_t)); + + /* we will use the first element found as root in case no other one was given. */ + if (root_name == NULL) + root_name = g_strdup(nl->name); + + element->name = nl->name; + element->element_names = nl->list; + element->hf_tag = -1; + element->hf_cdata = -1; + element->ett = -1; + element->attributes = g_hash_table_new(g_str_hash, g_str_equal); + element->elements = g_hash_table_new(g_str_hash, g_str_equal); + + if( g_hash_table_lookup(elements, element->name) ) { + g_string_append_printf(errors, "element %s defined more than once\n", element->name); + free_elements(NULL, element, NULL); + } else { + g_hash_table_insert(elements, element->name, element); + g_ptr_array_add(element_names, g_strdup(element->name)); + } + + g_free(nl); + } + + /* then we add the attributes to its relative elements */ + while(dtd_data->attributes->len) { + dtd_named_list_t *nl = g_ptr_array_remove_index(dtd_data->attributes, 0); + xml_ns_t *element = g_hash_table_lookup(elements, nl->name); + + if (element) { + while(nl->list->len) { + gchar *name = g_ptr_array_remove_index(nl->list, 0); + int *id_p = g_malloc(sizeof(int)); + + *id_p = -1; + g_hash_table_insert(element->attributes, name, id_p); + } + } + else { + g_string_append_printf(errors, "element %s is not defined\n", nl->name); + } + + g_free(nl->name); + g_ptr_array_free(nl->list, TRUE); + g_free(nl); + } + + /* if a proto_root is defined in the dtd we'll use that as root */ + if( dtd_data->proto_root ) { + g_free(root_name); + root_name = g_strdup(dtd_data->proto_root); + } + + /* we use a stack with the names to avoid recurring infinitelly */ + hier = g_ptr_array_new(); + + /* + * if a proto name was given in the dtd the dtd will be used as a protocol + * or else the dtd will be loaded as a branch of the xml namespace + */ + if( ! dtd_data->proto_name ) { + hfs = hf_arr; + etts = ett_arr; + g_ptr_array_add(hier, g_strdup("xml")); + } else { + /* + * if we were given a proto_name the namespace will be registered + * as an independent protocol with its own hf and ett arrays. + */ + hfs = g_array_new(FALSE, FALSE, sizeof(hf_register_info)); + etts = g_array_new(FALSE, FALSE, sizeof(gint *)); + } + + /* the root element of the dtd's namespace */ + root_element = g_malloc(sizeof(xml_ns_t)); + root_element->name = g_strdup(root_name); + root_element->fqn = dtd_data->proto_name ? g_strdup(dtd_data->proto_name) : root_element->name; + root_element->hf_tag = -1; + root_element->hf_cdata = -1; + root_element->ett = -1; + root_element->elements = g_hash_table_new(g_str_hash, g_str_equal); + root_element->element_names = element_names; + + /* + * we can either create a namespace as a flat namespace + * in which all the elements are at the root level + * or we can create a recursive namespace + */ + if (dtd_data->recursion) { + xml_ns_t *orig_root; + + make_xml_hier(root_name, root_element, elements, hier, errors, hfs, etts, dtd_data->proto_name); + + g_hash_table_insert(root_element->elements, root_element->name, root_element); + + orig_root = g_hash_table_lookup(elements, root_name); + + /* if the root element was defined copy its attrlist to the child */ + if(orig_root) { + struct _attr_reg_data d; + + d.basename = dtd_data->proto_name; + d.hf = hfs; + + root_element->attributes = copy_attributes_hash(orig_root->attributes); + g_hash_table_foreach(root_element->attributes, add_xml_attribute_names, &d); + } else { + root_element->attributes = g_hash_table_new(g_str_hash, g_str_equal); + } + + /* we then create all the sub hierachies to catch the recurred cases */ + g_ptr_array_add(hier, root_name); + + while(root_element->element_names->len) { + curr_name = g_ptr_array_remove_index(root_element->element_names, 0); + + if( ! g_hash_table_lookup(root_element->elements, curr_name) ) { + xml_ns_t *new = make_xml_hier(curr_name, root_element, elements, hier, errors, + hfs, etts, dtd_data->proto_name); + g_hash_table_insert(root_element->elements, new->name, new); + } + + g_free(curr_name); + } + + } else { + /* a flat namespace */ + g_ptr_array_add(hier, root_name); + + root_element->attributes = g_hash_table_new(g_str_hash, g_str_equal); + + while(root_element->element_names->len) { + xml_ns_t *new; + gint *ett_p; + struct _attr_reg_data d; + + curr_name = g_ptr_array_remove_index(root_element->element_names, 0); + new = duplicate_element(g_hash_table_lookup(elements, curr_name)); + new->fqn = fully_qualified_name(hier, curr_name, root_name); + + add_xml_field(hfs, &(new->hf_tag), curr_name, new->fqn); + add_xml_field(hfs, &(new->hf_cdata), curr_name, new->fqn); + + d.basename = new->fqn; + d.hf = hfs; + + g_hash_table_foreach(new->attributes, add_xml_attribute_names, &d); + + ett_p = &new->ett; + g_array_append_val(etts, ett_p); + + g_ptr_array_free(new->element_names, TRUE); + + g_hash_table_insert(root_element->elements, new->name, new); + } + } + + g_ptr_array_free(element_names, TRUE); + + g_ptr_array_free(hier, TRUE); + + /* + * if we were given a proto_name the namespace will be registered + * as an independent protocol. + */ + if( dtd_data->proto_name ) { + gint *ett_p; - add_xml_field(hfs, &root_element->hf_cdata, root_element->name, root_element->fqn); + if ( ! dtd_data->description) { + dtd_data->description = g_strdup(root_name); + } - root_element->hf_tag = proto_register_protocol(dtd_data->description, dtd_data->proto_name, dtd_data->proto_name); - proto_register_field_array(root_element->hf_tag, (hf_register_info*)g_array_data(hfs), hfs->len); - proto_register_subtree_array((gint**)g_array_data(etts), etts->len); + ett_p = &root_element->ett; + g_array_append_val(etts, ett_p); - if (dtd_data->media_type) { - g_hash_table_insert(media_types,dtd_data->media_type,root_element); - dtd_data->media_type = NULL; - } + add_xml_field(hfs, &root_element->hf_cdata, root_element->name, root_element->fqn); - dtd_data->description = NULL; - dtd_data->proto_name = NULL; - g_array_free(hfs,FALSE); - g_array_free(etts,TRUE); - } + root_element->hf_tag = proto_register_protocol(dtd_data->description, + dtd_data->proto_name, + dtd_data->proto_name); + proto_register_field_array(root_element->hf_tag, (hf_register_info*)g_array_data(hfs), hfs->len); + proto_register_subtree_array((gint **)g_array_data(etts), etts->len); - g_hash_table_insert(xml_ns.elements,root_element->name,root_element); + if (dtd_data->media_type) { + g_hash_table_insert(media_types, dtd_data->media_type, root_element); + dtd_data->media_type = NULL; + } - g_hash_table_foreach_remove(elements,free_elements,NULL); - g_hash_table_destroy(elements); + dtd_data->description = NULL; + dtd_data->proto_name = NULL; + g_array_free(hfs, FALSE); + g_array_free(etts, TRUE); + } - destroy_dtd_data(dtd_data); - g_free(root_name); + g_hash_table_insert(xml_ns.elements, root_element->name, root_element); + + g_hash_table_foreach_remove(elements, free_elements, NULL); + g_hash_table_destroy(elements); + + destroy_dtd_data(dtd_data); + g_free(root_name); } # define DIRECTORY_T GDir @@ -1205,218 +1257,259 @@ static void register_dtd(dtd_build_data_t* dtd_data, GString* errors) { # define GETFNAME_OP(file) (file); # define CLOSEDIR_OP(dir) g_dir_close(dir) -static void init_xml_names(void) { - xml_ns_t* xmlpi_xml_ns; - guint i; - DIRECTORY_T* dir; - const FILE_T* file; - const gchar* filename; - gchar* dirname; +static void init_xml_names(void) +{ + xml_ns_t *xmlpi_xml_ns; + guint i; + DIRECTORY_T *dir; + const FILE_T *file; + const gchar *filename; + gchar *dirname; - GError** dummy = g_malloc(sizeof(GError *)); - *dummy = NULL; + GError **dummy = g_malloc(sizeof(GError *)); + *dummy = NULL; - xmpli_names = g_hash_table_new(g_str_hash,g_str_equal); - media_types = g_hash_table_new(g_str_hash,g_str_equal); + xmpli_names = g_hash_table_new(g_str_hash, g_str_equal); + media_types = g_hash_table_new(g_str_hash, g_str_equal); - unknown_ns.elements = xml_ns.elements = g_hash_table_new(g_str_hash,g_str_equal); - unknown_ns.attributes = xml_ns.attributes = g_hash_table_new(g_str_hash,g_str_equal); + unknown_ns.elements = xml_ns.elements = g_hash_table_new(g_str_hash, g_str_equal); + unknown_ns.attributes = xml_ns.attributes = g_hash_table_new(g_str_hash, g_str_equal); - xmlpi_xml_ns = xml_new_namespace(xmpli_names,"xml","version","encoding","standalone",NULL); + xmlpi_xml_ns = xml_new_namespace(xmpli_names, "xml", "version", "encoding", "standalone", NULL); - g_hash_table_destroy(xmlpi_xml_ns->elements); - xmlpi_xml_ns->elements = NULL; + g_hash_table_destroy(xmlpi_xml_ns->elements); + xmlpi_xml_ns->elements = NULL; - dirname = get_persconffile_path("dtds", FALSE, FALSE); + dirname = get_persconffile_path("dtds", FALSE, FALSE); - if (test_for_directory(dirname) != EISDIR) { - /* Although dir isn't a directory it may still use memory */ - g_free(dirname); - dirname = get_datafile_path("dtds"); - } + if (test_for_directory(dirname) != EISDIR) { + /* Although dir isn't a directory it may still use memory */ + g_free(dirname); + dirname = get_datafile_path("dtds"); + } - if (test_for_directory(dirname) == EISDIR) { - if ((dir = OPENDIR_OP(dirname)) != NULL) { - GString* errors = g_string_new(""); + if (test_for_directory(dirname) == EISDIR) { + if ((dir = OPENDIR_OP(dirname)) != NULL) { + GString *errors = g_string_new(""); - while ((file = DIRGETNEXT_OP(dir)) != NULL) { - guint namelen; - filename = GETFNAME_OP(file); + while ((file = DIRGETNEXT_OP(dir)) != NULL) { + guint namelen; + filename = GETFNAME_OP(file); - namelen = (int)strlen(filename); - if ( namelen > 4 && ( g_ascii_strcasecmp(filename+(namelen-4),".dtd") == 0 ) ) { - GString* preparsed; - dtd_build_data_t* dtd_data; + namelen = (int)strlen(filename); + if ( namelen > 4 && ( g_ascii_strcasecmp(filename+(namelen-4), ".dtd") == 0 ) ) { + GString *preparsed; + dtd_build_data_t *dtd_data; - g_string_truncate(errors, 0); - preparsed = dtd_preparse(dirname, filename, errors); + g_string_truncate(errors, 0); + preparsed = dtd_preparse(dirname, filename, errors); - if (errors->len) { - report_failure("Dtd Preparser in file %s%c%s: %s",dirname,G_DIR_SEPARATOR,filename,errors->str); - continue; - } + if (errors->len) { + report_failure("Dtd Preparser in file %s%c%s: %s", + dirname, G_DIR_SEPARATOR, filename, errors->str); + continue; + } - dtd_data = dtd_parse(preparsed); + dtd_data = dtd_parse(preparsed); - g_string_free(preparsed,TRUE); + g_string_free(preparsed, TRUE); - if (dtd_data->error->len) { - report_failure("Dtd Parser in file %s%c%s: %s",dirname,G_DIR_SEPARATOR,filename,dtd_data->error->str); - destroy_dtd_data(dtd_data); - continue; - } + if (dtd_data->error->len) { + report_failure("Dtd Parser in file %s%c%s: %s", + dirname, G_DIR_SEPARATOR, filename, dtd_data->error->str); + destroy_dtd_data(dtd_data); + continue; + } - register_dtd(dtd_data,errors); + register_dtd(dtd_data, errors); - if (errors->len) { - report_failure("Dtd Registration in file: %s%c%s: %s",dirname,G_DIR_SEPARATOR,filename,errors->str); - continue; - } - } - } - g_string_free(errors,TRUE); + if (errors->len) { + report_failure("Dtd Registration in file: %s%c%s: %s", + dirname, G_DIR_SEPARATOR, filename, errors->str); + continue; + } + } + } + g_string_free(errors, TRUE); - CLOSEDIR_OP(dir); - } - } + CLOSEDIR_OP(dir); + } + } - g_free(dirname); + g_free(dirname); - for(i=0;i<array_length(default_media_types);i++) { - if( ! g_hash_table_lookup(media_types,default_media_types[i]) ) { - g_hash_table_insert(media_types,(gpointer)default_media_types[i],&xml_ns); - } - } + for(i=0;i<array_length(default_media_types);i++) { + if( ! g_hash_table_lookup(media_types, default_media_types[i]) ) { + g_hash_table_insert(media_types, (gpointer)default_media_types[i], &xml_ns); + } + } - g_hash_table_foreach(xmpli_names,add_xmlpi_namespace,"xml.xmlpi"); + g_hash_table_foreach(xmpli_names, add_xmlpi_namespace, "xml.xmlpi"); - g_free(dummy); + g_free(dummy); } -static void range_delete_xml_tcp_callback(guint32 port) { - dissector_delete_uint("tcp.port", port, xml_handle); +static void range_delete_xml_tcp_callback(guint32 port) +{ + dissector_delete_uint("tcp.port", port, xml_handle); } -static void range_add_xml_tcp_callback(guint32 port) { - dissector_add_uint("tcp.port", port, xml_handle); +static void range_add_xml_tcp_callback(guint32 port) +{ + dissector_add_uint("tcp.port", port, xml_handle); } -static void apply_prefs(void) { - if (pref_heuristic_media_save != pref_heuristic_media) { - if (pref_heuristic_media) { - heur_dissector_add("http", dissect_xml_heur, xml_ns.hf_tag); - heur_dissector_add("sip", dissect_xml_heur, xml_ns.hf_tag); - heur_dissector_add("media", dissect_xml_heur, xml_ns.hf_tag); - pref_heuristic_media_save = TRUE; - } else { - heur_dissector_delete("http", dissect_xml_heur, xml_ns.hf_tag); - heur_dissector_delete("sip", dissect_xml_heur, xml_ns.hf_tag); - heur_dissector_delete("media", dissect_xml_heur, xml_ns.hf_tag); - pref_heuristic_media_save = FALSE; - } - } - - if (pref_heuristic_tcp_save != pref_heuristic_tcp ) { - if (pref_heuristic_tcp) { - heur_dissector_add("tcp", dissect_xml_heur, xml_ns.hf_tag); - pref_heuristic_tcp_save = TRUE; - } else { - heur_dissector_delete("tcp", dissect_xml_heur, xml_ns.hf_tag); - pref_heuristic_tcp_save = FALSE; - } - } - - if (pref_heuristic_udp_save != pref_heuristic_udp ) { - if (pref_heuristic_udp) { - heur_dissector_add("udp", dissect_xml_heur, xml_ns.hf_tag); - pref_heuristic_udp_save = TRUE; - } else { - heur_dissector_delete("udp", dissect_xml_heur, xml_ns.hf_tag); - pref_heuristic_udp_save = FALSE; - } - } - - range_foreach(xml_tcp_range, range_delete_xml_tcp_callback); - g_free(xml_tcp_range); - xml_tcp_range = range_copy(global_xml_tcp_range); - range_foreach(xml_tcp_range, range_add_xml_tcp_callback); +static void apply_prefs(void) +{ + if (pref_heuristic_media_save != pref_heuristic_media) { + if (pref_heuristic_media) { + heur_dissector_add("http", dissect_xml_heur, xml_ns.hf_tag); + heur_dissector_add("sip", dissect_xml_heur, xml_ns.hf_tag); + heur_dissector_add("media", dissect_xml_heur, xml_ns.hf_tag); + pref_heuristic_media_save = TRUE; + } else { + heur_dissector_delete("http", dissect_xml_heur, xml_ns.hf_tag); + heur_dissector_delete("sip", dissect_xml_heur, xml_ns.hf_tag); + heur_dissector_delete("media", dissect_xml_heur, xml_ns.hf_tag); + pref_heuristic_media_save = FALSE; + } + } + + if (pref_heuristic_tcp_save != pref_heuristic_tcp ) { + if (pref_heuristic_tcp) { + heur_dissector_add("tcp", dissect_xml_heur, xml_ns.hf_tag); + pref_heuristic_tcp_save = TRUE; + } else { + heur_dissector_delete("tcp", dissect_xml_heur, xml_ns.hf_tag); + pref_heuristic_tcp_save = FALSE; + } + } + + if (pref_heuristic_udp_save != pref_heuristic_udp ) { + if (pref_heuristic_udp) { + heur_dissector_add("udp", dissect_xml_heur, xml_ns.hf_tag); + pref_heuristic_udp_save = TRUE; + } else { + heur_dissector_delete("udp", dissect_xml_heur, xml_ns.hf_tag); + pref_heuristic_udp_save = FALSE; + } + } + + range_foreach(xml_tcp_range, range_delete_xml_tcp_callback); + g_free(xml_tcp_range); + xml_tcp_range = range_copy(global_xml_tcp_range); + range_foreach(xml_tcp_range, range_add_xml_tcp_callback); } void -proto_register_xml(void) { - static gint *ett_base[] = { - &unknown_ns.ett, - &xml_ns.ett, - &ett_dtd, - &ett_xmpli - }; - - static hf_register_info hf_base[] = { - { &hf_xmlpi, {"XMLPI", "xml.xmlpi", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &hf_comment, {"Comment", "xml.comment", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &hf_unknowwn_attrib, {"Attribute", "xml.attribute", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &hf_doctype, {"Doctype", "xml.doctype", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &hf_dtd_tag, {"DTD Tag", "xml.dtdtag", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &unknown_ns.hf_cdata, {"CDATA", "xml.cdata", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &unknown_ns.hf_tag, {"Tag", "xml.tag", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, - { &xml_ns.hf_cdata, {"Unknown", "xml.unknown", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }} +proto_register_xml(void) +{ + static gint *ett_base[] = { + &unknown_ns.ett, + &xml_ns.ett, + &ett_dtd, + &ett_xmpli + }; + + static hf_register_info hf_base[] = { + { &hf_xmlpi, + {"XMLPI", "xml.xmlpi", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &hf_comment, + {"Comment", "xml.comment", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &hf_unknowwn_attrib, + {"Attribute", "xml.attribute", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &hf_doctype, + {"Doctype", "xml.doctype", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &hf_dtd_tag, + {"DTD Tag", "xml.dtdtag", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &unknown_ns.hf_cdata, + {"CDATA", "xml.cdata", + FT_STRING, BASE_NONE, NULL, 0, NULL, + HFILL } + }, + { &unknown_ns.hf_tag, + {"Tag", "xml.tag", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &xml_ns.hf_cdata, + {"Unknown", "xml.unknown", + FT_STRING, BASE_NONE, NULL, 0, + NULL, HFILL } + } }; - module_t* xml_module; + module_t *xml_module; - hf_arr = g_array_new(FALSE,FALSE,sizeof(hf_register_info)); - ett_arr = g_array_new(FALSE,FALSE,sizeof(gint*)); + hf_arr = g_array_new(FALSE, FALSE, sizeof(hf_register_info)); + ett_arr = g_array_new(FALSE, FALSE, sizeof(gint *)); - g_array_append_vals(hf_arr,hf_base,array_length(hf_base)); - g_array_append_vals(ett_arr,ett_base,array_length(ett_base)); + g_array_append_vals(hf_arr, hf_base, array_length(hf_base)); + g_array_append_vals(ett_arr, ett_base, array_length(ett_base)); - init_xml_names(); + init_xml_names(); - xml_ns.hf_tag = proto_register_protocol("eXtensible Markup Language", "XML", xml_ns.name); + xml_ns.hf_tag = proto_register_protocol("eXtensible Markup Language", "XML", xml_ns.name); - proto_register_field_array(xml_ns.hf_tag, (hf_register_info*)g_array_data(hf_arr), hf_arr->len); - proto_register_subtree_array((gint**)g_array_data(ett_arr), ett_arr->len); + proto_register_field_array(xml_ns.hf_tag, (hf_register_info*)g_array_data(hf_arr), hf_arr->len); + proto_register_subtree_array((gint **)g_array_data(ett_arr), ett_arr->len); - xml_module = prefs_register_protocol(xml_ns.hf_tag,apply_prefs); - prefs_register_bool_preference(xml_module, "heuristic", "Use Heuristics for media types", + xml_module = prefs_register_protocol(xml_ns.hf_tag, apply_prefs); + prefs_register_bool_preference(xml_module, "heuristic", "Use Heuristics for media types", "Try to recognize XML for unknown media types", &pref_heuristic_media); - prefs_register_bool_preference(xml_module, "heuristic_tcp", "Use Heuristics for TCP", + prefs_register_bool_preference(xml_module, "heuristic_tcp", "Use Heuristics for TCP", "Try to recognize XML for unknown TCP ports", &pref_heuristic_tcp); - prefs_register_range_preference(xml_module, "tcp.port", "TCP Ports", - "TCP Ports range", - &global_xml_tcp_range, 65535); - prefs_register_bool_preference(xml_module, "heuristic_udp", "Use Heuristics for UDP", + prefs_register_range_preference(xml_module, "tcp.port", "TCP Ports", + "TCP Ports range", + &global_xml_tcp_range, 65535); + prefs_register_bool_preference(xml_module, "heuristic_udp", "Use Heuristics for UDP", "Try to recognize XML for unknown UDP ports", &pref_heuristic_udp); - prefs_register_bool_preference(xml_module, "heuristic_unicode", "Use Unicode in heuristics", + prefs_register_bool_preference(xml_module, "heuristic_unicode", "Use Unicode in heuristics", "Try to recognize XML encoded in Unicode (UCS-2)", &pref_heuristic_unicode); - g_array_free(hf_arr,FALSE); - g_array_free(ett_arr,TRUE); + g_array_free(hf_arr, FALSE); + g_array_free(ett_arr, TRUE); - register_dissector("xml", dissect_xml, xml_ns.hf_tag); + register_dissector("xml", dissect_xml, xml_ns.hf_tag); - init_xml_parser(); + init_xml_parser(); - xml_tcp_range = range_empty(); + xml_tcp_range = range_empty(); } -static void add_dissector_media(gpointer k, gpointer v _U_, gpointer p _U_) { - dissector_add_string("media_type", (gchar*)k, xml_handle); +static void +add_dissector_media(gpointer k, gpointer v _U_, gpointer p _U_) +{ + dissector_add_string("media_type", (gchar *)k, xml_handle); } void proto_reg_handoff_xml(void) { + xml_handle = find_dissector("xml"); - xml_handle = find_dissector("xml"); - - g_hash_table_foreach(media_types,add_dissector_media,NULL); - heur_dissector_add("wtap_file", dissect_xml_heur, xml_ns.hf_tag); + g_hash_table_foreach(media_types, add_dissector_media, NULL); + heur_dissector_add("wtap_file", dissect_xml_heur, xml_ns.hf_tag); } |