aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2011-12-22 19:26:31 (GMT)
committerJouni Malinen <j@w1.fi>2011-12-22 19:26:31 (GMT)
commitb3ffc80b8cb5642c990cf5f1c32f2e646a33365a (patch)
tree2d9116ca0ce976b139739782c5067d60e4aaf80f /src
parentb3bcc0f5195ab9e2dc7c6885afee30bcb66c9e5d (diff)
downloadhostap-b3ffc80b8cb5642c990cf5f1c32f2e646a33365a.zip
hostap-b3ffc80b8cb5642c990cf5f1c32f2e646a33365a.tar.gz
hostap-b3ffc80b8cb5642c990cf5f1c32f2e646a33365a.tar.bz2
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>
Diffstat (limited to 'src')
-rw-r--r--src/p2p/p2p.c53
-rw-r--r--src/p2p/p2p.h18
2 files changed, 35 insertions, 36 deletions
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index a9d5998..001743b 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -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,
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 99934bd..c9e9fd3 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -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