uint8_t
IeLinkMetricReport::DeserializeInformationField (Buffer::Iterator start, uint8_t length)
{
  Buffer::Iterator i = start;
  m_metric = i.ReadLsbtohU32 ();
  return i.GetDistanceFrom (start);
}
예제 #2
0
void
PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
{
  Buffer::Iterator i = start;
  NS_ASSERT (m_subtype < 3);
  i = m_protocol.Serialize (i);
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
    {
      i.WriteHtolsbU16 (m_capability);
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
    {
      i.WriteHtolsbU16 (m_aid);
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
    {
      i = m_rates.Serialize (i);
      i = m_rates.extended.Serialize (i);
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
    {
      i = m_meshId.Serialize (i);
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
    {
      i = m_config.Serialize (i);
    }
  else
    {
      i.WriteHtolsbU16 (m_reasonCode);
    }
}
bool HTTPClientConnection::readDone() {
  int rc;

  while (true) {
    Buffer::Iterator it = in_.begin();
    Response* response = new Response;
    rc = Parser::parseResponse(&it, response);
    if (rc < 0) {
      delete response;
      LOG(LogMessage::ERROR) << "Error parsing response";
      return false;

    } else if (rc > 0) {
      delete response;
      return true;

    } else /* rc == 0 */ {
      in_.consume(it.bytesRead());
      if (! handleResponse(response)) { // response ownership xfer
        return false;
      }
      if (it.eob()) {
        return true;
      }
    }
  }
}
예제 #4
0
void
UanHeaderRcCtsGlobal::Serialize (Buffer::Iterator start) const
{
  start.WriteU16 (m_rateNum);
  start.WriteU16 (m_retryRate);
  start.WriteU32 ( (uint32_t)(m_timeStampTx.GetSeconds () * 1000.0 + 0.5));
  start.WriteU32 ( (uint32_t)(m_winTime.GetSeconds () * 1000.0 + 0.5));
}
예제 #5
0
 uint32_t
 RrepAckHeader::Deserialize (Buffer::Iterator start )
 {
     Buffer::Iterator i = start;
     m_reserved = i.ReadU8 ();
     uint32_t dist = i.GetDistanceFrom (start);
     NS_ASSERT (dist == GetSerializedSize ());
     return dist;
 }
예제 #6
0
void
UanHeaderRcCts::Serialize (Buffer::Iterator start) const
{
  start.WriteU8 (m_address.GetAsInt ());
  start.WriteU8 (m_frameNo);
  start.WriteU8 (m_retryNo);
  start.WriteU32 ((uint32_t)(m_timeStampRts.GetSeconds () * 1000.0 + 0.5));
  start.WriteU32 ((uint32_t)(m_delay.GetSeconds () * 1000.0 + 0.5));
}
예제 #7
0
uint32_t
UanHeaderRcData::Deserialize (Buffer::Iterator start)
{
  Buffer::Iterator rbuf = start;

  m_frameNo = start.ReadU8 ();
  m_propDelay = Seconds ( ((double) start.ReadU16 ()) / 1000.0 );

  return rbuf.GetDistanceFrom (start);
}
예제 #8
0
void
UanHeaderRcRts::Serialize (Buffer::Iterator start) const
{
  start.WriteU8 (m_frameNo);
  start.WriteU8 (m_retryNo);
  start.WriteU8 (m_noFrames);
  start.WriteU16 (m_length);
  start.WriteU32 ((uint32_t)(m_timeStamp.GetSeconds () * 1000.0 + 0.5));
  // start.WriteU16(uint16_t (m_timeStamp.GetSeconds ()*1000));
}
예제 #9
0
 void
 RrepHeader::Serialize (Buffer::Iterator i) const
 {
     i.WriteU8 (m_flags);
     i.WriteU8 (m_prefixSize);
     i.WriteU8 (m_hopCount);
     WriteTo (i, m_dst);
     i.WriteHtonU32 (m_dstSeqNo);
     WriteTo (i, m_origin);
     i.WriteHtonU32 (m_lifeTime);
 }
예제 #10
0
void
UanHeaderRcAck::Serialize (Buffer::Iterator start) const
{
  start.WriteU8 (m_frameNo);
  start.WriteU8 (GetNoNacks ());
  std::set<uint8_t>::iterator it = m_nackedFrames.begin ();
  for (; it != m_nackedFrames.end (); it++)
    {
      start.WriteU8 (*it);
    }
}
예제 #11
0
void
IePerr::SerializeInformationField (Buffer::Iterator i) const
{
  i.WriteU8 (0);
  i.WriteU8 (m_addressUnits.size ());
  for (unsigned int j = 0; j < m_addressUnits.size (); j++)
    {
      WriteTo (i, m_addressUnits[j].destination);
      i.WriteHtolsbU32 (m_addressUnits[j].seqnum);
    }
}
예제 #12
0
 void
 RreqHeader::Serialize (Buffer::Iterator i) const
 {
     i.WriteU8 (m_flags);
     i.WriteU8 (m_reserved);
     i.WriteU8 (m_hopCount);
     i.WriteHtonU32 (m_requestID);
     WriteTo (i, m_dst);
     i.WriteHtonU32 (m_dstSeqNo);
     WriteTo (i, m_origin);
     i.WriteHtonU32 (m_originSeqNo);
 }
예제 #13
0
uint32_t
UanHeaderRcAck::Deserialize (Buffer::Iterator start)
{
  Buffer::Iterator rbuf = start;
  m_frameNo = rbuf.ReadU8 ();
  uint8_t noAcks = rbuf.ReadU8 ();
  m_nackedFrames.clear ();
  for (uint32_t i = 0; i < noAcks; i++)
    {
      m_nackedFrames.insert (rbuf.ReadU8 ());
    }
  return rbuf.GetDistanceFrom (start);
}
예제 #14
0
 void
 RerrHeader::Serialize (Buffer::Iterator i ) const
 {
     i.WriteU8 (m_flag);
     i.WriteU8 (m_reserved);
     i.WriteU8 (GetDestCount ());
     std::map<Ipv4Address, uint32_t>::const_iterator j;
     for (j = m_unreachableDstSeqNo.begin (); j != m_unreachableDstSeqNo.end (); ++j)
     {
         WriteTo (i, (*j).first);
         i.WriteHtonU32 ((*j).second);
     }
 }
Buffer::Iterator
CapabilityInformation::Serialize (Buffer::Iterator start) const
{
  NS_LOG_FUNCTION (this << &start);
  start.WriteHtolsbU16 (m_capability);
  return start;
}
Buffer::Iterator
CapabilityInformation::Deserialize (Buffer::Iterator start)
{
  NS_LOG_FUNCTION (this << &start);
  m_capability = start.ReadLsbtohU16 ();
  return start;
}
예제 #17
0
uint8_t
IePerr::DeserializeInformationField (Buffer::Iterator start, uint8_t length)
{
  Buffer::Iterator i = start;
  i.Next (1); //Mode flags is not used now
  uint8_t numOfDest = i.ReadU8 ();
  NS_ASSERT ((2 + 10 * numOfDest ) == length);
  length = 0; //to avoid compiler warning in optimized builds
  for (unsigned int j = 0; j < numOfDest; j++)
    {
      HwmpProtocol::FailedDestination unit;
      ReadFrom (i, unit.destination);
      unit.seqnum = i.ReadLsbtohU32 ();
      m_addressUnits.push_back (unit);
    }
  return i.GetDistanceFrom (start);
}
bool HTTPServerConnection::readDone() {
//  TicksClock::Ticks start, end, duration;
//  start = TicksClock::getTicks();
  int rc;

  while (true) {
    request_.clear();
    Buffer::Iterator it = in_.begin();
    rc = Parser::parseRequest(&it, &request_);
    if (rc < 0) {
      LOG(LogMessage::ERROR) << "Error parsing request";
//      end = TicksClock::getTicks();
  //    duration = start - end;
    //  double in_seconds = duration / TicksClock::ticksPerSecond();
  //    RequestStats* stats = io_service()->stats();
    //  stats->updateTimeToParse(in_seconds);
      return false;
    } else if (rc > 0) {
    //  end = TicksClock::getTicks();
    //  duration = end - start;
    //  double in_seconds = duration / TicksClock::ticksPerSecond();
     // RequestStats* stats = io_service()->stats();
     // stats->updateTimeToParse(in_seconds);
      return true;

    } else /* rc == 0 */ {
        in_.consume(it.bytesRead());
       if (! handleRequest(&request_)) {
      //  end = TicksClock::getTicks();
      //  duration = end - start;
      //  double in_seconds = duration / TicksClock::ticksPerSecond();
       // RequestStats* stats = io_service()->stats();
       // stats->updateTimeToParse(in_seconds);
        return false;
       }

    }
  }
}
예제 #19
0
bool HTTPServerConnection::readDone() {
  int rc;

  while (true) {
    request_.clear();
    Buffer::Iterator it = in_.begin();
    rc = Parser::parseRequest(&it, &request_);
    if (rc < 0) {
      LOG(LogMessage::ERROR) << "Error parsing request";
      return false;

    } else if (rc > 0) {
      return true;

    } else /* rc == 0 */ {
      in_.consume(it.bytesRead());
      if (! handleRequest(&request_)) {
        return false;
      }
    }
  }
}
예제 #20
0
 uint32_t
 TypeHeader::Deserialize (Buffer::Iterator start)
 {
     Buffer::Iterator i = start;
     uint8_t type = i.ReadU8 ();
     m_valid = true;
     switch (type)
     {
         case AODVTYPE_RREQ:
         case AODVTYPE_RREP:
         case AODVTYPE_RERR:
         case AODVTYPE_RREP_ACK:
         {
             m_type = (MessageType) type;
             break;
         }
         default:
             m_valid = false;
     }
     uint32_t dist = i.GetDistanceFrom (start);
     NS_ASSERT (dist == GetSerializedSize ());
     return dist;
 }
예제 #21
0
uint32_t
UanHeaderRcCtsGlobal::Deserialize (Buffer::Iterator start)
{
  Buffer::Iterator rbuf = start;
  m_rateNum = rbuf.ReadU16 ();
  m_retryRate = rbuf.ReadU16 ();
  m_timeStampTx = Seconds ( ( (double) rbuf.ReadU32 ()) / 1000.0 );
  m_winTime = Seconds ( ( (double) rbuf.ReadU32 ()) / 1000.0 );
  return rbuf.GetDistanceFrom (start);

}
예제 #22
0
uint32_t
UanHeaderRcRts::Deserialize (Buffer::Iterator start)
{
  Buffer::Iterator rbuf = start;
  m_frameNo = rbuf.ReadU8 ();
  m_retryNo = rbuf.ReadU8 ();
  m_noFrames = rbuf.ReadU8 ();
  m_length = rbuf.ReadU16 ();
  m_timeStamp = Seconds ( ((double) rbuf.ReadU32 ()) / 1000.0 );
  // m_timeStamp = Seconds ( rbuf.ReadU16 ()/1000 );
  return rbuf.GetDistanceFrom (start);
}
예제 #23
0
uint32_t
UanHeaderRcCts::Deserialize (Buffer::Iterator start)
{
  Buffer::Iterator rbuf = start;
  m_address = UanAddress (rbuf.ReadU8 ());
  m_frameNo = rbuf.ReadU8 ();
  m_retryNo = rbuf.ReadU8 ();
  m_timeStampRts = Seconds ( ( (double) rbuf.ReadU32 ()) / 1000.0 );
  m_delay = Seconds ( ( (double) rbuf.ReadU32 ()) / 1000.0 );

  return rbuf.GetDistanceFrom (start);
}
예제 #24
0
        uint32_t
        RrepHeader::Deserialize (Buffer::Iterator start)
        {
            Buffer::Iterator i = start;

            m_flags = i.ReadU8 ();
            m_prefixSize = i.ReadU8 ();
            m_hopCount = i.ReadU8 ();
            ReadFrom (i, m_dst);
            m_dstSeqNo = i.ReadNtohU32 ();
            ReadFrom (i, m_origin);
            m_lifeTime = i.ReadNtohU32 ();

            uint32_t dist = i.GetDistanceFrom (start);
            NS_ASSERT (dist == GetSerializedSize ());
            return dist;
        }
예제 #25
0
        uint32_t
        RerrHeader::Deserialize (Buffer::Iterator start )
        {
            Buffer::Iterator i = start;
            m_flag = i.ReadU8 ();
            m_reserved = i.ReadU8 ();
            uint8_t dest = i.ReadU8 ();
            m_unreachableDstSeqNo.clear ();
            Ipv4Address address;
            uint32_t seqNo;
            for (uint8_t k = 0; k < dest; ++k)
            {
                ReadFrom (i, address);
                seqNo = i.ReadNtohU32 ();
                m_unreachableDstSeqNo.insert (std::make_pair (address, seqNo));
            }

            uint32_t dist = i.GetDistanceFrom (start);
            NS_ASSERT (dist == GetSerializedSize ());
            return dist;
        }
예제 #26
0
uint32_t
PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
{
  Buffer::Iterator i = start;
  NS_ASSERT (m_subtype < 3);
  {
    uint8_t id = i.ReadU8 ();
    uint8_t length = i.ReadU8 ();
    m_protocol.DeserializeInformationField (i, length);
    if ((m_protocol.ElementId () != (WifiInformationElementId) id) || (m_protocol.GetInformationFieldSize () != length))
      {
        NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
      }
    i.Next (m_protocol.GetInformationFieldSize ());
  }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
    {
      m_capability = i.ReadLsbtohU16 ();
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) == m_subtype)
    {
      m_aid = i.ReadLsbtohU16 ();
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
    {
      i = m_rates.Deserialize (i);
      i = m_rates.extended.DeserializeIfPresent (i);
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CONFIRM) != m_subtype)
    {
      uint8_t id = i.ReadU8 ();
      uint8_t length = i.ReadU8 ();
      m_meshId.DeserializeInformationField (i, length);
      if ((m_meshId.ElementId () != (WifiInformationElementId) id) || (m_meshId.GetInformationFieldSize () != length))
        {
          NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
        }
      i.Next (m_meshId.GetInformationFieldSize ());
    }
  if ((uint8_t)(WifiActionHeader::PEER_LINK_CLOSE) != m_subtype)
    {
      uint8_t id = i.ReadU8 ();
      uint8_t length = i.ReadU8 ();
      m_config.DeserializeInformationField (i, length);
      if ((m_config.ElementId () != (WifiInformationElementId) id) || (m_config.GetInformationFieldSize () != length))
        {
          NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
        }
      i.Next (m_config.GetInformationFieldSize ());
    }
  else
    {
      m_reasonCode = i.ReadLsbtohU16 ();
    }
  return i.GetDistanceFrom (start);
}
void
IeLinkMetricReport::SerializeInformationField (Buffer::Iterator i) const
{
  i.WriteHtolsbU32 (m_metric);
}
예제 #28
0
void
UanHeaderRcData::Serialize (Buffer::Iterator start) const
{
  start.WriteU8 (m_frameNo);
  start.WriteU16 ( (uint16_t)(1000.0 * m_propDelay.GetSeconds () + 0.5));
}
예제 #29
0
 void
 RrepAckHeader::Serialize (Buffer::Iterator i ) const
 {
     i.WriteU8 (m_reserved);
 }
예제 #30
0
 void
 TypeHeader::Serialize (Buffer::Iterator i) const
 {
     i.WriteU8 ((uint8_t) m_type);
 }