📄 slp-ua.h
字号:
#include "slp/slp-common.h"extern u_int16_t G_Xid;extern RNG G_arrival;class SLPua;class rqstHashTable;class rqstNode;class urlNode;class reReqTimer : public TimerHandler { public: reReqTimer(SLPua* s, double i, nsaddr_t a, const char* r, int m) : TimerHandler() { s_=s; i_=i; a_=a; r_=strdup(r); m_=m; if (m==REG) resched(i); else if (m==EXP) resched(G_arrival.exponential(i)); } inline virtual void expire(Event*); protected: SLPua* s_; double i_; nsaddr_t a_; const char* r_; int m_; }; class urlCacheTimer : public TimerHandler { public: urlCacheTimer(SLPua* s, urlNode* n, double timeout) : TimerHandler(), s_(s), n_(n) { sched(timeout); } inline virtual void expire(Event*); protected: SLPua* s_; urlNode * n_; }; class urlNode { public: hdr_slp_url data; urlNode* next; urlCacheTimer expireTimer; urlNode (SLPua* s, double timeout) : expireTimer(s, this, timeout) {} };class retxTimer : public TimerHandler { public: retxTimer(rqstHashTable* h, rqstNode* n) : TimerHandler(), h_(h), n_(n) {} inline virtual void expire(Event*); protected: rqstHashTable* h_; rqstNode * n_; };class rqstNode{ public: u_int16_t xid; int number_of_pr; int local_pr[SLP_MAX_PRLIST]; char msg[sizeof(hdr_slp_srvrqst)];// buffered pkt (used for retx) ns_addr_t dest; double timeout; // retrasmission timeout double expire; // retransmissions end here double cache_lifetime; // cache lifetime rqstNode *next; // next in the bucket bool retxok; // enable retransmissions bool gotreply; retxTimer retx_timer_; rqstNode(rqstHashTable *h) : retx_timer_(h, this) {}}; class rqstHashTable {private: int tablesize; rqstNode* *table; SLPua* s_; int hash(u_int16_t xid) const; void add_local_pr(rqstNode* c, int newaddress); char * get_local_pr(const rqstNode* c) const;public: rqstHashTable(SLPua* s); void cancel_retx(u_int16_t xid); void add_pr(u_int16_t xid, int newaddress); char * get_pr(u_int16_t xid) const; void add_resched_send(u_int16_t xid, int size, const char* mssg , ns_addr_t dst); void update_resched_resend(rqstNode* n); void remove_from_table (u_int16_t xid);};// SLP UA Class Definitionclass SLPua : public Application { friend class rqstHashTable; friend class urlCacheTimer; friend class reReqTimer; public: SLPua();protected: int command(int argc, const char*const* argv); void start(); // Start sending data packets (Sender) void stop(); // Stop sending data packets (Sender)private: void init(); virtual void recv_slpmsg(ns_addr_t src, int nbytes, const char *msg = 0); void add_scope(const char * newscope); void remove_scope(const char * removescope); void xid_seed(void); u_int16_t xid_generate(void); void printReply(hdr_slp_srvrply* rply); void send_srvrqst_pkt(const char* service_type, nsaddr_t destaddr); void cache_url(u_int16_t url_entry_count, const char* url); bool search_cached_urls(const char* service_type); void remove_cached_url(urlNode *removeurl); void discover_scopes(const char* scope_list, u_int16_t length_scope); char * get_local_scopes() const; int pktsize_; int32_t dstport_; int maxSearch_; int running_; int number_of_scopes_; char * local_scopes_[SLP_MAX_SCOPE]; rqstHashTable rqstTable_; urlNode * url_head;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -