* Validate OSP token * param ignore1 * param ignore2 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure MODULE_RETURNCODE_ERROR error */
| 69 | * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure MODULE_RETURNCODE_ERROR error |
| 70 | */ |
| 71 | int ospValidateHeader( |
| 72 | struct sip_msg* msg, |
| 73 | char* ignore1, |
| 74 | char* ignore2) |
| 75 | { |
| 76 | int errorcode; |
| 77 | OSPTTRANHANDLE transaction = -1; |
| 78 | unsigned int authorized = 0; |
| 79 | unsigned int timelimit = 0; |
| 80 | void* detaillog = NULL; |
| 81 | unsigned int logsize = 0; |
| 82 | unsigned char* callidval = (unsigned char*)""; |
| 83 | OSPT_CALL_ID* callid = NULL; |
| 84 | unsigned callidsize = 0; |
| 85 | unsigned char token[OSP_TOKENBUF_SIZE]; |
| 86 | unsigned int tokensize = sizeof(token); |
| 87 | osp_inbound inbound; |
| 88 | osp_dest dest; |
| 89 | int result = MODULE_RETURNCODE_FALSE; |
| 90 | |
| 91 | ospInitInboundInfo(&inbound); |
| 92 | ospInitDestination(&dest); |
| 93 | |
| 94 | if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction)) != OSPC_ERR_NO_ERROR) { |
| 95 | LM_ERR("failed to create a new OSP transaction handle (%d)\n", errorcode); |
| 96 | } else if (ospGetFromUser(msg, dest.calling, sizeof(dest.calling)) != 0) { |
| 97 | LM_ERR("failed to extract calling number\n"); |
| 98 | } else if ((ospGetUriUser(msg, dest.called, sizeof(dest.called)) != 0) && (ospGetToUser(msg, dest.called, sizeof(dest.called)) != 0)) { |
| 99 | LM_ERR("failed to extract called number\n"); |
| 100 | } else if (ospGetCallId(msg, &callid) != 0) { |
| 101 | LM_ERR("failed to extract call id\n"); |
| 102 | } else if (ospGetViaAddress(msg, inbound.source, sizeof(inbound.source)) != 0) { |
| 103 | LM_ERR("failed to extract source device address\n"); |
| 104 | } else if (ospGetOspToken(msg, token, &tokensize) != 0) { |
| 105 | LM_ERR("failed to extract OSP authorization token\n"); |
| 106 | } else { |
| 107 | LM_INFO("validate token for: " |
| 108 | "transaction_handle '%d' " |
| 109 | "e164_source '%s' " |
| 110 | "e164_dest '%s' " |
| 111 | "validate_call_id '%s' " |
| 112 | "call_id '%.*s'\n", |
| 113 | transaction, |
| 114 | dest.calling, |
| 115 | dest.called, |
| 116 | _osp_validate_callid == 0 ? "No" : "Yes", |
| 117 | callid->Length, |
| 118 | callid->Value); |
| 119 | |
| 120 | if (_osp_validate_callid != 0) { |
| 121 | callidsize = callid->Length; |
| 122 | callidval = callid->Value; |
| 123 | } |
| 124 | |
| 125 | errorcode = OSPPTransactionValidateAuthorisation( |
| 126 | transaction, |
| 127 | "", |
| 128 | "", |
nothing calls this directly
no test coverage detected