summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/in.h
diff options
context:
space:
mode:
authorMichael Brown2016-07-25 16:20:22 +0200
committerMichael Brown2016-07-25 16:20:22 +0200
commita4c4f72297bea6902001ce813aaf432bd49d382d (patch)
treeb685b22a5472252bfa6699b2a19cd89b9073fb34 /src/include/ipxe/in.h
parent[test] Update IPv6 tests to use okx() (diff)
downloadipxe-a4c4f72297bea6902001ce813aaf432bd49d382d.tar.gz
ipxe-a4c4f72297bea6902001ce813aaf432bd49d382d.tar.xz
ipxe-a4c4f72297bea6902001ce813aaf432bd49d382d.zip
[ipv6] Allow for multiple routers
Select the IPv6 source address and corresponding router (if any) using a very simplified version of the algorithm from RFC6724: - Ignore any source address that has a smaller scope than the destination address. For example, do not use a link-local source address when sending to a global destination address. - If we have a source address which is on the same link as the destination address, then use that source address. - If we are left with multiple possible source addresses, then choose the address with the smallest scope. For example, if we are sending to a site-local destination address and we have both a global source address and a site-local source address, then use the site-local source address. - If we are still left with multiple possible source addresses, then choose the address with the longest matching prefix. For the purposes of this algorithm, we treat RFC4193 Unique Local Addresses as having organisation-local scope. Since we use only link-local scope for our multicast transmissions, this approximation should remain valid in all practical situations. Originally-implemented-by: Thomas Bächler <thomas@archlinux.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/in.h')
-rw-r--r--src/include/ipxe/in.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/include/ipxe/in.h b/src/include/ipxe/in.h
index 0ebf441c..3044d631 100644
--- a/src/include/ipxe/in.h
+++ b/src/include/ipxe/in.h
@@ -69,8 +69,12 @@ struct in6_addr {
( ( *( ( const uint16_t * ) (addr) ) & htons ( 0xffc0 ) ) == \
htons ( 0xfe80 ) )
-#define IN6_IS_ADDR_NONGLOBAL( addr ) \
- ( IN6_IS_ADDR_LINKLOCAL (addr) || IN6_IS_ADDR_MULTICAST (addr) )
+#define IN6_IS_ADDR_SITELOCAL( addr ) \
+ ( ( *( ( const uint16_t * ) (addr) ) & htons ( 0xffc0 ) ) == \
+ htons ( 0xfec0 ) )
+
+#define IN6_IS_ADDR_ULA( addr ) \
+ ( ( *( ( const uint8_t * ) (addr) ) & 0xfe ) == 0xfc )
/**
* IPv4 socket address