From: Ken-ichirou MATSUZAWA <chamaken@gmail.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: [libmnl PATCH 8/9] batch: introduce mnl_nlmsg_batch_reset_buffer for mmap
Date: Sun, 08 Dec 2013 00:16:30 +0900 [thread overview]
Message-ID: <87iov08ze9.wl%chamaken@gmail.com> (raw)
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
reply other threads:[~2013-12-07 15:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iov08ze9.wl%chamaken@gmail.com \
--to=chamaken@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.