10 FILE_LICENCE ( GPL2_OR_LATER
);
15 * @defgroup commtypes Communication semantics
20 /** Connection-based, reliable streams */
21 extern int tcp_sock_stream
;
22 #define TCP_SOCK_STREAM 0x1
23 #define SOCK_STREAM tcp_sock_stream
25 /** Connectionless, unreliable streams */
26 extern int udp_sock_dgram
;
27 #define UDP_SOCK_DGRAM 0x2
28 #define SOCK_DGRAM udp_sock_dgram
33 * Name communication semantics
35 * @v semantics Communication semantics (e.g. SOCK_STREAM)
36 * @ret name Name of communication semantics
38 static inline __attribute__ (( always_inline
)) const char *
39 socket_semantics_name ( int semantics
) {
40 /* Cannot use a switch() because of the {TCP_UDP}_SOCK_XXX hack */
41 if ( semantics
== SOCK_STREAM
) {
43 } else if ( semantics
== SOCK_DGRAM
) {
46 return "SOCK_UNKNOWN";
51 * @defgroup addrfam Address families
55 #define AF_INET 1 /**< IPv4 Internet addresses */
56 #define AF_INET6 2 /**< IPv6 Internet addresses */
62 * @v family Address family (e.g. AF_INET)
63 * @ret name Name of address family
65 static inline __attribute__ (( always_inline
)) const char *
66 socket_family_name ( int family
) {
68 case AF_INET
: return "AF_INET";
69 case AF_INET6
: return "AF_INET6";
70 default: return "AF_UNKNOWN";
74 /** A socket address family */
75 typedef uint16_t sa_family_t
;
77 /** Length of a @c struct @c sockaddr */
81 * Generalized socket address structure
83 * This contains the fields common to socket addresses for all address
87 /** Socket address family
89 * This is an AF_XXX constant.
91 sa_family_t sa_family
;
94 * This ensures that a struct @c sockaddr_tcpip is large
95 * enough to hold a socket address for any TCP/IP address
98 char pad
[ SA_LEN
- sizeof ( sa_family_t
) ];
99 } __attribute__ (( may_alias
));
101 #endif /* _GPXE_SOCKET_H */