00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 #ifndef __CORE_PEER_H__
00038 #define __CORE_PEER_H__
00039 
00040 #include "global.h"
00041 
00042 namespace tacpp {
00043 
00044 #define PEERMASK_LEN    64
00045 
00051 class Peer_mask {
00054   pthread_mutex_t mutex_;
00057   void lock();
00060   void unlock();
00063   string mask_;
00064  public:
00067   string getMask();
00070   void setMask(string);
00073   bool check(const char*);
00076   Peer_mask(const char*);
00079   ~Peer_mask();
00080 };
00081 
00087 class Peer_data {
00090   pthread_mutex_t mutex_;
00093   void lock();
00096   void unlock();
00099   list<Peer_mask*> mask_;
00102   string descr_;
00105   string key_;
00108   ipaddr peerhost_;
00111   unsigned int port_;
00112  public:
00115   void setDescr(string);
00118   string getDescr();
00121   void setKey(string);
00124   string getKey();
00127   void setPeerhost(ipaddr);
00130   ipaddr getPeerhost();
00133   void setPort(unsigned int);
00136   unsigned int getPort();
00139   Peer_data(ipaddr,int);
00142   ~Peer_data();
00145   string buildcfstr();
00148   bool check_by_mask(const char*);
00151   void add_mask(const char*);
00154   void del_mask(const char*);
00155 };
00156 
00162 class CorePeer : public Core_data {
00165   list<Peer_data*> pd_;
00168   pthread_mutex_t mutex_;
00171   void lock();
00174   void unlock();
00175  public:
00178   CorePeer(const string,const string);
00181   ~CorePeer();
00184   void add(ipaddr,unsigned int);
00187   void del(ipaddr,unsigned int);
00190   void add_mask(ipaddr,unsigned int,const char*);
00193   void del_mask(ipaddr,unsigned int,const char*);
00196   void modify_des(ipaddr,unsigned int,const char*);
00199   void modify_key(ipaddr,unsigned int,const char*);
00202   string buildcfstr(int);
00205   string applycf(char * const*mask,const string cmdname,const list<string>paramList,Command * cmd=NULL)throw (CmdErr);
00206 };
00207 
00208 };
00209 
00210 #endif // __CORE_PEER_H__