Example #1
0
bool cResponsePacket::copyin(const uint8_t* src, uint32_t len)
{
    if (!checkExtend(len)) return false;
    memcpy(buffer + bufUsed, src, len);
    bufUsed += len;
    return true;
}
Example #2
0
bool cResponsePacket::add_U8(uint8_t c)
{
    if (!checkExtend(sizeof(uint8_t))) return false;
    buffer[bufUsed] = c;
    bufUsed += sizeof(uint8_t);
    return true;
}
Example #3
0
bool cResponsePacket::add_U64(uint64_t ull)
{
  if (!checkExtend(sizeof(uint64_t))) return false;
  *(uint64_t*)&buffer[bufUsed] = htonll(ull);
  bufUsed += sizeof(uint64_t);
  return true;
}
Example #4
0
bool cResponsePacket::add_S32(int32_t l)
{
  if (!checkExtend(sizeof(int32_t))) return false;
  *(int32_t*)&buffer[bufUsed] = htonl(l);
  bufUsed += sizeof(int32_t);
  return true;
}
Example #5
0
bool cResponsePacket::add_U64(uint64_t ull)
{
    if (!checkExtend(sizeof(uint64_t))) return false;
    uint64_t tmp = __cpu_to_be64(ull);
    memcpy(&buffer[bufUsed], &tmp, sizeof(uint64_t));
    bufUsed += sizeof(uint64_t);
    return true;
}
Example #6
0
bool cResponsePacket::add_S32(int32_t l)
{
    if (!checkExtend(sizeof(int32_t))) return false;
    int32_t tmp = htonl(l);
    memcpy(&buffer[bufUsed], &tmp, sizeof(int32_t));
    bufUsed += sizeof(int32_t);
    return true;
}
Example #7
0
bool cResponsePacket::add_String(const char* string)
{
    uint32_t len = strlen(string) + 1;
    if (!checkExtend(len)) return false;
    memcpy(buffer + bufUsed, string, len);
    bufUsed += len;
    return true;
}
Example #8
0
bool cRequestPacket::copyin(const uint8_t* src, uint32_t len)
{
  if (!checkExtend(len)) return false;
  memcpy(buffer + bufUsed, src, len);
  bufUsed += len;
  if (!lengthSet) *(uint32_t*)&buffer[userDataLenPos] = htonl(bufUsed - headerLength);
  return true;
}
Example #9
0
bool cRequestPacket::add_U64(uint64_t ull)
{
  if (!checkExtend(sizeof(uint64_t))) return false;
  *(uint64_t*)&buffer[bufUsed] = htonll(ull);
  bufUsed += sizeof(uint64_t);
  if (!lengthSet) *(uint32_t*)&buffer[userDataLenPos] = htonl(bufUsed - headerLength);
  return true;
}
Example #10
0
bool cResponsePacket::add_double(double d)
{
  if (!checkExtend(sizeof(double))) return false;
  uint64_t ull;
  memcpy(&ull,&d,sizeof(double));
  *(uint64_t*)&buffer[bufUsed] = htonll(ull);
  bufUsed += sizeof(uint64_t);
  return true;
}
Example #11
0
bool cRequestPacket::add_String(const char* string)
{
  uint32_t len = strlen(string) + 1;
  if (!checkExtend(len)) return false;
  memcpy(buffer + bufUsed, string, len);
  bufUsed += len;
  if (!lengthSet) *(uint32_t*)&buffer[userDataLenPos] = htonl(bufUsed - headerLength);
  return true;
}
Example #12
0
bool cResponsePacket::add_double(double d)
{
    if (!checkExtend(sizeof(double))) return false;
    uint64_t ull;
    memcpy(&ull, &d, sizeof(double));
    ull = __cpu_to_be64(ull);
    memcpy(&buffer[bufUsed], &ull, sizeof(uint64_t));
    bufUsed += sizeof(uint64_t);
    return true;
}
Example #13
0
bool cRequestPacket::add_U8(uint8_t c)
{
  if (!checkExtend(sizeof(uint8_t))) return false;
  buffer[bufUsed] = c;
  bufUsed += sizeof(uint8_t);
  if (!lengthSet)
  {
    uint32_t tmp = htonl(bufUsed - headerLength);
    memcpy(&buffer[userDataLenPos], &tmp, sizeof(uint32_t));
  }
  return true;
}
Example #14
0
uint8_t* cResponsePacket::reserve(uint32_t len) {
    if (!checkExtend(len)) return false;
    uint8_t* result = buffer + bufUsed;
    bufUsed += len;
    return result;
}