M1-nw-project/packetParser.h

32 lines
838 B
C
Raw Normal View History

2016-11-24 14:39:03 +01:00
/***************************************************************************
* By Théophile Bastian, 2017
* M1 Network course project at ENS Cachan, Juliusz Chroboczek.
* License: WTFPL v2 <http://www.wtfpl.net/>
**************************************************************************/
#pragma once
#include "neighbours.h"
#include "protocol.h"
2016-11-26 16:20:20 +01:00
#include "dataStore.h"
2016-11-24 14:39:03 +01:00
class PacketParser {
public:
2016-11-26 16:20:20 +01:00
PacketParser(Neighbours* nei, Protocol* proto, DataStore* dataStore);
2016-11-24 14:39:03 +01:00
2016-11-26 16:20:20 +01:00
void parse(Bytes pck, const SockAddr& addr);
2016-11-24 14:39:03 +01:00
private: //meth
2016-11-26 16:20:20 +01:00
void readTLV(Bytes& pck, u64 nei, const SockAddr& addr);
void receiveNeigh(Bytes& pck);
void receiveData(Bytes& pck, u64 from);
void receiveIHave(Bytes& pck, u64 from);
void handleNR(u64 from);
2016-11-24 14:39:03 +01:00
private:
Neighbours* neighbours;
Protocol* protocol;
2016-11-26 16:20:20 +01:00
DataStore* dataStore;
2016-11-24 14:39:03 +01:00
};