11 * @defgroup commtypes Communication semantics
16 /** Connection-based, reliable streams */
17 #define SOCK_STREAM ( ( int ) TCP_SOCK_STREAM )
18 extern char TCP_SOCK_STREAM[];
20 /** Connectionless, unreliable streams */
21 #define SOCK_DGRAM ( ( int ) UDP_SOCK_DGRAM )
22 extern char UDP_SOCK_DGRAM[];
27 * Name communication semantics
29 * @v semantics Communication semantics (e.g. SOCK_STREAM)
30 * @ret name Name of communication semantics
32 static inline __attribute__ (( always_inline )) const char *
33 socket_semantics_name ( int semantics ) {
34 /* Cannot use a switch() because of the {TCP_UDP}_SOCK_XXX hack */
35 if ( semantics == SOCK_STREAM ) {
37 } else if ( semantics == SOCK_DGRAM ) {
40 return "SOCK_UNKNOWN";
45 * @defgroup addrfam Address families
49 #define AF_INET 1 /**< IPv4 Internet addresses */
50 #define AF_INET6 2 /**< IPv6 Internet addresses */
56 * @v family Address family (e.g. AF_INET)
57 * @ret name Name of address family
59 static inline __attribute__ (( always_inline )) const char *
60 socket_family_name ( int family ) {
62 case AF_INET: return "AF_INET";
63 case AF_INET6: return "AF_INET6";
64 default: return "AF_UNKNOWN";
68 /** A socket address family */
69 typedef uint16_t sa_family_t;
71 /** Length of a @c struct @c sockaddr */
75 * Generalized socket address structure
77 * This contains the fields common to socket addresses for all address
81 /** Socket address family
83 * This is an AF_XXX constant.
85 sa_family_t sa_family;
88 * This ensures that a struct @c sockaddr_tcpip is large
89 * enough to hold a socket address for any TCP/IP address
92 char pad[ SA_LEN - sizeof ( sa_family_t ) ];
95 #endif /* _GPXE_SOCKET_H */