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

CoreDevice.h

00001 // tacppd network device related information
00002 // (c) Copyright in 2000-2005 by tacppd team and contributors
00003 // see http://tacppd.org for more information
00004 //
00005 //  This program is free software; you can redistribute it and/or modify
00006 //  it under the terms of the GNU General Public License as published by
00007 //  the Free Software Foundation; either version 2 of the License, or
00008 //  (at your option) any later version.
00009 //
00010 //  This program is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 //  GNU General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU General Public License
00016 //  along with this program; if not, write to the Free Software
00017 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // all comments which start from /** - this is comments for KDoc
00020 //  for classes
00021 //    @short [short description of the class]
00022 //    @author [class author]
00023 //    @version [class version]
00024 //    @see [references to other classes or methods]
00025 //  for methods
00026 //    @see [references]
00027 //    @return [sentence describing the return value]
00028 //    @exception [list the exeptions that could be thrown]
00029 //    @param [name id] [description]    - can be multiple
00030 
00031 #ifndef __CORE_DEVICE_H__
00032 #define __CORE_DEVICE_H__
00033 
00034 #include "global.h"
00035 
00036 #define DESCRIPTION_LEN       50
00037 #define SNMP_MODULE_LEN       100
00038 #define SNMP_COMMUNITY_LEN    30
00039 #define TACACS_KEY_LEN        50
00040 #define RADIUS_KEY_LEN        50
00041 #define LOGINSTRING_LEN       32
00042 #define PWDSTRING_LEN         32
00043 //#define AUTHENSOURCE_LEN    10
00044 
00045 namespace tacpp {
00046 
00052 class DeviceUser_data {
00055   pthread_mutex_t mutex_;
00058   void lock();
00061   void unlock();
00064   bool present_;
00067   string username_;
00070   string port_;
00073   string phone_;
00076   ipaddr useraddr_;
00079   bool active_;
00082   log_user log_;
00085   time_t lastdatatime_;
00088   ipaddr nasaddr_;
00089  public:
00092   DeviceUser_data(const string,const string,const string,const ipaddr,
00093     const ipaddr,const db_user);
00096   DeviceUser_data();
00099   ~DeviceUser_data();
00102   void update(const string,const string,const ipaddr);
00105   void update();
00108   void setActive();
00111   bool isActive();
00114   bool isExpired();
00117   void setPresent(const bool);
00120   bool isPresent();
00123   string getUsername();
00126   bool compareUsername(const string);
00129   string getPort();
00132   bool comparePort(const string);
00135   string getPhone();
00138   ipaddr getUserAddr();
00141   db_user getDbData();
00144   ipaddr getNasAddr();
00147   bool compareNasAddr(const ipaddr);
00150   bool match_time(const time_t);
00153   void operator =(DeviceUser_data);
00154 };
00155 
00161 class Device_data {
00164   DLoad *dl_;
00167   int delay_;
00170   pthread_mutex_t Mutex_;
00173   void lock();
00176   void unlock();
00179   string descr_;
00182   string community_;
00185   list<DeviceUser_data*> cusr_;
00188   ipaddr hostaddr_;
00191   string module_;
00194   bool counter_;
00197   bool shutdown_;
00200   string tac_key_;
00203   string loginstring_;
00206   string pwdstring_;
00209   bool def_author_;
00212   bool snmppolling_;
00215   bool icmppolling_;
00218   bool status_;
00221   int rest_;
00222  public:
00225   Device_data(const ipaddr);
00228   Device_data();
00231   ~Device_data();
00234   DeviceUser_data gets(const int);
00237 //  DeviceUser_data *erase(const int);
00240 //  DeviceUser_data *erase(const string,const string,const ipaddr);
00243   bool add(DeviceUser_data*);
00246   void usr_expire();
00249   bool usr_del(const string);
00252   void usr_del();
00255   bool usr_activate(const string,const string,const string,const ipaddr);
00258   bool usr_add(const ipaddr,const string,const string,const string,const ipaddr,const db_user);
00261   void usr_periodic(const time_t);
00264   int numsess(const string);
00267   int size();
00270   int getDelay();
00273   void setDelay(const int);
00276   void setDescr(const string);
00279   string getDescr();
00282   void setCommunity(const string);
00285   string getCommunity();
00288   ipaddr getHostaddr();
00292   bool compareHostaddr(const ipaddr);
00295   void setHostaddr(const ipaddr);
00298   void setModule(const string);
00301   string getModule();
00304   void setCounter(const bool);
00307   bool getCounter();
00310   void setShutdown(const bool);
00313   bool getShutdown();
00316   string getTacKey();
00319   void setTacKey(const string);
00322   string getLoginstring();
00325   void setLoginstring(const string);
00328   string getPwdstring();
00331   void setPwdstring(const string);
00334   bool getDefAuthor();
00337   void setDefAuthor(const bool);
00340   bool getSnmppolling();
00343   void setSnmppolling(const bool);
00346   bool getIcmppolling();
00349   void setIcmppolling(const bool);
00352   bool getStatus();
00355   void setStatus(const bool);
00358   int getRest();
00361   void setRest(const int);
00364   string load();
00367   bool (*getnas)(SnmpDevice*,SnmpD*(*)(char*,char*,char*),char*);
00370   bool (*dropnas)(SnmpDevice*,char*,
00371     SnmpD*(*)(char*,char*,char*),
00372         bool(*)(char*,char*,char*,char*,char),char*);
00375   string buildcfstr();
00376 };
00377 
00384 class CoreDevice : public Core_data {
00387   pthread_t thrvar_;
00390   pthread_mutex_t Mutex_;
00393   void lock();
00396   void unlock();
00399   Device_data *get_(const ipaddr);
00402   list<Device_data*> nas;
00405   bool runPeriodic_;
00406  public:
00409   CoreDevice(const string,const string);
00412   ~CoreDevice();
00415   Device_data *get(const ipaddr);
00418   void add(const ipaddr);
00421   void del(const ipaddr);
00424   void usr_expire();
00428   bool usr_del(const ipaddr,const string);
00431   void usr_del(const ipaddr);
00434   bool usr_activate(const ipaddr,const string,const string,const string,const ipaddr);
00438   bool usr_add(const ipaddr,const string,const string,const string,const ipaddr,const db_user);
00441   void usr_periodic(const time_t);
00444   int numsess(const string);
00447   void startPeriodic();
00450   void modifyCommunity(const ipaddr,const string);
00453   void modifyCounter(const ipaddr,const bool);
00456   void modifyDelay(ipaddr,int);
00459   void modifyDescr(ipaddr,const string);
00462   void modifyModule(ipaddr,const string);
00465   void modifyKey(ipaddr,const string);
00468   void modifyLogin(ipaddr,const string);
00471   void modifyPwd(ipaddr,const string);
00474   void modifyDef(ipaddr,bool);
00477   void modifyShut(ipaddr,bool);
00480   void modifySnmp(ipaddr,bool);
00483   void modifyIcmp(ipaddr,bool);
00486   Device_data *get(int);
00489   ipaddr getip(int);
00492   DeviceUser_data getuser(int);
00495   DeviceUser_data getuser(ipaddr,int);
00498   string load(const ipaddr);
00501   string getmodulename(const ipaddr);
00504   string applycf(char * const*mask,const string cmdname,const list<string>paramList,Command *cmd=NULL)throw (CmdErr);
00507   string buildcfstr(int);
00510   int size();
00513   void setDeviceStatus(ipaddr,bool);
00516   bool get_device_status(ipaddr);
00519   string getCommunity(ipaddr);
00522   void setRunPeriodic(bool);
00525   bool getRunPeriodic();
00526 };
00527 
00528 };
00529 
00530 #endif // __CORE_NAS_H__

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