47 static 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);
136 uuid =
assign_uuid(&cid_hdr->id, &to_hdr->tag, &from_hdr->tag);
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",
static int unload_module(void)
struct ast_sockaddr src_addr
Asterisk main include file. File version handling, generic pbx functions.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
enum hepv3_capture_type capture_type
struct ast_sockaddr dst_addr
Routines for integration with Homer using HEPv3.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_strdup(str)
A wrapper for strdup()
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.
A structure describing a SIP session.
static int transport_to_protocol_id(pjsip_transport *tp)
static pjsip_module logging_module
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
static struct ast_mansession session
#define ao2_ref(o, delta)
#define ast_malloc(len)
A wrapper for malloc()
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
static int load_module(void)
struct hepv3_capture_info * hepv3_create_capture_info(const void *payload, size_t len)
Create a hepv3_capture_info object.
static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata)
enum hep_uuid_type hepv3_get_uuid_type(void)
Get the preferred UUID type.
Module has failed to load, may be in an inconsistent state.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
int hepv3_is_loaded(void)
Return whether or not we're currently loaded and active.
struct timeval capture_time
static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
const char * ast_channel_name(const struct ast_channel *chan)
void ast_sip_unregister_service(pjsip_module *module)
int hepv3_send_packet(struct hepv3_capture_info *capture_info)
Send a generic packet capture to HEPv3.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ast_sip_session * ast_sip_dialog_get_session(pjsip_dialog *dlg)
Retrieves a session from a dialog.
static char * assign_uuid(const pj_str_t *call_id, const pj_str_t *local_tag, const pj_str_t *remote_tag)