[ovs-dev,RFC,3/7] lib: add ipv6 helper functions
diff mbox

Message ID 1443564658-12251-1-git-send-email-cascardo@redhat.com
State Accepted
Headers show

Commit Message

Thadeu Lima de Souza Cascardo Sept. 29, 2015, 10:10 p.m. UTC
From: Jiri Benc <jbenc@redhat.com>

ipv6_addr_is_set is going to be used by next patches.

[cascardo: compare with in6addr_any in ipv6_addr_is_set]
[cascardo: keep only ipv6_addr_is_* functions]

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
---
 lib/packets.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jiri Benc Oct. 2, 2015, 9:05 a.m. UTC | #1
On Tue, 29 Sep 2015 19:10:54 -0300, Thadeu Lima de Souza Cascardo wrote:
> From: Jiri Benc <jbenc@redhat.com>
> 
> ipv6_addr_is_set is going to be used by next patches.
> 
> [cascardo: compare with in6addr_any in ipv6_addr_is_set]

It was actually done with the "or" for purpose, it's faster that way.
But I don't care much, this is okay, too.

 Jiri
Ben Pfaff Oct. 5, 2015, 6:15 p.m. UTC | #2
On Tue, Sep 29, 2015 at 07:10:54PM -0300, Thadeu Lima de Souza Cascardo wrote:
> From: Jiri Benc <jbenc@redhat.com>
> 
> ipv6_addr_is_set is going to be used by next patches.
> 
> [cascardo: compare with in6addr_any in ipv6_addr_is_set]
> [cascardo: keep only ipv6_addr_is_* functions]
> 
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

Applied, thanks!

Patch
diff mbox

diff --git a/lib/packets.h b/lib/packets.h
index d55c718..e841fb1 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -871,6 +871,14 @@  static inline bool ipv6_is_all_hosts(const struct in6_addr *addr) {
     return ipv6_addr_equals(addr, &in6addr_all_hosts);
 }
 
+static inline bool ipv6_addr_is_set(const struct in6_addr *addr) {
+    return !ipv6_addr_equals(addr, &in6addr_any);
+}
+
+static inline bool ipv6_addr_is_multicast(const struct in6_addr *ip) {
+    return ip->s6_addr[0] == 0xff;
+}
+
 static inline void
 in6_addr_set_mapped_ipv4(struct in6_addr *addr, ovs_be32 ip4)
 {