[Midnightbsd-cvs] src [10652] trunk/lib/libradius: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jun 9 15:22:04 EDT 2018


Revision: 10652
          http://svnweb.midnightbsd.org/src/?rev=10652
Author:   laffer1
Date:     2018-06-09 15:22:04 -0400 (Sat, 09 Jun 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/lib/libradius/Makefile
    trunk/lib/libradius/libradius.3
    trunk/lib/libradius/radius.conf.5
    trunk/lib/libradius/radlib.c
    trunk/lib/libradius/radlib.h
    trunk/lib/libradius/radlib_private.h
    trunk/lib/libradius/radlib_vs.h

Property Changed:
----------------
    trunk/lib/libradius/libradius.3
    trunk/lib/libradius/radius.conf.5

Modified: trunk/lib/libradius/Makefile
===================================================================
--- trunk/lib/libradius/Makefile	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/Makefile	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 # Copyright 1998 Juniper Networks, Inc.
 # All rights reserved.
 #
@@ -22,7 +23,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/lib/libradius/Makefile 243956 2012-12-06 19:00:37Z sem $
 
 .include <bsd.own.mk>
 
@@ -35,6 +36,7 @@
 
 MLINKS+=libradius.3 rad_acct_open.3 \
 	libradius.3 rad_add_server.3 \
+	libradius.3 rad_add_server_ex.3 \
 	libradius.3 rad_auth_open.3 \
 	libradius.3 rad_bind_to.3 \
 	libradius.3 rad_close.3 \

Modified: trunk/lib/libradius/libradius.3
===================================================================
--- trunk/lib/libradius/libradius.3	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/libradius.3	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright 1998 Juniper Networks, Inc.
 .\" Copyright 2009 Alexander Motin <mav at FreeBSD.org>.
 .\" All rights reserved.
@@ -23,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libradius/libradius.3 245234 2013-01-09 19:49:35Z ae $
 .\"
 .Dd August 5, 2009
 .Dt LIBRADIUS 3
@@ -37,6 +38,8 @@
 .Fn rad_acct_open "void"
 .Ft int
 .Fn rad_add_server "struct rad_handle *h" "const char *host" "int port" "const char *secret" "int timeout" "int max_tries"
+.Ft int
+.Fn rad_add_server_ex "struct rad_handle *h" "const char *host" "int port" "const char *secret" "int timeout" "int max_tries" "int dead_time" "struct in_addr *bindto"
 .Ft "struct rad_handle *"
 .Fn rad_auth_open "void"
 .Ft void
@@ -51,7 +54,7 @@
 .Fn rad_create_response "struct rad_handle *h" "int code"
 .Ft "struct in_addr"
 .Fn rad_cvt_addr "const void *data"
-.Ft u_int32_t
+.Ft uint32_t
 .Fn rad_cvt_int "const void *data"
 .Ft char *
 .Fn rad_cvt_string "const void *data" "size_t len"
@@ -58,7 +61,7 @@
 .Ft int
 .Fn rad_get_attr "struct rad_handle *h" "const void **data" "size_t *len"
 .Ft int
-.Fn rad_get_vendor_attr "u_int32_t *vendor" "const void **data" "size_t *len"
+.Fn rad_get_vendor_attr "uint32_t *vendor" "const void **data" "size_t *len"
 .Ft int
 .Fn rad_init_send_request "struct rad_handle *h" "int *fd" "struct timeval *tv"
 .Ft int
@@ -66,7 +69,7 @@
 .Ft int
 .Fn rad_put_attr "struct rad_handle *h" "int type" "const void *data" "size_t len"
 .Ft int
-.Fn rad_put_int "struct rad_handle *h" "int type" "u_int32_t value"
+.Fn rad_put_int "struct rad_handle *h" "int type" "uint32_t value"
 .Ft int
 .Fn rad_put_string "struct rad_handle *h" "int type" "const char *str"
 .Ft int
@@ -76,7 +79,7 @@
 .Ft int
 .Fn rad_put_vendor_attr "struct rad_handle *h" "int vendor" "int type" "const void *data" "size_t len"
 .Ft int
-.Fn rad_put_vendor_int "struct rad_handle *h" "int vendor" "int type" "u_int32_t value"
+.Fn rad_put_vendor_int "struct rad_handle *h" "int vendor" "int type" "uint32_t value"
 .Ft int
 .Fn rad_put_vendor_string "struct rad_handle *h" "int vendor" "int type" "const char *str"
 .Ft ssize_t
@@ -153,7 +156,12 @@
 returns 0 on success, or \-1 if an error occurs.
 .Pp
 The library can also be configured programmatically by calls to
-.Fn rad_add_server .
+.Fn rad_add_server
+or
+.Fn rad_add_server_ex .
+.Fn rad_add_server
+is a backward compatible function, implemented via
+.Fn rad_add_server_ex .
 The
 .Fa host
 parameter specifies the server host, either as a fully qualified
@@ -188,11 +196,20 @@
 requests to make before giving up is passed into the
 .Fa max_tries
 parameter.
+Time interval in seconds when the server will not be requested
+if it is marked as dead (did not answer on the last try) set with
+.Fa dead_time
+parameter.
+.Fa bindto
+parameter is an IP address on the multihomed host that is used as
+a source address for all requests.
 .Fn rad_add_server
 returns 0 on success, or \-1 if an error occurs.
 .Pp
 .Fn rad_add_server
-may be called multiple times, and it may be used together with
+or
+.Fn rad_add_server_ex
+may be called multiple times, and they may be used together with
 .Fn rad_config .
 At most 10 servers may be specified.
 When multiple servers are given, they are tried in round-robin


Property changes on: trunk/lib/libradius/libradius.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libradius/radius.conf.5
===================================================================
--- trunk/lib/libradius/radius.conf.5	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/radius.conf.5	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright 1998 Juniper Networks, Inc.
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libradius/radius.conf.5 250582 2013-05-12 22:22:12Z joel $
 .\"
 .Dd October 30, 1999
 .Dt RADIUS.CONF 5
@@ -44,7 +45,7 @@
 white space is ignored, as are empty lines and lines containing
 only comments.
 .Pp
-A RADIUS server is described by three to five fields on a line:
+A RADIUS server is described by three to seven fields on a line:
 .Pp
 .Bl -item -offset indent -compact
 .It
@@ -57,6 +58,10 @@
 Timeout
 .It
 Retries
+.It
+Dead time
+.It
+Bind address
 .El
 .Pp
 The fields are separated by white space.
@@ -139,6 +144,13 @@
 Note,
 this is the total number of attempts and not the number of retries.
 .Pp
+The sixth field contains a decimal integer specifying a time interval
+in seconds when the server will not requested if it was inaccessible
+on the last try. 0 means ask always.
+.Pp
+The seventh field contains an IP address on multihomed host. All
+requests will be binded to this IP.
+.Pp
 Up to 10 RADIUS servers may be specified for each service type.
 The servers are tried in
 round-robin fashion, until a valid response is received or the
@@ -151,7 +163,9 @@
 Since the file contains sensitive information in the form of the
 shared secrets, it should not be readable except by root.
 .Sh FILES
-.Pa /etc/radius.conf
+.Bl -tag -width Pa
+.It Pa /etc/radius.conf
+.El
 .Sh EXAMPLES
 .Bd -literal
 # A simple entry using all the defaults:
@@ -161,6 +175,9 @@
 # timeout and maximum tries:
 auth  auth.domain.com:1645  "I can't see you"  5  4
 
+# As above but set dead time and bind address
+auth  auth.domain.com:1645  "I can't see you"  5  4  60  192.168.1.8
+
 # A server specified by its IP address:
 auth  192.168.27.81  $X*#..38947ax-+=
 .Ed


Property changes on: trunk/lib/libradius/radius.conf.5
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libradius/radlib.c
===================================================================
--- trunk/lib/libradius/radlib.c	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/radlib.c	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 1998 Juniper Networks, Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libradius/radlib.c 243964 2012-12-07 01:36:53Z delphij $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -43,6 +44,8 @@
 #include <md5.h>
 #endif
 
+#define	MAX_FIELDS	7
+
 /* We need the MPPE_KEY_LEN define */
 #include <netgraph/ng_mppc.h>
 
@@ -379,6 +382,18 @@
 rad_add_server(struct rad_handle *h, const char *host, int port,
     const char *secret, int timeout, int tries)
 {
+    	struct in_addr bindto;
+	bindto.s_addr = INADDR_ANY;
+
+	return rad_add_server_ex(h, host, port, secret, timeout, tries,
+		DEAD_TIME, &bindto);
+}
+
+int
+rad_add_server_ex(struct rad_handle *h, const char *host, int port,
+    const char *secret, int timeout, int tries, int dead_time,
+    struct in_addr *bindto)
+{
 	struct rad_server *srvp;
 
 	if (h->num_servers >= MAXSERVERS) {
@@ -421,6 +436,10 @@
 	srvp->timeout = timeout;
 	srvp->max_tries = tries;
 	srvp->num_tries = 0;
+	srvp->is_dead = 0;
+	srvp->dead_time = dead_time;
+	srvp->next_probe = 0;
+	srvp->bindto = bindto->s_addr;
 	h->num_servers++;
 	return 0;
 }
@@ -441,6 +460,13 @@
 	free(h);
 }
 
+void
+rad_bind_to(struct rad_handle *h, in_addr_t addr)
+{
+
+	h->bindto = addr;
+}
+
 int
 rad_config(struct rad_handle *h, const char *path)
 {
@@ -459,7 +485,7 @@
 	linenum = 0;
 	while (fgets(buf, sizeof buf, fp) != NULL) {
 		int len;
-		char *fields[5];
+		char *fields[MAX_FIELDS];
 		int nfields;
 		char msg[ERRSIZE];
 		char *type;
@@ -468,11 +494,15 @@
 		char *secret;
 		char *timeout_str;
 		char *maxtries_str;
+		char *dead_time_str;
+		char *bindto_str;
 		char *end;
 		char *wanttype;
 		unsigned long timeout;
 		unsigned long maxtries;
+		unsigned long dead_time;
 		int port;
+		struct in_addr bindto;
 		int i;
 
 		linenum++;
@@ -491,7 +521,7 @@
 		buf[len - 1] = '\0';
 
 		/* Extract the fields from the line. */
-		nfields = split(buf, fields, 5, msg, sizeof msg);
+		nfields = split(buf, fields, MAX_FIELDS, msg, sizeof msg);
 		if (nfields == -1) {
 			generr(h, "%s:%d: %s", path, linenum, msg);
 			retval = -1;
@@ -507,7 +537,7 @@
 		 */
 		if (strcmp(fields[0], "auth") != 0 &&
 		    strcmp(fields[0], "acct") != 0) {
-			if (nfields >= 5) {
+			if (nfields >= MAX_FIELDS) {
 				generr(h, "%s:%d: invalid service type", path,
 				    linenum);
 				retval = -1;
@@ -529,6 +559,8 @@
 		secret = fields[2];
 		timeout_str = fields[3];
 		maxtries_str = fields[4];
+		dead_time_str = fields[5];
+		bindto_str = fields[6];
 
 		/* Ignore the line if it is for the wrong service type. */
 		wanttype = h->type == RADIUS_AUTH ? "auth" : "acct";
@@ -570,8 +602,30 @@
 		} else
 			maxtries = MAXTRIES;
 
-		if (rad_add_server(h, host, port, secret, timeout, maxtries) ==
-		    -1) {
+		if (dead_time_str != NULL) {
+			dead_time = strtoul(dead_time_str, &end, 10);
+			if (*end != '\0') {
+				generr(h, "%s:%d: invalid dead_time", path,
+				    linenum);
+				retval = -1;
+				break;
+			}
+		} else
+		    	dead_time = DEAD_TIME;
+
+		if (bindto_str != NULL) {
+		    	bindto.s_addr = inet_addr(bindto_str);
+			if (bindto.s_addr == INADDR_NONE) {
+				generr(h, "%s:%d: invalid bindto", path,
+				    linenum);
+				retval = -1;
+				break;
+			}
+		} else
+		    	bindto.s_addr = INADDR_ANY;
+
+		if (rad_add_server_ex(h, host, port, secret, timeout, maxtries,
+			    dead_time, &bindto) == -1) {
 			strcpy(msg, h->errmsg);
 			generr(h, "%s:%d: %s", path, linenum, msg);
 			retval = -1;
@@ -596,7 +650,9 @@
 rad_continue_send_request(struct rad_handle *h, int selected, int *fd,
                           struct timeval *tv)
 {
-	int n;
+	int n, cur_srv;
+	time_t now;
+	struct sockaddr_in sin;
 
 	if (h->type == RADIUS_SERVER) {
 		generr(h, "denied function call");
@@ -621,20 +677,62 @@
 		}
 	}
 
-	if (h->try == h->total_tries) {
-		generr(h, "No valid RADIUS responses received");
-		return -1;
-	}
-
 	/*
          * Scan round-robin to the next server that has some
          * tries left.  There is guaranteed to be one, or we
          * would have exited this loop by now.
 	 */
-	while (h->servers[h->srv].num_tries >= h->servers[h->srv].max_tries)
-		if (++h->srv >= h->num_servers)
-			h->srv = 0;
+	cur_srv = h->srv;
+	now = time(NULL);
+	if (h->servers[h->srv].num_tries >= h->servers[h->srv].max_tries) {
+		/* Set next probe time for this server */
+		if (h->servers[h->srv].dead_time) {
+			h->servers[h->srv].is_dead = 1;
+			h->servers[h->srv].next_probe = now +
+			    h->servers[h->srv].dead_time;
+		}
+		do {
+		    	h->srv++;
+			if (h->srv >= h->num_servers)
+				h->srv = 0;
+			if (h->servers[h->srv].is_dead == 0)
+			    	break;
+			if (h->servers[h->srv].dead_time &&
+			    h->servers[h->srv].next_probe <= now) {
+			    	h->servers[h->srv].is_dead = 0;
+				h->servers[h->srv].num_tries = 0;
+				break;
+			}
+		} while (h->srv != cur_srv);
 
+		if (h->srv == cur_srv) {
+			generr(h, "No valid RADIUS responses received");
+			return (-1);
+		}
+	}
+
+	/* Rebind */
+	if (h->bindto != h->servers[h->srv].bindto) {
+	    	h->bindto = h->servers[h->srv].bindto;
+		close(h->fd);
+		if ((h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
+			generr(h, "Cannot create socket: %s", strerror(errno));
+			return -1;
+		}
+		memset(&sin, 0, sizeof sin);
+		sin.sin_len = sizeof sin;
+		sin.sin_family = AF_INET;
+		sin.sin_addr.s_addr = h->bindto;
+		sin.sin_port = 0;
+		if (bind(h->fd, (const struct sockaddr *)&sin,
+		    sizeof sin) == -1) {
+			generr(h, "bind: %s", strerror(errno));
+			close(h->fd);
+			h->fd = -1;
+			return (-1);
+		}
+	}
+
 	if (h->out[POS_CODE] == RAD_ACCESS_REQUEST) {
 		/* Insert the scrambled password into the request */
 		if (h->pass_pos != 0)
@@ -641,9 +739,11 @@
 			insert_scrambled_password(h, h->srv);
 	}
 	insert_message_authenticator(h, 0);
+
 	if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
 		/* Insert the request authenticator into the request */
-		insert_request_authenticator(h, h->srv);
+		memset(&h->out[POS_AUTH], 0, LEN_AUTH);
+		insert_request_authenticator(h, 0);
 	}
 
 	/* Send the request */
@@ -654,7 +754,6 @@
 		tv->tv_sec = 1; /* Do not wait full timeout if send failed. */
 	else
 		tv->tv_sec = h->servers[h->srv].timeout;
-	h->try++;
 	h->servers[h->srv].num_tries++;
 	tv->tv_usec = 0;
 	*fd = h->fd;
@@ -740,6 +839,10 @@
 		generr(h, "denied function call");
 		return (-1);
 	}
+	if (h->num_servers == 0) {
+	    	generr(h, "No RADIUS servers specified");
+		return (-1);
+	}
 	h->out[POS_CODE] = code;
 	h->out[POS_IDENT] = ++h->ident;
 	if (code == RAD_ACCESS_REQUEST) {
@@ -756,16 +859,9 @@
 	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)
 {
@@ -793,6 +889,15 @@
 	return value;
 }
 
+struct in6_addr
+rad_cvt_addr6(const void *data)
+{
+	struct in6_addr value;
+
+	memcpy(&value.s6_addr, data, sizeof value.s6_addr);
+	return value;
+}
+
 u_int32_t
 rad_cvt_int(const void *data)
 {
@@ -848,6 +953,8 @@
 rad_init_send_request(struct rad_handle *h, int *fd, struct timeval *tv)
 {
 	int srv;
+	time_t now;
+	struct sockaddr_in sin;
 
 	if (h->type == RADIUS_SERVER) {
 		generr(h, "denied function call");
@@ -855,8 +962,6 @@
 	}
 	/* Make sure we have a socket to use */
 	if (h->fd == -1) {
-		struct sockaddr_in sin;
-
 		if ((h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
 			generr(h, "Cannot create socket: %s", strerror(errno));
 			return -1;
@@ -902,22 +1007,31 @@
 	h->out[POS_LENGTH] = h->out_len >> 8;
 	h->out[POS_LENGTH+1] = h->out_len;
 
-	/*
-	 * Count the total number of tries we will make, and zero the
-	 * counter for each server.
-	 */
-	h->total_tries = 0;
+	h->srv = 0;
+	now = time(NULL);
+	for (srv = 0;  srv < h->num_servers;  srv++)
+		h->servers[srv].num_tries = 0;
+	/* Find a first good server. */
 	for (srv = 0;  srv < h->num_servers;  srv++) {
-		h->total_tries += h->servers[srv].max_tries;
-		h->servers[srv].num_tries = 0;
+		if (h->servers[srv].is_dead == 0)
+			break;
+		if (h->servers[srv].dead_time &&
+		    h->servers[srv].next_probe <= now) {
+		    	h->servers[srv].is_dead = 0;
+			break;
+		}
+		h->srv++;
 	}
-	if (h->total_tries == 0) {
-		generr(h, "No RADIUS servers specified");
-		return -1;
+
+	/* If all servers was dead on the last probe, try from beginning */
+	if (h->srv == h->num_servers) {
+		for (srv = 0;  srv < h->num_servers;  srv++) {
+		    	h->servers[srv].is_dead = 0;
+			h->servers[srv].next_probe = 0;
+		}
+		h->srv = 0;
 	}
 
-	h->try = h->srv = 0;
-
 	return rad_continue_send_request(h, 0, fd, tv);
 }
 
@@ -946,6 +1060,7 @@
 		h->type = RADIUS_AUTH;
 		h->out_created = 0;
 		h->eap_msg = 0;
+		h->bindto = INADDR_ANY;
 	}
 	return h;
 }
@@ -987,6 +1102,13 @@
 }
 
 int
+rad_put_addr6(struct rad_handle *h, int type, struct in6_addr addr)
+{
+
+	return rad_put_attr(h, type, &addr.s6_addr, sizeof addr.s6_addr);
+}
+
+int
 rad_put_attr(struct rad_handle *h, int type, const void *value, size_t len)
 {
 	int result;
@@ -1229,6 +1351,15 @@
 }
 
 int
+rad_put_vendor_addr6(struct rad_handle *h, int vendor, int type,
+    struct in6_addr addr)
+{
+
+	return (rad_put_vendor_attr(h, vendor, type, &addr.s6_addr,
+	    sizeof addr.s6_addr));
+}
+
+int
 rad_put_vendor_attr(struct rad_handle *h, int vendor, int type,
     const void *value, size_t len)
 {

Modified: trunk/lib/libradius/radlib.h
===================================================================
--- trunk/lib/libradius/radlib.h	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/radlib.h	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 1998 Juniper Networks, Inc.
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$MidnightBSD$
+ *	$FreeBSD: stable/10/lib/libradius/radlib.h 315153 2017-03-12 13:36:14Z des $
  */
 
 #ifndef _RADLIB_H_
@@ -98,7 +99,7 @@
 #define RAD_TERMINATION_ACTION		29	/* Integer */
 #define RAD_CALLED_STATION_ID		30	/* String */
 #define RAD_CALLING_STATION_ID		31	/* String */
-#define RAD_NAS_IDENTIFIER		32	/* Integer */
+#define RAD_NAS_IDENTIFIER		32	/* String */
 #define RAD_PROXY_STATE			33	/* Integer */
 #define RAD_LOGIN_LAT_SERVICE		34	/* Integer */
 #define RAD_LOGIN_LAT_NODE		35	/* Integer */
@@ -194,6 +195,9 @@
 struct rad_handle	*rad_acct_open(void);
 int			 rad_add_server(struct rad_handle *,
 			    const char *, int, const char *, int, int);
+int			 rad_add_server_ex(struct rad_handle *,
+			    const char *, int, const char *, int, int,
+			    int, struct in_addr *);
 struct rad_handle	*rad_auth_open(void);
 void			 rad_bind_to(struct rad_handle *, in_addr_t);
 void			 rad_close(struct rad_handle *);
@@ -203,6 +207,7 @@
 int			 rad_create_request(struct rad_handle *, int);
 int			 rad_create_response(struct rad_handle *, int);
 struct in_addr		 rad_cvt_addr(const void *);
+struct in6_addr		 rad_cvt_addr6(const void *);
 u_int32_t		 rad_cvt_int(const void *);
 char			*rad_cvt_string(const void *, size_t);
 int			 rad_get_attr(struct rad_handle *, const void **,
@@ -211,6 +216,7 @@
 			    struct timeval *);
 struct rad_handle	*rad_open(void);  /* Deprecated, == rad_auth_open */
 int			 rad_put_addr(struct rad_handle *, int, struct in_addr);
+int			 rad_put_addr6(struct rad_handle *, int, struct in6_addr);
 int			 rad_put_attr(struct rad_handle *, int,
 			    const void *, size_t);
 int			 rad_put_int(struct rad_handle *, int, u_int32_t);

Modified: trunk/lib/libradius/radlib_private.h
===================================================================
--- trunk/lib/libradius/radlib_private.h	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/radlib_private.h	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 1998 Juniper Networks, Inc.
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$MidnightBSD$
+ *	$FreeBSD: stable/10/lib/libradius/radlib_private.h 243956 2012-12-06 19:00:37Z sem $
  */
 
 #ifndef RADLIB_PRIVATE_H
@@ -46,6 +47,7 @@
 #define RADIUS_PORT		1812
 #define RADACCT_PORT		1813
 #define TIMEOUT			3	/* In seconds */
+#define	DEAD_TIME		0
 
 /* Limits */
 #define ERRSIZE		128		/* Maximum error message length */
@@ -68,6 +70,10 @@
 	int		 timeout;	/* Timeout in seconds */
 	int		 max_tries;	/* Number of tries before giving up */
 	int		 num_tries;	/* Number of tries so far */
+	int		 is_dead;	/* The server did not answer last time */
+	time_t		 dead_time;	/* Don't try this server for the time period if it is dead */
+	time_t		 next_probe;	/* Time of a next probe after failure */
+	in_addr_t	 bindto;	/* Bind to address */
 };
 
 struct rad_handle {
@@ -88,11 +94,9 @@
 	unsigned char	 in[MSGSIZE];	/* Response received */
 	int		 in_len;	/* Length of response */
 	int		 in_pos;	/* Current position scanning attrs */
-	int		 total_tries;	/* How many requests we'll send */
-	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 */
+	in_addr_t	 bindto;	/* Current bind address */
 };
 
 struct vendor_attribute {

Modified: trunk/lib/libradius/radlib_vs.h
===================================================================
--- trunk/lib/libradius/radlib_vs.h	2018-06-09 19:21:12 UTC (rev 10651)
+++ trunk/lib/libradius/radlib_vs.h	2018-06-09 19:22:04 UTC (rev 10652)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Brian Somers <brian at Awfulhak.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libradius/radlib_vs.h 243956 2012-12-06 19:00:37Z sem $
  */
 
 #ifndef _RADLIB_VS_H_
@@ -73,6 +74,7 @@
 __BEGIN_DECLS
 int	 rad_get_vendor_attr(u_int32_t *, const void **, size_t *);
 int	 rad_put_vendor_addr(struct rad_handle *, int, int, struct in_addr);
+int	 rad_put_vendor_addr6(struct rad_handle *, int, int, struct in6_addr);
 int	 rad_put_vendor_attr(struct rad_handle *, int, int, const void *,
 	    size_t);
 int	 rad_put_vendor_int(struct rad_handle *, int, int, u_int32_t);



More information about the Midnightbsd-cvs mailing list