22 #ifndef _LWPA_SOCKET_H_ 
   23 #define _LWPA_SOCKET_H_ 
   26 #include "lwpa_common.h" 
   27 #include "lwpa_bool.h" 
   28 #include "lwpa_error.h" 
   29 #include "lwpa_inet.h" 
   30 #include "lwpa_socket_plat.h" 
   51 #define LWPA_MSG_PEEK 0x1 
   59 #define LWPA_SOL_SOCKET     0  
   60 #define LWPA_IPPROTO_IP     1  
   61 #define LWPA_IPPROTO_ICMPV6 2  
   62 #define LWPA_IPPROTO_IPV6   3  
   63 #define LWPA_IPPROTO_TCP    4  
   64 #define LWPA_IPPROTO_UDP    5  
   72 #define LWPA_SO_BROADCAST 0   
   73 #define LWPA_SO_ERROR     1   
   75 #define LWPA_SO_KEEPALIVE 2   
   76 #define LWPA_SO_LINGER    3   
   77 #define LWPA_SO_RCVBUF    4   
   79 #define LWPA_SO_SNDBUF    5   
   81 #define LWPA_SO_RCVTIMEO  6   
   82 #define LWPA_SO_SNDTIMEO  7   
   83 #define LWPA_SO_REUSEADDR 8   
   84 #define LWPA_SO_REUSEPORT 9   
   85 #define LWPA_SO_TYPE      10  
   93 #define LWPA_IP_TTL            11  
   94 #define LWPA_IP_MULTICAST_IF   12  
   95 #define LWPA_IP_MULTICAST_TTL  13  
   96 #define LWPA_IP_MULTICAST_LOOP 14  
   97 #define LWPA_MCAST_JOIN_GROUP  15  
   98 #define LWPA_MCAST_LEAVE_GROUP 16  
  123 #define LWPA_SHUT_RD 0 
  124 #define LWPA_SHUT_WR 1 
  125 #define LWPA_SHUT_RDWR 2 
  130 #define LWPA_AF_UNSPEC 0 
  131 #define LWPA_AF_INET 1 
  132 #define LWPA_AF_INET6 2 
  137 #define LWPA_STREAM 0 
  181 #define LWPA_POLLIN 0x1 
  182 #define LWPA_POLLOUT 0x2 
  183 #define LWPA_POLLPRI 0x4 
  184 #define LWPA_POLLERR 0x8 
  205 #define LWPA_AI_PASSIVE 0x01 
  206 #define LWPA_AI_CANONNAME 0x02 
  207 #define LWPA_AI_NUMERICHOST 0x04 
  236 #define LWPA_INET_ADDRSTRLEN 16 
  238 #define LWPA_INET6_ADDRSTRLEN 46 
lwpa_error_t
A set of error codes that can be returned by library functions.
Definition: lwpa_error.h:37
lwpa_iptype_t
Used to identify the type of IP address contained in a LwpaIpAddr.
Definition: lwpa_inet.h:40
lwpa_socket_t lwpa_socket(unsigned int family, unsigned int type)
Create a socket.
Definition: lwpa_socket.c:437
lwpa_error_t lwpa_getsockname(lwpa_socket_t id, LwpaSockaddr *address)
Get socket name.
Definition: lwpa_socket.c:223
struct LwpaPollfd LwpaPollfd
A description for a socket to poll with lwpa_poll().
struct LwpaAddrinfo LwpaAddrinfo
A structure containing name and address information about an internet host.
lwpa_error_t lwpa_inet_pton(lwpa_iptype_t type, const char *src, LwpaIpAddr *dest)
Convert IPv4 and IPv6 addresses from text to binary form.
Definition: lwpa_socket.c:614
lwpa_error_t lwpa_getpeername(lwpa_socket_t id, LwpaSockaddr *address)
Get the name of the connected peer socket.
Definition: lwpa_socket.c:217
void lwpa_socket_deinit()
Deinitialize the lwpa_socket module.
Definition: lwpa_socket.c:148
lwpa_error_t lwpa_socket_init(void *platform_data)
Initialize the lwpa_socket module.
Definition: lwpa_socket.c:141
lwpa_error_t lwpa_getsockopt(lwpa_socket_t id, int level, int option_name, void *option_value, size_t *option_len)
Get an option value for a socket.
Definition: lwpa_socket.c:241
lwpa_error_t lwpa_getaddrinfo(const char *hostname, const char *service, const LwpaAddrinfo *hints, LwpaAddrinfo *result)
Get address information for a named internet host and/or service.
Definition: lwpa_socket.c:515
lwpa_error_t lwpa_connect(lwpa_socket_t id, const LwpaSockaddr *address)
Initiate a connection on a socket.
Definition: lwpa_socket.c:211
lwpa_error_t lwpa_bind(lwpa_socket_t id, const LwpaSockaddr *address)
Bind a name to a socket.
Definition: lwpa_socket.c:191
lwpa_error_t lwpa_setblocking(lwpa_socket_t id, bool blocking)
Change the blocking behavior of a socket.
Definition: lwpa_socket.c:469
void lwpa_freeaddrinfo(LwpaAddrinfo *ai)
Free an addrinfo list returned by lwpa_getaddrinfo().
Definition: lwpa_socket.c:580
int lwpa_recv(lwpa_socket_t id, void *buffer, size_t length, int flags)
Receive data on a connected socket.
Definition: lwpa_socket.c:253
UNDEFINED lwpa_socket_t
A socket handle.
Definition: lwpa_socket.dox:10
struct LwpaMreq LwpaMreq
Option value for LWPA_MCAST_JOIN_GROUP and LWPA_MCAST_LEAVE_GROUP.
int lwpa_recvfrom(lwpa_socket_t id, void *buffer, size_t length, int flags, LwpaSockaddr *address)
Receive data on a socket.
Definition: lwpa_socket.c:259
lwpa_error_t lwpa_close(lwpa_socket_t id)
Close a socket.
Definition: lwpa_socket.c:206
lwpa_error_t lwpa_listen(lwpa_socket_t id, int backlog)
Listen for connections on a socket.
Definition: lwpa_socket.c:247
lwpa_error_t lwpa_accept(lwpa_socket_t id, LwpaSockaddr *address, lwpa_socket_t *conn_sock)
Accept a connection on a socket.
Definition: lwpa_socket.c:185
lwpa_error_t lwpa_inet_ntop(const LwpaIpAddr *src, char *dest, size_t size)
Convert IPv4 and IPv6 addresses from binary to text form.
Definition: lwpa_socket.c:586
lwpa_error_t lwpa_setsockopt(lwpa_socket_t id, int level, int option_name, const void *option_value, size_t option_len)
Set an option value on a socket.
Definition: lwpa_socket.c:304
int lwpa_sendto(lwpa_socket_t id, const void *message, size_t length, int flags, const LwpaSockaddr *dest_addr)
Send data on a socket.
Definition: lwpa_socket.c:288
int lwpa_send(lwpa_socket_t id, const void *message, size_t length, int flags)
Send data on a connected socket.
Definition: lwpa_socket.c:282
lwpa_error_t lwpa_shutdown(lwpa_socket_t id, int how)
Shut down part of a full-duplex connection.
Definition: lwpa_socket.c:449
struct LwpaLinger LwpaLinger
Option value for LWPA_SO_LINGER.
int lwpa_poll(LwpaPollfd *fds, size_t nfds, int timeout_ms)
Wait for some event on a set of sockets.
Definition: lwpa_socket.c:448
bool lwpa_nextaddr(LwpaAddrinfo *ai)
Get the next address from the list returned by lwpa_getaddrinfo().
Definition: lwpa_socket.c:544
A structure containing name and address information about an internet host.
Definition: lwpa_socket.h:213
LwpaSockaddr ai_addr
Address of host.
Definition: lwpa_socket.h:219
int ai_socktype
i.e.
Definition: lwpa_socket.h:216
int ai_family
i.e.
Definition: lwpa_socket.h:215
int ai_protocol
i.e.
Definition: lwpa_socket.h:217
int ai_flags
i.e.
Definition: lwpa_socket.h:214
char * ai_canonname
Canonical name for host.
Definition: lwpa_socket.h:218
void * pd[2]
Used by internal platform logic; don't touch.
Definition: lwpa_socket.h:220
An IP address.
Definition: lwpa_inet.h:55
Option value for LWPA_SO_LINGER.
Definition: lwpa_socket.h:107
int linger
Linger time in seconds.
Definition: lwpa_socket.h:109
int onoff
0 = off, nonzero = on
Definition: lwpa_socket.h:108
Option value for LWPA_MCAST_JOIN_GROUP and LWPA_MCAST_LEAVE_GROUP.
Definition: lwpa_socket.h:114
LwpaIpAddr group
Multicast group to join.
Definition: lwpa_socket.h:118
LwpaIpAddr netint
Address of network interface on which to join the multicast group.
Definition: lwpa_socket.h:116
A description for a socket to poll with lwpa_poll().
Definition: lwpa_socket.h:189
lwpa_error_t err
Any error that occurred on the socket.
Definition: lwpa_socket.h:193
short events
Events to poll for.
Definition: lwpa_socket.h:191
lwpa_socket_t fd
Socket to poll.
Definition: lwpa_socket.h:190
short revents
Events that occurred on the socket.
Definition: lwpa_socket.h:192
An IP address with associated interface and port.
Definition: lwpa_inet.h:176