Encode IPv6 virtual IPs in a Framed-IPv6-Prefix attribute
authorMartin Willi <martin@revosec.ch>
Fri, 24 Feb 2012 10:15:11 +0000 (11:15 +0100)
committerMartin Willi <martin@revosec.ch>
Fri, 24 Feb 2012 10:20:16 +0000 (11:20 +0100)
src/libcharon/plugins/eap_radius/eap_radius_accounting.c

index d2e2cb3..613569f 100644 (file)
@@ -146,16 +146,24 @@ static void add_ike_sa_parameters(radius_message_t *message, ike_sa_t *ike_sa)
 {
        host_t *vip;
        char buf[64];
+       chunk_t data;
 
        snprintf(buf, sizeof(buf), "%Y", ike_sa->get_other_eap_id(ike_sa));
        message->add(message, RAT_USER_NAME, chunk_create(buf, strlen(buf)));
        snprintf(buf, sizeof(buf), "%#H", ike_sa->get_other_host(ike_sa));
        message->add(message, RAT_CALLING_STATION_ID, chunk_create(buf, strlen(buf)));
        vip = ike_sa->get_virtual_ip(ike_sa, FALSE);
-       if (vip)
+       if (vip && vip->get_family(vip) == AF_INET)
        {
                message->add(message, RAT_FRAMED_IP_ADDRESS, vip->get_address(vip));
        }
+       if (vip && vip->get_family(vip) == AF_INET6)
+       {
+               /* we currently assign /128 prefixes, only (reserved, length) */
+               data = chunk_from_chars(0, 128);
+               data = chunk_cata("cc", data, vip->get_address(vip));
+               message->add(message, RAT_FRAMED_IPV6_PREFIX, data);
+       }
 }
 
 /**