OPAL  Version 3.18.8
q922.h
Go to the documentation of this file.
1 /*
2  * q922.h
3  *
4  * Q.922 PDU implementation for the OpenH323 Project.
5  *
6  * Copyright (c) 2006 Network for Educational Technology, ETH Zurich.
7  * Written by Hannes Friederich.
8  *
9  * The contents of this file are subject to the Mozilla Public License
10  * Version 1.0 (the "License"); you may not use this file except in
11  * compliance with the License. You may obtain a copy of the License at
12  * http://www.mozilla.org/MPL/
13  *
14  * Software distributed under the License is distributed on an "AS IS"
15  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16  * the License for the specific language governing rights and limitations
17  * under the License.
18  *
19  * Contributor(s): ______________________________________.
20  */
21 
22 #ifndef OPAL_H224_Q922_H
23 #define OPAL_H224_Q922_H
24 
25 #ifdef P_USE_PRAGMA
26 #pragma interface
27 #endif
28 
29 #ifndef _PTLIB_H
30 #include <ptlib.h>
31 #endif
32 
33 #include <opal_config.h>
34 
35 #if OPAL_HAS_H224
36 
37 #define Q922_HEADER_SIZE 3
38 
39 class Q922_Frame : public PBYTEArray
40 {
41  PCLASSINFO(Q922_Frame, PBYTEArray);
42 
43 public:
44 
45  Q922_Frame(PINDEX informationFieldSize = 260);
46  ~Q922_Frame();
47 
48  BYTE GetHighOrderAddressOctet() const { return theArray[0]; }
49  BYTE GetLowOrderAddressOctet() const { return theArray[1]; }
50  void SetHighOrderAddressOctet(BYTE octet) { theArray[0] = octet; }
51  void SetLowOrderAddressOctet(BYTE octet) { theArray[1] = octet; }
52 
53  BYTE GetControlFieldOctet() const { return theArray[2]; }
54  void SetControlFieldOctet(BYTE octet) { theArray[2] = octet; }
55 
56  BYTE *GetInformationFieldPtr() const { return (BYTE *)(theArray + Q922_HEADER_SIZE); }
57 
59  void SetInformationFieldSize(PINDEX size);
60 
64  bool DecodeAnnexQ(const BYTE *buffer, PINDEX size);
65 
68  PINDEX GetAnnexQEncodedSize() const;
69 
73  bool EncodeAnnexQ(BYTE *buffer, PINDEX & size) const;
74 
78  bool DecodeHDLC(const BYTE *data, PINDEX size);
79 
83  PINDEX GetHDLCEncodedSize() const;
84 
88  bool EncodeHDLC(BYTE *buffer, PINDEX & size) const;
89 
97  bool EncodeHDLC(BYTE *buffer, PINDEX & size, PINDEX & bitPosition) const;
98 
99 protected:
100 
102 
103 private:
104 
105  // for HDLC mode
106  inline bool FindFlagEnd(const BYTE *buffer, PINDEX bufferSize, PINDEX & octetIndex, PINDEX & bitIndex);
107  inline BYTE DecodeOctet(const BYTE *buffer, BYTE *destination, PINDEX & octetIndex, PINDEX & bitIndex, PINDEX & onesCounter);
108  inline BYTE DecodeBit(const BYTE *buffer, PINDEX & octetIndex, PINDEX & bitIndex);
109 
110  inline void EncodeOctet(BYTE octet, BYTE *buffer, PINDEX & octetIndex, PINDEX & bitIndex, PINDEX & onesCounter) const;
111  inline void EncodeOctetNoEscape(BYTE octet, BYTE *buffer, PINDEX & octetIndex, PINDEX & bitIndex) const;
112  inline void EncodeBit(BYTE bit, BYTE *buffer, PINDEX & octetIndex, PINDEX & bitIndex) const;
113 
114  inline WORD CalculateFCS(const BYTE*data, PINDEX length) const;
115 };
116 
117 
118 #endif // OPAL_HAS_H224
119 
120 #endif // OPAL_H224_Q922_H
BYTE * GetInformationFieldPtr() const
Definition: q922.h:56
bool EncodeHDLC(BYTE *buffer, PINDEX &size) const
Definition: q922.h:39
PINDEX GetHDLCEncodedSize() const
void SetInformationFieldSize(PINDEX size)
bool EncodeAnnexQ(BYTE *buffer, PINDEX &size) const
void SetLowOrderAddressOctet(BYTE octet)
Definition: q922.h:51
void SetHighOrderAddressOctet(BYTE octet)
Definition: q922.h:50
PINDEX m_informationFieldSize
Definition: q922.h:101
bool DecodeAnnexQ(const BYTE *buffer, PINDEX size)
#define Q922_HEADER_SIZE
Definition: q922.h:37
void SetControlFieldOctet(BYTE octet)
Definition: q922.h:54
Q922_Frame(PINDEX informationFieldSize=260)
BYTE GetLowOrderAddressOctet() const
Definition: q922.h:49
bool DecodeHDLC(const BYTE *data, PINDEX size)
PINDEX GetInformationFieldSize() const
Definition: q922.h:58
BYTE GetControlFieldOctet() const
Definition: q922.h:53
PINDEX GetAnnexQEncodedSize() const
BYTE GetHighOrderAddressOctet() const
Definition: q922.h:48