D:/Storage/CVS_Head/h323plus/include/q922.h

00001 /*
00002  * q922.h
00003  *
00004  * Q.922 PDU implementation for the OpenH323 Project.
00005  *
00006  * Copyright (c) 2006 Network for Educational Technology, ETH Zurich.
00007  * Written by Hannes Friederich.
00008  *
00009  * The contents of this file are subject to the Mozilla Public License
00010  * Version 1.0 (the "License"); you may not use this file except in
00011  * compliance with the License. You may obtain a copy of the License at
00012  * http://www.mozilla.org/MPL/
00013  *
00014  * Software distributed under the License is distributed on an "AS IS"
00015  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  * the License for the specific language governing rights and limitations
00017  * under the License.
00018  *
00019  * Contributor(s): ______________________________________.
00020  *
00021  * $Log: q922.h,v $
00022  * Revision 1.1  2007/08/06 20:50:50  shorne
00023  * First commit of h323plus
00024  *
00025  * Revision 1.1  2006/06/22 11:07:22  shorne
00026  * Backport of FECC (H.224) from Opal
00027  *
00028  * Revision 1.2  2006/04/23 18:52:19  dsandras
00029  * Removed warnings when compiling with gcc on Linux.
00030  *
00031  * Revision 1.1  2006/04/20 16:48:17  hfriederich
00032  * Initial version of H.224/H.281 implementation.
00033  *
00034  */
00035 
00036 #ifndef __OPAL_Q922_H
00037 #define __OPAL_Q922_H
00038 
00039 #ifdef P_USE_PRAGMA
00040 #pragma interface
00041 #endif
00042 
00043 #include <ptlib.h>
00044 
00045 #define Q922_HEADER_SIZE 3
00046 
00047 class Q922_Frame : public PBYTEArray
00048 {
00049   PCLASSINFO(Q922_Frame, PBYTEArray);
00050         
00051 public:
00052         
00053   Q922_Frame(PINDEX informationFieldSize = 260);
00054   ~Q922_Frame();
00055         
00056   BYTE GetHighOrderAddressOctet() const { return theArray[0]; }
00057   BYTE GetLowOrderAddressOctet() const { return theArray[1]; }
00058   void SetHighOrderAddressOctet(BYTE octet) { theArray[0] = octet; }
00059   void SetLowOrderAddressOctet(BYTE octet) { theArray[1] = octet; }
00060         
00061   BYTE GetControlFieldOctet() const { return theArray[2]; }
00062   void SetControlFieldOctet(BYTE octet) { theArray[2] = octet; }
00063         
00064   BYTE *GetInformationFieldPtr() const { return (BYTE *)(theArray + Q922_HEADER_SIZE); }
00065         
00066   PINDEX GetInformationFieldSize() const { return informationFieldSize; }
00067   void SetInformationFieldSize(PINDEX size);
00068         
00071   BOOL Decode(const BYTE *data, PINDEX size);
00072         
00076   PINDEX GetEncodedSize() const;
00077   
00081   BOOL Encode(BYTE *buffer, PINDEX & size) const;
00082 
00090   BOOL Encode(BYTE *buffer, PINDEX & size, BYTE & bitPosition) const;
00091         
00092 protected:
00093         
00094   PINDEX informationFieldSize;
00095         
00096 private:
00097 
00098   inline BOOL FindFlagEnd(const BYTE *buffer, PINDEX bufferSize, PINDEX & octetIndex, BYTE & bitIndex);
00099   inline BYTE DecodeByte(const BYTE *buffer, BYTE *destination, PINDEX & octetIndex, BYTE & bitIndex, BYTE & onesCounter);
00100   inline BYTE DecodeBit(const BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex);
00101         
00102   inline void EncodeOctet(BYTE octet, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex, BYTE & onesCounter) const;
00103   inline void EncodeOctetNoEscape(BYTE octet, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex) const;
00104   inline void EncodeBit(BYTE bit, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex) const;
00105         
00106   inline WORD CalculateFCS(const BYTE*data, PINDEX length) const;
00107 };
00108 
00109 #endif // __OPAL_Q922_H
00110 

Generated on Thu Oct 25 13:42:36 2007 for h323plus by  doxygen 1.5.2