summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/src/include/ipxe/in.h
diff options
context:
space:
mode:
Diffstat (limited to 'qemu/roms/ipxe/src/include/ipxe/in.h')
-rw-r--r--qemu/roms/ipxe/src/include/ipxe/in.h40
1 files changed, 28 insertions, 12 deletions
diff --git a/qemu/roms/ipxe/src/include/ipxe/in.h b/qemu/roms/ipxe/src/include/ipxe/in.h
index de96ca22a..0ebf441c2 100644
--- a/qemu/roms/ipxe/src/include/ipxe/in.h
+++ b/qemu/roms/ipxe/src/include/ipxe/in.h
@@ -1,9 +1,10 @@
#ifndef _IPXE_IN_H
#define _IPXE_IN_H
-FILE_LICENCE ( GPL2_OR_LATER );
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
+#include <byteswap.h>
#include <ipxe/socket.h>
/* Protocol numbers */
@@ -15,17 +16,22 @@ FILE_LICENCE ( GPL2_OR_LATER );
/* IP address constants */
-#define INADDR_NONE 0xffffffff
+#define INADDR_NONE htonl ( 0xffffffff )
-#define INADDR_BROADCAST 0xffffffff
+#define INADDR_BROADCAST htonl ( 0xffffffff )
-#define IN_CLASSA(addr) ( ( (addr) & 0x80000000 ) == 0x00000000 )
-#define IN_CLASSA_NET 0xff000000
-#define IN_CLASSB(addr) ( ( (addr) & 0xc0000000 ) == 0x80000000 )
-#define IN_CLASSB_NET 0xffff0000
-#define IN_CLASSC(addr) ( ( (addr) & 0xe0000000 ) == 0xc0000000 )
-#define IN_CLASSC_NET 0xffffff00
-#define IN_MULTICAST(addr) ( ( (addr) & 0xf0000000 ) == 0xe0000000 )
+#define INADDR_NET_CLASSA htonl ( 0xff000000 )
+#define INADDR_NET_CLASSB htonl ( 0xffff0000 )
+#define INADDR_NET_CLASSC htonl ( 0xffffff00 )
+
+#define IN_IS_CLASSA( addr ) \
+ ( ( (addr) & htonl ( 0x80000000 ) ) == htonl ( 0x00000000 ) )
+#define IN_IS_CLASSB( addr ) \
+ ( ( (addr) & htonl ( 0xc0000000 ) ) == htonl ( 0x80000000 ) )
+#define IN_IS_CLASSC( addr ) \
+ ( ( (addr) & htonl ( 0xe0000000 ) ) == htonl ( 0xc0000000 ) )
+#define IN_IS_MULTICAST( addr ) \
+ ( ( (addr) & htonl ( 0xf0000000 ) ) == htonl ( 0xe0000000 ) )
/**
* IP address structure
@@ -63,6 +69,9 @@ 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) )
+
/**
* IPv4 socket address
*/
@@ -76,6 +85,11 @@ struct sockaddr_in {
uint16_t sin_flags;
/** TCP/IP port (part of struct @c sockaddr_tcpip) */
uint16_t sin_port;
+ /** Scope ID (part of struct @c sockaddr_tcpip)
+ *
+ * For multicast addresses, this is the network device index.
+ */
+ uint16_t sin_scope_id;
/** IPv4 address */
struct in_addr sin_addr;
/** Padding
@@ -87,6 +101,7 @@ struct sockaddr_in {
( sizeof ( sa_family_t ) /* sin_family */ +
sizeof ( uint16_t ) /* sin_flags */ +
sizeof ( uint16_t ) /* sin_port */ +
+ sizeof ( uint16_t ) /* sin_scope_id */ +
sizeof ( struct in_addr ) /* sin_addr */ ) ];
} __attribute__ (( packed, may_alias ));
@@ -103,9 +118,10 @@ struct sockaddr_in6 {
uint16_t sin6_flags;
/** TCP/IP port (part of struct @c sockaddr_tcpip) */
uint16_t sin6_port;
- /** Scope ID
+ /** Scope ID (part of struct @c sockaddr_tcpip)
*
- * For link-local addresses, this is the network device index.
+ * For link-local or multicast addresses, this is the network
+ * device index.
*/
uint16_t sin6_scope_id;
/** IPv6 address */