1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
From fb437ef493d6023e936bd55088df7e6d99452cfb Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 4 Jan 2011 22:34:03 +0300
Subject: [PATCH 11/11] Avoid using private Glibc functions
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
core/sip/resolver.cpp | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/core/sip/resolver.cpp b/core/sip/resolver.cpp
index e3443c7..3b3e4a6 100644
--- a/core/sip/resolver.cpp
+++ b/core/sip/resolver.cpp
@@ -54,6 +54,27 @@ using std::list;
// (the limit is the # bits in dns_handle::srv_used)
#define MAX_SRV_RR (sizeof(unsigned int)*8)
+/* The SEMS_GET16 macro and the sems_get16 function were copied from glibc 2.7
+ * (include/arpa/nameser.h (NS_GET16) and resolv/ns_netint.c (ns_get16)) to
+ * avoid using private glibc functions.
+ */
+
+# define SEMS_GET16(s, cp) \
+ do { \
+ uint16_t *t_cp = (uint16_t *) (cp); \
+ (s) = ntohs (*t_cp); \
+ (cp) += NS_INT16SZ; \
+} while (0)
+
+u_int
+sems_get16(const u_char *src)
+{
+ u_int dst;
+
+ SEMS_GET16(dst, src);
+ return (dst);
+}
+
struct ip_entry
: public dns_base_entry
{
@@ -399,15 +420,15 @@ dns_base_entry* dns_srv_entry::get_rr(dns_record* rr, u_char* begin, u_char* end
DBG("SRV:\tTTL=%i\t%s\tP=<%i> W=<%i> P=<%i> T=<%s>\n",
ns_rr_ttl(*rr),
ns_rr_name(*rr),
- ns_get16(rdata),
- ns_get16(rdata+2),
- ns_get16(rdata+4),
+ sems_get16(rdata),
+ sems_get16(rdata+2),
+ sems_get16(rdata+4),
name_buf);
srv_entry* srv_r = new srv_entry();
- srv_r->p = ns_get16(rdata);
- srv_r->w = ns_get16(rdata+2);
- srv_r->port = ns_get16(rdata+4);
+ srv_r->p = sems_get16(rdata);
+ srv_r->w = sems_get16(rdata+2);
+ srv_r->port = sems_get16(rdata+4);
srv_r->target = (const char*)name_buf;
return srv_r;
--
1.7.3.4
|