q922.h

Go to the documentation of this file.
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  * $Revision: 19279 $
00022  * $Author: rjongbloed $
00023  * $Date: 2008-01-17 04:08:34 +0000 (Thu, 17 Jan 2008) $
00024  */
00025 
00026 #ifndef __OPAL_Q922_H
00027 #define __OPAL_Q922_H
00028 
00029 #ifdef P_USE_PRAGMA
00030 #pragma interface
00031 #endif
00032 
00033 #ifndef _PTLIB_H
00034 #include <ptlib.h>
00035 #endif
00036 
00037 #define Q922_HEADER_SIZE 3
00038 
00039 class Q922_Frame : public PBYTEArray
00040 {
00041   PCLASSINFO(Q922_Frame, PBYTEArray);
00042         
00043 public:
00044         
00045   Q922_Frame(PINDEX informationFieldSize = 260);
00046   ~Q922_Frame();
00047         
00048   BYTE GetHighOrderAddressOctet() const { return theArray[0]; }
00049   BYTE GetLowOrderAddressOctet() const { return theArray[1]; }
00050   void SetHighOrderAddressOctet(BYTE octet) { theArray[0] = octet; }
00051   void SetLowOrderAddressOctet(BYTE octet) { theArray[1] = octet; }
00052         
00053   BYTE GetControlFieldOctet() const { return theArray[2]; }
00054   void SetControlFieldOctet(BYTE octet) { theArray[2] = octet; }
00055         
00056   BYTE *GetInformationFieldPtr() const { return (BYTE *)(theArray + Q922_HEADER_SIZE); }
00057         
00058   PINDEX GetInformationFieldSize() const { return informationFieldSize; }
00059   void SetInformationFieldSize(PINDEX size);
00060         
00063   PBoolean Decode(const BYTE *data, PINDEX size);
00064         
00068   PINDEX GetEncodedSize() const;
00069   
00073   PBoolean Encode(BYTE *buffer, PINDEX & size) const;
00074 
00082   PBoolean Encode(BYTE *buffer, PINDEX & size, BYTE & bitPosition) const;
00083         
00084 protected:
00085         
00086   PINDEX informationFieldSize;
00087         
00088 private:
00089 
00090   inline PBoolean FindFlagEnd(const BYTE *buffer, PINDEX bufferSize, PINDEX & octetIndex, BYTE & bitIndex);
00091   inline BYTE DecodeByte(const BYTE *buffer, BYTE *destination, PINDEX & octetIndex, BYTE & bitIndex, BYTE & onesCounter);
00092   inline BYTE DecodeBit(const BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex);
00093         
00094   inline void EncodeOctet(BYTE octet, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex, BYTE & onesCounter) const;
00095   inline void EncodeOctetNoEscape(BYTE octet, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex) const;
00096   inline void EncodeBit(BYTE bit, BYTE *buffer, PINDEX & octetIndex, BYTE & bitIndex) const;
00097         
00098   inline WORD CalculateFCS(const BYTE*data, PINDEX length) const;
00099 };
00100 
00101 #endif // __OPAL_Q922_H
00102 

Generated on Mon Sep 15 11:49:14 2008 for OPAL by  doxygen 1.5.1