Commit a3e4ff62 authored by Ghislain MARY's avatar Ghislain MARY

Define ortp_stream_is_ipv6 in utils.c so that it can be used everywhere in oRTP.

parent e4f28d14
...@@ -909,16 +909,8 @@ static int rtp_sendmsg(int sock,mblk_t *m, struct sockaddr *rem_addr, int addr_l ...@@ -909,16 +909,8 @@ static int rtp_sendmsg(int sock,mblk_t *m, struct sockaddr *rem_addr, int addr_l
#endif #endif
static bool_t is_ipv6(OrtpStream *os) {
if (os->sockfamily == AF_INET6) {
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&os->rem_addr;
return !IN6_IS_ADDR_V4MAPPED(&in6->sin6_addr);
}
return FALSE;
}
static void update_sent_bytes(OrtpStream *os, int nbytes) { static void update_sent_bytes(OrtpStream *os, int nbytes) {
int overhead = is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD; int overhead = ortp_stream_is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
if ((os->sent_bytes == 0) && (os->send_bw_start.tv_sec == 0) && (os->send_bw_start.tv_usec == 0)) { if ((os->sent_bytes == 0) && (os->send_bw_start.tv_sec == 0) && (os->send_bw_start.tv_usec == 0)) {
/* Initialize bandwidth computing time when has not been started yet. */ /* Initialize bandwidth computing time when has not been started yet. */
ortp_gettimeofday(&os->send_bw_start, NULL); ortp_gettimeofday(&os->send_bw_start, NULL);
...@@ -927,7 +919,7 @@ static void update_sent_bytes(OrtpStream *os, int nbytes) { ...@@ -927,7 +919,7 @@ static void update_sent_bytes(OrtpStream *os, int nbytes) {
} }
static void update_recv_bytes(OrtpStream *os, int nbytes) { static void update_recv_bytes(OrtpStream *os, int nbytes) {
int overhead = is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD; int overhead = ortp_stream_is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
if (os->recv_bytes == 0) { if (os->recv_bytes == 0) {
ortp_gettimeofday(&os->recv_bw_start, NULL); ortp_gettimeofday(&os->recv_bw_start, NULL);
} }
......
...@@ -92,3 +92,11 @@ uint64_t ortp_timeval_to_ntp(const struct timeval *tv){ ...@@ -92,3 +92,11 @@ uint64_t ortp_timeval_to_ntp(const struct timeval *tv){
lsw=(uint32_t)((double)tv->tv_usec*(double)(((uint64_t)1)<<32)*1.0e-6); lsw=(uint32_t)((double)tv->tv_usec*(double)(((uint64_t)1)<<32)*1.0e-6);
return msw<<32 | lsw; return msw<<32 | lsw;
} }
bool_t ortp_stream_is_ipv6(OrtpStream *os) {
if (os->sockfamily == AF_INET6) {
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&os->rem_addr;
return !IN6_IS_ADDR_V4MAPPED(&in6->sin6_addr);
}
return FALSE;
}
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define UTILS_H #define UTILS_H
#include "ortp/event.h" #include "ortp/event.h"
#include "ortp/rtpsession.h"
struct _OList { struct _OList {
struct _OList *next; struct _OList *next;
...@@ -81,4 +82,6 @@ void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev); ...@@ -81,4 +82,6 @@ void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev);
uint64_t ortp_timeval_to_ntp(const struct timeval *tv); uint64_t ortp_timeval_to_ntp(const struct timeval *tv);
bool_t ortp_stream_is_ipv6(OrtpStream *os);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment