# IP lease duration. (Leases expire even if Acct Stop packet is lost)
lease_duration = 3600
- # protocol to use. The default is IPv4.
-# ipv6 = yes
+ #
+ # As of 3.0.16, the 'ipv6 = yes' configuration is deprecated.
+ # You should use the "attribute_name" configuration item
+ # below, instead.
+ #
+
+ #
+ # The attribute to use for IP address assignment. The
+ # default is Framed-IP-Address. You can change this to any
+ # attribute which is IPv4 or IPv6.
+ #
+ # e.g. Framed-IPv6-Address, or Delegated-IPv6-Prefix.
+ #
+ attribute_name = Framed-IP-Address
# Attribute which should be considered unique per NAS
#
# which writes Module-Success-Message message.
#
messages {
- exists = "Existing IP: %{reply:Framed-IP-Address} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})"
+ exists = "Existing IP: %{reply:${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})"
success = "Allocated IP: %{reply:Framed-IP-Address} from %{control:Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})"
- clear = "Released IP %{Framed-IP-Address} (did %{Called-Station-Id} cli %{Calling-Station-Id} user %{User-Name})"
+ clear = "Released IP ${..attribute_name} (did %{Called-Station-Id} cli %{Calling-Station-Id} user %{User-Name})"
failed = "IP Allocation FAILED from %{control:Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})"
/**
* $Id$
* @file rlm_sqlippool.c
- * @brief Allocates an IPv4 address from pools stored in SQL.
+ * @brief Allocates an IP address / prefix from pools stored in SQL.
*
* @copyright 2002 Globe.Net Communications Limited
* @copyright 2006 The FreeRADIUS server project
char const *pool_name;
bool ipv6; //!< Whether or not we do IPv6 pools.
+ char const *attribute_name; //!< name of the IP address attribute
+
int framed_ip_address; //!< the attribute number for Framed-IP(v6)-Address
time_t last_clear; //!< So we only do it once a second.
{ "ipv6", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sqlippool_t, ipv6), NULL},
+ { "attribute_name", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_sqlippool_t, attribute_name), NULL},
{ "allocate-begin", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_DEPRECATED, rlm_sqlippool_t, allocate_begin), NULL },
{ "allocate_begin", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT, rlm_sqlippool_t, allocate_begin), "START TRANSACTION" },
return -1;
}
- if (!inst->ipv6) {
- inst->framed_ip_address = PW_FRAMED_IP_ADDRESS;
+ if (inst->attribute_name) {
+ DICT_ATTR const *da;
+
+ da = dict_attrbyname(inst->attribute_name);
+ if (!da) {
+ cf_log_err_cs(conf, "Unknown attribute 'attribute_name = %s'", inst->attribute_name);
+ return -1;
+ }
+
+ if (da->vendor != 0) {
+ cf_log_err_cs(conf, "Cannot use VSAs for 'attribute_name = %s'", inst->attribute_name);
+ return -1;
+ }
+
+ switch (da->type) {
+ default:
+ cf_log_err_cs(conf, "Cannot use non-IP attributes for 'attribute_name = %s'", inst->attribute_name);
+ return -1;
+
+ case PW_TYPE_IPV4_ADDR:
+ case PW_TYPE_IPV6_ADDR:
+ case PW_TYPE_IPV4_PREFIX:
+ case PW_TYPE_IPV6_PREFIX:
+ break;
+
+ }
+
+ inst->framed_ip_address = da->attr;
} else {
- inst->framed_ip_address = PW_FRAMED_IPV6_PREFIX;
+ if (!inst->ipv6) {
+ inst->framed_ip_address = PW_FRAMED_IP_ADDRESS;
+ inst->attribute_name = "Framed-IP-Address";
+ } else {
+ inst->framed_ip_address = PW_FRAMED_IPV6_PREFIX;
+ inst->attribute_name = "Framed-IPv6-Prefix";
+ }
}
if (strcmp(sql_inst->entry->name, "rlm_sql") != 0) {
time_t now;
/*
- * If there is a Framed-IP-Address attribute in the reply do nothing
+ * If there is already an attribute in the reply do nothing
*/
if (fr_pair_find_by_num(request->reply->vps, inst->framed_ip_address, 0, TAG_ANY) != NULL) {
- RDEBUG("Framed-IP-Address already exists");
+ RDEBUG("%s already exists", inst->attribute_name);
return do_logging(request, inst->log_exists, RLM_MODULE_NOOP);
}