Move driver deinitialization away from hostapd.c
[libeap.git] / wpa_supplicant / ap.c
1 /*
2  * WPA Supplicant - Basic AP mode support routines
3  * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2009, Atheros Communications
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15
16 #include "includes.h"
17
18 #include "common.h"
19 #include "ap/hostapd.h"
20 #include "ap/config.h"
21 #ifdef NEED_AP_MLME
22 #include "ap/ieee802_11.h"
23 #endif /* NEED_AP_MLME */
24 #include "ap/wps_hostapd.h"
25 #include "ap/ctrl_iface_ap.h"
26 #include "eap_common/eap_defs.h"
27 #include "eap_server/eap_methods.h"
28 #include "eap_common/eap_wsc_common.h"
29 #include "wps/wps.h"
30 #include "config_ssid.h"
31 #include "config.h"
32 #include "wpa_supplicant_i.h"
33 #include "driver_i.h"
34 #include "ap.h"
35
36
37 struct hapd_interfaces {
38         size_t count;
39         struct hostapd_iface **iface;
40 };
41
42
43 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
44                                int (*cb)(struct hostapd_iface *iface,
45                                          void *ctx), void *ctx)
46 {
47         /* TODO */
48         return 0;
49 }
50
51
52 int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
53 {
54         return 0;
55 }
56
57
58 void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
59 {
60 }
61
62
63 struct ap_driver_data {
64         struct hostapd_data *hapd;
65 };
66
67
68 static void * ap_driver_init(struct hostapd_data *hapd,
69                              struct wpa_init_params *params)
70 {
71         struct ap_driver_data *drv;
72         struct wpa_supplicant *wpa_s = hapd->iface->owner;
73
74         drv = os_zalloc(sizeof(struct ap_driver_data));
75         if (drv == NULL) {
76                 wpa_printf(MSG_ERROR, "Could not allocate memory for AP "
77                            "driver data");
78                 return NULL;
79         }
80         drv->hapd = hapd;
81         os_memcpy(hapd->own_addr, wpa_s->own_addr, ETH_ALEN);
82
83         return drv;
84 }
85
86
87 static void ap_driver_deinit(void *priv)
88 {
89         struct ap_driver_data *drv = priv;
90
91         os_free(drv);
92 }
93
94
95 static int ap_driver_send_ether(void *priv, const u8 *dst, const u8 *src,
96                                 u16 proto, const u8 *data, size_t data_len)
97 {
98         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
99         return -1;
100 }
101
102
103 static int ap_driver_set_key(const char *iface, void *priv, wpa_alg alg,
104                              const u8 *addr, int key_idx, int set_tx,
105                              const u8 *seq, size_t seq_len, const u8 *key,
106                              size_t key_len)
107 {
108         struct ap_driver_data *drv = priv;
109         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
110         return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
111                                key, key_len);
112 }
113
114
115 static int ap_driver_get_seqnum(const char *iface, void *priv, const u8 *addr,
116                                 int idx, u8 *seq)
117 {
118         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
119         return -1;
120 }
121
122
123 static int ap_driver_flush(void *priv)
124 {
125         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
126         return -1;
127 }
128
129
130 static int ap_driver_read_sta_data(void *priv,
131                                    struct hostap_sta_driver_data *data,
132                                    const u8 *addr)
133 {
134         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
135         return -1;
136 }
137
138
139 static int ap_driver_sta_set_flags(void *priv, const u8 *addr, int total_flags,
140                                    int flags_or, int flags_and)
141 {
142         struct ap_driver_data *drv = priv;
143         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
144         return wpa_drv_sta_set_flags(wpa_s, addr, total_flags, flags_or,
145                                      flags_and);
146 }
147
148
149 static int ap_driver_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
150                                 int reason)
151 {
152         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
153         return -1;
154 }
155
156
157 static int ap_driver_sta_disassoc(void *priv, const u8 *own_addr,
158                                   const u8 *addr, int reason)
159 {
160         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
161         return -1;
162 }
163
164
165 static int ap_driver_sta_remove(void *priv, const u8 *addr)
166 {
167         struct ap_driver_data *drv = priv;
168         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
169         return wpa_drv_sta_remove(wpa_s, addr);
170 }
171
172
173 static int ap_driver_send_mlme(void *priv, const u8 *data, size_t len)
174 {
175         struct ap_driver_data *drv = priv;
176         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
177         return wpa_drv_send_mlme(wpa_s, data, len);
178 }
179
180
181 static int ap_driver_sta_add(const char *ifname, void *priv,
182                              struct hostapd_sta_add_params *params)
183 {
184         struct ap_driver_data *drv = priv;
185         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
186         return wpa_drv_sta_add(wpa_s, params);
187 }
188
189
190 static int ap_driver_get_inact_sec(void *priv, const u8 *addr)
191 {
192         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
193         return -1;
194 }
195
196
197 static int ap_driver_set_freq(void *priv, struct hostapd_freq_params *freq)
198 {
199         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
200         return 0;
201 }
202
203
204 static int ap_driver_set_beacon(const char *iface, void *priv,
205                                 const u8 *head, size_t head_len,
206                                 const u8 *tail, size_t tail_len,
207                                 int dtim_period, int beacon_int)
208 {
209         struct ap_driver_data *drv = priv;
210         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
211         return wpa_drv_set_beacon(wpa_s, head, head_len, tail, tail_len,
212                                   dtim_period, beacon_int);
213 }
214
215
216 static int ap_driver_set_cts_protect(void *priv, int value)
217 {
218         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
219         return -1;
220 }
221
222
223 static int ap_driver_set_preamble(void *priv, int value)
224 {
225         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
226         return -1;
227 }
228
229
230 static int ap_driver_set_short_slot_time(void *priv, int value)
231 {
232         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
233         return -1;
234 }
235
236
237 static int ap_driver_set_tx_queue_params(void *priv, int queue, int aifs,
238                                          int cw_min, int cw_max,
239                                          int burst_time)
240 {
241         wpa_printf(MSG_DEBUG, "AP TODO: %s", __func__);
242         return -1;
243 }
244
245
246 static struct hostapd_hw_modes *ap_driver_get_hw_feature_data(void *priv,
247                                                               u16 *num_modes,
248                                                               u16 *flags)
249 {
250         struct ap_driver_data *drv = priv;
251         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
252         return wpa_drv_get_hw_feature_data(wpa_s, num_modes, flags);
253 }
254
255
256 static int ap_driver_hapd_send_eapol(void *priv, const u8 *addr,
257                                      const u8 *data, size_t data_len,
258                                      int encrypt, const u8 *own_addr)
259 {
260         struct ap_driver_data *drv = priv;
261         struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
262         return wpa_drv_hapd_send_eapol(wpa_s, addr, data, data_len, encrypt,
263                                        own_addr);
264 }
265
266
267 struct wpa_driver_ops ap_driver_ops =
268 {
269         .name = "wpa_supplicant",
270         .hapd_init = ap_driver_init,
271         .hapd_deinit = ap_driver_deinit,
272         .send_ether = ap_driver_send_ether,
273         .set_key = ap_driver_set_key,
274         .get_seqnum = ap_driver_get_seqnum,
275         .flush = ap_driver_flush,
276         .read_sta_data = ap_driver_read_sta_data,
277         .sta_set_flags = ap_driver_sta_set_flags,
278         .sta_deauth = ap_driver_sta_deauth,
279         .sta_disassoc = ap_driver_sta_disassoc,
280         .sta_remove = ap_driver_sta_remove,
281         .send_mlme = ap_driver_send_mlme,
282         .sta_add = ap_driver_sta_add,
283         .get_inact_sec = ap_driver_get_inact_sec,
284         .set_freq = ap_driver_set_freq,
285         .set_beacon = ap_driver_set_beacon,
286         .set_cts_protect = ap_driver_set_cts_protect,
287         .set_preamble = ap_driver_set_preamble,
288         .set_short_slot_time = ap_driver_set_short_slot_time,
289         .set_tx_queue_params = ap_driver_set_tx_queue_params,
290         .get_hw_feature_data = ap_driver_get_hw_feature_data,
291         .hapd_send_eapol = ap_driver_hapd_send_eapol,
292 };
293
294
295 extern struct wpa_driver_ops *wpa_drivers[];
296
297 static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
298                                   struct wpa_ssid *ssid,
299                                   struct hostapd_config *conf)
300 {
301         struct hostapd_bss_config *bss = &conf->bss[0];
302         int j, pairwise;
303
304         for (j = 0; wpa_drivers[j]; j++) {
305                 if (os_strcmp("wpa_supplicant", wpa_drivers[j]->name) == 0) {
306                         conf->driver = wpa_drivers[j];
307                         break;
308                 }
309         }
310         if (conf->driver == NULL) {
311                 wpa_printf(MSG_ERROR, "No AP driver ops found");
312                 return -1;
313         }
314
315         os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));
316
317         if (ssid->frequency == 0) {
318                 /* default channel 11 */
319                 conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
320                 conf->channel = 11;
321         } else if (ssid->frequency >= 2412 && ssid->frequency <= 2472) {
322                 conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
323                 conf->channel = (ssid->frequency - 2407) / 5;
324         } else if ((ssid->frequency >= 5180 && ssid->frequency <= 5240) ||
325                    (ssid->frequency >= 5745 && ssid->frequency <= 5825)) {
326                 conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
327                 conf->channel = (ssid->frequency - 5000) / 5;
328         } else {
329                 wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
330                            ssid->frequency);
331                 return -1;
332         }
333
334         /* TODO: enable HT if driver supports it;
335          * drop to 11b if driver does not support 11g */
336
337         if (ssid->ssid_len == 0) {
338                 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
339                 return -1;
340         }
341         os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
342         bss->ssid.ssid[ssid->ssid_len] = '\0';
343         bss->ssid.ssid_len = ssid->ssid_len;
344         bss->ssid.ssid_set = 1;
345
346         if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
347                 bss->wpa = ssid->proto;
348         bss->wpa_key_mgmt = ssid->key_mgmt;
349         bss->wpa_pairwise = ssid->pairwise_cipher;
350         if (ssid->passphrase) {
351                 bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
352         } else if (ssid->psk_set) {
353                 os_free(bss->ssid.wpa_psk);
354                 bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
355                 if (bss->ssid.wpa_psk == NULL)
356                         return -1;
357                 os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN);
358                 bss->ssid.wpa_psk->group = 1;
359         }
360
361         /* Select group cipher based on the enabled pairwise cipher suites */
362         pairwise = 0;
363         if (bss->wpa & 1)
364                 pairwise |= bss->wpa_pairwise;
365         if (bss->wpa & 2) {
366                 if (bss->rsn_pairwise == 0)
367                         bss->rsn_pairwise = bss->wpa_pairwise;
368                 pairwise |= bss->rsn_pairwise;
369         }
370         if (pairwise & WPA_CIPHER_TKIP)
371                 bss->wpa_group = WPA_CIPHER_TKIP;
372         else
373                 bss->wpa_group = WPA_CIPHER_CCMP;
374
375         if (bss->wpa && bss->ieee802_1x)
376                 bss->ssid.security_policy = SECURITY_WPA;
377         else if (bss->wpa)
378                 bss->ssid.security_policy = SECURITY_WPA_PSK;
379         else if (bss->ieee802_1x) {
380                 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
381                 bss->ssid.wep.default_len = bss->default_wep_key_len;
382         } else if (bss->ssid.wep.keys_set)
383                 bss->ssid.security_policy = SECURITY_STATIC_WEP;
384         else
385                 bss->ssid.security_policy = SECURITY_PLAINTEXT;
386
387 #ifdef CONFIG_WPS
388         /*
389          * Enable WPS by default, but require user interaction to actually use
390          * it. Only the internal Registrar is supported.
391          */
392         bss->eap_server = 1;
393         bss->wps_state = 2;
394         bss->ap_setup_locked = 1;
395         if (wpa_s->conf->config_methods)
396                 bss->config_methods = os_strdup(wpa_s->conf->config_methods);
397         if (wpa_s->conf->device_type)
398                 bss->device_type = os_strdup(wpa_s->conf->device_type);
399 #endif /* CONFIG_WPS */
400
401         return 0;
402 }
403
404
405 static int hostapd_driver_init(struct hostapd_iface *iface)
406 {
407         struct wpa_init_params params;
408         struct hostapd_data *hapd = iface->bss[0];
409
410         if (hapd->driver == NULL || hapd->driver->hapd_init == NULL) {
411                 wpa_printf(MSG_ERROR, "No hostapd driver wrapper available");
412                 return -1;
413         }
414
415         os_memset(&params, 0, sizeof(params));
416         params.ifname = hapd->conf->iface;
417         params.ssid = (const u8 *) hapd->conf->ssid.ssid;
418         params.ssid_len = hapd->conf->ssid.ssid_len;
419
420         params.num_bridge = hapd->iface->num_bss;
421         params.bridge = os_zalloc(hapd->iface->num_bss * sizeof(char *));
422         if (params.bridge == NULL)
423                 return -1;
424         params.own_addr = hapd->own_addr;
425
426         hapd->drv_priv = hapd->driver->hapd_init(hapd, &params);
427         os_free(params.bridge);
428         if (hapd->drv_priv == NULL) {
429                 wpa_printf(MSG_ERROR, "%s driver initialization failed.",
430                            hapd->driver->name);
431                 hapd->driver = NULL;
432                 return -1;
433         }
434
435         return 0;
436 }
437
438
439 int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
440                              struct wpa_ssid *ssid)
441 {
442         struct wpa_driver_associate_params params;
443         struct hostapd_iface *hapd_iface;
444         struct hostapd_config *conf;
445         size_t i;
446
447         if (ssid->ssid == NULL || ssid->ssid_len == 0) {
448                 wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
449                 return -1;
450         }
451
452         wpa_supplicant_ap_deinit(wpa_s);
453
454         wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')",
455                    wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
456
457         os_memset(&params, 0, sizeof(params));
458         params.ssid = ssid->ssid;
459         params.ssid_len = ssid->ssid_len;
460         params.mode = ssid->mode;
461         params.freq = ssid->frequency;
462
463         if (wpa_drv_associate(wpa_s, &params) < 0) {
464                 wpa_msg(wpa_s, MSG_INFO, "Failed to start AP functionality");
465                 return -1;
466         }
467
468         wpa_s->ap_iface = hapd_iface = os_zalloc(sizeof(*wpa_s->ap_iface));
469         if (hapd_iface == NULL)
470                 return -1;
471         hapd_iface->owner = wpa_s;
472
473         wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
474         if (conf == NULL) {
475                 wpa_supplicant_ap_deinit(wpa_s);
476                 return -1;
477         }
478
479         if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) {
480                 wpa_printf(MSG_ERROR, "Failed to create AP configuration");
481                 wpa_supplicant_ap_deinit(wpa_s);
482                 return -1;
483         }
484
485         hapd_iface->num_bss = conf->num_bss;
486         hapd_iface->bss = os_zalloc(conf->num_bss *
487                                     sizeof(struct hostapd_data *));
488         if (hapd_iface->bss == NULL) {
489                 wpa_supplicant_ap_deinit(wpa_s);
490                 return -1;
491         }
492
493         for (i = 0; i < conf->num_bss; i++) {
494                 hapd_iface->bss[i] =
495                         hostapd_alloc_bss_data(hapd_iface, conf,
496                                                &conf->bss[i]);
497                 if (hapd_iface->bss[i] == NULL) {
498                         wpa_supplicant_ap_deinit(wpa_s);
499                         return -1;
500                 }
501
502                 hapd_iface->bss[i]->msg_ctx = wpa_s;
503         }
504
505         if (hostapd_driver_init(wpa_s->ap_iface) ||
506             hostapd_setup_interface(wpa_s->ap_iface)) {
507                 wpa_printf(MSG_ERROR, "Failed to initialize AP interface");
508                 wpa_supplicant_ap_deinit(wpa_s);
509                 return -1;
510         }
511
512         wpa_s->current_ssid = ssid;
513         os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
514         wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
515
516         return 0;
517 }
518
519
520 void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
521 {
522         const struct wpa_driver_ops *driver;
523         void *drv_priv;
524
525         if (wpa_s->ap_iface == NULL)
526                 return;
527
528         driver = wpa_s->ap_iface->bss[0]->driver;
529         drv_priv = wpa_s->ap_iface->bss[0]->drv_priv;
530         hostapd_interface_deinit(wpa_s->ap_iface);
531         wpa_s->ap_iface = NULL;
532         if (driver && driver->hapd_deinit)
533                 driver->hapd_deinit(drv_priv);
534 }
535
536
537 void ap_tx_status(void *ctx, const u8 *addr,
538                   const u8 *buf, size_t len, int ack)
539 {
540 #ifdef NEED_AP_MLME
541         struct wpa_supplicant *wpa_s = ctx;
542         hostapd_tx_status(wpa_s->ap_iface->bss[0], addr, buf, len, ack);
543 #endif /* NEED_AP_MLME */
544 }
545
546
547 void ap_rx_from_unknown_sta(void *ctx, const struct ieee80211_hdr *hdr,
548                             size_t len)
549 {
550 #ifdef NEED_AP_MLME
551         struct wpa_supplicant *wpa_s = ctx;
552         u16 fc = le_to_host16(hdr->frame_control);
553         ieee802_11_rx_from_unknown(wpa_s->ap_iface->bss[0], hdr->addr2,
554                                    (fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) ==
555                                    (WLAN_FC_TODS | WLAN_FC_FROMDS));
556 #endif /* NEED_AP_MLME */
557 }
558
559
560 void ap_mgmt_rx(void *ctx, const u8 *buf, size_t len,
561                 struct hostapd_frame_info *fi)
562 {
563 #ifdef NEED_AP_MLME
564         struct wpa_supplicant *wpa_s = ctx;
565         ieee802_11_mgmt(wpa_s->ap_iface->bss[0], buf, len, fi);
566 #endif /* NEED_AP_MLME */
567 }
568
569
570 void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok)
571 {
572 #ifdef NEED_AP_MLME
573         struct wpa_supplicant *wpa_s = ctx;
574         ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok);
575 #endif /* NEED_AP_MLME */
576 }
577
578
579 void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s,
580                                 const u8 *src_addr, const u8 *buf, size_t len)
581 {
582         hostapd_eapol_receive(wpa_s->ap_iface->bss[0], src_addr, buf, len);
583 }
584
585
586 #ifdef CONFIG_WPS
587
588 int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid)
589 {
590         return hostapd_wps_button_pushed(wpa_s->ap_iface->bss[0]);
591 }
592
593
594 int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
595                               const char *pin, char *buf, size_t buflen)
596 {
597         int ret, ret_len = 0;
598
599         if (pin == NULL) {
600                 unsigned int rpin = wps_generate_pin();
601                 ret_len = os_snprintf(buf, buflen, "%d", rpin);
602                 pin = buf;
603         }
604
605         ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], "any", pin, 0);
606         if (ret)
607                 return -1;
608         return ret_len;
609 }
610
611 #endif /* CONFIG_WPS */
612
613
614 #ifdef CONFIG_CTRL_IFACE
615
616 int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s,
617                             char *buf, size_t buflen)
618 {
619         if (wpa_s->ap_iface == NULL)
620                 return -1;
621         return hostapd_ctrl_iface_sta_first(wpa_s->ap_iface->bss[0],
622                                             buf, buflen);
623 }
624
625
626 int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr,
627                       char *buf, size_t buflen)
628 {
629         if (wpa_s->ap_iface == NULL)
630                 return -1;
631         return hostapd_ctrl_iface_sta(wpa_s->ap_iface->bss[0], txtaddr,
632                                       buf, buflen);
633 }
634
635
636 int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr,
637                            char *buf, size_t buflen)
638 {
639         if (wpa_s->ap_iface == NULL)
640                 return -1;
641         return hostapd_ctrl_iface_sta_next(wpa_s->ap_iface->bss[0], txtaddr,
642                                            buf, buflen);
643 }
644
645
646 int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
647                                  size_t buflen, int verbose)
648 {
649         char *pos = buf, *end = buf + buflen;
650         int ret;
651         struct hostapd_bss_config *conf;
652
653         if (wpa_s->ap_iface == NULL)
654                 return -1;
655
656         conf = wpa_s->ap_iface->bss[0]->conf;
657         if (conf->wpa == 0)
658                 return 0;
659
660         ret = os_snprintf(pos, end - pos,
661                           "pairwise_cipher=%s\n"
662                           "group_cipher=%s\n"
663                           "key_mgmt=%s\n",
664                           wpa_cipher_txt(conf->rsn_pairwise),
665                           wpa_cipher_txt(conf->wpa_group),
666                           wpa_key_mgmt_txt(conf->wpa_key_mgmt,
667                                            conf->wpa));
668         if (ret < 0 || ret >= end - pos)
669                 return pos - buf;
670         pos += ret;
671         return pos - buf;
672 }
673
674 #endif /* CONFIG_CTRL_IFACE */