From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
kernel@pengutronix.de, mcr@sandelman.ca,
lukasz.duda@nordicsemi.no, martin.gergeleit@hs-rm.de,
Alexander Aring <alex.aring@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
James Morris <jmorris@namei.org>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
Patrick McHardy <kaber@trash.net>
Subject: [RFCv3 bluetooth-next 3/4] ipv6: add ipv6_addr_prefix_copy
Date: Sun, 29 Nov 2015 12:34:41 +0100 [thread overview]
Message-ID: <1448796882-316-4-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1448796882-316-1-git-send-email-alex.aring@gmail.com>
This patch adds a static inline function ipv6_addr_prefix_copy which
copies a ipv6 address prefix(argument pfx) into the ipv6 address prefix.
The prefix len is given by plen as bits. This function mainly based on
ipv6_addr_prefix which copies one address prefix from address into a new
ipv6 address destination and zero all other address bits.
The difference is that ipv6_addr_prefix_copy don't get a prefix from an
ipv6 address, it sets a prefix to an ipv6 address with keeping other
address bits. The use case is for context based address compression
inside 6LoWPAN IPHC header which keeping ipv6 prefixes inside a context
table to lookup address-bits without sending them.
Cc: David S. Miller <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
include/net/ipv6.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e1a10b0..cd3881e6 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -382,6 +382,21 @@ static inline void ipv6_addr_prefix(struct in6_addr *pfx,
pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b);
}
+static inline void ipv6_addr_prefix_copy(struct in6_addr *addr,
+ const struct in6_addr *pfx,
+ int plen)
+{
+ /* caller must guarantee 0 <= plen <= 128 */
+ int o = plen >> 3,
+ b = plen & 0x7;
+
+ memcpy(addr->s6_addr, pfx, o);
+ if (b != 0) {
+ addr->s6_addr[o] &= ~(0xff00 >> b);
+ addr->s6_addr[o] |= (pfx->s6_addr[o] & (0xff00 >> b));
+ }
+}
+
static inline void __ipv6_addr_set_half(__be32 *addr,
__be32 wh, __be32 wl)
{
--
2.6.1
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-wpan-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
mcr-SWp7JaYWvAQV+D8aMU/kSg@public.gmane.org,
lukasz.duda-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org,
martin.gergeleit-6wGqcYweBVc@public.gmane.org,
Alexander Aring
<alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"David S . Miller"
<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Alexey Kuznetsov <kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org>,
James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>,
Hideaki YOSHIFUJI
<yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org>,
Patrick McHardy <kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org>
Subject: [RFCv3 bluetooth-next 3/4] ipv6: add ipv6_addr_prefix_copy
Date: Sun, 29 Nov 2015 12:34:41 +0100 [thread overview]
Message-ID: <1448796882-316-4-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1448796882-316-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
This patch adds a static inline function ipv6_addr_prefix_copy which
copies a ipv6 address prefix(argument pfx) into the ipv6 address prefix.
The prefix len is given by plen as bits. This function mainly based on
ipv6_addr_prefix which copies one address prefix from address into a new
ipv6 address destination and zero all other address bits.
The difference is that ipv6_addr_prefix_copy don't get a prefix from an
ipv6 address, it sets a prefix to an ipv6 address with keeping other
address bits. The use case is for context based address compression
inside 6LoWPAN IPHC header which keeping ipv6 prefixes inside a context
table to lookup address-bits without sending them.
Cc: David S. Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: Alexey Kuznetsov <kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org>
Cc: James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>
Cc: Hideaki YOSHIFUJI <yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org>
Cc: Patrick McHardy <kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org>
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/net/ipv6.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e1a10b0..cd3881e6 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -382,6 +382,21 @@ static inline void ipv6_addr_prefix(struct in6_addr *pfx,
pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b);
}
+static inline void ipv6_addr_prefix_copy(struct in6_addr *addr,
+ const struct in6_addr *pfx,
+ int plen)
+{
+ /* caller must guarantee 0 <= plen <= 128 */
+ int o = plen >> 3,
+ b = plen & 0x7;
+
+ memcpy(addr->s6_addr, pfx, o);
+ if (b != 0) {
+ addr->s6_addr[o] &= ~(0xff00 >> b);
+ addr->s6_addr[o] |= (pfx->s6_addr[o] & (0xff00 >> b));
+ }
+}
+
static inline void __ipv6_addr_set_half(__be32 *addr,
__be32 wh, __be32 wl)
{
--
2.6.1
next prev parent reply other threads:[~2015-11-29 11:34 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 11:34 [RFCv3 bluetooth-next 0/4] 6lowpan: debugfs and stateful compression support Alexander Aring
2015-11-29 11:34 ` Alexander Aring
2015-11-29 11:34 ` [RFCv3 bluetooth-next 1/4] 6lowpan: add lowpan dev register helpers Alexander Aring
2015-11-29 11:34 ` Alexander Aring
2015-12-01 20:38 ` Stefan Schmidt
2015-11-29 11:34 ` [RFCv3 bluetooth-next 2/4] 6lowpan: add debugfs support Alexander Aring
2015-11-29 11:34 ` Alexander Aring
2015-12-01 20:50 ` Stefan Schmidt
2015-12-01 20:50 ` Stefan Schmidt
2015-11-29 11:34 ` Alexander Aring [this message]
2015-11-29 11:34 ` [RFCv3 bluetooth-next 3/4] ipv6: add ipv6_addr_prefix_copy Alexander Aring
2015-12-01 10:56 ` Hannes Frederic Sowa
2015-12-01 10:56 ` Hannes Frederic Sowa
2015-12-01 11:17 ` YOSHIFUJI Hideaki/吉藤英明
2015-12-01 11:38 ` Stefan Schmidt
2015-12-01 11:38 ` Stefan Schmidt
2015-12-01 11:51 ` Duda, Lukasz
2015-11-29 11:34 ` [RFCv3 bluetooth-next 4/4] 6lowpan: iphc: add support for stateful compression Alexander Aring
2015-11-29 11:34 ` Alexander Aring
2015-12-02 14:18 ` Stefan Schmidt
2015-12-03 14:22 ` Alexander Aring
2015-12-03 14:22 ` Alexander Aring
2015-12-04 12:13 ` Stefan Schmidt
2015-12-04 12:13 ` Stefan Schmidt
2015-12-11 17:05 ` Alexander Aring
2015-12-11 17:13 ` Alexander Aring
2015-12-11 17:13 ` Alexander Aring
2015-12-11 19:11 ` Stefan Schmidt
2015-12-11 19:49 ` Alexander Aring
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=1448796882-316-4-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kernel@pengutronix.de \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=lukasz.duda@nordicsemi.no \
--cc=martin.gergeleit@hs-rm.de \
--cc=mcr@sandelman.ca \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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.