42 #include <osp/osputils.h>
43 #include <osp/ospb64.h>
430 #define OSP_SIZE_INTSTR ((unsigned int)16)
431 #define OSP_SIZE_NORSTR ((unsigned int)256)
432 #define OSP_SIZE_KEYSTR ((unsigned int)1024)
433 #define OSP_SIZE_TOKSTR ((unsigned int)4096)
434 #define OSP_SIZE_TECHSTR ((unsigned int)32)
435 #define OSP_SIZE_UUID ((unsigned int)16)
436 #define OSP_SIZE_UUIDSTR ((unsigned int)36)
437 #define OSP_SIZE_QOSSTR ((unsigned int)1024)
440 #define OSP_CALLID_UNDEF ((unsigned int)0)
441 #define OSP_CALLID_SIP ((unsigned int)(1 << 0))
442 #define OSP_CALLID_H323 ((unsigned int)(1 << 1))
443 #define OSP_CALLID_IAX ((unsigned int)(1 << 2))
444 #define OSP_CALLID_MAXNUM ((unsigned int)3)
447 #define OSP_PROT_SIP ((const char*)"SIP")
448 #define OSP_PROT_H323 ((const char*)"H323")
449 #define OSP_PROT_IAX ((const char*)"IAX")
450 #define OSP_PROT_SKYPE ((const char*)"SKYPE")
453 #define OSP_TECH_SIP ((const char*)"SIP")
454 #define OSP_TECH_H323 ((const char*)"H323")
455 #define OSP_TECH_IAX ((const char*)"IAX2")
456 #define OSP_TECH_SKYPE ((const char*)"SKYPE")
459 #define OSP_SIP_HEADER ((const char*)"P-OSP-Auth-Token")
481 #define OSP_OK ((int)1)
482 #define OSP_FAILED ((int)0)
483 #define OSP_ERROR ((int)-1)
484 #define OSP_AST_OK ((int)0)
485 #define OSP_AST_ERROR ((int)-1)
486 #define OSP_INVALID_HANDLE ((int)-1)
487 #define OSP_CONFIG_FILE ((const char*)"osp.conf")
488 #define OSP_GENERAL_CAT ((const char*)"general")
489 #define OSP_DEF_PROVIDER ((const char*)"default")
490 #define OSP_MAX_CERTS ((unsigned int)10)
491 #define OSP_MAX_SPOINTS ((unsigned int)10)
492 #define OSP_DEF_MAXCONNECT ((unsigned int)20)
493 #define OSP_MIN_MAXCONNECT ((unsigned int)1)
494 #define OSP_MAX_MAXCONNECT ((unsigned int)1000)
495 #define OSP_DEF_RETRYDELAY ((unsigned int)0)
496 #define OSP_MIN_RETRYDELAY ((unsigned int)0)
497 #define OSP_MAX_RETRYDELAY ((unsigned int)10)
498 #define OSP_DEF_RETRYLIMIT ((unsigned int)2)
499 #define OSP_MIN_RETRYLIMIT ((unsigned int)0)
500 #define OSP_MAX_RETRYLIMIT ((unsigned int)100)
501 #define OSP_DEF_TIMEOUT ((unsigned int)500)
502 #define OSP_MIN_TIMEOUT ((unsigned int)200)
503 #define OSP_MAX_TIMEOUT ((unsigned int)10000)
504 #define OSP_DEF_AUTHPOLICY OSP_AUTH_YES
505 #define OSP_AUDIT_URL ((const char*)"localhost")
506 #define OSP_LOCAL_VALIDATION ((int)1)
507 #define OSP_SSL_LIFETIME ((unsigned int)300)
508 #define OSP_HTTP_PERSISTENCE ((int)1)
509 #define OSP_CUSTOMER_ID ((const char*)"")
510 #define OSP_DEVICE_ID ((const char*)"")
511 #define OSP_DEF_MAXDESTS ((unsigned int)5)
512 #define OSP_DEF_TIMELIMIT ((unsigned int)0)
513 #define OSP_DEF_PROTOCOL OSP_PROT_SIP
514 #define OSP_DEF_WORKMODE OSP_MODE_DIRECT
515 #define OSP_DEF_SRVTYPE OSP_SRV_VOICE
516 #define OSP_MAX_CUSTOMINFO ((unsigned int)8)
517 #define OSP_DEF_INTSTATS ((int)-1)
518 #define OSP_DEF_FLOATSTATS ((float)-1)
614 const char*
B64PKey =
"MIIBOgIBAAJBAK8t5l+PUbTC4lvwlNxV5lpl+2dwSZGW46dowTe6y133XyVEwNiiRma2YNk3xKs/TJ3Wl9Wpns2SYEAJsFfSTukCAwEAAQJAPz13vCm2GmZ8Zyp74usTxLCqSJZNyMRLHQWBM0g44Iuy4wE3vpi7Wq+xYuSOH2mu4OddnxswCP4QhaXVQavTAQIhAOBVCKXtppEw9UaOBL4vW0Ed/6EA/1D8hDW6St0h7EXJAiEAx+iRmZKhJD6VT84dtX5ZYNVk3j3dAcIOovpzUj9a0CECIEduTCapmZQ5xqAEsLXuVlxRtQgLTUD4ZxDElPn8x0MhAiBE2HlcND0+qDbvtwJQQOUzDgqg5xk3w8capboVdzAlQQIhAMC+lDL7+gDYkNAft5Mu+NObJmQs4Cr+DkDFsKqoxqrm";
615 const char*
B64LCert =
"MIIBeTCCASMCEHqkOHVRRWr+1COq3CR/xsowDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTA1MDYyMzAwMjkxOFoXDTA2MDYyNDAwMjkxOFowRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCvLeZfj1G0wuJb8JTcVeZaZftncEmRluOnaME3ustd918lRMDYokZmtmDZN8SrP0yd1pfVqZ7NkmBACbBX0k7pAgMBAAEwDQYJKoZIhvcNAQEEBQADQQDnV8QNFVVJx/+7IselU0wsepqMurivXZzuxOmTEmTVDzCJx1xhA8jd3vGAj7XDIYiPub1PV23eY5a2ARJuw5w9";
616 const char*
B64CACert =
"MIIBYDCCAQoCAQEwDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTAyMDIwNDE4MjU1MloXDTEyMDIwMzE4MjU1MlowOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPGeGwV41EIhX0jEDFLRXQhDEr50OUQPq+f55VwQd0TQNts06BP29+UiNdRW3c3IRHdZcJdC1Cg68ME9cgeq0h8CAwEAATANBgkqhkiG9w0BAQQFAANBAGkzBSj1EnnmUxbaiG1N4xjIuLAWydun7o3bFk2tV8dBIhnuh445obYyk1EnQ27kI7eACCILBZqi2MHDOIMnoN0=";
641 int i, num, error = OSPC_ERR_NO_ERROR;
643 if (!(provider =
ast_calloc(1,
sizeof(*provider)))) {
664 if (!strcasecmp(var->
name,
"privatekey")) {
666 if (var->
value[0] ==
'/') {
673 }
else if (!strcasecmp(var->
name,
"localcert")) {
675 if (var->
value[0] ==
'/') {
682 }
else if (!strcasecmp(var->
name,
"cacert")) {
685 if (var->
value[0] ==
'/') {
696 }
else if (!strcasecmp(var->
name,
"servicepoint")) {
704 }
else if (!strcasecmp(var->
name,
"maxconnect")) {
707 ast_debug(1,
"OSP: maxconnect '%d'\n", num);
709 ast_log(
LOG_WARNING,
"OSP: maxconnect should be an integer from %d to %d, not '%s' at line %d\n",
712 }
else if (!strcasecmp(var->
name,
"retrydelay")) {
715 ast_debug(1,
"OSP: retrydelay '%d'\n", num);
717 ast_log(
LOG_WARNING,
"OSP: retrydelay should be an integer from %d to %d, not '%s' at line %d\n",
720 }
else if (!strcasecmp(var->
name,
"retrylimit")) {
723 ast_debug(1,
"OSP: retrylimit '%d'\n", num);
725 ast_log(
LOG_WARNING,
"OSP: retrylimit should be an integer from %d to %d, not '%s' at line %d\n",
728 }
else if (!strcasecmp(var->
name,
"timeout")) {
731 ast_debug(1,
"OSP: timeout '%d'\n", num);
733 ast_log(
LOG_WARNING,
"OSP: timeout should be an integer from %d to %d, not '%s' at line %d\n",
736 }
else if (!strcasecmp(var->
name,
"source")) {
739 }
else if (!strcasecmp(var->
name,
"authpolicy")) {
742 ast_debug(1,
"OSP: authpolicy '%d'\n", num);
747 }
else if (!strcasecmp(var->
name,
"defprotocol")) {
750 ast_debug(1,
"OSP: default protocol SIP\n");
753 ast_debug(1,
"OSP: default protocol H.323\n");
756 ast_debug(1,
"OSP: default protocol IAX\n");
759 ast_debug(1,
"OSP: default protocol Skype\n");
761 ast_log(
LOG_WARNING,
"OSP: default protocol should be %s, %s, %s or %s not '%s' at line %d\n",
764 }
else if (!strcasecmp(var->
name,
"workmode")) {
767 ast_debug(1,
"OSP: workmode '%d'\n", num);
772 }
else if (!strcasecmp(var->
name,
"servicetype")) {
775 ast_debug(1,
"OSP: servicetype '%d'\n", num);
783 if (provider->
canum == 0) {
787 for (i = 0; i < provider->
spnum; i++) {
788 pspoints[i] = provider->
spoints[i];
792 privatekey.PrivateKeyData = NULL;
793 privatekey.PrivateKeyLength = 0;
795 localcert.CertData = NULL;
796 localcert.CertDataLength = 0;
798 for (i = 0; i < provider->
canum; i++) {
799 cacerts[i].CertData = NULL;
800 cacerts[i].CertDataLength = 0;
803 if ((error = OSPPUtilLoadPEMPrivateKey((
unsigned char*)provider->
privatekey, &privatekey)) != OSPC_ERR_NO_ERROR) {
805 }
else if ((error = OSPPUtilLoadPEMCert((
unsigned char*)provider->
localcert, &localcert)) != OSPC_ERR_NO_ERROR) {
808 for (i = 0; i < provider->
canum; i++) {
809 if ((error = OSPPUtilLoadPEMCert((
unsigned char*)provider->
cacerts[i], &cacerts[i])) != OSPC_ERR_NO_ERROR) {
813 pcacerts[i] = &cacerts[i];
818 privatekey.PrivateKeyData = privatekeydata;
819 privatekey.PrivateKeyLength =
sizeof(privatekeydata);
821 localcert.CertData = localcertdata;
822 localcert.CertDataLength =
sizeof(localcertdata);
824 cacerts[0].CertData = cacertdata;
825 cacerts[0].CertDataLength =
sizeof(cacertdata);
826 pcacerts[0] = &cacerts[0];
828 if ((error = OSPPBase64Decode(B64PKey, strlen(B64PKey), privatekey.PrivateKeyData, &privatekey.PrivateKeyLength)) != OSPC_ERR_NO_ERROR) {
830 }
else if ((error = OSPPBase64Decode(B64LCert, strlen(B64LCert), localcert.CertData, &localcert.CertDataLength)) != OSPC_ERR_NO_ERROR) {
832 }
else if ((error = OSPPBase64Decode(B64CACert, strlen(B64CACert), cacerts[0].CertData, &cacerts[0].CertDataLength)) != OSPC_ERR_NO_ERROR) {
837 if (error == OSPC_ERR_NO_ERROR) {
838 error = OSPPProviderNew(provider->
spnum,
856 if (error != OSPC_ERR_NO_ERROR) {
857 ast_log(
LOG_WARNING,
"OSP: Unable to create provider '%s', error '%d'\n", name, error);
860 ast_debug(1,
"OSP: provider '%s'\n", name);
863 osp_providers = provider;
870 for (i = 0; i < provider->
canum; i++) {
871 if (cacerts[i].CertData) {
875 if (localcert.CertData) {
878 if (privatekey.PrivateKeyData) {
879 ast_free(privatekey.PrivateKeyData);
906 for (p = osp_providers; p != NULL; p = p->
next) {
907 if (!strcasecmp(p->
name, name)) {
909 ast_debug(1,
"OSP: find provider '%s'\n", name);
931 unsigned int srcsize)
937 if ((trans == NULL) || (source == NULL) || (srcsize <= 0)) {
946 for (provider = osp_providers; provider; provider = provider->
next) {
947 if (!strcasecmp(provider->
name, name)) {
948 error = OSPPTransactionNew(provider->
handle, trans);
949 if (error == OSPC_ERR_NO_ERROR) {
950 ast_debug(1,
"OSP: transaction '%d'\n", *trans);
952 ast_debug(1,
"OSP: source '%s'\n", source);
956 ast_debug(1,
"OSP: Unable to create transaction handle, error '%d'\n", error);
977 unsigned int destsize)
983 if ((dest != NULL) && (destsize > 0)) {
987 if((port = strchr(buffer,
':')) != NULL) {
992 if (inet_pton(AF_INET, buffer, &inp) == 1) {
994 snprintf(dest, destsize,
"[%s]:%s", buffer, port);
996 snprintf(dest, destsize,
"[%s]", buffer);
998 dest[destsize - 1] =
'\0';
1017 unsigned int destsize)
1023 if ((dest != NULL) && (destsize > 0)) {
1027 if (buffer[0] ==
'[') {
1028 if((port = strchr(buffer + 1,
':')) != NULL) {
1033 if ((end = strchr(buffer + 1,
']')) != NULL) {
1038 snprintf(dest, destsize,
"%s:%s", buffer + 1, port);
1039 dest[destsize - 1] =
'\0';
1066 const char* destination,
1067 const char* calling,
1070 unsigned int* timelimit)
1077 unsigned int authorised;
1078 unsigned int dummy = 0;
1081 if (timelimit == NULL) {
1089 error = OSPPTransactionValidateAuthorisation(trans,
1094 calling ? calling :
"",
1107 if (error != OSPC_ERR_NO_ERROR) {
1111 }
else if (authorised) {
1137 return in < out ? in : out;
1155 const char* calling,
1157 const char* destination,
1158 unsigned int tokenlen,
1160 OSPEFAILREASON* reason,
1165 OSPE_DEST_PROTOCOL protocol;
1167 OSPE_OPERATOR_NAME
type;
1170 if ((provider == NULL) || (reason == NULL) || (results == NULL)) {
1175 if ((error = OSPPTransactionIsDestOSPEnabled(results->
outhandle, &enabled)) != OSPC_ERR_NO_ERROR) {
1176 ast_debug(1,
"OSP: Unable to get destination OSP version, error '%d'\n", error);
1177 *reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
1181 if (enabled == OSPC_DOSP_FALSE) {
1182 results->
token[0] =
'\0';
1187 if ((error = OSPPTransactionGetDestinationNetworkId(results->
outhandle,
sizeof(results->
networkid), results->
networkid)) != OSPC_ERR_NO_ERROR) {
1188 ast_debug(1,
"OSP: Unable to get destination network ID, error '%d'\n", error);
1192 error = OSPPTransactionGetNumberPortabilityParameters(results->
outhandle,
1193 sizeof(results->
nprn),
1195 sizeof(results->
npcic),
1198 if (error != OSPC_ERR_NO_ERROR) {
1199 ast_debug(1,
"OSP: Unable to get number portability parameters, error '%d'\n", error);
1200 results->
nprn[0] =
'\0';
1201 results->
npcic[0] =
'\0';
1205 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1206 error = OSPPTransactionGetOperatorName(results->
outhandle, type,
sizeof(results->
opname[type]), results->
opname[type]);
1207 if (error != OSPC_ERR_NO_ERROR) {
1208 ast_debug(1,
"OSP: Unable to get operator name of type '%d', error '%d'\n", type, error);
1213 if ((error = OSPPTransactionGetDestProtocol(results->
outhandle, &protocol)) != OSPC_ERR_NO_ERROR) {
1214 ast_debug(1,
"OSP: Unable to get destination protocol, error '%d'\n", error);
1215 *reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
1216 results->
token[0] =
'\0';
1218 results->
nprn[0] =
'\0';
1219 results->
npcic[0] =
'\0';
1221 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1230 case OSPC_DPROT_SIP:
1237 case OSPC_DPROT_Q931:
1244 case OSPC_DPROT_IAX:
1251 case OSPC_DPROT_SKYPE:
1258 case OSPC_DPROT_UNDEFINED:
1259 case OSPC_DPROT_UNKNOWN:
1260 ast_debug(1,
"OSP: unknown/undefined protocol '%d'\n", protocol);
1267 case OSPC_DPROT_LRQ:
1268 case OSPC_DPROT_T37:
1269 case OSPC_DPROT_T38:
1270 case OSPC_DPROT_SMPP:
1271 case OSPC_DPROT_XMPP:
1274 *reason = OSPC_FAIL_PROTOCOL_ERROR;
1275 results->
token[0] =
'\0';
1277 results->
nprn[0] =
'\0';
1278 results->
npcic[0] =
'\0';
1280 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1298 return (OSPEFAILREASON)cause;
1316 const char* calling,
1319 unsigned int* timelimit)
1325 if ((trans == NULL) || (timelimit == NULL)) {
1334 ast_debug(1,
"OSP: Unabe to find OSP provider '%s'\n", name);
1346 ast_debug(1,
"OSP: Unable to generate transaction handle\n");
1349 }
else if((res =
osp_validate_token(*trans, source, dest, calling, called, token, timelimit)) <= 0) {
1350 OSPPTransactionRecordFailure(*trans, OSPC_FAIL_CALL_REJECTED);
1358 ast_debug(1,
"OSP: Unable to generate transaction handle\n");
1361 }
else if((res =
osp_validate_token(*trans, source, dest, calling, called, token, timelimit)) <= 0) {
1362 OSPPTransactionRecordFailure(*trans, OSPC_FAIL_CALL_REJECTED);
1377 unsigned char* uuid,
1378 unsigned int* bufsize)
1406 unsigned char* uuid,
1408 unsigned int bufsize)
1413 snprintf(buffer, bufsize,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1414 uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
1415 uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
1437 if (callid == NULL) {
1442 callid->
len =
sizeof(callid->
buf);
1455 if ((res !=
OSP_OK) && (callid->
len != 0)) {
1456 callid->
buf[0] =
'\0';
1480 unsigned int callidtypes,
1481 const char* actualsrc,
1483 const char* calling,
1488 const char* cinfo[],
1498 unsigned int tokenlen;
1503 unsigned int i,
type;
1505 unsigned int callidnum;
1508 const char* preferred[2] = { NULL };
1509 unsigned int dummy = 0;
1510 OSPEFAILREASON reason;
1513 if (results == NULL) {
1521 results->
tech[0] =
'\0';
1523 results->
called[0] =
'\0';
1524 results->
token[0] =
'\0';
1526 results->
nprn[0] =
'\0';
1527 results->
npcic[0] =
'\0';
1529 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1536 ast_debug(1,
"OSP: Unabe to find OSP provider '%s'\n", name);
1541 ast_debug(1,
"OSP: Unable to generate transaction handle\n");
1544 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1550 OSPPTransactionSetNetworkIds(results->
outhandle, snetid,
"");
1555 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1556 OSPPTransactionSetOperatorName(results->
outhandle, type, np->
opname[type]);
1560 OSPPTransactionSetDiversion(results->
outhandle, div->
user, host);
1562 if (cinfo != NULL) {
1565 OSPPTransactionSetCustomInfo(results->
outhandle, i, cinfo[i]);
1571 if((tmp = strchr(callednum,
';')) != NULL) {
1579 if (callidtypes & type) {
1582 callids[callidnum] = OSPPCallIdNew(callid.
len, callid.
buf);
1601 OSPPTransactionSetServiceType(results->
outhandle, OSPC_SERVICE_NPQUERY);
1603 preferred[0] = dest;
1607 OSPPTransactionSetServiceType(results->
outhandle, OSPC_SERVICE_VOICE);
1610 error = OSPPTransactionRequestAuthorisation(results->
outhandle,
1613 calling ? calling :
"",
1625 for (i = 0; i < callidnum; i++) {
1626 OSPPCallIdDelete(&callids[i]);
1629 if (error != OSPC_ERR_NO_ERROR) {
1633 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1639 ast_debug(1,
"OSP: No more destination\n");
1641 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1647 tokenlen =
sizeof(token);
1648 error = OSPPTransactionGetFirstDestination(results->
outhandle,
1659 sizeof(destination),
1665 if (error != OSPC_ERR_NO_ERROR) {
1666 ast_debug(1,
"OSP: Unable to get first route, error '%d'\n", error);
1670 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1678 ast_debug(1,
"OSP: calling '%s'\n", callingnum);
1679 ast_debug(1,
"OSP: called '%s'\n", callednum);
1680 ast_debug(1,
"OSP: destination '%s'\n", destination);
1681 ast_debug(1,
"OSP: token size '%d'\n", tokenlen);
1683 if ((res =
osp_check_destination(provider, callingnum, callednum, destination, tokenlen, token, &reason, results)) > 0) {
1688 ast_debug(1,
"OSP: No more destination\n");
1690 OSPPTransactionRecordFailure(results->
outhandle, reason);
1692 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1699 tokenlen =
sizeof(token);
1700 error = OSPPTransactionGetNextDestination(results->
outhandle,
1712 sizeof(destination),
1718 if (error == OSPC_ERR_NO_ERROR) {
1722 ast_debug(1,
"OSP: calling '%s'\n", callingnum);
1723 ast_debug(1,
"OSP: called '%s'\n", callednum);
1724 ast_debug(1,
"OSP: destination '%s'\n", destination);
1725 ast_debug(1,
"OSP: token size '%d'\n", tokenlen);
1727 if ((res =
osp_check_destination(provider, callingnum, callednum, destination, tokenlen, token, &reason, results)) > 0) {
1730 ast_debug(1,
"OSP: No more destination\n");
1731 OSPPTransactionRecordFailure(results->
outhandle, reason);
1733 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1739 ast_debug(1,
"OSP: Unable to get route, error '%d'\n", error);
1743 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1770 unsigned int tokenlen;
1772 OSPEFAILREASON reason;
1773 OSPE_OPERATOR_NAME
type;
1776 if (results == NULL) {
1781 results->
tech[0] =
'\0';
1782 results->
dest[0] =
'\0';
1784 results->
called[0] =
'\0';
1785 results->
token[0] =
'\0';
1787 results->
nprn[0] =
'\0';
1788 results->
npcic[0] =
'\0';
1790 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
1796 ast_debug(1,
"OSP: Unabe to find OSP provider '%s'\n", name);
1801 ast_debug(1,
"OSP: Transaction handle undefined\n");
1804 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1812 ast_debug(1,
"OSP: No more destination\n");
1813 OSPPTransactionRecordFailure(results->
outhandle, reason);
1815 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1822 tokenlen =
sizeof(token);
1823 error = OSPPTransactionGetNextDestination(
1842 if (error == OSPC_ERR_NO_ERROR) {
1846 ast_debug(1,
"OSP: calling '%s'\n", calling);
1847 ast_debug(1,
"OSP: called '%s'\n", called);
1848 ast_debug(1,
"OSP: destination '%s'\n", dest);
1849 ast_debug(1,
"OSP: token size '%d'\n", tokenlen);
1851 if ((res =
osp_check_destination(provider, calling, called, dest, tokenlen, token, &reason, results)) > 0) {
1855 ast_debug(1,
"OSP: No more destination\n");
1856 OSPPTransactionRecordFailure(results->
outhandle, reason);
1858 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
1864 ast_debug(1,
"OSP: Unable to get route, error '%d'\n", error);
1865 results->
token[0] =
'\0';
1869 OSPPTransactionRecordFailure(results->
inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
1891 if ((tmp = strchr(vstr,
'=')) != NULL) {
1893 if (sscanf(tmp,
"%30d", &value) != 1) {
1914 if ((tmp = strchr(vstr,
'=')) != NULL) {
1916 if (sscanf(tmp,
"%30f", &value) != 1) {
1976 for (item = strtok_r(buffer,
";", &tmp); item; item = strtok_r(NULL,
";", &tmp)) {
1977 if (!strncasecmp(item,
"rxcount", strlen(
"rxcount"))) {
1979 }
else if (!strncasecmp(item,
"txcount", strlen(
"txcount"))) {
1981 }
else if (!strncasecmp(item,
"lp", strlen(
"lp"))) {
1983 }
else if (!strncasecmp(item,
"minrxlost", strlen(
"minrxlost"))) {
1985 }
else if (!strncasecmp(item,
"maxrxlost", strlen(
"maxrxlost"))) {
1987 }
else if (!strncasecmp(item,
"avgrxlost", strlen(
"avgrxlost"))) {
1989 }
else if (!strncasecmp(item,
"stdevrxlost", strlen(
"stdevrxlost"))) {
1991 }
else if (!strncasecmp(item,
"rlp", strlen(
"rlp"))) {
1993 }
else if (!strncasecmp(item,
"reported_minlost", strlen(
"reported_minlost"))) {
1995 }
else if (!strncasecmp(item,
"reported_maxlost", strlen(
"reported_maxlost"))) {
1997 }
else if (!strncasecmp(item,
"reported_avglost", strlen(
"reported_avglost"))) {
1999 }
else if (!strncasecmp(item,
"reported_stdevlost", strlen(
"reported_stdevlost"))) {
2001 }
else if (!strncasecmp(item,
"rxjitter", strlen(
"rxjitter"))) {
2003 }
else if (!strncasecmp(item,
"minrxjitter", strlen(
"minrxjitter"))) {
2005 }
else if (!strncasecmp(item,
"maxrxjitter", strlen(
"maxrxjitter"))) {
2007 }
else if (!strncasecmp(item,
"avgrxjitter", strlen(
"avgjitter"))) {
2009 }
else if (!strncasecmp(item,
"stdevrxjitter", strlen(
"stdevjitter"))) {
2011 }
else if (!strncasecmp(item,
"txjitter", strlen(
"txjitter"))) {
2013 }
else if (!strncasecmp(item,
"reported_minjitter", strlen(
"reported_minjitter"))) {
2015 }
else if (!strncasecmp(item,
"reported_maxjitter", strlen(
"reported_maxjitter"))) {
2017 }
else if (!strncasecmp(item,
"reported_avgjitter", strlen(
"reported_avgjitter"))) {
2019 }
else if (!strncasecmp(item,
"reported_stdevjitter", strlen(
"reported_stdevjitter"))) {
2021 }
else if (!strncasecmp(item,
"rtt", strlen(
"rtt"))) {
2023 }
else if (!strncasecmp(item,
"minrtt", strlen(
"minrtt"))) {
2025 }
else if (!strncasecmp(item,
"maxrtt", strlen(
"maxrtt"))) {
2027 }
else if (!strncasecmp(item,
"avgrtt", strlen(
"avgrtt"))) {
2029 }
else if (!strncasecmp(item,
"stdevrtt", strlen(
"stdevrtt"))) {
2034 ast_debug(1,
"OSP: call leg '%d'\n", leg);
2037 ast_debug(1,
"OSP: lp '%d'\n",lost[OSP_DIR_RX].value);
2038 ast_debug(1,
"OSP: minrxlost '%f'\n", lost[OSP_DIR_RX].
min);
2039 ast_debug(1,
"OSP: maxrxlost '%f'\n", lost[OSP_DIR_RX].
max);
2040 ast_debug(1,
"OSP: avgrxlost '%f'\n", lost[OSP_DIR_RX].
avg);
2041 ast_debug(1,
"OSP: stdevrxlost '%f'\n", lost[OSP_DIR_RX].
sdev);
2042 ast_debug(1,
"OSP: rlp '%d'\n", lost[OSP_DIR_TX].value);
2043 ast_debug(1,
"OSP: reported_minlost '%f'\n", lost[OSP_DIR_TX].min);
2044 ast_debug(1,
"OSP: reported_maxlost '%f'\n", lost[OSP_DIR_TX].max);
2045 ast_debug(1,
"OSP: reported_avglost '%f'\n", lost[OSP_DIR_TX].avg);
2046 ast_debug(1,
"OSP: reported_stdevlost '%f'\n", lost[OSP_DIR_TX].sdev);
2047 ast_debug(1,
"OSP: rxjitter '%d'\n", jitter[OSP_DIR_RX].value);
2048 ast_debug(1,
"OSP: minrxjitter '%f'\n", jitter[OSP_DIR_RX].min);
2049 ast_debug(1,
"OSP: maxrxjitter '%f'\n", jitter[OSP_DIR_RX].max);
2050 ast_debug(1,
"OSP: avgrxjitter '%f'\n", jitter[OSP_DIR_RX].avg);
2051 ast_debug(1,
"OSP: stdevrxjitter '%f'\n", jitter[OSP_DIR_RX].sdev);
2052 ast_debug(1,
"OSP: txjitter '%d'\n", jitter[OSP_DIR_TX].value);
2053 ast_debug(1,
"OSP: reported_minjitter '%f'\n", jitter[OSP_DIR_TX].min);
2054 ast_debug(1,
"OSP: reported_maxjitter '%f'\n", jitter[OSP_DIR_TX].max);
2055 ast_debug(1,
"OSP: reported_avgjitter '%f'\n", jitter[OSP_DIR_TX].avg);
2056 ast_debug(1,
"OSP: reported_stdevjitter '%f'\n", jitter[OSP_DIR_TX].sdev);
2064 OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTP, OSPC_SFLOW_DOWNSTREAM, totalpackets[OSP_DIR_RX]);
2065 OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTCP, OSPC_SFLOW_UPSTREAM, totalpackets[OSP_DIR_TX]);
2066 if (lost[OSP_DIR_RX].value >= 0) {
2069 value = (int)lost[OSP_DIR_RX].avg;
2071 OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTP, OSPC_SFLOW_DOWNSTREAM, value,
OSP_DEF_INTSTATS);
2072 if (lost[OSP_DIR_TX].value >= 0) {
2075 value = (int)lost[OSP_DIR_TX].avg;
2077 OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTCP, OSPC_SFLOW_UPSTREAM, value,
OSP_DEF_INTSTATS);
2078 if (jitter[OSP_DIR_RX].value >= 0) {
2081 value = (int)jitter[OSP_DIR_RX].avg;
2083 OSPPTransactionSetJitter(trans,
2085 OSPC_SFLOW_DOWNSTREAM,
2087 (
int)jitter[OSP_DIR_RX].min,
2088 (
int)jitter[OSP_DIR_RX].max,
2089 value, jitter[OSP_DIR_RX].sdev);
2090 if (jitter[OSP_DIR_TX].value >= 0) {
2093 value = (int)jitter[OSP_DIR_TX].avg;
2095 OSPPTransactionSetJitter(trans, OSPC_SMETRIC_RTCP, OSPC_SFLOW_UPSTREAM,
2096 OSP_DEF_INTSTATS, (
int)jitter[OSP_DIR_TX].min, (
int)jitter[OSP_DIR_TX].max, value, jitter[OSP_DIR_TX].sdev);
2098 OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTP, OSPC_SFLOW_UPSTREAM, totalpackets[OSP_DIR_RX]);
2099 OSPPTransactionSetPackets(trans, OSPC_SMETRIC_RTCP, OSPC_SFLOW_DOWNSTREAM, totalpackets[OSP_DIR_TX]);
2100 OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTP, OSPC_SFLOW_UPSTREAM, lost[OSP_DIR_RX].value,
OSP_DEF_INTSTATS);
2101 OSPPTransactionSetLost(trans, OSPC_SMETRIC_RTCP, OSPC_SFLOW_DOWNSTREAM, lost[OSP_DIR_TX].value,
OSP_DEF_INTSTATS);
2102 if (jitter[OSP_DIR_RX].value >= 0) {
2105 value = (int)jitter[OSP_DIR_RX].avg;
2107 OSPPTransactionSetJitter(trans,
2109 OSPC_SFLOW_UPSTREAM,
2111 (
int)jitter[OSP_DIR_RX].min,
2112 (
int)jitter[OSP_DIR_RX].max,
2114 jitter[OSP_DIR_RX].sdev);
2115 if (jitter[OSP_DIR_TX].value >= 0) {
2118 value = (int)jitter[OSP_DIR_TX].avg;
2120 OSPPTransactionSetJitter(trans,
2122 OSPC_SFLOW_DOWNSTREAM,
2124 (
int)jitter[OSP_DIR_TX].min,
2125 (
int)jitter[OSP_DIR_TX].max,
2127 jitter[OSP_DIR_TX].sdev);
2129 if (rtt.
value >= 0) {
2132 value = (int)rtt.
avg;
2162 unsigned int release,
2167 OSPEFAILREASON reason;
2169 unsigned isPddInfoPresent = 0;
2171 unsigned int dummy = 0;
2180 OSPPTransactionRecordFailure(trans, reason);
2186 error = OSPPTransactionReportUsage(trans,
2187 difftime(end, connect),
2202 if (error == OSPC_ERR_NO_ERROR) {
2206 ast_debug(1,
"OSP: Unable to report usage, error '%d'\n", error);
2209 OSPPTransactionDelete(trans);
2230 const char* source =
"";
2231 const char* token =
"";
2233 unsigned int timelimit;
2248 provider =
args.provider;
2250 ast_debug(1,
"OSPAuth: provider '%s'\n", provider);
2254 if (!strcasecmp(
ast_var_name(current),
"OSPINPEERIP")) {
2256 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINTOKEN")) {
2261 ast_debug(1,
"OSPAuth: source '%s'\n", source);
2262 ast_debug(1,
"OSPAuth: token size '%zd'\n", strlen(token));
2264 res =
osp_auth(provider, &handle, source,
2266 chan->
exten, token, &timelimit);
2278 snprintf(buffer,
sizeof(buffer),
"%d", handle);
2280 ast_debug(1,
"OSPAuth: OSPINHANDLE '%s'\n", buffer);
2281 snprintf(buffer,
sizeof(buffer),
"%d", timelimit);
2283 ast_debug(1,
"OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
2311 const char* actualsrc =
"";
2312 const char* srcdev =
"";
2313 const char* snetid =
"";
2315 OSPE_OPERATOR_NAME
type;
2331 ast_log(
LOG_WARNING,
"OSPLookup: Arg required, OSPLookup(exten[,provider[,options]])\n");
2342 provider =
args.provider;
2344 ast_debug(1,
"OSPlookup: provider '%s'\n", provider);
2347 if (strchr(
args.options,
'h')) {
2350 if (strchr(
args.options,
's')) {
2353 if (strchr(
args.options,
'i')) {
2357 ast_debug(1,
"OSPLookup: call id types '%d'\n", callidtypes);
2361 results.
dest[0] =
'\0';
2366 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2375 if (!strcasecmp(
ast_var_name(current),
"OSPINACTUALSRC")) {
2377 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINPEERIP")) {
2379 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINHANDLE")) {
2383 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINTIMELIMIT")) {
2387 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINNETWORKID")) {
2389 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINNPRN")) {
2391 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINNPCIC")) {
2393 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINNPDI")) {
2397 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINSPID")) {
2399 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINOCN")) {
2401 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINSPN")) {
2403 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINALTSPN")) {
2405 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINMCC")) {
2407 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINMNC")) {
2409 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINTOHOST")) {
2411 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINDIVUSER")) {
2413 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINDIVHOST")) {
2415 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO1")) {
2417 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO2")) {
2419 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO3")) {
2421 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO4")) {
2423 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO5")) {
2425 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO6")) {
2427 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO7")) {
2429 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINCUSTOMINFO8")) {
2433 ast_debug(1,
"OSPLookup: actual source device '%s'\n", actualsrc);
2434 ast_debug(1,
"OSPLookup: source device '%s'\n", srcdev);
2437 ast_debug(1,
"OSPLookup: OSPINNETWORKID '%s'\n", snetid);
2438 ast_debug(1,
"OSPLookup: OSPINNPRN '%s'\n", np.
rn);
2441 ast_debug(1,
"OSPLookup: OSPINSPID '%s'\n", np.
opname[OSPC_OPNAME_SPID]);
2442 ast_debug(1,
"OSPLookup: OSPINOCN '%s'\n", np.
opname[OSPC_OPNAME_OCN]);
2443 ast_debug(1,
"OSPLookup: OSPINSPN '%s'\n", np.
opname[OSPC_OPNAME_SPN]);
2444 ast_debug(1,
"OSPLookup: OSPINALTSPN '%s'\n", np.
opname[OSPC_OPNAME_ALTSPN]);
2445 ast_debug(1,
"OSPLookup: OSPINMCC '%s'\n", np.
opname[OSPC_OPNAME_MCC]);
2446 ast_debug(1,
"OSPLookup: OSPINMNC '%s'\n", np.
opname[OSPC_OPNAME_MNC]);
2447 ast_debug(1,
"OSPLookup: OSPINTOHOST '%s'\n", results.
dest);
2452 ast_debug(1,
"OSPLookup: OSPINCUSTOMINFO%d '%s'\n", i, cinfo[i]);
2460 res =
osp_lookup(provider, callidtypes, actualsrc, srcdev,
2462 args.exten, snetid, &np, &div, cinfo, &results);
2466 results.
tech[0] =
'\0';
2467 results.
dest[0] =
'\0';
2469 results.
called[0] =
'\0';
2470 results.
token[0] =
'\0';
2472 results.
nprn[0] =
'\0';
2473 results.
npcic[0] =
'\0';
2475 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2489 snprintf(buffer,
sizeof(buffer),
"%d", results.
outhandle);
2491 ast_debug(1,
"OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
2495 ast_debug(1,
"OSPLookup: OSPDESTINATION '%s'\n", results.
dest);
2506 snprintf(buffer,
sizeof(buffer),
"%d", results.
npdi);
2508 ast_debug(1,
"OSPLookup: OSPOUTNPDI'%s'\n", buffer);
2510 ast_debug(1,
"OSPLookup: OSPOUTSPID '%s'\n", results.
opname[OSPC_OPNAME_SPID]);
2512 ast_debug(1,
"OSPLookup: OSPOUTOCN '%s'\n", results.
opname[OSPC_OPNAME_OCN]);
2514 ast_debug(1,
"OSPLookup: OSPOUTSPN '%s'\n", results.
opname[OSPC_OPNAME_SPN]);
2516 ast_debug(1,
"OSPLookup: OSPOUTALTSPN '%s'\n", results.
opname[OSPC_OPNAME_ALTSPN]);
2518 ast_debug(1,
"OSPLookup: OSPOUTMCC '%s'\n", results.
opname[OSPC_OPNAME_MCC]);
2520 ast_debug(1,
"OSPLookup: OSPOUTMNC '%s'\n", results.
opname[OSPC_OPNAME_MNC]);
2522 ast_debug(1,
"OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(results.
token));
2523 snprintf(buffer,
sizeof(buffer),
"%d", results.
numdests);
2525 ast_debug(1,
"OSPLookup: OSPDESTREMAILS '%s'\n", buffer);
2526 snprintf(buffer,
sizeof(buffer),
"%d", results.
outtimelimit);
2528 ast_debug(1,
"OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
2529 snprintf(buffer,
sizeof(buffer),
"%d", callidtypes);
2531 ast_debug(1,
"OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
2533 ast_debug(1,
"OSPLookup: %s\n", status);
2536 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
tech, results.
called, results.
dest);
2541 ast_debug(1,
"OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
2550 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
tech, results.
called, results.
dest);
2553 snprintf(buffer,
sizeof(buffer),
"%s/%s/%s", results.
tech, results.
dest, results.
called);
2556 snprintf(buffer,
sizeof(buffer),
"%s/%s", results.
tech, results.
called);
2589 OSPE_OPERATOR_NAME
type;
2602 ast_log(
LOG_WARNING,
"OSPNext: Arg required, OSPNext(cause[,provider[,options]])\n");
2613 ast_debug(1,
"OSPNext: cause '%d'\n", cause);
2616 provider =
args.provider;
2618 ast_debug(1,
"OSPlookup: provider '%s'\n", provider);
2627 if (!strcasecmp(
ast_var_name(current),
"OSPINHANDLE")) {
2631 }
else if (!strcasecmp(
ast_var_name(current),
"OSPOUTHANDLE")) {
2635 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINTIMELIMIT")) {
2639 }
else if (!strcasecmp(
ast_var_name(current),
"OSPOUTCALLIDTYPES")) {
2640 if (sscanf(
ast_var_value(current),
"%30d", &callidtypes) != 1) {
2643 }
else if (!strcasecmp(
ast_var_name(current),
"OSPDESTREMAILS")) {
2652 ast_debug(1,
"OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
2655 if ((res =
osp_next(provider, cause, &results)) > 0) {
2658 results.
tech[0] =
'\0';
2659 results.
dest[0] =
'\0';
2661 results.
called[0] =
'\0';
2662 results.
token[0] =
'\0';
2664 results.
nprn[0] =
'\0';
2665 results.
npcic[0] =
'\0';
2667 for (type = OSPC_OPNAME_START; type < OSPC_OPNAME_NUMBER; type++) {
2684 ast_debug(1,
"OSPNext: OSPDESTINATION '%s'\n", results.
dest);
2695 snprintf(buffer,
sizeof(buffer),
"%d", results.
npdi);
2697 ast_debug(1,
"OSPLookup: OSPOUTNPDI'%s'\n", buffer);
2699 ast_debug(1,
"OSPLookup: OSPOUTSPID '%s'\n", results.
opname[OSPC_OPNAME_SPID]);
2701 ast_debug(1,
"OSPLookup: OSPOUTOCN '%s'\n", results.
opname[OSPC_OPNAME_OCN]);
2703 ast_debug(1,
"OSPLookup: OSPOUTSPN '%s'\n", results.
opname[OSPC_OPNAME_SPN]);
2705 ast_debug(1,
"OSPLookup: OSPOUTALTSPN '%s'\n", results.
opname[OSPC_OPNAME_ALTSPN]);
2707 ast_debug(1,
"OSPLookup: OSPOUTMCC '%s'\n", results.
opname[OSPC_OPNAME_MCC]);
2709 ast_debug(1,
"OSPLookup: OSPOUTMNC '%s'\n", results.
opname[OSPC_OPNAME_MNC]);
2711 ast_debug(1,
"OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(results.
token));
2712 snprintf(buffer,
sizeof(buffer),
"%d", results.
numdests);
2714 ast_debug(1,
"OSPNext: OSPDESTREMAILS '%s'\n", buffer);
2715 snprintf(buffer,
sizeof(buffer),
"%d", results.
outtimelimit);
2717 ast_debug(1,
"OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
2722 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
tech, results.
called, results.
dest);
2727 ast_debug(1,
"OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
2736 snprintf(buffer,
sizeof(buffer),
"%s/%s@%s", results.
tech, results.
called, results.
dest);
2739 snprintf(buffer,
sizeof(buffer),
"%s/%s/%s", results.
tech, results.
dest, results.
called);
2742 snprintf(buffer,
sizeof(buffer),
"%s/%s", results.
tech, results.
called);
2772 time_t start, connect, end;
2773 unsigned int release;
2791 if (!strcasecmp(
ast_var_name(current),
"OSPINHANDLE")) {
2792 if (sscanf(
ast_var_value(current),
"%30d", &inhandle) != 1) {
2795 }
else if (!strcasecmp(
ast_var_name(current),
"OSPOUTHANDLE")) {
2796 if (sscanf(
ast_var_value(current),
"%30d", &outhandle) != 1) {
2799 }
else if (!recorded &&
2800 (!strcasecmp(
ast_var_name(current),
"OSPAUTHSTATUS") ||
2801 !strcasecmp(
ast_var_name(current),
"OSPLOOKUPSTATUS") ||
2807 }
else if (!strcasecmp(
ast_var_name(current),
"OSPINAUDIOQOS")) {
2809 }
else if (!strcasecmp(
ast_var_name(current),
"OSPOUTAUDIOQOS")) {
2813 ast_debug(1,
"OSPFinish: OSPINHANDLE '%d'\n", inhandle);
2814 ast_debug(1,
"OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
2815 ast_debug(1,
"OSPFinish: recorded '%d'\n", recorded);
2816 ast_debug(1,
"OSPFinish: OSPINAUDIOQOS '%s'\n", inqos);
2817 ast_debug(1,
"OSPFinish: OSPOUTAUDIOQOS '%s'\n", outqos);
2822 ast_debug(1,
"OSPFinish: cause '%d'\n", cause);
2837 ast_debug(1,
"OSPFinish: start '%ld'\n", start);
2838 ast_debug(1,
"OSPFinish: connect '%ld'\n", connect);
2839 ast_debug(1,
"OSPFinish: end '%ld'\n", end);
2843 if (
osp_finish(outhandle, recorded, cause, start, connect, end, release, inqos, outqos) <= 0) {
2844 ast_debug(1,
"OSPFinish: Unable to report usage for outbound call\n");
2853 if (
osp_finish(inhandle, recorded, cause, start, connect, end, release, inqos, outqos) <= 0) {
2854 ast_debug(1,
"OSPFinish: Unable to report usage for inbound call\n");
2885 if (osp_initialized) {
2887 for (provider = osp_providers; provider; provider =
next) {
2888 next = provider->
next;
2889 OSPPProviderDelete(provider->
handle, 0);
2892 osp_providers = NULL;
2897 osp_tokenformat = TOKEN_ALGO_SIGNED;
2900 osp_initialized = 0;
2912 int error = OSPC_ERR_NO_ERROR;
2927 if ((error = OSPPInit(1)) != OSPC_ERR_NO_ERROR) {
2936 ast_debug(1,
"OSP: osp_hardware '%d'\n", osp_hardware);
2941 ast_debug(1,
"OSP: osp_security '%d'\n", osp_security);
2944 if ((sscanf(cvar,
"%30d", &ivar) == 1) &&
2945 ((ivar == TOKEN_ALGO_SIGNED) || (ivar == TOKEN_ALGO_UNSIGNED) || (ivar == TOKEN_ALGO_BOTH)))
2947 osp_tokenformat = ivar;
2949 ast_log(
LOG_WARNING,
"tokenformat should be an integer from %d, %d or %d, not '%s'\n",
2950 TOKEN_ALGO_SIGNED, TOKEN_ALGO_UNSIGNED, TOKEN_ALGO_BOTH, cvar);
2953 ast_debug(1,
"OSP: osp_tokenformat '%d'\n", osp_tokenformat);
2961 osp_initialized = 1;
2968 ast_debug(1,
"OSP: osp_initialized '%d'\n", osp_initialized);
2978 const char*
name = NULL;
2979 const char* tokenalgo;
2986 " Displays information on Open Settlement Protocol support\n";
2992 if ((a->
argc < 2) || (a->
argc > 3)) {
3001 switch (osp_tokenformat) {
3002 case TOKEN_ALGO_BOTH:
3005 case TOKEN_ALGO_UNSIGNED:
3006 tokenalgo =
"Unsigned";
3008 case TOKEN_ALGO_SIGNED:
3010 tokenalgo =
"Signed";
3014 osp_initialized ?
"Initialized" :
"Uninitialized",
3015 osp_hardware ?
"Accelerated" :
"Normal",
3016 osp_security ?
"Enabled" :
"Disabled",
3021 for (provider = osp_providers; provider; provider = provider->
next) {
3022 if (!name || !strcasecmp(provider->
name, name)) {
3026 ast_cli(a->
fd,
" == OSP Provider '%s' == \n", provider->
name);
3030 for (i = 0; i < provider->
canum; i++) {
3034 for (i = 0; i < provider->
spnum; i++) {
3054 ast_cli(a->
fd,
"Unable to find OSP provider '%s'\n", name);
3056 ast_cli(a->
fd,
"No OSP providers configured\n");
3064 static const char app1[] =
"OSPAuth";
3067 static const char app2[] =
"OSPLookup";
3070 static const char app3[] =
"OSPNext";
3073 static const char app4[] =
"OSPFinish";
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,...)
char * str
Subscriber phone number (Malloced)
static int osp_unload(void)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
#define OSP_MAX_RETRYDELAY
struct ast_party_caller caller
Channel Caller ID information.
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.
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_diversion *div, const char *cinfo[], struct osp_results *results)
OSP Lookup function.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define OSP_DEF_MAXCONNECT
enum osp_authpolicy authpolicy
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
descriptor for a cli entry.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
static void dummy(char *unused,...)
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 AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Structure for variables, used for configurations and for channel variables.
char dest[OSP_SIZE_NORSTR]
Configuration File Parser.
#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)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
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 nprn[OSP_SIZE_NORSTR]
void ast_config_destroy(struct ast_config *config)
Destroys a config.
char name[OSP_SIZE_NORSTR]
struct ast_party_id id
Caller party ID.
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.
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.
#define ast_config_load(filename, flags)
Load a config file.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char localcert[OSP_SIZE_NORSTR]
char calling[OSP_SIZE_NORSTR]
#define AST_CAUSE_NORMAL_CLEARING
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
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.
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.
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.
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 ast_strdupa(s)
duplicate a string in memory from the stack
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]
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static int load_module(void)
#define OSP_MAX_MAXCONNECT
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
char cacerts[OSP_MAX_CERTS][OSP_SIZE_NORSTR]
struct ast_var_t::@158 entries
enum osp_workmode workmode
char privatekey[OSP_SIZE_NORSTR]
#define OSP_DEF_TIMELIMIT
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.
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]
char tech[OSP_SIZE_TECHSTR]
#define OSP_MAX_CUSTOMINFO
static int osp_create_callid(unsigned int type, struct osp_callid *callid)
Create a call ID according to the type.
Open Settlement Protocol (OSP)
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.
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
#define OSP_MIN_RETRYLIMIT
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Internal Asterisk hangup causes.
char called[OSP_SIZE_NORSTR]
struct osp_provider * next
#define OSP_CALLID_MAXNUM
#define OSP_MIN_RETRYDELAY
#define AST_APP_ARG(name)
Define an application argument.
struct ast_variable * next
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
unsigned char buf[OSP_SIZE_NORSTR]
#define CONFIG_STATUS_FILEINVALID
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 ast_mutex_t osp_lock
unsigned char valid
TRUE if the number information is valid/present.
char exten[AST_MAX_EXTENSION]
#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 ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define OSP_MAX_RETRYLIMIT
#define CONFIG_STATUS_FILEUNCHANGED
static char * handle_cli_osp_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_mutex_unlock(a)
struct ast_party_number number
Subscriber phone number.
const char * opname[OSPC_OPNAME_NUMBER]