netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@oss.sgi.com
Subject: [PATCH 1/4] [NETLINK] New message building macros
Date: Thu, 26 May 2005 20:54:02 +0200	[thread overview]
Message-ID: <20050526185402.GX15391@postel.suug.ch> (raw)
In-Reply-To: <20050526185306.GW15391@postel.suug.ch>

 NLMSG_PUT_ANSWER(skb, nlcb, type, length)
   Start a new netlink message as answer to a request,
   returns the message header.

 NLMSG_END(skb, nlh)
   End a netlink message, fixes total message length,
   returns skb->len.

 NLMSG_CANCEL(skb, nlh)
   Cancel the building process and trim whole message
   from skb again, returns -1.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

---
commit 88e04e26d887e806372014a2f7b33c6a7ea64741
tree 031c0e0d63096ca2dff2203940b90460f1db5c68
parent d1faeaeb95a05275cf0c5b51b88f2fa833434625
author Thomas Graf <tgraf@suug.ch> Thu, 26 May 2005 18:21:36 +0200
committer Thomas Graf <tgraf@suug.ch> Thu, 26 May 2005 18:21:36 +0200

 include/linux/netlink.h |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

Index: include/linux/netlink.h
===================================================================
--- c6f827347b3c6c28bc55a8eb1e62ea2659202cab/include/linux/netlink.h  (mode:100644)
+++ 031c0e0d63096ca2dff2203940b90460f1db5c68/include/linux/netlink.h  (mode:100644)
@@ -171,8 +171,21 @@
 }
 
 #define NLMSG_PUT(skb, pid, seq, type, len) \
-({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) goto nlmsg_failure; \
-   __nlmsg_put(skb, pid, seq, type, len); })
+({	if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) \
+		goto nlmsg_failure; \
+	__nlmsg_put(skb, pid, seq, type, len); })
+
+#define NLMSG_PUT_ANSWER(skb, cb, type, len) \
+	NLMSG_PUT(skb, NETLINK_CB((cb)->skb).pid, \
+		  (cb)->nlh->nlmsg_seq, type, len)
+
+#define NLMSG_END(skb, nlh) \
+({	(nlh)->nlmsg_len = (skb)->tail - (unsigned char *) (nlh); \
+	(skb)->len; })
+
+#define NLMSG_CANCEL(skb, nlh) \
+({	skb_trim(skb, (unsigned char *) (nlh) - (skb)->data); \
+	-1; })
 
 extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
 			      struct nlmsghdr *nlh,

  reply	other threads:[~2005-05-26 18:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-26 18:53 [PATCHSET] neighbour tables access via rtnetlink Thomas Graf
2005-05-26 18:54 ` Thomas Graf [this message]
2005-05-26 18:54 ` [PATCH 2/4] [RTNETLINK] Routing attribute related shortcuts Thomas Graf
2005-05-26 18:55 ` [PATCH 3/4] [NEIGH] neighbour table configuration and statistics via rtnetlink Thomas Graf
2005-05-26 22:17   ` David S. Miller
2005-05-26 22:24     ` Thomas Graf
2005-05-26 22:26     ` Thomas Graf
2005-05-26 22:37       ` David S. Miller
2005-05-27 11:14   ` jamal
2005-05-27 12:15     ` Thomas Graf
2005-05-27 13:50       ` jamal
     [not found]         ` <20050527141023.GP15391@postel.suug.ch>
2005-05-27 14:57           ` jamal
2005-05-27 15:16             ` Thomas Graf
2005-05-27 15:56               ` jamal
2005-05-27 16:35                 ` Thomas Graf
2005-05-28  1:42                   ` jamal
2005-05-28 12:07                     ` Thomas Graf
2005-05-31 10:04                       ` jamal
2005-05-31 11:42                         ` Thomas Graf
2005-05-31 12:48                           ` jamal
2005-05-31 13:17                             ` Thomas Graf
2005-05-31 14:59                               ` Jamal Hadi Salim
2005-05-31 16:13                                 ` Thomas Graf
2005-06-02 13:33                                   ` jamal
2005-05-26 18:55 ` [NEIGH] Remove unused fields in struct neigh_parms and neigh_table Thomas Graf
2005-05-26 19:00   ` Thomas Graf

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=20050526185402.GX15391@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    /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 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).