summaryrefslogtreecommitdiff
path: root/res/res_pjsip/security_events.c
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2013-09-26 18:51:54 +0000
committerKevin Harwell <kharwell@digium.com>2013-09-26 18:51:54 +0000
commit103ebcf807cb9050ad3653c606cb8cf07c36850f (patch)
tree0b2385b16e999ff3dd5f9feeaa6e21c41f0f153a /res/res_pjsip/security_events.c
parent1df1ebdc379d46545c35f1abdff6b100f0c4bcac (diff)
pjsip: race condition in registrar
While handling a registration request a race condition could occur if/when two+ clients registered at the same time. This happened when one request obtained a copy of the current contacts for an AOR and another request did the same before the first request updated. Thus the second would update and overwrite the first (or vice-versa depending on which actually updated first). In the case of it being the same contact two "add" events would be raised. pjsip registration handling is now serialized to alleviate this issue. (closes issue AST-1213) Reported by: John Bigelow Review: https://reviewboard.asterisk.org/r/2860/ ........ Merged revisions 399897 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399898 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip/security_events.c')
-rw-r--r--res/res_pjsip/security_events.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/res/res_pjsip/security_events.c b/res/res_pjsip/security_events.c
index 7b4913753..6bdb6cb39 100644
--- a/res/res_pjsip/security_events.c
+++ b/res/res_pjsip/security_events.c
@@ -232,3 +232,59 @@ void ast_sip_report_auth_challenge_sent(struct ast_sip_endpoint *endpoint, pjsip
ast_security_event_report(AST_SEC_EVT(&chal_sent));
}
+
+void ast_sip_report_req_no_support(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata,
+ const char* req_type)
+{
+ enum ast_transport transport = security_event_get_transport(rdata);
+ char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
+ struct ast_sockaddr local, remote;
+
+ struct ast_security_event_req_no_support req_no_support_event = {
+ .common.event_type = AST_SECURITY_EVENT_REQ_NO_SUPPORT,
+ .common.version = AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION,
+ .common.service = "PJSIP",
+ .common.account_id = ast_sorcery_object_get_id(endpoint),
+ .common.local_addr = {
+ .addr = &local,
+ .transport = transport,
+ },
+ .common.remote_addr = {
+ .addr = &remote,
+ .transport = transport,
+ },
+ .common.session_id = call_id,
+ .request_type = req_type
+ };
+
+ security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
+
+ ast_security_event_report(AST_SEC_EVT(&req_no_support_event));
+}
+
+void ast_sip_report_mem_limit(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
+{
+ enum ast_transport transport = security_event_get_transport(rdata);
+ char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
+ struct ast_sockaddr local, remote;
+
+ struct ast_security_event_mem_limit mem_limit_event = {
+ .common.event_type = AST_SECURITY_EVENT_MEM_LIMIT,
+ .common.version = AST_SECURITY_EVENT_MEM_LIMIT_VERSION,
+ .common.service = "PJSIP",
+ .common.account_id = ast_sorcery_object_get_id(endpoint),
+ .common.local_addr = {
+ .addr = &local,
+ .transport = transport,
+ },
+ .common.remote_addr = {
+ .addr = &remote,
+ .transport = transport,
+ },
+ .common.session_id = call_id
+ };
+
+ security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
+
+ ast_security_event_report(AST_SEC_EVT(&mem_limit_event));
+}