[proto] Remove unsupported IGMP protocol
[gpxe.git] / src / include / gpxe / in.h
blobc313717c0acb7aaea6c6cfaf07337004b60d2308
1 #ifndef _GPXE_IN_H
2 #define _GPXE_IN_H
4 FILE_LICENCE ( GPL2_OR_LATER );
6 #include <stdint.h>
7 #include <gpxe/socket.h>
9 /* Protocol numbers */
11 #define IP_ICMP 1
12 #define IP_TCP 6
13 #define IP_UDP 17
14 #define IP_ICMP6 58
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 )
30 /**
31 * IP address structure
33 struct in_addr {
34 uint32_t s_addr;
37 typedef struct in_addr in_addr;
39 /**
40 * IP6 address structure
42 struct in6_addr {
43 union {
44 uint8_t u6_addr8[16];
45 uint16_t u6_addr16[8];
46 uint32_t u6_addr32[4];
47 } in6_u;
48 #define s6_addr in6_u.u6_addr8
49 #define s6_addr16 in6_u.u6_addr16
50 #define s6_addr32 in6_u.u6_addr32
53 /**
54 * IPv4 socket address
56 struct sockaddr_in {
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) */
63 uint16_t sin_port;
64 /** IPv4 address */
65 struct in_addr sin_addr;
66 /** Padding
68 * This ensures that a struct @c sockaddr_tcpip is large
69 * enough to hold a socket address for any TCP/IP address
70 * family.
72 char pad[ sizeof ( struct sockaddr ) - sizeof ( sa_family_t )
73 - sizeof ( uint16_t )
74 - sizeof ( struct in_addr ) ];
75 } __attribute__ (( may_alias ));
77 /**
78 * IPv6 socket address
80 struct sockaddr_in6 {
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) */
87 uint16_t sin_port;
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 */