summaryrefslogtreecommitdiff
path: root/res/res_hep_pjsip.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-03-21 07:59:12 -0400
committerSean Bright <sean.bright@gmail.com>2017-03-21 13:40:29 -0600
commitd4fcf196a20b3141a10c0cd5b84f09b367e8f7e3 (patch)
tree1954a3c6d921d3c1c1eb9146bcd719c9d4c7fc74 /res/res_hep_pjsip.c
parentf5603cb1ece5001d1288004c9bc6ed51448deb81 (diff)
res_hep: Capture actual transport type in use
Rather than hard-coding UDP, allow consumers of the HEP API to specify which protocol is in use. Update the PJSIP provider to pass in the current protocol type. ASTERISK-26850 #close Change-Id: I54bbb0a001cfe4c6a87ad4b6f2014af233349978
Diffstat (limited to 'res/res_hep_pjsip.c')
-rw-r--r--res/res_hep_pjsip.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/res/res_hep_pjsip.c b/res/res_hep_pjsip.c
index 358cbc934..13efbfa6a 100644
--- a/res/res_hep_pjsip.c
+++ b/res/res_hep_pjsip.c
@@ -71,6 +71,15 @@ static char *assign_uuid(const pj_str_t *call_id, const pj_str_t *local_tag, con
return uuid;
}
+static int transport_to_protocol_id(pjsip_transport *tp)
+{
+ /* XXX If we ever add SCTP support, we'll need to revisit */
+ if (tp->flag & PJSIP_TRANSPORT_RELIABLE) {
+ return IPPROTO_TCP;
+ }
+ return IPPROTO_UDP;
+}
+
static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
{
char local_buf[256];
@@ -124,6 +133,7 @@ static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
ast_sockaddr_parse(&capture_info->src_addr, local_buf, PARSE_PORT_REQUIRE);
ast_sockaddr_parse(&capture_info->dst_addr, remote_buf, PARSE_PORT_REQUIRE);
+ capture_info->protocol_id = transport_to_protocol_id(tdata->tp_info.transport);
capture_info->capture_time = ast_tvnow();
capture_info->capture_type = HEPV3_CAPTURE_TYPE_SIP;
capture_info->uuid = uuid;
@@ -183,6 +193,8 @@ static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata)
ast_sockaddr_parse(&capture_info->src_addr, remote_buf, PARSE_PORT_REQUIRE);
ast_sockaddr_parse(&capture_info->dst_addr, local_buf, PARSE_PORT_REQUIRE);
+
+ capture_info->protocol_id = transport_to_protocol_id(rdata->tp_info.transport);
capture_info->capture_time.tv_sec = rdata->pkt_info.timestamp.sec;
capture_info->capture_time.tv_usec = rdata->pkt_info.timestamp.msec * 1000;
capture_info->capture_type = HEPV3_CAPTURE_TYPE_SIP;