示例#1
0
	bool bin_index_t::dir_node::next(data_t& key,data_t& val) const
	{
		validate_key_len(key);
		validate_index();
		
		data_t head(key.begin(),key.begin()+parent.dir_key_len);
		data_t tail(key.begin()+parent.dir_key_len,key.end());

		datas_t::const_iterator it=std::lower_bound(indexes.begin(),indexes.end(),head,data_less_pr());
		if(it==indexes.end())return false;

		if(*it==head)
		{
			validate_sub(head);
			if(sub_node->next(tail,val))
			{
				key=head;
				key.insert(key.end(),tail.begin(),tail.end());
				return true;
			}
		}

		++it;
		if(it==indexes.end())return false;
		head=*it;

		validate_sub(head);
		if(!sub_node->first(tail,val))return false;

		key=head;
		key.insert(key.end(),tail.begin(),tail.end());
		return true;
	}
示例#2
0
 void CTCPProfile::Compress(const data_t &data, data_t &output) {
     size_t outputInSize = output.size();
     const iphdr* ip = reinterpret_cast<const iphdr*>(&data[0]);
     const tcphdr* tcp = reinterpret_cast<const tcphdr*>(ip+ip->ihl*4);
     
     UpdateIpIdOffset(ip);
     
     if (IR_State == state)
     {
         CreateIR(ip, tcp, output);
     }
     else
     {
         CreateCO(ip, tcp, output);
     }
     
     UpdateIpInformation(ip);
     
     AdvanceState(false, false);
     increaseMsn();
     // Append payload
     // TODO, handle TCP options
     output.insert(output.end(), data.begin() + sizeof(iphdr) + sizeof(tcphdr), data.end());
     
     ++numberOfPacketsSent;
     dataSizeCompressed += output.size() - outputInSize;
     dataSizeUncompressed += data.size();
     
 }
示例#3
0
 void
 DUncompressedProfile::ParseCO(uint8_t packetTypeIndication, data_t &data, data_iterator pos, data_t &output)
 {
     // pti is first byte of IP
     output.push_back(packetTypeIndication);
     // data contains the rest
     output.insert(output.end(), pos, data.end());
     ++numberOfPacketsReceived;
     dataSizeCompressed += distance(pos, data.end()) + 1;
     dataSizeUncompressed += distance(pos, data.end()) + 1;
 }
示例#4
0
	bool bin_index_t::dir_node::first(data_t& key,data_t& val) const
	{
		validate_index();

		if(indexes.empty())return false;

		const data_t& head=indexes.front();
		validate_sub(head);

		data_t tail;
		if(!sub_node->first(tail,val))return false;
		
		key=head;
		key.insert(key.end(),tail.begin(),tail.end());

		return true;
	}