47static char *
assign_uuid(
const pj_str_t *call_id,
const pj_str_t *local_tag,
const pj_str_t *remote_tag)
55 && (dlg = pjsip_ua_find_dialog(call_id, local_tag, remote_tag, PJ_FALSE))
77 if (tp->flag & PJSIP_TRANSPORT_RELIABLE) {
89 pjsip_cid_hdr *cid_hdr;
90 pjsip_from_hdr *from_hdr;
98 if (!(tdata->tp_info.transport->flag & PJSIP_TRANSPORT_RELIABLE)) {
99 pjsip_tpmgr_fla2_param prm;
102 pjsip_tpmgr_fla2_param_default(&prm);
103 prm.tp_type = tdata->tp_info.transport->key.type;
104 pj_strset2(&prm.dst_host, tdata->tp_info.dst_name);
105 prm.local_if = PJ_TRUE;
109 pj_sockaddr_print(&tdata->tp_info.transport->local_addr, local_buf,
sizeof(local_buf), 3);
111 if (prm.tp_type & PJSIP_TRANSPORT_IPV6) {
112 snprintf(local_buf,
sizeof(local_buf),
"[%.*s]:%hu",
113 (
int)pj_strlen(&prm.ret_addr),
114 pj_strbuf(&prm.ret_addr),
117 snprintf(local_buf,
sizeof(local_buf),
"%.*s:%hu",
118 (
int)pj_strlen(&prm.ret_addr),
119 pj_strbuf(&prm.ret_addr),
127 pj_sockaddr_print(&tdata->tp_info.transport->local_addr, local_buf,
sizeof(local_buf), 3);
130 pj_sockaddr_print(&tdata->tp_info.dst_addr, remote_buf,
sizeof(remote_buf), 3);
132 cid_hdr = PJSIP_MSG_CID_HDR(tdata->msg);
133 from_hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
134 to_hdr = PJSIP_MSG_TO_HDR(tdata->msg);
159 char remote_buf[256];
168 if (!rdata->pkt_info.src_addr_len) {
171 pj_sockaddr_print(&rdata->pkt_info.src_addr, remote_buf,
sizeof(remote_buf), 3);
173 if (!(rdata->tp_info.transport->flag & PJSIP_TRANSPORT_RELIABLE)) {
174 pjsip_tpmgr_fla2_param prm;
177 pjsip_tpmgr_fla2_param_default(&prm);
178 prm.tp_type = rdata->tp_info.transport->key.type;
179 pj_strset2(&prm.dst_host, rdata->pkt_info.src_name);
180 prm.local_if = PJ_TRUE;
183 if (pjsip_tpmgr_find_local_addr2(pjsip_endpt_get_tpmgr(
ast_sip_get_pjsip_endpoint()), rdata->tp_info.pool, &prm) != PJ_SUCCESS) {
184 pj_sockaddr_print(&rdata->tp_info.transport->local_addr, local_buf,
sizeof(local_buf), 3);
186 if (prm.tp_type & PJSIP_TRANSPORT_IPV6) {
187 snprintf(local_buf,
sizeof(local_buf),
"[%.*s]:%hu",
188 (
int)pj_strlen(&prm.ret_addr),
189 pj_strbuf(&prm.ret_addr),
192 snprintf(local_buf,
sizeof(local_buf),
"%.*s:%hu",
193 (
int)pj_strlen(&prm.ret_addr),
194 pj_strbuf(&prm.ret_addr),
199 pj_sockaddr_print(&rdata->tp_info.transport->local_addr, local_buf,
sizeof(local_buf), 3);
202 uuid =
assign_uuid(&rdata->msg_info.cid->id, &rdata->msg_info.to->tag, &rdata->msg_info.from->tag);
212 capture_info->
capture_time.tv_sec = rdata->pkt_info.timestamp.sec;
213 capture_info->
capture_time.tv_usec = rdata->pkt_info.timestamp.msec * 1000;
224 .name = {
"HEPv3 Logging Module", 20 },
254 .
requires =
"res_pjsip,res_pjsip_session,res_hep",
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_strdup(str)
A wrapper for strdup()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const char * ast_channel_name(const struct ast_channel *chan)
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Routines for integration with Homer using HEPv3.
enum hep_uuid_type hepv3_get_uuid_type(void)
Get the preferred UUID type.
int hepv3_is_loaded(void)
Return whether or not we're currently loaded and active.
struct hepv3_capture_info * hepv3_create_capture_info(const void *payload, size_t len)
Create a hepv3_capture_info object.
int hepv3_send_packet(struct hepv3_capture_info *capture_info)
Send a generic packet capture to HEPv3.
static pjsip_module logging_module
static int transport_to_protocol_id(pjsip_transport *tp)
static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
static int load_module(void)
static int unload_module(void)
static char * assign_uuid(const pj_str_t *call_id, const pj_str_t *local_tag, const pj_str_t *remote_tag)
static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata)
void ast_sip_unregister_service(pjsip_module *module)
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
struct ast_sip_session * ast_sip_dialog_get_session(pjsip_dialog *dlg)
Retrieves a session from a dialog.
A structure describing a SIP session.
struct timeval capture_time
struct ast_sockaddr src_addr
enum hepv3_capture_type capture_type
struct ast_sockaddr dst_addr
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.