1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/*
* openser osp module.
*
* This module enables openser to communicate with an Open Settlement
* Protocol (OSP) server. The Open Settlement Protocol is an ETSI
* defined standard for Inter-Domain VoIP pricing, authorization
* and usage exchange. The technical specifications for OSP
* (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
*
* Uli Abend was the original contributor to this module.
*
* Copyright (C) 2001-2005 Fhg Fokus
*
* This file is part of openser, a free SIP server.
*
* openser is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* openser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "osp_mod.h"
#include "provider.h"
#include "../../sr_module.h"
#include "osp/osputils.h"
#include "../../data_lump_rpl.h"
#include "../../mem/mem.h"
extern char* _spURIs[2];
extern unsigned long _spWeights[2];
extern unsigned char* _private_key;
extern unsigned char* _local_certificate;
extern unsigned char* _ca_certificate;
extern int _ssl_lifetime;
extern int _persistence;
extern int _retry_delay;
extern int _retry_limit;
extern int _timeout;
extern int _crypto_hw_support;
extern OSPTPROVHANDLE _provider;
int setup_provider() {
int result = 1;
OSPTCERT localcert;
OSPTCERT cacert;
OSPTPRIVATEKEY privatekey;
OSPTCERT *cacerts[1];
cacerts[0] = &cacert;
if ( (result = OSPPInit(_crypto_hw_support)) != 0 ) {
LOG(L_ERR, "ERROR: osp: setup_provider: could not initalize libosp. (%i)\n", result);
} else if ( OSPPUtilLoadPEMPrivateKey (_private_key, &privatekey) != 0 ) {
LOG(L_ERR, "ERROR: osp: setup_provider: could not load private key from %s\n", _private_key);
} else if ( OSPPUtilLoadPEMCert (_local_certificate, &localcert) != 0 ) {
LOG(L_ERR, "ERROR: osp: setup_provider: could not load local certificate from %s\n",_local_certificate);
} else if ( OSPPUtilLoadPEMCert (_ca_certificate, &cacert) != 0 ) {
LOG(L_ERR, "ERROR: osp: setup_provider: could not load CA certificate from %s\n", _ca_certificate);
} else if ( 0 != (result = OSPPProviderNew(
2,
(const char **)_spURIs,
_spWeights,
"http://localhost:1234",
&privatekey,
&localcert,
1,
(const OSPTCERT **)cacerts,
1,
_ssl_lifetime,
2,
_persistence,
_retry_delay,
_retry_limit,
_timeout,
"",
"",
&_provider))) {
LOG(L_ERR, "ERROR: osp: setup_provider: could not create provider. (%i)\n", result);
} else {
LOG(L_INFO,"osp: Successfully created a new (per process) provider object, handle (%d)\n",_provider);
result = 0;
}
/* Free space allocated while loading crypto information from PEM-encoded files */
if (localcert.CertData != NULL) {
//free(localcert.CertData);
}
if (cacert.CertData != NULL) {
//free(localcert.CertData);
}
if (privatekey.PrivateKeyData != NULL) {
//free(privatekey.PrivateKeyData);
}
return result;
}
int delete_provider() {
int result;
LOG(L_INFO, "osp: Deleting provider object\n");
if (0 != (result = OSPPProviderDelete(_provider,0))) {
LOG(L_ERR, "ERROR: osp: problems deleting provider object, handle (%d), error (%d)\n",_provider,result);
}
return result;
}
|