aboutsummaryrefslogtreecommitdiff
path: root/lib/libradius
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2011-12-20 11:13:44 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2011-12-20 11:13:44 +0000
commit07d7b74b812aa7eb6d53c4f24e2c1bc7ad8d8ccd (patch)
treeedb0af86ee389aae22d3a4b26a85fe25baab590c /lib/libradius
parent74ab90b71e5ad299fc091c031768d591358bde0f (diff)
downloadsrc-07d7b74b812aa7eb6d53c4f24e2c1bc7ad8d8ccd.tar.gz
src-07d7b74b812aa7eb6d53c4f24e2c1bc7ad8d8ccd.zip
Add binding support to libradius(3).
Submitted by: Sergey Matveychuk <sem33@yandex-team.ru> Approved by: ae (mentor) MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=228730
Diffstat (limited to 'lib/libradius')
-rw-r--r--lib/libradius/Makefile1
-rw-r--r--lib/libradius/libradius.36
-rw-r--r--lib/libradius/radlib.c9
-rw-r--r--lib/libradius/radlib.h1
-rw-r--r--lib/libradius/radlib_private.h1
5 files changed, 17 insertions, 1 deletions
diff --git a/lib/libradius/Makefile b/lib/libradius/Makefile
index 5723bf1ba6f0..d71d8f2022ed 100644
--- a/lib/libradius/Makefile
+++ b/lib/libradius/Makefile
@@ -36,6 +36,7 @@ MAN= libradius.3 radius.conf.5
MLINKS+=libradius.3 rad_acct_open.3 \
libradius.3 rad_add_server.3 \
libradius.3 rad_auth_open.3 \
+ libradius.3 rad_bind_to.3 \
libradius.3 rad_close.3 \
libradius.3 rad_config.3 \
libradius.3 rad_continue_send_request.3 \
diff --git a/lib/libradius/libradius.3 b/lib/libradius/libradius.3
index 7fc11625f118..dca38ca009ee 100644
--- a/lib/libradius/libradius.3
+++ b/lib/libradius/libradius.3
@@ -91,6 +91,8 @@
.Fn rad_server_open "int fd"
.Ft "const char *"
.Fn rad_server_secret "struct rad_handle *h"
+.Ft "void"
+.Fn rad_bind_to "struct rad_handle *h" "in_addr_t addr"
.Ft u_char *
.Fn rad_demangle "struct rad_handle *h" "const void *mangled" "size_t mlen"
.Ft u_char *
@@ -431,6 +433,10 @@ returns the secret shared with the current RADIUS server according to the
supplied rad_handle.
.Pp
The
+.Fn rad_bind_to
+assigns a source address for all requests to the current RADIUS server.
+.Pp
+The
.Fn rad_demangle
function demangles attributes containing passwords and MS-CHAPv1 MPPE-Keys.
The return value is
diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
index e4e4a9411800..46a9b58c9e2f 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -756,9 +756,16 @@ rad_create_request(struct rad_handle *h, int code)
clear_password(h);
h->authentic_pos = 0;
h->out_created = 1;
+ h->bindto = INADDR_ANY;
return 0;
}
+void
+rad_bind_to(struct rad_handle *h, in_addr_t addr)
+{
+ h->bindto = addr;
+}
+
int
rad_create_response(struct rad_handle *h, int code)
{
@@ -857,7 +864,7 @@ rad_init_send_request(struct rad_handle *h, int *fd, struct timeval *tv)
memset(&sin, 0, sizeof sin);
sin.sin_len = sizeof sin;
sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
+ sin.sin_addr.s_addr = h->bindto;
sin.sin_port = htons(0);
if (bind(h->fd, (const struct sockaddr *)&sin,
sizeof sin) == -1) {
diff --git a/lib/libradius/radlib.h b/lib/libradius/radlib.h
index b26be41d66ef..f9e451b465d9 100644
--- a/lib/libradius/radlib.h
+++ b/lib/libradius/radlib.h
@@ -195,6 +195,7 @@ struct rad_handle *rad_acct_open(void);
int rad_add_server(struct rad_handle *,
const char *, int, const char *, int, int);
struct rad_handle *rad_auth_open(void);
+void rad_bind_to(struct rad_handle *, in_addr_t);
void rad_close(struct rad_handle *);
int rad_config(struct rad_handle *, const char *);
int rad_continue_send_request(struct rad_handle *, int,
diff --git a/lib/libradius/radlib_private.h b/lib/libradius/radlib_private.h
index d886c740b3fd..a76e594aa613 100644
--- a/lib/libradius/radlib_private.h
+++ b/lib/libradius/radlib_private.h
@@ -92,6 +92,7 @@ struct rad_handle {
int try; /* How many requests we've sent */
int srv; /* Server number we did last */
int type; /* Handle type */
+ in_addr_t bindto; /* Bind to address */
};
struct vendor_attribute {