static void
decode_iei_ip_address(nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) {
  guint8 addr_type;
  guint32 ip4_addr;
  struct e_in6_addr ip6_addr;

  addr_type = tvb_get_guint8(bi->tvb, bi->offset);
  proto_tree_add_item(bi->nsip_tree, hf_nsip_ip_address_type,
                          bi->tvb, bi->offset, 1, ENC_BIG_ENDIAN);
  switch (addr_type) {
  case NSIP_IP_ADDRESS_TYPE_IPV4:
    ie->total_length = 2 + ipv4_element.address_length;
    ip4_addr = tvb_get_ipv4(bi->tvb, bi->offset+1);
    proto_tree_add_ipv4(bi->nsip_tree, hf_nsip_ip_address_ipv4,
        bi->tvb, ie_start_offset, ie->total_length,
        ip4_addr);
    break;
  case NSIP_IP_ADDRESS_TYPE_IPV6:
    ie->total_length = 2 + ipv6_element.address_length;
    tvb_get_ipv6(bi->tvb, bi->offset+1, &ip6_addr);
    proto_tree_add_ipv6(bi->nsip_tree, hf_nsip_ip_address_ipv4,
        bi->tvb, ie_start_offset, ie->total_length,
        (guint8 *)&ip6_addr);
    break;
  default:
    return; /* error */
  }
  bi->offset += ie->value_length;
}
static proto_item *
decode_ip_element(nsip_ip_element_info_t *element, build_info_t *bi, proto_tree * element_tree) {
  guint16 udp_port;
  guint32 ip4_addr;
  struct e_in6_addr ip6_addr;
  proto_item *tf = NULL;
  proto_tree *field_tree = NULL;

  if (bi->nsip_tree) {
    tf = proto_tree_add_text(element_tree, bi->tvb, bi->offset,
                             element->total_length, "IP Element");
    field_tree = proto_item_add_subtree(tf, ett_nsip_ip_element);

    /* IP address */
    switch (element->version) {
    case NSIP_IP_VERSION_4:
      ip4_addr = tvb_get_ipv4(bi->tvb, bi->offset);
      proto_tree_add_item(field_tree, hf_nsip_ip_address_ipv4,
                          bi->tvb, bi->offset, element->address_length,
                          ENC_BIG_ENDIAN);
      proto_item_append_text(tf, ": IP address: %s",
                             ip_to_str((guint8 *)&ip4_addr));

      break;
    case NSIP_IP_VERSION_6:
      tvb_get_ipv6(bi->tvb, bi->offset, &ip6_addr);
      proto_tree_add_item(field_tree, hf_nsip_ip_address_ipv6, bi->tvb,
                          bi->offset, element->address_length,
                          ENC_NA);
      proto_item_append_text(tf, ": IP address: %s",
                             ip6_to_str((struct e_in6_addr *)&ip6_addr));
      break;
    default:
      ;
    }
  }
  bi->offset += element->address_length;

  if (bi->nsip_tree) {
    /* UDP port value */
    udp_port = tvb_get_ntohs(bi->tvb, bi->offset);
    proto_tree_add_item(field_tree, hf_nsip_ip_element_udp_port,
                               bi->tvb, bi->offset, 2, ENC_BIG_ENDIAN);
    proto_item_append_text(tf, ", UDP Port: %u", udp_port);
  }
  bi->offset += 2;

  if (bi->nsip_tree) {
    /* Signalling weight */
    proto_tree_add_item(field_tree, hf_nsip_ip_element_signalling_weight,
                        bi->tvb, bi->offset, 1, ENC_BIG_ENDIAN);
  }
  bi->offset++;

  if (bi->nsip_tree) {
    /* Data weight */
    proto_tree_add_item(field_tree, hf_nsip_ip_element_data_weight,
                        bi->tvb, bi->offset, 1, ENC_BIG_ENDIAN);
  }
  bi->offset++;
  return tf;
}
static int
dissect_ppcap_source_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree * ppcap_tree1, int offset)
{
	int key1;
	guint16 msg_len;
	msg_len = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item( ppcap_tree1, hf_ppcap_length, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset  = offset + 2;
	proto_tree_add_item(ppcap_tree1, hf_ppcap_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	key1 = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item(ppcap_tree1, hf_ppcap_address_type, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	if (key1 == 1)
	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_ssn, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;
		proto_tree_add_item(ppcap_tree1, hf_ppcap_spc, tvb, offset, 3, ENC_BIG_ENDIAN);
		/*src_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_opc = wmem_new0(wmem_packet_scope(), mtp3_addr_pc_t);
		mtp3_addr_opc->pc = (guint32 )tvb_get_ntoh24(tvb, offset);
		mtp3_addr_opc->type = ITU_STANDARD;
		mtp3_addr_opc->ni = 0;
		/*SET_ADDRESS(&pinfo->net_src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);*/
		SET_ADDRESS(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
		if (msg_len%4)
			msg_len = msg_len + (4 - (msg_len%4));

		offset += msg_len-1;
		return offset;
	}
	else if (key1 == 2)
	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_opc, tvb, offset, msg_len, ENC_BIG_ENDIAN);

		/*src_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_opc = wmem_new0(wmem_packet_scope(), mtp3_addr_pc_t);
		mtp3_addr_opc->pc = tvb_get_ntohl(tvb, offset);
		mtp3_addr_opc->type = ITU_STANDARD;
		mtp3_addr_opc->ni = 0;
		SET_ADDRESS(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
	}
	else if (key1 == 3)
	{
		if (msg_len%16 != 0)
		{

			proto_tree_add_ipv4(ppcap_tree1, hf_ppcap_source_ip_address1, tvb, offset, msg_len, tvb_get_ipv4(tvb, offset));
			TVB_SET_ADDRESS(&pinfo->net_src, AT_IPv4, tvb, offset, 4);
			COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->net_src);
		}
		else
		{
			struct e_in6_addr value;
			tvb_get_ipv6(tvb, offset, &value);
			proto_tree_add_ipv6(ppcap_tree1, hf_ppcap_source_ip_address2, tvb, offset, msg_len, &value);
			TVB_SET_ADDRESS(&pinfo->net_src, AT_IPv6, tvb, offset, 6);
			COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->net_src);
		}
	}

	else if (key1 == 4)

	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_source_nodeid, tvb, offset, msg_len, ENC_ASCII|ENC_NA);
		TVB_SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, tvb, offset, msg_len);
		COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->net_src);
	}
	if (msg_len%4)
		msg_len = msg_len + (4 - (msg_len%4));
	offset += msg_len;
	return offset;
}
static int
dissect_ppcap_destination_address(tvbuff_t *tvb, packet_info * pinfo, proto_tree * ppcap_tree1, int offset)
{
	int key2;
	guint16 msg_len;
	msg_len = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item( ppcap_tree1, hf_ppcap_length, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset  = offset + 2;
	proto_tree_add_item(ppcap_tree1, hf_ppcap_destreserved, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	key2 = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item(ppcap_tree1, hf_ppcap_address_type, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	if (key2 == 1)
	{
		ssn = tvb_get_guint8(tvb, offset);
		proto_tree_add_item(ppcap_tree1, hf_ppcap_ssn1, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		proto_tree_add_item(ppcap_tree1, hf_ppcap_spc1, tvb, offset, 3, ENC_BIG_ENDIAN);

		/*dst_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_dpc = wmem_new0(wmem_packet_scope(), mtp3_addr_pc_t);
		mtp3_addr_dpc->pc = (guint32)tvb_get_ntoh24(tvb, offset);
		mtp3_addr_dpc->type = ITU_STANDARD;
		mtp3_addr_dpc->ni = 0;
		SET_ADDRESS(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);

		if (msg_len%4)
			msg_len = msg_len + (4 - (msg_len%4));

		offset += msg_len-1;
		return offset;

	}
	else if (key2 == 2)
	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_dpc, tvb, offset, 4, ENC_BIG_ENDIAN);

		/*dst_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_dpc = wmem_new0(wmem_packet_scope(), mtp3_addr_pc_t);
		mtp3_addr_dpc->pc = tvb_get_ntohl(tvb, offset);
		mtp3_addr_dpc->type = ITU_STANDARD;
		mtp3_addr_dpc->ni = 0;
		SET_ADDRESS(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
	}
	else if (key2 == 3)
	{
		if (msg_len%16 != 0)
		{
			proto_tree_add_ipv4(ppcap_tree1, hf_ppcap_destination_ip_address1, tvb, offset, msg_len, tvb_get_ipv4(tvb, offset));
			TVB_SET_ADDRESS(&pinfo->net_dst, AT_IPv4, tvb, offset, 4);
			COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->net_dst);
		}
		else
		{
			struct e_in6_addr value;

			tvb_get_ipv6(tvb, offset,&value);
			proto_tree_add_ipv6(ppcap_tree1, hf_ppcap_destination_ip_address2, tvb, offset, msg_len, &value);
			TVB_SET_ADDRESS(&pinfo->net_dst, AT_IPv6, tvb, offset, 6);
			COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->net_dst);
		}
	}

	else if (key2 == 4)
	{
		char *string;
		string = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, msg_len, ENC_UTF_8|ENC_NA);
		proto_tree_add_string(ppcap_tree1, hf_ppcap_destination_nodeid, tvb, offset, msg_len, string);
		TVB_SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, tvb, offset, msg_len);
		COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->net_dst);
	}

	if (msg_len%4)
		msg_len = msg_len+(4-(msg_len%4));

	offset += msg_len;

	return offset;
}
static void
dissect_aodv_draft_01_v6_rrep(tvbuff_t *tvb, packet_info *pinfo,
			      proto_tree *aodv_tree, proto_item *ti)
{
    int offset = 1;
    proto_item *tj;
    proto_tree *aodv_flags_tree;
    guint8 flags;
    guint8 prefix_sz;
    guint8 hop_count;
    guint32 dest_seqno;
    struct e_in6_addr dest_addr_v6;
    struct e_in6_addr orig_addr_v6;
    guint32 lifetime;
    int extlen;

    flags = tvb_get_guint8(tvb, offset);
    if (aodv_tree) {
	tj = proto_tree_add_text(aodv_tree, tvb, offset, 1, "Flags:");
	aodv_flags_tree = proto_item_add_subtree(tj, ett_aodv_flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rrep_repair,
			       tvb, offset, 1, flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rrep_ack, tvb,
			       offset, 1, flags);
	if (flags & RREP_REP)
	    proto_item_append_text(tj, " R");
	if (flags & RREP_ACK_REQ)
	    proto_item_append_text(tj, " A");
    }
    offset += 1;

    prefix_sz = tvb_get_guint8(tvb, offset) & 0x7F;
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_prefix_sz, tvb, offset, 1,
			    prefix_sz);
    offset += 1;

    hop_count = tvb_get_guint8(tvb, offset);
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_hopcount, tvb, offset, 1,
			    hop_count);
    offset += 1;

    dest_seqno = tvb_get_ntohl(tvb, offset);
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_dest_seqno, tvb, offset, 4,
			    dest_seqno);
    offset += 4;

    tvb_get_ipv6(tvb, offset, &dest_addr_v6);
    if (aodv_tree) {
	proto_tree_add_ipv6(aodv_tree, hf_aodv_dest_ipv6, tvb, offset,
			    INET6_ADDRLEN, (guint8 *)&dest_addr_v6);
	proto_item_append_text(ti, ", Dest IP: %s",
			       ip6_to_str(&dest_addr_v6));
    }

	col_append_fstr(pinfo->cinfo, COL_INFO, ", D: %s",
			ip6_to_str(&dest_addr_v6));
    offset += INET6_ADDRLEN;

    tvb_get_ipv6(tvb, offset, &orig_addr_v6);
    if (aodv_tree) {
	proto_tree_add_ipv6(aodv_tree, hf_aodv_orig_ipv6, tvb, offset,
			    INET6_ADDRLEN, (guint8 *)&orig_addr_v6);
	proto_item_append_text(ti, ", Orig IP: %s",
			       ip6_to_str(&orig_addr_v6));
    }

	col_append_fstr(pinfo->cinfo, COL_INFO, ", O: %s",
			ip6_to_str(&orig_addr_v6));
    offset += INET6_ADDRLEN;

    lifetime = tvb_get_ntohl(tvb, offset);
    if (aodv_tree) {
	proto_tree_add_uint(aodv_tree, hf_aodv_lifetime, tvb, offset, 4,
			    lifetime);
	proto_item_append_text(ti, ", Lifetime=%u", lifetime);
    }

	col_append_fstr(pinfo->cinfo, COL_INFO, " Hcnt=%u DSN=%u Lifetime=%u",
			hop_count,
			dest_seqno,
			lifetime);
    offset += 4;

    if (aodv_tree) {
	extlen = tvb_reported_length_remaining(tvb, offset);
	if (extlen > 0)
	    dissect_aodv_ext(tvb, offset, aodv_tree);
    }
}
static void
dissect_aodv_draft_01_v6_rreq(tvbuff_t *tvb, packet_info *pinfo,
			      proto_tree *aodv_tree, proto_item *ti)
{
    int offset = 1;
    proto_item *tj;
    proto_tree *aodv_flags_tree;
    guint8 flags;
    guint8 hop_count;
    guint32 rreq_id;
    guint32 dest_seqno;
    guint32 orig_seqno;
    struct e_in6_addr dest_addr_v6;
    struct e_in6_addr orig_addr_v6;
    int extlen;

    flags = tvb_get_guint8(tvb, offset);
    if (aodv_tree) {
	tj = proto_tree_add_text(aodv_tree, tvb, offset, 1, "Flags:");
	aodv_flags_tree = proto_item_add_subtree(tj, ett_aodv_flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rreq_join,
			       tvb, offset, 1, flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rreq_repair,
			       tvb, offset, 1, flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rreq_gratuitous,
			       tvb, offset, 1, flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rreq_destinationonly,
			       tvb, offset, 1, flags);
	proto_tree_add_boolean(aodv_flags_tree, hf_aodv_flags_rreq_unknown,
			       tvb, offset, 1, flags);
	if (flags & RREQ_JOIN)
	    proto_item_append_text(tj, " J");
	if (flags & RREQ_REP)
	    proto_item_append_text(tj, " R");
	if (flags & RREQ_GRATRREP)
	    proto_item_append_text(tj, " G");
	if (flags & RREQ_DESTONLY)
	    proto_item_append_text(tj, " D");
	if (flags & RREQ_UNKNSEQ)
	    proto_item_append_text(tj, " U");
    }
    offset += 2;	/* skip reserved byte */

    hop_count = tvb_get_guint8(tvb, offset);
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_hopcount, tvb, offset, 1,
			     hop_count);
    offset += 1;

    rreq_id = tvb_get_ntohl(tvb, offset);
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_rreq_id, tvb, offset, 4,
			    rreq_id);
    offset += 4;

    dest_seqno = tvb_get_ntohl(tvb, offset);
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_dest_seqno, tvb, offset, 4,
			    dest_seqno);
    offset += 4;

    orig_seqno = tvb_get_ntohl(tvb, offset);
    if (aodv_tree)
	proto_tree_add_uint(aodv_tree, hf_aodv_orig_seqno, tvb, offset, 4,
			    orig_seqno);
    offset += 4;

    tvb_get_ipv6(tvb, offset, &dest_addr_v6);
    if (aodv_tree) {
	proto_tree_add_ipv6(aodv_tree, hf_aodv_dest_ipv6, tvb, offset,
			    INET6_ADDRLEN, (guint8 *)&dest_addr_v6);
	proto_item_append_text(ti, ", Dest IP: %s",
			       ip6_to_str(&dest_addr_v6));
    }

	col_append_fstr(pinfo->cinfo, COL_INFO, ", D: %s",
			ip6_to_str(&dest_addr_v6));
    offset += INET6_ADDRLEN;

    tvb_get_ipv6(tvb, offset, &orig_addr_v6);
    if (aodv_tree) {
	proto_tree_add_ipv6(aodv_tree, hf_aodv_orig_ipv6, tvb, offset,
			    INET6_ADDRLEN, (guint8 *)&orig_addr_v6);
	proto_item_append_text(ti, ", Orig IP: %s",
			       ip6_to_str(&orig_addr_v6));
    }

	col_append_fstr(pinfo->cinfo, COL_INFO,
			", O: %s Id=%u Hcnt=%u DSN=%u OSN=%u",
			ip6_to_str(&orig_addr_v6),
			rreq_id,
			hop_count,
			dest_seqno,
			orig_seqno);
    offset += INET6_ADDRLEN;

    if (aodv_tree) {
	extlen = tvb_reported_length_remaining(tvb, offset);
	if (extlen > 0)
	    dissect_aodv_ext(tvb, offset, aodv_tree);
    }
}
Exemple #7
0
/* Code to actually dissect the packets */
static int
rsip_parameter(tvbuff_t *tvb, proto_tree *rsip_tree, int off, int eoff)
{
	int		consumed, i, paramleft;
	guint8		addrtype, flowpolicy, method, number, paramtype, tuntype;
	guint16		error, ind, paramlen, portnum;
	guint32		bid, cid, leasetm, msgc;
	proto_tree	*p_tree, *v_tree;
	proto_item	*pti, *vti;
	struct e_in6_addr in6;

	/* XXX */
	if (off >= eoff)
		return 0;

	paramtype = tvb_get_guint8(tvb, off);
	paramlen = tvb_get_ntohs(tvb, off + 1);

	pti = proto_tree_add_text(rsip_tree, tvb, off, 3 + paramlen,
	    "%s",
	    val_to_str(paramtype, param_type_vals, "Unknown (%d)"));
	p_tree = proto_item_add_subtree(pti, ett_rsip_param);

	proto_tree_add_item(p_tree, hf_rsip_parameter_type, tvb,
	    off, 1, ENC_BIG_ENDIAN);
	proto_tree_add_item(p_tree, hf_rsip_parameter_length, tvb,
	    off + 1, 2, ENC_BIG_ENDIAN);
	consumed = 3;

	if (paramlen == 0)
	    return consumed;

	vti = proto_tree_add_item(p_tree, hf_rsip_parameter_value,
	    tvb, off + 3, paramlen, ENC_NA);
	v_tree = proto_item_add_subtree(vti, ett_rsip_param_val);

	switch (paramtype) {
	case 1:		/* Address */
		proto_tree_add_item(v_tree, hf_rsip_parameter_address_type,
		    tvb, off + 3, 1, ENC_BIG_ENDIAN);

		addrtype = tvb_get_guint8(tvb, off + 3);

		switch (addrtype) {
		case 0:		/* Reserved */
			break;
		case 1:		/* IPv4 */
			if (paramlen - 1 > 0) {
				proto_tree_add_item(v_tree,
				    hf_rsip_parameter_address_ipv4, tvb,
				    off + 4, paramlen - 1, ENC_BIG_ENDIAN);
				proto_item_append_text(pti, ": %s",
				    tvb_ip_to_str(tvb, off + 4));
			} else
				proto_item_append_text(pti,
				    ": Any IPv4 Address");
			break;
		case 2:		/* IPv4 netmask */
			if (paramlen - 1 > 0) {
				proto_tree_add_item(v_tree,
				    hf_rsip_parameter_address_ipv4_netmask,
				    tvb, off + 4, paramlen - 1, ENC_BIG_ENDIAN);
				proto_item_append_text(pti, "(netmask): %s",
				    tvb_ip_to_str(tvb, off + 4));
			} else
				proto_item_append_text(pti,
				    ": Any IPv4 Netmask");
			break;
		case 3:		/* IPv6 */
			if (paramlen - 1 > 0) {
				tvb_get_ipv6(tvb, off + 4, &in6);
				proto_tree_add_item(v_tree,
				    hf_rsip_parameter_address_ipv6, tvb,
				    off + 4, paramlen - 1, ENC_NA);
				proto_item_append_text(pti, ": %s",
				    ip6_to_str(&in6));
			} else
				proto_item_append_text(pti,
				    ": Any IPv6 Address");
			break;
		case 4:		/* FQDN */
			if (paramlen - 1 > 0) {
				proto_tree_add_item(v_tree,
				    hf_rsip_parameter_address_fqdn, tvb,
				    off + 4, paramlen - 1, ENC_ASCII|ENC_NA);
				proto_item_append_text(pti, ": %s",
				    tvb_format_text(tvb, off + 4, paramlen - 1));
			} else
				proto_item_append_text(pti,
				    ": Any Fully Qualified Domain Name");
			break;
		default:
			proto_tree_add_text(p_tree, tvb, off + 4,
			    paramlen - 1, ": Unknown Address Type");
			break;
		}
		break;
	case 2:		/* Ports */
		proto_tree_add_item(v_tree, hf_rsip_parameter_ports_number,
		    tvb, off + 3, 1, ENC_BIG_ENDIAN);
		number = tvb_get_guint8(tvb, off + 3);
		if (paramlen == 1) {
			switch (number) {
			case 0:
				proto_item_append_text(pti, ": Unspecified");
				break;
			case 1:
				proto_item_append_text(pti, ": Any port");
				break;
			default:
				proto_item_append_text(pti, ": Any %d ports",
				    number);
				break;
			}
		} else {
			portnum = tvb_get_ntohs(tvb, off + 4);
			if (number == 1) {
				proto_tree_add_item(v_tree,
				    hf_rsip_parameter_ports_port_number,
				    tvb, off + 4, 2, ENC_BIG_ENDIAN);
			} else {
				paramleft = paramlen - 1;
				if (paramleft == 2) {
					proto_tree_add_uint_format_value(v_tree,
					    hf_rsip_parameter_ports_port_number,
					    tvb, off + 4, 2, portnum, "%d - %d",
					    portnum, portnum + number);
					proto_item_append_text(pti,
					    ": %d - %d", portnum,
					    portnum + number);
				} else {
					for (i = off + 4;
					    paramleft > 0;
					    i += 2, paramleft -= 2)
						proto_tree_add_item(v_tree,
						    hf_rsip_parameter_ports_port_number,
						    tvb, i, 2, ENC_BIG_ENDIAN);
					proto_item_append_text(pti,
					    ": List of %d Ports", number);
				}
			}
		}
		break;
	case 3:		/* Lease Time */
		/* XXX if paramlen != 4 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_lease_time,
		    tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
		leasetm = tvb_get_ntohl(tvb, off + 3);
		proto_item_append_text(pti, ": %d seconds", leasetm);
		break;
	case 4:		/* Client ID */
		/* XXX if paramlen != 4 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_client_id,
		    tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
		cid = tvb_get_ntohl(tvb, off + 3);
		proto_item_append_text(pti, ": %d", cid);
		break;
	case 5:		/* Bind ID */
		/* XXX if paramlen != 4 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_bind_id,
		    tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
		bid = tvb_get_ntohl(tvb, off + 3);
		proto_item_append_text(pti, ": %d", bid);
		break;
	case 6:		/* Tunnel Type */
		/* XXX if paramlen != 1 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_tunnel_type,
		    tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
		tuntype = tvb_get_guint8(tvb, off + 3);
		proto_item_append_text(pti, ": %s",
		    val_to_str(tuntype, tunnel_type_vals,
		        "Unknown Tunnel Type (%d)"));
		break;
	case 7:		/* RSIP Method */
		/* XXX if paramlen != 1 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_method,
		    tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
		method = tvb_get_guint8(tvb, off + 3);
		proto_item_append_text(pti, ": %s",
		    val_to_str(method, method_vals,
		    "Unknown RSIP Method (%d)"));
		break;
	case 8:		/* Error */
		/* XXX if paramlen != 2 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_error,
		    tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
		error = tvb_get_ntohs(tvb, off + 3);
		proto_item_append_text(pti, ": %s",
		    val_to_str(error, error_number_vals, "Undefined Error (%d)"));
		break;
	case 9:		/* Flow Policy */
		/* XXX if paramlen != 2 we've got a protocol violation */
		proto_tree_add_item(v_tree,
		    hf_rsip_parameter_flow_policy_local, tvb, off + 3, 1, ENC_BIG_ENDIAN);
		flowpolicy = tvb_get_guint8(tvb, off + 3);
		proto_item_append_text(pti, ": %s",
		    val_to_str(flowpolicy, lcl_flow_policy_vals,
		    "Undefined Local Flow Policy (%d)"));
		proto_tree_add_item(v_tree,
		    hf_rsip_parameter_flow_policy_remote, tvb, off + 4, 1,
		    ENC_BIG_ENDIAN);
		flowpolicy = tvb_get_guint8(tvb, off + 4);
		proto_item_append_text(pti, "/%s",
		    val_to_str(flowpolicy, rmt_flow_policy_vals,
		    "Undefined Remote Flow Policy (%d)"));
		break;
	case 10:	/* Indicator */
		/* XXX if paramlen != 2 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_indicator, tvb,
		    off + 3, 2, ENC_BIG_ENDIAN);
		ind = tvb_get_ntohs(tvb, off + 3);
		proto_item_append_text(pti, ": %d", ind);
		break;
	case 11:	/* Message Counter */
		/* XXX if paramlen != 4 we've got a protocol violation */
		proto_tree_add_item(v_tree, hf_rsip_parameter_message_counter,
		    tvb, off + 3, 4, ENC_BIG_ENDIAN);
		msgc = tvb_get_ntohl(tvb, off + 3);
		proto_item_append_text(pti, ": %d", msgc);
		break;
	case 12:	/* Vendor Specific */
		proto_tree_add_item(v_tree,
		    hf_rsip_parameter_vendor_specific_vendor_id, tvb, off + 3,
		    2, ENC_BIG_ENDIAN);
		proto_tree_add_item(v_tree,
		    hf_rsip_parameter_vendor_specific_subtype, tvb, off + 5,
		    2, ENC_BIG_ENDIAN);
		proto_tree_add_item(v_tree,
		    hf_rsip_parameter_vendor_specific_value, tvb, off + 9,
		    paramlen - 4, ENC_NA);
		break;
	case 22:	/* SPI */
		proto_tree_add_item(v_tree, hf_rsip_parameter_spi_number, tvb,
		    off + 3, 2, ENC_BIG_ENDIAN);
		/* XXX need loop? */
		proto_tree_add_item(v_tree, hf_rsip_parameter_spi, tvb,
		    off + 5, 4, ENC_BIG_ENDIAN);
		break;
	default:
		break;
	}

	consumed += paramlen;

	return consumed;
}
Exemple #8
0
static int
dissect_ppcap_destination_address(tvbuff_t *tvb, packet_info * pinfo, proto_tree * ppcap_tree1, int offset, guint16 msg_len )
{
	int key2;
	const guchar *dst_addr;
	/*guint32 dst_addr1;*/

	proto_tree_add_item(ppcap_tree1, hf_ppcap_destreserved, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	key2 = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item(ppcap_tree1, hf_ppcap_address_type, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	if (key2 == 1)
	{
		ssn = tvb_get_guint8(tvb, offset);
		proto_tree_add_item(ppcap_tree1, hf_ppcap_ssn1, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		proto_tree_add_item(ppcap_tree1, hf_ppcap_spc1, tvb, offset, 3, ENC_BIG_ENDIAN);

		/*dst_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_dpc = ep_alloc0(sizeof(mtp3_addr_pc_t));
		mtp3_addr_dpc->pc = (guint32)tvb_get_ntoh24(tvb, offset);
		mtp3_addr_dpc->type = 1; /* ITU_STANDARD */
		mtp3_addr_dpc->ni = 0;
                SET_ADDRESS(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
		/*dst_addr = tvb_get_ptr(tvb, offset, msg_len-1);
		SET_ADDRESS(&pinfo->net_dst, AT_SS7PC, msg_len-1, dst_addr);
		SET_ADDRESS(&pinfo->dst, AT_SS7PC, msg_len-1, dst_addr);*/

		if (msg_len%4)
			msg_len = msg_len + (4 - (msg_len%4));

        offset += msg_len-1;
        return offset;

	}
	else if (key2 == 2)
	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_dpc, tvb, offset, 4, ENC_BIG_ENDIAN);

		/*dst_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_dpc = ep_alloc0(sizeof(mtp3_addr_pc_t));
		mtp3_addr_dpc->pc = tvb_get_ntohl(tvb, offset);
		mtp3_addr_dpc->type = 1; /* ITU_STANDARD */
		mtp3_addr_dpc->ni = 0;
        SET_ADDRESS(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
	}
	else if (key2 == 3)
	{
		if (msg_len%4 == 0)
		{
			proto_tree_add_ipv4(ppcap_tree1, hf_ppcap_destination_ip_address1, tvb, offset, msg_len, tvb_get_ipv4(tvb, offset));
			dst_addr = tvb_get_ptr(tvb, offset, 4);
			SET_ADDRESS(&pinfo->net_dst, AT_IPv4, 4, dst_addr);
			SET_ADDRESS(&pinfo->dst, AT_IPv4, 4, dst_addr);
		}
		else
		{
			struct e_in6_addr value;

			tvb_get_ipv6(tvb, offset,&value);
			proto_tree_add_ipv6(ppcap_tree1, hf_ppcap_destination_ip_address2, tvb, offset, msg_len, (guint8*)&value);
			dst_addr = tvb_get_ptr(tvb, offset, 6);
			SET_ADDRESS(&pinfo->net_dst, AT_IPv6, 6, dst_addr);
			SET_ADDRESS(&pinfo->dst, AT_IPv6, 6, dst_addr);
		}
	}

	else if (key2 == 4)
	{
		char *string;
		string = tvb_get_string(tvb, offset, msg_len);
		proto_tree_add_string(ppcap_tree1, hf_ppcap_destination_nodeid, tvb, offset, msg_len, string);
		dst_addr = tvb_get_ptr(tvb, offset, msg_len);
		SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, msg_len, dst_addr);
		SET_ADDRESS(&pinfo->dst, AT_STRINGZ, msg_len, dst_addr);
		/*g_free(string);*/
	}

	if (msg_len%4)
		msg_len = msg_len+(4-(msg_len%4));
		offset += msg_len;
	return offset;
}
Exemple #9
0
static int
dissect_ppcap_source_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree * ppcap_tree1, int offset, guint16 msg_len)
{
	int key1;
	const guchar  *src_addr;
	/*guint32 src_addr1;*/
	proto_tree_add_item(ppcap_tree1, hf_ppcap_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	key1 = tvb_get_ntohs(tvb, offset);
	proto_tree_add_item(ppcap_tree1, hf_ppcap_address_type, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	if (key1 == 1)
	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_ssn, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;
		proto_tree_add_item(ppcap_tree1, hf_ppcap_spc, tvb, offset, 3, ENC_BIG_ENDIAN);
		/*src_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_opc = ep_alloc0(sizeof(mtp3_addr_pc_t));
		mtp3_addr_opc->pc = (guint32 )tvb_get_ntoh24(tvb, offset);
		mtp3_addr_opc->type = 1; /* ITU_STANDARD */
		mtp3_addr_opc->ni = 0;
		/*SET_ADDRESS(&pinfo->net_src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);*/
		SET_ADDRESS(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
		if (msg_len%4)
			msg_len = msg_len + (4 - (msg_len%4));

		offset += msg_len-1;
		return offset;
	}
	else if (key1 == 2)
	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_opc, tvb, offset, msg_len, ENC_BIG_ENDIAN);

		/*src_addr1 = (guint32 )tvb_get_ntoh24(tvb, offset);*/
		mtp3_addr_opc = ep_alloc0(sizeof(mtp3_addr_pc_t));
		mtp3_addr_opc->pc = tvb_get_ntohl(tvb, offset);
		mtp3_addr_opc->type = 1; /* ITU_STANDARD */
		mtp3_addr_opc->ni = 0;
		SET_ADDRESS(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
		/*src_addr = tvb_get_ptr(tvb, offset, 4);*/
		/*SET_ADDRESS(&pinfo->net_src, AT_SS7PC, 4, src_addr);*/
		/*SET_ADDRESS(&pinfo->src, AT_SS7PC, 4, src_addr);*/
	}
	else if (key1 == 3)
	{
		if (msg_len%4 == 0)
		{

			proto_tree_add_ipv4(ppcap_tree1, hf_ppcap_source_ip_address1, tvb, offset, msg_len, tvb_get_ipv4(tvb, offset));
			src_addr = tvb_get_ptr(tvb, offset, 4);
			SET_ADDRESS(&pinfo->net_src, AT_IPv4, 4, src_addr);
			SET_ADDRESS(&pinfo->src, AT_IPv4, 4, src_addr);
		}
		else
		{
			struct e_in6_addr value;
			tvb_get_ipv6(tvb, offset, &value);
			proto_tree_add_ipv6(ppcap_tree1, hf_ppcap_source_ip_address2, tvb, offset, msg_len, (guint8*)&value);
			src_addr = tvb_get_ptr(tvb, offset, 6);
			SET_ADDRESS(&pinfo->net_src, AT_IPv6, 6, src_addr);
			SET_ADDRESS(&pinfo->src, AT_IPv6, 6, src_addr);
		}
	}

	else if (key1 == 4)

	{
		proto_tree_add_item(ppcap_tree1, hf_ppcap_source_nodeid, tvb, offset, msg_len, ENC_BIG_ENDIAN|ENC_ASCII);
		src_addr = tvb_get_ptr(tvb, offset, msg_len);
		SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, msg_len, src_addr);
		SET_ADDRESS(&pinfo->src, AT_STRINGZ, msg_len, src_addr);
	}
	if (msg_len%4)
		msg_len = msg_len + (4 - (msg_len%4));
	offset += msg_len;
	return offset;
}