Main Page | Class Hierarchy | Class List | File List | Class Members

CorePeer.h

00001 // This is part of tacppd project (extended tacacs++ server)
00002 // (c) Copyright in 2000-2004 by tacppd team and contributors
00003 // see http://tacppd.org for more information
00004 //
00005 // file: CorePeer.h
00006 // description: rouming peers
00007 
00008 //  This program is free software; you can redistribute it and/or modify
00009 //  it under the terms of the GNU General Public License as published by
00010 //  the Free Software Foundation; either version 2 of the License, or
00011 //  (at your option) any later version.
00012 //
00013 //  This program is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //  GNU General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU General Public License
00019 //  along with this program; if not, write to the Free Software
00020 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 // modifications:
00023 //
00024 
00025 // all comments which start from /** - this is comments for KDoc
00026 //  for classes
00027 //    @short [short description of the class]
00028 //    @author [class author]
00029 //    @version [class version]
00030 //    @see [references to other classes or methods]
00031 //  for methods
00032 //    @see [references]
00033 //    @return [sentence describing the return value]
00034 //    @exception [list the exeptions that could be thrown]
00035 //    @param [name id] [description]    - can be multiple
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__

Generated on Thu Jul 21 23:09:45 2005 for tacppd.kdevelop by doxygen 1.3.5