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

Tiep.h

00001 // This is part of tacppd project (extended tacacs++ daemon)
00002 // (c) Copyright in 2000-2004 by tacppd team and contributors
00003 // see http://tacppd.org for more information
00004 //
00005 // file: Tiep.h
00006 // description: tacppd interchange/exchange protocol
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 __TIEP_H__
00038 #define __TIEP_H__
00039 
00040 #include "global.h"
00041 
00045 struct tiep_pak_hdr {
00046   unsigned int type;          // 4 bytes: packet type
00047   unsigned int varkey;        // 4 bytes: crypto variable key
00048   unsigned int entrynum;      // 4 bytes: number of entries in packet body
00049   unsigned int priority;      // 4 bytes: tacppd priority value
00050 };
00051 
00057 //class TiepPacket : public md5 {
00058 class TiepPacket {
00061   pthread_mutex_t mutex_tpk_;
00064   void lock();
00067   void unlock();
00068  public:
00071   TiepPacket::TiepPacket();
00074   TiepPacket::~TiepPacket();
00078   struct tiep_pak_hdr *createhdr(int,int,int);
00082   int packet_type(char*);
00086   int packet_varkey(char*);
00090   int packet_num(char*);
00094   int packet_pri(char*);
00097   void create_md5_hash(unsigned char*,unsigned char*,unsigned char*);
00100   void md5_xor(unsigned char*,unsigned char*,unsigned char*,int);
00104   char *encrypt(char*,int,char*,int);
00108   char *decrypt(char*,int,char*,int);
00109 };
00110 
00112 
00113 // devicetrack packet type id
00114 #define TIP_DT_PACKET       1
00115 // usertrack packet type id
00116 #define TIP_UT_PACKET       2
00117 // keepalive packet
00118 #define TIP_KA_PACKET       3
00119 // keepalive start packet
00120 #define TIP_START_PACKET    4
00121 
00122 // maximum entries into one TIP packet
00123 #define TIP_MAX_ENT         7
00124 
00128 struct dt_pak_entry {
00131   unsigned int device;
00134   unsigned int status;
00137   unsigned int checknum;
00138 };
00139 
00143 struct ut_pak_entry {
00146   char username[32];
00149   unsigned int device;
00152   unsigned int userip;
00155   unsigned int checknum;
00158   char port[32];
00161   char phone[32];
00164   unsigned int status;
00165 };
00166 
00172 class TipPacket : public TiepPacket {
00175   pthread_mutex_t mutex_tp_;
00178   void lock();
00181   void unlock();
00182  public:
00185   TipPacket::TipPacket();
00188   TipPacket::~TipPacket();
00192   bool sendbuf(ipaddr,int,int,char*,int);
00195   struct dt_pak_entry *read_dt(char*,int,char*);
00198   struct ut_pak_entry *read_ut(char*,int,char*);
00202   int packetlen_dt(int);
00206   int packetlen_ut(int);
00207 };
00208 
00214 class TipSystem : public TipPacket {
00217   pthread_mutex_t mutex_;
00220   void lock();
00223   void unlock();
00226   list<struct dt_pak_entry*> dt_pak;
00229   list<struct ut_pak_entry*> ut_pak;
00230  public:
00233   TipSystem::TipSystem();
00236   TipSystem::~TipSystem();
00239   void clear_dt();
00242   void clear_ut();
00245   void add_dt(ipaddr,bool);
00248   void add_ut(const string,ipaddr,ipaddr,const string,const string,bool);
00251   void send_dt();
00254   void send_ut();
00257   void send_ka();
00260   void send_start();
00261 };
00262 
00264 
00265 // devicetrack packet type id
00266 #define TEP_DT_PACKET       6
00267 // usertrack packet type id
00268 #define TEP_UT_PACKET       7
00269 
00274 class TepPacket : public TiepPacket {
00275  public:
00278   bool sendbuf(ipaddr,int,char*,int);
00281 //  struct dt_pak_entry *read_dt(char*,int,char*);
00284 //  struct ut_pak_entry *read_ut(char*,int,char*);
00287 //  int packetlen_dt(int);
00290 //  int packetlen_ut(int);
00291 };
00292 
00297 class TepSystem : public TepPacket {
00298  public:
00299 };
00300 
00301 #endif //__TIEP_H__

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