From: Simon H. <sh...@us...> - 2006-12-23 19:04:35
|
Update of /cvsroot/openh323/openh323/include In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2489 Added Files: Tag: openh323_plugins h235plugin.h h235pluginmgr.h Log Message: H235 plugin authenticator added --- NEW FILE: h235plugin.h --- /* * h235pugin.h * * h235 Implementation for the OpenH323 Project. * * Copyright (c) 2006 ISVO (Asia) Pte Ltd. All Rights Reserved. * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * Special Note: * All copied/derived work shall be subject to the same licence and * portions applicable shall remain the copyright of ISVO (Asia) Pte Ltd. * * * Contributor(s): ______________________________________. * * $Log: h235plugin.h,v $ * Revision 1.1.2.1 2006/12/23 19:04:28 shorne * H235 plugin authenticator added * * * */ #ifndef __h235PLUGIN_H #define __h235PLUGIN_H #include <time.h> #ifdef __cplusplus extern "C" { #endif ///////////////////////////////////////////////////////////////////////////////// // // h235 Plugins #define PWLIB_PLUGIN_API_VERSION 0 #define PLUGIN_H235_VERSION 1 // Function calls static const char H235_BuildClear[] = "Build_Clear"; static const char H235_BuildCrypto[] = "Build_Crypto"; static const char H235_FinaliseCrypto[] = "Finalise_Crypto"; static const char H235_ValidateClear[] = "Validate_Clear"; static const char H235_ValidateCrypto[] = "Validate_Crypto"; // Settings direction static const char GET_PLUGINH235_SETTINGS[] = "get_h235_settings"; static const char SET_PLUGINH235_SETTINGS[] = "set_h235_settings"; // Validation Constants #define Pluginh235_Val_OK 0 ///< Security parameters and Msg are ok, no security attacks #define Pluginh235_Val_Absent 1 ///< Security parameters are expected but absent #define Pluginh235_Val_Error 2 ///< Security parameters are present but incorrect #define Pluginh235_Val_InvalidTime 3 ///< Security parameters indicate peer has bad real time clock #define Pluginh235_Val_BadPassword 4 ///< Security parameters indicate bad password in token #define Pluginh235_Val_ReplyAttack 5 ///< Security parameters indicate an attack was made #define Pluginh235_Val_Disabled 6 ///< Security is disabled by local system // Application Constants #define Pluginh235_App_GKAdmission 0 ///< To Be Used for GK Admission #define Pluginh235_App_EPAuthentication 1 ///< To Be Used for EP Authentication #define Pluginh235_App_LRQOnly 2 ///< To Be Used for Location Request Authentication #define Pluginh235_App_AnyApplication 3 ///< To Be Used for Any Application // Settings constants static const char Pluginh235_Set_Application[] ="Application"; static const char Pluginh235_Set_UseGkAndEpIdentifiers[] ="UseGkAndEpIdentifiers"; static const char Pluginh235_Set_IsSecuredPDU[] ="IsSecuredPDU"; static const char Pluginh235_Set_IsSecuredSignalPDU[] ="IsSecuredSignalPDU"; static const char Pluginh235_Set_IsActive[] ="IsActive"; static const char Pluginh235_Set_RemoteId[] ="RemoteId"; static const char Pluginh235_Set_LocalId[] ="LocalId"; static const char Pluginh235_Set_Password[] ="Password"; static const char Pluginh235_Set_TimestampGracePeriod[] ="TimestampGracePeriod"; // Ras Message constants #define Pluginh235_msg_gatekeeperRequest 0 #define Pluginh235_msg_gatekeeperConfirm 1 #define Pluginh235_msg_gatekeeperReject 2 #define Pluginh235_msg_registrationRequest 3 #define Pluginh235_msg_registrationConfirm 4 #define Pluginh235_msg_registrationReject 5 #define Pluginh235_msg_unregistrationRequest 6 #define Pluginh235_msg_unregistrationConfirm 7 #define Pluginh235_msg_unregistrationReject 8 #define Pluginh235_msg_admissionRequest 9 #define Pluginh235_msg_admissionConfirm 10 #define Pluginh235_msg_admissionReject 11 #define Pluginh235_msg_bandwidthRequest 12 #define Pluginh235_msg_bandwidthConfirm 13 #define Pluginh235_msg_bandwidthReject 14 #define Pluginh235_msg_disengageRequest 15 #define Pluginh235_msg_disengageConfirm 16 #define Pluginh235_msg_disengageReject 17 #define Pluginh235_msg_locationRequest 18 #define Pluginh235_msg_locationConfirm 19 #define Pluginh235_msg_locationReject 20 #define Pluginh235_msg_infoRequest 21 #define Pluginh235_msg_infoRequestResponse 22 // Signal message constants #define Pluginh235_msg_setup 0 #define Pluginh235_msg_callProceeding 1 #define Pluginh235_msg_connect 2 #define Pluginh235_msg_alerting 3 #define Pluginh235_msg_information 4 #define Pluginh235_msg_releaseComplete 5 #define Pluginh235_msg_facility 6 #define Pluginh235_msg_progress 7 #define Pluginh235_msg_empty 8 #define Pluginh235_msg_status 9 #define Pluginh235_msg_statusInquiry 10 #define Pluginh235_msg_setupAcknowledge 11 #define Pluginh235_msg_notify 12 ///////////////////////////////////////////////////////////////////////////////// enum Pluginh235_Flags { // Token type Pluginh235_TokenTypeMask = 0x000f, Pluginh235_TokenTypeclear = 0x0000, Pluginh235_TokenTypecrypto = 0x0001, Pluginh235_TokenTypeBoth = 0x0002, // CryptoToken Style Pluginh235_TokenStyleMask = 0x0010, Pluginh235_TokenStyleHash = 0x0010, Pluginh235_TokenStyleSigned = 0x0011, Pluginh235_TokenStyleEncrypted = 0x0012 }; struct Pluginh235_Definition; struct Pluginh235_ControlDefn { const char * name; int (*control)(const struct Pluginh235_Definition * def, void * context, const char * parm, const char * value); }; ///////////////////////////////////////////////////////////////////////////////// struct Pluginh235_information { // start of version 1 fields time_t timestamp; // codec creation time and date - obtain with command: date -u "+%c = %s" const char * sourceAuthor; // source code author const char * sourceVersion; // source code version const char * sourceEmail; // source code email contact information const char * sourceURL; // source code web site const char * sourceCopyright; // source code copyright const char * sourceLicense; // source code license unsigned char sourceLicenseCode; // source code license const char * h235Description; // h235 description const char * h235Manufacturer; // h235 Manufacturer const char * h235Model; // h235 Model const char * h235Email; // h235 email contact information const char * h235URL; // h235 Manufacturer web site // end of version 1 fields }; struct Pluginh235_Definition { unsigned int version; // codec structure version // start of version 1 fields struct Pluginh235_information * info; // license information unsigned int flags; // Pluginh235_Flags, const char * desc; // text decription const char * identifier; // OID Identifier const void * userData; // user data value void *(*createh235)(const struct Pluginh235_Definition * def); // create h235 void (*destroyh235)(const struct Pluginh235_Definition * def); // destroy h235 int (*h235function)(const struct Pluginh235_Definition * def, void * context, // do H235 function const char * function,const void * data, unsigned * dataLen, const void * raw, unsigned * rawLen); struct Pluginh235_ControlDefn * h235Controls; // do control function // end of version 1 fields }; typedef struct Pluginh235_Definition * (* Pluginh235_Geth235Function)(unsigned int *, unsigned int); typedef unsigned (* Pluginh235_GetAPIVersionFunction)(); ////////////////////////////////////////////////////////////////////////////// // // Plugin Definition // // API version #define PLUGIN_H235_API_VER_FN PWLibPlugin_GetAPIVersion #define PLUGIN_H235_API_VER_FN_STR "PWLibPlugin_GetAPIVersion" // Harware Input Device #define PLUGIN_H235_GET_DEVICE_FN Opalh235Plugin_GetDevice #define PLUGIN_H235_GET_DEVICE_FN_STR "Opalh235Plugin_GetDevice" # define PLUGIN_H235_IMPLEMENT(name) \ PLUGIN_CODEC_DLL_API unsigned int PLUGIN_H235_API_VER_FN() \ { return PWLIB_PLUGIN_API_VERSION; } \ #ifdef __cplusplus }; #endif #endif // __h235PLUGIN_H --- NEW FILE: h235pluginmgr.h --- /* * h235pluginmgr.h * * h235 Implementation for the OpenH323/Opal/OpenSip Project. * * Copyright (c) 2006 ISVO (Asia) Pte Ltd. All Rights Reserved. * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * Special Note: * All copied/derived work shall be subject to the same licence and * portions applicable shall remain the copyright of ISVO (Asia) Pte Ltd. * * * Contributor(s): ______________________________________. * * $Log: h235pluginmgr.h,v $ * Revision 1.1.2.1 2006/12/23 19:04:29 shorne * H235 plugin authenticator added * * * */ #include <ptlib.h> #include <ptlib/pluginmgr.h> #include <h235auth.h> #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifdef _MSC_VER #pragma warning(disable:4100) #endif ////////////////////////////////////////////////////////////////////////////////////// struct Pluginh235_Definition; class H235PluginAuthenticator : public H235Authenticator { PCLASSINFO(H235PluginAuthenticator, H235Authenticator); public: H235PluginAuthenticator(Pluginh235_Definition * _def); H235_ClearToken * CreateClearToken(); H225_CryptoH323Token * CreateCryptoToken(); BOOL Finalise( PBYTEArray & rawPDU ); const char * GetName() const { return h235name; }; void SetName(PString & name) { h235name = name; }; ValidationResult ValidateClearToken( const H235_ClearToken & clearToken ); ValidationResult ValidateCryptoToken( const H225_CryptoH323Token & cryptoToken, const PBYTEArray & rawPDU ); BOOL IsCapability( const H235_AuthenticationMechanism & mechansim, const PASN_ObjectId & algorithmOID ); BOOL SetCapability( H225_ArrayOf_AuthenticationMechanism & mechansims, H225_ArrayOf_PASN_ObjectId & algorithmOIDs ); BOOL UseGkAndEpIdentifiers() const; BOOL IsSecuredPDU( unsigned rasPDU, BOOL received ) const; BOOL IsSecuredSignalPDU( unsigned signalPDU, BOOL received ) const; BOOL IsActive() const; const PString & GetRemoteId() const; void SetRemoteId(const PString & id); const PString & GetLocalId() const; void SetLocalId(const PString & id); const PString & GetPassword() const; void SetPassword(const PString & pw); int GetTimestampGracePeriod() const; void SetTimestampGracePeriod(int grace); Application GetApplication(); protected: PString h235name; unsigned type; Pluginh235_Definition * def; }; ///////////////////////////////////////////////////////////////////////////////////// class h235PluginDeviceManager : public PPluginModuleManager { PCLASSINFO(h235PluginDeviceManager, PPluginModuleManager); public: h235PluginDeviceManager(PPluginManager * pluginMgr = NULL); ~h235PluginDeviceManager(); void OnLoadPlugin(PDynaLink & dll, INT code); virtual void OnShutdown(); static void Bootstrap(); virtual BOOL Registerh235(unsigned int count, void * _h235List); virtual BOOL Unregisterh235(unsigned int count, void * _h235List); void CreateH235Authenticator(Pluginh235_Definition * h235authenticator); }; static PFactory<PPluginModuleManager>::Worker<h235PluginDeviceManager> h323PluginCodecManagerFactory("h235PluginDeviceManager", true); /////////////////////////////////////////////////////////////////////////////// typedef PFactory<H235Authenticator> h235Factory; #define H235_REGISTER(cls, h235Name) static h235Factory::Worker<cls> cls##Factory(h235Name, true); \ #define H235_DEFINE_AUTHENTICATOR(cls, h235Name, fmtName) \ class cls : public H235PluginAuthenticator { \ public: \ cls() : H235PluginAuthenticator() { } \ PString GetName() const \ { return fmtName; } \ }; \ H235_REGISTER(cls, capName) \ ///////////////////////////////////////////////////////////////////////////// |