Пример #1
0
frame::frame(buffer_sptr buf) :
   buf_(buf)
{
   const size_t min_frame_sz = 10; // sizeof(ACK_frame)
   if(buf->data_size() < min_frame_sz) {
      ostringstream msg;
      msg << "frame too small (" << buf->data_size() << " <= " << min_frame_sz << " octets)";
      msg << hex << setw(2) << setfill('0') << dump(buf->data_size(), buf->data()) << endl;
      raise<length_error>(__PRETTY_FUNCTION__, __FILE__, __LINE__, msg.str());
   }
}
Пример #2
0
data_frame::data_frame(buffer_sptr buf) :
   frame(buf)
{
   const size_t min_data_frame_sz = 24;
   if(buf->data_size() < min_data_frame_sz) {
      ostringstream msg;
      msg << "data frame too small (" << buf->data_size() << " <= " << min_data_frame_sz << " octets)";
      msg << hex << setw(2) << setfill('0') << dump(buf->data_size(), buf->data()) << endl;
      raise<invalid_argument>(__PRETTY_FUNCTION__, __FILE__, __LINE__, msg.str());
   }
}
Пример #3
0
uint8_t
mgmt_frame::IE(uint8_t tag) const
{
   uint8_t tag_size;
   size_t frame_sz = buf_->data_size();
   for(size_t i = 0x24; i < frame_sz; i += tag_size) {
      const uint8_t t = buf_->read_u8(i);
      const uint8_t l = buf_->read_u8(i+1);
      if(t == tag && l == 1) {
         return buf_->read_u8(i+2);
      }
      tag_size = l + 2;
   }
   ostringstream msg;
   msg << "unknown IE  (tag=" << hex << setw(2) << setfill('0') << tag << ")";
   msg << hex << setw(2) << setfill('0') << dump(buf_->data_size(), buf_->data()) << endl;
   raise<invalid_argument>(__PRETTY_FUNCTION__, __FILE__, __LINE__, msg.str());
}