157{
158 char local_buf[256];
159 char remote_buf[256];
162
164 if (!capture_info) {
165 return PJ_SUCCESS;
166 }
167
168 if (!rdata->pkt_info.src_addr_len) {
169 return PJ_SUCCESS;
170 }
171 pj_sockaddr_print(&rdata->pkt_info.src_addr, remote_buf, sizeof(remote_buf), 3);
172
173 if (!(rdata->tp_info.transport->flag & PJSIP_TRANSPORT_RELIABLE)) {
174 pjsip_tpmgr_fla2_param prm;
175
176
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;
181
182
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);
185 } else {
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),
190 prm.ret_port);
191 } else {
192 snprintf(local_buf, sizeof(local_buf), "%.*s:%hu",
193 (int)pj_strlen(&prm.ret_addr),
194 pj_strbuf(&prm.ret_addr),
195 prm.ret_port);
196 }
197 }
198 } else {
199 pj_sockaddr_print(&rdata->tp_info.transport->local_addr, local_buf, sizeof(local_buf), 3);
200 }
201
202 uuid =
assign_uuid(&rdata->msg_info.cid->id, &rdata->msg_info.to->tag, &rdata->msg_info.from->tag);
205 return PJ_SUCCESS;
206 }
207
210
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;
217
219
220 return PJ_FALSE;
221}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
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 int transport_to_protocol_id(pjsip_transport *tp)
static char * assign_uuid(const pj_str_t *call_id, const pj_str_t *local_tag, const pj_str_t *remote_tag)
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
struct timeval capture_time
struct ast_sockaddr src_addr
enum hepv3_capture_type capture_type
struct ast_sockaddr dst_addr