Implemented TOS/Traffic Class bit in received first RTP packet

pull/101/head
Frederic-Philippe Metz 11 years ago
parent 070212ec3a
commit f8aaf358cd

@ -16,6 +16,7 @@
#include <sys/wait.h>
#include <time.h>
#include <sys/time.h>
#include <inttypes.h>
#include "poller.h"
#include "aux.h"
@ -1347,6 +1348,10 @@ static void callmaster_timer(void *ptr) {
DS(bytes);
DS(errors);
mutex_lock(&m->statspslock);
ps->stats.in_tos_tclass = m->statsps.in_tos_tclass = ke->stats.in_tos;
mutex_unlock(&m->statspslock);
#if (RE_HAS_MEASUREDELAY)
mutex_lock(&m->statspslock);
ps->stats.delay_min = m->statsps.delay_min = ke->stats.delay_min;
@ -1363,6 +1368,7 @@ static void callmaster_timer(void *ptr) {
ps->kernel_stats.packets = ke->stats.packets;
ps->kernel_stats.bytes = ke->stats.bytes;
ps->kernel_stats.errors = ke->stats.errors;
ps->kernel_stats.in_tos_tclass = ke->stats.in_tos;
#if (RE_HAS_MEASUREDELAY)
ps->kernel_stats.delay_min = ke->stats.delay_min;
@ -2512,14 +2518,16 @@ void call_destroy(struct call *c) {
"ml%i_midx%u_%s_relayed_packets=%llu, "
"ml%i_midx%u_%s_relayed_bytes=%llu, "
"ml%i_midx%u_%s_relayed_errors=%llu, "
"ml%i_midx%u_%s_last_packet=%llu, ",
"ml%i_midx%u_%s_last_packet=%llu, "
"ml%i_midx%u_%s_in_tos_tclass=%" PRIu8 ", ",
cdrlinecnt, md->index, protocol, addr,
cdrlinecnt, md->index, protocol, ps->endpoint.port,
cdrlinecnt, md->index, protocol, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0),
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.packets,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.bytes,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.errors,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->last_packet);
cdrlinecnt, md->index, protocol, (unsigned long long) ps->last_packet,
cdrlinecnt, md->index, protocol, ((unsigned int) ps->stats.in_tos_tclass) & 0xff);
} else {
#if (RE_HAS_MEASUREDELAY)
cdrbufcur += sprintf(cdrbufcur,
@ -2530,6 +2538,7 @@ void call_destroy(struct call *c) {
"ml%i_midx%u_%s_relayed_bytes=%llu, "
"ml%i_midx%u_%s_relayed_errors=%llu, "
"ml%i_midx%u_%s_last_packet=%llu, "
"ml%i_midx%u_%s_in_tos_tclass=%" PRIu8 ", "
"ml%i_midx%u_%s_delay_min=%llu.%09llu, "
"ml%i_midx%u_%s_delay_avg=%llu.%09llu, "
"ml%i_midx%u_%s_delay_max=%llu.%09llu, ",
@ -2540,6 +2549,7 @@ void call_destroy(struct call *c) {
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.bytes,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.errors,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->last_packet,
cdrlinecnt, md->index, protocol, ((unsigned int) ps->stats.in_tos_tclass) & 0xff,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.delay_min.tv_sec, (unsigned long long) ps->stats.delay_min.tv_nsec,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.delay_avg.tv_sec, (unsigned long long) ps->stats.delay_avg.tv_nsec,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.delay_max.tv_sec, (unsigned long long) ps->stats.delay_max.tv_nsec);
@ -2551,14 +2561,16 @@ void call_destroy(struct call *c) {
"ml%i_midx%u_%s_relayed_packets=%llu, "
"ml%i_midx%u_%s_relayed_bytes=%llu, "
"ml%i_midx%u_%s_relayed_errors=%llu, "
"ml%i_midx%u_%s_last_packet=%llu, ",
"ml%i_midx%u_%s_last_packet=%llu, "
"ml%i_midx%u_%s_in_tos_tclass=%" PRIu8 ", ",
cdrlinecnt, md->index, protocol, addr,
cdrlinecnt, md->index, protocol, ps->endpoint.port,
cdrlinecnt, md->index, protocol, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0),
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.packets,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.bytes,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->stats.errors,
cdrlinecnt, md->index, protocol, (unsigned long long) ps->last_packet);
cdrlinecnt, md->index, protocol, (unsigned long long) ps->last_packet,
cdrlinecnt, md->index, protocol, ((unsigned int) ps->stats.in_tos_tclass) & 0xff);
#endif
}
}

@ -193,6 +193,7 @@ struct stats {
struct timespec delay_min;
struct timespec delay_avg;
struct timespec delay_max;
u_int8_t in_tos_tclass;
};
struct totalstats {

@ -2146,9 +2146,9 @@ static int re_timespec_cmp (struct timespec *a, struct timespec *b)
}
#if (RE_HAS_MEASUREDELAY)
static unsigned int rtpengine46(struct sk_buff *skb, struct rtpengine_table *t, struct re_address *src, struct timespec *starttime) {
static unsigned int rtpengine46(struct sk_buff *skb, struct rtpengine_table *t, struct re_address *src, struct timespec *starttime, u_int8_t in_tos) {
#else
static unsigned int rtpengine46(struct sk_buff *skb, struct rtpengine_table *t, struct re_address *src) {
static unsigned int rtpengine46(struct sk_buff *skb, struct rtpengine_table *t, struct re_address *src, u_int8_t in_tos) {
#endif
struct udphdr *uh;
struct rtpengine_target *g;
@ -2263,6 +2263,9 @@ not_rtp:
out:
spin_lock_irqsave(&g->stats_lock, flags);
if (g->stats.packets==0)
g->stats.in_tos = in_tos;
if (err)
g->stats.errors++;
else {
@ -2351,9 +2354,9 @@ static unsigned int rtpengine4(struct sk_buff *oskb, const struct xt_action_para
src.u.ipv4 = ih->saddr;
#if (RE_HAS_MEASUREDELAY)
return rtpengine46(skb, t, &src, &starttime);
return rtpengine46(skb, t, &src, &starttime, (u_int8_t)ih->tos);
#else
return rtpengine46(skb, t, &src);
return rtpengine46(skb, t, &src, (u_int8_t)ih->tos);
#endif
skip2:
@ -2393,6 +2396,7 @@ static unsigned int rtpengine6(struct sk_buff *oskb, const struct xt_action_para
skb_reset_network_header(skb);
ih = ipv6_hdr(skb);
skb_pull(skb, sizeof(*ih));
if (ih->nexthdr != IPPROTO_UDP)
goto skip2;
@ -2402,9 +2406,9 @@ static unsigned int rtpengine6(struct sk_buff *oskb, const struct xt_action_para
memcpy(&src.u.ipv6, &ih->saddr, sizeof(src.u.ipv6));
#if (RE_HAS_MEASUREDELAY)
return rtpengine46(skb, t, &src, &starttime);
return rtpengine46(skb, t, &src, &starttime, ipv6_get_dsfield(ih));
#else
return rtpengine46(skb, t, &src);
return rtpengine46(skb, t, &src, ipv6_get_dsfield(ih));
#endif
skip2:

@ -12,6 +12,7 @@ struct rtpengine_stats {
struct timespec delay_min;
struct timespec delay_avg;
struct timespec delay_max;
u_int8_t in_tos;
};
struct re_address {

Loading…
Cancel
Save