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

ZIDRecord.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 #ifndef _ZIDRECORD_H_
00019 #define _ZIDRECORD_H_
00020 
00021 #include <string.h>
00022 
00023 #define IDENTIFIER_LEN  12
00024 #define RS_LENGTH       32
00025 
00026 typedef struct zidrecord {
00027     char recValid,              // if 1 record is valid, if 0: invalid
00028         ownZid,                 // if 1 record contains own ZID, usually 1st record
00029         rs1Valid,                       // if 1 RS1 contains valid data
00030         rs2Valid;                       // if 1 RS2 contains valid data
00031     unsigned char identifier[IDENTIFIER_LEN]; // the peer's ZID
00032     unsigned char rs1Data[RS_LENGTH], rs2Data[RS_LENGTH]; // the peer's RS data
00033 } zidrecord_t;
00034 
00048 static const int valid = 0x1;
00049 static const int SASVerified = 0x2;
00050 
00051 class ZIDRecord {
00052     friend class ZIDFile;
00053 
00054  private:
00055     zidrecord_t record;
00056     unsigned long position;
00057 
00058  public:
00059     ZIDRecord(unsigned char *idData) {
00060         memset(&record, 0, sizeof(zidrecord_t));
00061         memcpy(record.identifier, idData, IDENTIFIER_LEN);
00062     }
00063 
00064     int isRs1Valid() { return (record.rs1Valid & valid); }
00065     int isRs2Valid() { return (record.rs2Valid & valid); }
00066 
00067     void setSasVerified()   { record.rs1Valid |= SASVerified; }
00068     void resetSasVerified() { record.rs1Valid &= ~SASVerified; }
00069     int isSasVerified()     { return (record.rs1Valid & SASVerified); }
00070 
00071     const unsigned char *getRs1() { return record.rs1Data; }
00072     const unsigned char *getRs2() { return record.rs2Data; }
00073 
00074     void setNewRs1(const unsigned char*data);
00075 };
00076 
00077 #endif // ZIDRECORD
00078 
00079 

© sourcejam.com 2005-2008