1 /*
2  * h235pugin.h
3  *
4  * h235 Implementation for the h323plus library.
5  *
6  * Copyright (c) 2006 ISVO (Asia) Pte Ltd. All Rights Reserved.
7  *
8  * The contents of this file are subject to the Mozilla Public License
9  * Version 1.1 (the "License"); you may not use this file except in
10  * compliance with the License. You may obtain a copy of the License at
11  * http://www.mozilla.org/MPL/
12  *
13  * Alternatively, the contents of this file may be used under the terms
14  * of the General Public License (the  "GNU License"), in which case the
15  * provisions of GNU License are applicable instead of those
16  * above. If you wish to allow use of your version of this file only
17  * under the terms of the GNU License and not to allow others to use
18  * your version of this file under the MPL, indicate your decision by
19  * deleting the provisions above and replace them with the notice and
20  * other provisions required by the GNU License. If you do not delete
21  * the provisions above, a recipient may use your version of this file
22  * under either the MPL or the GNU License."
23  *
24  * Software distributed under the License is distributed on an "AS IS"
25  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
26  * the License for the specific language governing rights and limitations
27  * under the License.
28  *
29  *
30  * Contributor(s): ______________________________________.
31  *
32  * $Id$
33  *
34  */
35 
36 #ifndef __h235PLUGIN_H
37 #define __h235PLUGIN_H
38 
39 #include <time.h>
40 
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /////////////////////////////////////////////////////////////////////////////////
47 //
48 // h235 Plugins
49 
50 #define PWLIB_PLUGIN_API_VERSION     0
51 #define	PLUGIN_H235_VERSION          1
52 
53 
54 // Function calls
55 static const char H235_BuildClear[]       = "Build_Clear";
56 static const char H235_BuildCrypto[]      = "Build_Crypto";
57 static const char H235_FinaliseCrypto[]   = "Finalise_Crypto";
58 static const char H235_ValidateClear[]    = "Validate_Clear";
59 static const char H235_ValidateCrypto[]   = "Validate_Crypto";
60 
61 // Settings direction
62 static const char GET_PLUGINH235_SETTINGS[]    = "get_h235_settings";
63 static const char SET_PLUGINH235_SETTINGS[]    = "set_h235_settings";
64 
65 // Validation Constants
66 #define Pluginh235_Val_OK            0     ///< Security parameters and Msg are ok, no security attacks
67 #define Pluginh235_Val_Absent        1     ///< Security parameters are expected but absent
68 #define Pluginh235_Val_Error         2     ///< Security parameters are present but incorrect
69 #define Pluginh235_Val_InvalidTime   3     ///< Security parameters indicate peer has bad real time clock
70 #define Pluginh235_Val_BadPassword   4     ///< Security parameters indicate bad password in token
71 #define Pluginh235_Val_ReplyAttack   5     ///< Security parameters indicate an attack was made
72 #define Pluginh235_Val_Disabled      6     ///< Security is disabled by local system
73 
74 
75 // Application Constants
76 #define Pluginh235_App_GKAdmission       0     ///< To Be Used for GK Admission
77 #define Pluginh235_App_EPAuthentication  1     ///< To Be Used for EP Authentication
78 #define Pluginh235_App_LRQOnly           2     ///< To Be Used for Location Request Authentication
79 #define Pluginh235_App_AnyApplication    3     ///< To Be Used for Any Application
80 
81 
82 // Settings constants
83 static const char Pluginh235_Set_Application[]             ="Application";
84 static const char Pluginh235_Set_UseGkAndEpIdentifiers[]   ="UseGkAndEpIdentifiers";
85 static const char Pluginh235_Set_IsSecuredPDU[]            ="IsSecuredPDU";
86 static const char Pluginh235_Set_IsSecuredSignalPDU[]      ="IsSecuredSignalPDU";
87 static const char Pluginh235_Set_IsActive[]                ="IsActive";
88 static const char Pluginh235_Set_RemoteId[]                ="RemoteId";
89 static const char Pluginh235_Set_LocalId[]                 ="LocalId";
90 static const char Pluginh235_Set_Password[]                ="Password";
91 static const char Pluginh235_Set_TimestampGracePeriod[]    ="TimestampGracePeriod";
92 
93 // Ras Message constants
94 #define Pluginh235_msg_gatekeeperRequest           0
95 #define Pluginh235_msg_gatekeeperConfirm	       1
96 #define Pluginh235_msg_gatekeeperReject            2
97 #define Pluginh235_msg_registrationRequest         3
98 #define Pluginh235_msg_registrationConfirm         4
99 #define Pluginh235_msg_registrationReject          5
100 #define Pluginh235_msg_unregistrationRequest       6
101 #define Pluginh235_msg_unregistrationConfirm       7
102 #define Pluginh235_msg_unregistrationReject        8
103 #define Pluginh235_msg_admissionRequest            9
104 #define Pluginh235_msg_admissionConfirm            10
105 #define Pluginh235_msg_admissionReject             11
106 #define Pluginh235_msg_bandwidthRequest            12
107 #define Pluginh235_msg_bandwidthConfirm            13
108 #define Pluginh235_msg_bandwidthReject             14
109 #define Pluginh235_msg_disengageRequest            15
110 #define Pluginh235_msg_disengageConfirm            16
111 #define Pluginh235_msg_disengageReject             17
112 #define Pluginh235_msg_locationRequest             18
113 #define Pluginh235_msg_locationConfirm             19
114 #define Pluginh235_msg_locationReject              20
115 #define Pluginh235_msg_infoRequest                 21
116 #define Pluginh235_msg_infoRequestResponse         22
117 
118 // Signal message constants
119 #define Pluginh235_msg_setup                       0
120 #define Pluginh235_msg_callProceeding              1
121 #define Pluginh235_msg_connect                     2
122 #define Pluginh235_msg_alerting                    3
123 #define Pluginh235_msg_information                 4
124 #define Pluginh235_msg_releaseComplete             5
125 #define Pluginh235_msg_facility                    6
126 #define Pluginh235_msg_progress                    7
127 #define Pluginh235_msg_empty                       8
128 #define Pluginh235_msg_status                      9
129 #define Pluginh235_msg_statusInquiry              10
130 #define Pluginh235_msg_setupAcknowledge           11
131 #define Pluginh235_msg_notify                     12
132 
133 
134 /////////////////////////////////////////////////////////////////////////////////
135 
136 enum Pluginh235_Flags {
137  // Token type
138   Pluginh235_TokenTypeMask           = 0x000f,
139   Pluginh235_TokenTypeclear          = 0x0000,
140   Pluginh235_TokenTypecrypto         = 0x0001,
141   Pluginh235_TokenTypeBoth           = 0x0002,
142 
143  // CryptoToken Style
144   Pluginh235_TokenStyleMask          = 0x0010,
145   Pluginh235_TokenStyleHash          = 0x0010,
146   Pluginh235_TokenStyleSigned        = 0x0011,
147   Pluginh235_TokenStyleEncrypted     = 0x0012
148 };
149 
150 struct Pluginh235_Definition;
151 
152 struct Pluginh235_ControlDefn {
153   const char * name;
154   int (*control)(const struct Pluginh235_Definition * def, void * context,
155                  const char * parm, const char * value);
156 };
157 
158 /////////////////////////////////////////////////////////////////////////////////
159 
160 struct Pluginh235_information {
161   // start of version 1 fields
162   time_t timestamp;                     // codec creation time and date - obtain with command: date -u "+%c = %s"
163 
164   const char * sourceAuthor;            // source code author
165   const char * sourceVersion;           // source code version
166   const char * sourceEmail;             // source code email contact information
167   const char * sourceURL;               // source code web site
168   const char * sourceCopyright;         // source code copyright
169   const char * sourceLicense;           // source code license
170   unsigned char sourceLicenseCode;      // source code license
171 
172   const char * h235Description;          // h235 description
173   const char * h235Manufacturer;         // h235 Manufacturer
174   const char * h235Model;                // h235 Model
175   const char * h235Email;		         // h235 email contact information
176   const char * h235URL;                  // h235 Manufacturer web site
177   // end of version 1 fields
178 };
179 
180 struct Pluginh235_Definition {
181   unsigned int version;			               // codec structure version
182 
183   // start of version 1 fields
184   struct Pluginh235_information * info;                // license information
185 
186   unsigned int flags;                                  // Pluginh235_Flags,
187   const char * desc;    		                       // text decription
188   const char * identifier;                             // OID Identifier
189   const void * userData;                               // user data value
190 
191   void *(*createh235)(const struct Pluginh235_Definition * def);	               // create h235
192   void (*destroyh235)(const struct Pluginh235_Definition * def);                   // destroy h235
193   int (*h235function)(const struct Pluginh235_Definition * def,  void * context,   // do H235 function
194 	                  const char * function,const void * data, unsigned * dataLen,
195 					  const void * raw, unsigned * rawLen);
196 
197   struct Pluginh235_ControlDefn * h235Controls;                                     // do control function
198 
199   // end of version 1 fields
200 };
201 
202 typedef struct Pluginh235_Definition * (* Pluginh235_Geth235Function)(unsigned int *, unsigned int);
203 typedef unsigned (* Pluginh235_GetAPIVersionFunction)();
204 
205 
206 //////////////////////////////////////////////////////////////////////////////
207 //
208 // Plugin Definition
209 //
210 
211 // API version
212 #define PLUGIN_H235_API_VER_FN       PWLibPlugin_GetAPIVersion
213 #define PLUGIN_H235_API_VER_FN_STR   "PWLibPlugin_GetAPIVersion"
214 
215 // Harware Input Device
216 #define PLUGIN_H235_GET_DEVICE_FN	Opalh235Plugin_GetDevice
217 #define PLUGIN_H235_GET_DEVICE_FN_STR "Opalh235Plugin_GetDevice"
218 
219 
220 #  define PLUGIN_H235_IMPLEMENT(name) \
221 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_H235_API_VER_FN() \
222 { return PWLIB_PLUGIN_API_VERSION; } \
223 
224 
225 #ifdef __cplusplus
226 };
227 #endif
228 
229 #endif // __h235PLUGIN_H
230