4 FILE_LICENCE ( GPL2_OR_LATER
);
7 #include <gpxe/socket.h>
16 /* IP address constants */
18 #define INADDR_NONE 0xffffffff
20 #define INADDR_BROADCAST 0xffffffff
22 #define IN_CLASSA(addr) ( ( (addr) & 0x80000000 ) == 0x00000000 )
23 #define IN_CLASSA_NET 0xff000000
24 #define IN_CLASSB(addr) ( ( (addr) & 0xc0000000 ) == 0x80000000 )
25 #define IN_CLASSB_NET 0xffff0000
26 #define IN_CLASSC(addr) ( ( (addr) & 0xe0000000 ) == 0xc0000000 )
27 #define IN_CLASSC_NET 0xffffff00
28 #define IN_MULTICAST(addr) ( ( (addr) & 0xf0000000 ) == 0xe0000000 )
31 * IP address structure
37 typedef struct in_addr in_addr
;
40 * IP6 address structure
45 uint16_t u6_addr16
[8];
46 uint32_t u6_addr32
[4];
48 #define s6_addr in6_u.u6_addr8
49 #define s6_addr16 in6_u.u6_addr16
50 #define s6_addr32 in6_u.u6_addr32
57 /** Socket address family (part of struct @c sockaddr)
59 * Always set to @c AF_INET for IPv4 addresses
61 sa_family_t sin_family
;
62 /** TCP/IP port (part of struct @c sockaddr_tcpip) */
65 struct in_addr sin_addr
;
68 * This ensures that a struct @c sockaddr_tcpip is large
69 * enough to hold a socket address for any TCP/IP address
72 char pad
[ sizeof ( struct sockaddr
) - sizeof ( sa_family_t
)
74 - sizeof ( struct in_addr
) ];
75 } __attribute__ (( may_alias
));
81 /** Socket address family (part of struct @c sockaddr)
83 * Always set to @c AF_INET6 for IPv6 addresses
85 sa_family_t sin_family
;
86 /** TCP/IP port (part of struct @c sockaddr_tcpip) */
88 uint32_t sin6_flowinfo
; /* Flow number */
89 struct in6_addr sin6_addr
; /* 128-bit destination address */
90 uint32_t sin6_scope_id
; /* Scope ID */
91 } __attribute__ (( may_alias
));
93 extern int inet_aton ( const char *cp
, struct in_addr
*inp
);
94 extern char * inet_ntoa ( struct in_addr in
);
96 /* Adding the following for IP6 support
99 extern int inet6_aton ( const char *cp, struct in6_addr *inp );
100 extern char * inet6_ntoa ( struct in_addr in );
104 #endif /* _GPXE_IN_H */