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

Packet.h

00001 /* hey emacs! -*- Mode: C++; c-file-style: "stroustrup"; indent-tabs-mode: nil -*- */
00002 /*
00003  * $Id: Packet.h,v 1.9 2001/11/24 21:11:50 benoit Exp $
00004  *
00005  * Copyright (c) 2000 Remi Lefebvre <remi@dhis.net>
00006  *                and Luca Filipozzi <lfilipoz@dhis.net>
00007  *
00008  * DDT comes with ABSOLUTELY NO WARRANTY and is licenced under the
00009  * GNU General Public License (version 2 or later). This license
00010  * can be retrieved from http://www.gnu.org/copyleft/gnu.html.
00011  *
00012  */
00013 
00014 #ifndef PACKET_H
00015 #define PACKET_H
00016 
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020 
00021 #include "packets.h"
00022 #include "Logger.h"
00023 
00024 class Packet
00025 {
00026   public:
00027     static int encode (DdtpPacket* pkt, char* buf, int bufSize);
00028     static int decode (DdtpPacket* pkt, char* buf, int bufSize);
00029 
00030     static int decrypt (DdtpPacket* pkt, char* md5_password);
00031     static int encrypt (DdtpPacket* pkt, char* md5_password);
00032 
00033     static int getAccountId (DdtpPacket* pkt);
00034 
00035     static int createUpdateQuery(
00036         DdtpPacket*             ddtpPacket,
00037         ProtocolVersion         protocolVersion,
00038         EncryptionType          encryptionType,
00039         int                     accountId,
00040         DDTPv1UpdateQueryOpCode opCode,
00041         unsigned long           ipAddress,
00042         char*                   updatePassword);
00043 
00044     static int createAliveQuery(
00045         DdtpPacket*             ddtpPacket,
00046         ProtocolVersion         protocolVersion,
00047         int                     accountId);
00048 
00049     static int createAliveReply(
00050             DdtpPacket*             ddtpPacket,
00051             ProtocolVersion         protocolVersion,
00052             int                     accountId);
00053 
00054     /*
00055     int processDdtpPacket  (DdtpPacket* pkt);
00056 
00057     int  getMessageType() { return messageType_;   }
00058     int  getReplyStatus() { return replyStatus_;   }
00059     bool replyRequired()  { return replyRequired_; }
00060     */
00061 
00062   private:
00063     static int decryptDDTPv1Plaintext (DDTPv1Plaintext* ptmsg);
00064     static int encryptDDTPv1Plaintext (DDTPv1Plaintext* ptmsg);
00065     static int decryptDDTPv1Blowfish  (DDTPv1Blowfish*  bfmsg, char* md5_password);
00066     static int encryptDDTPv1Blowfish  (DDTPv1Blowfish*  bfmsg, char* md5_password);
00067 
00068     /*
00069     Logger*     log_;
00070 #ifdef DDT_SERVER
00071     DdtDB*     db_;
00072 #endif
00073     bool        amServer_;
00074 
00075     bool        replyRequired_;
00076     int         messageType_;
00077     int         replyStatus_;
00078 
00079     int         accountId_;
00080 
00081     int processDDTPv1Packet      (DDTPv1Packet*   ddtpv1);
00082 
00083     int processDDTPv1Message     (DDTPv1Message*  msg, int accountId);
00084 
00085     int processDDTPv1UpdateQuery (DDTPv1UpdateQuery* updateQuery,
00086                                   DDTPv1UpdateReply* updateReply,
00087                                   int accountId);
00088     int processDDTPv1UpdateReply (DDTPv1UpdateReply* updateReply);
00089 
00090     int processDDTPv1AliveQuery  (DDTPv1AliveQuery*  aliveQuery,
00091                                   DDTPv1AliveReply*  aliveReply);
00092     int processDDTPv1AliveReply  (DDTPv1AliveReply*  aliveReply,
00093                                   int accountId);
00094     */
00095 
00096 };
00097 #endif // PACKET_H

Generated on Tue Sep 13 01:32:47 2005 for DDT Project by  doxygen 1.4.4