void set(Uint16 by_player_index, Uint16 with_player_index,
         Uint8 update_type )
 {
     allie_by_player_index = htol16(by_player_index);
     allie_with_player_index = htol16(with_player_index);
     alliance_update_type = update_type;
 }
 void set(Uint16 allie_by_player_index, Uint16 allie_with_player_index,
         Uint8 alliance_request_type)
 {
     this->allie_by_player_index = htol16(allie_by_player_index);
     this->allie_with_player_index = htol16(allie_with_player_index);
     this->alliance_request_type = alliance_request_type;
 }
int
bcm_pack_xtlv_entry_from_hex_string(void **tlv_buf, uint16 *buflen, uint16 type, char *hex)
{
	bcm_xtlv_t *ptlv = *tlv_buf;
	uint16 len = strlen(hex)/2;

	/* copy data from tlv buffer to dst provided by user */

	if ((BCM_XTLV_HDR_SIZE + len) > *buflen) {
		printf("bcm_pack_xtlv_entry: no space tlv_buf: requested:%d, available:%d\n",
			((int)BCM_XTLV_HDR_SIZE + len), *buflen);
		return BCME_BADLEN;
	}
	ptlv->id = htol16(type);
	ptlv->len = htol16(len);

	/* copy callers data */
	if (get_ie_data((uchar*)hex, ptlv->data, len)) {
		return BCME_BADARG;
	}

	/* advance callers pointer to tlv buff */
	*tlv_buf += BCM_XTLV_SIZE(ptlv);
	/* decrement the len */
	*buflen -=  BCM_XTLV_SIZE(ptlv);
	return BCME_OK;
}
/*
 *  packs user data into tlv record
 *  advances tlv pointer to next xtlv slot
 *  buflen is used for tlv_buf space check
 */
int
bcm_pack_xtlv_entry(void **tlv_buf, uint16 *buflen, uint16 type, uint16 len, void *src)
{
	bcm_xtlv_t *ptlv = *tlv_buf;

	/* copy data from tlv buffer to dst provided by user */

	ASSERT(ptlv);
	ASSERT(src);

	if ((BCM_XTLV_HDR_SIZE + len) > *buflen) {
		printf("bcm_pack_xtlv_entry: no space tlv_buf: requested:%d, available:%d\n",
		 ((int)BCM_XTLV_HDR_SIZE + len), *buflen);
		return BCME_BADLEN;
	}
	ptlv->id = htol16(type);
	ptlv->len = htol16(len);

	/* copy callers data */
	memcpy(ptlv->data, src, len);

	/* advance callers pointer to tlv buff */
	*tlv_buf += BCM_XTLV_SIZE(ptlv);
	/* decrement the len */
	*buflen -=  BCM_XTLV_SIZE(ptlv);
	return BCME_OK;
}
 void set(UnitID destroyed_unit, UnitID destroyer_unit,
         unsigned char unit_type )
 {
     message_id = _umesg_end_lifecycle;
     message_flags = _umesg_flag_manager_request;
     destroyed = htol16(destroyed_unit);
     destroyer = htol16(destroyer_unit);
     this->unit_type = unit_type;
 }
int
bcm_xtlv_put_data(struct bcm_tlvbuf *tbuf, uint16 type, const void *data, uint16 dlen)
{
	bcm_xtlv_t *xtlv;
	if (tbuf == NULL || bcm_xtlv_buf_rlen(tbuf) < (dlen + BCM_XTLV_HDR_SIZE))
		return BCME_BADARG;
	xtlv = (bcm_xtlv_t *)bcm_xtlv_buf(tbuf);
	xtlv->id = htol16(type);
	xtlv->len = htol16(dlen);
	memcpy(xtlv->data, data, dlen);
	tbuf->buf += BCM_XTLV_SIZE(xtlv);
	return BCME_OK;
}
int
bcm_xtlv_put_32(struct bcm_tlvbuf *tbuf, uint16 type, const int32 data)
{
	bcm_xtlv_t *xtlv;
	if (tbuf == NULL || bcm_xtlv_buf_rlen(tbuf) < (4 + BCM_XTLV_HDR_SIZE))
		return BCME_BADARG;
	xtlv = (bcm_xtlv_t *)bcm_xtlv_buf(tbuf);
	xtlv->id = htol16(type);
	xtlv->len = htol16(sizeof(data));
	htol32_ua_store(data, xtlv->data);
	tbuf->buf += BCM_XTLV_SIZE(xtlv);
	return BCME_OK;
}
int
bcm_xtlv_put_8(struct bcm_tlvbuf *tbuf, uint16 type, const int8 data)
{
	bcm_xtlv_t *xtlv;
	if (tbuf == NULL || bcm_xtlv_buf_rlen(tbuf) < (1 + BCM_XTLV_HDR_SIZE))
		return BCME_BADARG;
	xtlv = (bcm_xtlv_t *)bcm_xtlv_buf(tbuf);
	xtlv->id = htol16(type);
	xtlv->len = htol16(sizeof(data));
	xtlv->data[0] = data;
	tbuf->buf += BCM_XTLV_SIZE(xtlv);
	return BCME_OK;
}
Пример #9
0
/* calculates BIP; mic must be at least AES_BLOCK_SZ */
static void bip_calc(const struct dot11_header *hdr,
    const uint8 *data, int data_len, const uint8 *key, uint8 * mic)
{
    uint len;
	uint8* micdata; 
	uint16 fc; 

	memset(mic, 0 , AES_BLOCK_SZ);
	micdata = malloc(2 + 3 * ETHER_ADDR_LEN + data_len);
	if (!micdata) 
		return;

	fc = htol16(ltoh16(hdr->fc) & ~(FC_RETRY | FC_PM | FC_MOREDATA));

	len = 0;
    memcpy((char *)&micdata[len], (uint8 *)&fc, 2);
    len += 2;
    memcpy(&micdata[len], (uint8 *)&hdr->a1, ETHER_ADDR_LEN);
    len += ETHER_ADDR_LEN;
    memcpy(&micdata[len], (uint8 *)&hdr->a2, ETHER_ADDR_LEN);
    len += ETHER_ADDR_LEN;
    memcpy(&micdata[len], (uint8 *)&hdr->a3, ETHER_ADDR_LEN);
    len += ETHER_ADDR_LEN;

    memcpy(&micdata[len], data, data_len);
    len += data_len;

    aes_cmac_calc(micdata, len, key, BIP_KEY_SIZE, mic);
	free(micdata);
}
 void setTargetUnit(UnitID target)
 {
     message_id = _umesg_ai_command;
     command = _command_attack_unit;
     target_id = htol16(target);
     manual_move_orientation = 0;
 }
Пример #11
0
/* Pack 16-bit vectors */
int
bcm_xdr_pack_uint16_vec(bcm_xdr_buf_t *b, uint len, void *vec)
{
	size_t tot_len, r;
	int i;
	uint16	*vec16 = (uint16*)vec, *buf16 = (uint16*)b->buf;
	ASSERT((len % sizeof(uint16)) == 0);

	/* calc residual padding to 4 bytes */
	r = (4 - len) & 3;

	tot_len = len + r;

	if (b->size < tot_len)
		return -1;

	/* Do the 16 bit swap and copy */
	for (i = 0; i < (int)(len/sizeof(uint16)); i++)
		buf16[i] = htol16(vec16[i]);

	/* Padding */
	memset(b->buf + len, 0, r);

	b->size -= tot_len;
	b->buf += tot_len;

	return 0;
}
void ConnectClientSettings::set(const char *player_name, Uint8 unit_color,
        Uint16 player_flag )
{
    strncpy(ConnectClientSettings::player_name, player_name, 64);
    ConnectClientSettings::player_name[63] = '\0';
    ConnectClientSettings::unit_color = unit_color;
    ConnectClientSettings::player_flag = htol16(player_flag);
}
Пример #13
0
NetworkUnitState UnitState::getNetworkUnitState() const
{
    NetworkUnitState state;

    state.unit_type = unit_type;
    state.location_x = htol32(location.x);
    state.location_y = htol32(location.y);
    state.bbox_min_x = htol32(bbox.min.x);
    state.bbox_min_y = htol32(bbox.min.y);
    state.bbox_max_x = htol32(bbox.max.x);
    state.bbox_max_y = htol32(bbox.max.y);

    state.body_angle = body_angle.getNetworkAngleInt();
    state.turret_angle = turret_angle.getNetworkAngleInt();
    state.orientation = htol16(orientation);
    state.speed_rate = htol16(speed_rate);
    state.speed_factor = htol16(speed_factor);
    
    state.reload_time = htol16(reload_time);
    state.max_hit_points = htol16(max_hit_points);
    state.hit_points = htol16(hit_points);
    state.damage_factor = htol16(damage_factor);
    state.weapon_range = htol32(weapon_range);
    state.defend_range = htol32(defend_range);
    
    state.threat_level = threat_level;
    state.lifecycle_state = lifecycle_state;

    return state;
}
 UnitRemoteCreate(PlayerID player_id, UnitID id,
         Uint32 x, Uint32 y, Uint8 type)
 {
     message_class = _net_message_class_unit;
     message_id = _net_message_id_create_unit;
     this->player_id = player_id;
     new_unit_id = htol16(id);
     location_x = htol32(x);
     location_y = htol32(y);
     unit_type = type;
 }
 UnitIniSyncMessage(Uint8 unit_type, PlayerID player_id, UnitID unit_id,
     Uint32 location_x, Uint32 location_y)
 {
     message_class = _net_message_class_unit;
     message_id = _net_message_id_ini_sync_mesg;
     this->unit_type = unit_type;
     //this->player_id = htol16(player_id);
     this->player_id = player_id;
     this->unit_id = htol16(unit_id);
     this->location_x = htol32(location_x);
     this->location_y = htol32(location_y);
 }
Пример #16
0
static void input_handler_done (PacketProtoEncoder *enc, int in_len)
{
    ASSERT(enc->output_packet)
    DebugObject_Access(&enc->d_obj);

    // write length
    struct packetproto_header pp;
    pp.len = htol16(in_len);
    memcpy(enc->output_packet, &pp, sizeof(pp));

    // finish output packet
    enc->output_packet = NULL;
    PacketRecvInterface_Done(&enc->output, PACKETPROTO_ENCLEN(in_len));
}
Пример #17
0
static void input_handler_done (SCOutmsgEncoder *o, int in_len)
{
    DebugObject_Access(&o->d_obj);
    ASSERT(o->output_packet)
    
    // write SC header
    struct sc_header *header = (struct sc_header *)o->output_packet;
    header->type = htol8(SCID_OUTMSG);
    
    // write outmsg
    struct sc_client_outmsg *outmsg = (struct sc_client_outmsg *)(header + 1);
    outmsg->clientid = htol16(o->peer_id);
    
    // finish output packet
    o->output_packet = NULL;
    PacketRecvInterface_Done(&o->output, SCOUTMSG_OVERHEAD + in_len);
}
Пример #18
0
NetworkPlayerState PlayerState::getNetworkPlayerState() const
{
    NetworkPlayerState state;

    memset(state.name, 0, sizeof(state.name));
    strncpy(state.name, name.c_str(), sizeof(state.name)-1);
    state.flag = flag;
    state.playerindex_id = htol16(player_index);
    state.status = status;
    state.kills = htol16(kills);
    state.kill_points = htol16(kill_points);
    state.losses = htol16(losses);
    state.loss_points = htol16(loss_points);
    state.total = htol16(total);
    state.objectives_held = htol16(objectives_held);
    state.colorIndex = htol32(colorIndex);
    
    return state;
}
Пример #19
0
/* totally bogus -- d11 hdr only + tx hdrs */
static void *
wlc_olpc_get_pkt(wlc_info_t *wlc, uint ac, uint* fifo)
{
    int buflen = (TXOFF + WL_OLPC_PKT_LEN);
    void* p = NULL;
    osl_t *osh = wlc->osh;
    const char* macaddr = NULL;
    struct dot11_header *hdr = NULL;

    if ((p = PKTGET(osh, buflen, TRUE)) == NULL) {
        WL_ERROR(("wl%d: %s: pktget error for len %d \n",
                  wlc->pub->unit, __FUNCTION__, buflen));
        goto fatal;
    }
    macaddr = WLC_MACADDR(wlc);

    WL_NONE(("pkt manip\n"));
    /* reserve TXOFF bytes of headroom */
    PKTPULL(osh, p, TXOFF);
    PKTSETLEN(osh, p, WL_OLPC_PKT_LEN);

    WL_NONE(("d11_hdr\n"));
    hdr = (struct dot11_header*)PKTDATA(osh, p);
    bzero((char*)hdr, WL_OLPC_PKT_LEN);
    hdr->fc = htol16(FC_DATA);
    hdr->durid = 0;
    bcopy((const char*)macaddr, (char*)&(hdr->a1.octet), ETHER_ADDR_LEN);
    bcopy((const char*)macaddr, (char*)&(hdr->a2.octet), ETHER_ADDR_LEN);
    bcopy((const char*)macaddr, (char*)&(hdr->a3.octet), ETHER_ADDR_LEN);
    hdr->seq = 0;
    WL_NONE(("prep raw 80211\n"));
    wlc->olpc_info->tx_cal_pkts = TRUE;
    /* frameid returned here -- ignore for now -- may speed up using this */
    (void)wlc_prep80211_raw(wlc, NULL, ac, TRUE, p, fifo);
    wlc->olpc_info->tx_cal_pkts = FALSE;

    return p;
fatal:
    return (NULL);
}
 void setUnitToDestroy(UnitID id)
 {
     unit_to_destroy = htol16(id);
 }
 void setKillOnPlayerIndex(Uint16 kill_on_index)
 {
     kill_on_player_index = htol16(kill_on_index);
 }
 void set(const Uint16 player_idx, unsigned char alert_type)
 {
     player_index = htol16(player_idx);
     alert_enum = alert_type;
 }                                               
 SystemPingRequest(Uint16 playerIndex)
 {
     message_class = _net_message_class_system;
     message_id = _net_message_id_system_ping_request;
     client_player_index = htol16(playerIndex);
 }
Пример #24
0
 void setHitPoints(Sint16 newhitpoints)
 {
     hit_points = htol16(newhitpoints);
 }
Пример #25
0
 void setTarget(iXY target)
 {
     x = htol16(target.x);
     y = htol16(target.y);
 }
 void set(Uint16 kill_by_index, Uint16 kill_on_index, Uint8 unit_type)
 {
     kill_by_player_index = htol16(kill_by_index);
     kill_on_player_index = htol16(kill_on_index);
     this->unit_type = unit_type;
 }
 void setKillByPlayerIndex(Uint16 kill_by_index)
 {
     kill_by_player_index = htol16(kill_by_index);
 }
void ConnectMesgServerGameSettings::setMaxPlayers(Uint16 maxPlayers)
{
    max_players = htol16(maxPlayers);
}
Пример #29
0
 void setUnitID(UnitID id)
 {
     unit_id = htol16(id);
 }
void ConnectMesgServerGameSettings::setMaxUnits(Uint16 maxUnits)
{
    max_units = htol16(maxUnits);
}