Exemplo n.º 1
0
TEST_F(PcapTest, Write) {
  typedef PcapFileComparator::Status Status;

  PcapFilesReader reader(false, 0);
  reader.addFile(0, getFile1());
  reader.addFile(1, getFile2());
  reader.set_packet_handler(packet_handler, (void*)this);

  PcapFilesWriter writer;
  setReceiver(&writer);
  // only write packets for port 0, drop packets for port 1
  writer.addFile(0, getTmpFile());

  reader.start();
  setReceiver(nullptr);

  PcapFileComparator comparator(false);
  Status comparison = comparator.compare(getFile1(), getTmpFile());
  ASSERT_EQ(Status::OK, comparison);
}
Exemplo n.º 2
0
void ccPacketHandler::buildDetectedNodePacket(byte sender, byte neighbourID)
{
    clearPacket(); 

    setReceiver(SERVER_01); 

    setSender(sender); 

    setAdminKey(NEAR_NODE_EVENT);

    setNeighbourId(neighbourID);

    setBuildCounter(4); 
}
void ccPacketHandler::buildPacket(byte receiver, byte sender, byte adminKey) 

{

    clearPacket(); /// clear existing ccPacket

    setReceiver(receiver); /// set given receiver

    setSender(sender); /// set sender

    setAdminKey(adminKey); /// set given administration key

    setBuildCounter(3); /// set build counter to next free byte's position

}
Exemplo n.º 4
0
void ccPacketHandler::buildPacket(byte receiver, byte sender, byte adminKey) 

{

    clearPacket(); 

    setReceiver(receiver); 

    setSender(sender); 

    setAdminKey(adminKey); 

    setBuildCounter(3); 

}
void ccPacketHandler::buildRSSIPacket(byte sender, byte rawRSSI, byte neighbourID)
{
    clearPacket(); /// clear the packet

    setReceiver(SERVER_01); 

    setSender(sender); 

    setAdminKey(NEAR_NODE_EVENT);

    setDetectedRSSI(rawRSSI);

    setNeighbourId(neighbourID);

    setBuildCounter(5); /// set build counter to next free byte's position    
}
Exemplo n.º 6
0
void ccPacketHandler::buildPatternCommand(byte receiver, byte PatternKey, byte colorKey1, byte colorKey2)
{
    clearPacket(); 

    setReceiver(receiver);

    setSender(SERVER_01);
 
    setAdminKey(PatternKey);   
 
    setFirstColor(colorKey1);

    setSecondColor(colorKey2);

    setBuildCounter(5); 

}
void ccPacketHandler::testPacket(byte receiver, byte sender)

{

    for (byte i = 0; i < _ccPacket.length; ++i) /// fill packet with zeros

    {

        _ccPacket.data[i] = i; /// set i-th byte := i for each byte in the packet

    }

    setReceiver(receiver); /// setting receiver

    setSender(sender); /// setting sender

    setAdminKey(TEST); /// setting administration key - default := 255

    setHash(ccHash()); /// hashing the data and saving in member _hash

}
void ccPacketHandler::acknowledge()

{

    byte sender = getPacketSender(); /// save sender

    byte receiver = getPacketReceiver(); /// save receiver

    byte ulf = ccHash(); /// hash the data

    clearPacket(); /// clear the packet

    setReceiver(sender); /// set sender as receiver

    setSender(receiver); /// set receiver as sender

    setAdminKey(ACKNOWLEDGE_REQUEST); /// set acknowlegde key

    setPackNum(ulf); /// set the hash as data

}
void Message::toMessage(string msg) {
	/* local variables */
	int i, len, x;
	string temp = "";
	time_t t_temp;
	
	/* algorithm */
	if (msg[0]=='4') {
		i = 2;
		len = msg.length();
		//sender
		temp = getSubstr(msg, i, ';');
		setSender(temp);
		temp = "";
		//receiver
		i++;
		temp = getSubstr(msg, i, ';');
		setReceiver(temp);
		temp = "";
		//timestamp
		i++;
		temp = getSubstr(msg, i, ';');
		istringstream buffer(temp);
		int x;
		buffer >> x;
		t_temp = x;
		setTimestamp(t_temp);
		temp = "";
		//message body
		i++;
		temp = getSubstr(msg, i, ';');
		text = temp;
		temp = "";
		//type
		i++;
		temp = getSubstrInt(msg, i, len);
		type = temp;
	}