4 * T.120 protocol handler
6 * Open Phone Abstraction Library
8 * Copyright (c) 1998-2000 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is Open H323 Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
27 * Revision 1.6 2004/05/20 02:07:29 csoutheren
28 * Use macro to work around MSVC internal compiler errors
30 * Revision 1.5 2004/05/19 07:38:24 csoutheren
31 * Changed OpalMediaFormat handling to use abstract factory method functions
33 * Revision 1.4 2002/09/03 06:04:11 robertj
34 * Added globally accessible functions for media format name.
36 * Revision 1.3 2002/08/05 10:03:48 robertj
37 * Cosmetic changes to normalise the usage of pragma interface/implementation.
39 * Revision 1.2 2002/02/01 01:47:34 robertj
40 * Some more fixes for T.120 channel establishment, more to do!
42 * Revision 1.1 2001/07/17 04:44:32 robertj
43 * Partial implementation of T.120 and T.38 logical channels.
50 #pragma implementation "t120proto.h"
53 #include "t120proto.h"
55 #include "transports.h"
60 class T120_X224
: public X224
{
61 PCLASSINFO(T120_X224
, X224
);
63 BOOL
Read(H323Transport
& transport
);
64 BOOL
Write(H323Transport
& transport
);
68 class T120ConnectPDU
: public MCS_ConnectMCSPDU
{
69 PCLASSINFO(T120ConnectPDU
, MCS_ConnectMCSPDU
);
71 BOOL
Read(H323Transport
& transport
);
72 BOOL
Write(H323Transport
& transport
);
80 /////////////////////////////////////////////////////////////////////////////
82 BOOL
T120_X224::Read(H323Transport
& transport
)
86 if (!transport
.ReadPDU(rawData
)) {
87 PTRACE(1, "T120\tRead of X224 failed: " << transport
.GetErrorText());
91 if (Decode(rawData
)) {
92 PTRACE(1, "T120\tDecode of PDU failed:\n " << setprecision(2) << *this);
96 PTRACE(4, "T120\tRead X224 PDU:\n " << setprecision(2) << *this);
101 BOOL
T120_X224::Write(H323Transport
& transport
)
105 PTRACE(4, "T120\tWrite X224 PDU:\n " << setprecision(2) << *this);
107 if (!Encode(rawData
)) {
108 PTRACE(1, "T120\tEncode of PDU failed:\n " << setprecision(2) << *this);
112 if (!transport
.WritePDU(rawData
)) {
113 PTRACE(1, "T120\tWrite X224 PDU failed: " << transport
.GetErrorText());
121 /////////////////////////////////////////////////////////////////////////////
123 BOOL
T120ConnectPDU::Read(H323Transport
& transport
)
125 if (!x224
.Read(transport
))
128 // An X224 Data PDU...
129 if (x224
.GetCode() != X224::DataPDU
) {
130 PTRACE(1, "T120\tX224 must be data PDU");
134 // ... contains the T120 MCS PDU
135 PBER_Stream ber
= x224
.GetData();
137 PTRACE(1, "T120\tDecode of PDU failed:\n " << setprecision(2) << *this);
141 PTRACE(4, "T120\tReceived MCS Connect PDU:\n " << setprecision(2) << *this);
146 BOOL
T120ConnectPDU::Write(H323Transport
& transport
)
148 PTRACE(4, "T120\tSending MCS Connect PDU:\n " << setprecision(2) << *this);
152 ber
.CompleteEncoding();
154 return x224
.Write(transport
);
158 /////////////////////////////////////////////////////////////////////////////
160 OpalT120Protocol::OpalT120Protocol()
165 BOOL
OpalT120Protocol::Originate(H323Transport
& transport
)
167 PTRACE(3, "T120\tOriginate, sending X224 CONNECT-REQUEST");
170 x224
.BuildConnectRequest();
171 if (!x224
.Write(transport
))
174 transport
.SetReadTimeout(10000); // Wait 10 seconds for reply
175 if (!x224
.Read(transport
))
178 if (x224
.GetCode() != X224::ConnectConfirm
) {
179 PTRACE(1, "T120\tPDU was not X224 CONNECT-CONFIRM");
184 while (pdu
.Read(transport
)) {
185 if (!HandleConnect(pdu
))
193 BOOL
OpalT120Protocol::Answer(H323Transport
& transport
)
195 PTRACE(3, "T120\tAnswer, awaiting X224 CONNECT-REQUEST");
198 transport
.SetReadTimeout(60000); // Wait 60 seconds for reply
201 if (!x224
.Read(transport
))
203 } while (x224
.GetCode() != X224::ConnectRequest
);
205 x224
.BuildConnectConfirm();
206 if (!x224
.Write(transport
))
210 while (pdu
.Read(transport
)) {
211 if (!HandleConnect(pdu
))
219 BOOL
OpalT120Protocol::HandleConnect(const MCS_ConnectMCSPDU
& /*pdu*/)
225 BOOL
OpalT120Protocol::HandleDomain(const MCS_DomainMCSPDU
& /*pdu*/)
231 /////////////////////////////////////////////////////////////////////////////