]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/drivers/scan_helpers.c
Move wpa_supplicant specific scan code away from src/drivers
[thirdparty/hostap.git] / src / drivers / scan_helpers.c
CommitLineData
6fc6879b
JM
1/*
2 * WPA Supplicant - Helper functions for scan result processing
351f09a2 3 * Copyright (c) 2007-2008, Jouni Malinen <j@w1.fi>
6fc6879b
JM
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#include "includes.h"
16
17#include "common.h"
18#include "drivers/driver.h"
90973fb2 19#include "common/ieee802_11_defs.h"
6fc6879b
JM
20
21
22const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie)
23{
24 const u8 *end, *pos;
25
26 pos = (const u8 *) (res + 1);
27 end = pos + res->ie_len;
28
29 while (pos + 1 < end) {
30 if (pos + 2 + pos[1] > end)
31 break;
32 if (pos[0] == ie)
33 return pos;
34 pos += 2 + pos[1];
35 }
36
37 return NULL;
38}
39
40
6fc6879b
JM
41void wpa_scan_results_free(struct wpa_scan_results *res)
42{
43 size_t i;
44
45 if (res == NULL)
46 return;
47
48 for (i = 0; i < res->num; i++)
49 os_free(res->res[i]);
50 os_free(res->res);
51 os_free(res);
52}