Fixes to match PCAP packets with SDP

We want to be able to match up the source and target <IP>:<PORT> with
the IP and port info sent in SDP. I adjusted the source and target
<IP>:<PORT> we write to the IP and UDP headers in the PCAP file.

I added the offer SDP (in addition to the already written answer SDP)
to the metadata file.

As a consequence of writing out the offer SDP, we will have empty PCAP
files and associated metadata files for calls that are never answered.

squash! Fixes to match PCAP packets with SDP

Added comments detailing the types of endpoint IP/port values we can
use.
pull/245/head
Dylan Mikus 10 years ago committed by Eric Green
parent beab4d95b4
commit abd953812f

@ -712,7 +712,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
bencode_buffer_destroy_add(output->buffer, (free_func_t) sdp_chopper_destroy, chopper);
bencode_dictionary_get_str(input, "record-call", &recordcall);
if (opmode == OP_ANSWER && recordcall.s) {
if (recordcall.s) {
detect_setup_recording(call, recordcall);
}
@ -741,7 +741,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
bencode_dictionary_add_string(output, "result", "ok");
struct recording *recording = call->recording;
if (opmode == OP_ANSWER && call->record_call && recording != NULL && recording->meta_fp != NULL) {
if (call->record_call && recording != NULL && recording->meta_fp != NULL) {
struct iovec *iov = &g_array_index(chopper->iov, struct iovec, 0);
int iovcnt = chopper->iov_num;
meta_write_sdp(recording->meta_fp, iov, iovcnt);

@ -1018,6 +1018,26 @@ noop:
/* XXX split this function into pieces */
/* called lock-free */
static int stream_packet(struct stream_fd *sfd, str *s, const endpoint_t *fsin, const struct timeval *tv) {
/**
* Incoming packets:
* - sfd->socket.local: the local IP/port on which the packet arrived
* - sfd->stream->endpoint: adjusted/learned IP/port from where the packet
* was sent
* - sfd->stream->advertised_endpoint: the unadjusted IP/port from where the
* packet was sent. These are the values present in the SDP
*
* Outgoing packets:
* - sfd->stream->rtp_sink->endpoint: the destination IP/port
* - sfd->stream->selected_sfd->socket.local: the local source IP/port for the
* outgoing packet
*
* If the rtpengine runs behind a NAT and local addresses are configured with
* different advertised endpoints, the SDP would not contain the address from
* `...->socket.local`, but rather from `sfd->local_intf->spec->address.advertised`
* (of type `sockaddr_t`). The port will be the same.
*/
/* TODO move the above comments to the data structure definitions, if the above
* always holds true */
struct packet_stream *stream,
*sink = NULL,
*in_srtp, *out_srtp;

@ -337,9 +337,9 @@ void recording_finish_file(struct recording *recording) {
* Write out a PCAP packet with payload string.
* A fair amount extraneous of packet data is spoofed.
*/
void stream_pcap_dump(pcap_dumper_t *pdumper, struct packet_stream *sink, str *s) {
endpoint_t src_endpoint = sink->advertised_endpoint;
endpoint_t dst_endpoint = sink->endpoint;
void stream_pcap_dump(pcap_dumper_t *pdumper, struct packet_stream *stream, str *s) {
endpoint_t src_endpoint = stream->advertised_endpoint;
endpoint_t dst_endpoint = stream->selected_sfd->socket.local;
// Wrap RTP in fake UDP packet header
// Right now, we spoof it all

Loading…
Cancel
Save