1d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt/* 2d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt * FST module - FST interface object implementation 3d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt * Copyright (c) 2014, Qualcomm Atheros, Inc. 4d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt * 5d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt * This software may be distributed under the terms of the BSD license. 6d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt * See README for more details. 7d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt */ 8d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 9d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#include "utils/includes.h" 10d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#include "utils/common.h" 11d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#include "fst/fst_internal.h" 12d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt#include "fst/fst_defs.h" 13d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 14d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 15d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtstruct fst_iface * fst_iface_create(struct fst_group *g, const char *ifname, 16d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt const u8 *own_addr, 17d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt const struct fst_wpa_obj *iface_obj, 18d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt const struct fst_iface_cfg *cfg) 19d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 20d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct fst_iface *i; 21d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 22d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt i = os_zalloc(sizeof(*i)); 23d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!i) { 24d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt fst_printf_group(g, MSG_ERROR, "cannot allocate iface for %s", 25d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt ifname); 26d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return NULL; 27d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 28d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 29d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt i->cfg = *cfg; 30d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt i->iface_obj = *iface_obj; 31d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt i->group = g; 32d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_strlcpy(i->ifname, ifname, sizeof(i->ifname)); 33d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_memcpy(i->own_addr, own_addr, sizeof(i->own_addr)); 34d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 35d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (!i->cfg.llt) { 36d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt fst_printf_iface(i, MSG_WARNING, "Zero llt adjusted"); 37d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt i->cfg.llt = FST_DEFAULT_LLT_CFG_VALUE; 38d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt } 39d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 40d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return i; 41d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 42d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 43d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 44d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtvoid fst_iface_delete(struct fst_iface *i) 45d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 46d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt fst_iface_set_ies(i, NULL); 47d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpabuf_free(i->mb_ie); 48d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt os_free(i); 49d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 50d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 51d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 52d7ff03d48f825360eec2a371e3361306f2fd721bDmitry ShmidtBoolean fst_iface_is_connected(struct fst_iface *iface, const u8 *addr, 53d7ff03d48f825360eec2a371e3361306f2fd721bDmitry Shmidt Boolean mb_only) 54d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 55d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt struct fst_get_peer_ctx *ctx; 56d7ff03d48f825360eec2a371e3361306f2fd721bDmitry Shmidt const u8 *a = fst_iface_get_peer_first(iface, &ctx, mb_only); 57d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 58d7ff03d48f825360eec2a371e3361306f2fd721bDmitry Shmidt for (; a != NULL; a = fst_iface_get_peer_next(iface, &ctx, mb_only)) 59d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt if (os_memcmp(addr, a, ETH_ALEN) == 0) 60d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return TRUE; 61d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 62d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return FALSE; 63d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 64d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 65d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 66d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtvoid fst_iface_attach_mbie(struct fst_iface *i, struct wpabuf *mbie) 67d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 68d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt wpabuf_free(i->mb_ie); 69d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt i->mb_ie = mbie; 70d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 71d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 72d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 73d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidtenum mb_band_id fst_iface_get_band_id(struct fst_iface *i) 74d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt{ 75d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt enum hostapd_hw_mode hw_mode; 76d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt u8 channel; 77d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt 78d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt fst_iface_get_channel_info(i, &hw_mode, &channel); 79d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt return fst_hw_mode_to_band(hw_mode); 80d80a401aed31d06f261efd19223cf55d1a2a8228Dmitry Shmidt} 81