/* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. $id$ */ #ifndef OT_SOCKET_H__ #define OT_SOCKET_H__ #include #include #include "trackerlogic.h" /* Every socket opentracker opens is an AF_INET6 socket with IPV6_V6ONLY cleared, so one descriptor serves both families and an IPv4 peer arrives as the v4 mapped address */ /* Ask the kernel to let several processes bind the same address */ extern int g_socket_reuseport; /* Create, bind and, for TCP, listen. The returned socket is non blocking Returns -1 on failure with errno set */ int socket_tcp_listen(const ot_ip6 ip, uint16_t port); int socket_udp_bind(const ot_ip6 ip, uint16_t port); int socket_tcp_connect(const ot_ip6 srcip, uint16_t srcport, const ot_ip6 dstip, uint16_t dstport); int socket_is_connected(int s); int socket_accept(int s, ot_ip6 ip, uint16_t *port); ssize_t socket_recv(int s, void *buf, size_t len, ot_ip6 ip, uint16_t *port); ssize_t socket_send(int s, const void *buf, size_t len, const ot_ip6 ip, uint16_t port); #ifdef WANT_SYNC_LIVE /* socket_mcast_join takes the wildcard address and names the interface in the join, and hands back a blocking socket, since the thread that reads it does nothing else. socket_mcast_bind hands back a non blocking one, because the thread that sends from it is also serving clients. Incoming datagrams are read with socket_recv */ int socket_mcast_join(const ot_ip6 group, const ot_ip6 interface, uint16_t port); int socket_mcast_bind(const ot_ip6 interface, uint16_t port, int loopback); ssize_t socket_mcast_send(int s, const void *buf, size_t len, const ot_ip6 group, uint16_t port); #endif #endif