4 * H.225 Service Control protocol handler
8 * Copyright (c) 2003 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.
23 * Contributor(s): ______________________________________.
26 * Revision 1.2 2006/05/16 11:37:11 shorne
27 * Added ability to detect type of service control
29 * Revision 1.1 2003/04/01 01:07:22 robertj
30 * Split service control handlers from H.225 RAS header.
34 #ifndef __OPAL_SVCCTRL_H
35 #define __OPAL_SVCCTRL_H
42 class H225_ServiceControlDescriptor;
43 class H225_ServiceControlIndication;
44 class H225_ServiceControlResponse;
46 class H248_SignalsDescriptor;
47 class H248_SignalRequest;
53 ///////////////////////////////////////////////////////////////////////////////
55 /**This is a base class for H.323 Service Control Session handling.
56 This implements the service class session management as per Annex K/H.323.
58 class H323ServiceControlSession : public PObject
60 PCLASSINFO(H323ServiceControlSession, PObject);
62 /**@name Construction */
64 /**Create a new handler for a Service Control.
66 H323ServiceControlSession();
69 /**@name Operations */
71 /**Determine of the session is valid.
72 That is has all of the data it needs to correctly encode a PDU.
74 Default behaviour is pure.
76 virtual BOOL IsValid() const = 0;
78 /**Get identification name for the Control Service.
79 This function separates the dynamic data from the fundamental type of
80 the control service which will cause a new session ID to be generated
81 by the gatekeeper server.
83 Default behaviour returns the class name.
85 virtual PString GetServiceControlType() const;
87 /**Handle a received PDU.
88 Update in the internal state from the received PDU.
90 Returns FALSE is PDU is not sutiable for the class type.
92 Default behaviour is pure.
94 virtual BOOL OnReceivedPDU(
95 const H225_ServiceControlDescriptor & descriptor
99 Set the PDU fields from in the internal state.
101 Returns FALSE is PDU cannot be created.
103 Default behaviour is pure.
105 virtual BOOL OnSendingPDU(
106 H225_ServiceControlDescriptor & descriptor
110 OpenSession, // H225_ServiceControlSession_reason::e_open
111 RefreshSession, // H225_ServiceControlSession_reason::e_refresh
112 CloseSession // H225_ServiceControlSession_reason::e_close
115 /**Handle a change of the state of the Service Control Session.
117 Default behaviour is pure.
119 virtual void OnChange(
122 H323EndPoint & endpoint,
123 H323Connection * connection
133 virtual serviceType GetType() = 0;
138 /**This class is for H.323 Service Control Session handling for HTTP.
139 This implements the HTTP channel management as per Annex K/H.323.
141 class H323HTTPServiceControl : public H323ServiceControlSession
143 PCLASSINFO(H323HTTPServiceControl, H323ServiceControlSession);
145 /**@name Construction */
147 /**Create a new handler for a Service Control.
149 H323HTTPServiceControl(
153 /**Create a new handler for a Service Control, initialise to PDU.
155 H323HTTPServiceControl(
156 const H225_ServiceControlDescriptor & contents
160 /**@name Operations */
162 /**Determine of the session is valid.
163 That is has all of the data it needs to correctly encode a PDU.
165 Default behaviour returns TRUE if url is not an empty string.
167 virtual BOOL IsValid() const;
169 /**Get identification name for the Control Service.
170 This function separates the dynamic data from the fundamental type of
171 the control service which will cause a new session ID to be generated
172 by the gatekeeper server.
174 Default behaviour returns the class name.
176 virtual PString GetServiceControlType() const;
178 /**Handle a received PDU.
179 Update in the internal state from the received PDU.
181 Default behaviour gets the contents for an e_url.
183 virtual BOOL OnReceivedPDU(
184 const H225_ServiceControlDescriptor & contents
187 /**Handle a sent PDU.
188 Set the PDU fields from in the internal state.
190 Default behaviour sets the contents to an e_url.
192 virtual BOOL OnSendingPDU(
193 H225_ServiceControlDescriptor & contents
196 /**Handle a change of the state of the Service Control Session.
198 Default behaviour calls endpoint.OnHTTPServiceControl().
200 virtual void OnChange(
203 H323EndPoint & endpoint,
204 H323Connection * connection
207 serviceType GetType() { return e_URL; };
209 void GetValue(PString & _url) { _url = url; }
217 /**This is a base class for H.323 Service Control Session handling for H.248.
219 class H323H248ServiceControl : public H323ServiceControlSession
221 PCLASSINFO(H323H248ServiceControl, H323ServiceControlSession);
223 /**@name Construction */
225 /**Create a new handler for a Service Control.
227 H323H248ServiceControl();
229 /**Create a new handler for a Service Control, initialise to PDU.
231 H323H248ServiceControl(
232 const H225_ServiceControlDescriptor & contents
236 /**@name Operations */
238 /**Handle a received PDU.
239 Update in the internal state from the received PDU.
241 Default behaviour converts to pdu to H248_SignalsDescriptor and calls
242 that version of OnReceivedPDU().
244 virtual BOOL OnReceivedPDU(
245 const H225_ServiceControlDescriptor & contents
248 /**Handle a sent PDU.
249 Set the PDU fields from in the internal state.
251 Default behaviour calls the H248_SignalsDescriptor version of
252 OnSendingPDU() and converts that to the contents pdu.
254 virtual BOOL OnSendingPDU(
255 H225_ServiceControlDescriptor & contents
258 /**Handle a received PDU.
259 Update in the internal state from the received PDU.
261 Default behaviour calls the H248_SignalRequest version of
262 OnReceivedPDU() for every element in H248_SignalsDescriptor.
264 virtual BOOL OnReceivedPDU(
265 const H248_SignalsDescriptor & descriptor
268 /**Handle a sent PDU.
269 Set the PDU fields from in the internal state.
271 Default behaviour calls the H248_SignalRequest version of
272 OnSendingPDU() and appends it to the H248_SignalsDescriptor.
274 virtual BOOL OnSendingPDU(
275 H248_SignalsDescriptor & descriptor
278 /**Handle a received PDU.
279 Update in the internal state from the received PDU.
281 Default behaviour is pure.
283 virtual BOOL OnReceivedPDU(
284 const H248_SignalRequest & request
287 /**Handle a sent PDU.
288 Set the PDU fields from in the internal state.
290 Default behaviour is pure.
292 virtual BOOL OnSendingPDU(
293 H248_SignalRequest & request
296 serviceType GetType() { return e_Signal; };
301 /**This class is for H.323 Service Control Session handling for call credit.
303 class H323CallCreditServiceControl : public H323ServiceControlSession
305 PCLASSINFO(H323CallCreditServiceControl, H323ServiceControlSession);
307 /**@name Construction */
309 /**Create a new handler for a Service Control.
311 H323CallCreditServiceControl(
312 const PString & amount,
314 unsigned duration = 0
317 /**Create a new handler for a Service Control, initialise to PDU.
319 H323CallCreditServiceControl(
320 const H225_ServiceControlDescriptor & contents
324 /**@name Operations */
326 /**Determine of the session is valid.
327 That is has all of the data it needs to correctly encode a PDU.
329 Default behaviour returns TRUE if amount or duration is set.
331 virtual BOOL IsValid() const;
333 /**Handle a received PDU.
334 Update in the internal state from the received PDU.
336 Default behaviour gets the contents for an e_callCreditServiceControl.
338 virtual BOOL OnReceivedPDU(
339 const H225_ServiceControlDescriptor & contents
342 /**Handle a sent PDU.
343 Set the PDU fields from in the internal state.
345 Default behaviour sets the contents to an e_callCreditServiceControl.
347 virtual BOOL OnSendingPDU(
348 H225_ServiceControlDescriptor & contents
351 /**Handle a change of the state of the Service Control Session.
353 Default behaviour calls endpoint.OnCallCreditServiceControl() and
354 optionally connection->SetEnforceDurationLimit().
356 virtual void OnChange(
359 H323EndPoint & endpoint,
360 H323Connection * connection
363 serviceType GetType() { return e_CallCredit; };
365 void GetValue(PString & _amount,BOOL & _credit, unsigned & _time)
366 { _amount = amount; _credit = mode; _time = durationLimit;}
372 unsigned durationLimit;
376 #endif // __OPAL_SVCCTRL_H
379 /////////////////////////////////////////////////////////////////////////////