static void cmpp_submit_resp(proto_tree *tree, tvbuff_t *tvb) { int offset; offset = CMPP_FIX_HEADER_LENGTH; cmpp_msg_id(tree, tvb, hf_cmpp_msg_id, offset); offset += 8; cmpp_uint4(tree, tvb, hf_cmpp_submit_resp_Result, offset); }
static void cmpp_deliver_resp(proto_tree *tree, tvbuff_t *tvb) { int offset; offset = CMPP_FIX_HEADER_LENGTH; cmpp_msg_id(tree, tvb, hf_cmpp_msg_id, offset); offset += 8; /* TODO implement the result field here */ cmpp_uint4(tree, tvb, hf_cmpp_deliver_resp_Result, offset); }
static void cmpp_connect_resp(proto_tree *tree, tvbuff_t *tvb) { int offset; offset = CMPP_FIX_HEADER_LENGTH; cmpp_uint4(tree, tvb, hf_cmpp_connect_resp_status, offset); offset += 4; proto_tree_add_string(tree, hf_cmpp_connect_resp_AuthenticatorISMG, tvb, offset, 16, "MD5 Hash"); offset += 16; cmpp_version(tree, tvb, hf_cmpp_Version, offset); }
static void cmpp_deliver_report(proto_tree *tree, tvbuff_t *tvb, gint field, guint offset) { proto_item *pi; proto_tree *sub_tree; pi = proto_tree_add_item(tree, field, tvb, offset, CMPP_DELIVER_REPORT_LEN, ENC_BIG_ENDIAN); sub_tree = proto_item_add_subtree(pi, ett_deliver_report); cmpp_msg_id(sub_tree, tvb, hf_cmpp_msg_id, offset); offset += 8; cmpp_octet_string(sub_tree, tvb, hf_cmpp_deliver_Report_Stat, offset, 7); offset += 7; cmpp_octet_string(sub_tree, tvb, hf_cmpp_deliver_Report_Submit_time, offset, 10); offset += 10; cmpp_octet_string(sub_tree, tvb, hf_cmpp_deliver_Report_Done_time, offset, 10); offset += 10; cmpp_octet_string(sub_tree, tvb, hf_cmpp_Dest_terminal_Id, offset, 32); offset += 32; cmpp_uint4(sub_tree, tvb, hf_cmpp_deliver_Report_SMSC_sequence, offset); }
/* Code to actually dissect the packets */ static void dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; proto_tree *cmpp_tree; guint command_id; guint tvb_len; guint total_length; const gchar *command_str; /* Header command string */ /* Get the length of the PDU */ tvb_len = tvb_length(tvb); /* if the length of the tvb is shorder then the cmpp header length exit */ if (tvb_len < CMPP_FIX_HEADER_LENGTH) return; total_length = tvb_get_ntohl(tvb, 0); /* Get the pdu length */ command_id = tvb_get_ntohl(tvb, 4); /* get the pdu command id */ if (match_strval(command_id, vals_command_Id) == NULL) { /* Should never happen: we checked this in dissect_cmpp() */ return; } command_str = val_to_str(command_id, vals_command_Id, "(Unknown CMPP Operation 0x%08X)"); /* tvb has less data then the PDU Header status, return */ if (tvb_len < total_length) { /* Should never happen: TCP should have desegmented for us */ return; } /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMPP"); col_append_fstr(pinfo->cinfo, COL_INFO, "%s. ", command_str); if (tree) { ti = proto_tree_add_item(tree, proto_cmpp, tvb, 0, -1, ENC_NA); cmpp_tree = proto_item_add_subtree(ti, ett_cmpp); /* Add the fix header informations to the tree */ cmpp_uint4(cmpp_tree, tvb, hf_cmpp_Total_Length, 0); cmpp_uint4(cmpp_tree, tvb, hf_cmpp_Command_Id, 4); cmpp_uint4(cmpp_tree, tvb, hf_cmpp_Sequence_Id, 8); switch(command_id) { case CMPP_CONNECT: cmpp_connect(cmpp_tree, tvb); break; case CMPP_CONNECT_RESP: cmpp_connect_resp(cmpp_tree, tvb); break; /* CMPP_TERMINATE and CMPP_TERMINATE_RESP don't have msg body */ case CMPP_TERMINATE: case CMPP_TERMINATE_RESP: break; case CMPP_SUBMIT: cmpp_submit(cmpp_tree, tvb); break; case CMPP_SUBMIT_RESP: cmpp_submit_resp(cmpp_tree, tvb); break; case CMPP_DELIVER: cmpp_deliver(cmpp_tree, tvb); break; case CMPP_DELIVER_RESP: cmpp_deliver_resp(cmpp_tree, tvb); break; default: /* Implement the rest of the protocol here */ break; } } }