📄 listenmanager.hh
字号:
#ifndef LISTENMANAGER_HH#define LISTENMANAGER_HHCLICK_DECLS#include <click/element.hh>#include <click/bighashmap.hh>#include <click/packet.hh>#include <click/timestamp.hh>#include <click/vector.hh>#include <click/string.hh>#include <click/straccum.hh>#include <map>#include <ext/slist>#include "guessmanager.hh"#include "common.hh"#define EVENT_NONE 0#define EVENT_EXPIRE 2class ListenManager : public Element {public: ListenManager(); ~ListenManager(); const char *class_name() const { return "ListenManager"; } int configure(Vector<String> &, ErrorHandler *); void *cast(const char *n); void add_handlers(); static int enable_recps(const String &arg, Element *e, void *, ErrorHandler *errh); void set_enable_recps(bool ea) {_enable_recps = ea;} bool register_packet_to_recp(Packet *, uint32_t); WritablePacket* get_recps(bool, int); uint32_t get_next_recp_time(); Packet* get_packet(PacketRID); void add_new_packet(Packet *, uint32_t); GuessManager *_guessmgr; private: class RecpState { public: uint16_t _id; bool _recped; uint32_t _timeout; RecpState() : _id(0), _recped(0), _timeout(0) {}; RecpState(uint16_t id, bool recped, uint32_t to) : _id(id), _recped(recped), _timeout(to) {} RecpState(uint16_t id, uint32_t now) : _id(id), _recped(0), _timeout(now) {} }; class SrcState { public: IPAddress _src; uint32_t _nrecps; SrcState(IPAddress src, int nrecps) : _nrecps(nrecps) { _src = IPAddress(src.addr()); } SrcState(IPAddress src) : _nrecps(1) { _src = IPAddress(src.addr()); } }; class RecpUnit { public: IPAddress _src; uint16_t _id; uint8_t _bmp; RecpUnit(IPAddress src, uint16_t id, uint8_t bmp) : _id(id), _bmp(bmp) { _src = IPAddress(src.addr()); } }; // Hash Table for packets overheard class PacketState { public: Packet *_p; // the actual packet PacketState() : _p(0) {}; PacketState(Packet *p) : _p(p) {}; }; class Event { public: char _event_type; PacketRID _pid; Event() : _event_type(EVENT_NONE) {} Event(char e, const PacketRID &pid) : _event_type(e), _pid(pid) {} }; typedef __gnu_cxx::slist<Event> EventList; // stores a map of time to list of events at that time typedef std::map<int32_t, EventList *> EventMap; EventMap _eventmap; // keep track of packets I have overheard typedef HashMap<PacketRID, PacketState *> OverheardPackets; OverheardPackets _ovhdpacks; typedef Vector<RecpUnit> RecpVector; // Vector used to make reception report packet typedef __gnu_cxx::slist<RecpState *> RecpStateList; // List of packets to send reception reports about typedef __gnu_cxx::slist<SrcState *> SrcStateList; // List of nodes from which I have overheard packets typedef HashMap <IPAddress, RecpStateList *> PendingRecps; // Pending Reception reports organised by source of packet typedef std::map<uint32_t, SrcStateList *> TimeoutList; // Hash map containig timestamp by which information about packets overheard has to be sent out typedef HashMap<IPAddress, uint8_t> SrcList; // Keeping track of which sources to send reception reportsd about, temp data structure PendingRecps _pending; TimeoutList _timedout; EtherAddress _myea; uint32_t _recp_timeout; uint32_t _expire_timeout; uint32_t _max_recps; bool _enable_recps; uint16_t _enc_ethtype; void fwd_packet(Packet *p); void update_timeout_list(uint32_t, IPAddress); RecpVector* get_recps_timeout(uint32_t, SrcList &); WritablePacket *make_packet(RecpVector *); void flush_expired(); void check_packet(Packet*);};CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -