OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / lib / libopenh323 / include / svcctrl.h
1 /*
2  * svcctrl.h
3  *
4  * H.225 Service Control protocol handler
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 2003 Equivalence Pty. Ltd.
9  *
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/
14  *
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
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  * Contributor(s): ______________________________________.
24  *
25  * $Log: svcctrl.h,v $
26  * Revision 1.2  2006/05/16 11:37:11  shorne
27  * Added ability to detect type of service control
28  *
29  * Revision 1.1  2003/04/01 01:07:22  robertj
30  * Split service control handlers from H.225 RAS header.
31  *
32  */
33
34 #ifndef __OPAL_SVCCTRL_H
35 #define __OPAL_SVCCTRL_H
36
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40
41
42 class H225_ServiceControlDescriptor;
43 class H225_ServiceControlIndication;
44 class H225_ServiceControlResponse;
45
46 class H248_SignalsDescriptor;
47 class H248_SignalRequest;
48
49 class H323EndPoint;
50 class H323Connection;
51
52
53 ///////////////////////////////////////////////////////////////////////////////
54
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.
57   */
58 class H323ServiceControlSession : public PObject
59 {
60     PCLASSINFO(H323ServiceControlSession, PObject);
61   public:
62   /**@name Construction */
63   //@{
64     /**Create a new handler for a Service Control.
65      */
66     H323ServiceControlSession();
67   //@}
68
69   /**@name Operations */
70   //@{
71     /**Determine of the session is valid.
72        That is has all of the data it needs to correctly encode a PDU.
73
74        Default behaviour is pure.
75       */
76     virtual BOOL IsValid() const = 0;
77
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.
82
83        Default behaviour returns the class name.
84       */
85     virtual PString GetServiceControlType() const;
86
87     /**Handle a received PDU.
88        Update in the internal state from the received PDU.
89
90        Returns FALSE is PDU is not sutiable for the class type.
91
92        Default behaviour is pure.
93       */
94     virtual BOOL OnReceivedPDU(
95       const H225_ServiceControlDescriptor & descriptor
96     ) = 0;
97
98     /**Handle a sent PDU.
99        Set the PDU fields from in the internal state.
100
101        Returns FALSE is PDU cannot be created.
102
103        Default behaviour is pure.
104       */
105     virtual BOOL OnSendingPDU(
106       H225_ServiceControlDescriptor & descriptor
107     ) const = 0;
108
109     enum ChangeType {
110       OpenSession,    // H225_ServiceControlSession_reason::e_open
111       RefreshSession, // H225_ServiceControlSession_reason::e_refresh
112       CloseSession    // H225_ServiceControlSession_reason::e_close
113     };
114
115     /**Handle a change of the state of the Service Control Session.
116
117        Default behaviour is pure.
118       */
119     virtual void OnChange(
120       unsigned type,
121       unsigned sessionId,
122       H323EndPoint & endpoint,
123       H323Connection * connection
124     ) const = 0;
125
126     enum serviceType {
127        e_URL,
128        e_Signal,
129        e_NonStandard,
130        e_CallCredit
131      };
132
133      virtual serviceType GetType() = 0;
134   //@}
135 };
136
137
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.
140   */
141 class H323HTTPServiceControl : public H323ServiceControlSession
142 {
143     PCLASSINFO(H323HTTPServiceControl, H323ServiceControlSession);
144   public:
145   /**@name Construction */
146   //@{
147     /**Create a new handler for a Service Control.
148      */
149     H323HTTPServiceControl(
150       const PString & url
151     );
152
153     /**Create a new handler for a Service Control, initialise to PDU.
154      */
155     H323HTTPServiceControl(
156       const H225_ServiceControlDescriptor & contents
157     );
158   //@}
159
160   /**@name Operations */
161   //@{
162     /**Determine of the session is valid.
163        That is has all of the data it needs to correctly encode a PDU.
164
165        Default behaviour returns TRUE if url is not an empty string.
166       */
167     virtual BOOL IsValid() const;
168
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.
173
174        Default behaviour returns the class name.
175       */
176     virtual PString GetServiceControlType() const;
177
178     /**Handle a received PDU.
179        Update in the internal state from the received PDU.
180
181        Default behaviour gets the contents for an e_url.
182       */
183     virtual BOOL OnReceivedPDU(
184       const H225_ServiceControlDescriptor & contents
185     );
186
187     /**Handle a sent PDU.
188        Set the PDU fields from in the internal state.
189
190        Default behaviour sets the contents to an e_url.
191       */
192     virtual BOOL OnSendingPDU(
193       H225_ServiceControlDescriptor & contents
194     ) const;
195
196     /**Handle a change of the state of the Service Control Session.
197
198        Default behaviour calls endpoint.OnHTTPServiceControl().
199       */
200     virtual void OnChange(
201       unsigned type,
202       unsigned sessionId,
203       H323EndPoint & endpoint,
204       H323Connection * connection
205     ) const;
206
207     serviceType GetType() { return e_URL; };
208
209     void GetValue(PString & _url) { _url = url; }
210   //@}
211
212   protected:
213     PString url;
214 };
215
216
217 /**This is a base class for H.323 Service Control Session handling for H.248.
218   */
219 class H323H248ServiceControl : public H323ServiceControlSession
220 {
221     PCLASSINFO(H323H248ServiceControl, H323ServiceControlSession);
222   public:
223   /**@name Construction */
224   //@{
225     /**Create a new handler for a Service Control.
226      */
227     H323H248ServiceControl();
228
229     /**Create a new handler for a Service Control, initialise to PDU.
230      */
231     H323H248ServiceControl(
232       const H225_ServiceControlDescriptor & contents
233     );
234   //@}
235
236   /**@name Operations */
237   //@{
238     /**Handle a received PDU.
239        Update in the internal state from the received PDU.
240
241        Default behaviour converts to pdu to H248_SignalsDescriptor and calls
242        that version of OnReceivedPDU().
243       */
244     virtual BOOL OnReceivedPDU(
245       const H225_ServiceControlDescriptor & contents
246     );
247
248     /**Handle a sent PDU.
249        Set the PDU fields from in the internal state.
250
251        Default behaviour calls the H248_SignalsDescriptor version of
252        OnSendingPDU() and converts that to the contents pdu.
253       */
254     virtual BOOL OnSendingPDU(
255       H225_ServiceControlDescriptor & contents
256     ) const;
257
258     /**Handle a received PDU.
259        Update in the internal state from the received PDU.
260
261        Default behaviour calls the H248_SignalRequest version of
262        OnReceivedPDU() for every element in H248_SignalsDescriptor.
263       */
264     virtual BOOL OnReceivedPDU(
265       const H248_SignalsDescriptor & descriptor
266     );
267
268     /**Handle a sent PDU.
269        Set the PDU fields from in the internal state.
270
271        Default behaviour calls the H248_SignalRequest version of
272        OnSendingPDU() and appends it to the H248_SignalsDescriptor.
273       */
274     virtual BOOL OnSendingPDU(
275       H248_SignalsDescriptor & descriptor
276     ) const;
277
278     /**Handle a received PDU.
279        Update in the internal state from the received PDU.
280
281        Default behaviour is pure.
282       */
283     virtual BOOL OnReceivedPDU(
284       const H248_SignalRequest & request
285     ) = 0;
286
287     /**Handle a sent PDU.
288        Set the PDU fields from in the internal state.
289
290        Default behaviour is pure.
291       */
292     virtual BOOL OnSendingPDU(
293       H248_SignalRequest & request
294     ) const = 0;
295
296     serviceType GetType() { return e_Signal; };
297   //@}
298 };
299
300
301 /**This class is for H.323 Service Control Session handling for call credit.
302   */
303 class H323CallCreditServiceControl : public H323ServiceControlSession
304 {
305     PCLASSINFO(H323CallCreditServiceControl, H323ServiceControlSession);
306   public:
307   /**@name Construction */
308   //@{
309     /**Create a new handler for a Service Control.
310      */
311     H323CallCreditServiceControl(
312       const PString & amount,
313       BOOL mode,
314       unsigned duration = 0
315     );
316
317     /**Create a new handler for a Service Control, initialise to PDU.
318      */
319     H323CallCreditServiceControl(
320       const H225_ServiceControlDescriptor & contents
321     );
322   //@}
323
324   /**@name Operations */
325   //@{
326     /**Determine of the session is valid.
327        That is has all of the data it needs to correctly encode a PDU.
328
329        Default behaviour returns TRUE if amount or duration is set.
330       */
331     virtual BOOL IsValid() const;
332
333     /**Handle a received PDU.
334        Update in the internal state from the received PDU.
335
336        Default behaviour gets the contents for an e_callCreditServiceControl.
337       */
338     virtual BOOL OnReceivedPDU(
339       const H225_ServiceControlDescriptor & contents
340     );
341
342     /**Handle a sent PDU.
343        Set the PDU fields from in the internal state.
344
345        Default behaviour sets the contents to an e_callCreditServiceControl.
346       */
347     virtual BOOL OnSendingPDU(
348       H225_ServiceControlDescriptor & contents
349     ) const;
350
351     /**Handle a change of the state of the Service Control Session.
352
353        Default behaviour calls endpoint.OnCallCreditServiceControl() and
354        optionally connection->SetEnforceDurationLimit().
355       */
356     virtual void OnChange(
357       unsigned type,
358       unsigned sessionId,
359       H323EndPoint & endpoint,
360       H323Connection * connection
361     ) const;
362
363     serviceType GetType() { return e_CallCredit; };
364
365     void GetValue(PString & _amount,BOOL & _credit, unsigned & _time)
366         { _amount = amount; _credit = mode; _time = durationLimit;}
367   //@}
368
369   protected:
370     PString  amount;
371     BOOL     mode;
372     unsigned durationLimit;
373 };
374
375
376 #endif // __OPAL_SVCCTRL_H
377
378
379 /////////////////////////////////////////////////////////////////////////////