Package: opensips / 2.2.2-3.1

fix-radcli.patch Patch series | download
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Description: Add support for radcli library.
Author: Răzvan Crainea <razvan@opensips.org>
Last-Update: 2016-12-01
--- a/Makefile
+++ b/Makefile
@@ -31,14 +31,6 @@
 #  2007-09-28  added db_berkeley (wiquan)
 #
 
-#FREERADIUS=1
-# freeradius libs check (must be done in toplevel makefile)
-ifneq ("$(wildcard /usr/include/freeradius-client.h)","")
-FREERADIUS=1
-else
-#FREERADIUS=0
-endif
-
 #SQLITE_BIND=1
 NICER?=1
 auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
@@ -124,7 +116,6 @@
 
 ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules Makefile.conf
 
-
 install_docs := README-MODULES AUTHORS NEWS README
 ifneq ($(skip-install-doc),yes)
 	install_docs += INSTALL
@@ -179,6 +170,7 @@
 .PHONY: all
 all: $(NAME) modules utils
 
+
 .PHONY: app
 app: $(NAME)
 
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -601,13 +601,6 @@
 	DEFS+= -DVERSIONTYPE='"$(VERSIONTYPE)"' -DTHISREVISION='"$(THISREVISION)"'
 endif
 
-ifneq ($(FREERADIUS),)
-	DEFS+= -DUSE_FREERADIUS
-	RADIUS_LIB= -lfreeradius-client
-else
-	RADIUS_LIB= -lradiusclient-ng
-endif
-
 ifneq ($(SQLITE_BIND),)
 	DEFS+= -DSQLITE_BIND
 endif
--- a/modules/aaa_radius/Makefile
+++ b/modules/aaa_radius/Makefile
@@ -10,10 +10,32 @@
 
 ETC_DIR?=../../etc/
 
-# Comment the next two line and uncomment the following two if you want
-# to enable Radius support
-DEFS+= -I$(LOCALBASE)/include
-LIBS=-L$(LOCALBASE)/lib $(RADIUS_LIB)
+# Find the radius library we shall use
+#
+ifeq ($(RADIUSCLIENT),)
+RADIUSCLIENT=$(shell if [ -n "`ldconfig -p | grep radcli`" ]; then echo "RADCLI"; \
+	elif [ -n "`ldconfig -p | grep freeradius`" ]; then echo "FREERADIUS"; \
+	elif [ -n "`ldconfig -p | grep radiusclient-ng`" ];then echo "RADIUSCLIENT"; fi)
+endif
+
+
+ifneq ($(RADIUSCLIENT), RADCLI)
+ifneq ($(RADIUSCLIENT), FREERADIUS)
+ifeq ($(RADIUSCLIENT), RADIUSCLIENT)
+	DEFS+= -DRADIUSCLIENT
+	RADIUS_LIB= -lradiusclient-ng
+endif
+else
+	DEFS+= -DFREERADIUS
+	RADIUS_LIB= -lfreeradius-client
+endif
+else
+	RADIUS_LIB= -lradiusclient-ng
+	DEFS+= -DRADCLI
+	RADIUS_LIB= -lradcli
+endif
+
+LIBS=$(RADIUS_LIB)
 
 include ../../Makefile.modules
 
--- a/modules/aaa_radius/README
+++ b/modules/aaa_radius/README
@@ -102,9 +102,18 @@
        http://developer.berlios.de/projects/radiusclient-ng/.
      * freeradius-client See http://freeradius.org/.
 
-   By default, radiusclient-ng is used. To change at compile time
-   to freeradius, uncomment the USE_FREERADIUS=1 line in main
-   Makefile.
+   One can force used radius library by setting RADIUSCLIENT env,
+   before compiling the module, to one of the following values:
+     * RADCLI libradcli-dev library shall be used;
+     * FREERADIUS libfreeradius-client-dev library shall be used;
+     * RADIUSCLIENT libradiusclient-ng library shall be used;
+
+   IMPORTANT: If the selected library is not installed the module
+   won't compile. NOTE: If RADIUSCLIENT env not set, the module
+   will try to find one of the three radius libraries in the
+   following order: radcli, freeradius, radiusclient-ng. That is
+   if radcli library is installed it shall be used, else
+   freeradius shall be looked for and so on.
 
 1.3. Exported Parameters
 
--- a/modules/aaa_radius/aaa_radius.c
+++ b/modules/aaa_radius/aaa_radius.c
@@ -31,10 +31,16 @@
  * to get information from the RADIUS reply.
  */
 
-#ifndef USE_FREERADIUS
-	#include <radiusclient-ng.h>
-#else
+#ifdef FREERADIUS
 	#include <freeradius-client.h>
+#else
+	#ifdef RADCLI
+		#include <radcli/radcli.h>
+	#else
+		#ifdef RADIUSCLIENT
+			#include <radiusclient-ng.h>
+		#endif
+	#endif
 #endif
 
 #include "../../sr_module.h"
--- a/modules/aaa_radius/doc/aaa_radius_admin.xml
+++ b/modules/aaa_radius/doc/aaa_radius_admin.xml
@@ -70,8 +70,25 @@
 			</listitem>
 			</itemizedlist>
 			<para>
-				By default, radiusclient-ng is used. To change at compile time
-				to freeradius, uncomment the USE_FREERADIUS=1 line in main Makefile.
+				One can force the radius library that is usedby setting RADIUSCLIENT env, before compiling the module, to one of the following values:
+				<itemizedlist>
+					<listitem>
+						<para><emphasis>RADCLI  ***</emphasis> libradcli-dev library shall be used;</para>
+					</listitem>
+
+					<listitem>
+						<para><emphasis>FREERADIUS  ***</emphasis> libfreeradius-client-dev library shall be used;</para>
+					</listitem>
+
+					<listitem>
+						<para><emphasis>RADIUSCLIENT  ***</emphasis> libradiusclient-ng library shall be used;</para>
+					</listitem>
+				</itemizedlist>
+
+				<para>IMPORTANT: If the selected library is not installed the module won't compile.</para>
+				<para>NOTE: If RADIUSCLIENT env not set, the module will try to find one of the three radius libraries in
+				the following order: radcli, freeradius, radiusclient-ng. That is if radcli library is installed
+				it shall be used, else freeradius shall be looked for and so on.</para>
 			</para>
 	</section>
 	</section>
--- a/modules/aaa_radius/rad.c
+++ b/modules/aaa_radius/rad.c
@@ -28,10 +28,16 @@
  * This is the Radius implementation for the generic AAA Interface.
  */
 
-#ifndef USE_FREERADIUS
-	#include <radiusclient-ng.h>
-#else
+#ifdef FREERADIUS
 	#include <freeradius-client.h>
+#else
+	#ifdef RADCLI
+		#include <radcli/radcli.h>
+	#else
+		#ifdef RADIUSCLIENT
+			#include <radiusclient-ng.h>
+		#endif
+	#endif
 #endif
 
 #ifndef REJECT_RC
@@ -45,6 +51,33 @@
 #include "rad.h"
 #include "../../ut.h"
 #include "../../usr_avp.h"
+#include "../../resolve.h"
+
+/**
+ * this function is removed from current versions
+ * of FREERADIUS-CLIENT and RADCLI because it only offers
+ * support for IPv4
+ * but since the whole code is built around IPv4 we will
+ * implement it only for IPv4 usage
+ */
+#ifdef RADCLI
+uint32_t rc_get_ipaddr (char *host)
+{
+	const struct hostent* he;
+	struct in_addr** addr_list;
+
+	he=resolvehost(host, 0/*do test if is ip*/);
+
+	/* FIXME the function is not for IPV6 */
+	addr_list = (struct in_addr **)he->h_addr_list;
+	if (addr_list[0])
+		return addr_list[0]->s_addr;
+
+	return 0;
+
+}
+#endif
+
 
 
 /*
--- a/modules/aaa_radius/rad.h
+++ b/modules/aaa_radius/rad.h
@@ -47,4 +47,7 @@
 
 int extract_avp(VALUE_PAIR* vp);
 
+#ifdef RADCLI
+uint32_t rc_get_ipaddr (char *host);
+#endif
 #endif
--- a/version.h
+++ b/version.h
@@ -171,7 +171,6 @@
 #define NOSMP_STR ""
 #endif
 
-
 #define OPENSIPS_COMPILE_FLAGS \
 	STATS_STR EXTRA_DEBUG_STR \
 	DISABLE_NAGLE_STR USE_MCAST_STR NO_DEBUG_STR NO_LOG_STR \