00001 #ifndef _GPXE_IN_H 00002 #define _GPXE_IN_H 00003 00004 FILE_LICENCE ( GPL2_OR_LATER ); 00005 00006 #include <stdint.h> 00007 #include <gpxe/socket.h> 00008 00009 /* Protocol numbers */ 00010 00011 #define IP_ICMP 1 00012 #define IP_TCP 6 00013 #define IP_UDP 17 00014 #define IP_ICMP6 58 00015 00016 /* IP address constants */ 00017 00018 #define INADDR_NONE 0xffffffff 00019 00020 #define INADDR_BROADCAST 0xffffffff 00021 00022 #define IN_CLASSA(addr) ( ( (addr) & 0x80000000 ) == 0x00000000 ) 00023 #define IN_CLASSA_NET 0xff000000 00024 #define IN_CLASSB(addr) ( ( (addr) & 0xc0000000 ) == 0x80000000 ) 00025 #define IN_CLASSB_NET 0xffff0000 00026 #define IN_CLASSC(addr) ( ( (addr) & 0xe0000000 ) == 0xc0000000 ) 00027 #define IN_CLASSC_NET 0xffffff00 00028 #define IN_MULTICAST(addr) ( ( (addr) & 0xf0000000 ) == 0xe0000000 ) 00029 00030 /** 00031 * IP address structure 00032 */ 00033 struct in_addr { 00034 uint32_t s_addr; 00035 }; 00036 00037 typedef struct in_addr in_addr; 00038 00039 /** 00040 * IP6 address structure 00041 */ 00042 struct in6_addr { 00043 union { 00044 uint8_t u6_addr8[16]; 00045 uint16_t u6_addr16[8]; 00046 uint32_t u6_addr32[4]; 00047 } in6_u; 00048 #define s6_addr in6_u.u6_addr8 00049 #define s6_addr16 in6_u.u6_addr16 00050 #define s6_addr32 in6_u.u6_addr32 00051 }; 00052 00053 /** 00054 * IPv4 socket address 00055 */ 00056 struct sockaddr_in { 00057 /** Socket address family (part of struct @c sockaddr) 00058 * 00059 * Always set to @c AF_INET for IPv4 addresses 00060 */ 00061 sa_family_t sin_family; 00062 /** TCP/IP port (part of struct @c sockaddr_tcpip) */ 00063 uint16_t sin_port; 00064 /** IPv4 address */ 00065 struct in_addr sin_addr; 00066 /** Padding 00067 * 00068 * This ensures that a struct @c sockaddr_tcpip is large 00069 * enough to hold a socket address for any TCP/IP address 00070 * family. 00071 */ 00072 char pad[ sizeof ( struct sockaddr ) - sizeof ( sa_family_t ) 00073 - sizeof ( uint16_t ) 00074 - sizeof ( struct in_addr ) ]; 00075 } __attribute__ (( may_alias )); 00076 00077 /** 00078 * IPv6 socket address 00079 */ 00080 struct sockaddr_in6 { 00081 /** Socket address family (part of struct @c sockaddr) 00082 * 00083 * Always set to @c AF_INET6 for IPv6 addresses 00084 */ 00085 sa_family_t sin_family; 00086 /** TCP/IP port (part of struct @c sockaddr_tcpip) */ 00087 uint16_t sin_port; 00088 uint32_t sin6_flowinfo; /* Flow number */ 00089 struct in6_addr sin6_addr; /* 128-bit destination address */ 00090 uint32_t sin6_scope_id; /* Scope ID */ 00091 } __attribute__ (( may_alias )); 00092 00093 extern int inet_aton ( const char *cp, struct in_addr *inp ); 00094 extern char * inet_ntoa ( struct in_addr in ); 00095 00096 /* Adding the following for IP6 support 00097 * 00098 00099 extern int inet6_aton ( const char *cp, struct in6_addr *inp ); 00100 extern char * inet6_ntoa ( struct in_addr in ); 00101 00102 */ 00103 00104 #endif /* _GPXE_IN_H */
1.5.7.1