Main: use Jumbos when sending to ourselves

Use Jumbos when sending and receirver run in one process and communicate
through loopback.
This commit is contained in:
Martin Pulec
2016-10-06 17:35:00 +02:00
parent 020d9e24a0
commit 116f99fd4d
5 changed files with 212 additions and 75 deletions

View File

@@ -56,6 +56,7 @@
#include "module.h"
#include "rtp/net_udp.h" // socket_error
#include "tv.h"
#include "utils/net.h"
#define DEFAULT_CONTROL_PORT 5054
#define MAX_CLIENTS 16
@@ -66,17 +67,6 @@ typedef const char *sso_val_type;
typedef void *sso_val_type;
#endif /* WIN32 */
#ifdef WIN32
#define CLOSESOCKET closesocket
#else
#define CLOSESOCKET close
#endif
// MSW does not have the macro defined
#ifndef IN_LOOPBACKNET
#define IN_LOOPBACKNET 127
#endif
using namespace std;
struct client {
@@ -610,36 +600,6 @@ static bool parse_msg(char *buffer, int buffer_len, /* out */ char *message, int
return ret;
}
static bool is_addr_loopback(struct sockaddr_storage *ss)
{
switch (ss->ss_family) {
case AF_UNIX:
return true;
case AF_INET:
{
struct sockaddr_in *sin = (struct sockaddr_in *) ss;
uint32_t addr = ntohl(sin->sin_addr.s_addr);
if ((addr >> 24) == IN_LOOPBACKNET) {
return true;
}
}
case AF_INET6:
{
struct sockaddr_in6 *sin = (struct sockaddr_in6 *) ss;
if (IN6_IS_ADDR_V4MAPPED(&sin->sin6_addr)) {
uint32_t v4_addr = ntohl(*((uint32_t*)(sin->sin6_addr.s6_addr + 12)));
if ((v4_addr >> 24) == IN_LOOPBACKNET) {
return true;
}
} else {
return IN6_IS_ADDR_LOOPBACK(&sin->sin6_addr);
}
}
default:
return false;
}
}
static struct client *add_client(struct client *clients, int fd) {
struct client *new_client = (struct client *)
malloc(sizeof(struct client));