Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Enumerations | Functions | Variables
app_osplookup.c File Reference

Open Settlement Protocol (OSP) Applications. More...

#include "asterisk.h"
#include <osp/osp.h>
#include <osp/osputils.h>
#include <osp/ospb64.h>
#include "asterisk/paths.h"
#include "asterisk/lock.h"
#include "asterisk/config.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/cli.h"
Include dependency graph for app_osplookup.c:

Go to the source code of this file.

Data Structures

struct  osp_callid
 
struct  osp_headers
 
struct  osp_metrics
 
struct  osp_npdata
 
struct  osp_provider
 
struct  osp_results
 

Macros

#define AST_OSP_ERROR   ((char*)"ERROR") /* Return status, error */
 
#define AST_OSP_FAILED   ((char*)"FAILED") /* Return status, failed */
 
#define AST_OSP_SUCCESS   ((char*)"SUCCESS") /* Return status, success */
 
#define OSP_AST_ERROR   ((int)-1) /* Asterisk function call error */
 
#define OSP_AST_OK   ((int)0) /* Asterisk function call successful */
 
#define OSP_AUDIT_URL   ((const char*)"localhost") /* OSP default Audit URL */
 
#define OSP_CALLID_H323   ((unsigned int)(1 << 1)) /* H.323 */
 
#define OSP_CALLID_IAX   ((unsigned int)(1 << 2)) /* IAX2 */
 
#define OSP_CALLID_MAXNUM   ((unsigned int)3) /* Max number of call ID types */
 
#define OSP_CALLID_SIP   ((unsigned int)(1 << 0)) /* SIP */
 
#define OSP_CALLID_UNDEF   ((unsigned int)0) /* Undefined */
 
#define OSP_CONFIG_FILE   ((const char*)"osp.conf") /* OSP configuration file name */
 
#define OSP_CUSTOMER_ID   ((const char*)"") /* OSP customer ID */
 
#define OSP_DEF_AUTHPOLICY   OSP_AUTH_YES /* OSP default auth policy, yes */
 
#define OSP_DEF_FLOATSTATS   ((float)-1) /* OSP default float statistic */
 
#define OSP_DEF_INTSTATS   ((int)-1) /* OSP default int statistic */
 
#define OSP_DEF_MAXCONNECT   ((unsigned int)20) /* OSP default max_connections */
 
#define OSP_DEF_MAXDESTS   ((unsigned int)12) /* OSP default max number of destinations */
 
#define OSP_DEF_PROTOCOL   OSP_PROT_SIP /* OSP default signaling protocol, SIP */
 
#define OSP_DEF_PROVIDER   ((const char*)"default") /* OSP default provider context name */
 
#define OSP_DEF_RETRYDELAY   ((unsigned int)0) /* OSP default retry delay */
 
#define OSP_DEF_RETRYLIMIT   ((unsigned int)2) /* OSP default retry times */
 
#define OSP_DEF_SRVTYPE   OSP_SRV_VOICE /* OSP default service type, voice */
 
#define OSP_DEF_TIMELIMIT   ((unsigned int)0) /* OSP default duration limit, no limit */
 
#define OSP_DEF_TIMEOUT   ((unsigned int)500) /* OSP default timeout in ms */
 
#define OSP_DEF_WORKMODE   OSP_MODE_DIRECT /* OSP default work mode, direct */
 
#define OSP_DEVICE_ID   ((const char*)"") /* OSP device ID */
 
#define OSP_ERROR   ((int)-1) /* OSP function call error */
 
#define OSP_FAILED   ((int)0) /* OSP function call failed */
 
#define OSP_GENERAL_CAT   ((const char*)"general") /* OSP global configuration context name */
 
#define OSP_HTTP_PERSISTENCE   ((int)1) /* In seconds */
 
#define OSP_INVALID_HANDLE   ((int)-1) /* Invalid OSP handle, provider, transaction etc. */
 
#define OSP_LOCAL_VALIDATION   ((int)1) /* Validate OSP token locally */
 
#define OSP_MAX_CERTS   ((unsigned int)10) /* OSP max number of cacerts */
 
#define OSP_MAX_CUSTOMINFO   ((unsigned int)8) /* OSP max number of custom info */
 
#define OSP_MAX_MAXCONNECT   ((unsigned int)1000) /* OSP max max_connections */
 
#define OSP_MAX_RETRYDELAY   ((unsigned int)10) /* OSP max retry delay */
 
#define OSP_MAX_RETRYLIMIT   ((unsigned int)100) /* OSP max retry times */
 
#define OSP_MAX_SPOINTS   ((unsigned int)10) /* OSP max number of service points */
 
#define OSP_MAX_TIMEOUT   ((unsigned int)10000) /* OSP max timeout in ms */
 
#define OSP_MIN_MAXCONNECT   ((unsigned int)1) /* OSP min max_connections */
 
#define OSP_MIN_RETRYDELAY   ((unsigned int)0) /* OSP min retry delay */
 
#define OSP_MIN_RETRYLIMIT   ((unsigned int)0) /* OSP min retry times */
 
#define OSP_MIN_TIMEOUT   ((unsigned int)200) /* OSP min timeout in ms */
 
#define OSP_OK   ((int)1) /* OSP function call successful */
 
#define OSP_PROT_H323   ((const char*)"H323") /* H.323 Q.931 protocol name*/
 
#define OSP_PROT_IAX   ((const char*)"IAX") /* IAX2 protocol name */
 
#define OSP_PROT_SIP   ((const char*)"SIP") /* SIP protocol name */
 
#define OSP_PROT_SKYPE   ((const char*)"SKYPE") /* Skype protocol name */
 
#define OSP_SIP_HEADER   ((const char*)"P-OSP-Auth-Token")
 
#define OSP_SIZE_INTSTR   ((unsigned int)16) /* OSP signed/unsigned int string buffer size */
 
#define OSP_SIZE_KEYSTR   ((unsigned int)1024) /* OSP certificate string buffer size */
 
#define OSP_SIZE_NORSTR   ((unsigned int)256) /* OSP normal string buffer size */
 
#define OSP_SIZE_OUTSTR   ((unsigned int)288) /* OSP out size for osp_convert_inout */
 
#define OSP_SIZE_QOSSTR   ((unsigned int)1024) /* QoS string buffer size */
 
#define OSP_SIZE_TECHSTR   ((unsigned int)32) /* OSP signed/unsigned int string buffer size */
 
#define OSP_SIZE_TOKSTR   ((unsigned int)4096) /* OSP token string buffer size */
 
#define OSP_SIZE_UUID   ((unsigned int)16) /* UUID size */
 
#define OSP_SIZE_UUIDSTR   ((unsigned int)36) /* UUID string size */
 
#define OSP_SSL_LIFETIME   ((unsigned int)300) /* SSL life time, in seconds */
 
#define OSP_TECH_H323   ((const char*)"H323") /* OH323 tech name */
 
#define OSP_TECH_IAX   ((const char*)"IAX2") /* IAX2 tech name */
 
#define OSP_TECH_SIP   ((const char*)"SIP") /* SIP tech name */
 
#define OSP_TECH_SKYPE   ((const char*)"SKYPE") /* Skype tech name */
 

Enumerations

enum  osp_authpolicy { OSP_AUTH_NO = 0, OSP_AUTH_YES, OSP_AUTH_EXC }
 
enum  osp_callleg { OSP_CALL_INBOUND, OSP_CALL_OUTBOUND }
 
enum  osp_direction { OSP_DIR_RX = 0, OSP_DIR_TX, OSP_DIR_NUMBER }
 
enum  osp_srvtype { OSP_SRV_VOICE = 0, OSP_SRV_NPQUERY }
 
enum  osp_workmode { OSP_MODE_DIRECT = 0, OSP_MODE_INDIRECT }
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static OSPEFAILREASON asterisk2osp (int cause)
 Convert Asterisk status to TC code. More...
 
static char * handle_cli_osp_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int load_module (void)
 
static int osp_auth (const char *name, int *trans, const char *source, const char *calling, const char *called, const char *token, unsigned int *timelimit)
 OSP Authentication function. More...
 
static int osp_check_destination (struct osp_provider *provider, const char *calling, const char *called, const char *destination, unsigned int tokenlen, const char *token, OSPEFAILREASON *reason, struct osp_results *results)
 Choose min duration limit. More...
 
static unsigned int osp_choose_timelimit (unsigned int in, unsigned int out)
 Choose min duration limit. More...
 
static void osp_convert_inout (const char *src, char *dest, unsigned int destsize)
 Convert "address:port" to "[x.x.x.x]:port" or "hostname:port" format. More...
 
static void osp_convert_outin (const char *src, char *dest, unsigned int destsize)
 Convert "[x.x.x.x]:port" or "hostname:prot" to "address:port" format. More...
 
static int osp_create_callid (unsigned int type, struct osp_callid *callid)
 Create a call ID according to the type. More...
 
static int osp_create_provider (struct ast_config *cfg, const char *name)
 Create OSP provider handle according to configuration. More...
 
static int osp_create_transaction (const char *name, int *trans, char *source, unsigned int srcsize)
 Create OSP transaction handle. More...
 
static int osp_create_uuid (unsigned char *uuid, unsigned int *bufsize)
 Create a UUID. More...
 
static int osp_finish (int trans, int recorded, int cause, time_t start, time_t connect, time_t end, unsigned int release, const char *inqos, const char *outqos)
 OSP Finish function. More...
 
static int osp_get_provider (const char *name, struct osp_provider **provider)
 Get OSP provider by name. More...
 
static float osp_get_varfloat (const char *vstr)
 Get float from variable string. More...
 
static int osp_get_varint (const char *vstr)
 Get integer from variable string. More...
 
static int osp_load (int reload)
 
static int osp_lookup (const char *name, unsigned int callidtypes, const char *actualsrc, const char *srcdev, const char *calling, const char *called, const char *snetid, struct osp_npdata *np, struct osp_headers *headers, const char *cinfo[], struct osp_results *results)
 OSP Lookup function. More...
 
static int osp_next (const char *name, int cause, struct osp_results *results)
 OSP Lookup Next function. More...
 
static int osp_report_qos (int trans, enum osp_callleg leg, const char *qos)
 Report QoS. More...
 
static int osp_unload (void)
 
static int osp_uuid2str (unsigned char *uuid, char *buffer, unsigned int bufsize)
 UUID to string. More...
 
static int osp_validate_token (int trans, const char *source, const char *destination, const char *calling, const char *called, const char *token, unsigned int *timelimit)
 Validate OSP token of inbound call. More...
 
static int ospauth_exec (struct ast_channel *chan, const char *data)
 OSP Application OSPAuth. More...
 
static int ospfinished_exec (struct ast_channel *chan, const char *data)
 OSP Application OSPFinish. More...
 
static int osplookup_exec (struct ast_channel *chan, const char *data)
 OSP Application OSPLookup. More...
 
static int ospnext_exec (struct ast_channel *chan, const char *data)
 OSP Application OSPNext. More...
 
static int reload (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Open Settlement Protocol Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, }
 
static const char app1 [] = "OSPAuth"
 
static const char app2 [] = "OSPLookup"
 
static const char app3 [] = "OSPNext"
 
static const char app4 [] = "OSPFinish"
 
static const struct ast_module_infoast_module_info = &__mod_info
 
const char * B64CACert = "MIIBYDCCAQoCAQEwDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTAyMDIwNDE4MjU1MloXDTEyMDIwMzE4MjU1MlowOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPGeGwV41EIhX0jEDFLRXQhDEr50OUQPq+f55VwQd0TQNts06BP29+UiNdRW3c3IRHdZcJdC1Cg68ME9cgeq0h8CAwEAATANBgkqhkiG9w0BAQQFAANBAGkzBSj1EnnmUxbaiG1N4xjIuLAWydun7o3bFk2tV8dBIhnuh445obYyk1EnQ27kI7eACCILBZqi2MHDOIMnoN0="
 
const char * B64LCert = "MIIBeTCCASMCEHqkOHVRRWr+1COq3CR/xsowDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTA1MDYyMzAwMjkxOFoXDTA2MDYyNDAwMjkxOFowRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCvLeZfj1G0wuJb8JTcVeZaZftncEmRluOnaME3ustd918lRMDYokZmtmDZN8SrP0yd1pfVqZ7NkmBACbBX0k7pAgMBAAEwDQYJKoZIhvcNAQEEBQADQQDnV8QNFVVJx/+7IselU0wsepqMurivXZzuxOmTEmTVDzCJx1xhA8jd3vGAj7XDIYiPub1PV23eY5a2ARJuw5w9"
 
const char * B64PKey = "MIIBOgIBAAJBAK8t5l+PUbTC4lvwlNxV5lpl+2dwSZGW46dowTe6y133XyVEwNiiRma2YNk3xKs/TJ3Wl9Wpns2SYEAJsFfSTukCAwEAAQJAPz13vCm2GmZ8Zyp74usTxLCqSJZNyMRLHQWBM0g44Iuy4wE3vpi7Wq+xYuSOH2mu4OddnxswCP4QhaXVQavTAQIhAOBVCKXtppEw9UaOBL4vW0Ed/6EA/1D8hDW6St0h7EXJAiEAx+iRmZKhJD6VT84dtX5ZYNVk3j3dAcIOovpzUj9a0CECIEduTCapmZQ5xqAEsLXuVlxRtQgLTUD4ZxDElPn8x0MhAiBE2HlcND0+qDbvtwJQQOUzDgqg5xk3w8capboVdzAlQQIhAMC+lDL7+gDYkNAft5Mu+NObJmQs4Cr+DkDFsKqoxqrm"
 
static struct ast_cli_entry cli_osp []
 
static int osp_hardware = 0
 
static int osp_initialized = 0
 
static ast_mutex_t osp_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct osp_providerosp_providers = NULL
 
static int osp_security = 0
 
static unsigned int osp_tokenformat = TOKEN_ALGO_SIGNED
 

Detailed Description

Open Settlement Protocol (OSP) Applications.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
ExtRef:

The OSP Toolkit: http://www.transnexus.com

OpenSSL http://www.openssl.org

Definition in file app_osplookup.c.

Macro Definition Documentation

◆ AST_OSP_ERROR

#define AST_OSP_ERROR   ((char*)"ERROR") /* Return status, error */

Definition at line 441 of file app_osplookup.c.

Referenced by ospauth_exec(), ospfinished_exec(), osplookup_exec(), and ospnext_exec().

◆ AST_OSP_FAILED

#define AST_OSP_FAILED   ((char*)"FAILED") /* Return status, failed */

Definition at line 440 of file app_osplookup.c.

Referenced by ospauth_exec(), ospfinished_exec(), osplookup_exec(), and ospnext_exec().

◆ AST_OSP_SUCCESS

#define AST_OSP_SUCCESS   ((char*)"SUCCESS") /* Return status, success */

Definition at line 439 of file app_osplookup.c.

Referenced by ospauth_exec(), ospfinished_exec(), osplookup_exec(), and ospnext_exec().

◆ OSP_AST_ERROR

#define OSP_AST_ERROR   ((int)-1) /* Asterisk function call error */

Definition at line 500 of file app_osplookup.c.

Referenced by ospauth_exec(), ospfinished_exec(), osplookup_exec(), and ospnext_exec().

◆ OSP_AST_OK

#define OSP_AST_OK   ((int)0) /* Asterisk function call successful */

Definition at line 499 of file app_osplookup.c.

Referenced by ospauth_exec(), ospfinished_exec(), osplookup_exec(), and ospnext_exec().

◆ OSP_AUDIT_URL

#define OSP_AUDIT_URL   ((const char*)"localhost") /* OSP default Audit URL */

Definition at line 520 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_CALLID_H323

#define OSP_CALLID_H323   ((unsigned int)(1 << 1)) /* H.323 */

Definition at line 457 of file app_osplookup.c.

Referenced by osp_create_callid(), osplookup_exec(), and ospnext_exec().

◆ OSP_CALLID_IAX

#define OSP_CALLID_IAX   ((unsigned int)(1 << 2)) /* IAX2 */

Definition at line 458 of file app_osplookup.c.

Referenced by osp_create_callid(), and osplookup_exec().

◆ OSP_CALLID_MAXNUM

#define OSP_CALLID_MAXNUM   ((unsigned int)3) /* Max number of call ID types */

Definition at line 459 of file app_osplookup.c.

Referenced by osp_lookup().

◆ OSP_CALLID_SIP

#define OSP_CALLID_SIP   ((unsigned int)(1 << 0)) /* SIP */

Definition at line 456 of file app_osplookup.c.

Referenced by osp_create_callid(), and osplookup_exec().

◆ OSP_CALLID_UNDEF

#define OSP_CALLID_UNDEF   ((unsigned int)0) /* Undefined */

Definition at line 455 of file app_osplookup.c.

Referenced by osplookup_exec(), and ospnext_exec().

◆ OSP_CONFIG_FILE

#define OSP_CONFIG_FILE   ((const char*)"osp.conf") /* OSP configuration file name */

Definition at line 502 of file app_osplookup.c.

Referenced by osp_load().

◆ OSP_CUSTOMER_ID

#define OSP_CUSTOMER_ID   ((const char*)"") /* OSP customer ID */

Definition at line 524 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_AUTHPOLICY

#define OSP_DEF_AUTHPOLICY   OSP_AUTH_YES /* OSP default auth policy, yes */

Definition at line 519 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_FLOATSTATS

#define OSP_DEF_FLOATSTATS   ((float)-1) /* OSP default float statistic */

Definition at line 533 of file app_osplookup.c.

Referenced by osp_get_varfloat(), and osp_report_qos().

◆ OSP_DEF_INTSTATS

#define OSP_DEF_INTSTATS   ((int)-1) /* OSP default int statistic */

Definition at line 532 of file app_osplookup.c.

Referenced by osp_finish(), osp_get_varint(), and osp_report_qos().

◆ OSP_DEF_MAXCONNECT

#define OSP_DEF_MAXCONNECT   ((unsigned int)20) /* OSP default max_connections */

Definition at line 507 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_MAXDESTS

#define OSP_DEF_MAXDESTS   ((unsigned int)12) /* OSP default max number of destinations */

Definition at line 526 of file app_osplookup.c.

Referenced by osp_lookup().

◆ OSP_DEF_PROTOCOL

#define OSP_DEF_PROTOCOL   OSP_PROT_SIP /* OSP default signaling protocol, SIP */

Definition at line 528 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_PROVIDER

#define OSP_DEF_PROVIDER   ((const char*)"default") /* OSP default provider context name */

Definition at line 504 of file app_osplookup.c.

Referenced by ospauth_exec(), osplookup_exec(), and ospnext_exec().

◆ OSP_DEF_RETRYDELAY

#define OSP_DEF_RETRYDELAY   ((unsigned int)0) /* OSP default retry delay */

Definition at line 510 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_RETRYLIMIT

#define OSP_DEF_RETRYLIMIT   ((unsigned int)2) /* OSP default retry times */

Definition at line 513 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_SRVTYPE

#define OSP_DEF_SRVTYPE   OSP_SRV_VOICE /* OSP default service type, voice */

Definition at line 530 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_TIMELIMIT

#define OSP_DEF_TIMELIMIT   ((unsigned int)0) /* OSP default duration limit, no limit */

◆ OSP_DEF_TIMEOUT

#define OSP_DEF_TIMEOUT   ((unsigned int)500) /* OSP default timeout in ms */

Definition at line 516 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEF_WORKMODE

#define OSP_DEF_WORKMODE   OSP_MODE_DIRECT /* OSP default work mode, direct */

Definition at line 529 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_DEVICE_ID

#define OSP_DEVICE_ID   ((const char*)"") /* OSP device ID */

Definition at line 525 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_ERROR

#define OSP_ERROR   ((int)-1) /* OSP function call error */

◆ OSP_FAILED

#define OSP_FAILED   ((int)0) /* OSP function call failed */

◆ OSP_GENERAL_CAT

#define OSP_GENERAL_CAT   ((const char*)"general") /* OSP global configuration context name */

Definition at line 503 of file app_osplookup.c.

Referenced by osp_load().

◆ OSP_HTTP_PERSISTENCE

#define OSP_HTTP_PERSISTENCE   ((int)1) /* In seconds */

Definition at line 523 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_INVALID_HANDLE

#define OSP_INVALID_HANDLE   ((int)-1) /* Invalid OSP handle, provider, transaction etc. */

◆ OSP_LOCAL_VALIDATION

#define OSP_LOCAL_VALIDATION   ((int)1) /* Validate OSP token locally */

Definition at line 521 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MAX_CERTS

#define OSP_MAX_CERTS   ((unsigned int)10) /* OSP max number of cacerts */

Definition at line 505 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MAX_CUSTOMINFO

#define OSP_MAX_CUSTOMINFO   ((unsigned int)8) /* OSP max number of custom info */

Definition at line 531 of file app_osplookup.c.

Referenced by osp_lookup(), and osplookup_exec().

◆ OSP_MAX_MAXCONNECT

#define OSP_MAX_MAXCONNECT   ((unsigned int)1000) /* OSP max max_connections */

Definition at line 509 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MAX_RETRYDELAY

#define OSP_MAX_RETRYDELAY   ((unsigned int)10) /* OSP max retry delay */

Definition at line 512 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MAX_RETRYLIMIT

#define OSP_MAX_RETRYLIMIT   ((unsigned int)100) /* OSP max retry times */

Definition at line 515 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MAX_SPOINTS

#define OSP_MAX_SPOINTS   ((unsigned int)10) /* OSP max number of service points */

Definition at line 506 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MAX_TIMEOUT

#define OSP_MAX_TIMEOUT   ((unsigned int)10000) /* OSP max timeout in ms */

Definition at line 518 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MIN_MAXCONNECT

#define OSP_MIN_MAXCONNECT   ((unsigned int)1) /* OSP min max_connections */

Definition at line 508 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MIN_RETRYDELAY

#define OSP_MIN_RETRYDELAY   ((unsigned int)0) /* OSP min retry delay */

Definition at line 511 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MIN_RETRYLIMIT

#define OSP_MIN_RETRYLIMIT   ((unsigned int)0) /* OSP min retry times */

Definition at line 514 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_MIN_TIMEOUT

#define OSP_MIN_TIMEOUT   ((unsigned int)200) /* OSP min timeout in ms */

Definition at line 517 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_OK

#define OSP_OK   ((int)1) /* OSP function call successful */

◆ OSP_PROT_H323

#define OSP_PROT_H323   ((const char*)"H323") /* H.323 Q.931 protocol name*/

Definition at line 463 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_PROT_IAX

#define OSP_PROT_IAX   ((const char*)"IAX") /* IAX2 protocol name */

Definition at line 464 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_PROT_SIP

#define OSP_PROT_SIP   ((const char*)"SIP") /* SIP protocol name */

Definition at line 462 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_PROT_SKYPE

#define OSP_PROT_SKYPE   ((const char*)"SKYPE") /* Skype protocol name */

Definition at line 465 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_SIP_HEADER

#define OSP_SIP_HEADER   ((const char*)"P-OSP-Auth-Token")

Definition at line 474 of file app_osplookup.c.

Referenced by osplookup_exec(), and ospnext_exec().

◆ OSP_SIZE_INTSTR

#define OSP_SIZE_INTSTR   ((unsigned int)16) /* OSP signed/unsigned int string buffer size */

Definition at line 444 of file app_osplookup.c.

Referenced by ospauth_exec(), and ospfinished_exec().

◆ OSP_SIZE_KEYSTR

#define OSP_SIZE_KEYSTR   ((unsigned int)1024) /* OSP certificate string buffer size */

Definition at line 446 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_SIZE_NORSTR

#define OSP_SIZE_NORSTR   ((unsigned int)256) /* OSP normal string buffer size */

◆ OSP_SIZE_OUTSTR

#define OSP_SIZE_OUTSTR   ((unsigned int)288) /* OSP out size for osp_convert_inout */

Definition at line 452 of file app_osplookup.c.

Referenced by osp_lookup(), and osp_validate_token().

◆ OSP_SIZE_QOSSTR

#define OSP_SIZE_QOSSTR   ((unsigned int)1024) /* QoS string buffer size */

Definition at line 451 of file app_osplookup.c.

Referenced by ospfinished_exec().

◆ OSP_SIZE_TECHSTR

#define OSP_SIZE_TECHSTR   ((unsigned int)32) /* OSP signed/unsigned int string buffer size */

Definition at line 448 of file app_osplookup.c.

◆ OSP_SIZE_TOKSTR

#define OSP_SIZE_TOKSTR   ((unsigned int)4096) /* OSP token string buffer size */

◆ OSP_SIZE_UUID

#define OSP_SIZE_UUID   ((unsigned int)16) /* UUID size */

Definition at line 449 of file app_osplookup.c.

Referenced by osp_create_uuid().

◆ OSP_SIZE_UUIDSTR

#define OSP_SIZE_UUIDSTR   ((unsigned int)36) /* UUID string size */

Definition at line 450 of file app_osplookup.c.

Referenced by osp_uuid2str().

◆ OSP_SSL_LIFETIME

#define OSP_SSL_LIFETIME   ((unsigned int)300) /* SSL life time, in seconds */

Definition at line 522 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ OSP_TECH_H323

#define OSP_TECH_H323   ((const char*)"H323") /* OH323 tech name */

Definition at line 469 of file app_osplookup.c.

Referenced by osp_check_destination(), osp_lookup(), osplookup_exec(), and ospnext_exec().

◆ OSP_TECH_IAX

#define OSP_TECH_IAX   ((const char*)"IAX2") /* IAX2 tech name */

Definition at line 470 of file app_osplookup.c.

Referenced by osp_check_destination(), osp_lookup(), osplookup_exec(), and ospnext_exec().

◆ OSP_TECH_SIP

#define OSP_TECH_SIP   ((const char*)"SIP") /* SIP tech name */

Definition at line 468 of file app_osplookup.c.

Referenced by osp_check_destination(), osp_lookup(), osplookup_exec(), and ospnext_exec().

◆ OSP_TECH_SKYPE

#define OSP_TECH_SKYPE   ((const char*)"SKYPE") /* Skype tech name */

Definition at line 471 of file app_osplookup.c.

Referenced by osp_check_destination(), osp_lookup(), osplookup_exec(), and ospnext_exec().

Enumeration Type Documentation

◆ osp_authpolicy

Enumerator
OSP_AUTH_NO 
OSP_AUTH_YES 
OSP_AUTH_EXC 

Definition at line 477 of file app_osplookup.c.

477  {
478  OSP_AUTH_NO = 0, /* Accept any call */
479  OSP_AUTH_YES, /* Accept call with valid OSP token or without OSP token */
480  OSP_AUTH_EXC /* Only accept call with valid OSP token */
481 };

◆ osp_callleg

Enumerator
OSP_CALL_INBOUND 
OSP_CALL_OUTBOUND 

Definition at line 602 of file app_osplookup.c.

602  {
603  OSP_CALL_INBOUND, /* Inbound call leg */
604  OSP_CALL_OUTBOUND /* Outbound call leg */
605 };

◆ osp_direction

Enumerator
OSP_DIR_RX 
OSP_DIR_TX 
OSP_DIR_NUMBER 

Definition at line 608 of file app_osplookup.c.

608  {
609  OSP_DIR_RX = 0, /* Receive */
610  OSP_DIR_TX, /* Send */
611  OSP_DIR_NUMBER /* Number of directions */
612 };

◆ osp_srvtype

Enumerator
OSP_SRV_VOICE 
OSP_SRV_NPQUERY 

Definition at line 490 of file app_osplookup.c.

490  {
491  OSP_SRV_VOICE = 0, /* Normal voice service */
492  OSP_SRV_NPQUERY /* Ported number query service */
493 };

◆ osp_workmode

Enumerator
OSP_MODE_DIRECT 
OSP_MODE_INDIRECT 

Definition at line 484 of file app_osplookup.c.

484  {
485  OSP_MODE_DIRECT= 0, /* Direct */
486  OSP_MODE_INDIRECT /* Indirect */
487 };

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 3170 of file app_osplookup.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 3170 of file app_osplookup.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 3170 of file app_osplookup.c.

◆ asterisk2osp()

static OSPEFAILREASON asterisk2osp ( int  cause)
static

Convert Asterisk status to TC code.

Parameters
causeAsterisk hangup cause
Returns
OSP TC code

Definition at line 1313 of file app_osplookup.c.

Referenced by osp_finish(), and osp_next().

1315 {
1316  return (OSPEFAILREASON)cause;
1317 }

◆ handle_cli_osp_show()

static char* handle_cli_osp_show ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3022 of file app_osplookup.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_mutex_lock, ast_mutex_unlock, osp_provider::authpolicy, osp_provider::cacerts, osp_provider::canum, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, osp_provider::defprotocol, ast_cli_args::fd, osp_provider::handle, osp_provider::localcert, osp_provider::maxconnect, osp_provider::name, osp_provider::next, NULL, osp_hardware, osp_initialized, osp_lock, osp_security, osp_tokenformat, osp_provider::privatekey, provider, osp_provider::retrydelay, osp_provider::retrylimit, osp_provider::source, osp_provider::spnum, osp_provider::spoints, osp_provider::srvtype, osp_provider::timeout, ast_cli_entry::usage, and osp_provider::workmode.

3023 {
3024  int i;
3025  int found = 0;
3026  struct osp_provider* provider;
3027  const char* name = NULL;
3028  const char* tokenalgo;
3029 
3030  switch (cmd) {
3031  case CLI_INIT:
3032  e->command = "osp show";
3033  e->usage =
3034  "Usage: osp show\n"
3035  " Displays information on Open Settlement Protocol support\n";
3036  return NULL;
3037  case CLI_GENERATE:
3038  return NULL;
3039  }
3040 
3041  if ((a->argc < 2) || (a->argc > 3)) {
3042  return CLI_SHOWUSAGE;
3043  }
3044 
3045  if (a->argc > 2) {
3046  name = a->argv[2];
3047  }
3048 
3049  if (!name) {
3050  switch (osp_tokenformat) {
3051  case TOKEN_ALGO_BOTH:
3052  tokenalgo = "Both";
3053  break;
3054  case TOKEN_ALGO_UNSIGNED:
3055  tokenalgo = "Unsigned";
3056  break;
3057  case TOKEN_ALGO_SIGNED:
3058  default:
3059  tokenalgo = "Signed";
3060  break;
3061  }
3062  ast_cli(a->fd, "OSP: %s/%s/%s/%s\n",
3063  osp_initialized ? "Initialized" : "Uninitialized",
3064  osp_hardware ? "Accelerated" : "Normal",
3065  osp_security ? "Enabled" : "Disabled",
3066  tokenalgo);
3067  }
3068 
3070  for (provider = osp_providers; provider; provider = provider->next) {
3071  if (!name || !strcasecmp(provider->name, name)) {
3072  if (found) {
3073  ast_cli(a->fd, "\n");
3074  }
3075  ast_cli(a->fd, " == OSP Provider '%s' == \n", provider->name);
3076  if (osp_security) {
3077  ast_cli(a->fd, "Local Private Key: %s\n", provider->privatekey);
3078  ast_cli(a->fd, "Local Certificate: %s\n", provider->localcert);
3079  for (i = 0; i < provider->canum; i++) {
3080  ast_cli(a->fd, "CA Certificate %d: %s\n", i + 1, provider->cacerts[i]);
3081  }
3082  }
3083  for (i = 0; i < provider->spnum; i++) {
3084  ast_cli(a->fd, "Service Point %d: %s\n", i + 1, provider->spoints[i]);
3085  }
3086  ast_cli(a->fd, "Max Connections: %d\n", provider->maxconnect);
3087  ast_cli(a->fd, "Retry Delay: %d seconds\n", provider->retrydelay);
3088  ast_cli(a->fd, "Retry Limit: %d\n", provider->retrylimit);
3089  ast_cli(a->fd, "Timeout: %d milliseconds\n", provider->timeout);
3090  ast_cli(a->fd, "Source: %s\n", strlen(provider->source) ? provider->source : "<unspecified>");
3091  ast_cli(a->fd, "Auth Policy %d\n", provider->authpolicy);
3092  ast_cli(a->fd, "Default protocol %s\n", provider->defprotocol);
3093  ast_cli(a->fd, "Work mode %d\n", provider->workmode);
3094  ast_cli(a->fd, "Service type %d\n", provider->srvtype);
3095  ast_cli(a->fd, "OSP Handle: %d\n", provider->handle);
3096  found++;
3097  }
3098  }
3100 
3101  if (!found) {
3102  if (name) {
3103  ast_cli(a->fd, "Unable to find OSP provider '%s'\n", name);
3104  } else {
3105  ast_cli(a->fd, "No OSP providers configured\n");
3106  }
3107  }
3108 
3109  return CLI_SUCCESS;
3110 }
static int osp_hardware
enum osp_authpolicy authpolicy
const int argc
Definition: cli.h:160
OSPTPROVHANDLE handle
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
unsigned int maxconnect
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
char name[OSP_SIZE_NORSTR]
unsigned int retrylimit
static int osp_initialized
const int fd
Definition: cli.h:159
char localcert[OSP_SIZE_NORSTR]
const char * defprotocol
unsigned int canum
const char *const * argv
Definition: cli.h:161
unsigned int timeout
#define CLI_SHOWUSAGE
Definition: cli.h:45
unsigned int retrydelay
char cacerts[OSP_MAX_CERTS][OSP_SIZE_NORSTR]
static const char name[]
Definition: cdr_mysql.c:74
char * command
Definition: cli.h:186
enum osp_workmode workmode
char privatekey[OSP_SIZE_NORSTR]
static unsigned int osp_tokenformat
static int osp_security
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
static struct osp_provider * osp_providers
struct osp_provider * next
unsigned int spnum
char source[OSP_SIZE_NORSTR]
enum osp_srvtype srvtype
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
static ast_mutex_t osp_lock
char spoints[OSP_MAX_SPOINTS][OSP_SIZE_NORSTR]
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ load_module()

static int load_module ( void  )
static

Definition at line 3128 of file app_osplookup.c.

References app1, app2, app3, app4, ast_cli_register_multiple, AST_MODULE_LOAD_DECLINE, ast_register_application_xml, osp_load(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), and ospnext_exec().

Referenced by reload().

3129 {
3130  int res;
3131 
3132  if (!osp_load(0))
3133  return AST_MODULE_LOAD_DECLINE;
3134 
3135  ast_cli_register_multiple(cli_osp, sizeof(cli_osp) / sizeof(struct ast_cli_entry));
3140 
3141  return res;
3142 }
descriptor for a cli entry.
Definition: cli.h:171
static const char app1[]
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
static const char app3[]
static const char app4[]
static int osp_load(int reload)
static int ospnext_exec(struct ast_channel *chan, const char *data)
OSP Application OSPNext.
static int ospfinished_exec(struct ast_channel *chan, const char *data)
OSP Application OSPFinish.
static int ospauth_exec(struct ast_channel *chan, const char *data)
OSP Application OSPAuth.
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static struct ast_cli_entry cli_osp[]
static int osplookup_exec(struct ast_channel *chan, const char *data)
OSP Application OSPLookup.
static const char app2[]
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ osp_auth()

static int osp_auth ( const char *  name,
int *  trans,
const char *  source,
const char *  calling,
const char *  called,
const char *  token,
unsigned int *  timelimit 
)
static

OSP Authentication function.

Parameters
nameOSP provider context name
transOSP transaction handle, output
sourceSource of inbound call
callingCalling number
calledCalled number
tokenOSP token, may be empty
timelimitCall duration limit, output
Returns
OSP_OK Authenricated, OSP_FAILED Unauthenticated, OSP_ERROR Error

Definition at line 1330 of file app_osplookup.c.

References ast_debug, ast_log, ast_strlen_zero, osp_provider::authpolicy, LOG_ERROR, NULL, OSP_AUTH_EXC, OSP_AUTH_NO, OSP_AUTH_YES, osp_create_transaction(), OSP_DEF_TIMELIMIT, OSP_ERROR, OSP_FAILED, osp_get_provider(), OSP_INVALID_HANDLE, OSP_OK, OSP_SIZE_NORSTR, osp_validate_token(), and provider.

Referenced by ospauth_exec().

1338 {
1339  int res;
1340  struct osp_provider* provider = NULL;
1341  char dest[OSP_SIZE_NORSTR];
1342 
1343  if ((trans == NULL) || (timelimit == NULL)) {
1344  ast_log(LOG_ERROR, "Invalid parameters\n");
1345  return OSP_ERROR;
1346  }
1347 
1348  *trans = OSP_INVALID_HANDLE;
1349  *timelimit = OSP_DEF_TIMELIMIT;
1350 
1351  if ((res = osp_get_provider(name, &provider)) <= 0) {
1352  ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", name);
1353  return res;
1354  }
1355 
1356  switch (provider->authpolicy) {
1357  case OSP_AUTH_NO:
1358  res = OSP_OK;
1359  break;
1360  case OSP_AUTH_EXC:
1361  if (ast_strlen_zero(token)) {
1362  res = OSP_FAILED;
1363  } else if ((res = osp_create_transaction(name, trans, dest, sizeof(dest))) <= 0) {
1364  ast_debug(1, "OSP: Unable to generate transaction handle\n");
1365  *trans = OSP_INVALID_HANDLE;
1366  res = OSP_FAILED;
1367  } else if((res = osp_validate_token(*trans, source, dest, calling, called, token, timelimit)) <= 0) {
1368  OSPPTransactionRecordFailure(*trans, OSPC_FAIL_CALL_REJECTED);
1369  }
1370  break;
1371  case OSP_AUTH_YES:
1372  default:
1373  if (ast_strlen_zero(token)) {
1374  res = OSP_OK;
1375  } else if ((res = osp_create_transaction(name, trans, dest, sizeof(dest))) <= 0) {
1376  ast_debug(1, "OSP: Unable to generate transaction handle\n");
1377  *trans = OSP_INVALID_HANDLE;
1378  res = OSP_FAILED;
1379  } else if((res = osp_validate_token(*trans, source, dest, calling, called, token, timelimit)) <= 0) {
1380  OSPPTransactionRecordFailure(*trans, OSPC_FAIL_CALL_REJECTED);
1381  }
1382  break;
1383  }
1384 
1385  return res;
1386 }
enum osp_authpolicy authpolicy
static int osp_validate_token(int trans, const char *source, const char *destination, const char *calling, const char *called, const char *token, unsigned int *timelimit)
Validate OSP token of inbound call.
#define OSP_OK
static int osp_get_provider(const char *name, struct osp_provider **provider)
Get OSP provider by name.
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static int osp_create_transaction(const char *name, int *trans, char *source, unsigned int srcsize)
Create OSP transaction handle.
#define OSP_ERROR
#define LOG_ERROR
Definition: logger.h:285
static const char name[]
Definition: cdr_mysql.c:74
#define OSP_DEF_TIMELIMIT
#define OSP_INVALID_HANDLE
#define OSP_SIZE_NORSTR
char source[OSP_SIZE_NORSTR]
#define OSP_FAILED
static struct prometheus_metrics_provider provider
Definition: bridges.c:178

◆ osp_check_destination()

static int osp_check_destination ( struct osp_provider provider,
const char *  calling,
const char *  called,
const char *  destination,
unsigned int  tokenlen,
const char *  token,
OSPEFAILREASON *  reason,
struct osp_results results 
)
static

Choose min duration limit.

Parameters
providerOSP provider
callingCalling number
calledCalled number
destinationDestination IP in '[x.x.x.x]' format
tokenlenOSP token length
tokenOSP token
reasonFailure reason, output
resultsOSP lookup results, in/output
Returns
OSP_OK Success, OSP_FAILED Failed, OSP_ERROR Error

Definition at line 1171 of file app_osplookup.c.

References ast_base64encode(), ast_copy_string(), ast_debug, ast_log, osp_results::called, osp_results::calling, osp_provider::defprotocol, osp_results::dest, enabled, error(), LOG_ERROR, LOG_WARNING, osp_results::networkid, osp_results::npcic, osp_results::npdi, osp_results::nprn, NULL, osp_results::opname, osp_convert_outin(), OSP_ERROR, OSP_FAILED, OSP_OK, OSP_SIZE_NORSTR, OSP_TECH_H323, OSP_TECH_IAX, OSP_TECH_SIP, OSP_TECH_SKYPE, osp_results::outhandle, osp_results::outtech, osp_results::token, and type.

Referenced by osp_lookup(), and osp_next().

1180 {
1181  int res;
1182  OSPE_DEST_OSPENABLED enabled;
1183  OSPE_PROTOCOL_NAME protocol;
1184  char dest[OSP_SIZE_NORSTR];
1185  OSPE_OPERATOR_NAME type;
1186  int error;
1187 
1188  if ((provider == NULL) || (reason == NULL) || (results == NULL)) {
1189  ast_log(LOG_ERROR, "Invalid parameters\n");
1190  return OSP_ERROR;
1191  }
1192 
1193  if ((error = OSPPTransactionIsDestOSPEnabled(results->outhandle, &enabled)) != OSPC_ERR_NO_ERROR) {
1194  ast_debug(1, "OSP: Unable to get destination OSP version, error '%d'\n", error);
1195  *reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
1196  return OSP_ERROR;
1197  }
1198 
1199  if (enabled == OSPC_DOSP_FALSE) {
1200  results->token[0] = '\0';
1201  } else {
1202  ast_base64encode(results->token, (const unsigned char*)token, tokenlen, sizeof(results->token) - 1);
1203  }
1204 
1205  if ((error = OSPPTransactionGetDestinationNetworkId(results->outhandle, sizeof(results->networkid), results->networkid)) != OSPC_ERR_NO_ERROR) {
1206  ast_debug(1, "OSP: Unable to get destination network ID, error '%d'\n", error);
1207  results->networkid[0] = '\0';
1208  }
1209 
1210  error = OSPPTransactionGetNumberPortabilityParameters(results->outhandle,
1211  sizeof(results->nprn),
1212  results->nprn,
1213  sizeof(results->npcic),
1214  results->npcic,
1215  &results->npdi);
1216  if (error != OSPC_ERR_NO_ERROR) {
1217  ast_debug(1, "OSP: Unable to get number portability parameters, error '%d'\n", error);
1218  results->nprn[0] = '\0';
1219  results->npcic[0] = '\0';
1220  results->npdi = 0;
1221  }
1222 
1223  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1224  error = OSPPTransactionGetOperatorName(results->outhandle, type, sizeof(results->opname[type]), results->opname[type]);
1225  if (error != OSPC_ERR_NO_ERROR) {
1226  ast_debug(1, "OSP: Unable to get operator name of type '%d', error '%d'\n", type, error);
1227  results->opname[type][0] = '\0';
1228  }
1229  }
1230 
1231  if ((error = OSPPTransactionGetDestProtocol(results->outhandle, &protocol)) != OSPC_ERR_NO_ERROR) {
1232  ast_debug(1, "OSP: Unable to get destination protocol, error '%d'\n", error);
1233  *reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
1234  results->token[0] = '\0';
1235  results->networkid[0] = '\0';
1236  results->nprn[0] = '\0';
1237  results->npcic[0] = '\0';
1238  results->npdi = 0;
1239  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1240  results->opname[type][0] = '\0';
1241  }
1242  return OSP_ERROR;
1243  }
1244 
1245  res = OSP_OK;
1246  osp_convert_outin(destination, dest, sizeof(dest));
1247  switch(protocol) {
1248  case OSPC_PROTNAME_SIP:
1249  ast_debug(1, "OSP: protocol SIP\n");
1250  ast_copy_string(results->outtech, OSP_TECH_SIP, sizeof(results->outtech));
1251  ast_copy_string(results->dest, dest, sizeof(results->dest));
1252  ast_copy_string(results->calling, calling, sizeof(results->calling));
1253  ast_copy_string(results->called, called, sizeof(results->called));
1254  break;
1255  case OSPC_PROTNAME_Q931:
1256  ast_debug(1, "OSP: protocol Q.931\n");
1257  ast_copy_string(results->outtech, OSP_TECH_H323, sizeof(results->outtech));
1258  ast_copy_string(results->dest, dest, sizeof(results->dest));
1259  ast_copy_string(results->calling, calling, sizeof(results->calling));
1260  ast_copy_string(results->called, called, sizeof(results->called));
1261  break;
1262  case OSPC_PROTNAME_IAX:
1263  ast_debug(1, "OSP: protocol IAX\n");
1264  ast_copy_string(results->outtech, OSP_TECH_IAX, sizeof(results->outtech));
1265  ast_copy_string(results->dest, dest, sizeof(results->dest));
1266  ast_copy_string(results->calling, calling, sizeof(results->calling));
1267  ast_copy_string(results->called, called, sizeof(results->called));
1268  break;
1269  case OSPC_PROTNAME_SKYPE:
1270  ast_debug(1, "OSP: protocol Skype\n");
1271  ast_copy_string(results->outtech, OSP_TECH_SKYPE, sizeof(results->outtech));
1272  ast_copy_string(results->dest, dest, sizeof(results->dest));
1273  ast_copy_string(results->calling, calling, sizeof(results->calling));
1274  ast_copy_string(results->called, called, sizeof(results->called));
1275  break;
1276  case OSPC_PROTNAME_UNDEFINED:
1277  case OSPC_PROTNAME_UNKNOWN:
1278  ast_debug(1, "OSP: unknown/undefined protocol '%d'\n", protocol);
1279  ast_debug(1, "OSP: use default protocol '%s'\n", provider->defprotocol);
1280  ast_copy_string(results->outtech, provider->defprotocol, sizeof(results->outtech));
1281  ast_copy_string(results->dest, dest, sizeof(results->dest));
1282  ast_copy_string(results->calling, calling, sizeof(results->calling));
1283  ast_copy_string(results->called, called, sizeof(results->called));
1284  break;
1285  case OSPC_PROTNAME_LRQ:
1286  case OSPC_PROTNAME_T37:
1287  case OSPC_PROTNAME_T38:
1288  case OSPC_PROTNAME_SMPP:
1289  case OSPC_PROTNAME_XMPP:
1290  default:
1291  ast_log(LOG_WARNING, "OSP: unsupported protocol '%d'\n", protocol);
1292  *reason = OSPC_FAIL_PROTOCOL_ERROR;
1293  results->token[0] = '\0';
1294  results->networkid[0] = '\0';
1295  results->nprn[0] = '\0';
1296  results->npcic[0] = '\0';
1297  results->npdi = 0;
1298  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1299  results->opname[type][0] = '\0';
1300  }
1301  res = OSP_FAILED;
1302  break;
1303  }
1304 
1305  return res;
1306 }
static const char type[]
Definition: chan_ooh323.c:109
#define OSP_TECH_SIP
#define OSP_TECH_H323
#define LOG_WARNING
Definition: logger.h:274
char dest[OSP_SIZE_NORSTR]
#define OSP_OK
#define OSP_TECH_SKYPE
#define NULL
Definition: resample.c:96
char outtech[OSP_SIZE_TECHSTR]
char nprn[OSP_SIZE_NORSTR]
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
char calling[OSP_SIZE_NORSTR]
const char * defprotocol
#define OSP_ERROR
static void osp_convert_outin(const char *src, char *dest, unsigned int destsize)
Convert "[x.x.x.x]:port" or "hostname:prot" to "address:port" format.
#define LOG_ERROR
Definition: logger.h:285
char opname[OSPC_OPNAME_NUMBER][OSP_SIZE_NORSTR]
int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max)
Encode data in base64.
Definition: main/utils.c:404
#define OSP_TECH_IAX
char npcic[OSP_SIZE_NORSTR]
char networkid[OSP_SIZE_NORSTR]
char token[OSP_SIZE_TOKSTR]
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_SIZE_NORSTR
char called[OSP_SIZE_NORSTR]
int error(const char *format,...)
Definition: utils/frame.c:999
#define OSP_FAILED
static int enabled
Definition: dnsmgr.c:91

◆ osp_choose_timelimit()

static unsigned int osp_choose_timelimit ( unsigned int  in,
unsigned int  out 
)
static

Choose min duration limit.

Parameters
inInbound duration limit
outOutbound duration limit
Returns
min duration limit

Definition at line 1146 of file app_osplookup.c.

References in, OSP_DEF_TIMELIMIT, and out.

Referenced by osp_lookup(), and osp_next().

1149 {
1150  if (in == OSP_DEF_TIMELIMIT) {
1151  return out;
1152  } else if (out == OSP_DEF_TIMELIMIT) {
1153  return in;
1154  } else {
1155  return in < out ? in : out;
1156  }
1157 }
FILE * in
Definition: utils/frame.c:33
#define OSP_DEF_TIMELIMIT
FILE * out
Definition: utils/frame.c:33

◆ osp_convert_inout()

static void osp_convert_inout ( const char *  src,
char *  dest,
unsigned int  destsize 
)
static

Convert "address:port" to "[x.x.x.x]:port" or "hostname:port" format.

Parameters
srcSource address string
destDestination address string
destsizeSize of dest buffer

Definition at line 992 of file app_osplookup.c.

References ast_copy_string(), ast_strlen_zero, NULL, and OSP_SIZE_NORSTR.

Referenced by osp_lookup(), and osp_validate_token().

996 {
997  struct in_addr inp;
998  char buffer[OSP_SIZE_NORSTR];
999  char* port;
1000 
1001  if ((dest != NULL) && (destsize > 0)) {
1002  if (!ast_strlen_zero(src)) {
1003  ast_copy_string(buffer, src, sizeof(buffer));
1004 
1005  if((port = strchr(buffer, ':')) != NULL) {
1006  *port = '\0';
1007  port++;
1008  }
1009 
1010  if (inet_pton(AF_INET, buffer, &inp) == 1) {
1011  if (port != NULL) {
1012  snprintf(dest, destsize, "[%s]:%s", buffer, port);
1013  } else {
1014  snprintf(dest, destsize, "[%s]", buffer);
1015  }
1016  dest[destsize - 1] = '\0';
1017  } else {
1018  ast_copy_string(dest, src, destsize);
1019  }
1020  } else {
1021  *dest = '\0';
1022  }
1023  }
1024 }
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_SIZE_NORSTR

◆ osp_convert_outin()

static void osp_convert_outin ( const char *  src,
char *  dest,
unsigned int  destsize 
)
static

Convert "[x.x.x.x]:port" or "hostname:prot" to "address:port" format.

Parameters
srcSource address string
destDestination address string
destsizeSize of dest buffer

Definition at line 1032 of file app_osplookup.c.

References ast_copy_string(), ast_strlen_zero, end, NULL, and OSP_SIZE_NORSTR.

Referenced by osp_check_destination().

1036 {
1037  char buffer[OSP_SIZE_NORSTR];
1038  char* end;
1039  char* port;
1040 
1041  if ((dest != NULL) && (destsize > 0)) {
1042  if (!ast_strlen_zero(src)) {
1043  ast_copy_string(buffer, src, sizeof(buffer));
1044 
1045  if (buffer[0] == '[') {
1046  if((port = strchr(buffer + 1, ':')) != NULL) {
1047  *port = '\0';
1048  port++;
1049  }
1050 
1051  if ((end = strchr(buffer + 1, ']')) != NULL) {
1052  *end = '\0';
1053  }
1054 
1055  if (port != NULL) {
1056  snprintf(dest, destsize, "%s:%s", buffer + 1, port);
1057  dest[destsize - 1] = '\0';
1058  } else {
1059  ast_copy_string(dest, buffer + 1, destsize);
1060  }
1061  } else {
1062  ast_copy_string(dest, src, destsize);
1063  }
1064  } else {
1065  *dest = '\0';
1066  }
1067  }
1068 }
#define NULL
Definition: resample.c:96
char * end
Definition: eagi_proxy.c:73
#define ast_strlen_zero(foo)
Definition: strings.h:52
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_SIZE_NORSTR

◆ osp_create_callid()

static int osp_create_callid ( unsigned int  type,
struct osp_callid callid 
)
static

Create a call ID according to the type.

Parameters
typeCall ID type
callidCall ID buffer
Returns
OSK_OK Created, OSP_FAILED Not create, OSP_ERROR Error

Definition at line 1451 of file app_osplookup.c.

References ast_log, osp_callid::buf, osp_callid::len, LOG_ERROR, NULL, OSP_CALLID_H323, OSP_CALLID_IAX, OSP_CALLID_SIP, osp_create_uuid(), OSP_ERROR, OSP_FAILED, and OSP_OK.

Referenced by osp_lookup().

1454 {
1455  int res;
1456 
1457  if (callid == NULL) {
1458  ast_log(LOG_ERROR, "Invalid parameters\n");
1459  return OSP_ERROR;
1460  }
1461 
1462  callid->len = sizeof(callid->buf);
1463  switch (type) {
1464  case OSP_CALLID_H323:
1465  res = osp_create_uuid(callid->buf, &callid->len);
1466  break;
1467  case OSP_CALLID_SIP:
1468  case OSP_CALLID_IAX:
1469  res = OSP_FAILED;
1470  break;
1471  default:
1472  res = OSP_ERROR;
1473  break;
1474  }
1475 
1476  if ((res != OSP_OK) && (callid->len != 0)) {
1477  callid->buf[0] = '\0';
1478  callid->len = 0;
1479  }
1480 
1481  return res;
1482 }
static const char type[]
Definition: chan_ooh323.c:109
#define OSP_OK
#define OSP_CALLID_H323
#define NULL
Definition: resample.c:96
static int osp_create_uuid(unsigned char *uuid, unsigned int *bufsize)
Create a UUID.
#define ast_log
Definition: astobj2.c:42
#define OSP_CALLID_SIP
#define OSP_ERROR
#define OSP_CALLID_IAX
#define LOG_ERROR
Definition: logger.h:285
unsigned char buf[OSP_SIZE_NORSTR]
#define OSP_FAILED
unsigned int len

◆ osp_create_provider()

static int osp_create_provider ( struct ast_config cfg,
const char *  name 
)
static

Create OSP provider handle according to configuration.

Parameters
cfgOSP configuration
nameOSP provider context name
Returns
OSP_OK Success, OSP_FAILED Failed, OSP_ERROR Error

Definition at line 644 of file app_osplookup.c.

References ast_calloc, ast_config_AST_KEY_DIR, ast_copy_string(), ast_debug, ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_variable_browse(), osp_provider::authpolicy, B64CACert, B64LCert, B64PKey, osp_provider::cacerts, osp_provider::canum, osp_provider::defprotocol, error(), osp_provider::handle, ast_variable::lineno, osp_provider::localcert, LOG_ERROR, LOG_WARNING, osp_provider::maxconnect, ast_variable::name, osp_provider::name, ast_variable::next, osp_provider::next, NULL, OSP_AUDIT_URL, OSP_AUTH_EXC, OSP_AUTH_NO, OSP_AUTH_YES, OSP_CUSTOMER_ID, OSP_DEF_AUTHPOLICY, OSP_DEF_MAXCONNECT, OSP_DEF_PROTOCOL, OSP_DEF_RETRYDELAY, OSP_DEF_RETRYLIMIT, OSP_DEF_SRVTYPE, OSP_DEF_TIMEOUT, OSP_DEF_WORKMODE, OSP_DEVICE_ID, OSP_ERROR, OSP_FAILED, OSP_HTTP_PERSISTENCE, OSP_INVALID_HANDLE, OSP_LOCAL_VALIDATION, osp_lock, OSP_MAX_CERTS, OSP_MAX_MAXCONNECT, OSP_MAX_RETRYDELAY, OSP_MAX_RETRYLIMIT, OSP_MAX_SPOINTS, OSP_MAX_TIMEOUT, OSP_MIN_MAXCONNECT, OSP_MIN_RETRYDELAY, OSP_MIN_RETRYLIMIT, OSP_MIN_TIMEOUT, OSP_MODE_DIRECT, OSP_MODE_INDIRECT, OSP_OK, OSP_PROT_H323, OSP_PROT_IAX, OSP_PROT_SIP, OSP_PROT_SKYPE, osp_providers, osp_security, OSP_SIZE_KEYSTR, OSP_SRV_NPQUERY, OSP_SRV_VOICE, OSP_SSL_LIFETIME, osp_provider::privatekey, provider, osp_provider::retrydelay, osp_provider::retrylimit, osp_provider::source, osp_provider::spnum, osp_provider::spoints, osp_provider::srvtype, osp_provider::timeout, ast_variable::value, var, and osp_provider::workmode.

Referenced by osp_load().

647 {
648  int res = OSP_FAILED;
649  struct ast_variable* var;
650  struct osp_provider* provider;
651  OSPTPRIVATEKEY privatekey;
652  OSPT_CERT localcert;
653  OSPT_CERT cacerts[OSP_MAX_CERTS];
654  const OSPT_CERT* pcacerts[OSP_MAX_CERTS];
655  const char* pspoints[OSP_MAX_SPOINTS];
656  unsigned char privatekeydata[OSP_SIZE_KEYSTR];
657  unsigned char localcertdata[OSP_SIZE_KEYSTR];
658  unsigned char cacertdata[OSP_SIZE_KEYSTR];
659  int i, num, error = OSPC_ERR_NO_ERROR;
660 
661  if (!(provider = ast_calloc(1, sizeof(*provider)))) {
662  ast_log(LOG_ERROR, "Out of memory\n");
663  return OSP_ERROR;
664  }
665 
666  /* ast_calloc has set 0 in provider */
667  provider->handle = OSP_INVALID_HANDLE;
668  ast_copy_string(provider->name, name, sizeof(provider->name));
669  snprintf(provider->privatekey, sizeof(provider->privatekey), "%s/%s-privatekey.pem", ast_config_AST_KEY_DIR, name);
670  snprintf(provider->localcert, sizeof(provider->localcert), "%s/%s-localcert.pem", ast_config_AST_KEY_DIR, name);
671  snprintf(provider->cacerts[0], sizeof(provider->cacerts[0]), "%s/%s-cacert_0.pem", ast_config_AST_KEY_DIR, name);
672  provider->maxconnect = OSP_DEF_MAXCONNECT;
673  provider->retrydelay = OSP_DEF_RETRYDELAY;
674  provider->retrylimit = OSP_DEF_RETRYLIMIT;
675  provider->timeout = OSP_DEF_TIMEOUT;
676  provider->authpolicy = OSP_DEF_AUTHPOLICY;
677  provider->defprotocol = OSP_DEF_PROTOCOL;
678  provider->workmode = OSP_DEF_WORKMODE;
679  provider->srvtype = OSP_DEF_SRVTYPE;
680 
681  for (var = ast_variable_browse(cfg, name); var != NULL; var = var->next) {
682  if (!strcasecmp(var->name, "privatekey")) {
683  if (osp_security) {
684  if (var->value[0] == '/') {
685  ast_copy_string(provider->privatekey, var->value, sizeof(provider->privatekey));
686  } else {
687  snprintf(provider->privatekey, sizeof(provider->privatekey), "%s/%s", ast_config_AST_KEY_DIR, var->value);
688  }
689  ast_debug(1, "OSP: privatekey '%s'\n", provider->privatekey);
690  }
691  } else if (!strcasecmp(var->name, "localcert")) {
692  if (osp_security) {
693  if (var->value[0] == '/') {
694  ast_copy_string(provider->localcert, var->value, sizeof(provider->localcert));
695  } else {
696  snprintf(provider->localcert, sizeof(provider->localcert), "%s/%s", ast_config_AST_KEY_DIR, var->value);
697  }
698  ast_debug(1, "OSP: localcert '%s'\n", provider->localcert);
699  }
700  } else if (!strcasecmp(var->name, "cacert")) {
701  if (osp_security) {
702  if (provider->canum < OSP_MAX_CERTS) {
703  if (var->value[0] == '/') {
704  ast_copy_string(provider->cacerts[provider->canum], var->value, sizeof(provider->cacerts[provider->canum]));
705  } else {
706  snprintf(provider->cacerts[provider->canum], sizeof(provider->cacerts[provider->canum]), "%s/%s", ast_config_AST_KEY_DIR, var->value);
707  }
708  ast_debug(1, "OSP: cacerts[%d]: '%s'\n", provider->canum, provider->cacerts[provider->canum]);
709  provider->canum++;
710  } else {
711  ast_log(LOG_WARNING, "OSP: Too many CA Certificates at line %d\n", var->lineno);
712  }
713  }
714  } else if (!strcasecmp(var->name, "servicepoint")) {
715  if (provider->spnum < OSP_MAX_SPOINTS) {
716  ast_copy_string(provider->spoints[provider->spnum], var->value, sizeof(provider->spoints[provider->spnum]));
717  ast_debug(1, "OSP: servicepoint[%d]: '%s'\n", provider->spnum, provider->spoints[provider->spnum]);
718  provider->spnum++;
719  } else {
720  ast_log(LOG_WARNING, "OSP: Too many Service Points at line %d\n", var->lineno);
721  }
722  } else if (!strcasecmp(var->name, "maxconnect")) {
723  if ((sscanf(var->value, "%30d", &num) == 1) && (num >= OSP_MIN_MAXCONNECT) && (num <= OSP_MAX_MAXCONNECT)) {
724  provider->maxconnect = num;
725  ast_debug(1, "OSP: maxconnect '%d'\n", num);
726  } else {
727  ast_log(LOG_WARNING, "OSP: maxconnect should be an integer from %d to %d, not '%s' at line %d\n",
729  }
730  } else if (!strcasecmp(var->name, "retrydelay")) {
731  if ((sscanf(var->value, "%30d", &num) == 1) && (num >= OSP_MIN_RETRYDELAY) && (num <= OSP_MAX_RETRYDELAY)) {
732  provider->retrydelay = num;
733  ast_debug(1, "OSP: retrydelay '%d'\n", num);
734  } else {
735  ast_log(LOG_WARNING, "OSP: retrydelay should be an integer from %d to %d, not '%s' at line %d\n",
737  }
738  } else if (!strcasecmp(var->name, "retrylimit")) {
739  if ((sscanf(var->value, "%30d", &num) == 1) && (num >= OSP_MIN_RETRYLIMIT) && (num <= OSP_MAX_RETRYLIMIT)) {
740  provider->retrylimit = num;
741  ast_debug(1, "OSP: retrylimit '%d'\n", num);
742  } else {
743  ast_log(LOG_WARNING, "OSP: retrylimit should be an integer from %d to %d, not '%s' at line %d\n",
745  }
746  } else if (!strcasecmp(var->name, "timeout")) {
747  if ((sscanf(var->value, "%30d", &num) == 1) && (num >= OSP_MIN_TIMEOUT) && (num <= OSP_MAX_TIMEOUT)) {
748  provider->timeout = num;
749  ast_debug(1, "OSP: timeout '%d'\n", num);
750  } else {
751  ast_log(LOG_WARNING, "OSP: timeout should be an integer from %d to %d, not '%s' at line %d\n",
753  }
754  } else if (!strcasecmp(var->name, "source")) {
755  ast_copy_string(provider->source, var->value, sizeof(provider->source));
756  ast_debug(1, "OSP: source '%s'\n", provider->source);
757  } else if (!strcasecmp(var->name, "authpolicy")) {
758  if ((sscanf(var->value, "%30d", &num) == 1) && ((num == OSP_AUTH_NO) || (num == OSP_AUTH_YES) || (num == OSP_AUTH_EXC))) {
759  provider->authpolicy = num;
760  ast_debug(1, "OSP: authpolicy '%d'\n", num);
761  } else {
762  ast_log(LOG_WARNING, "OSP: authpolicy should be %d, %d or %d, not '%s' at line %d\n",
764  }
765  } else if (!strcasecmp(var->name, "defprotocol")) {
766  if (!strcasecmp(var->value, OSP_PROT_SIP)) {
767  provider->defprotocol = OSP_PROT_SIP;
768  ast_debug(1, "OSP: default protocol SIP\n");
769  } else if (!strcasecmp(var->value, OSP_PROT_H323)) {
770  provider->defprotocol = OSP_PROT_H323;
771  ast_debug(1, "OSP: default protocol H.323\n");
772  } else if (!strcasecmp(var->value, OSP_PROT_IAX)) {
773  provider->defprotocol = OSP_PROT_IAX;
774  ast_debug(1, "OSP: default protocol IAX\n");
775  } else if (!strcasecmp(var->value, OSP_PROT_SKYPE)) {
776  provider->defprotocol = OSP_PROT_SKYPE;
777  ast_debug(1, "OSP: default protocol Skype\n");
778  } else {
779  ast_log(LOG_WARNING, "OSP: default protocol should be %s, %s, %s or %s not '%s' at line %d\n",
781  }
782  } else if (!strcasecmp(var->name, "workmode")) {
783  if ((sscanf(var->value, "%30d", &num) == 1) && ((num == OSP_MODE_DIRECT) || (num == OSP_MODE_INDIRECT))) {
784  provider->workmode = num;
785  ast_debug(1, "OSP: workmode '%d'\n", num);
786  } else {
787  ast_log(LOG_WARNING, "OSP: workmode should be %d or %d, not '%s' at line %d\n",
789  }
790  } else if (!strcasecmp(var->name, "servicetype")) {
791  if ((sscanf(var->value, "%30d", &num) == 1) && ((num == OSP_SRV_VOICE) || (num == OSP_SRV_NPQUERY))) {
792  provider->srvtype = num;
793  ast_debug(1, "OSP: servicetype '%d'\n", num);
794  } else {
795  ast_log(LOG_WARNING, "OSP: servicetype should be %d or %d, not '%s' at line %d\n",
797  }
798  }
799  }
800 
801  if (provider->canum == 0) {
802  provider->canum = 1;
803  }
804 
805  for (i = 0; i < provider->spnum; i++) {
806  pspoints[i] = provider->spoints[i];
807  }
808 
809  if (osp_security) {
810  privatekey.PrivateKeyData = NULL;
811  privatekey.PrivateKeyLength = 0;
812 
813  localcert.CertData = NULL;
814  localcert.CertDataLength = 0;
815 
816  for (i = 0; i < provider->canum; i++) {
817  cacerts[i].CertData = NULL;
818  cacerts[i].CertDataLength = 0;
819  }
820 
821  if ((error = OSPPUtilLoadPEMPrivateKey((unsigned char*)provider->privatekey, &privatekey)) != OSPC_ERR_NO_ERROR) {
822  ast_log(LOG_WARNING, "OSP: Unable to load privatekey '%s', error '%d'\n", provider->privatekey, error);
823  } else if ((error = OSPPUtilLoadPEMCert((unsigned char*)provider->localcert, &localcert)) != OSPC_ERR_NO_ERROR) {
824  ast_log(LOG_WARNING, "OSP: Unable to load localcert '%s', error '%d'\n", provider->localcert, error);
825  } else {
826  for (i = 0; i < provider->canum; i++) {
827  if ((error = OSPPUtilLoadPEMCert((unsigned char*)provider->cacerts[i], &cacerts[i])) != OSPC_ERR_NO_ERROR) {
828  ast_log(LOG_WARNING, "OSP: Unable to load cacert '%s', error '%d'\n", provider->cacerts[i], error);
829  break;
830  } else {
831  pcacerts[i] = &cacerts[i];
832  }
833  }
834  }
835  } else {
836  privatekey.PrivateKeyData = privatekeydata;
837  privatekey.PrivateKeyLength = sizeof(privatekeydata);
838 
839  localcert.CertData = localcertdata;
840  localcert.CertDataLength = sizeof(localcertdata);
841 
842  cacerts[0].CertData = cacertdata;
843  cacerts[0].CertDataLength = sizeof(cacertdata);
844  pcacerts[0] = &cacerts[0];
845 
846  if ((error = OSPPBase64Decode(B64PKey, strlen(B64PKey), privatekey.PrivateKeyData, &privatekey.PrivateKeyLength)) != OSPC_ERR_NO_ERROR) {
847  ast_log(LOG_WARNING, "OSP: Unable to decode private key, error '%d'\n", error);
848  } else if ((error = OSPPBase64Decode(B64LCert, strlen(B64LCert), localcert.CertData, &localcert.CertDataLength)) != OSPC_ERR_NO_ERROR) {
849  ast_log(LOG_WARNING, "OSP: Unable to decode local cert, error '%d'\n", error);
850  } else if ((error = OSPPBase64Decode(B64CACert, strlen(B64CACert), cacerts[0].CertData, &cacerts[0].CertDataLength)) != OSPC_ERR_NO_ERROR) {
851  ast_log(LOG_WARNING, "OSP: Unable to decode cacert, error '%d'\n", error);
852  }
853  }
854 
855  if (error == OSPC_ERR_NO_ERROR) {
856  error = OSPPProviderNew(provider->spnum,
857  pspoints,
858  NULL,
860  &privatekey,
861  &localcert,
862  provider->canum,
863  pcacerts,
866  provider->maxconnect,
868  provider->retrydelay,
869  provider->retrylimit,
870  provider->timeout,
873  &provider->handle);
874  if (error != OSPC_ERR_NO_ERROR) {
875  ast_log(LOG_WARNING, "OSP: Unable to create provider '%s', error '%d'\n", name, error);
876  res = OSP_ERROR;
877  } else {
878  ast_debug(1, "OSP: provider '%s'\n", name);
880  provider->next = osp_providers;
883  res = OSP_OK;
884  }
885  }
886 
887  if (osp_security) {
888  for (i = 0; i < provider->canum; i++) {
889  if (cacerts[i].CertData) {
890  ast_free(cacerts[i].CertData);
891  }
892  }
893  if (localcert.CertData) {
894  ast_free(localcert.CertData);
895  }
896  if (privatekey.PrivateKeyData) {
897  ast_free(privatekey.PrivateKeyData);
898  }
899  }
900 
901  if (res != OSP_OK) {
902  ast_free(provider);
903  }
904 
905  return res;
906 }
struct ast_variable * next
const char * ast_config_AST_KEY_DIR
Definition: options.c:161
#define OSP_LOCAL_VALIDATION
#define OSP_MAX_RETRYDELAY
#define OSP_PROT_SIP
const char * B64LCert
#define OSP_DEF_MAXCONNECT
enum osp_authpolicy authpolicy
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
#define OSP_DEF_RETRYDELAY
const char * B64CACert
#define OSP_HTTP_PERSISTENCE
#define LOG_WARNING
Definition: logger.h:274
OSPTPROVHANDLE handle
Structure for variables, used for configurations and for channel variables.
#define OSP_DEF_PROTOCOL
#define var
Definition: ast_expr2f.c:614
#define OSP_DEVICE_ID
#define OSP_OK
#define OSP_DEF_SRVTYPE
#define OSP_MIN_MAXCONNECT
#define OSP_MAX_TIMEOUT
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
unsigned int maxconnect
char name[OSP_SIZE_NORSTR]
unsigned int retrylimit
#define OSP_MIN_TIMEOUT
#define OSP_SIZE_KEYSTR
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
char localcert[OSP_SIZE_NORSTR]
const char * defprotocol
#define OSP_ERROR
#define OSP_DEF_AUTHPOLICY
unsigned int canum
#define LOG_ERROR
Definition: logger.h:285
unsigned int timeout
#define OSP_DEF_WORKMODE
#define OSP_PROT_IAX
unsigned int retrydelay
#define OSP_MAX_MAXCONNECT
char cacerts[OSP_MAX_CERTS][OSP_SIZE_NORSTR]
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
enum osp_workmode workmode
char privatekey[OSP_SIZE_NORSTR]
const char * B64PKey
#define OSP_PROT_H323
static int osp_security
#define OSP_INVALID_HANDLE
static struct osp_provider * osp_providers
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_MIN_RETRYLIMIT
int error(const char *format,...)
Definition: utils/frame.c:999
struct osp_provider * next
#define OSP_MIN_RETRYDELAY
#define OSP_MAX_CERTS
unsigned int spnum
#define OSP_CUSTOMER_ID
char source[OSP_SIZE_NORSTR]
#define OSP_FAILED
#define OSP_DEF_RETRYLIMIT
enum osp_srvtype srvtype
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
#define OSP_AUDIT_URL
static ast_mutex_t osp_lock
#define OSP_DEF_TIMEOUT
char spoints[OSP_MAX_SPOINTS][OSP_SIZE_NORSTR]
#define OSP_PROT_SKYPE
#define OSP_MAX_RETRYLIMIT
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define OSP_MAX_SPOINTS
#define OSP_SSL_LIFETIME

◆ osp_create_transaction()

static int osp_create_transaction ( const char *  name,
int *  trans,
char *  source,
unsigned int  srcsize 
)
static

Create OSP transaction handle.

Parameters
nameOSP provider context name
transOSP transaction handle, output
sourceSource of provider, output
srcsizeSize of source buffer, in
Returns
OSK_OK Success, OSK_FAILED Failed, OSP_ERROR Error

Definition at line 945 of file app_osplookup.c.

References ast_copy_string(), ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, error(), osp_provider::handle, LOG_ERROR, osp_provider::name, osp_provider::next, NULL, OSP_ERROR, OSP_FAILED, OSP_INVALID_HANDLE, osp_lock, OSP_OK, provider, and osp_provider::source.

Referenced by osp_auth(), and osp_lookup().

950 {
951  int res = OSP_FAILED;
952  struct osp_provider* provider;
953  int error;
954 
955  if ((trans == NULL) || (source == NULL) || (srcsize <= 0)) {
956  ast_log(LOG_ERROR, "Invalid parameters\n");
957  return OSP_ERROR;
958  }
959 
960  *trans = OSP_INVALID_HANDLE;
961  *source = '\0';
962 
964  for (provider = osp_providers; provider; provider = provider->next) {
965  if (!strcasecmp(provider->name, name)) {
966  error = OSPPTransactionNew(provider->handle, trans);
967  if (error == OSPC_ERR_NO_ERROR) {
968  ast_debug(1, "OSP: transaction '%d'\n", *trans);
969  ast_copy_string(source, provider->source, srcsize);
970  ast_debug(1, "OSP: source '%s'\n", source);
971  res = OSP_OK;
972  } else {
973  *trans = OSP_INVALID_HANDLE;
974  ast_debug(1, "OSP: Unable to create transaction handle, error '%d'\n", error);
975  *source = '\0';
976  res = OSP_ERROR;
977  }
978  break;
979  }
980  }
982 
983  return res;
984 }
OSPTPROVHANDLE handle
#define OSP_OK
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
char name[OSP_SIZE_NORSTR]
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define OSP_ERROR
#define LOG_ERROR
Definition: logger.h:285
static const char name[]
Definition: cdr_mysql.c:74
#define OSP_INVALID_HANDLE
static struct osp_provider * osp_providers
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
int error(const char *format,...)
Definition: utils/frame.c:999
struct osp_provider * next
char source[OSP_SIZE_NORSTR]
#define OSP_FAILED
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
static ast_mutex_t osp_lock
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ osp_create_uuid()

static int osp_create_uuid ( unsigned char *  uuid,
unsigned int *  bufsize 
)
static

Create a UUID.

Parameters
uuidUUID buffer
bufsizeUUID buffer size
Returns
OSK_OK Created, OSP_ERROR Error

Definition at line 1394 of file app_osplookup.c.

References ast_log, ast_random(), LOG_ERROR, NULL, OSP_ERROR, OSP_OK, OSP_SIZE_UUID, and tmp().

Referenced by osp_create_callid().

1397 {
1398  int i, res;
1399  long int tmp[OSP_SIZE_UUID / sizeof(long int)];
1400 
1401  if ((uuid != NULL) && (*bufsize >= OSP_SIZE_UUID)) {
1402  for (i = 0; i < OSP_SIZE_UUID / sizeof(long int); i++) {
1403  tmp[i] = ast_random();
1404  }
1405  memcpy(uuid, tmp, OSP_SIZE_UUID);
1406  *bufsize = OSP_SIZE_UUID;
1407  res = OSP_OK;
1408  } else {
1409  ast_log(LOG_ERROR, "Invalid parameters\n");
1410  res = OSP_ERROR;
1411  }
1412 
1413  return res;
1414 }
static int tmp()
Definition: bt_open.c:389
#define OSP_OK
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define OSP_ERROR
long int ast_random(void)
Definition: main/utils.c:2064
#define LOG_ERROR
Definition: logger.h:285
#define OSP_SIZE_UUID

◆ osp_finish()

static int osp_finish ( int  trans,
int  recorded,
int  cause,
time_t  start,
time_t  connect,
time_t  end,
unsigned int  release,
const char *  inqos,
const char *  outqos 
)
static

OSP Finish function.

Parameters
transOSP in/outbound transaction handle
recordedIf failure reason has been recorded
causeAsterisk hangup cause
startCall start time
connectCall connect time
endCall end time
releaseWho release first, 0 source, 1 destination
inqosInbound QoS string
outqosOutbound QoS string
Returns
OSP_OK Success, OSP_FAILED Failed, OSP_ERROR Error

Definition at line 2188 of file app_osplookup.c.

References ast_debug, asterisk2osp(), dummy(), error(), NULL, OSP_CALL_INBOUND, OSP_CALL_OUTBOUND, OSP_DEF_INTSTATS, OSP_ERROR, OSP_FAILED, OSP_INVALID_HANDLE, OSP_OK, and osp_report_qos().

Referenced by ospfinished_exec().

2198 {
2199  int res;
2200  OSPEFAILREASON reason;
2201  time_t alert = 0;
2202  unsigned isPddInfoPresent = 0;
2203  unsigned pdd = 0;
2204  unsigned int dummy = 0;
2205  int error;
2206 
2207  if (trans == OSP_INVALID_HANDLE) {
2208  return OSP_FAILED;
2209  }
2210 
2211  OSPPTransactionSetRoleInfo(trans, OSPC_RSTATE_STOP, OSPC_RFORMAT_OSP, OSPC_RVENDOR_ASTERISK);
2212 
2213  if (!recorded) {
2214  reason = asterisk2osp(cause);
2215  OSPPTransactionRecordFailure(trans, reason);
2216  }
2217 
2218  osp_report_qos(trans, OSP_CALL_INBOUND, inqos);
2219  osp_report_qos(trans, OSP_CALL_OUTBOUND, outqos);
2220 
2221  error = OSPPTransactionReportUsage(trans,
2222  difftime(end, connect),
2223  start,
2224  end,
2225  alert,
2226  connect,
2227  isPddInfoPresent,
2228  pdd,
2229  release,
2230  NULL,
2235  &dummy,
2236  NULL);
2237  if (error == OSPC_ERR_NO_ERROR) {
2238  ast_debug(1, "OSP: Usage reported\n");
2239  res = OSP_OK;
2240  } else {
2241  ast_debug(1, "OSP: Unable to report usage, error '%d'\n", error);
2242  res = OSP_ERROR;
2243  }
2244  OSPPTransactionDelete(trans);
2245 
2246  return res;
2247 }
static void dummy(char *unused,...)
Definition: chan_unistim.c:220
#define OSP_OK
#define NULL
Definition: resample.c:96
char * end
Definition: eagi_proxy.c:73
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define OSP_ERROR
static int osp_report_qos(int trans, enum osp_callleg leg, const char *qos)
Report QoS.
static OSPEFAILREASON asterisk2osp(int cause)
Convert Asterisk status to TC code.
#define OSP_INVALID_HANDLE
int error(const char *format,...)
Definition: utils/frame.c:999
#define OSP_DEF_INTSTATS
#define OSP_FAILED

◆ osp_get_provider()

static int osp_get_provider ( const char *  name,
struct osp_provider **  provider 
)
static

Get OSP provider by name.

Parameters
nameOSP provider context name
providerOSP provider structure
Returns
OSP_OK Success, OSP_FAILED Failed, OSP_ERROR Error

Definition at line 914 of file app_osplookup.c.

References ast_debug, ast_mutex_lock, ast_mutex_unlock, osp_provider::name, osp_provider::next, NULL, OSP_FAILED, osp_lock, and OSP_OK.

Referenced by osp_auth(), osp_lookup(), and osp_next().

917 {
918  int res = OSP_FAILED;
919  struct osp_provider* p;
920 
921  *provider = NULL;
922 
924  for (p = osp_providers; p != NULL; p = p->next) {
925  if (!strcasecmp(p->name, name)) {
926  *provider = p;
927  ast_debug(1, "OSP: find provider '%s'\n", name);
928  res = OSP_OK;
929  break;
930  }
931  }
933 
934  return res;
935 }
#define OSP_OK
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
char name[OSP_SIZE_NORSTR]
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
static const char name[]
Definition: cdr_mysql.c:74
static struct osp_provider * osp_providers
struct osp_provider * next
#define OSP_FAILED
static ast_mutex_t osp_lock
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ osp_get_varfloat()

static float osp_get_varfloat ( const char *  vstr)
static

Get float from variable string.

Parameters
vstrVariable string
Returns
OSP_DEF_FLOATSTATS Error

Definition at line 1946 of file app_osplookup.c.

References ast_strlen_zero, NULL, OSP_DEF_FLOATSTATS, tmp(), and value.

Referenced by osp_report_qos().

1948 {
1949  char* tmp;
1950  float value = OSP_DEF_FLOATSTATS;
1951 
1952  if (!ast_strlen_zero(vstr)) {
1953  if ((tmp = strchr(vstr, '=')) != NULL) {
1954  tmp++;
1955  if (sscanf(tmp, "%30f", &value) != 1) {
1956  value = OSP_DEF_FLOATSTATS;
1957  }
1958  }
1959  }
1960 
1961  return value;
1962 }
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define OSP_DEF_FLOATSTATS

◆ osp_get_varint()

static int osp_get_varint ( const char *  vstr)
static

Get integer from variable string.

Parameters
vstrVariable string
Returns
OSP_DEF_INTSTATS Error

Definition at line 1923 of file app_osplookup.c.

References ast_strlen_zero, NULL, OSP_DEF_INTSTATS, tmp(), and value.

Referenced by osp_report_qos().

1925 {
1926  char* tmp;
1927  int value = OSP_DEF_INTSTATS;
1928 
1929  if (!ast_strlen_zero(vstr)) {
1930  if ((tmp = strchr(vstr, '=')) != NULL) {
1931  tmp++;
1932  if (sscanf(tmp, "%30d", &value) != 1) {
1933  value = OSP_DEF_INTSTATS;
1934  }
1935  }
1936  }
1937 
1938  return value;
1939 }
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define OSP_DEF_INTSTATS

◆ osp_load()

static int osp_load ( int  reload)
static

Definition at line 2955 of file app_osplookup.c.

References ast_category_browse(), ast_config_destroy(), ast_config_load, ast_debug, ast_log, ast_true(), ast_variable_retrieve(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, error(), LOG_ERROR, LOG_WARNING, NULL, OSP_CONFIG_FILE, osp_create_provider(), OSP_GENERAL_CAT, osp_hardware, osp_initialized, osp_security, osp_tokenformat, and osp_unload().

Referenced by load_module(), and reload().

2956 {
2957  const char* cvar;
2958  unsigned int ivar;
2959  struct ast_config* cfg;
2960  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
2961  int error = OSPC_ERR_NO_ERROR;
2962 
2963  if ((cfg = ast_config_load(OSP_CONFIG_FILE, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
2964  return 0;
2965  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
2966  ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", OSP_CONFIG_FILE);
2967  return 0;
2968  }
2969 
2970  if (cfg) {
2971  if (reload) {
2972  osp_unload();
2973  }
2974 
2975  if ((cvar = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "accelerate")) && ast_true(cvar)) {
2976  if ((error = OSPPInit(1)) != OSPC_ERR_NO_ERROR) {
2977  ast_log(LOG_WARNING, "OSP: Unable to enable hardware acceleration, error='%d'\n", error);
2978  OSPPInit(0);
2979  } else {
2980  osp_hardware = 1;
2981  }
2982  } else {
2983  OSPPInit(0);
2984  }
2985  ast_debug(1, "OSP: osp_hardware '%d'\n", osp_hardware);
2986 
2987  if ((cvar = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "securityfeatures")) && ast_true(cvar)) {
2988  osp_security = 1;
2989  }
2990  ast_debug(1, "OSP: osp_security '%d'\n", osp_security);
2991 
2992  if ((cvar = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "tokenformat"))) {
2993  if ((sscanf(cvar, "%30d", &ivar) == 1) &&
2994  ((ivar == TOKEN_ALGO_SIGNED) || (ivar == TOKEN_ALGO_UNSIGNED) || (ivar == TOKEN_ALGO_BOTH)))
2995  {
2996  osp_tokenformat = ivar;
2997  } else {
2998  ast_log(LOG_WARNING, "tokenformat should be an integer from %d, %d or %d, not '%s'\n",
2999  TOKEN_ALGO_SIGNED, TOKEN_ALGO_UNSIGNED, TOKEN_ALGO_BOTH, cvar);
3000  }
3001  }
3002  ast_debug(1, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
3003 
3004  for (cvar = ast_category_browse(cfg, NULL); cvar != NULL; cvar = ast_category_browse(cfg, cvar)) {
3005  if (strcasecmp(cvar, OSP_GENERAL_CAT)) {
3006  osp_create_provider(cfg, cvar);
3007  }
3008  }
3009 
3010  osp_initialized = 1;
3011 
3012  ast_config_destroy(cfg);
3013  } else {
3014  ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n");
3015  return 0;
3016  }
3017  ast_debug(1, "OSP: osp_initialized '%d'\n", osp_initialized);
3018 
3019  return 1;
3020 }
static int osp_hardware
static int osp_unload(void)
#define LOG_WARNING
Definition: logger.h:274
#define CONFIG_STATUS_FILEINVALID
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3328
#define OSP_GENERAL_CAT
#define NULL
Definition: resample.c:96
static int osp_create_provider(struct ast_config *cfg, const char *name)
Create OSP provider handle according to configuration.
static int osp_initialized
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ast_config_load(filename, flags)
Load a config file.
static int reload(void)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
#define CONFIG_STATUS_FILEUNCHANGED
#define LOG_ERROR
Definition: logger.h:285
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define OSP_CONFIG_FILE
static unsigned int osp_tokenformat
Structure used to handle boolean flags.
Definition: utils.h:199
static int osp_security
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:694
int error(const char *format,...)
Definition: utils/frame.c:999

◆ osp_lookup()

static int osp_lookup ( const char *  name,
unsigned int  callidtypes,
const char *  actualsrc,
const char *  srcdev,
const char *  calling,
const char *  called,
const char *  snetid,
struct osp_npdata np,
struct osp_headers headers,
const char *  cinfo[],
struct osp_results results 
)
static

OSP Lookup function.

Parameters
nameOSP provider context name
callidtypesCall ID types
actualsrcActual source device in indirect mode
srcdevSource device of outbound call
callingCalling number
calledCalled number
snetidSource network ID
npNP parameters
headersSIP header parameters
cinfoCustom info
resultsLookup results
Returns
OSP_OK Found , OSP_FAILED No route, OSP_ERROR Error

Definition at line 1499 of file app_osplookup.c.

References ast_copy_string(), ast_debug, ast_log, ast_strlen_zero, osp_callid::buf, osp_results::called, osp_results::calling, osp_npdata::cic, osp_results::dest, osp_headers::divhost, osp_headers::divuser, dummy(), error(), host, osp_results::inhandle, osp_results::intech, osp_results::intimelimit, osp_callid::len, LOG_ERROR, LOG_WARNING, osp_results::networkid, osp_results::npcic, osp_npdata::npdi, osp_results::npdi, osp_results::nprn, NULL, osp_results::numdests, osp_npdata::opname, osp_results::opname, OSP_CALLID_MAXNUM, osp_check_destination(), osp_choose_timelimit(), osp_convert_inout(), osp_create_callid(), osp_create_transaction(), OSP_DEF_MAXDESTS, OSP_DEF_TIMELIMIT, OSP_ERROR, OSP_FAILED, osp_get_provider(), OSP_INVALID_HANDLE, OSP_MAX_CUSTOMINFO, OSP_MODE_INDIRECT, OSP_OK, OSP_SIZE_NORSTR, OSP_SIZE_OUTSTR, OSP_SIZE_TOKSTR, OSP_SRV_NPQUERY, OSP_TECH_H323, OSP_TECH_IAX, OSP_TECH_SIP, OSP_TECH_SKYPE, osp_results::outcallid, osp_results::outhandle, osp_results::outtech, osp_results::outtimelimit, osp_headers::paiuser, osp_headers::pciuser, provider, osp_npdata::rn, osp_headers::rpiduser, osp_provider::source, osp_provider::srvtype, tmp(), osp_results::token, type, and osp_provider::workmode.

Referenced by osplookup_exec().

1511 {
1512  int res;
1513  struct osp_provider* provider = NULL;
1514  OSPE_PROTOCOL_NAME protocol;
1515  char source[OSP_SIZE_NORSTR];
1516  char callingnum[OSP_SIZE_NORSTR];
1517  char callednum[OSP_SIZE_NORSTR];
1518  char destination[OSP_SIZE_NORSTR];
1519  char* tmp;
1520  unsigned int tokenlen;
1521  char token[OSP_SIZE_TOKSTR];
1522  char src[OSP_SIZE_OUTSTR];
1523  char dev[OSP_SIZE_OUTSTR];
1524  char host[OSP_SIZE_OUTSTR];
1525  unsigned int i, type;
1526  struct osp_callid callid;
1527  unsigned int callidnum;
1528  OSPT_CALL_ID* callids[OSP_CALLID_MAXNUM];
1529  char dest[OSP_SIZE_OUTSTR];
1530  const char* preferred[2] = { NULL };
1531  unsigned int dummy = 0;
1532  OSPEFAILREASON reason;
1533  int error;
1534 
1535  if (results == NULL) {
1536  ast_log(LOG_ERROR, "Invalid parameters\n");
1537  return OSP_ERROR;
1538  }
1539 
1540  osp_convert_inout(results->dest, dest, sizeof(dest));
1541 
1542  results->outhandle = OSP_INVALID_HANDLE;
1543  results->outtech[0] = '\0';
1544  results->calling[0] = '\0';
1545  results->called[0] = '\0';
1546  results->token[0] = '\0';
1547  results->networkid[0] = '\0';
1548  results->nprn[0] = '\0';
1549  results->npcic[0] = '\0';
1550  results->npdi = 0;
1551  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1552  results->opname[type][0] = '\0';
1553  }
1554  results->numdests = 0;
1555  results->outtimelimit = OSP_DEF_TIMELIMIT;
1556 
1557  if ((res = osp_get_provider(name, &provider)) <= 0) {
1558  ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", name);
1559  return res;
1560  }
1561 
1562  if ((res = osp_create_transaction(name, &results->outhandle, source, sizeof(source))) <= 0) {
1563  ast_debug(1, "OSP: Unable to generate transaction handle\n");
1564  results->outhandle = OSP_INVALID_HANDLE;
1565  if (results->inhandle != OSP_INVALID_HANDLE) {
1566  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1567  }
1568  return OSP_ERROR;
1569  }
1570 
1571  if (!strcasecmp(results->intech, OSP_TECH_SIP)) {
1572  protocol = OSPC_PROTNAME_SIP;
1573  } else if (!strcasecmp(results->intech, OSP_TECH_H323)) {
1574  protocol = OSPC_PROTNAME_Q931;
1575  } else if (!strcasecmp(results->intech, OSP_TECH_IAX)) {
1576  protocol = OSPC_PROTNAME_IAX;
1577  } else if (!strcasecmp(results->intech, OSP_TECH_SKYPE)) {
1578  protocol = OSPC_PROTNAME_SKYPE;
1579  } else {
1580  protocol = OSPC_PROTNAME_SIP;
1581  }
1582  OSPPTransactionSetProtocol(results->outhandle, OSPC_PROTTYPE_SOURCE, protocol);
1583 
1584  if (!ast_strlen_zero(snetid)) {
1585  OSPPTransactionSetNetworkIds(results->outhandle, snetid, "");
1586  }
1587 
1588  OSPPTransactionSetNumberPortability(results->outhandle, np->rn, np->cic, np->npdi);
1589 
1590  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1591  OSPPTransactionSetOperatorName(results->outhandle, type, np->opname[type]);
1592  }
1593 
1594  OSPPTransactionSetRemotePartyId(results->outhandle, OSPC_NFORMAT_E164, headers->rpiduser);
1595  OSPPTransactionSetAssertedId(results->outhandle, OSPC_NFORMAT_E164, headers->paiuser);
1596  osp_convert_inout(headers->divhost, host, sizeof(host));
1597  OSPPTransactionSetDiversion(results->outhandle, headers->divuser, host);
1598  OSPPTransactionSetChargeInfo(results->outhandle, OSPC_NFORMAT_E164, headers->pciuser);
1599 
1600  if (cinfo != NULL) {
1601  for (i = 0; i < OSP_MAX_CUSTOMINFO; i++) {
1602  if (!ast_strlen_zero(cinfo[i])) {
1603  OSPPTransactionSetCustomInfo(results->outhandle, i, cinfo[i]);
1604  }
1605  }
1606  }
1607 
1608  ast_copy_string(callednum, called, sizeof(callednum));
1609  if((tmp = strchr(callednum, ';')) != NULL) {
1610  *tmp = '\0';
1611  }
1612 
1613  callidnum = 0;
1614  callids[0] = NULL;
1615  for (i = 0; i < OSP_CALLID_MAXNUM; i++) {
1616  type = 1 << i;
1617  if (callidtypes & type) {
1618  error = osp_create_callid(type, &callid);
1619  if (error == 1) {
1620  callids[callidnum] = OSPPCallIdNew(callid.len, callid.buf);
1621  callidnum++;
1622  }
1623  }
1624  }
1625 
1626  if (provider->workmode == OSP_MODE_INDIRECT) {
1627  osp_convert_inout(srcdev, src, sizeof(src));
1628  if (ast_strlen_zero(actualsrc)) {
1629  osp_convert_inout(srcdev, dev, sizeof(dev));
1630  } else {
1631  osp_convert_inout(actualsrc, dev, sizeof(dev));
1632  }
1633  } else {
1634  osp_convert_inout(source, src, sizeof(src));
1635  osp_convert_inout(srcdev, dev, sizeof(dev));
1636  }
1637 
1638  if (provider->srvtype == OSP_SRV_NPQUERY) {
1639  OSPPTransactionSetServiceType(results->outhandle, OSPC_SERVICE_NPQUERY);
1640  if (!ast_strlen_zero(dest)) {
1641  preferred[0] = dest;
1642  }
1643  results->numdests = 1;
1644  } else {
1645  OSPPTransactionSetServiceType(results->outhandle, OSPC_SERVICE_VOICE);
1646  results->numdests = OSP_DEF_MAXDESTS;
1647  }
1648 
1649  error = OSPPTransactionRequestAuthorisation(results->outhandle,
1650  src,
1651  dev,
1652  calling ? calling : "",
1653  OSPC_NFORMAT_E164,
1654  callednum,
1655  OSPC_NFORMAT_E164,
1656  NULL,
1657  callidnum,
1658  callids,
1659  preferred,
1660  &results->numdests,
1661  &dummy,
1662  NULL);
1663 
1664  for (i = 0; i < callidnum; i++) {
1665  OSPPCallIdDelete(&callids[i]);
1666  }
1667 
1668  if (error != OSPC_ERR_NO_ERROR) {
1669  ast_log(LOG_WARNING, "OSP: Unable to request authorization, error '%d'\n", error);
1670  results->numdests = 0;
1671  if (results->inhandle != OSP_INVALID_HANDLE) {
1672  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1673  }
1674  return OSP_ERROR;
1675  }
1676 
1677  if (!results->numdests) {
1678  ast_debug(1, "OSP: No more destination\n");
1679  if (results->inhandle != OSP_INVALID_HANDLE) {
1680  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1681  }
1682  return OSP_FAILED;
1683  }
1684 
1685  results->outcallid.len = sizeof(results->outcallid.buf);
1686  tokenlen = sizeof(token);
1687  error = OSPPTransactionGetFirstDestination(results->outhandle,
1688  0,
1689  NULL,
1690  NULL,
1691  &results->outtimelimit,
1692  &results->outcallid.len,
1693  results->outcallid.buf,
1694  sizeof(callednum),
1695  callednum,
1696  sizeof(callingnum),
1697  callingnum,
1698  sizeof(destination),
1699  destination,
1700  0,
1701  NULL,
1702  &tokenlen,
1703  token);
1704  if (error != OSPC_ERR_NO_ERROR) {
1705  ast_debug(1, "OSP: Unable to get first route, error '%d'\n", error);
1706  results->numdests = 0;
1707  results->outtimelimit = OSP_DEF_TIMELIMIT;
1708  if (results->inhandle != OSP_INVALID_HANDLE) {
1709  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1710  }
1711  return OSP_ERROR;
1712  }
1713 
1714  results->numdests--;
1715  results->outtimelimit = osp_choose_timelimit(results->intimelimit, results->outtimelimit);
1716  ast_debug(1, "OSP: outtimelimit '%d'\n", results->outtimelimit);
1717  ast_debug(1, "OSP: calling '%s'\n", callingnum);
1718  ast_debug(1, "OSP: called '%s'\n", callednum);
1719  ast_debug(1, "OSP: destination '%s'\n", destination);
1720  ast_debug(1, "OSP: token size '%d'\n", tokenlen);
1721 
1722  if ((res = osp_check_destination(provider, callingnum, callednum, destination, tokenlen, token, &reason, results)) > 0) {
1723  return OSP_OK;
1724  }
1725 
1726  if (!results->numdests) {
1727  ast_debug(1, "OSP: No more destination\n");
1728  results->outtimelimit = OSP_DEF_TIMELIMIT;
1729  OSPPTransactionRecordFailure(results->outhandle, reason);
1730  if (results->inhandle != OSP_INVALID_HANDLE) {
1731  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1732  }
1733  return OSP_FAILED;
1734  }
1735 
1736  while(results->numdests) {
1737  results->outcallid.len = sizeof(results->outcallid.buf);
1738  tokenlen = sizeof(token);
1739  error = OSPPTransactionGetNextDestination(results->outhandle,
1740  reason,
1741  0,
1742  NULL,
1743  NULL,
1744  &results->outtimelimit,
1745  &results->outcallid.len,
1746  results->outcallid.buf,
1747  sizeof(callednum),
1748  callednum,
1749  sizeof(callingnum),
1750  callingnum,
1751  sizeof(destination),
1752  destination,
1753  0,
1754  NULL,
1755  &tokenlen,
1756  token);
1757  if (error == OSPC_ERR_NO_ERROR) {
1758  results->numdests--;
1759  results->outtimelimit = osp_choose_timelimit(results->intimelimit, results->outtimelimit);
1760  ast_debug(1, "OSP: outtimelimit '%d'\n", results->outtimelimit);
1761  ast_debug(1, "OSP: calling '%s'\n", callingnum);
1762  ast_debug(1, "OSP: called '%s'\n", callednum);
1763  ast_debug(1, "OSP: destination '%s'\n", destination);
1764  ast_debug(1, "OSP: token size '%d'\n", tokenlen);
1765 
1766  if ((res = osp_check_destination(provider, callingnum, callednum, destination, tokenlen, token, &reason, results)) > 0) {
1767  break;
1768  } else if (!results->numdests) {
1769  ast_debug(1, "OSP: No more destination\n");
1770  OSPPTransactionRecordFailure(results->outhandle, reason);
1771  if (results->inhandle != OSP_INVALID_HANDLE) {
1772  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1773  }
1774  res = OSP_FAILED;
1775  break;
1776  }
1777  } else {
1778  ast_debug(1, "OSP: Unable to get route, error '%d'\n", error);
1779  results->numdests = 0;
1780  results->outtimelimit = OSP_DEF_TIMELIMIT;
1781  if (results->inhandle != OSP_INVALID_HANDLE) {
1782  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1783  }
1784  res = OSP_ERROR;
1785  break;
1786  }
1787  }
1788 
1789  return res;
1790 }
static const char type[]
Definition: chan_ooh323.c:109
const char * paiuser
#define OSP_TECH_SIP
#define OSP_TECH_H323
const char * cic
#define LOG_WARNING
Definition: logger.h:274
const char * divuser
static void dummy(char *unused,...)
Definition: chan_unistim.c:220
static int tmp()
Definition: bt_open.c:389
char dest[OSP_SIZE_NORSTR]
#define OSP_SIZE_TOKSTR
#define OSP_OK
#define OSP_TECH_SKYPE
static int osp_get_provider(const char *name, struct osp_provider **provider)
Get OSP provider by name.
#define NULL
Definition: resample.c:96
unsigned int numdests
char outtech[OSP_SIZE_TECHSTR]
char nprn[OSP_SIZE_NORSTR]
#define ast_strlen_zero(foo)
Definition: strings.h:52
char intech[OSP_SIZE_TECHSTR]
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static int osp_create_transaction(const char *name, int *trans, char *source, unsigned int srcsize)
Create OSP transaction handle.
static char host[256]
Definition: muted.c:77
unsigned int outtimelimit
char calling[OSP_SIZE_NORSTR]
#define OSP_ERROR
static unsigned int osp_choose_timelimit(unsigned int in, unsigned int out)
Choose min duration limit.
static void osp_convert_inout(const char *src, char *dest, unsigned int destsize)
Convert "address:port" to "[x.x.x.x]:port" or "hostname:port" format.
unsigned int intimelimit
static int osp_check_destination(struct osp_provider *provider, const char *calling, const char *called, const char *destination, unsigned int tokenlen, const char *token, OSPEFAILREASON *reason, struct osp_results *results)
Choose min duration limit.
#define LOG_ERROR
Definition: logger.h:285
char opname[OSPC_OPNAME_NUMBER][OSP_SIZE_NORSTR]
#define OSP_TECH_IAX
char npcic[OSP_SIZE_NORSTR]
const char * rn
static const char name[]
Definition: cdr_mysql.c:74
#define OSP_SIZE_OUTSTR
enum osp_workmode workmode
#define OSP_DEF_TIMELIMIT
char networkid[OSP_SIZE_NORSTR]
#define OSP_INVALID_HANDLE
char token[OSP_SIZE_TOKSTR]
#define OSP_MAX_CUSTOMINFO
static int osp_create_callid(unsigned int type, struct osp_callid *callid)
Create a call ID according to the type.
const char * pciuser
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_SIZE_NORSTR
char called[OSP_SIZE_NORSTR]
int error(const char *format,...)
Definition: utils/frame.c:999
#define OSP_CALLID_MAXNUM
#define OSP_DEF_MAXDESTS
unsigned char buf[OSP_SIZE_NORSTR]
struct osp_callid outcallid
char source[OSP_SIZE_NORSTR]
#define OSP_FAILED
enum osp_srvtype srvtype
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
const char * divhost
unsigned int len
const char * rpiduser
const char * opname[OSPC_OPNAME_NUMBER]

◆ osp_next()

static int osp_next ( const char *  name,
int  cause,
struct osp_results results 
)
static

OSP Lookup Next function.

Parameters
nameOSP provider name
causeAsterisk hangup cause
resultsLookup results, in/output
Returns
OSP_OK Found , OSP_FAILED No route, OSP_ERROR Error

Definition at line 1799 of file app_osplookup.c.

References ast_debug, ast_log, asterisk2osp(), osp_callid::buf, osp_results::called, osp_results::calling, osp_results::dest, error(), osp_results::inhandle, osp_results::intimelimit, osp_callid::len, LOG_ERROR, osp_results::networkid, osp_results::npcic, osp_results::npdi, osp_results::nprn, NULL, osp_results::numdests, osp_results::opname, osp_check_destination(), osp_choose_timelimit(), OSP_DEF_TIMELIMIT, OSP_ERROR, OSP_FAILED, osp_get_provider(), OSP_INVALID_HANDLE, OSP_OK, OSP_SIZE_NORSTR, OSP_SIZE_TOKSTR, osp_results::outcallid, osp_results::outhandle, osp_results::outtech, osp_results::outtimelimit, provider, osp_results::token, and type.

Referenced by ospnext_exec().

1803 {
1804  int res;
1805  struct osp_provider* provider = NULL;
1806  char calling[OSP_SIZE_NORSTR];
1807  char called[OSP_SIZE_NORSTR];
1808  char dest[OSP_SIZE_NORSTR];
1809  unsigned int tokenlen;
1810  char token[OSP_SIZE_TOKSTR];
1811  OSPEFAILREASON reason;
1812  OSPE_OPERATOR_NAME type;
1813  int error;
1814 
1815  if (results == NULL) {
1816  ast_log(LOG_ERROR, "Invalid parameters\n");
1817  return OSP_ERROR;
1818  }
1819 
1820  results->outtech[0] = '\0';
1821  results->dest[0] = '\0';
1822  results->calling[0] = '\0';
1823  results->called[0] = '\0';
1824  results->token[0] = '\0';
1825  results->networkid[0] = '\0';
1826  results->nprn[0] = '\0';
1827  results->npcic[0] = '\0';
1828  results->npdi = 0;
1829  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1830  results->opname[type][0] = '\0';
1831  }
1832  results->outtimelimit = OSP_DEF_TIMELIMIT;
1833 
1834  if ((res = osp_get_provider(name, &provider)) <= 0) {
1835  ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", name);
1836  return res;
1837  }
1838 
1839  if (results->outhandle == OSP_INVALID_HANDLE) {
1840  ast_debug(1, "OSP: Transaction handle undefined\n");
1841  results->numdests = 0;
1842  if (results->inhandle != OSP_INVALID_HANDLE) {
1843  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1844  }
1845  return OSP_ERROR;
1846  }
1847 
1848  reason = asterisk2osp(cause);
1849 
1850  if (!results->numdests) {
1851  ast_debug(1, "OSP: No more destination\n");
1852  OSPPTransactionRecordFailure(results->outhandle, reason);
1853  if (results->inhandle != OSP_INVALID_HANDLE) {
1854  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1855  }
1856  return OSP_FAILED;
1857  }
1858 
1859  while(results->numdests) {
1860  results->outcallid.len = sizeof(results->outcallid.buf);
1861  tokenlen = sizeof(token);
1862  error = OSPPTransactionGetNextDestination(
1863  results->outhandle,
1864  reason,
1865  0,
1866  NULL,
1867  NULL,
1868  &results->outtimelimit,
1869  &results->outcallid.len,
1870  results->outcallid.buf,
1871  sizeof(called),
1872  called,
1873  sizeof(calling),
1874  calling,
1875  sizeof(dest),
1876  dest,
1877  0,
1878  NULL,
1879  &tokenlen,
1880  token);
1881  if (error == OSPC_ERR_NO_ERROR) {
1882  results->numdests--;
1883  results->outtimelimit = osp_choose_timelimit(results->intimelimit, results->outtimelimit);
1884  ast_debug(1, "OSP: outtimelimit '%d'\n", results->outtimelimit);
1885  ast_debug(1, "OSP: calling '%s'\n", calling);
1886  ast_debug(1, "OSP: called '%s'\n", called);
1887  ast_debug(1, "OSP: destination '%s'\n", dest);
1888  ast_debug(1, "OSP: token size '%d'\n", tokenlen);
1889 
1890  if ((res = osp_check_destination(provider, calling, called, dest, tokenlen, token, &reason, results)) > 0) {
1891  res = OSP_OK;
1892  break;
1893  } else if (!results->numdests) {
1894  ast_debug(1, "OSP: No more destination\n");
1895  OSPPTransactionRecordFailure(results->outhandle, reason);
1896  if (results->inhandle != OSP_INVALID_HANDLE) {
1897  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1898  }
1899  res = OSP_FAILED;
1900  break;
1901  }
1902  } else {
1903  ast_debug(1, "OSP: Unable to get route, error '%d'\n", error);
1904  results->token[0] = '\0';
1905  results->numdests = 0;
1906  results->outtimelimit = OSP_DEF_TIMELIMIT;
1907  if (results->inhandle != OSP_INVALID_HANDLE) {
1908  OSPPTransactionRecordFailure(results->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1909  }
1910  res = OSP_ERROR;
1911  break;
1912  }
1913  }
1914 
1915  return res;
1916 }
static const char type[]
Definition: chan_ooh323.c:109
char dest[OSP_SIZE_NORSTR]
#define OSP_SIZE_TOKSTR
#define OSP_OK
static int osp_get_provider(const char *name, struct osp_provider **provider)
Get OSP provider by name.
#define NULL
Definition: resample.c:96
unsigned int numdests
char outtech[OSP_SIZE_TECHSTR]
char nprn[OSP_SIZE_NORSTR]
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
unsigned int outtimelimit
char calling[OSP_SIZE_NORSTR]
#define OSP_ERROR
static unsigned int osp_choose_timelimit(unsigned int in, unsigned int out)
Choose min duration limit.
unsigned int intimelimit
static int osp_check_destination(struct osp_provider *provider, const char *calling, const char *called, const char *destination, unsigned int tokenlen, const char *token, OSPEFAILREASON *reason, struct osp_results *results)
Choose min duration limit.
#define LOG_ERROR
Definition: logger.h:285
char opname[OSPC_OPNAME_NUMBER][OSP_SIZE_NORSTR]
char npcic[OSP_SIZE_NORSTR]
static const char name[]
Definition: cdr_mysql.c:74
#define OSP_DEF_TIMELIMIT
char networkid[OSP_SIZE_NORSTR]
static OSPEFAILREASON asterisk2osp(int cause)
Convert Asterisk status to TC code.
#define OSP_INVALID_HANDLE
char token[OSP_SIZE_TOKSTR]
#define OSP_SIZE_NORSTR
char called[OSP_SIZE_NORSTR]
int error(const char *format,...)
Definition: utils/frame.c:999
unsigned char buf[OSP_SIZE_NORSTR]
struct osp_callid outcallid
#define OSP_FAILED
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
unsigned int len

◆ osp_report_qos()

static int osp_report_qos ( int  trans,
enum osp_callleg  leg,
const char *  qos 
)
static

Report QoS.

Parameters
transOSP in/outbound transaction handle
legInbound/outbound
qosQoS string
Returns
OSP_OK Success, OSP_FAILED Failed, OSP_ERROR Error

Definition at line 1971 of file app_osplookup.c.

References ast_copy_string(), ast_debug, ast_strlen_zero, osp_metrics::avg, item, max, osp_metrics::max, min, osp_metrics::min, NULL, OSP_CALL_INBOUND, OSP_DEF_FLOATSTATS, OSP_DEF_INTSTATS, OSP_DIR_NUMBER, OSP_DIR_RX, OSP_DIR_TX, OSP_FAILED, osp_get_varfloat(), osp_get_varint(), OSP_OK, OSP_SIZE_NORSTR, osp_metrics::sdev, tmp(), value, and osp_metrics::value.

Referenced by osp_finish().

1975 {
1976  int res = OSP_FAILED;
1977  enum osp_direction dir;
1978  char buffer[OSP_SIZE_NORSTR];
1979  char* tmp;
1980  char* item;
1981  int totalpackets[OSP_DIR_NUMBER];
1982  struct osp_metrics lost[OSP_DIR_NUMBER];
1983  struct osp_metrics jitter[OSP_DIR_NUMBER];
1984  struct osp_metrics rtt;
1985  int value;
1986 
1987  if (!ast_strlen_zero(qos)) {
1988  for (dir = OSP_DIR_RX; dir < OSP_DIR_NUMBER; dir++) {
1989  totalpackets[dir] = OSP_DEF_INTSTATS;
1990  }
1991 
1992  for (dir = OSP_DIR_RX; dir < OSP_DIR_NUMBER; dir++) {
1993  lost[dir].value = OSP_DEF_INTSTATS;
1994  lost[dir].min = OSP_DEF_FLOATSTATS;
1995  lost[dir].max = OSP_DEF_FLOATSTATS;
1996  lost[dir].avg = OSP_DEF_FLOATSTATS;
1997  lost[dir].sdev = OSP_DEF_FLOATSTATS;
1998  }
1999 
2000  for (dir = OSP_DIR_RX; dir < OSP_DIR_NUMBER; dir++) {
2001  jitter[dir].value = OSP_DEF_INTSTATS;
2002  jitter[dir].min = OSP_DEF_FLOATSTATS;
2003  jitter[dir].max = OSP_DEF_FLOATSTATS;
2004  jitter[dir].avg = OSP_DEF_FLOATSTATS;
2005  jitter[dir].sdev = OSP_DEF_FLOATSTATS;
2006  }
2007 
2008  rtt.value = OSP_DEF_INTSTATS;
2009  rtt.min = OSP_DEF_FLOATSTATS;
2010  rtt.max = OSP_DEF_FLOATSTATS;
2011  rtt.avg = OSP_DEF_FLOATSTATS;
2012  rtt.sdev = OSP_DEF_FLOATSTATS;
2013 
2014  ast_copy_string(buffer, qos, sizeof(buffer));
2015  for (item = strtok_r(buffer, ";", &tmp); item; item = strtok_r(NULL, ";", &tmp)) {
2016  if (!strncasecmp(item, "rxcount", strlen("rxcount"))) {
2017  totalpackets[OSP_DIR_RX] = osp_get_varint(item);
2018  } else if (!strncasecmp(item, "txcount", strlen("txcount"))) {
2019  totalpackets[OSP_DIR_TX] = osp_get_varint(item);
2020  } else if (!strncasecmp(item, "lp", strlen("lp"))) {
2021  lost[OSP_DIR_RX].value = osp_get_varint(item);
2022  } else if (!strncasecmp(item, "minrxlost", strlen("minrxlost"))) {
2023  lost[OSP_DIR_RX].min = osp_get_varfloat(item);
2024  } else if (!strncasecmp(item, "maxrxlost", strlen("maxrxlost"))) {
2025  lost[OSP_DIR_RX].max = osp_get_varfloat(item);
2026  } else if (!strncasecmp(item, "avgrxlost", strlen("avgrxlost"))) {
2027  lost[OSP_DIR_RX].avg = osp_get_varfloat(item);
2028  } else if (!strncasecmp(item, "stdevrxlost", strlen("stdevrxlost"))) {
2029  lost[OSP_DIR_RX].sdev = osp_get_varfloat(item);
2030  } else if (!strncasecmp(item, "rlp", strlen("rlp"))) {
2031  lost[OSP_DIR_TX].value = osp_get_varint(item);
2032  } else if (!strncasecmp(item, "reported_minlost", strlen("reported_minlost"))) {
2033  lost[OSP_DIR_TX].min = osp_get_varfloat(item);
2034  } else if (!strncasecmp(item, "reported_maxlost", strlen("reported_maxlost"))) {
2035  lost[OSP_DIR_TX].max = osp_get_varfloat(item);
2036  } else if (!strncasecmp(item, "reported_avglost", strlen("reported_avglost"))) {
2037  lost[OSP_DIR_TX].avg = osp_get_varfloat(item);
2038  } else if (!strncasecmp(item, "reported_stdevlost", strlen("reported_stdevlost"))) {
2039  lost[OSP_DIR_TX].sdev = osp_get_varfloat(item);
2040  } else if (!strncasecmp(item, "rxjitter", strlen("rxjitter"))) {
2041  jitter[OSP_DIR_RX].value = osp_get_varint(item);
2042  } else if (!strncasecmp(item, "minrxjitter", strlen("minrxjitter"))) {
2043  jitter[OSP_DIR_RX].min = osp_get_varfloat(item);
2044  } else if (!strncasecmp(item, "maxrxjitter", strlen("maxrxjitter"))) {
2045  jitter[OSP_DIR_RX].max = osp_get_varfloat(item);
2046  } else if (!strncasecmp(item, "avgrxjitter", strlen("avgjitter"))) {
2047  jitter[OSP_DIR_RX].avg = osp_get_varfloat(item);
2048  } else if (!strncasecmp(item, "stdevrxjitter", strlen("stdevjitter"))) {
2049  jitter[OSP_DIR_RX].sdev = osp_get_varfloat(item);
2050  } else if (!strncasecmp(item, "txjitter", strlen("txjitter"))) {
2051  jitter[OSP_DIR_TX].value = osp_get_varint(item);
2052  } else if (!strncasecmp(item, "reported_minjitter", strlen("reported_minjitter"))) {
2053  jitter[OSP_DIR_TX].min = osp_get_varfloat(item);
2054  } else if (!strncasecmp(item, "reported_maxjitter", strlen("reported_maxjitter"))) {
2055  jitter[OSP_DIR_TX].max = osp_get_varfloat(item);
2056  } else if (!strncasecmp(item, "reported_avgjitter", strlen("reported_avgjitter"))) {
2057  jitter[OSP_DIR_TX].avg = osp_get_varfloat(item);
2058  } else if (!strncasecmp(item, "reported_stdevjitter", strlen("reported_stdevjitter"))) {
2059  jitter[OSP_DIR_TX].sdev = osp_get_varfloat(item);
2060  } else if (!strncasecmp(item, "rtt", strlen("rtt"))) {
2061  rtt.value = osp_get_varint(item);
2062  } else if (!strncasecmp(item, "minrtt", strlen("minrtt"))) {
2063  rtt.min = osp_get_varfloat(item);
2064  } else if (!strncasecmp(item, "maxrtt", strlen("maxrtt"))) {
2065  rtt.max = osp_get_varfloat(item);
2066  } else if (!strncasecmp(item, "avgrtt", strlen("avgrtt"))) {
2067  rtt.avg = osp_get_varfloat(item);
2068  } else if (!strncasecmp(item, "stdevrtt", strlen("stdevrtt"))) {
2069  rtt.sdev = osp_get_varfloat(item);
2070  }
2071  }
2072 
2073  ast_debug(1, "OSP: call leg '%d'\n", leg);
2074  ast_debug(1, "OSP: rxcount '%d'\n", totalpackets[OSP_DIR_RX]);
2075  ast_debug(1, "OSP: txcount '%d'\n", totalpackets[OSP_DIR_TX]);
2076  ast_debug(1, "OSP: lp '%d'\n",lost[OSP_DIR_RX].value);
2077  ast_debug(1, "OSP: minrxlost '%f'\n", lost[OSP_DIR_RX].min);
2078  ast_debug(1, "OSP: maxrxlost '%f'\n", lost[OSP_DIR_RX].max);
2079  ast_debug(1, "OSP: avgrxlost '%f'\n", lost[OSP_DIR_RX].avg);
2080  ast_debug(1, "OSP: stdevrxlost '%f'\n", lost[OSP_DIR_RX].sdev);
2081  ast_debug(1, "OSP: rlp '%d'\n", lost[OSP_DIR_TX].value);
2082  ast_debug(1, "OSP: reported_minlost '%f'\n", lost[OSP_DIR_TX].min);
2083  ast_debug(1, "OSP: reported_maxlost '%f'\n", lost[OSP_DIR_TX].max);
2084  ast_debug(1, "OSP: reported_avglost '%f'\n", lost[OSP_DIR_TX].avg);
2085  ast_debug(1, "OSP: reported_stdevlost '%f'\n", lost[OSP_DIR_TX].sdev);
2086  ast_debug(1, "OSP: rxjitter '%d'\n", jitter[OSP_DIR_RX].value);
2087  ast_debug(1, "OSP: minrxjitter '%f'\n", jitter[OSP_DIR_RX].min);
2088  ast_debug(1, "OSP: maxrxjitter '%f'\n", jitter[OSP_DIR_RX].max);
2089  ast_debug(1, "OSP: avgrxjitter '%f'\n", jitter[OSP_DIR_RX].avg);
2090  ast_debug(1, "OSP: stdevrxjitter '%f'\n", jitter[OSP_DIR_RX].sdev);
2091  ast_debug(1, "OSP: txjitter '%d'\n", jitter[OSP_DIR_TX].value);
2092  ast_debug(1, "OSP: reported_minjitter '%f'\n", jitter[OSP_DIR_TX].min);
2093  ast_debug(1, "OSP: reported_maxjitter '%f'\n", jitter[OSP_DIR_TX].max);
2094  ast_debug(1, "OSP: reported_avgjitter '%f'\n", jitter[OSP_DIR_TX].avg);
2095  ast_debug(1, "OSP: reported_stdevjitter '%f'\n", jitter[OSP_DIR_TX].sdev);
2096  ast_debug(1, "OSP: rtt '%d'\n", rtt.value);
2097  ast_debug(1, "OSP: minrtt '%f'\n", rtt.min);
2098  ast_debug(1, "OSP: maxrtt '%f'\n", rtt.max);
2099  ast_debug(1, "OSP: avgrtt '%f'\n", rtt.avg);
2100  ast_debug(1, "OSP: stdevrtt '%f'\n", rtt.sdev);
2101 
2102  if (leg == OSP_CALL_INBOUND) {
2103  OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTP, OSPC_SDIR_SRCREP, totalpackets[OSP_DIR_RX]);
2104  OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTCP, OSPC_SDIR_DESTREP, totalpackets[OSP_DIR_TX]);
2105  if (lost[OSP_DIR_RX].value >= 0) {
2106  value = lost[OSP_DIR_RX].value;
2107  } else {
2108  value = (int)lost[OSP_DIR_RX].avg;
2109  }
2110  OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTP, OSPC_SDIR_SRCREP, value, OSP_DEF_INTSTATS);
2111  if (lost[OSP_DIR_TX].value >= 0) {
2112  value = lost[OSP_DIR_TX].value;
2113  } else {
2114  value = (int)lost[OSP_DIR_TX].avg;
2115  }
2116  OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTCP, OSPC_SDIR_DESTREP, value, OSP_DEF_INTSTATS);
2117  if (jitter[OSP_DIR_RX].value >= 0) {
2118  value = jitter[OSP_DIR_RX].value;
2119  } else {
2120  value = (int)jitter[OSP_DIR_RX].avg;
2121  }
2122  OSPPTransactionSetJitter(trans,
2123  OSPC_SMETRIC_RTP,
2124  OSPC_SDIR_SRCREP,
2126  (int)jitter[OSP_DIR_RX].min,
2127  (int)jitter[OSP_DIR_RX].max,
2128  value, jitter[OSP_DIR_RX].sdev);
2129  if (jitter[OSP_DIR_TX].value >= 0) {
2130  value = jitter[OSP_DIR_TX].value;
2131  } else {
2132  value = (int)jitter[OSP_DIR_TX].avg;
2133  }
2134  OSPPTransactionSetJitter(trans, OSPC_SMETRIC_RTCP, OSPC_SDIR_DESTREP,
2135  OSP_DEF_INTSTATS, (int)jitter[OSP_DIR_TX].min, (int)jitter[OSP_DIR_TX].max, value, jitter[OSP_DIR_TX].sdev);
2136  } else {
2137  OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTP, OSPC_SDIR_DESTREP, totalpackets[OSP_DIR_RX]);
2138  OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTCP, OSPC_SDIR_SRCREP, totalpackets[OSP_DIR_TX]);
2139  OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTP, OSPC_SDIR_DESTREP, lost[OSP_DIR_RX].value, OSP_DEF_INTSTATS);
2140  OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTCP, OSPC_SDIR_SRCREP, lost[OSP_DIR_TX].value, OSP_DEF_INTSTATS);
2141  if (jitter[OSP_DIR_RX].value >= 0) {
2142  value = jitter[OSP_DIR_RX].value;
2143  } else {
2144  value = (int)jitter[OSP_DIR_RX].avg;
2145  }
2146  OSPPTransactionSetJitter(trans,
2147  OSPC_SMETRIC_RTP,
2148  OSPC_SDIR_DESTREP,
2150  (int)jitter[OSP_DIR_RX].min,
2151  (int)jitter[OSP_DIR_RX].max,
2152  value,
2153  jitter[OSP_DIR_RX].sdev);
2154  if (jitter[OSP_DIR_TX].value >= 0) {
2155  value = jitter[OSP_DIR_TX].value;
2156  } else {
2157  value = (int)jitter[OSP_DIR_TX].avg;
2158  }
2159  OSPPTransactionSetJitter(trans,
2160  OSPC_SMETRIC_RTCP,
2161  OSPC_SDIR_SRCREP,
2163  (int)jitter[OSP_DIR_TX].min,
2164  (int)jitter[OSP_DIR_TX].max,
2165  value,
2166  jitter[OSP_DIR_TX].sdev);
2167  }
2168 
2169  res = OSP_OK;
2170  }
2171 
2172  return res;
2173 }
static struct @111 qos
static int tmp()
Definition: bt_open.c:389
#define OSP_OK
static struct aco_type item
Definition: test_config.c:1463
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
osp_direction
static int osp_get_varint(const char *vstr)
Get integer from variable string.
#define OSP_DEF_FLOATSTATS
static float osp_get_varfloat(const char *vstr)
Get float from variable string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_SIZE_NORSTR
#define OSP_DEF_INTSTATS
#define OSP_FAILED
#define min(a, b)
Definition: f2c.h:197
#define max(a, b)
Definition: f2c.h:198

◆ osp_unload()

static int osp_unload ( void  )
static

Definition at line 2929 of file app_osplookup.c.

References ast_free, ast_mutex_lock, ast_mutex_unlock, osp_provider::handle, osp_provider::next, NULL, osp_hardware, osp_initialized, osp_lock, osp_security, osp_tokenformat, and provider.

Referenced by osp_load(), and unload_module().

2930 {
2931  struct osp_provider* provider;
2932  struct osp_provider* next;
2933 
2934  if (osp_initialized) {
2936  for (provider = osp_providers; provider; provider = next) {
2937  next = provider->next;
2938  OSPPProviderDelete(provider->handle, 0);
2939  ast_free(provider);
2940  }
2941  osp_providers = NULL;
2943 
2944  OSPPCleanup();
2945 
2946  osp_tokenformat = TOKEN_ALGO_SIGNED;
2947  osp_security = 0;
2948  osp_hardware = 0;
2949  osp_initialized = 0;
2950  }
2951 
2952  return 0;
2953 }
static int osp_hardware
OSPTPROVHANDLE handle
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static int osp_initialized
#define ast_free(a)
Definition: astmm.h:182
static unsigned int osp_tokenformat
static int osp_security
static struct osp_provider * osp_providers
struct osp_provider * next
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
static ast_mutex_t osp_lock
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ osp_uuid2str()

static int osp_uuid2str ( unsigned char *  uuid,
char *  buffer,
unsigned int  bufsize 
)
static

UUID to string.

Parameters
uuidUUID
bufferString buffer
bufsizeString buffer size
Returns
OSP_OK Successed, OSP_ERROR Error

Definition at line 1423 of file app_osplookup.c.

References ast_log, LOG_ERROR, NULL, OSP_ERROR, OSP_OK, and OSP_SIZE_UUIDSTR.

Referenced by osplookup_exec(), and ospnext_exec().

1427 {
1428  int res;
1429 
1430  if ((uuid != NULL) && (bufsize > OSP_SIZE_UUIDSTR)) {
1431  snprintf(buffer, bufsize, "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-"
1432  "%02hhx%02hhx-%02hhx%02hhx-"
1433  "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
1434  uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
1435  uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
1436  res = OSP_OK;
1437  } else {
1438  ast_log(LOG_ERROR, "Invalid parameters\n");
1439  res = OSP_ERROR;
1440  }
1441 
1442  return res;
1443 }
#define OSP_OK
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define OSP_ERROR
#define OSP_SIZE_UUIDSTR
#define LOG_ERROR
Definition: logger.h:285

◆ osp_validate_token()

static int osp_validate_token ( int  trans,
const char *  source,
const char *  destination,
const char *  calling,
const char *  called,
const char *  token,
unsigned int *  timelimit 
)
static

Validate OSP token of inbound call.

Parameters
transOSP transaction handle
sourceSource of inbound call
destinationDestination of inbound call
callingCalling number
calledCalled number
tokenOSP token, may be empty
timelimitCall duration limit, output
Returns
OSP_OK Success, OSP_FAILED Failed, OSP_ERROR Error

Definition at line 1081 of file app_osplookup.c.

References ast_base64decode(), ast_debug, ast_log, dummy(), error(), LOG_ERROR, LOG_WARNING, NULL, osp_convert_inout(), OSP_ERROR, OSP_FAILED, OSP_OK, OSP_SIZE_OUTSTR, OSP_SIZE_TOKSTR, and osp_tokenformat.

Referenced by osp_auth().

1089 {
1090  int res;
1091  int tokenlen;
1092  unsigned char tokenstr[OSP_SIZE_TOKSTR];
1093  char src[OSP_SIZE_OUTSTR];
1094  char dest[OSP_SIZE_OUTSTR];
1095  unsigned int authorised;
1096  unsigned int dummy = 0;
1097  int error;
1098 
1099  if (timelimit == NULL) {
1100  ast_log(LOG_ERROR, "Invalid parameters\n");
1101  return OSP_ERROR;
1102  }
1103 
1104  tokenlen = ast_base64decode(tokenstr, token, strlen(token));
1105  osp_convert_inout(source, src, sizeof(src));
1106  osp_convert_inout(destination, dest, sizeof(dest));
1107  error = OSPPTransactionValidateAuthorisation(trans,
1108  src,
1109  dest,
1110  NULL,
1111  NULL,
1112  calling ? calling : "",
1113  OSPC_NFORMAT_E164,
1114  called,
1115  OSPC_NFORMAT_E164,
1116  0,
1117  NULL,
1118  tokenlen,
1119  (char*)tokenstr,
1120  &authorised,
1121  timelimit,
1122  &dummy,
1123  NULL,
1124  osp_tokenformat);
1125  if (error != OSPC_ERR_NO_ERROR) {
1126  ast_log(LOG_WARNING, "OSP: Unable to validate inbound token, error '%d'\n", error);
1127  *timelimit = 0;
1128  res = OSP_ERROR;
1129  } else if (authorised) {
1130  ast_debug(1, "OSP: Authorised\n");
1131  res = OSP_OK;
1132  } else {
1133  ast_debug(1, "OSP: Unauthorised\n");
1134  res = OSP_FAILED;
1135  }
1136 
1137  return res;
1138 }
#define LOG_WARNING
Definition: logger.h:274
static void dummy(char *unused,...)
Definition: chan_unistim.c:220
#define OSP_SIZE_TOKSTR
#define OSP_OK
#define NULL
Definition: resample.c:96
int ast_base64decode(unsigned char *dst, const char *src, int max)
Decode data from base64.
Definition: main/utils.c:294
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define OSP_ERROR
static void osp_convert_inout(const char *src, char *dest, unsigned int destsize)
Convert "address:port" to "[x.x.x.x]:port" or "hostname:port" format.
#define LOG_ERROR
Definition: logger.h:285
#define OSP_SIZE_OUTSTR
static unsigned int osp_tokenformat
int error(const char *format,...)
Definition: utils/frame.c:999
char source[OSP_SIZE_NORSTR]
#define OSP_FAILED

◆ ospauth_exec()

static int ospauth_exec ( struct ast_channel chan,
const char *  data 
)
static

OSP Application OSPAuth.

Parameters
chanChannel
dataParameter
Returns
OSP_AST_OK Success, OSP_AST_ERROR Error

Definition at line 2257 of file app_osplookup.c.

References args, AST_APP_ARG, ast_channel_caller(), ast_channel_exten(), ast_channel_varshead(), ast_debug, AST_DECLARE_APP_ARGS, AST_LIST_TRAVERSE, AST_OSP_ERROR, AST_OSP_FAILED, AST_OSP_SUCCESS, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_var_name(), ast_var_value(), ast_var_t::entries, osp_provider::handle, NULL, options, OSP_AST_ERROR, OSP_AST_OK, osp_auth(), OSP_DEF_PROVIDER, OSP_DEF_TIMELIMIT, OSP_OK, OSP_SIZE_INTSTR, pbx_builtin_setvar_helper(), provider, S_COR, osp_provider::source, status, and tmp().

Referenced by load_module().

2260 {
2261  int res;
2262  const char* provider = OSP_DEF_PROVIDER;
2263  struct varshead* headp;
2264  struct ast_var_t* current;
2265  const char* source = "";
2266  const char* token = "";
2267  int handle;
2268  unsigned int timelimit;
2269  char buffer[OSP_SIZE_INTSTR];
2270  const char* status;
2271  char* tmp;
2272 
2274  AST_APP_ARG(provider);
2276  );
2277 
2278  tmp = ast_strdupa(data);
2279 
2281 
2282  if (!ast_strlen_zero(args.provider)) {
2283  provider = args.provider;
2284  }
2285  ast_debug(1, "OSPAuth: provider '%s'\n", provider);
2286 
2287  headp = ast_channel_varshead(chan);
2288  AST_LIST_TRAVERSE(headp, current, entries) {
2289  if (!strcmp(ast_var_name(current), "OSPINPEERIP")) {
2290  source = ast_var_value(current);
2291  } else if (!strcmp(ast_var_name(current), "OSPINTOKEN")) {
2292  token = ast_var_value(current);
2293  }
2294  }
2295 
2296  ast_debug(1, "OSPAuth: source '%s'\n", source);
2297  ast_debug(1, "OSPAuth: token size '%zd'\n", strlen(token));
2298 
2299  res = osp_auth(provider, &handle, source,
2300  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL),
2301  ast_channel_exten(chan), token, &timelimit);
2302  if (res > 0) {
2303  status = AST_OSP_SUCCESS;
2304  } else {
2305  timelimit = OSP_DEF_TIMELIMIT;
2306  if (!res) {
2307  status = AST_OSP_FAILED;
2308  } else {
2309  status = AST_OSP_ERROR;
2310  }
2311  }
2312 
2313  snprintf(buffer, sizeof(buffer), "%d", handle);
2314  pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
2315  ast_debug(1, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
2316  snprintf(buffer, sizeof(buffer), "%d", timelimit);
2317  pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer);
2318  ast_debug(1, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
2319  pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status);
2320  ast_debug(1, "OSPAuth: %s\n", status);
2321 
2322  if(res != OSP_OK) {
2323  res = OSP_AST_ERROR;
2324  } else {
2325  res = OSP_AST_OK;
2326  }
2327 
2328  return res;
2329 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define AST_OSP_FAILED
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:80
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:60
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
static int tmp()
Definition: bt_open.c:389
#define OSP_OK
#define AST_OSP_SUCCESS
struct varshead * ast_channel_varshead(struct ast_channel *chan)
const char * args
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
static int osp_auth(const char *name, int *trans, const char *source, const char *calling, const char *called, const char *token, unsigned int *timelimit)
OSP Authentication function.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:85
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
const char * ast_channel_exten(const struct ast_channel *chan)
#define OSP_AST_ERROR
#define OSP_SIZE_INTSTR
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@249 entries
#define OSP_DEF_TIMELIMIT
#define OSP_DEF_PROVIDER
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_OSP_ERROR
static struct test_options options
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
jack_status_t status
Definition: app_jack.c:146
#define OSP_AST_OK
#define AST_APP_ARG(name)
Define an application argument.

◆ ospfinished_exec()

static int ospfinished_exec ( struct ast_channel chan,
const char *  data 
)
static

OSP Application OSPFinish.

Parameters
chanChannel
dataParameter
Returns
OSP_AST_OK Success, OSP_AST_ERROR Error

Definition at line 2811 of file app_osplookup.c.

References args, AST_APP_ARG, AST_CAUSE_NO_ROUTE_DESTINATION, AST_CAUSE_NORMAL_CLEARING, ast_channel_answertime(), ast_channel_creationtime(), ast_channel_varshead(), ast_check_hangup(), ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, AST_LIST_TRAVERSE, AST_OSP_ERROR, AST_OSP_FAILED, AST_OSP_SUCCESS, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_tvzero(), ast_var_name(), ast_var_value(), end, ast_var_t::entries, NULL, options, OSP_AST_ERROR, OSP_AST_OK, osp_finish(), OSP_INVALID_HANDLE, OSP_OK, OSP_SIZE_INTSTR, OSP_SIZE_QOSSTR, pbx_builtin_setvar_helper(), status, and tmp().

Referenced by load_module().

2814 {
2815  int res = OSP_OK;
2816  int cause = 0;
2817  struct varshead* headp;
2818  struct ast_var_t* current;
2819  int inhandle = OSP_INVALID_HANDLE;
2820  int outhandle = OSP_INVALID_HANDLE;
2821  int recorded = 0;
2822  time_t start = 0, connect = 0, end = 0;
2823  unsigned int release;
2824  char buffer[OSP_SIZE_INTSTR];
2825  char inqos[OSP_SIZE_QOSSTR] = { 0 };
2826  char outqos[OSP_SIZE_QOSSTR] = { 0 };
2827  const char* status;
2828  char* tmp;
2829 
2831  AST_APP_ARG(cause);
2833  );
2834 
2835  tmp = ast_strdupa(data);
2836 
2838 
2839  headp = ast_channel_varshead(chan);
2840  AST_LIST_TRAVERSE(headp, current, entries) {
2841  if (!strcmp(ast_var_name(current), "OSPINHANDLE")) {
2842  if (sscanf(ast_var_value(current), "%30d", &inhandle) != 1) {
2843  inhandle = OSP_INVALID_HANDLE;
2844  }
2845  } else if (!strcmp(ast_var_name(current), "OSPOUTHANDLE")) {
2846  if (sscanf(ast_var_value(current), "%30d", &outhandle) != 1) {
2847  outhandle = OSP_INVALID_HANDLE;
2848  }
2849  } else if (!recorded &&
2850  (!strcmp(ast_var_name(current), "OSPAUTHSTATUS") ||
2851  !strcmp(ast_var_name(current), "OSPLOOKUPSTATUS") ||
2852  !strcmp(ast_var_name(current), "OSPNEXTSTATUS")))
2853  {
2854  if (strcmp(ast_var_value(current), AST_OSP_SUCCESS)) {
2855  recorded = 1;
2856  }
2857  } else if (!strcmp(ast_var_name(current), "OSPINAUDIOQOS")) {
2858  ast_copy_string(inqos, ast_var_value(current), sizeof(inqos));
2859  } else if (!strcmp(ast_var_name(current), "OSPOUTAUDIOQOS")) {
2860  ast_copy_string(outqos, ast_var_value(current), sizeof(outqos));
2861  }
2862  }
2863  ast_debug(1, "OSPFinish: OSPINHANDLE '%d'\n", inhandle);
2864  ast_debug(1, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
2865  ast_debug(1, "OSPFinish: recorded '%d'\n", recorded);
2866  ast_debug(1, "OSPFinish: OSPINAUDIOQOS '%s'\n", inqos);
2867  ast_debug(1, "OSPFinish: OSPOUTAUDIOQOS '%s'\n", outqos);
2868 
2869  if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%30d", &cause) != 1) {
2870  cause = 0;
2871  }
2872  ast_debug(1, "OSPFinish: cause '%d'\n", cause);
2873 
2874  if (!ast_tvzero(ast_channel_creationtime(chan))) {
2875  start = ast_channel_creationtime(chan).tv_sec;
2876  }
2877  if (!ast_tvzero(ast_channel_answertime(chan))) {
2878  connect = ast_channel_answertime(chan).tv_sec;
2879  }
2880  if (connect) {
2881  end = time(NULL);
2882  } else {
2883  end = connect;
2884  }
2885 
2886  ast_debug(1, "OSPFinish: start '%ld'\n", start);
2887  ast_debug(1, "OSPFinish: connect '%ld'\n", connect);
2888  ast_debug(1, "OSPFinish: end '%ld'\n", end);
2889 
2890  release = ast_check_hangup(chan) ? 0 : 1;
2891 
2892  if (osp_finish(outhandle, recorded, cause, start, connect, end, release, inqos, outqos) <= 0) {
2893  ast_debug(1, "OSPFinish: Unable to report usage for outbound call\n");
2894  }
2895  switch (cause) {
2897  break;
2898  default:
2900  break;
2901  }
2902  if (osp_finish(inhandle, recorded, cause, start, connect, end, release, inqos, outqos) <= 0) {
2903  ast_debug(1, "OSPFinish: Unable to report usage for inbound call\n");
2904  }
2905  snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE);
2906  pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
2907  pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
2908 
2909  if (res > 0) {
2910  status = AST_OSP_SUCCESS;
2911  } else if (!res) {
2912  status = AST_OSP_FAILED;
2913  } else {
2914  status = AST_OSP_ERROR;
2915  }
2916  pbx_builtin_setvar_helper(chan, "OSPFINISHSTATUS", status);
2917 
2918  if(res != OSP_OK) {
2919  res = OSP_AST_ERROR;
2920  } else {
2921  res = OSP_AST_OK;
2922  }
2923 
2924  return res;
2925 }
#define AST_OSP_FAILED
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:80
#define OSP_SIZE_QOSSTR
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:60
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
struct timeval ast_channel_answertime(struct ast_channel *chan)
static int tmp()
Definition: bt_open.c:389
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
#define OSP_OK
#define AST_OSP_SUCCESS
struct varshead * ast_channel_varshead(struct ast_channel *chan)
const char * args
#define NULL
Definition: resample.c:96
char * end
Definition: eagi_proxy.c:73
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define OSP_AST_ERROR
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
#define OSP_SIZE_INTSTR
struct timeval ast_channel_creationtime(struct ast_channel *chan)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_var_t::@249 entries
#define OSP_INVALID_HANDLE
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_CAUSE_NO_ROUTE_DESTINATION
Definition: causes.h:99
#define AST_OSP_ERROR
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct test_options options
static int osp_finish(int trans, int recorded, int cause, time_t start, time_t connect, time_t end, unsigned int release, const char *inqos, const char *outqos)
OSP Finish function.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
jack_status_t status
Definition: app_jack.c:146
#define OSP_AST_OK
#define AST_APP_ARG(name)
Define an application argument.

◆ osplookup_exec()

static int osplookup_exec ( struct ast_channel chan,
const char *  data 
)
static

OSP Application OSPLookup.

Parameters
chanChannel
dataParameter
Returns
OSP_AST_OK Success, OSP_AST_ERROR Error

Definition at line 2337 of file app_osplookup.c.

References args, AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), ast_channel_caller(), ast_channel_varshead(), ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, AST_LIST_TRAVERSE, ast_log, AST_OSP_ERROR, AST_OSP_FAILED, AST_OSP_SUCCESS, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_true(), ast_var_name(), ast_var_value(), osp_callid::buf, osp_results::called, osp_results::calling, osp_npdata::cic, osp_results::dest, osp_headers::divhost, osp_headers::divuser, exten, osp_results::inhandle, osp_results::intech, osp_results::intimelimit, osp_callid::len, LOG_WARNING, osp_results::networkid, osp_results::npcic, osp_npdata::npdi, osp_results::npdi, osp_results::nprn, NULL, osp_results::numdests, osp_npdata::opname, osp_results::opname, options, OSP_AST_ERROR, OSP_AST_OK, OSP_CALLID_H323, OSP_CALLID_IAX, OSP_CALLID_SIP, OSP_CALLID_UNDEF, OSP_DEF_PROVIDER, OSP_DEF_TIMELIMIT, OSP_INVALID_HANDLE, osp_lookup(), OSP_MAX_CUSTOMINFO, OSP_OK, OSP_SIP_HEADER, OSP_SIZE_TOKSTR, OSP_TECH_H323, OSP_TECH_IAX, OSP_TECH_SIP, OSP_TECH_SKYPE, osp_uuid2str(), osp_results::outcallid, osp_results::outhandle, osp_results::outtech, osp_results::outtimelimit, osp_headers::paiuser, pbx_builtin_setvar_helper(), osp_headers::pciuser, provider, osp_npdata::rn, osp_headers::rpiduser, S_COR, status, tmp(), osp_results::token, and type.

Referenced by load_module().

2340 {
2341  int res;
2342  const char* provider = OSP_DEF_PROVIDER;
2343  unsigned int callidtypes = OSP_CALLID_UNDEF;
2344  struct varshead* headp;
2345  struct ast_var_t* current;
2346  const char* actualsrc = "";
2347  const char* srcdev = "";
2348  const char* snetid = "";
2349  struct osp_npdata np;
2350  OSPE_OPERATOR_NAME type;
2351  struct osp_headers headers;
2352  unsigned int i;
2353  const char* cinfo[OSP_MAX_CUSTOMINFO] = { NULL };
2354  char buffer[OSP_SIZE_TOKSTR + strlen(": ") + strlen(OSP_SIP_HEADER)];
2355  struct osp_results results;
2356  const char* status;
2357  char* tmp;
2358 
2360  AST_APP_ARG(exten);
2361  AST_APP_ARG(provider);
2363  );
2364 
2365  if (ast_strlen_zero(data)) {
2366  ast_log(LOG_WARNING, "OSPLookup: Arg required, OSPLookup(exten[,provider[,options]])\n");
2367  return OSP_AST_ERROR;
2368  }
2369 
2370  tmp = ast_strdupa(data);
2371 
2373 
2374  ast_debug(1, "OSPLookup: exten '%s'\n", args.exten);
2375 
2376  if (!ast_strlen_zero(args.provider)) {
2377  provider = args.provider;
2378  }
2379  ast_debug(1, "OSPlookup: provider '%s'\n", provider);
2380 
2381  if (args.options) {
2382  if (strchr(args.options, 'h')) {
2383  callidtypes |= OSP_CALLID_H323;
2384  }
2385  if (strchr(args.options, 's')) {
2386  callidtypes |= OSP_CALLID_SIP;
2387  }
2388  if (strchr(args.options, 'i')) {
2389  callidtypes |= OSP_CALLID_IAX;
2390  }
2391  }
2392  ast_debug(1, "OSPLookup: call id types '%d'\n", callidtypes);
2393 
2394  results.inhandle = OSP_INVALID_HANDLE;
2395  results.intimelimit = OSP_DEF_TIMELIMIT;
2396  results.dest[0] = '\0';
2397 
2398  np.rn = "";
2399  np.cic = "";
2400  np.npdi = 0;
2401  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2402  np.opname[type] = "";
2403  }
2404 
2405  headers.rpiduser = "";
2406  headers.paiuser = "";
2407  headers.divuser = "";
2408  headers.divhost = "";
2409  headers.pciuser = "";
2410 
2411  headp = ast_channel_varshead(chan);
2412  AST_LIST_TRAVERSE(headp, current, entries) {
2413  if (!strcmp(ast_var_name(current), "OSPINACTUALSRC")) {
2414  actualsrc = ast_var_value(current);
2415  } else if (!strcmp(ast_var_name(current), "OSPINPEERIP")) {
2416  srcdev = ast_var_value(current);
2417  } else if (!strcmp(ast_var_name(current), "OSPINTECH")) {
2418  ast_copy_string(results.intech, ast_var_value(current), sizeof(results.intech));
2419  } else if (!strcmp(ast_var_name(current), "OSPINHANDLE")) {
2420  if (sscanf(ast_var_value(current), "%30d", &results.inhandle) != 1) {
2421  results.inhandle = OSP_INVALID_HANDLE;
2422  }
2423  } else if (!strcmp(ast_var_name(current), "OSPINTIMELIMIT")) {
2424  if (sscanf(ast_var_value(current), "%30d", &results.intimelimit) != 1) {
2425  results.intimelimit = OSP_DEF_TIMELIMIT;
2426  }
2427  } else if (!strcmp(ast_var_name(current), "OSPINNETWORKID")) {
2428  snetid = ast_var_value(current);
2429  } else if (!strcmp(ast_var_name(current), "OSPINNPRN")) {
2430  np.rn = ast_var_value(current);
2431  } else if (!strcmp(ast_var_name(current), "OSPINNPCIC")) {
2432  np.cic = ast_var_value(current);
2433  } else if (!strcmp(ast_var_name(current), "OSPINNPDI")) {
2434  if (ast_true(ast_var_value(current))) {
2435  np.npdi = 1;
2436  }
2437  } else if (!strcmp(ast_var_name(current), "OSPINSPID")) {
2438  np.opname[OSPC_OPNAME_SPID] = ast_var_value(current);
2439  } else if (!strcmp(ast_var_name(current), "OSPINOCN")) {
2440  np.opname[OSPC_OPNAME_OCN] = ast_var_value(current);
2441  } else if (!strcmp(ast_var_name(current), "OSPINSPN")) {
2442  np.opname[OSPC_OPNAME_SPN] = ast_var_value(current);
2443  } else if (!strcmp(ast_var_name(current), "OSPINALTSPN")) {
2444  np.opname[OSPC_OPNAME_ALTSPN] = ast_var_value(current);
2445  } else if (!strcmp(ast_var_name(current), "OSPINMCC")) {
2446  np.opname[OSPC_OPNAME_MCC] = ast_var_value(current);
2447  } else if (!strcmp(ast_var_name(current), "OSPINMNC")) {
2448  np.opname[OSPC_OPNAME_MNC] = ast_var_value(current);
2449  } else if (!strcmp(ast_var_name(current), "OSPINTOHOST")) {
2450  ast_copy_string(results.dest, ast_var_value(current), sizeof(results.dest));
2451  } else if (!strcmp(ast_var_name(current), "OSPINRPIDUSER")) {
2452  headers.rpiduser = ast_var_value(current);
2453  } else if (!strcmp(ast_var_name(current), "OSPINPAIUSER")) {
2454  headers.paiuser = ast_var_value(current);
2455  } else if (!strcmp(ast_var_name(current), "OSPINDIVUSER")) {
2456  headers.divuser = ast_var_value(current);
2457  } else if (!strcmp(ast_var_name(current), "OSPINDIVHOST")) {
2458  headers.divhost = ast_var_value(current);
2459  } else if (!strcmp(ast_var_name(current), "OSPINPCIUSER")) {
2460  headers.pciuser = ast_var_value(current);
2461  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO1")) {
2462  cinfo[0] = ast_var_value(current);
2463  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO2")) {
2464  cinfo[1] = ast_var_value(current);
2465  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO3")) {
2466  cinfo[2] = ast_var_value(current);
2467  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO4")) {
2468  cinfo[3] = ast_var_value(current);
2469  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO5")) {
2470  cinfo[4] = ast_var_value(current);
2471  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO6")) {
2472  cinfo[5] = ast_var_value(current);
2473  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO7")) {
2474  cinfo[6] = ast_var_value(current);
2475  } else if (!strcmp(ast_var_name(current), "OSPINCUSTOMINFO8")) {
2476  cinfo[7] = ast_var_value(current);
2477  }
2478  }
2479  ast_debug(1, "OSPLookup: actual source device '%s'\n", actualsrc);
2480  ast_debug(1, "OSPLookup: source device '%s'\n", srcdev);
2481  ast_debug(1, "OSPLookup: OSPINTECH '%s'\n", results.intech);
2482  ast_debug(1, "OSPLookup: OSPINHANDLE '%d'\n", results.inhandle);
2483  ast_debug(1, "OSPLookup: OSPINTIMELIMIT '%d'\n", results.intimelimit);
2484  ast_debug(1, "OSPLookup: OSPINNETWORKID '%s'\n", snetid);
2485  ast_debug(1, "OSPLookup: OSPINNPRN '%s'\n", np.rn);
2486  ast_debug(1, "OSPLookup: OSPINNPCIC '%s'\n", np.cic);
2487  ast_debug(1, "OSPLookup: OSPINNPDI '%d'\n", np.npdi);
2488  ast_debug(1, "OSPLookup: OSPINSPID '%s'\n", np.opname[OSPC_OPNAME_SPID]);
2489  ast_debug(1, "OSPLookup: OSPINOCN '%s'\n", np.opname[OSPC_OPNAME_OCN]);
2490  ast_debug(1, "OSPLookup: OSPINSPN '%s'\n", np.opname[OSPC_OPNAME_SPN]);
2491  ast_debug(1, "OSPLookup: OSPINALTSPN '%s'\n", np.opname[OSPC_OPNAME_ALTSPN]);
2492  ast_debug(1, "OSPLookup: OSPINMCC '%s'\n", np.opname[OSPC_OPNAME_MCC]);
2493  ast_debug(1, "OSPLookup: OSPINMNC '%s'\n", np.opname[OSPC_OPNAME_MNC]);
2494  ast_debug(1, "OSPLookup: OSPINTOHOST '%s'\n", results.dest);
2495  ast_debug(1, "OSPLookup: OSPINRPIDUSER '%s'\n", headers.rpiduser);
2496  ast_debug(1, "OSPLookup: OSPINPAIUSER '%s'\n", headers.paiuser);
2497  ast_debug(1, "OSPLookup: OSPINDIVUSER '%s'\n", headers.divuser);
2498  ast_debug(1, "OSPLookup: OSPINDIVHOST'%s'\n", headers.divhost);
2499  ast_debug(1, "OSPLookup: OSPINPCIUSER '%s'\n", headers.pciuser);
2500  for (i = 0; i < OSP_MAX_CUSTOMINFO; i++) {
2501  if (!ast_strlen_zero(cinfo[i])) {
2502  ast_debug(1, "OSPLookup: OSPINCUSTOMINFO%d '%s'\n", i, cinfo[i]);
2503  }
2504  }
2505 
2506  if (ast_autoservice_start(chan) < 0) {
2507  return OSP_AST_ERROR;
2508  }
2509 
2510  res = osp_lookup(provider, callidtypes, actualsrc, srcdev,
2511  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL),
2512  args.exten, snetid, &np, &headers, cinfo, &results);
2513  if (res > 0) {
2514  status = AST_OSP_SUCCESS;
2515  } else {
2516  results.outtech[0] = '\0';
2517  results.dest[0] = '\0';
2518  results.calling[0] = '\0';
2519  results.called[0] = '\0';
2520  results.token[0] = '\0';
2521  results.networkid[0] = '\0';
2522  results.nprn[0] = '\0';
2523  results.npcic[0] = '\0';
2524  results.npdi = 0;
2525  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2526  results.opname[type][0] = '\0';
2527  }
2528  results.numdests = 0;
2529  results.outtimelimit = OSP_DEF_TIMELIMIT;
2530  results.outcallid.buf[0] = '\0';
2531  results.outcallid.len = 0;
2532  if (!res) {
2533  status = AST_OSP_FAILED;
2534  } else {
2535  status = AST_OSP_ERROR;
2536  }
2537  }
2538 
2539  snprintf(buffer, sizeof(buffer), "%d", results.outhandle);
2540  pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
2541  ast_debug(1, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
2542  pbx_builtin_setvar_helper(chan, "OSPOUTTECH", results.outtech);
2543  ast_debug(1, "OSPLookup: OSPOUTTECH '%s'\n", results.outtech);
2544  pbx_builtin_setvar_helper(chan, "OSPDESTINATION", results.dest);
2545  ast_debug(1, "OSPLookup: OSPDESTINATION '%s'\n", results.dest);
2546  pbx_builtin_setvar_helper(chan, "OSPOUTCALLING", results.calling);
2547  ast_debug(1, "OSPLookup: OSPOUTCALLING '%s'\n", results.calling);
2548  pbx_builtin_setvar_helper(chan, "OSPOUTCALLED", results.called);
2549  ast_debug(1, "OSPLookup: OSPOUTCALLED '%s'\n", results.called);
2550  pbx_builtin_setvar_helper(chan, "OSPOUTNETWORKID", results.networkid);
2551  ast_debug(1, "OSPLookup: OSPOUTNETWORKID '%s'\n", results.networkid);
2552  pbx_builtin_setvar_helper(chan, "OSPOUTNPRN", results.nprn);
2553  ast_debug(1, "OSPLookup: OSPOUTNPRN '%s'\n", results.nprn);
2554  pbx_builtin_setvar_helper(chan, "OSPOUTNPCIC", results.npcic);
2555  ast_debug(1, "OSPLookup: OSPOUTNPCIC '%s'\n", results.npcic);
2556  snprintf(buffer, sizeof(buffer), "%d", results.npdi);
2557  pbx_builtin_setvar_helper(chan, "OSPOUTNPDI", buffer);
2558  ast_debug(1, "OSPLookup: OSPOUTNPDI'%s'\n", buffer);
2559  pbx_builtin_setvar_helper(chan, "OSPOUTSPID", results.opname[OSPC_OPNAME_SPID]);
2560  ast_debug(1, "OSPLookup: OSPOUTSPID '%s'\n", results.opname[OSPC_OPNAME_SPID]);
2561  pbx_builtin_setvar_helper(chan, "OSPOUTOCN", results.opname[OSPC_OPNAME_OCN]);
2562  ast_debug(1, "OSPLookup: OSPOUTOCN '%s'\n", results.opname[OSPC_OPNAME_OCN]);
2563  pbx_builtin_setvar_helper(chan, "OSPOUTSPN", results.opname[OSPC_OPNAME_SPN]);
2564  ast_debug(1, "OSPLookup: OSPOUTSPN '%s'\n", results.opname[OSPC_OPNAME_SPN]);
2565  pbx_builtin_setvar_helper(chan, "OSPOUTALTSPN", results.opname[OSPC_OPNAME_ALTSPN]);
2566  ast_debug(1, "OSPLookup: OSPOUTALTSPN '%s'\n", results.opname[OSPC_OPNAME_ALTSPN]);
2567  pbx_builtin_setvar_helper(chan, "OSPOUTMCC", results.opname[OSPC_OPNAME_MCC]);
2568  ast_debug(1, "OSPLookup: OSPOUTMCC '%s'\n", results.opname[OSPC_OPNAME_MCC]);
2569  pbx_builtin_setvar_helper(chan, "OSPOUTMNC", results.opname[OSPC_OPNAME_MNC]);
2570  ast_debug(1, "OSPLookup: OSPOUTMNC '%s'\n", results.opname[OSPC_OPNAME_MNC]);
2571  pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", results.token);
2572  ast_debug(1, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(results.token));
2573  snprintf(buffer, sizeof(buffer), "%d", results.numdests);
2574  pbx_builtin_setvar_helper(chan, "OSPDESTREMAILS", buffer);
2575  ast_debug(1, "OSPLookup: OSPDESTREMAILS '%s'\n", buffer);
2576  snprintf(buffer, sizeof(buffer), "%d", results.outtimelimit);
2577  pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
2578  ast_debug(1, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
2579  snprintf(buffer, sizeof(buffer), "%d", callidtypes);
2580  pbx_builtin_setvar_helper(chan, "OSPOUTCALLIDTYPES", buffer);
2581  ast_debug(1, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
2582  pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status);
2583  ast_debug(1, "OSPLookup: %s\n", status);
2584 
2585  if (!strcasecmp(results.outtech, OSP_TECH_SIP)) {
2586  snprintf(buffer, sizeof(buffer), "%s/%s@%s", results.outtech, results.called, results.dest);
2587  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2588  if (!ast_strlen_zero(results.token)) {
2589  snprintf(buffer, sizeof(buffer), "%s: %s", OSP_SIP_HEADER, results.token);
2590  pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
2591  ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
2592  }
2593  } else if (!strcasecmp(results.outtech, OSP_TECH_H323)) {
2594  if ((callidtypes & OSP_CALLID_H323) && (results.outcallid.len != 0)) {
2595  osp_uuid2str(results.outcallid.buf, buffer, sizeof(buffer));
2596  } else {
2597  buffer[0] = '\0';
2598  }
2599  pbx_builtin_setvar_helper(chan, "OSPOUTCALLID", buffer);
2600  snprintf(buffer, sizeof(buffer), "%s/%s@%s", results.outtech, results.called, results.dest);
2601  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2602  } else if (!strcasecmp(results.outtech, OSP_TECH_IAX)) {
2603  snprintf(buffer, sizeof(buffer), "%s/%s/%s", results.outtech, results.dest, results.called);
2604  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2605  } else if (!strcasecmp(results.outtech, OSP_TECH_SKYPE)) {
2606  snprintf(buffer, sizeof(buffer), "%s/%s", results.outtech, results.called);
2607  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2608  }
2609 
2610  if (ast_autoservice_stop(chan) < 0) {
2611  return OSP_AST_ERROR;
2612  }
2613 
2614  if(res != OSP_OK) {
2615  res = OSP_AST_ERROR;
2616  } else {
2617  res = OSP_AST_OK;
2618  }
2619 
2620  return res;
2621 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
static const char type[]
Definition: chan_ooh323.c:109
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define OSP_TECH_SIP
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
#define AST_OSP_FAILED
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:80
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:60
#define OSP_TECH_H323
static int osp_lookup(const char *name, unsigned int callidtypes, const char *actualsrc, const char *srcdev, const char *calling, const char *called, const char *snetid, struct osp_npdata *np, struct osp_headers *headers, const char *cinfo[], struct osp_results *results)
OSP Lookup function.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
#define OSP_SIZE_TOKSTR
#define OSP_OK
#define OSP_TECH_SKYPE
#define AST_OSP_SUCCESS
#define OSP_CALLID_H323
struct varshead * ast_channel_varshead(struct ast_channel *chan)
const char * args
#define NULL
Definition: resample.c:96
static int osp_uuid2str(unsigned char *uuid, char *buffer, unsigned int bufsize)
UUID to string.
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define OSP_CALLID_SIP
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:85
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define OSP_CALLID_IAX
#define OSP_AST_ERROR
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
#define OSP_TECH_IAX
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define OSP_SIP_HEADER
#define OSP_DEF_TIMELIMIT
#define OSP_INVALID_HANDLE
#define OSP_DEF_PROVIDER
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define OSP_MAX_CUSTOMINFO
#define AST_OSP_ERROR
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OSP_CALLID_UNDEF
static struct test_options options
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
jack_status_t status
Definition: app_jack.c:146
#define OSP_AST_OK
#define AST_APP_ARG(name)
Define an application argument.

◆ ospnext_exec()

static int ospnext_exec ( struct ast_channel chan,
const char *  data 
)
static

OSP Application OSPNext.

Parameters
chanChannel
dataParameter
Returns
OSP_AST_OK Success, OSP_AST_ERROR Error

Definition at line 2629 of file app_osplookup.c.

References args, AST_APP_ARG, ast_channel_varshead(), ast_debug, AST_DECLARE_APP_ARGS, AST_LIST_TRAVERSE, ast_log, AST_OSP_ERROR, AST_OSP_FAILED, AST_OSP_SUCCESS, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_var_name(), ast_var_value(), osp_callid::buf, osp_results::called, osp_results::calling, osp_results::dest, osp_results::inhandle, osp_results::intimelimit, osp_callid::len, LOG_WARNING, osp_results::networkid, osp_results::npcic, osp_results::npdi, osp_results::nprn, osp_results::numdests, osp_results::opname, options, OSP_AST_ERROR, OSP_AST_OK, OSP_CALLID_H323, OSP_CALLID_UNDEF, OSP_DEF_PROVIDER, OSP_DEF_TIMELIMIT, OSP_INVALID_HANDLE, osp_next(), OSP_OK, OSP_SIP_HEADER, OSP_SIZE_TOKSTR, OSP_TECH_H323, OSP_TECH_IAX, OSP_TECH_SIP, OSP_TECH_SKYPE, osp_uuid2str(), osp_results::outcallid, osp_results::outhandle, osp_results::outtech, osp_results::outtimelimit, pbx_builtin_setvar_helper(), provider, status, tmp(), osp_results::token, and type.

Referenced by load_module().

2632 {
2633  int res;
2634  const char* provider = OSP_DEF_PROVIDER;
2635  int cause = 0;
2636  struct varshead* headp;
2637  struct ast_var_t* current;
2638  struct osp_results results;
2639  OSPE_OPERATOR_NAME type;
2640  char buffer[OSP_SIZE_TOKSTR + strlen(": ") + strlen(OSP_SIP_HEADER)];
2641  unsigned int callidtypes = OSP_CALLID_UNDEF;
2642  const char* status;
2643  char* tmp;
2644 
2646  AST_APP_ARG(cause);
2647  AST_APP_ARG(provider);
2649  );
2650 
2651  if (ast_strlen_zero(data)) {
2652  ast_log(LOG_WARNING, "OSPNext: Arg required, OSPNext(cause[,provider[,options]])\n");
2653  return OSP_AST_ERROR;
2654  }
2655 
2656  tmp = ast_strdupa(data);
2657 
2659 
2660  if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%30d", &cause) != 1) {
2661  cause = 0;
2662  }
2663  ast_debug(1, "OSPNext: cause '%d'\n", cause);
2664 
2665  if (!ast_strlen_zero(args.provider)) {
2666  provider = args.provider;
2667  }
2668  ast_debug(1, "OSPlookup: provider '%s'\n", provider);
2669 
2670  results.inhandle = OSP_INVALID_HANDLE;
2671  results.outhandle = OSP_INVALID_HANDLE;
2672  results.intimelimit = OSP_DEF_TIMELIMIT;
2673  results.numdests = 0;
2674 
2675  headp = ast_channel_varshead(chan);
2676  AST_LIST_TRAVERSE(headp, current, entries) {
2677  if (!strcmp(ast_var_name(current), "OSPINHANDLE")) {
2678  if (sscanf(ast_var_value(current), "%30d", &results.inhandle) != 1) {
2679  results.inhandle = OSP_INVALID_HANDLE;
2680  }
2681  } else if (!strcmp(ast_var_name(current), "OSPOUTHANDLE")) {
2682  if (sscanf(ast_var_value(current), "%30d", &results.outhandle) != 1) {
2683  results.outhandle = OSP_INVALID_HANDLE;
2684  }
2685  } else if (!strcmp(ast_var_name(current), "OSPINTIMELIMIT")) {
2686  if (sscanf(ast_var_value(current), "%30d", &results.intimelimit) != 1) {
2687  results.intimelimit = OSP_DEF_TIMELIMIT;
2688  }
2689  } else if (!strcmp(ast_var_name(current), "OSPOUTCALLIDTYPES")) {
2690  if (sscanf(ast_var_value(current), "%30d", &callidtypes) != 1) {
2691  callidtypes = OSP_CALLID_UNDEF;
2692  }
2693  } else if (!strcmp(ast_var_name(current), "OSPDESTREMAILS")) {
2694  if (sscanf(ast_var_value(current), "%30d", &results.numdests) != 1) {
2695  results.numdests = 0;
2696  }
2697  }
2698  }
2699  ast_debug(1, "OSPNext: OSPINHANDLE '%d'\n", results.inhandle);
2700  ast_debug(1, "OSPNext: OSPOUTHANDLE '%d'\n", results.outhandle);
2701  ast_debug(1, "OSPNext: OSPINTIMELIMIT '%d'\n", results.intimelimit);
2702  ast_debug(1, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
2703  ast_debug(1, "OSPNext: OSPDESTREMAILS '%d'\n", results.numdests);
2704 
2705  if ((res = osp_next(provider, cause, &results)) > 0) {
2706  status = AST_OSP_SUCCESS;
2707  } else {
2708  results.outtech[0] = '\0';
2709  results.dest[0] = '\0';
2710  results.calling[0] = '\0';
2711  results.called[0] = '\0';
2712  results.token[0] = '\0';
2713  results.networkid[0] = '\0';
2714  results.nprn[0] = '\0';
2715  results.npcic[0] = '\0';
2716  results.npdi = 0;
2717  for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2718  results.opname[type][0] = '\0';
2719  }
2720  results.numdests = 0;
2721  results.outtimelimit = OSP_DEF_TIMELIMIT;
2722  results.outcallid.buf[0] = '\0';
2723  results.outcallid.len = 0;
2724  if (!res) {
2725  status = AST_OSP_FAILED;
2726  } else {
2727  status = AST_OSP_ERROR;
2728  }
2729  }
2730 
2731  pbx_builtin_setvar_helper(chan, "OSPOUTTECH", results.outtech);
2732  ast_debug(1, "OSPNext: OSPOUTTECH '%s'\n", results.outtech);
2733  pbx_builtin_setvar_helper(chan, "OSPDESTINATION", results.dest);
2734  ast_debug(1, "OSPNext: OSPDESTINATION '%s'\n", results.dest);
2735  pbx_builtin_setvar_helper(chan, "OSPOUTCALLING", results.calling);
2736  ast_debug(1, "OSPNext: OSPOUTCALLING '%s'\n", results.calling);
2737  pbx_builtin_setvar_helper(chan, "OSPOUTCALLED", results.called);
2738  ast_debug(1, "OSPNext: OSPOUTCALLED'%s'\n", results.called);
2739  pbx_builtin_setvar_helper(chan, "OSPOUTNETWORKID", results.networkid);
2740  ast_debug(1, "OSPLookup: OSPOUTNETWORKID '%s'\n", results.networkid);
2741  pbx_builtin_setvar_helper(chan, "OSPOUTNPRN", results.nprn);
2742  ast_debug(1, "OSPLookup: OSPOUTNPRN '%s'\n", results.nprn);
2743  pbx_builtin_setvar_helper(chan, "OSPOUTNPCIC", results.npcic);
2744  ast_debug(1, "OSPLookup: OSPOUTNPCIC '%s'\n", results.npcic);
2745  snprintf(buffer, sizeof(buffer), "%d", results.npdi);
2746  pbx_builtin_setvar_helper(chan, "OSPOUTNPDI", buffer);
2747  ast_debug(1, "OSPLookup: OSPOUTNPDI'%s'\n", buffer);
2748  pbx_builtin_setvar_helper(chan, "OSPOUTSPID", results.opname[OSPC_OPNAME_SPID]);
2749  ast_debug(1, "OSPLookup: OSPOUTSPID '%s'\n", results.opname[OSPC_OPNAME_SPID]);
2750  pbx_builtin_setvar_helper(chan, "OSPOUTOCN", results.opname[OSPC_OPNAME_OCN]);
2751  ast_debug(1, "OSPLookup: OSPOUTOCN '%s'\n", results.opname[OSPC_OPNAME_OCN]);
2752  pbx_builtin_setvar_helper(chan, "OSPOUTSPN", results.opname[OSPC_OPNAME_SPN]);
2753  ast_debug(1, "OSPLookup: OSPOUTSPN '%s'\n", results.opname[OSPC_OPNAME_SPN]);
2754  pbx_builtin_setvar_helper(chan, "OSPOUTALTSPN", results.opname[OSPC_OPNAME_ALTSPN]);
2755  ast_debug(1, "OSPLookup: OSPOUTALTSPN '%s'\n", results.opname[OSPC_OPNAME_ALTSPN]);
2756  pbx_builtin_setvar_helper(chan, "OSPOUTMCC", results.opname[OSPC_OPNAME_MCC]);
2757  ast_debug(1, "OSPLookup: OSPOUTMCC '%s'\n", results.opname[OSPC_OPNAME_MCC]);
2758  pbx_builtin_setvar_helper(chan, "OSPOUTMNC", results.opname[OSPC_OPNAME_MNC]);
2759  ast_debug(1, "OSPLookup: OSPOUTMNC '%s'\n", results.opname[OSPC_OPNAME_MNC]);
2760  pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", results.token);
2761  ast_debug(1, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(results.token));
2762  snprintf(buffer, sizeof(buffer), "%d", results.numdests);
2763  pbx_builtin_setvar_helper(chan, "OSPDESTREMAILS", buffer);
2764  ast_debug(1, "OSPNext: OSPDESTREMAILS '%s'\n", buffer);
2765  snprintf(buffer, sizeof(buffer), "%d", results.outtimelimit);
2766  pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
2767  ast_debug(1, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
2768  pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status);
2769  ast_debug(1, "OSPNext: %s\n", status);
2770 
2771  if (!strcasecmp(results.outtech, OSP_TECH_SIP)) {
2772  snprintf(buffer, sizeof(buffer), "%s/%s@%s", results.outtech, results.called, results.dest);
2773  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2774  if (!ast_strlen_zero(results.token)) {
2775  snprintf(buffer, sizeof(buffer), "%s: %s", OSP_SIP_HEADER, results.token);
2776  pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
2777  ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
2778  }
2779  } else if (!strcasecmp(results.outtech, OSP_TECH_H323)) {
2780  if ((callidtypes & OSP_CALLID_H323) && (results.outcallid.len != 0)) {
2781  osp_uuid2str(results.outcallid.buf, buffer, sizeof(buffer));
2782  } else {
2783  buffer[0] = '\0';
2784  }
2785  pbx_builtin_setvar_helper(chan, "OSPOUTCALLID", buffer);
2786  snprintf(buffer, sizeof(buffer), "%s/%s@%s", results.outtech, results.called, results.dest);
2787  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2788  } else if (!strcasecmp(results.outtech, OSP_TECH_IAX)) {
2789  snprintf(buffer, sizeof(buffer), "%s/%s/%s", results.outtech, results.dest, results.called);
2790  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2791  } else if (!strcasecmp(results.outtech, OSP_TECH_SKYPE)) {
2792  snprintf(buffer, sizeof(buffer), "%s/%s", results.outtech, results.called);
2793  pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
2794  }
2795 
2796  if(res != OSP_OK) {
2797  res = OSP_AST_ERROR;
2798  } else {
2799  res = OSP_AST_OK;
2800  }
2801 
2802  return res;
2803 }
static const char type[]
Definition: chan_ooh323.c:109
#define OSP_TECH_SIP
static int osp_next(const char *name, int cause, struct osp_results *results)
OSP Lookup Next function.
#define AST_OSP_FAILED
const char * ast_var_value(const struct ast_var_t *var)
Definition: chanvars.c:80
const char * ast_var_name(const struct ast_var_t *var)
Definition: chanvars.c:60
#define OSP_TECH_H323
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
#define OSP_SIZE_TOKSTR
#define OSP_OK
#define OSP_TECH_SKYPE
#define AST_OSP_SUCCESS
#define OSP_CALLID_H323
struct varshead * ast_channel_varshead(struct ast_channel *chan)
const char * args
static int osp_uuid2str(unsigned char *uuid, char *buffer, unsigned int bufsize)
UUID to string.
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define OSP_AST_ERROR
#define OSP_TECH_IAX
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define OSP_SIP_HEADER
#define OSP_DEF_TIMELIMIT
#define OSP_INVALID_HANDLE
#define OSP_DEF_PROVIDER
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_OSP_ERROR
#define OSP_CALLID_UNDEF
static struct test_options options
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
jack_status_t status
Definition: app_jack.c:146
#define OSP_AST_OK
#define AST_APP_ARG(name)
Define an application argument.

◆ reload()

static int reload ( void  )
static

Definition at line 3158 of file app_osplookup.c.

References AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_SUPPORT_EXTENDED, ASTERISK_GPL_KEY, load_module(), osp_load(), and unload_module().

3159 {
3160  osp_load(1);
3161 
3162  return 0;
3163 }
static int osp_load(int reload)

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 3144 of file app_osplookup.c.

References app1, app2, app3, app4, ast_cli_unregister_multiple(), ast_unregister_application(), and osp_unload().

Referenced by reload().

3145 {
3146  int res;
3147 
3152  ast_cli_unregister_multiple(cli_osp, sizeof(cli_osp) / sizeof(struct ast_cli_entry));
3153  osp_unload();
3154 
3155  return res;
3156 }
static int osp_unload(void)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
descriptor for a cli entry.
Definition: cli.h:171
static const char app1[]
static const char app3[]
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static const char app4[]
static struct ast_cli_entry cli_osp[]
static const char app2[]

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Open Settlement Protocol Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, }
static

Definition at line 3170 of file app_osplookup.c.

◆ app1

const char app1[] = "OSPAuth"
static

Definition at line 3113 of file app_osplookup.c.

Referenced by load_module(), and unload_module().

◆ app2

const char app2[] = "OSPLookup"
static

Definition at line 3116 of file app_osplookup.c.

Referenced by load_module(), and unload_module().

◆ app3

const char app3[] = "OSPNext"
static

Definition at line 3119 of file app_osplookup.c.

Referenced by load_module(), and unload_module().

◆ app4

const char app4[] = "OSPFinish"
static

Definition at line 3122 of file app_osplookup.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 3170 of file app_osplookup.c.

◆ B64CACert

const char* B64CACert = "MIIBYDCCAQoCAQEwDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTAyMDIwNDE4MjU1MloXDTEyMDIwMzE4MjU1MlowOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPGeGwV41EIhX0jEDFLRXQhDEr50OUQPq+f55VwQd0TQNts06BP29+UiNdRW3c3IRHdZcJdC1Cg68ME9cgeq0h8CAwEAATANBgkqhkiG9w0BAQQFAANBAGkzBSj1EnnmUxbaiG1N4xjIuLAWydun7o3bFk2tV8dBIhnuh445obYyk1EnQ27kI7eACCILBZqi2MHDOIMnoN0="

Definition at line 634 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ B64LCert

const char* B64LCert = "MIIBeTCCASMCEHqkOHVRRWr+1COq3CR/xsowDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTA1MDYyMzAwMjkxOFoXDTA2MDYyNDAwMjkxOFowRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCvLeZfj1G0wuJb8JTcVeZaZftncEmRluOnaME3ustd918lRMDYokZmtmDZN8SrP0yd1pfVqZ7NkmBACbBX0k7pAgMBAAEwDQYJKoZIhvcNAQEEBQADQQDnV8QNFVVJx/+7IselU0wsepqMurivXZzuxOmTEmTVDzCJx1xhA8jd3vGAj7XDIYiPub1PV23eY5a2ARJuw5w9"

Definition at line 633 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ B64PKey

const char* B64PKey = "MIIBOgIBAAJBAK8t5l+PUbTC4lvwlNxV5lpl+2dwSZGW46dowTe6y133XyVEwNiiRma2YNk3xKs/TJ3Wl9Wpns2SYEAJsFfSTukCAwEAAQJAPz13vCm2GmZ8Zyp74usTxLCqSJZNyMRLHQWBM0g44Iuy4wE3vpi7Wq+xYuSOH2mu4OddnxswCP4QhaXVQavTAQIhAOBVCKXtppEw9UaOBL4vW0Ed/6EA/1D8hDW6St0h7EXJAiEAx+iRmZKhJD6VT84dtX5ZYNVk3j3dAcIOovpzUj9a0CECIEduTCapmZQ5xqAEsLXuVlxRtQgLTUD4ZxDElPn8x0MhAiBE2HlcND0+qDbvtwJQQOUzDgqg5xk3w8capboVdzAlQQIhAMC+lDL7+gDYkNAft5Mu+NObJmQs4Cr+DkDFsKqoxqrm"

Definition at line 632 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ cli_osp

struct ast_cli_entry cli_osp[]
static
Initial value:
= {
{ .handler = handle_cli_osp_show , .summary = "Displays OSF information" ,}
}
static char * handle_cli_osp_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)

Definition at line 3124 of file app_osplookup.c.

◆ osp_hardware

int osp_hardware = 0
static

Definition at line 626 of file app_osplookup.c.

Referenced by handle_cli_osp_show(), osp_load(), and osp_unload().

◆ osp_initialized

int osp_initialized = 0
static

Definition at line 625 of file app_osplookup.c.

Referenced by handle_cli_osp_show(), osp_load(), and osp_unload().

◆ osp_lock

ast_mutex_t osp_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
static

◆ osp_providers

struct osp_provider* osp_providers = NULL
static

Definition at line 628 of file app_osplookup.c.

Referenced by osp_create_provider().

◆ osp_security

int osp_security = 0
static

Definition at line 627 of file app_osplookup.c.

Referenced by handle_cli_osp_show(), osp_create_provider(), osp_load(), and osp_unload().

◆ osp_tokenformat

unsigned int osp_tokenformat = TOKEN_ALGO_SIGNED
static

Definition at line 629 of file app_osplookup.c.

Referenced by handle_cli_osp_show(), osp_load(), osp_unload(), and osp_validate_token().