1 /* 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 15 struct 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 44 void 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 52 Boolean fst_iface_is_connected(struct fst_iface *iface, const u8 *addr) 53 { 54 struct fst_get_peer_ctx *ctx; 55 const u8 *a = fst_iface_get_peer_first(iface, &ctx, TRUE); 56 57 for (; a != NULL; a = fst_iface_get_peer_next(iface, &ctx, TRUE)) 58 if (os_memcmp(addr, a, ETH_ALEN) == 0) 59 return TRUE; 60 61 return FALSE; 62 } 63 64 65 void fst_iface_attach_mbie(struct fst_iface *i, struct wpabuf *mbie) 66 { 67 wpabuf_free(i->mb_ie); 68 i->mb_ie = mbie; 69 } 70 71 72 enum mb_band_id fst_iface_get_band_id(struct fst_iface *i) 73 { 74 enum hostapd_hw_mode hw_mode; 75 u8 channel; 76 77 fst_iface_get_channel_info(i, &hw_mode, &channel); 78 return fst_hw_mode_to_band(hw_mode); 79 } 80