FST: Replace print_mb_ies() with wpa_snprintf_hex()
There is no need to add new functions with more or less identical functionality of an already available helper function. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
4390030a51
commit
74619cc150
3 changed files with 7 additions and 34 deletions
|
@ -561,7 +561,6 @@ static int get_peer_mbies(const char *params, char *buf, size_t buflen)
|
||||||
struct fst_group *g;
|
struct fst_group *g;
|
||||||
struct fst_iface *iface = NULL;
|
struct fst_iface *iface = NULL;
|
||||||
struct wpabuf *mbies;
|
struct wpabuf *mbies;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (fst_read_next_text_param(params, ifname, sizeof(ifname), &endp) ||
|
if (fst_read_next_text_param(params, ifname, sizeof(ifname), &endp) ||
|
||||||
!*ifname)
|
!*ifname)
|
||||||
|
@ -584,11 +583,8 @@ static int get_peer_mbies(const char *params, char *buf, size_t buflen)
|
||||||
if (!mbies)
|
if (!mbies)
|
||||||
goto problem;
|
goto problem;
|
||||||
|
|
||||||
ret = print_mb_ies(mbies, buf, buflen);
|
return wpa_snprintf_hex(buf, buflen, wpabuf_head(mbies),
|
||||||
if ((size_t) ret != wpabuf_len(mbies) * 2)
|
wpabuf_len(mbies));
|
||||||
fst_printf(MSG_WARNING, "MB IEs copied only partially");
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
problem:
|
problem:
|
||||||
return os_snprintf(buf, buflen, "FAIL\n");
|
return os_snprintf(buf, buflen, "FAIL\n");
|
||||||
|
@ -648,25 +644,6 @@ static int list_groups(const char *cmd, char *buf, size_t buflen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int print_mb_ies(struct wpabuf *mbies, char *buf, size_t buflen)
|
|
||||||
{
|
|
||||||
const u8 *p = wpabuf_head(mbies);
|
|
||||||
size_t s = wpabuf_len(mbies);
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
while ((size_t) ret < buflen && s--) {
|
|
||||||
int res;
|
|
||||||
|
|
||||||
res = os_snprintf(buf + ret, buflen - ret, "%02x", *p++);
|
|
||||||
if (os_snprintf_error(buflen - ret, res))
|
|
||||||
break;
|
|
||||||
ret += res;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const char * band_freq(enum mb_band_id band)
|
static const char * band_freq(enum mb_band_id band)
|
||||||
{
|
{
|
||||||
static const char *band_names[] = {
|
static const char *band_names[] = {
|
||||||
|
@ -697,7 +674,9 @@ static int print_band(unsigned num, struct fst_iface *iface, const u8 *addr,
|
||||||
if (wpabuf) {
|
if (wpabuf) {
|
||||||
ret += os_snprintf(buf + ret, buflen - ret, "band%u_mb_ies=",
|
ret += os_snprintf(buf + ret, buflen - ret, "band%u_mb_ies=",
|
||||||
num);
|
num);
|
||||||
ret += print_mb_ies(wpabuf, buf + ret, buflen - ret);
|
ret += wpa_snprintf_hex(buf + ret, buflen - ret,
|
||||||
|
wpabuf_head(wpabuf),
|
||||||
|
wpabuf_len(wpabuf));
|
||||||
ret += os_snprintf(buf + ret, buflen - ret, "\n");
|
ret += os_snprintf(buf + ret, buflen - ret, "\n");
|
||||||
}
|
}
|
||||||
ret += os_snprintf(buf + ret, buflen - ret, "band%u_fst_group_id=%s\n",
|
ret += os_snprintf(buf + ret, buflen - ret, "band%u_fst_group_id=%s\n",
|
||||||
|
|
|
@ -30,9 +30,6 @@ fst_ctrl_iface_mb_info(const u8 *addr, char *buf, size_t buflen)
|
||||||
|
|
||||||
#endif /* CONFIG_FST */
|
#endif /* CONFIG_FST */
|
||||||
|
|
||||||
|
|
||||||
int print_mb_ies(struct wpabuf *mbies, char *buf, size_t buflen);
|
|
||||||
|
|
||||||
int fst_read_next_int_param(const char *params, Boolean *valid, char **endp);
|
int fst_read_next_int_param(const char *params, Boolean *valid, char **endp);
|
||||||
int fst_read_next_text_param(const char *params, char *buf, size_t buflen,
|
int fst_read_next_text_param(const char *params, char *buf, size_t buflen,
|
||||||
char **endp);
|
char **endp);
|
||||||
|
|
|
@ -1571,7 +1571,6 @@ int fst_test_req_get_local_mbies(const char *request, char *buf, size_t buflen)
|
||||||
char ifname[FST_MAX_COMMAND_WORD_NAME_LENGTH];
|
char ifname[FST_MAX_COMMAND_WORD_NAME_LENGTH];
|
||||||
struct fst_group *g;
|
struct fst_group *g;
|
||||||
struct fst_iface *iface;
|
struct fst_iface *iface;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (fst_read_next_text_param(request, ifname, sizeof(ifname), &endp) ||
|
if (fst_read_next_text_param(request, ifname, sizeof(ifname), &endp) ||
|
||||||
!*ifname)
|
!*ifname)
|
||||||
|
@ -1583,10 +1582,8 @@ int fst_test_req_get_local_mbies(const char *request, char *buf, size_t buflen)
|
||||||
iface = fst_group_get_iface_by_name(g, ifname);
|
iface = fst_group_get_iface_by_name(g, ifname);
|
||||||
if (!iface || !iface->mb_ie)
|
if (!iface || !iface->mb_ie)
|
||||||
goto problem;
|
goto problem;
|
||||||
ret = print_mb_ies(iface->mb_ie, buf, buflen);
|
return wpa_snprintf_hex(buf, buflen, wpabuf_head(iface->mb_ie),
|
||||||
if ((size_t) ret != wpabuf_len(iface->mb_ie) * 2)
|
wpabuf_len(iface->mb_ie));
|
||||||
fst_printf(MSG_WARNING, "MB IEs copied only partially");
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
problem:
|
problem:
|
||||||
return os_snprintf(buf, buflen, "FAIL\n");
|
return os_snprintf(buf, buflen, "FAIL\n");
|
||||||
|
|
Loading…
Reference in a new issue