MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / ospValidateHeader

Function ospValidateHeader

modules/osp/term_transaction.c:71–195  ·  view source on GitHub ↗

* Validate OSP token * param ignore1 * param ignore2 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure MODULE_RETURNCODE_ERROR error */

Source from the content-addressed store, hash-verified

69 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure MODULE_RETURNCODE_ERROR error
70 */
71int 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 "",

Callers

nothing calls this directly

Calls 12

ospInitInboundInfoFunction · 0.85
ospInitDestinationFunction · 0.85
ospGetFromUserFunction · 0.85
ospGetUriUserFunction · 0.85
ospGetToUserFunction · 0.85
ospGetCallIdFunction · 0.85
ospGetViaAddressFunction · 0.85
ospGetOspTokenFunction · 0.85
ospGetTransactionIdFunction · 0.85
ospSaveTermDestinationFunction · 0.85
ospRecordEventFunction · 0.85
ospRecordTermTransactionFunction · 0.85

Tested by

no test coverage detected