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

ZrtpPacketBase.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2006-2007 Werner Dittmann
00003 
00004   This program is free software: you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation, either version 3 of the License, or
00007   (at your option) any later version.
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00018 /*
00019  * Authors: Werner Dittmann <Werner.Dittmann@t-online.de>
00020  */
00021 
00022 #ifndef _ZRTPPACKETBASE_H_
00023 #define _ZRTPPACKETBASE_H_
00024 
00025 #include <stdio.h>
00026 #include <stdint.h>
00027 #include <string.h>
00028 #include <malloc.h>
00029 #include <netinet/in.h>
00030 
00031 #include <libzrtpcpp/zrtpPacket.h>
00032 #include <libzrtpcpp/ZrtpTextData.h>
00033 #include <libzrtpcpp/ZrtpCrc32.h>
00034 
00035 // #define DEBUGOUT(deb)   deb
00036 #define DEBUGOUT(deb)
00037 
00038 /*
00039  * This is the unique ZRTP ID in network order (PZ)
00040  */
00041 const uint16_t zrtpId = 0x505a;
00042 
00052 class ZrtpPacketBase {
00053 
00054   private:
00055 
00056   protected:
00057       void* allocated;
00058       zrtpPacketHeader_t* zrtpHeader;
00059 
00060   public:
00061       virtual ~ZrtpPacketBase() {};
00062 
00063     const uint8_t* getHeaderBase() { return (const uint8_t*)zrtpHeader; };
00064     bool isZrtpPacket()            { return (ntohs(zrtpHeader->zrtpId) == zrtpId); };
00065     uint16_t getLength()           { return ntohs(zrtpHeader->length); };
00066     uint8_t* getMessageType()      { return zrtpHeader->messageType; };
00067 
00068     void setLength(uint16_t len)  { zrtpHeader->length = htons(len); };
00069     void setMessageType(uint8_t *msg) 
00070         { memcpy(zrtpHeader->messageType, msg, sizeof(zrtpHeader->messageType)); };
00071     void setZrtpId()              { zrtpHeader->zrtpId = htons(zrtpId); }
00072 };
00073 
00074 #endif // ZRTPPACKETBASE

© sourcejam.com 2005-2008