#include <gossip.h>
Inheritance diagram for CGossip:
Public Member Functions | |
virtual | ~CGossip () |
void | NotifyApp (const std::string &sFileName, uint8_t filetype, uint8_t relatedModule) |
int | GetTransactionLog (std::string &transList) const |
int | FindMissingGossip (const std::string &sTransList, std::string &sMissingList) const |
int | SendMissingGossip (const std::string &sMissingList, uint32_t ip, uint16_t port) |
Static Public Member Functions | |
static CGossip * | getGossipInstance (std::string) |
Private Types | |
typedef std::deque< CFileTransfer * > | FileTransfer |
Private Member Functions | |
CGossip (std::string sFileName) | |
void | ProcessGossipPacket (const GossipPacket &gPack, uint32 ip, uint16 port, size_t length) |
int | SendGossipPacket (const GossipPacket &packet, int pktLen, uint32_t destinationHost, uint16_t destinationPort) |
void | OnPacketReceived (uint32 ip, uint16 port, byte *buffer, size_t length) |
int | OnCommandReceived (int iFd) |
int | SendCommand (const GossipPacket &gPack, int len, uint32_t srcIP, uint16_t srcPort) |
int | SendTcpCommand (const std::string &sFileToSend, const boost::uuids::uuid &Tag, uint32_t srcIP, uint16_t srcPort) |
int | SendCommand (const std::string &sCommand, bool bTcp=false, uint8_t module=MODULE_GOSSIP) |
int | NotifyCommand (const std::string &) |
int | GetTransactionID (const std::string &sFile, boost::uuids::uuid &id) |
int | SendTcpGossipPacket (const std::string &sFileName, uint32_t destinationHost, uint16_t destinationPort) |
void | ProcessTcpGossipPacket (const std::string &sFileName, uint32 ip, uint16 port, uint8_t module) |
std::string | CopyFileToTmpDir (const std::string &sFile) |
int | GetKadBootstrapInfo (int iServerIP, int iPort) |
int | DoTransactionLog (const boost::uuids::uuid &Tag, const std::string &sFileName) |
std::string | BackupFileToDownloadDir (const std::string &sFile, const boost::uuids::uuid &Tag) |
int | SendMissingGossip (const boost::uuids::uuid &Tag, uint32_t ip, uint16_t port) |
Private Attributes | |
MapFwHist | mFwHist |
MapFwHist | mRecvHist |
FileTransfer | m_gfiletrans |
CBootStrapClient * | m_pBootStrapClient |
std::deque< TransactionLog > | m_qTransactionLog |
Static Private Attributes | |
static bool | bInstance = false |
static CGossip * | instance = NULL |
CGossip::~CGossip | ( | ) | [virtual] |
CGossip Destructor.
CGossip::CGossip | ( | std::string | sFileName | ) | [private] |
CGossip Constructor; Takes configuration file name as its argument. It is private due to make the class as a singleton pattern.
int CGossip::DoTransactionLog | ( | const boost::uuids::uuid & | Tag, | |
const std::string & | sFileName | |||
) | [private] |
After receiving or sending any TCP Gossip message, the message id, time and the file name is saved so that id list can be sent to the neighbor in PING message.
int CGossip::FindMissingGossip | ( | const std::string & | sTransList, | |
std::string & | sMissingList | |||
) | const |
From the KAD PING message, this method is used to find if the node missed any gossip message.
CGossip * CGossip::getGossipInstance | ( | std::string | ) | [static] |
This method is used to get an instance of CGossip class. It is used to make this architecture as a singleton pattern.
int CGossip::GetKadBootstrapInfo | ( | int | iServerIP, | |
int | iPort | |||
) | [private] |
Invokes Bootstrap Client for getting bootstrap IP and port.
int CGossip::GetTransactionID | ( | const std::string & | sFile, | |
boost::uuids::uuid & | id | |||
) | [private] |
Get the transaction id as UUID from sFile. sFile is supposed to be in SMIME format and id should be found in "FROM:" field.
int CGossip::GetTransactionLog | ( | std::string & | transList | ) | const |
It is used to get the log of already received Gossip Message Transaction ID to attached in the KAD PING message.
void CGossip::NotifyApp | ( | const std::string & | sFileName, | |
uint8_t | filetype, | |||
uint8_t | relatedModule | |||
) | [virtual] |
Overrides the functionality of NotifyApp of CKadInterface to send EventMessage to the Policy Component.
Reimplemented from CKadInterface.
int CGossip::NotifyCommand | ( | const std::string & | ) | [private] |
This actually sends data to the Policy Component.
int CGossip::OnCommandReceived | ( | int | iFd | ) | [private, virtual] |
This method is invoked after receiving EventMessage from Policy Component.
Reimplemented from CKadInterface.
void CGossip::OnPacketReceived | ( | uint32 | ip, | |
uint16 | port, | |||
byte * | buffer, | |||
size_t | length | |||
) | [private] |
This method is invoked after receiving any Kademlia message.
void CGossip::ProcessGossipPacket | ( | const GossipPacket & | gPack, | |
uint32 | ip, | |||
uint16 | port, | |||
size_t | length | |||
) | [private] |
Process any received UDP Gossip Message.
void CGossip::ProcessTcpGossipPacket | ( | const std::string & | sFileName, | |
uint32 | ip, | |||
uint16 | port, | |||
uint8_t | module | |||
) | [private, virtual] |
Process any received TCP Gossip Message.
Reimplemented from CKadInterface.
int CGossip::SendCommand | ( | const std::string & | sCommand, | |
bool | bTcp = false , |
|||
uint8_t | module = MODULE_GOSSIP | |||
) | [private] |
Sends a gossip message in the network.
int CGossip::SendCommand | ( | const GossipPacket & | gPack, | |
int | len, | |||
uint32_t | srcIP, | |||
uint16_t | srcPort | |||
) | [private] |
It sends a UDP Gossip Message.
int CGossip::SendGossipPacket | ( | const GossipPacket & | packet, | |
int | pktLen, | |||
uint32_t | destinationHost, | |||
uint16_t | destinationPort | |||
) | [private] |
Send a gossip message using UDP protocol.
int CGossip::SendMissingGossip | ( | const boost::uuids::uuid & | Tag, | |
uint32_t | ip, | |||
uint16_t | port | |||
) | [private] |
If a neighbor sends a gossip message ID in PONG message, the message is sent to the neighbor.
int CGossip::SendMissingGossip | ( | const std::string & | sMissingList, | |
uint32_t | ip, | |||
uint16_t | port | |||
) |
If any missing Gossip Message is found, the transaction is written in the KAD PONG message to retrieve it.
int CGossip::SendTcpCommand | ( | const std::string & | sFileToSend, | |
const boost::uuids::uuid & | Tag, | |||
uint32_t | srcIP, | |||
uint16_t | srcPort | |||
) | [private] |
It sends a TCP Gossip Message. Tag is used as a unique ID for this gossip message.
int CGossip::SendTcpGossipPacket | ( | const std::string & | sFileName, | |
uint32_t | destinationHost, | |||
uint16_t | destinationPort | |||
) | [private] |
Sends a gossip message over TCP transport protocol.