diff mbox

[3/4] P2P: use wpabuf when notif NOA change

Message ID 3078A9B976EF864C8DDD0C499FFD07911E3B76D9B2@EXMB01.eu.tieto.com
State Changes Requested
Headers show

Commit Message

Janusz.Dziedzic@tieto.com Nov. 28, 2011, 12:11 p.m. UTC
In case we build NOA attr via p2p_buf_add_noa() as
a result we get wpabuf. Next it is much easier to
use wpabuf also in p2p_group_notif_noa().
---
 src/p2p/p2p.h       |    4 +---
 src/p2p/p2p_group.c |   11 ++++-------
 2 files changed, 5 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 1501a20..51a46c8 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1274,15 +1274,13 @@  void p2p_group_notif_formation_done(struct p2p_group *group);
  * p2p_group_notif_noa - Notification of NoA change
  * @group: P2P group context from p2p_group_init()
  * @noa: Notice of Absence attribute payload, %NULL if none
- * @noa_len: Length of noa buffer in octets
  * Returns: 0 on success, -1 on failure
  *
  * Notify the P2P group management about a new NoA contents. This will be
  * inserted into the P2P IEs in Beacon and Probe Response frames with rest of
  * the group information.
  */
-int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
-			size_t noa_len);
+int p2p_group_notif_noa(struct p2p_group *group, struct wpabuf *noa);
 
 /**
  * p2p_group_match_dev_type - Match device types in group with requested type
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index c34a92f..be5075a 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -169,8 +169,6 @@  static void p2p_group_add_noa(struct wpabuf *ie, struct wpabuf *noa)
 	if (noa == NULL)
 		return;
 	/* Notice of Absence */
-	wpabuf_put_u8(ie, P2P_ATTR_NOTICE_OF_ABSENCE);
-	wpabuf_put_le16(ie, wpabuf_len(noa));
 	wpabuf_put_buf(ie, noa);
 }
 
@@ -500,17 +498,16 @@  void p2p_group_notif_formation_done(struct p2p_group *group)
 }
 
 
-int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
-			size_t noa_len)
+int p2p_group_notif_noa(struct p2p_group *group, struct wpabuf *noa)
 {
 	if (noa == NULL) {
 		wpabuf_free(group->noa);
 		group->noa = NULL;
 	} else {
 		if (group->noa) {
-			if (wpabuf_size(group->noa) >= noa_len) {
+			if (wpabuf_size(group->noa) >= wpabuf_len(noa)) {
 				group->noa->used = 0;
-				wpabuf_put_data(group->noa, noa, noa_len);
+				wpabuf_put_buf(group->noa, noa);
 			} else {
 				wpabuf_free(group->noa);
 				group->noa = NULL;
@@ -518,7 +515,7 @@  int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa,
 		}
 
 		if (!group->noa) {
-			group->noa = wpabuf_alloc_copy(noa, noa_len);
+			group->noa = wpabuf_dup(noa);
 			if (group->noa == NULL)
 				return -1;
 		}