From: Thomas Graf <tgraf@suug.ch>
To: "David S. Miller" <davem@davemloft.net>
Cc: werner@almesberger.net, netdev@oss.sgi.com
Subject: [PATCH 4/7] [RTNETLINK] Add RTA_(PUT|GET) shortcuts for u8, u16, and flag
Date: Fri, 27 May 2005 16:52:52 +0200 [thread overview]
Message-ID: <20050527145252.GV15391@postel.suug.ch> (raw)
In-Reply-To: <20050527145002.GR15391@postel.suug.ch>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
commit c49bbdd22621352b9b96097ffdb9e5c14b4ed95e
tree 6204e59b7aa59cf79632003c621e521db1297b1b
parent 0ecf7991c4f8532a5afc903e175e2bec80585fea
author Thomas Graf <tgraf@suug.ch> Fri, 27 May 2005 14:36:11 +0200
committer Thomas Graf <tgraf@suug.ch> Fri, 27 May 2005 14:36:11 +0200
include/linux/rtnetlink.h | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+)
Index: include/linux/rtnetlink.h
===================================================================
--- 07e28bf36ae4052536820a75bbefc6ac1c7a9098/include/linux/rtnetlink.h (mode:100644)
+++ 6204e59b7aa59cf79632003c621e521db1297b1b/include/linux/rtnetlink.h (mode:100644)
@@ -897,6 +897,14 @@
goto rtattr_failure; \
memcpy(skb_put(skb, RTA_ALIGN(attrlen)), data, attrlen); })
+#define RTA_PUT_U8(skb, attrtype, value) \
+({ u8 _tmp = (value); \
+ RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); })
+
+#define RTA_PUT_U16(skb, attrtype, value) \
+({ u16 _tmp = (value); \
+ RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); })
+
#define RTA_PUT_U32(skb, attrtype, value) \
({ u32 _tmp = (value); \
RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); })
@@ -914,6 +922,9 @@
#define RTA_PUT_STRING(skb, attrtype, value) \
RTA_PUT(skb, attrtype, strlen(value) + 1, value)
+#define RTA_PUT_FLAG(skb, attrtype) \
+ RTA_PUT(skb, attrtype, 0, NULL);
+
#define RTA_NEST(skb, type) \
({ struct rtattr *__start = (struct rtattr *) (skb)->tail; \
RTA_PUT(skb, type, 0, NULL); \
@@ -928,6 +939,16 @@
skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
-1; })
+#define RTA_GET_U8(rta) \
+({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \
+ goto rtattr_failure; \
+ *(u8 *) RTA_DATA(rta); })
+
+#define RTA_GET_U16(rta) \
+({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \
+ goto rtattr_failure; \
+ *(u16 *) RTA_DATA(rta); })
+
#define RTA_GET_U32(rta) \
({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \
goto rtattr_failure; \
@@ -940,6 +961,8 @@
memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
_tmp; })
+#define RTA_GET_FLAG(rta) (!!(rta))
+
#define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
#define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
next prev parent reply other threads:[~2005-05-27 14:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-27 14:50 [PATCHSET] dsmark fixes & cleanups Thomas Graf
2005-05-27 14:50 ` [PATCH 1/7] [PKT_SCHED] Fix dsmark to count ignored indices while walking Thomas Graf
2005-05-31 22:20 ` David S. Miller
2005-05-27 14:51 ` [PATCH 2/7] [PKT_SCHED] make dsmark try using pfifo instead of noop while grafting Thomas Graf
2005-05-31 22:20 ` David S. Miller
2005-05-27 14:52 ` [PATCH 3/7] [PKT_SCHED] Disable dsmark debugging messages by default Thomas Graf
2005-05-31 22:20 ` David S. Miller
2005-05-27 14:52 ` Thomas Graf [this message]
2005-05-27 14:53 ` [PATCH 5/7] [PKT_SCHED] Fix dsmark to apply changes consistent Thomas Graf
2005-05-27 14:54 ` [PATCH 6/7] [PKT_SCHED] Make dsmark use the new dumping macros Thomas Graf
2005-05-27 14:56 ` [PATCH 7/7] [PKT_SCHED] Logic simplifications and codingstyle/whitespace cleanups Thomas Graf
2005-05-31 22:30 ` David S. Miller
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=20050527145252.GV15391@postel.suug.ch \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=netdev@oss.sgi.com \
--cc=werner@almesberger.net \
/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).