From 8047f4fbd9ca7ff4bb63185ebc8f3746bdcfe705 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 17 Mar 2017 08:23:58 +0100 Subject: [PATCH] compat: move all missing IPTOS defines to compat.h, fixes #4285 --- src/compat.h | 18 +++++++++++++++++- src/config.c | 13 ++----------- src/tcp.c | 6 ++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/compat.h b/src/compat.h index 45e93f67d..a58c34870 100644 --- a/src/compat.h +++ b/src/compat.h @@ -41,8 +41,17 @@ // 32-bit Android has only timegm64() and not timegm(). // We replicate the behaviour of timegm() when the result overflows time_t. +#endif /* ENABLE_ANDROID */ + +#ifdef COMPAT_IPTOS + +#ifndef IPTOS_DSCP_MASK #define IPTOS_DSCP_MASK 0xfc +#endif +#ifndef IPTOS_DSCP #define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK) +#endif +#ifndef IPTOS_DSCP_AF11 #define IPTOS_DSCP_AF11 0x28 #define IPTOS_DSCP_AF12 0x30 #define IPTOS_DSCP_AF13 0x38 @@ -56,9 +65,15 @@ #define IPTOS_DSCP_AF42 0x90 #define IPTOS_DSCP_AF43 0x98 #define IPTOS_DSCP_EF 0xb8 +#endif +#ifndef IPTOS_CLASS_MASK #define IPTOS_CLASS_MASK 0xe0 +#endif +#ifndef IPTOS_CLASS #define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK) +#endif +#ifndef IPTOS_CLASS_CS0 #define IPTOS_CLASS_CS0 0x00 #define IPTOS_CLASS_CS1 0x20 #define IPTOS_CLASS_CS2 0x40 @@ -67,9 +82,10 @@ #define IPTOS_CLASS_CS5 0xa0 #define IPTOS_CLASS_CS6 0xc0 #define IPTOS_CLASS_CS7 0xe0 +#endif #define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0 -#endif +#endif /* COMPAT_IPTOS */ #endif /* COMPAT_H */ diff --git a/src/config.c b/src/config.c index 9bf31bf0e..2b81fbb1c 100644 --- a/src/config.c +++ b/src/config.c @@ -36,17 +36,8 @@ #include "input/mpegts/scanfile.h" #include - -#ifndef IPTOS_CLASS_CS0 -#define IPTOS_CLASS_CS0 0x00 -#define IPTOS_CLASS_CS1 0x20 -#define IPTOS_CLASS_CS2 0x40 -#define IPTOS_CLASS_CS3 0x60 -#define IPTOS_CLASS_CS4 0x80 -#define IPTOS_CLASS_CS5 0xa0 -#define IPTOS_CLASS_CS6 0xc0 -#define IPTOS_CLASS_CS7 0xe0 -#endif +#define COMPAT_IPTOS +#include "compat.h" static void config_muxconfpath_notify ( void *o, const char *lang ); diff --git a/src/tcp.c b/src/tcp.c index 4b37aa648..f1cea9733 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -41,6 +41,8 @@ #include "notify.h" #include "access.h" #include "dvr/dvr.h" +#define COMPAT_IPTOS +#include "compat.h" #if ENABLE_LIBSYSTEMD_DAEMON #include @@ -53,10 +55,6 @@ th_pipe_t tcp_server_pipe; /** * */ -#ifndef IPTOS_DSCP_MASK -#define IPTOS_DSCP_MASK 0xfc -#endif - int socket_set_dscp(int sockfd, uint32_t dscp, char *errbuf, size_t errbufsize) { -- 2.47.2