mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
P2P: Move public P2P_PEER info generation into ctrl_iface
The P2P module provides access to public peer data in struct p2p_peer_info. Use this to build the P2P_PEER information in ctrl_iface.c instead of providing such text format data from the P2P module. The internal data that was previously built in p2p_get_peer_info() as part of the text format peer data is now available through a separate p2p_get_peer_info_txt() function. This is still included in P2P_PEER output to maintain backwards compatibility with external programs that could have started to use this. However, it should be noted that this data is not really supposed to be used for anything else apart from debugging purposes and its format is subject to change. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
b3bcc0f519
commit
b3ffc80b8c
@ -3070,14 +3070,10 @@ static const char * p2p_go_state_text(enum p2p_go_state go_state)
|
||||
}
|
||||
|
||||
|
||||
int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||
char *buf, size_t buflen)
|
||||
const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p,
|
||||
const u8 *addr, int next)
|
||||
{
|
||||
struct p2p_device *dev;
|
||||
int res;
|
||||
char *pos, *end;
|
||||
struct os_time now;
|
||||
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
||||
|
||||
if (addr)
|
||||
dev = p2p_get_device(p2p, addr);
|
||||
@ -3091,35 +3087,37 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||
}
|
||||
|
||||
if (dev == NULL)
|
||||
return NULL;
|
||||
|
||||
return &dev->info;
|
||||
}
|
||||
|
||||
|
||||
int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
struct p2p_device *dev;
|
||||
int res;
|
||||
char *pos, *end;
|
||||
struct os_time now;
|
||||
|
||||
if (info == NULL)
|
||||
return -1;
|
||||
|
||||
dev = (struct p2p_device *) (((u8 *) info) -
|
||||
offsetof(struct p2p_device, info));
|
||||
|
||||
pos = buf;
|
||||
end = buf + buflen;
|
||||
|
||||
res = os_snprintf(pos, end - pos, MACSTR "\n",
|
||||
MAC2STR(dev->info.p2p_device_addr));
|
||||
if (res < 0 || res >= end - pos)
|
||||
return pos - buf;
|
||||
pos += res;
|
||||
|
||||
os_get_time(&now);
|
||||
res = os_snprintf(pos, end - pos,
|
||||
"age=%d\n"
|
||||
"listen_freq=%d\n"
|
||||
"level=%d\n"
|
||||
"wps_method=%s\n"
|
||||
"interface_addr=" MACSTR "\n"
|
||||
"member_in_go_dev=" MACSTR "\n"
|
||||
"member_in_go_iface=" MACSTR "\n"
|
||||
"pri_dev_type=%s\n"
|
||||
"device_name=%s\n"
|
||||
"manufacturer=%s\n"
|
||||
"model_name=%s\n"
|
||||
"model_number=%s\n"
|
||||
"serial_number=%s\n"
|
||||
"config_methods=0x%x\n"
|
||||
"dev_capab=0x%x\n"
|
||||
"group_capab=0x%x\n"
|
||||
"go_neg_req_sent=%d\n"
|
||||
"go_state=%s\n"
|
||||
"dialog_token=%u\n"
|
||||
@ -3133,21 +3131,10 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||
"invitation_reqs=%u\n",
|
||||
(int) (now.sec - dev->last_seen.sec),
|
||||
dev->listen_freq,
|
||||
dev->info.level,
|
||||
p2p_wps_method_text(dev->wps_method),
|
||||
MAC2STR(dev->interface_addr),
|
||||
MAC2STR(dev->member_in_go_dev),
|
||||
MAC2STR(dev->member_in_go_iface),
|
||||
wps_dev_type_bin2str(dev->info.pri_dev_type,
|
||||
devtype, sizeof(devtype)),
|
||||
dev->info.device_name,
|
||||
dev->info.manufacturer,
|
||||
dev->info.model_name,
|
||||
dev->info.model_number,
|
||||
dev->info.serial_number,
|
||||
dev->info.config_methods,
|
||||
dev->info.dev_capab,
|
||||
dev->info.group_capab,
|
||||
dev->go_neg_req_sent,
|
||||
p2p_go_state_text(dev->go_state),
|
||||
dev->dialog_token,
|
||||
|
@ -1416,16 +1416,28 @@ int p2p_get_cross_connect_disallowed(const struct wpabuf *p2p_ie);
|
||||
const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie);
|
||||
|
||||
/**
|
||||
* p2p_get_peer_info - Get P2P peer information in text format
|
||||
* p2p_get_peer_info - Get P2P peer information
|
||||
* @p2p: P2P module context from p2p_init()
|
||||
* @addr: P2P Device Address of the peer or %NULL to indicate the first peer
|
||||
* @next: Whether to select the peer entry following the one indicated by addr
|
||||
* Returns: Pointer to peer info or %NULL if not found
|
||||
*/
|
||||
const struct p2p_peer_info * p2p_get_peer_info(struct p2p_data *p2p,
|
||||
const u8 *addr, int next);
|
||||
|
||||
/**
|
||||
* p2p_get_peer_info_txt - Get internal P2P peer information in text format
|
||||
* @info: Pointer to P2P peer info from p2p_get_peer_info()
|
||||
* @buf: Buffer for returning text
|
||||
* @buflen: Maximum buffer length
|
||||
* Returns: Number of octets written to the buffer or -1 on failure
|
||||
*
|
||||
* Note: This information is internal to the P2P module and subject to change.
|
||||
* As such, this should not really be used by external programs for purposes
|
||||
* other than debugging.
|
||||
*/
|
||||
int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||
char *buf, size_t buflen);
|
||||
int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
||||
char *buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* p2p_peer_known - Check whether P2P peer is known
|
||||
|
@ -2985,7 +2985,10 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
u8 addr[ETH_ALEN], *addr_ptr;
|
||||
int next;
|
||||
int next, res;
|
||||
const struct p2p_peer_info *info;
|
||||
char *pos, *end;
|
||||
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
||||
|
||||
if (!wpa_s->global->p2p)
|
||||
return -1;
|
||||
@ -3005,8 +3008,46 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
||||
next = 0;
|
||||
}
|
||||
|
||||
return p2p_get_peer_info(wpa_s->global->p2p, addr_ptr, next,
|
||||
buf, buflen);
|
||||
info = p2p_get_peer_info(wpa_s->global->p2p, addr_ptr, next);
|
||||
if (info == NULL)
|
||||
return -1;
|
||||
|
||||
pos = buf;
|
||||
end = buf + buflen;
|
||||
|
||||
res = os_snprintf(pos, end - pos, MACSTR "\n"
|
||||
"pri_dev_type=%s\n"
|
||||
"device_name=%s\n"
|
||||
"manufacturer=%s\n"
|
||||
"model_name=%s\n"
|
||||
"model_number=%s\n"
|
||||
"serial_number=%s\n"
|
||||
"config_methods=0x%x\n"
|
||||
"dev_capab=0x%x\n"
|
||||
"group_capab=0x%x\n"
|
||||
"level=%d\n",
|
||||
MAC2STR(info->p2p_device_addr),
|
||||
wps_dev_type_bin2str(info->pri_dev_type,
|
||||
devtype, sizeof(devtype)),
|
||||
info->device_name,
|
||||
info->manufacturer,
|
||||
info->model_name,
|
||||
info->model_number,
|
||||
info->serial_number,
|
||||
info->config_methods,
|
||||
info->dev_capab,
|
||||
info->group_capab,
|
||||
info->level);
|
||||
if (res < 0 || res >= end - pos)
|
||||
return pos - buf;
|
||||
pos += res;
|
||||
|
||||
res = p2p_get_peer_info_txt(info, pos, end - pos);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
pos += res;
|
||||
|
||||
return pos - buf;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user