Skip to content

Commit

Permalink
fix / add manipulate with iphdr2 in rtpthreads - fix save rtp dscp in…
Browse files Browse the repository at this point in the history
… scanpcapdir
  • Loading branch information
Radek Bucek committed Dec 20, 2013
1 parent a8409c8 commit 51e653a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions calltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ Call::read_rtcp(unsigned char* data, int datalen, struct pcap_pkthdr *header, u_

/* analyze rtp packet */
void
Call::read_rtp(unsigned char* data, int datalen, struct pcap_pkthdr *header, u_int32_t saddr, u_int32_t daddr, unsigned short port, int iscaller, int *record) {
Call::read_rtp(unsigned char* data, int datalen, struct pcap_pkthdr *header, struct iphdr2 *header_ip, u_int32_t saddr, u_int32_t daddr, unsigned short port, int iscaller, int *record) {

*record = 0;

Expand All @@ -565,7 +565,9 @@ Call::read_rtp(unsigned char* data, int datalen, struct pcap_pkthdr *header, u_i
}

if(opt_dscp) {
struct iphdr2 *header_ip = (struct iphdr2 *)(data - sizeof(struct iphdr2) - sizeof(udphdr2));
if(!header_ip) {
header_ip = (struct iphdr2 *)(data - sizeof(struct iphdr2) - sizeof(udphdr2));
}
if(iscaller) {
this->caller_rtpdscp = header_ip->tos >> 2;
////cout << "caller_rtpdscp " << (int)(header_ip->tos>>2) << endl;
Expand Down
2 changes: 1 addition & 1 deletion calltable.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class Call {
* @param saddr source IP adress of the packet
*
*/
void read_rtp( unsigned char *data, int datalen, struct pcap_pkthdr *header, u_int32_t saddr, u_int32_t daddr, unsigned short port, int iscaller, int *record);
void read_rtp( unsigned char *data, int datalen, struct pcap_pkthdr *header, struct iphdr2 *header_ip, u_int32_t saddr, u_int32_t daddr, unsigned short port, int iscaller, int *record);

/**
* @brief read RTCP packet
Expand Down
9 changes: 5 additions & 4 deletions sniff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ void add_to_rtp_thread_queue(Call *call, unsigned char *data, int datalen, struc
rtpp->is_rtcp = is_rtcp;

memcpy(&rtpp->header, header, sizeof(struct pcap_pkthdr));
memcpy(&rtpp->header_ip, (struct iphdr2*)(data - sizeof(struct iphdr2) - sizeof(udphdr2)), sizeof(struct iphdr2));
if(datalen > MAXPACKETLENQRING) {
syslog(LOG_ERR, "error: packet is to large [%d]b for RTP QRING[%d]b", header->caplen, MAXPACKETLENQRING);
return;
Expand Down Expand Up @@ -1150,7 +1151,7 @@ void *rtp_read_thread_func(void *arg) {
rtpp_pq.call->read_rtcp(rtpp_pq.data, rtpp_pq.datalen, &rtpp_pq.pkthdr_pcap.header->header_std, rtpp_pq.saddr, rtpp_pq.port, rtpp_pq.iscaller);
} else {
int monitor;
rtpp_pq.call->read_rtp(rtpp_pq.data, rtpp_pq.datalen, &rtpp_pq.pkthdr_pcap.header->header_std, rtpp_pq.saddr, rtpp_pq.daddr, rtpp_pq.port, rtpp_pq.iscaller, &monitor);
rtpp_pq.call->read_rtp(rtpp_pq.data, rtpp_pq.datalen, &rtpp_pq.pkthdr_pcap.header->header_std, NULL, rtpp_pq.saddr, rtpp_pq.daddr, rtpp_pq.port, rtpp_pq.iscaller, &monitor);
}
rtpp_pq.call->set_last_packet_time(rtpp_pq.pkthdr_pcap.header->header_std.ts.tv_sec);
rtpp_pq.block_store->unlock_packet(rtpp_pq.block_store_index);
Expand All @@ -1159,7 +1160,7 @@ void *rtp_read_thread_func(void *arg) {
rtpp->call->read_rtcp((unsigned char*)rtpp->data, rtpp->datalen, &rtpp->header, rtpp->saddr, rtpp->port, rtpp->iscaller);
} else {
int monitor;
rtpp->call->read_rtp(rtpp->data, rtpp->datalen, &rtpp->header, rtpp->saddr, rtpp->daddr, rtpp->port, rtpp->iscaller, &monitor);
rtpp->call->read_rtp(rtpp->data, rtpp->datalen, &rtpp->header, &rtpp->header_ip, rtpp->saddr, rtpp->daddr, rtpp->port, rtpp->iscaller, &monitor);
}
rtpp->call->set_last_packet_time(rtpp->header.ts.tv_sec);
}
Expand Down Expand Up @@ -2844,7 +2845,7 @@ if (header->ts.tv_sec - last_cleanup > 10){
return call;
}
} else {
call->read_rtp((unsigned char*) data, datalen, header, saddr, daddr, source, iscaller, &record);
call->read_rtp((unsigned char*) data, datalen, header, NULL, saddr, daddr, source, iscaller, &record);
call->set_last_packet_time(header->ts.tv_sec);
}
if(!dontsave && ((call->flags & FLAG_SAVERTPHEADER) || (call->flags & FLAG_SAVERTP) || (call->isfax && opt_saveudptl) || record)) {
Expand Down Expand Up @@ -2917,7 +2918,7 @@ if (header->ts.tv_sec - last_cleanup > 10){
}
*was_rtp = 1;
} else {
call->read_rtp((unsigned char*) data, datalen, header, saddr, daddr, source, !iscaller, &record);
call->read_rtp((unsigned char*) data, datalen, header, NULL, saddr, daddr, source, !iscaller, &record);
call->set_last_packet_time(header->ts.tv_sec);
}
if(!dontsave && ((call->flags & FLAG_SAVERTP) || (call->isfax && opt_saveudptl) || record)) {
Expand Down
1 change: 1 addition & 0 deletions sniff.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ typedef struct {
char iscaller;
char is_rtcp;
struct pcap_pkthdr header;
struct iphdr2 header_ip;
volatile char free;
} rtp_packet;

Expand Down

0 comments on commit 51e653a

Please sign in to comment.