31 lines
838 B
C++
31 lines
838 B
C++
/***************************************************************************
|
|
* 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"
|
|
#include "dataStore.h"
|
|
|
|
class PacketParser {
|
|
public:
|
|
PacketParser(Neighbours* nei, Protocol* proto, DataStore* dataStore);
|
|
|
|
void parse(Bytes pck, const SockAddr& addr);
|
|
|
|
private: //meth
|
|
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);
|
|
|
|
private:
|
|
Neighbours* neighbours;
|
|
Protocol* protocol;
|
|
DataStore* dataStore;
|
|
};
|
|
|