1 From 18e2b5ed1ffb3e7c5dfec8ff41b3027163f680ed Mon Sep 17 00:00:00 2001
2 From: Leonid Evdokimov <leon@darkk.net.ru>
3 Date: Wed, 12 Sep 2012 02:05:39 +0400
4 Subject: [PATCH 09/12] Fix compilation on Ubuntu 10.04 LTS and (hopefully)
7 fixes #28, fixes #22, fixes #24
8 [1] current "stable" release
10 libc-compat.h | 25 +++++++++++++++++++++++++
11 libevent-compat.h | 11 +++++++++++
15 5 files changed, 39 insertions(+)
16 create mode 100644 libc-compat.h
17 create mode 100644 libevent-compat.h
19 diff --git a/libc-compat.h b/libc-compat.h
21 index 0000000..adcf63b
25 +#ifndef UUID_67C91670_FCCB_4855_BDF7_609F1EECB8B4
26 +#define UUID_67C91670_FCCB_4855_BDF7_609F1EECB8B4
28 +/* all these definitions, are included into bits/in.h from libc6-dev 2.15-0ubuntu10
29 + * from Ubuntu 12.04 and is not included into libc6-dev 2.11.1-0ubuntu7.10 from
31 + * linux/in.h is not included directly because of lots of redefinitions,
32 + * extracting single value from linux/in.h is not done because it looks like
33 + * autotools reinvention */
34 +#ifndef IP_ORIGDSTADDR
35 +# warning Using hardcoded value for IP_ORIGDSTADDR as libc headers do not define it.
36 +# define IP_ORIGDSTADDR 20
39 +#ifndef IP_RECVORIGDSTADDR
40 +# warning Using hardcoded value for IP_RECVORIGDSTADDR as libc headers do not define it.
41 +# define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
44 +#ifndef IP_TRANSPARENT
45 +# warning Using hardcoded value for IP_TRANSPARENT as libc headers do not define it.
46 +# define IP_TRANSPARENT 19
49 +#endif // 67C91670_FCCB_4855_BDF7_609F1EECB8B4
50 diff --git a/libevent-compat.h b/libevent-compat.h
52 index 0000000..a7f1ca1
54 +++ b/libevent-compat.h
56 +#ifndef UUID_FC148CFA_5ECC_488E_8A62_CD39406C9F1E
57 +#define UUID_FC148CFA_5ECC_488E_8A62_CD39406C9F1E
59 +/* evutil_socket_t is macros in libevent-2.0, not typedef, libevent-1.4 is
60 + * still supported because of Ubuntu 10.04 LTS */
61 +#ifndef evutil_socket_t
62 +# warning Using hardcoded value for evutil_socket_t as libevent headers do not define it.
63 +# define evutil_socket_t int
66 +#endif // FC148CFA_5ECC_488E_8A62_CD39406C9F1E
67 diff --git a/redsocks.c b/redsocks.c
68 index ba5eab2..878576f 100644
75 +#include "libevent-compat.h"
78 #define REDSOCKS_RELAY_HALFBUFF 4096
79 diff --git a/redudp.c b/redudp.c
80 index 262af3e..05460dc 100644
87 +#include "libc-compat.h"
89 #define redudp_log_error(client, prio, msg...) \
90 redsocks_log_write_plain(__FILE__, __LINE__, __func__, 0, &(client)->clientaddr, get_destaddr(client), prio, ## msg)
91 diff --git a/utils.c b/utils.c
92 index 31c6894..7de3969 100644
98 #include "redsocks.h" // for redsocks_close
99 +#include "libc-compat.h"
101 int red_recv_udp_pkt(int fd, char *buf, size_t buflen, struct sockaddr_in *inaddr, struct sockaddr_in *toaddr)