blob: 90c5fc0357ede4efa462e3715d0514ca7c60690b [file] [log] [blame]
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001/*
2 * FST module - FST interface object implementation
3 * Copyright (c) 2014, Qualcomm Atheros, Inc.
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#include "utils/includes.h"
10#include "utils/common.h"
11#include "fst/fst_internal.h"
12#include "fst/fst_defs.h"
13
14
15struct fst_iface * fst_iface_create(struct fst_group *g, const char *ifname,
16 const u8 *own_addr,
17 const struct fst_wpa_obj *iface_obj,
18 const struct fst_iface_cfg *cfg)
19{
20 struct fst_iface *i;
21
22 i = os_zalloc(sizeof(*i));
23 if (!i) {
24 fst_printf_group(g, MSG_ERROR, "cannot allocate iface for %s",
25 ifname);
26 return NULL;
27 }
28
29 i->cfg = *cfg;
30 i->iface_obj = *iface_obj;
31 i->group = g;
32 os_strlcpy(i->ifname, ifname, sizeof(i->ifname));
33 os_memcpy(i->own_addr, own_addr, sizeof(i->own_addr));
34
35 if (!i->cfg.llt) {
36 fst_printf_iface(i, MSG_WARNING, "Zero llt adjusted");
37 i->cfg.llt = FST_DEFAULT_LLT_CFG_VALUE;
38 }
39
40 return i;
41}
42
43
44void fst_iface_delete(struct fst_iface *i)
45{
46 fst_iface_set_ies(i, NULL);
47 wpabuf_free(i->mb_ie);
48 os_free(i);
49}
50
51
Hai Shalome21d4e82020-04-29 16:34:06 -070052bool fst_iface_is_connected(struct fst_iface *iface, const u8 *addr,
53 bool mb_only)
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080054{
55 struct fst_get_peer_ctx *ctx;
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -080056 const u8 *a = fst_iface_get_peer_first(iface, &ctx, mb_only);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080057
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -080058 for (; a != NULL; a = fst_iface_get_peer_next(iface, &ctx, mb_only))
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080059 if (os_memcmp(addr, a, ETH_ALEN) == 0)
Hai Shalome21d4e82020-04-29 16:34:06 -070060 return true;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080061
Hai Shalome21d4e82020-04-29 16:34:06 -070062 return false;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080063}
64
65
66void fst_iface_attach_mbie(struct fst_iface *i, struct wpabuf *mbie)
67{
68 wpabuf_free(i->mb_ie);
69 i->mb_ie = mbie;
70}
71
72
73enum mb_band_id fst_iface_get_band_id(struct fst_iface *i)
74{
75 enum hostapd_hw_mode hw_mode;
76 u8 channel;
77
78 fst_iface_get_channel_info(i, &hw_mode, &channel);
79 return fst_hw_mode_to_band(hw_mode);
80}