Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void PacketHandler::onPacketPI(const g2::Packet& pk, ip::Endpoint ep, ip::protocol::Type proto)
- {
- verb2::g2 << "Got ping from " << ep << std::endl;
- g2::Reader r(pk);
- bool bUdp = false;
- bool bRelay = false;
- ip::Endpoint to;
- while (r.next())
- {
- if(r.type() == g2::UDP)
- {
- g2::Reader rudp(r.child(), g2::Reader::payload);
- to.address = rudp.pod<uint32>();
- to.port = rudp.pod<uint16>();
- if( !to.empty() )
- {
- bUdp = true;
- }
- }
- else if (r.type() == g2::RELAY)
- {
- bRelay = true;
- }
- }
- if(!bUdp && !bRelay)
- {
- // Direct Ping
- g2::Packet po;
- g2::Writer w(po);
- w.Begin( g2::PO );
- w.Close( g2::PO );
- manager_.transceiver()->send(ep, po);
- }
- if(bUdp && !bRelay)
- {
- // /PI/UDP
- // TODO: Relay UDP pings if neighbour is G2 HUB
- }
- if(bUdp && bRelay)
- {
- g2::Packet po;
- g2::Writer w(po);
- w.Begin( g2::PO );
- w.Begin( g2::RELAY );
- w.Close( g2::RELAY );
- w.Close( g2::PO );
- manager_.transceiver()->send(to, po);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement