예제 #1
0
파일: Peer.cpp 프로젝트: smasherprog/NWork
void NWork::Peer::Send(Packet& packet, unsigned char channel){
	if(channel>=_Channels.size()) return;
	packet.get_Header()->PeerID = SendingId;
	packet.get_Header()->ChannelID = channel;
	if(IS_RELIABLE(packet.get_Header()->Command)) _Channels[channel].SendReliable(packet);
	else _Channels[channel].SendUnReliable(packet);
}
예제 #2
0
static gboolean
dissect_clique_rm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  guint8 version = 0;
  guint8 type = 0;
  int offset = 0;

  if (tvb_length (tvb) < 12)
    return FALSE;

  if (tvb_strneql (tvb, offset, "Clique", 6))
    return FALSE;
  offset += 6;

  version = tvb_get_guint8 (tvb, offset);
  if (version != 1)
    return FALSE;
  offset++;

  type = tvb_get_guint8 (tvb, offset);
  offset++;

  col_set_str(pinfo->cinfo, COL_PROTOCOL, "Clique-rm");
  col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
        val_to_str(type, packet_type_vals, "Unknown (0x%02x)"));

  if (tree) {
    proto_item *ti = NULL;
    proto_tree *clique_rm_tree = NULL;

    /* rewind back to just behind the prefix */
    offset = 6;

    ti = proto_tree_add_item(tree, proto_clique_rm, tvb, 0, -1, ENC_NA);
    clique_rm_tree = proto_item_add_subtree(ti, ett_clique_rm);

    proto_tree_add_item(clique_rm_tree, hf_clique_rm_version, tvb, offset, 1,
        ENC_BIG_ENDIAN);
    offset++;

    proto_tree_add_item(clique_rm_tree, hf_clique_rm_type, tvb, offset, 1,
        ENC_BIG_ENDIAN);
    offset++;

   if (check_col(pinfo->cinfo, COL_INFO))
     col_append_fstr(pinfo->cinfo, COL_INFO, ", sender: 0x%x",
       tvb_get_ntohl (tvb, offset));

    proto_tree_add_item(clique_rm_tree, hf_clique_rm_sender, tvb, offset,
        4, ENC_BIG_ENDIAN);
    offset += 4;

    if (IS_RELIABLE(type)) {
      if (check_col(pinfo->cinfo, COL_INFO))
        col_append_fstr(pinfo->cinfo, COL_INFO, ", id: 0x%x",
          tvb_get_ntohl (tvb, offset));

      dissect_reliable_packet(clique_rm_tree, type, tvb, offset);
    } else {
      dissect_unreliable_packet(clique_rm_tree, type, tvb, offset);
    }
  }

  return TRUE;
}