sizeof(client->ipaddr.ipaddr.ip6addr));
} else if (client->prefix < 128) {
- int i;
uint32_t mask, *addr;
addr = (uint32_t *) &client->ipaddr.ipaddr.ip6addr;
- for (i = client->prefix; i < 128; i += 32) {
- mask = ~0;
- mask <<= ((128 - i) & 0x1f);
- addr[i / 32] &= mask;
+ if ((client->prefix & 0x1f) == 0) {
+ mask = 0;
+ } else {
+ mask = ~ ((uint32_t) 0);
+ mask <<= (32 - (client->prefix & 0x1f));
+ mask = htonl(mask);
+ }
+
+ switch (client->prefix >> 5) {
+ case 0:
+ addr[0] &= mask;
+ mask = 0;
+ /* FALL-THROUGH */
+ case 1:
+ addr[1] &= mask;
+ mask = 0;
+ /* FALL-THROUGH */
+ case 2:
+ addr[2] &= mask;
+ mask = 0;
+ /* FALL-THROUGH */
+ case 3:
+ addr[3] &= mask;
+ break;
}
}
break;
* If there IS an enclosing network,
* inherit the lifetime from it.
*/
- network = client_find(clients, &client->ipaddr
-#ifdef WITH_TCP
- , client->proto
-#endif
- );
+ network = client_find(clients, &client->ipaddr, client->proto);
if (network) {
client->lifetime = network->lifetime;
}
#ifdef WITH_DYNAMIC_CLIENTS
void client_delete(RADCLIENT_LIST *clients, RADCLIENT *client)
{
- if (!clients || !client) return;
+ if (!client) return;
+
+ if (!clients) clients = root_clients;
+
+ if (!client->dynamic) return;
rad_assert((client->prefix >= 0) && (client->prefix <= 128));
client->dynamic = 2; /* signal to client_free */
+#ifdef WITH_STATS
rbtree_deletebydata(tree_num, client);
+#endif
rbtree_deletebydata(clients->trees[client->prefix], client);
}
#endif
* Find a client in the RADCLIENTS list.
*/
RADCLIENT *client_find(const RADCLIENT_LIST *clients,
- const fr_ipaddr_t *ipaddr
-#ifdef WITH_TCP
- , int proto
-#endif
- )
+ const fr_ipaddr_t *ipaddr, int proto)
{
int i, max_prefix;
RADCLIENT myclient;
myclient.prefix = i;
myclient.ipaddr = *ipaddr;
-#ifdef WITH_TCP
myclient.proto = proto;
-#endif
client_sane(&myclient); /* clean up the ipaddress */
if (!clients->trees[i]) continue;
offsetof(RADCLIENT, client_server), 0, NULL },
{ "lifetime", PW_TYPE_INTEGER,
offsetof(RADCLIENT, lifetime), 0, NULL },
+ { "rate_limit", PW_TYPE_BOOLEAN,
+ offsetof(RADCLIENT, rate_limit), 0, NULL },
#endif
#ifdef WITH_COA
*/
if (!c->shortname) c->shortname = strdup(name2);
-#ifdef WITH_TCP
c->proto = IPPROTO_UDP;
+#ifdef WITH_TCP
if (hs_proto) {
if (strcmp(hs_proto, "udp") == 0) {
free(hs_proto);
return NULL;
}
- vp = pairfind(request->config_items, da->attr);
+ vp = pairfind(request->config_items, da->attr, da->vendor);
if (!vp) {
/*
* Not required. Skip it.