1#ifndef _MCAST_H_ 2#define _MCAST_H_ 3 4#include <stdint.h> 5#include <netinet/in.h> 6#include <net/if.h> 7 8struct mcast_conf { 9 int ipproto; 10 int reuseaddr; 11 int checksum; 12 unsigned short port; 13 union { 14 struct in_addr inet_addr; 15 struct in6_addr inet_addr6; 16 } in; 17 union { 18 struct in_addr interface_addr; 19 unsigned int interface_index6; 20 } ifa; 21 int sndbuf; 22 int rcvbuf; 23}; 24 25struct mcast_stats { 26 uint64_t bytes; 27 uint64_t messages; 28 uint64_t error; 29}; 30 31struct mcast_sock { 32 int fd; 33 union { 34 struct sockaddr_in ipv4; 35 struct sockaddr_in6 ipv6; 36 } addr; 37 socklen_t sockaddr_len; 38 struct mcast_stats stats; 39}; 40 41struct mcast_sock *mcast_server_create(struct mcast_conf *conf); 42void mcast_server_destroy(struct mcast_sock *m); 43 44struct mcast_sock *mcast_client_create(struct mcast_conf *conf); 45void mcast_client_destroy(struct mcast_sock *m); 46 47ssize_t mcast_send(struct mcast_sock *m, const void *data, int size); 48ssize_t mcast_recv(struct mcast_sock *m, void *data, int size); 49 50int mcast_get_fd(struct mcast_sock *m); 51int mcast_isset(struct mcast_sock *m, fd_set *readfds); 52 53int mcast_snprintf_stats(char *buf, size_t buflen, char *ifname, 54 struct mcast_stats *s, struct mcast_stats *r); 55 56int mcast_snprintf_stats2(char *buf, size_t buflen, const char *ifname, 57 const char *status, int active, 58 struct mcast_stats *s, struct mcast_stats *r); 59 60#endif 61