예제 #1
0
Packet *newPacketIHAVE(Packet *pktWHOHAS)
{
    uint8_t numHash = getPacketNumHash(pktWHOHAS);
    int i = 0;
    int idx;
    uint8_t *hash;
    Packet *thisObj = newPacketDefault();
    incPacketSize(thisObj, 4);
    setPacketType(thisObj, "IHAVE");
    for(i = 0; i < numHash; i++) {
        hash = getPacketHash(pktWHOHAS, i);
        idx = searchHash(hash, &hasChunk, -1);
        if(idx >= 0) {
            printf("Has[%d]", i);
            insertPacketHash(thisObj, hash);
        }
    }

    if(i == 0 || getPacketSize(thisObj) == 20) {
        freePacket(thisObj);
        return NULL;
    } else {
      setPacketDest(thisObj, &(pktWHOHAS->src), sizeof(pktWHOHAS->src));
      return thisObj;
    }
}
예제 #2
0
bool L2Game_CharacterDelete::create( L2_VERSION ver )
{
	ver = L2_VERSION_T1;
	setPacketType( 0x0D ); // CharacterDelete
	writeD( p_charSlot );
	return true;
}
예제 #3
0
void newPacketACK(uint32_t ack, queue *ackSendQueue)
{
    Packet *thisObj = newPacketDefault();
    setPacketType(thisObj, "ACK");
    setPacketAck(thisObj, ack);
    enqueue(ackSendQueue, (void *)thisObj);
}
예제 #4
0
bool L2Login_PlayFail::create( L2_VERSION ver /*= L2_VERSION_T1*/ )
{
	UNREFERENCED_PARAMETER(ver);
	setPacketType( 0x06 );
	writeUChar( p_reasonCode );
	return true;
}
예제 #5
0
void HTTPPacket::setStatusCode(int statusCode) {
    if (statusCode < 100 || statusCode >= 600) {
        statusCode = 0;
    }
    _statusCode =  statusCode;
    setPacketType(PT_RESPONSE);
}
예제 #6
0
Packet *newPacketSingleGET(uint8_t *hash)
{
    Packet *thisObj = newPacketDefault();
    incPacketSize(thisObj, 20);
    setPacketType(thisObj, "GET");
    memcpy(thisObj->payload + 16, hash, SHA1_HASH_SIZE);
    return thisObj;
}
예제 #7
0
void HTTPPacket::setMethod(HTTPMethod method) {
    if ( method < HM_OPTIONS || method >= HM_UNSUPPORTED) {
        _method = HM_UNSUPPORTED;
    } else {
        _method = method;
    }
    setPacketType(PT_REQUEST);
}
예제 #8
0
bool L2Login_LoginOK::create( L2_VERSION ver /*= L2_VERSION_T23*/ )
{
	UNREFERENCED_PARAMETER(ver);
	setPacketType( 0x03 );
	writeBytes( p_sessionKey1, 8 );
	writeD( 0x00 );
	writeD( 0x00 );
	writeD( 0x000003ea ); // wtf?
	writeD( 0x00 );
	writeD( 0x00 );
	writeD( 0x00 );
	//writeB(new byte[16]); // 4 Ds
	writeD( 0x00 );
	writeD( 0x00 );
	writeD( 0x00 );
	writeD( 0x00 );
	return true;
}
예제 #9
0
bool L2Game_CharacterCreate::create( const L2Game_NewCharacterTemplate *tmpl, const wchar_t *name,
		int hairStyle, int hairColor, int face, int gender )
{
	if( !tmpl ) return false;
	setPacketType( 0x0C ); // CharacterCreate
	writeS( name );
	writeD( tmpl->race );
	writeD( gender );
	writeD( tmpl->classID );
	writeD( tmpl->base_INT );
	writeD( tmpl->base_STR );
	writeD( tmpl->base_CON );
	writeD( tmpl->base_MEN );
	writeD( tmpl->base_DEX );
	writeD( tmpl->base_WIT );
	writeD( hairStyle );
	writeD( hairColor );
	writeD( face );
	return true;
}
예제 #10
0
Packet *newPacketSingleDATA(int seqNo, int seqChunk, size_t size)
{
    size_t retSize;
    long offset = seqChunk * BT_CHUNK_SIZE + (seqNo - 1) * PACKET_DATA_SIZE;
    Packet *pkt = newPacketDefault();

    setPacketType(pkt, "DATA");
    incPacketSize(pkt, size);
    setPacketSeq(pkt, seqNo);

    FILE *mf = masterChunk.filePtr;

    rewind(mf);
    fseek(mf, offset, SEEK_SET);
    retSize = fread(pkt->payload + 16, sizeof(uint8_t), size, mf);
    if(retSize != size) {
      printf("IO Error reading chunk\n");
      freePacket(pkt);
      return NULL;
    } else {
      return pkt;
    }
}
예제 #11
0
void newPacketWHOHAS(queue *sendQueue)
{
    int i, j;
    int pktIndex = 0;
    int needToFetch = 0;
    int numHash = getChunk.numChunk;
    int numPacket = numHash / MAX_HASH_PER_PACKET;
    if(getChunk.numChunk % MAX_HASH_PER_PACKET > 0) {
        numPacket++;
    }

    for(i = 0; i < numPacket; i++) {
      int num;
      Packet *thisObj = newPacketDefault();
      incPacketSize(thisObj, 4);
      setPacketType(thisObj, "WHOHAS");
      if(i < numPacket - 1) {
	num = MAX_HASH_PER_PACKET;
      } else {
	num = getChunk.numChunk % MAX_HASH_PER_PACKET;
      }
      for(j = 0; j < num; j++) {
	while(getChunk.list[pktIndex].fetchState == 1
	      || (searchHash(getChunk.list[pktIndex].hash, &hasChunk, -1) >= 0)) {
	  pktIndex++;
	}
	if(pktIndex == numHash)
	  break;
	insertPacketHash(thisObj, getChunk.list[pktIndex].hash);
	needToFetch = 1;
	pktIndex++;
      }
      if(needToFetch)
	enqueue(sendQueue, (void *)thisObj);
    }
}
예제 #12
0
Packet *newFreePacketACK(uint32_t ack){
  Packet *thisObj = newPacketDefault();
  setPacketType(thisObj, "ACK");
  setPacketAck(thisObj, ack);
  return thisObj;
}
예제 #13
0
LIFXPayload::LIFXPayload(unsigned int packetType)
{
    LIFXPayload();
    setPacketType(packetType);
}