]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add more user friendly debug print of channel lists
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 22 Oct 2013 15:44:05 +0000 (18:44 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 22 Oct 2013 21:39:17 +0000 (00:39 +0300)
This makes it easier to go through the P2P channel list operations in
the debug log without having to parse through the hexdump manually.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p_go_neg.c
src/p2p/p2p_i.h
src/p2p/p2p_utils.c

index 491a3d0981b30f53f12e098fb3794bcc5c2726ef..76e7cf592320e955a09a43ebabde6d636d9a49fc 100644 (file)
@@ -465,9 +465,11 @@ static int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
                                 u8 *status)
 {
        struct p2p_channels intersection;
-       size_t i;
 
+       p2p_channels_dump(p2p, "own channels", &p2p->channels);
+       p2p_channels_dump(p2p, "peer channels", &dev->channels);
        p2p_channels_intersect(&p2p->channels, &dev->channels, &intersection);
+       p2p_channels_dump(p2p, "intersection", &intersection);
        if (intersection.reg_classes == 0 ||
            intersection.reg_class[0].channels == 0) {
                *status = P2P_SC_FAIL_NO_COMMON_CHANNELS;
@@ -475,14 +477,6 @@ static int p2p_go_select_channel(struct p2p_data *p2p, struct p2p_device *dev,
                return -1;
        }
 
-       for (i = 0; i < intersection.reg_classes; i++) {
-               struct p2p_reg_class *c;
-               c = &intersection.reg_class[i];
-               p2p_dbg(p2p, "reg_class %u", c->reg_class);
-               wpa_hexdump(MSG_DEBUG, "P2P: channels",
-                           c->channel, c->channels);
-       }
-
        if (!p2p_channels_includes(&intersection, p2p->op_reg_class,
                                   p2p->op_channel)) {
                if (dev->flags & P2P_DEV_FORCE_FREQ) {
index e12e6f0e6a24988388a7c47385bfe5e56613c58e..56056fa7b27b1c6798df921716ecdef241a64861 100644 (file)
@@ -572,6 +572,8 @@ void p2p_channels_intersect(const struct p2p_channels *a,
                            struct p2p_channels *res);
 int p2p_channels_includes(const struct p2p_channels *channels, u8 reg_class,
                          u8 channel);
+void p2p_channels_dump(struct p2p_data *p2p, const char *title,
+                      const struct p2p_channels *chan);
 
 /* p2p_parse.c */
 int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg);
index deb7aa9f544bef9c150104731b0e84172a99aa4e..8489b535c332bc246e955da441ed49aaf66d7bc5 100644 (file)
@@ -280,3 +280,36 @@ unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
 
        return 0;
 }
+
+
+void p2p_channels_dump(struct p2p_data *p2p, const char *title,
+                      const struct p2p_channels *chan)
+{
+       char buf[500], *pos, *end;
+       size_t i, j;
+       int ret;
+
+       pos = buf;
+       end = pos + sizeof(buf);
+
+       for (i = 0; i < chan->reg_classes; i++) {
+               const struct p2p_reg_class *c;
+               c = &chan->reg_class[i];
+               ret = os_snprintf(pos, end - pos, " %u:", c->reg_class);
+               if (ret < 0 || ret >= end - pos)
+                       break;
+               pos += ret;
+
+               for (j = 0; j < c->channels; j++) {
+                       ret = os_snprintf(pos, end - pos, "%s%u",
+                                         j == 0 ? "" : ",",
+                                         c->channel[j]);
+                       if (ret < 0 || ret >= end - pos)
+                               break;
+                       pos += ret;
+               }
+       }
+       *pos = '\0';
+
+       p2p_dbg(p2p, "%s:%s", title, buf);
+}