netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libmnl PATCH 8/9] batch: introduce mnl_nlmsg_batch_reset_buffer for mmap
@ 2013-12-07 15:16 Ken-ichirou MATSUZAWA
  0 siblings, 0 replies; only message in thread
From: Ken-ichirou MATSUZAWA @ 2013-12-07 15:16 UTC (permalink / raw)
  To: Pablo Neira Ayuso, netfilter-devel


Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>

---
 include/libmnl/libmnl.h |  1 +
 src/libmnl.map          |  1 +
 src/nlmsg.c             | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 722cb79..603abc5 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -74,6 +74,7 @@ extern void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b);
 extern void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b);
 extern void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b);
 extern bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b);
+extern void mnl_nlmsg_batch_reset_buffer(struct mnl_nlmsg_batch *b, void *buf, size_t limit);
 
 /*
  * Netlink attributes API
diff --git a/src/libmnl.map b/src/libmnl.map
index d329988..4de63b5 100644
--- a/src/libmnl.map
+++ b/src/libmnl.map
@@ -85,4 +85,5 @@ LIBMNL_1.2 {
   mnl_ring_build_frame;
   mnl_ring_parse_frame2;
   mnl_ring_parse_frame;
+  mnl_nlmsg_batch_reset_buffer;
 } LIBMNL_1.1;
diff --git a/src/nlmsg.c b/src/nlmsg.c
index fdb7af8..0210067 100644
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -569,5 +569,25 @@ bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b)
 EXPORT_SYMBOL(mnl_nlmsg_batch_is_empty);
 
 /**
+ * mnl_nlmsg_batch_reset_buffer - reset to the new buffer
+ */
+void mnl_nlmsg_batch_reset_buffer(struct mnl_nlmsg_batch *b, void *buf, size_t limit)
+{
+	if (b->overflow) {
+		struct nlmsghdr *nlh = b->cur;
+		memcpy(buf, b->cur, nlh->nlmsg_len);
+		b->buflen = nlh->nlmsg_len;
+		b->cur = buf + b->buflen;
+		b->overflow = false;
+	} else {
+		b->buflen = 0;
+		b->cur = buf;
+	}
+	b->buf = buf;
+	b->limit = limit;
+}
+EXPORT_SYMBOL(mnl_nlmsg_batch_reset_buffer);
+
+/**
  * @}
  */
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-07 15:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07 15:16 [libmnl PATCH 8/9] batch: introduce mnl_nlmsg_batch_reset_buffer for mmap Ken-ichirou MATSUZAWA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).