hostapd: Fix internal crypto build without TLS
[wpasupplicant] / wpa_supplicant / eapol_test.c
index 17bda23..1b5ae68 100644 (file)
@@ -35,7 +35,7 @@
 extern int wpa_debug_level;
 extern int wpa_debug_show_keys;
 
-struct wpa_driver_ops *wpa_supplicant_drivers[] = { NULL };
+struct wpa_driver_ops *wpa_drivers[] = { NULL };
 
 
 struct extra_radius_attr {
@@ -156,6 +156,18 @@ static int add_extra_attrs(struct radius_msg *msg,
 }
 
 
+static struct extra_radius_attr *
+find_extra_attr(struct extra_radius_attr *attrs, u8 type)
+{
+       struct extra_radius_attr *p;
+       for (p = attrs; p; p = p->next) {
+               if (p->type == type)
+                       return p;
+       }
+       return NULL;
+}
+
+
 static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
                                          const u8 *eap, size_t len)
 {
@@ -200,7 +212,8 @@ static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
                goto fail;
        }
 
-       if (!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IP_ADDRESS,
+       if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_NAS_IP_ADDRESS) &&
+           !radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IP_ADDRESS,
                                 (u8 *) &e->own_ip_addr, 4)) {
                printf("Could not add NAS-IP-Address\n");
                goto fail;
@@ -208,7 +221,9 @@ static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
 
        os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
                    MAC2STR(e->wpa_s->own_addr));
-       if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
+       if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_CALLING_STATION_ID)
+           &&
+           !radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
                                 (u8 *) buf, os_strlen(buf))) {
                printf("Could not add Calling-Station-Id\n");
                goto fail;
@@ -217,19 +232,22 @@ static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
        /* TODO: should probably check MTU from driver config; 2304 is max for
         * IEEE 802.11, but use 1400 to avoid problems with too large packets
         */
-       if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_FRAMED_MTU, 1400)) {
+       if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_FRAMED_MTU) &&
+           !radius_msg_add_attr_int32(msg, RADIUS_ATTR_FRAMED_MTU, 1400)) {
                printf("Could not add Framed-MTU\n");
                goto fail;
        }
 
-       if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_NAS_PORT_TYPE,
+       if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_NAS_PORT_TYPE) &&
+           !radius_msg_add_attr_int32(msg, RADIUS_ATTR_NAS_PORT_TYPE,
                                       RADIUS_NAS_PORT_TYPE_IEEE_802_11)) {
                printf("Could not add NAS-Port-Type\n");
                goto fail;
        }
 
        os_snprintf(buf, sizeof(buf), "%s", e->connect_info);
-       if (!radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
+       if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_CONNECT_INFO) &&
+           !radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
                                 (u8 *) buf, os_strlen(buf))) {
                printf("Could not add Connect-Info\n");
                goto fail;
@@ -599,7 +617,8 @@ static void ieee802_1x_decapsulate_radius(struct eapol_test_data *e)
 
 static void ieee802_1x_get_keys(struct eapol_test_data *e,
                                struct radius_msg *msg, struct radius_msg *req,
-                               u8 *shared_secret, size_t shared_secret_len)
+                               const u8 *shared_secret,
+                               size_t shared_secret_len)
 {
        struct radius_ms_mppe_keys *keys;
 
@@ -646,7 +665,7 @@ static void ieee802_1x_get_keys(struct eapol_test_data *e,
 /* Process the RADIUS frames from Authentication Server */
 static RadiusRxResult
 ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
-                       u8 *shared_secret, size_t shared_secret_len,
+                       const u8 *shared_secret, size_t shared_secret_len,
                        void *data)
 {
        struct eapol_test_data *e = data;
@@ -970,7 +989,7 @@ static void usage(void)
               "automatically\n"
               "  -r<count> = number of re-authentications\n"
               "  -W = wait for a control interface monitor before starting\n"
-              "  -S = save configuration after authentiation\n"
+              "  -S = save configuration after authentication\n"
               "  -n = no MPPE keys expected\n"
               "  -t<timeout> = sets timeout in seconds (default: 30 s)\n"
               "  -C<Connect-Info> = RADIUS Connect-Info (default: "