Ejemplo n.º 1
0
// special serialization function with the ability to omit the TLV header
void querycookie::serializeEXT(NetMsg& msg, coding_t cod, uint32& wbytes, bool header) const {
    uint32 ielen = get_serialized_size(cod); //+header_length;
    
        // check arguments and IE state
	check_ser_args(cod,wbytes);
	//DLog("querycookie::serialize()", "Bytes left in NetMsg: " << msg.get_bytes_left());
	//Log(ERROR_LOG,LOG_NORMAL, "mri_pathcoupled::serialize()","should be of length" << ielen);

        // calculate length and encode header
	encode_header_ntlpv1(msg,get_serialized_size(cod)-4);
	


	uint32 position = msg.get_pos();
	// copy data into our buffer, padding is of no concern
	msg.copy_from(buf, position, buf_length);

	
	
	msg.set_pos_r(round_up4(buf_length));

	wbytes = ielen;
	
	//ostringstream tmpostr;
	//msg.hexdump(tmpostr,0,wbytes);
	//Log(DEBUG_LOG,LOG_NORMAL, "querycookie_serialize", "netmsg pos:" << msg.get_pos() << " netmsg:" << tmpostr.str().c_str());
    return;
} // end serialize
Ejemplo n.º 2
0
querycookie* 
querycookie::deserializeEXT(NetMsg& msg, coding_t cod, IEErrorList& errorlist, uint32& bread, bool skip, bool header) {
	
    uint16 len = 0;
    uint32 ielen = 0;
    uint32 saved_pos = 0;
    uint32 resume = 0;
    

    // check arguments
    if (!check_deser_args(cod,errorlist,bread)) 
	return NULL;
    // decode header
    if (!decode_header_ntlpv1(msg,len,ielen,saved_pos,resume,errorlist,bread,skip)) 
	return NULL;
    
    // check length
    
    // THIS IS IMPOSSIBLE!!! THERE IS NO LENGTH VALUE TO CHECK AGAINST!!!! MRI IS VARIABLE LENGTH!!
    /*if (len!=contlen) 
    {
	// wrong length
	error_wrong_length(cod,len,saved_pos,skip,errorlist,resume,msg);
	return NULL;
    } // end if wrong length
    

    */

    // initialize our buffer (ielen in words)
    buf = new(nothrow) uchar[len];

    // get msg position pointer
    uint32 position = msg.get_pos();
    
    // copy data into our buffer, padding is of no concern
    msg.copy_to(buf, position, len);
    
    buf_length=len;

    msg.set_pos_r(round_up4(buf_length));

    // There is no padding.
    bread = ielen;

    //check for correct length
    if (ielen != get_serialized_size(cod)) {

	ERRCLog("QueryCookie", "Incorrect Object Length Error");
	errorlist.put(new GIST_IncorrectObjectLength(protocol_v1, this));
    }




    return this;
} // end deserialize
Ejemplo n.º 3
0
size_t DFS::deserialize(char *buffer, size_t buffer_size)
{
  if(buffer_size < get_serialized_size()) throw runtime_error("Buffer too small");
  int *buf = (int*) buffer;
  from = buf[0];
  to = buf[1];
  fromlabel = buf[2];
  elabel = buf[3];
  tolabel = buf[4];
  return 5 * sizeof(int);
}
Ejemplo n.º 4
0
size_t DFSCode::deserialize(char *buffer, size_t buffer_size)
{
  if(get_serialized_size(buffer, buffer_size) == 0) return sizeof(int);
  clear();

  int elements = *((int*)buffer);
  size_t read = sizeof(int);

  for(int i = 0; i < elements; i++) {
    DFS d;
    size_t tmp = d.deserialize(buffer + read, buffer_size - read);
    read += tmp;
    push_back(d);
  } // for i
  return read;
} // DFSCode::deserialize
Ejemplo n.º 5
0
size_t DFSCode::serialize(char *buffer, size_t buffer_size) const
{
  if(buffer_size < get_serialized_size()) throw runtime_error("Buffer too small.");

  char *buf = buffer;
  size_t stored = 0;

  // store dfs code element count
  *((int*)(buf + stored)) = size();
  stored += sizeof(int);

  // store each dfs element
  for(int i = 0; i < size(); i++) {
    size_t tmp = at(i).serialize(buf + stored, buffer_size - stored);
    stored += tmp;
  } // for i

  return stored;
} // DFSCode::serialize