static int dissect_dtpt_guid(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex) { guint32 guid_length; guid_length = tvb_get_letohl(tvb, offset); if (tree) { e_guid_t guid; proto_item *dtpt_guid_item = NULL; proto_tree *dtpt_guid_tree = NULL; const gchar *guid_name = NULL; if (guid_length) { tvb_get_guid(tvb, offset+4, &guid, ENC_LITTLE_ENDIAN); } else { memset(&guid, 0, sizeof(guid)); } dtpt_guid_item = proto_tree_add_guid(tree, hfindex, tvb, offset, 4 + guid_length, &guid); if (dtpt_guid_item) { guid_name = guids_get_guid_name(&guid); if (guid_name != NULL) proto_item_set_text(dtpt_guid_item, "%s: %s (%s)", proto_registrar_get_name(hfindex), guid_name, guid_to_str(&guid)); dtpt_guid_tree = proto_item_add_subtree(dtpt_guid_item, ett_dtpt_guid); } if (dtpt_guid_tree) { proto_item *dtpt_guid_data_item = NULL; proto_tree_add_uint(dtpt_guid_tree, hf_dtpt_guid_length, tvb, offset, 4, guid_length); if (guid_length) { dtpt_guid_data_item = proto_tree_add_guid(dtpt_guid_tree, hf_dtpt_guid_data, tvb, offset+4, guid_length, &guid); if (guid_name != NULL && dtpt_guid_data_item != NULL) { proto_item_set_text(dtpt_guid_data_item, "%s: %s (%s)", proto_registrar_get_name(hf_dtpt_guid_data), guid_name, guid_to_str(&guid)); } } } } offset+=4; offset+=guid_length; return offset; }
/* the UUID is the same as a GlusterFS GFID, except its encoded per byte */ static int gluster_gd_mgmt_dissect_uuid(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset) { if (tree) { e_guid_t uuid; int start_offset = offset; uuid.data1 = (tvb_get_ntohl(tvb, offset) & 0xff) << 24 | (tvb_get_ntohl(tvb, offset+4) & 0xff) << 16 | (tvb_get_ntohl(tvb, offset+8) & 0xff) << 8 | (tvb_get_ntohl(tvb, offset+12) & 0xff); offset += 16; uuid.data2 = (tvb_get_ntohl(tvb, offset) & 0xff) << 8 | (tvb_get_ntohl(tvb, offset+4) & 0xff); offset += 8; uuid.data3 = (tvb_get_ntohl(tvb, offset) & 0xff) << 8 | (tvb_get_ntohl(tvb, offset+4) & 0xff); offset += 8; uuid.data4[0] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[1] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[2] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[3] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[4] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[5] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[6] = tvb_get_ntohl(tvb, offset); offset += 4; uuid.data4[7] = tvb_get_ntohl(tvb, offset); offset += 4; proto_tree_add_guid(tree, hfindex, tvb, start_offset, 4*16, &uuid); } else offset += 16 * 4; return offset; }
static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, h225_packet_info *pi) { proto_item *hidden_item; conversation_t* conversation = NULL; h225ras_call_info_key h225ras_call_key; h225ras_call_t *h225ras_call = NULL; nstime_t delta; guint msg_category; if(pi->msg_type == H225_RAS && pi->msg_tag < 21) { /* make RAS request/response matching only for tags from 0 to 20 for now */ msg_category = pi->msg_tag / 3; if(pi->msg_tag % 3 == 0) { /* Request Message */ conversation = find_or_create_conversation(pinfo); /* prepare the key data */ h225ras_call_key.reqSeqNum = pi->requestSeqNum; h225ras_call_key.conversation = conversation; /* look up the request */ h225ras_call = find_h225ras_call(&h225ras_call_key ,msg_category); if (h225ras_call != NULL) { /* We've seen requests with this reqSeqNum, with the same source and destination, before - do we have *this* request already? */ /* Walk through list of ras requests with identical keys */ do { if (pinfo->fd->num == h225ras_call->req_num) { /* We have seen this request before -> do nothing */ break; } /* if end of list is reached, exit loop and decide if request is duplicate or not. */ if (h225ras_call->next_call == NULL) { if ( (pinfo->fd->num > h225ras_call->rsp_num && h225ras_call->rsp_num != 0 && pinfo->fd->abs_ts.secs > (h225ras_call->req_time.secs + THRESHOLD_REPEATED_RESPONDED_CALL) ) ||(pinfo->fd->num > h225ras_call->req_num && h225ras_call->rsp_num == 0 && pinfo->fd->abs_ts.secs > (h225ras_call->req_time.secs + THRESHOLD_REPEATED_NOT_RESPONDED_CALL) ) ) { /* if last request has been responded and this request appears after last response (has bigger frame number) and last request occured more than 300 seconds ago, or if last request hasn't been responded and this request appears after last request (has bigger frame number) and last request occured more than 1800 seconds ago, we decide that we have a new request */ /* Append new ras call to list */ h225ras_call = append_h225ras_call(h225ras_call, pinfo, &pi->guid, msg_category); } else { /* No, so it's a duplicate request. Mark it as such. */ pi->is_duplicate = TRUE; hidden_item = proto_tree_add_uint(tree, hf_h225_ras_dup, tvb, 0,0, pi->requestSeqNum); PROTO_ITEM_SET_HIDDEN(hidden_item); } break; } h225ras_call = h225ras_call->next_call; } while (h225ras_call != NULL ); } else { h225ras_call = new_h225ras_call(&h225ras_call_key, pinfo, &pi->guid, msg_category); } /* add link to response frame, if available */ if(h225ras_call && h225ras_call->rsp_num != 0){ proto_item *ti = proto_tree_add_uint_format(tree, hf_h225_ras_rsp_frame, tvb, 0, 0, h225ras_call->rsp_num, "The response to this request is in frame %u", h225ras_call->rsp_num); PROTO_ITEM_SET_GENERATED(ti); } /* end of request message handling*/ } else { /* Confirm or Reject Message */ conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); if (conversation != NULL) { /* look only for matching request, if matching conversation is available. */ h225ras_call_key.reqSeqNum = pi->requestSeqNum; h225ras_call_key.conversation = conversation; h225ras_call = find_h225ras_call(&h225ras_call_key ,msg_category); if(h225ras_call) { /* find matching ras_call in list of ras calls with identical keys */ do { if (pinfo->fd->num == h225ras_call->rsp_num) { /* We have seen this response before -> stop now with matching ras call */ break; } /* Break when list end is reached */ if(h225ras_call->next_call == NULL) { break; } h225ras_call = h225ras_call->next_call; } while (h225ras_call != NULL) ; if (!h225ras_call) { return; } /* if this is an ACF, ARJ or DCF, DRJ, give guid to tap and make it filterable */ if (msg_category == 3 || msg_category == 5) { pi->guid = h225ras_call->guid; hidden_item = proto_tree_add_guid(tree, hf_h225_guid, tvb, 0, GUID_LEN, &pi->guid); PROTO_ITEM_SET_HIDDEN(hidden_item); } if (h225ras_call->rsp_num == 0) { /* We have not yet seen a response to that call, so this must be the first response; remember its frame number. */ h225ras_call->rsp_num = pinfo->fd->num; } else { /* We have seen a response to this call - but was it *this* response? */ if (h225ras_call->rsp_num != pinfo->fd->num) { /* No, so it's a duplicate response. Mark it as such. */ pi->is_duplicate = TRUE; hidden_item = proto_tree_add_uint(tree, hf_h225_ras_dup, tvb, 0,0, pi->requestSeqNum); PROTO_ITEM_SET_HIDDEN(hidden_item); } } if(h225ras_call->req_num != 0){ proto_item *ti; h225ras_call->responded = TRUE; pi->request_available = TRUE; /* Indicate the frame to which this is a reply. */ ti = proto_tree_add_uint_format(tree, hf_h225_ras_req_frame, tvb, 0, 0, h225ras_call->req_num, "This is a response to a request in frame %u", h225ras_call->req_num); PROTO_ITEM_SET_GENERATED(ti); /* Calculate RAS Service Response Time */ nstime_delta(&delta, &pinfo->fd->abs_ts, &h225ras_call->req_time); pi->delta_time = delta; /* give it to tap */ /* display Ras Service Response Time and make it filterable */ ti = proto_tree_add_time(tree, hf_h225_ras_deltatime, tvb, 0, 0, &(pi->delta_time)); PROTO_ITEM_SET_GENERATED(ti); } } } } } }