From owner-svn-src-all@FreeBSD.ORG Sat Apr 21 18:30:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8D08B1065774; Sat, 21 Apr 2012 18:30:49 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 774F08FC14; Sat, 21 Apr 2012 18:30:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3LIUnaj099808; Sat, 21 Apr 2012 18:30:49 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3LIUn9P099802; Sat, 21 Apr 2012 18:30:49 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201204211830.q3LIUn9P099802@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Sat, 21 Apr 2012 18:30:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234555 - stable/8/lib/libradius X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Apr 2012 18:30:49 -0000 Author: melifaro Date: Sat Apr 21 18:30:48 2012 New Revision: 234555 URL: http://svn.freebsd.org/changeset/base/234555 Log: MFC: r228730 Add binding support to libradius(3). Submitted by: Sergey Matveychuk Approved by: kib(mentor) Modified: stable/8/lib/libradius/Makefile stable/8/lib/libradius/libradius.3 stable/8/lib/libradius/radlib.c stable/8/lib/libradius/radlib.h stable/8/lib/libradius/radlib_private.h Directory Properties: stable/8/lib/libradius/ (props changed) Modified: stable/8/lib/libradius/Makefile ============================================================================== --- stable/8/lib/libradius/Makefile Sat Apr 21 18:26:16 2012 (r234554) +++ stable/8/lib/libradius/Makefile Sat Apr 21 18:30:48 2012 (r234555) @@ -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 \ Modified: stable/8/lib/libradius/libradius.3 ============================================================================== --- stable/8/lib/libradius/libradius.3 Sat Apr 21 18:26:16 2012 (r234554) +++ stable/8/lib/libradius/libradius.3 Sat Apr 21 18:30:48 2012 (r234555) @@ -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 curre 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 Modified: stable/8/lib/libradius/radlib.c ============================================================================== --- stable/8/lib/libradius/radlib.c Sat Apr 21 18:26:16 2012 (r234554) +++ stable/8/lib/libradius/radlib.c Sat Apr 21 18:30:48 2012 (r234555) @@ -756,9 +756,16 @@ rad_create_request(struct rad_handle *h, 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 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) { Modified: stable/8/lib/libradius/radlib.h ============================================================================== --- stable/8/lib/libradius/radlib.h Sat Apr 21 18:26:16 2012 (r234554) +++ stable/8/lib/libradius/radlib.h Sat Apr 21 18:30:48 2012 (r234555) @@ -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, Modified: stable/8/lib/libradius/radlib_private.h ============================================================================== --- stable/8/lib/libradius/radlib_private.h Sat Apr 21 18:26:16 2012 (r234554) +++ stable/8/lib/libradius/radlib_private.h Sat Apr 21 18:30:48 2012 (r234555) @@ -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 {