40 #include <osp/osputils.h> 41 #include <osp/ospb64.h> 439 #define AST_OSP_SUCCESS ((char*)"SUCCESS") 440 #define AST_OSP_FAILED ((char*)"FAILED") 441 #define AST_OSP_ERROR ((char*)"ERROR") 444 #define OSP_SIZE_INTSTR ((unsigned int)16) 445 #define OSP_SIZE_NORSTR ((unsigned int)256) 446 #define OSP_SIZE_KEYSTR ((unsigned int)1024) 447 #define OSP_SIZE_TOKSTR ((unsigned int)4096) 448 #define OSP_SIZE_TECHSTR ((unsigned int)32) 449 #define OSP_SIZE_UUID ((unsigned int)16) 450 #define OSP_SIZE_UUIDSTR ((unsigned int)36) 451 #define OSP_SIZE_QOSSTR ((unsigned int)1024) 452 #define OSP_SIZE_OUTSTR ((unsigned int)288) 455 #define OSP_CALLID_UNDEF ((unsigned int)0) 456 #define OSP_CALLID_SIP ((unsigned int)(1 << 0)) 457 #define OSP_CALLID_H323 ((unsigned int)(1 << 1)) 458 #define OSP_CALLID_IAX ((unsigned int)(1 << 2)) 459 #define OSP_CALLID_MAXNUM ((unsigned int)3) 462 #define OSP_PROT_SIP ((const char*)"SIP") 463 #define OSP_PROT_H323 ((const char*)"H323") 464 #define OSP_PROT_IAX ((const char*)"IAX") 465 #define OSP_PROT_SKYPE ((const char*)"SKYPE") 468 #define OSP_TECH_SIP ((const char*)"SIP") 469 #define OSP_TECH_H323 ((const char*)"H323") 470 #define OSP_TECH_IAX ((const char*)"IAX2") 471 #define OSP_TECH_SKYPE ((const char*)"SKYPE") 474 #define OSP_SIP_HEADER ((const char*)"P-OSP-Auth-Token") 496 #define OSP_OK ((int)1) 497 #define OSP_FAILED ((int)0) 498 #define OSP_ERROR ((int)-1) 499 #define OSP_AST_OK ((int)0) 500 #define OSP_AST_ERROR ((int)-1) 501 #define OSP_INVALID_HANDLE ((int)-1) 502 #define OSP_CONFIG_FILE ((const char*)"osp.conf") 503 #define OSP_GENERAL_CAT ((const char*)"general") 504 #define OSP_DEF_PROVIDER ((const char*)"default") 505 #define OSP_MAX_CERTS ((unsigned int)10) 506 #define OSP_MAX_SPOINTS ((unsigned int)10) 507 #define OSP_DEF_MAXCONNECT ((unsigned int)20) 508 #define OSP_MIN_MAXCONNECT ((unsigned int)1) 509 #define OSP_MAX_MAXCONNECT ((unsigned int)1000) 510 #define OSP_DEF_RETRYDELAY ((unsigned int)0) 511 #define OSP_MIN_RETRYDELAY ((unsigned int)0) 512 #define OSP_MAX_RETRYDELAY ((unsigned int)10) 513 #define OSP_DEF_RETRYLIMIT ((unsigned int)2) 514 #define OSP_MIN_RETRYLIMIT ((unsigned int)0) 515 #define OSP_MAX_RETRYLIMIT ((unsigned int)100) 516 #define OSP_DEF_TIMEOUT ((unsigned int)500) 517 #define OSP_MIN_TIMEOUT ((unsigned int)200) 518 #define OSP_MAX_TIMEOUT ((unsigned int)10000) 519 #define OSP_DEF_AUTHPOLICY OSP_AUTH_YES 520 #define OSP_AUDIT_URL ((const char*)"localhost") 521 #define OSP_LOCAL_VALIDATION ((int)1) 522 #define OSP_SSL_LIFETIME ((unsigned int)300) 523 #define OSP_HTTP_PERSISTENCE ((int)1) 524 #define OSP_CUSTOMER_ID ((const char*)"") 525 #define OSP_DEVICE_ID ((const char*)"") 526 #define OSP_DEF_MAXDESTS ((unsigned int)12) 527 #define OSP_DEF_TIMELIMIT ((unsigned int)0) 528 #define OSP_DEF_PROTOCOL OSP_PROT_SIP 529 #define OSP_DEF_WORKMODE OSP_MODE_DIRECT 530 #define OSP_DEF_SRVTYPE OSP_SRV_VOICE 531 #define OSP_MAX_CUSTOMINFO ((unsigned int)8) 532 #define OSP_DEF_INTSTATS ((int)-1) 533 #define OSP_DEF_FLOATSTATS ((float)-1) 568 const char* opname[OSPC_OPNAME_NUMBER];
632 const char*
B64PKey =
"MIIBOgIBAAJBAK8t5l+PUbTC4lvwlNxV5lpl+2dwSZGW46dowTe6y133XyVEwNiiRma2YNk3xKs/TJ3Wl9Wpns2SYEAJsFfSTukCAwEAAQJAPz13vCm2GmZ8Zyp74usTxLCqSJZNyMRLHQWBM0g44Iuy4wE3vpi7Wq+xYuSOH2mu4OddnxswCP4QhaXVQavTAQIhAOBVCKXtppEw9UaOBL4vW0Ed/6EA/1D8hDW6St0h7EXJAiEAx+iRmZKhJD6VT84dtX5ZYNVk3j3dAcIOovpzUj9a0CECIEduTCapmZQ5xqAEsLXuVlxRtQgLTUD4ZxDElPn8x0MhAiBE2HlcND0+qDbvtwJQQOUzDgqg5xk3w8capboVdzAlQQIhAMC+lDL7+gDYkNAft5Mu+NObJmQs4Cr+DkDFsKqoxqrm";
633 const char*
B64LCert =
"MIIBeTCCASMCEHqkOHVRRWr+1COq3CR/xsowDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTA1MDYyMzAwMjkxOFoXDTA2MDYyNDAwMjkxOFowRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCvLeZfj1G0wuJb8JTcVeZaZftncEmRluOnaME3ustd918lRMDYokZmtmDZN8SrP0yd1pfVqZ7NkmBACbBX0k7pAgMBAAEwDQYJKoZIhvcNAQEEBQADQQDnV8QNFVVJx/+7IselU0wsepqMurivXZzuxOmTEmTVDzCJx1xhA8jd3vGAj7XDIYiPub1PV23eY5a2ARJuw5w9";
634 const char*
B64CACert =
"MIIBYDCCAQoCAQEwDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTAyMDIwNDE4MjU1MloXDTEyMDIwMzE4MjU1MlowOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPGeGwV41EIhX0jEDFLRXQhDEr50OUQPq+f55VwQd0TQNts06BP29+UiNdRW3c3IRHdZcJdC1Cg68ME9cgeq0h8CAwEAATANBgkqhkiG9w0BAQQFAANBAGkzBSj1EnnmUxbaiG1N4xjIuLAWydun7o3bFk2tV8dBIhnuh445obYyk1EnQ27kI7eACCILBZqi2MHDOIMnoN0=";
659 int i, num,
error = OSPC_ERR_NO_ERROR;
661 if (!(provider =
ast_calloc(1,
sizeof(*provider)))) {
682 if (!strcasecmp(var->
name,
"privatekey")) {
684 if (var->
value[0] ==
'/') {
691 }
else if (!strcasecmp(var->
name,
"localcert")) {
693 if (var->
value[0] ==
'/') {
700 }
else if (!strcasecmp(var->
name,
"cacert")) {
703 if (var->
value[0] ==
'/') {
714 }
else if (!strcasecmp(var->
name,
"servicepoint")) {
722 }
else if (!strcasecmp(var->
name,
"maxconnect")) {
725 ast_debug(1,
"OSP: maxconnect '%d'\n", num);
727 ast_log(
LOG_WARNING,
"OSP: maxconnect should be an integer from %d to %d, not '%s' at line %d\n",
730 }
else if (!strcasecmp(var->
name,
"retrydelay")) {
733 ast_debug(1,
"OSP: retrydelay '%d'\n", num);
735 ast_log(
LOG_WARNING,
"OSP: retrydelay should be an integer from %d to %d, not '%s' at line %d\n",
738 }
else if (!strcasecmp(var->
name,
"retrylimit")) {
741 ast_debug(1,
"OSP: retrylimit '%d'\n", num);
743 ast_log(
LOG_WARNING,
"OSP: retrylimit should be an integer from %d to %d, not '%s' at line %d\n",
746 }
else if (!strcasecmp(var->
name,
"timeout")) {
749 ast_debug(1,
"OSP: timeout '%d'\n", num);
751 ast_log(
LOG_WARNING,
"OSP: timeout should be an integer from %d to %d, not '%s' at line %d\n",
754 }
else if (!strcasecmp(var->
name,
"source")) {
757 }
else if (!strcasecmp(var->
name,
"authpolicy")) {
760 ast_debug(1,
"OSP: authpolicy '%d'\n", num);
765 }
else if (!strcasecmp(var->
name,
"defprotocol")) {
768 ast_debug(1,
"OSP: default protocol SIP\n");
771 ast_debug(1,
"OSP: default protocol H.323\n");
774 ast_debug(1,
"OSP: default protocol IAX\n");
777 ast_debug(1,
"OSP: default protocol Skype\n");
779 ast_log(
LOG_WARNING,
"OSP: default protocol should be %s, %s, %s or %s not '%s' at line %d\n",
782 }
else if (!strcasecmp(var->
name,
"workmode")) {
785 ast_debug(1,
"OSP: workmode '%d'\n", num);
790 }
else if (!strcasecmp(var->
name,
"servicetype")) {
793 ast_debug(1,
"OSP: servicetype '%d'\n", num);
801 if (provider->
canum == 0) {
805 for (i = 0; i < provider->
spnum; i++) {
806 pspoints[i] = provider->
spoints[i];
810 privatekey.PrivateKeyData =
NULL;
811 privatekey.PrivateKeyLength = 0;
813 localcert.CertData =
NULL;
814 localcert.CertDataLength = 0;
816 for (i = 0; i < provider->
canum; i++) {
817 cacerts[i].CertData =
NULL;
818 cacerts[i].CertDataLength = 0;
821 if ((error = OSPPUtilLoadPEMPrivateKey((
unsigned char*)provider->
privatekey, &privatekey)) != OSPC_ERR_NO_ERROR) {
823 }
else if ((error = OSPPUtilLoadPEMCert((
unsigned char*)provider->
localcert, &localcert)) != OSPC_ERR_NO_ERROR) {
826 for (i = 0; i < provider->
canum; i++) {
827 if ((error = OSPPUtilLoadPEMCert((
unsigned char*)provider->
cacerts[i], &cacerts[i])) != OSPC_ERR_NO_ERROR) {
831 pcacerts[i] = &cacerts[i];
836 privatekey.PrivateKeyData = privatekeydata;
837 privatekey.PrivateKeyLength =
sizeof(privatekeydata);
839 localcert.CertData = localcertdata;
840 localcert.CertDataLength =
sizeof(localcertdata);
842 cacerts[0].CertData = cacertdata;
843 cacerts[0].CertDataLength =
sizeof(cacertdata);
844 pcacerts[0] = &cacerts[0];
846 if ((error = OSPPBase64Decode(
B64PKey, strlen(
B64PKey), privatekey.PrivateKeyData, &privatekey.PrivateKeyLength)) != OSPC_ERR_NO_ERROR) {
848 }
else if ((error = OSPPBase64Decode(
B64LCert, strlen(
B64LCert), localcert.CertData, &localcert.CertDataLength)) != OSPC_ERR_NO_ERROR) {
850 }
else if ((error = OSPPBase64Decode(
B64CACert, strlen(
B64CACert), cacerts[0].CertData, &cacerts[0].CertDataLength)) != OSPC_ERR_NO_ERROR) {
855 if (error == OSPC_ERR_NO_ERROR) {
856 error = OSPPProviderNew(provider->
spnum,
874 if (error != OSPC_ERR_NO_ERROR) {
875 ast_log(
LOG_WARNING,
"OSP: Unable to create provider '%s', error '%d'\n", name, error);
878 ast_debug(1,
"OSP: provider '%s'\n", name);
888 for (i = 0; i < provider->
canum; i++) {
889 if (cacerts[i].CertData) {
893 if (localcert.CertData) {
896 if (privatekey.PrivateKeyData) {
897 ast_free(privatekey.PrivateKeyData);
924 for (p = osp_providers; p !=
NULL; p = p->
next) {
925 if (!strcasecmp(p->
name, name)) {
927 ast_debug(1,
"OSP: find provider '%s'\n", name);
949 unsigned int srcsize)
955 if ((trans ==
NULL) || (source ==
NULL) || (srcsize <= 0)) {
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);
970 ast_debug(1,
"OSP: source '%s'\n", source);
974 ast_debug(1,
"OSP: Unable to create transaction handle, error '%d'\n", error);
995 unsigned int destsize)
1001 if ((dest !=
NULL) && (destsize > 0)) {
1005 if((port = strchr(buffer,
':')) !=
NULL) {
1010 if (inet_pton(AF_INET, buffer, &inp) == 1) {
1012 snprintf(dest, destsize,
"[%s]:%s", buffer, port);
1014 snprintf(dest, destsize,
"[%s]", buffer);
1016 dest[destsize - 1] =
'\0';
1035 unsigned int destsize)
1041 if ((dest !=
NULL) && (destsize > 0)) {
1045 if (buffer[0] ==
'[') {
1046 if((port = strchr(buffer + 1,
':')) !=
NULL) {
1051 if ((end = strchr(buffer + 1,
']')) !=
NULL) {
1056 snprintf(dest, destsize,
"%s:%s", buffer + 1, port);
1057 dest[destsize - 1] =
'\0';
1084 const char* destination,
1085 const char* calling,
1088 unsigned int* timelimit)
1095 unsigned int authorised;
1096 unsigned int dummy = 0;
1099 if (timelimit ==
NULL) {
1107 error = OSPPTransactionValidateAuthorisation(trans,
1112 calling ? calling :
"",
1125 if (error != OSPC_ERR_NO_ERROR) {
1129 }
else if (authorised) {
1155 return in < out ?
in :
out;
1173 const char* calling,
1175 const char* destination,
1176 unsigned int tokenlen,
1178 OSPEFAILREASON* reason,
1183 OSPE_PROTOCOL_NAME protocol;
1185 OSPE_OPERATOR_NAME
type;
1188 if ((provider ==
NULL) || (reason ==
NULL) || (results ==
NULL)) {
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;
1199 if (enabled == OSPC_DOSP_FALSE) {
1200 results->
token[0] =
'\0';
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);
1210 error = OSPPTransactionGetNumberPortabilityParameters(results->
outhandle,
1211 sizeof(results->
nprn),
1213 sizeof(results->
npcic),
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';
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);
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';
1236 results->
nprn[0] =
'\0';
1237 results->
npcic[0] =
'\0';
1239 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1248 case OSPC_PROTNAME_SIP:
1255 case OSPC_PROTNAME_Q931:
1262 case OSPC_PROTNAME_IAX:
1269 case OSPC_PROTNAME_SKYPE:
1276 case OSPC_PROTNAME_UNDEFINED:
1277 case OSPC_PROTNAME_UNKNOWN:
1278 ast_debug(1,
"OSP: unknown/undefined protocol '%d'\n", protocol);
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:
1292 *reason = OSPC_FAIL_PROTOCOL_ERROR;
1293 results->
token[0] =
'\0';
1295 results->
nprn[0] =
'\0';
1296 results->
npcic[0] =
'\0';
1298 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1316 return (OSPEFAILREASON)cause;
1334 const char* calling,
1337 unsigned int* timelimit)
1343 if ((trans ==
NULL) || (timelimit ==
NULL)) {
1352 ast_debug(1,
"OSP: Unabe to find OSP provider '%s'\n", name);
1364 ast_debug(1,
"OSP: Unable to generate transaction handle\n");
1367 }
else if((res =
osp_validate_token(*trans, source, dest, calling, called, token, timelimit)) <= 0) {
1368 OSPPTransactionRecordFailure(*trans, OSPC_FAIL_CALL_REJECTED);
1376 ast_debug(1,
"OSP: Unable to generate transaction handle\n");
1379 }
else if((res =
osp_validate_token(*trans, source, dest, calling, called, token, timelimit)) <= 0) {
1380 OSPPTransactionRecordFailure(*trans, OSPC_FAIL_CALL_REJECTED);
1395 unsigned char* uuid,
1396 unsigned int* bufsize)
1424 unsigned char* uuid,
1426 unsigned int bufsize)
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]);
1457 if (callid ==
NULL) {
1462 callid->
len =
sizeof(callid->
buf);
1476 if ((res !=
OSP_OK) && (callid->
len != 0)) {
1477 callid->
buf[0] =
'\0';
1501 unsigned int callidtypes,
1502 const char* actualsrc,
1504 const char* calling,
1509 const char* cinfo[],
1514 OSPE_PROTOCOL_NAME protocol;
1520 unsigned int tokenlen;
1525 unsigned int i,
type;
1527 unsigned int callidnum;
1530 const char* preferred[2] = {
NULL };
1531 unsigned int dummy = 0;
1532 OSPEFAILREASON reason;
1535 if (results ==
NULL) {
1545 results->
called[0] =
'\0';
1546 results->
token[0] =
'\0';
1548 results->
nprn[0] =
'\0';
1549 results->
npcic[0] =
'\0';
1551 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1558 ast_debug(1,
"OSP: Unabe to find OSP provider '%s'\n", name);
1563 ast_debug(1,
"OSP: Unable to generate transaction handle\n");
1566 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1572 protocol = OSPC_PROTNAME_SIP;
1574 protocol = OSPC_PROTNAME_Q931;
1576 protocol = OSPC_PROTNAME_IAX;
1578 protocol = OSPC_PROTNAME_SKYPE;
1580 protocol = OSPC_PROTNAME_SIP;
1582 OSPPTransactionSetProtocol(results->
outhandle, OSPC_PROTTYPE_SOURCE, protocol);
1585 OSPPTransactionSetNetworkIds(results->
outhandle, snetid,
"");
1590 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1591 OSPPTransactionSetOperatorName(results->
outhandle, type, np->
opname[type]);
1594 OSPPTransactionSetRemotePartyId(results->
outhandle, OSPC_NFORMAT_E164, headers->
rpiduser);
1595 OSPPTransactionSetAssertedId(results->
outhandle, OSPC_NFORMAT_E164, headers->
paiuser);
1598 OSPPTransactionSetChargeInfo(results->
outhandle, OSPC_NFORMAT_E164, headers->
pciuser);
1600 if (cinfo !=
NULL) {
1603 OSPPTransactionSetCustomInfo(results->
outhandle, i, cinfo[i]);
1609 if((tmp = strchr(callednum,
';')) !=
NULL) {
1617 if (callidtypes & type) {
1620 callids[callidnum] = OSPPCallIdNew(callid.
len, callid.
buf);
1639 OSPPTransactionSetServiceType(results->
outhandle, OSPC_SERVICE_NPQUERY);
1641 preferred[0] = dest;
1645 OSPPTransactionSetServiceType(results->
outhandle, OSPC_SERVICE_VOICE);
1649 error = OSPPTransactionRequestAuthorisation(results->
outhandle,
1652 calling ? calling :
"",
1664 for (i = 0; i < callidnum; i++) {
1665 OSPPCallIdDelete(&callids[i]);
1668 if (error != OSPC_ERR_NO_ERROR) {
1672 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1678 ast_debug(1,
"OSP: No more destination\n");
1680 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1686 tokenlen =
sizeof(token);
1687 error = OSPPTransactionGetFirstDestination(results->
outhandle,
1698 sizeof(destination),
1704 if (error != OSPC_ERR_NO_ERROR) {
1705 ast_debug(1,
"OSP: Unable to get first route, error '%d'\n", error);
1709 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
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);
1722 if ((res =
osp_check_destination(provider, callingnum, callednum, destination, tokenlen, token, &reason, results)) > 0) {
1727 ast_debug(1,
"OSP: No more destination\n");
1729 OSPPTransactionRecordFailure(results->
outhandle, reason);
1731 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1738 tokenlen =
sizeof(token);
1739 error = OSPPTransactionGetNextDestination(results->
outhandle,
1751 sizeof(destination),
1757 if (error == OSPC_ERR_NO_ERROR) {
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);
1766 if ((res =
osp_check_destination(provider, callingnum, callednum, destination, tokenlen, token, &reason, results)) > 0) {
1769 ast_debug(1,
"OSP: No more destination\n");
1770 OSPPTransactionRecordFailure(results->
outhandle, reason);
1772 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1778 ast_debug(1,
"OSP: Unable to get route, error '%d'\n", error);
1782 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1809 unsigned int tokenlen;
1811 OSPEFAILREASON reason;
1812 OSPE_OPERATOR_NAME
type;
1815 if (results ==
NULL) {
1821 results->
dest[0] =
'\0';
1823 results->
called[0] =
'\0';
1824 results->
token[0] =
'\0';
1826 results->
nprn[0] =
'\0';
1827 results->
npcic[0] =
'\0';
1829 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1835 ast_debug(1,
"OSP: Unabe to find OSP provider '%s'\n", name);
1840 ast_debug(1,
"OSP: Transaction handle undefined\n");
1843 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1851 ast_debug(1,
"OSP: No more destination\n");
1852 OSPPTransactionRecordFailure(results->
outhandle, reason);
1854 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1861 tokenlen =
sizeof(token);
1862 error = OSPPTransactionGetNextDestination(
1881 if (error == OSPC_ERR_NO_ERROR) {
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);
1890 if ((res =
osp_check_destination(provider, calling, called, dest, tokenlen, token, &reason, results)) > 0) {
1894 ast_debug(1,
"OSP: No more destination\n");
1895 OSPPTransactionRecordFailure(results->
outhandle, reason);
1897 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1903 ast_debug(1,
"OSP: Unable to get route, error '%d'\n", error);
1904 results->
token[0] =
'\0';
1908 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1930 if ((tmp = strchr(vstr,
'=')) !=
NULL) {
1932 if (sscanf(tmp,
"%30d", &value) != 1) {
1953 if ((tmp = strchr(vstr,
'=')) !=
NULL) {
1955 if (sscanf(tmp,
"%30f", &value) != 1) {
2015 for (item = strtok_r(buffer,
";", &tmp);
item; item = strtok_r(
NULL,
";", &tmp)) {
2016 if (!strncasecmp(item,
"rxcount", strlen(
"rxcount"))) {
2018 }
else if (!strncasecmp(item,
"txcount", strlen(
"txcount"))) {
2020 }
else if (!strncasecmp(item,
"lp", strlen(
"lp"))) {
2022 }
else if (!strncasecmp(item,
"minrxlost", strlen(
"minrxlost"))) {
2024 }
else if (!strncasecmp(item,
"maxrxlost", strlen(
"maxrxlost"))) {
2026 }
else if (!strncasecmp(item,
"avgrxlost", strlen(
"avgrxlost"))) {
2028 }
else if (!strncasecmp(item,
"stdevrxlost", strlen(
"stdevrxlost"))) {
2030 }
else if (!strncasecmp(item,
"rlp", strlen(
"rlp"))) {
2032 }
else if (!strncasecmp(item,
"reported_minlost", strlen(
"reported_minlost"))) {
2034 }
else if (!strncasecmp(item,
"reported_maxlost", strlen(
"reported_maxlost"))) {
2036 }
else if (!strncasecmp(item,
"reported_avglost", strlen(
"reported_avglost"))) {
2038 }
else if (!strncasecmp(item,
"reported_stdevlost", strlen(
"reported_stdevlost"))) {
2040 }
else if (!strncasecmp(item,
"rxjitter", strlen(
"rxjitter"))) {
2042 }
else if (!strncasecmp(item,
"minrxjitter", strlen(
"minrxjitter"))) {
2044 }
else if (!strncasecmp(item,
"maxrxjitter", strlen(
"maxrxjitter"))) {
2046 }
else if (!strncasecmp(item,
"avgrxjitter", strlen(
"avgjitter"))) {
2048 }
else if (!strncasecmp(item,
"stdevrxjitter", strlen(
"stdevjitter"))) {
2050 }
else if (!strncasecmp(item,
"txjitter", strlen(
"txjitter"))) {
2052 }
else if (!strncasecmp(item,
"reported_minjitter", strlen(
"reported_minjitter"))) {
2054 }
else if (!strncasecmp(item,
"reported_maxjitter", strlen(
"reported_maxjitter"))) {
2056 }
else if (!strncasecmp(item,
"reported_avgjitter", strlen(
"reported_avgjitter"))) {
2058 }
else if (!strncasecmp(item,
"reported_stdevjitter", strlen(
"reported_stdevjitter"))) {
2060 }
else if (!strncasecmp(item,
"rtt", strlen(
"rtt"))) {
2062 }
else if (!strncasecmp(item,
"minrtt", strlen(
"minrtt"))) {
2064 }
else if (!strncasecmp(item,
"maxrtt", strlen(
"maxrtt"))) {
2066 }
else if (!strncasecmp(item,
"avgrtt", strlen(
"avgrtt"))) {
2068 }
else if (!strncasecmp(item,
"stdevrtt", strlen(
"stdevrtt"))) {
2073 ast_debug(1,
"OSP: call leg '%d'\n", leg);
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);
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) {
2108 value = (int)lost[OSP_DIR_RX].avg;
2110 OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTP, OSPC_SDIR_SRCREP, value,
OSP_DEF_INTSTATS);
2111 if (lost[OSP_DIR_TX].value >= 0) {
2114 value = (int)lost[OSP_DIR_TX].avg;
2116 OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTCP, OSPC_SDIR_DESTREP, value,
OSP_DEF_INTSTATS);
2117 if (jitter[OSP_DIR_RX].value >= 0) {
2120 value = (int)jitter[OSP_DIR_RX].avg;
2122 OSPPTransactionSetJitter(trans,
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) {
2132 value = (int)jitter[OSP_DIR_TX].avg;
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);
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) {
2144 value = (int)jitter[OSP_DIR_RX].avg;
2146 OSPPTransactionSetJitter(trans,
2150 (
int)jitter[OSP_DIR_RX].min,
2151 (
int)jitter[OSP_DIR_RX].max,
2153 jitter[OSP_DIR_RX].sdev);
2154 if (jitter[OSP_DIR_TX].value >= 0) {
2157 value = (int)jitter[OSP_DIR_TX].avg;
2159 OSPPTransactionSetJitter(trans,
2163 (
int)jitter[OSP_DIR_TX].min,
2164 (
int)jitter[OSP_DIR_TX].max,
2166 jitter[OSP_DIR_TX].sdev);
2195 unsigned int release,
2200 OSPEFAILREASON reason;
2202 unsigned isPddInfoPresent = 0;
2204 unsigned int dummy = 0;
2211 OSPPTransactionSetRoleInfo(trans, OSPC_RSTATE_STOP, OSPC_RFORMAT_OSP, OSPC_RVENDOR_ASTERISK);
2215 OSPPTransactionRecordFailure(trans, reason);
2221 error = OSPPTransactionReportUsage(trans,
2222 difftime(end, connect),
2237 if (error == OSPC_ERR_NO_ERROR) {
2241 ast_debug(1,
"OSP: Unable to report usage, error '%d'\n", error);
2244 OSPPTransactionDelete(trans);
2266 const char* token =
"";
2268 unsigned int timelimit;
2283 provider =
args.provider;
2285 ast_debug(1,
"OSPAuth: provider '%s'\n", provider);
2291 }
else if (!strcmp(
ast_var_name(current),
"OSPINTOKEN")) {
2296 ast_debug(1,
"OSPAuth: source '%s'\n", source);
2297 ast_debug(1,
"OSPAuth: token size '%zd'\n", strlen(token));
2299 res =
osp_auth(provider, &handle, source,
2313 snprintf(buffer,
sizeof(buffer),
"%d", handle);
2315 ast_debug(1,
"OSPAuth: OSPINHANDLE '%s'\n", buffer);
2316 snprintf(buffer,
sizeof(buffer),
"%d", timelimit);
2318 ast_debug(1,
"OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
2346 const char* actualsrc =
"";
2347 const char* srcdev =
"";
2348 const char* snetid =
"";
2350 OSPE_OPERATOR_NAME
type;
2366 ast_log(
LOG_WARNING,
"OSPLookup: Arg required, OSPLookup(exten[,provider[,options]])\n");
2377 provider =
args.provider;
2379 ast_debug(1,
"OSPlookup: provider '%s'\n", provider);
2382 if (strchr(
args.options,
'h')) {
2385 if (strchr(
args.options,
's')) {
2388 if (strchr(
args.options,
'i')) {
2392 ast_debug(1,
"OSPLookup: call id types '%d'\n", callidtypes);
2396 results.
dest[0] =
'\0';
2401 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2413 if (!strcmp(
ast_var_name(current),
"OSPINACTUALSRC")) {
2415 }
else if (!strcmp(
ast_var_name(current),
"OSPINPEERIP")) {
2417 }
else if (!strcmp(
ast_var_name(current),
"OSPINTECH")) {
2419 }
else if (!strcmp(
ast_var_name(current),
"OSPINHANDLE")) {
2423 }
else if (!strcmp(
ast_var_name(current),
"OSPINTIMELIMIT")) {
2427 }
else if (!strcmp(
ast_var_name(current),
"OSPINNETWORKID")) {
2429 }
else if (!strcmp(
ast_var_name(current),
"OSPINNPRN")) {
2431 }
else if (!strcmp(
ast_var_name(current),
"OSPINNPCIC")) {
2433 }
else if (!strcmp(
ast_var_name(current),
"OSPINNPDI")) {
2437 }
else if (!strcmp(
ast_var_name(current),
"OSPINSPID")) {
2439 }
else if (!strcmp(
ast_var_name(current),
"OSPINOCN")) {
2441 }
else if (!strcmp(
ast_var_name(current),
"OSPINSPN")) {
2443 }
else if (!strcmp(
ast_var_name(current),
"OSPINALTSPN")) {
2445 }
else if (!strcmp(
ast_var_name(current),
"OSPINMCC")) {
2447 }
else if (!strcmp(
ast_var_name(current),
"OSPINMNC")) {
2449 }
else if (!strcmp(
ast_var_name(current),
"OSPINTOHOST")) {
2451 }
else if (!strcmp(
ast_var_name(current),
"OSPINRPIDUSER")) {
2453 }
else if (!strcmp(
ast_var_name(current),
"OSPINPAIUSER")) {
2455 }
else if (!strcmp(
ast_var_name(current),
"OSPINDIVUSER")) {
2457 }
else if (!strcmp(
ast_var_name(current),
"OSPINDIVHOST")) {
2459 }
else if (!strcmp(
ast_var_name(current),
"OSPINPCIUSER")) {
2461 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO1")) {
2463 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO2")) {
2465 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO3")) {
2467 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO4")) {
2469 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO5")) {
2471 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO6")) {
2473 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO7")) {
2475 }
else if (!strcmp(
ast_var_name(current),
"OSPINCUSTOMINFO8")) {
2479 ast_debug(1,
"OSPLookup: actual source device '%s'\n", actualsrc);
2480 ast_debug(1,
"OSPLookup: source device '%s'\n", srcdev);
2484 ast_debug(1,
"OSPLookup: OSPINNETWORKID '%s'\n", snetid);
2485 ast_debug(1,
"OSPLookup: OSPINNPRN '%s'\n", np.
rn);
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);
2502 ast_debug(1,
"OSPLookup: OSPINCUSTOMINFO%d '%s'\n", i, cinfo[i]);
2510 res =
osp_lookup(provider, callidtypes, actualsrc, srcdev,
2512 args.exten, snetid, &np, &headers, cinfo, &results);
2517 results.
dest[0] =
'\0';
2519 results.
called[0] =
'\0';
2520 results.
token[0] =
'\0';
2522 results.
nprn[0] =
'\0';
2523 results.
npcic[0] =
'\0';
2525 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2539 snprintf(buffer,
sizeof(buffer),
"%d", results.
outhandle);
2541 ast_debug(1,
"OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
2545 ast_debug(1,
"OSPLookup: OSPDESTINATION '%s'\n", results.
dest);
2556 snprintf(buffer,
sizeof(buffer),
"%d", results.
npdi);
2558 ast_debug(1,
"OSPLookup: OSPOUTNPDI'%s'\n", buffer);
2560 ast_debug(1,
"OSPLookup: OSPOUTSPID '%s'\n", results.
opname[OSPC_OPNAME_SPID]);
2562 ast_debug(1,
"OSPLookup: OSPOUTOCN '%s'\n", results.
opname[OSPC_OPNAME_OCN]);
2564 ast_debug(1,
"OSPLookup: OSPOUTSPN '%s'\n", results.
opname[OSPC_OPNAME_SPN]);
2566 ast_debug(1,
"OSPLookup: OSPOUTALTSPN '%s'\n", results.
opname[OSPC_OPNAME_ALTSPN]);
2568 ast_debug(1,
"OSPLookup: OSPOUTMCC '%s'\n", results.
opname[OSPC_OPNAME_MCC]);
2570 ast_debug(1,
"OSPLookup: OSPOUTMNC '%s'\n", results.
opname[OSPC_OPNAME_MNC]);
2572 ast_debug(1,
"OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(results.
token));
2573 snprintf(buffer,
sizeof(buffer),
"%d", results.
numdests);
2575 ast_debug(1,
"OSPLookup: OSPDESTREMAILS '%s'\n", buffer);
2576 snprintf(buffer,
sizeof(buffer),
"%d", results.
outtimelimit);
2578 ast_debug(1,
"OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
2579 snprintf(buffer,
sizeof(buffer),
"%d", callidtypes);
2581 ast_debug(1,
"OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
2583 ast_debug(1,
"OSPLookup: %s\n", status);
2586 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
outtech, results.
called, results.
dest);
2591 ast_debug(1,
"OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
2600 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
outtech, results.
called, results.
dest);
2603 snprintf(buffer,
sizeof(buffer),
"%s/%s/%s", results.
outtech, results.
dest, results.
called);
2606 snprintf(buffer,
sizeof(buffer),
"%s/%s", results.
outtech, results.
called);
2639 OSPE_OPERATOR_NAME
type;
2652 ast_log(
LOG_WARNING,
"OSPNext: Arg required, OSPNext(cause[,provider[,options]])\n");
2663 ast_debug(1,
"OSPNext: cause '%d'\n", cause);
2666 provider =
args.provider;
2668 ast_debug(1,
"OSPlookup: provider '%s'\n", provider);
2681 }
else if (!strcmp(
ast_var_name(current),
"OSPOUTHANDLE")) {
2685 }
else if (!strcmp(
ast_var_name(current),
"OSPINTIMELIMIT")) {
2689 }
else if (!strcmp(
ast_var_name(current),
"OSPOUTCALLIDTYPES")) {
2690 if (sscanf(
ast_var_value(current),
"%30d", &callidtypes) != 1) {
2693 }
else if (!strcmp(
ast_var_name(current),
"OSPDESTREMAILS")) {
2702 ast_debug(1,
"OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
2705 if ((res =
osp_next(provider, cause, &results)) > 0) {
2709 results.
dest[0] =
'\0';
2711 results.
called[0] =
'\0';
2712 results.
token[0] =
'\0';
2714 results.
nprn[0] =
'\0';
2715 results.
npcic[0] =
'\0';
2717 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2734 ast_debug(1,
"OSPNext: OSPDESTINATION '%s'\n", results.
dest);
2745 snprintf(buffer,
sizeof(buffer),
"%d", results.
npdi);
2747 ast_debug(1,
"OSPLookup: OSPOUTNPDI'%s'\n", buffer);
2749 ast_debug(1,
"OSPLookup: OSPOUTSPID '%s'\n", results.
opname[OSPC_OPNAME_SPID]);
2751 ast_debug(1,
"OSPLookup: OSPOUTOCN '%s'\n", results.
opname[OSPC_OPNAME_OCN]);
2753 ast_debug(1,
"OSPLookup: OSPOUTSPN '%s'\n", results.
opname[OSPC_OPNAME_SPN]);
2755 ast_debug(1,
"OSPLookup: OSPOUTALTSPN '%s'\n", results.
opname[OSPC_OPNAME_ALTSPN]);
2757 ast_debug(1,
"OSPLookup: OSPOUTMCC '%s'\n", results.
opname[OSPC_OPNAME_MCC]);
2759 ast_debug(1,
"OSPLookup: OSPOUTMNC '%s'\n", results.
opname[OSPC_OPNAME_MNC]);
2761 ast_debug(1,
"OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(results.
token));
2762 snprintf(buffer,
sizeof(buffer),
"%d", results.
numdests);
2764 ast_debug(1,
"OSPNext: OSPDESTREMAILS '%s'\n", buffer);
2765 snprintf(buffer,
sizeof(buffer),
"%d", results.
outtimelimit);
2767 ast_debug(1,
"OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
2772 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
outtech, results.
called, results.
dest);
2777 ast_debug(1,
"OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
2786 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
outtech, results.
called, results.
dest);
2789 snprintf(buffer,
sizeof(buffer),
"%s/%s/%s", results.
outtech, results.
dest, results.
called);
2792 snprintf(buffer,
sizeof(buffer),
"%s/%s", results.
outtech, results.
called);
2822 time_t start = 0, connect = 0,
end = 0;
2823 unsigned int release;
2842 if (sscanf(
ast_var_value(current),
"%30d", &inhandle) != 1) {
2845 }
else if (!strcmp(
ast_var_name(current),
"OSPOUTHANDLE")) {
2846 if (sscanf(
ast_var_value(current),
"%30d", &outhandle) != 1) {
2849 }
else if (!recorded &&
2857 }
else if (!strcmp(
ast_var_name(current),
"OSPINAUDIOQOS")) {
2859 }
else if (!strcmp(
ast_var_name(current),
"OSPOUTAUDIOQOS")) {
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);
2872 ast_debug(1,
"OSPFinish: cause '%d'\n", cause);
2886 ast_debug(1,
"OSPFinish: start '%ld'\n", start);
2887 ast_debug(1,
"OSPFinish: connect '%ld'\n", connect);
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");
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");
2936 for (provider = osp_providers;
provider; provider =
next) {
2937 next = provider->
next;
2938 OSPPProviderDelete(provider->
handle, 0);
2941 osp_providers =
NULL;
2961 int error = OSPC_ERR_NO_ERROR;
2976 if ((error = OSPPInit(1)) != OSPC_ERR_NO_ERROR) {
2977 ast_log(
LOG_WARNING,
"OSP: Unable to enable hardware acceleration, error='%d'\n", error);
2993 if ((sscanf(cvar,
"%30d", &ivar) == 1) &&
2994 ((ivar == TOKEN_ALGO_SIGNED) || (ivar == TOKEN_ALGO_UNSIGNED) || (ivar == TOKEN_ALGO_BOTH)))
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);
3028 const char* tokenalgo;
3035 " Displays information on Open Settlement Protocol support\n";
3041 if ((a->
argc < 2) || (a->
argc > 3)) {
3051 case TOKEN_ALGO_BOTH:
3054 case TOKEN_ALGO_UNSIGNED:
3055 tokenalgo =
"Unsigned";
3057 case TOKEN_ALGO_SIGNED:
3059 tokenalgo =
"Signed";
3070 for (provider = osp_providers;
provider; provider = provider->
next) {
3071 if (!name || !strcasecmp(provider->
name, name)) {
3075 ast_cli(a->
fd,
" == OSP Provider '%s' == \n", provider->
name);
3079 for (i = 0; i < provider->
canum; i++) {
3083 for (i = 0; i < provider->
spnum; i++) {
3103 ast_cli(a->
fd,
"Unable to find OSP provider '%s'\n", name);
3105 ast_cli(a->
fd,
"No OSP providers configured\n");
3113 static const char app1[] =
"OSPAuth";
3116 static const char app2[] =
"OSPLookup";
3119 static const char app3[] =
"OSPNext";
3122 static const char app4[] =
"OSPFinish";
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
struct ast_variable * next
const char * ast_config_AST_KEY_DIR
#define OSP_LOCAL_VALIDATION
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
static int osp_unload(void)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define OSP_MAX_RETRYDELAY
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
static int osp_next(const char *name, int cause, struct osp_results *results)
OSP Lookup Next function.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define OSP_DEF_MAXCONNECT
enum osp_authpolicy authpolicy
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
const char * ast_var_value(const struct ast_var_t *var)
#define OSP_DEF_RETRYDELAY
static int unload_module(void)
const char * ast_var_name(const struct ast_var_t *var)
#define OSP_HTTP_PERSISTENCE
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 'standard' argument separation process for an application.
descriptor for a cli entry.
static void dummy(char *unused,...)
struct timeval ast_channel_answertime(struct ast_channel *chan)
#define CONFIG_STATUS_FILEINVALID
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.
Structure for variables, used for configurations and for channel variables.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
char dest[OSP_SIZE_NORSTR]
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct aco_type item
#define OSP_MIN_MAXCONNECT
static int osp_get_provider(const char *name, struct osp_provider **provider)
Get OSP provider by name.
#define ast_mutex_lock(a)
struct varshead * ast_channel_varshead(struct ast_channel *chan)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
void ast_cli(int fd, const char *fmt,...)
static int osp_uuid2str(unsigned char *uuid, char *buffer, unsigned int bufsize)
UUID to string.
int ast_unregister_application(const char *app)
Unregister an application.
static int osp_create_provider(struct ast_config *cfg, const char *name)
Create OSP provider handle according to configuration.
static int osp_create_uuid(unsigned char *uuid, unsigned int *bufsize)
Create a UUID.
char outtech[OSP_SIZE_TECHSTR]
char nprn[OSP_SIZE_NORSTR]
char name[OSP_SIZE_NORSTR]
#define ast_strlen_zero(foo)
char intech[OSP_SIZE_TECHSTR]
Configuration File Parser.
int ast_base64decode(unsigned char *dst, const char *src, int max)
Decode data from base64.
static int osp_initialized
static int osp_load(int reload)
#define ast_debug(level,...)
Log a DEBUG message.
static int osp_create_transaction(const char *name, int *trans, char *source, unsigned int srcsize)
Create OSP transaction handle.
static int ospnext_exec(struct ast_channel *chan, const char *data)
OSP Application OSPNext.
#define ast_config_load(filename, flags)
Load a config file.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
unsigned int outtimelimit
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.
char localcert[OSP_SIZE_NORSTR]
char calling[OSP_SIZE_NORSTR]
#define AST_CAUSE_NORMAL_CLEARING
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
void ast_config_destroy(struct ast_config *config)
Destroys a config.
long int ast_random(void)
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 ast_strdupa(s)
duplicate a string in memory from the stack
static unsigned int osp_choose_timelimit(unsigned int in, unsigned int out)
Choose min duration limit.
#define OSP_DEF_AUTHPOLICY
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.
const char * ast_channel_exten(const struct ast_channel *chan)
Core PBX routines and definitions.
static int osp_get_varint(const char *vstr)
Get integer from variable string.
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
#define CONFIG_STATUS_FILEUNCHANGED
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.
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".
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.
static int ospfinished_exec(struct ast_channel *chan, const char *data)
OSP Application OSPFinish.
#define OSP_DEF_FLOATSTATS
static float osp_get_varfloat(const char *vstr)
Get float from variable string.
static int ospauth_exec(struct ast_channel *chan, const char *data)
OSP Application OSPAuth.
char npcic[OSP_SIZE_NORSTR]
static int load_module(void)
#define OSP_MAX_MAXCONNECT
struct timeval ast_channel_creationtime(struct ast_channel *chan)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
char cacerts[OSP_MAX_CERTS][OSP_SIZE_NORSTR]
#define ast_calloc(num, len)
A wrapper for calloc()
struct ast_var_t::@249 entries
enum osp_workmode workmode
char privatekey[OSP_SIZE_NORSTR]
#define OSP_DEF_TIMELIMIT
Module has failed to load, may be in an inconsistent state.
char networkid[OSP_SIZE_NORSTR]
static unsigned int osp_tokenformat
Structure used to handle boolean flags.
static struct ast_cli_entry cli_osp[]
static int osp_report_qos(int trans, enum osp_callleg leg, const char *qos)
Report QoS.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static OSPEFAILREASON asterisk2osp(int cause)
Convert Asterisk status to TC code.
#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...
char token[OSP_SIZE_TOKSTR]
#define OSP_MAX_CUSTOMINFO
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
static int osp_create_callid(unsigned int type, struct osp_callid *callid)
Create a call ID according to the type.
static struct osp_provider * osp_providers
static int osplookup_exec(struct ast_channel *chan, const char *data)
OSP Application OSPLookup.
#define AST_CAUSE_NO_ROUTE_DESTINATION
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define OSP_MIN_RETRYLIMIT
Internal Asterisk hangup causes.
char called[OSP_SIZE_NORSTR]
int error(const char *format,...)
struct osp_provider * next
#define OSP_CALLID_MAXNUM
#define OSP_MIN_RETRYDELAY
unsigned char buf[OSP_SIZE_NORSTR]
struct osp_callid outcallid
char source[OSP_SIZE_NORSTR]
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
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 OSP_DEF_RETRYLIMIT
static struct prometheus_metrics_provider provider
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static ast_mutex_t osp_lock
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
char spoints[OSP_MAX_SPOINTS][OSP_SIZE_NORSTR]
#define OSP_MAX_RETRYLIMIT
static char * handle_cli_osp_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_mutex_unlock(a)
#define AST_APP_ARG(name)
Define an application argument.
const char * opname[OSPC_OPNAME_NUMBER]