[ipxe-devel] [RFC 2/3] [net] Add IN6_ARE_ADDR_EQUAL

Thomas Bächler thomas at archlinux.org
Wed Feb 3 19:12:43 UTC 2016


This macro checks if two addresses are equal.
---
 src/include/ipxe/in.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/include/ipxe/in.h b/src/include/ipxe/in.h
index 61c60d7..f1cfbd1 100644
--- a/src/include/ipxe/in.h
+++ b/src/include/ipxe/in.h
@@ -73,6 +73,12 @@ struct in6_addr {
 	( IN6_IS_ADDR_LINKLOCAL (addr) || 					\
 	  ( IN6_IS_ADDR_MULTICAST (addr) && ( *( ( const uint16_t * ) (addr) ) & htons( 0x000f ) ) == htons( 0x0002 ) ) )
 
+#define IN6_ARE_ADDR_EQUAL( first, second )						\
+	( ( ( ( const uint32_t * ) (first) )[0] ) == ( ( ( const uint32_t * ) (second) )[0] ) && \
+	  ( ( ( const uint32_t * ) (first) )[1] ) == ( ( ( const uint32_t * ) (second) )[1] ) && \
+	  ( ( ( const uint32_t * ) (first) )[2] ) == ( ( ( const uint32_t * ) (second) )[2] ) && \
+	  ( ( ( const uint32_t * ) (first) )[3] ) == ( ( ( const uint32_t * ) (second) )[3] ) )
+
 /**
  * IPv4 socket address
  */
-- 
2.6.3



More information about the ipxe-devel mailing list