73
74
if ((m->fd = socket(conf->ipproto, SOCK_DGRAM, 0)) == -1) {
74
debug("mcast_sock_server_create:socket");
82
strncpy(ifr.ifr_name, conf->iface, sizeof(ifr.ifr_name));
84
if (ioctl(m->fd, SIOCGIFMTU, &ifr) == -1) {
90
conf->mtu = ifr.ifr_mtu;
93
79
if (setsockopt(m->fd, SOL_SOCKET, SO_REUSEADDR, &yes,
94
80
sizeof(int)) == -1) {
95
debug("mcast_sock_server_create:setsockopt1");
223
200
memset(m, 0, sizeof(struct mcast_sock));
225
202
if ((m->fd = socket(conf->ipproto, SOCK_DGRAM, 0)) == -1) {
226
debug("mcast_sock_client_create:socket");
231
207
if (setsockopt(m->fd, SOL_SOCKET, SO_NO_CHECK, &conf->checksum,
232
208
sizeof(int)) == -1) {
233
debug("mcast_sock_client_create:setsockopt1");
329
struct mcast_stats *mcast_get_stats(struct mcast_sock *m)
334
void mcast_dump_stats(int fd, struct mcast_sock *s, struct mcast_sock *r)
339
size = sprintf(buf, "multicast traffic:\n"
341
"%20llu Bytes recv\n"
343
"%20llu Pckts recv\n"
345
"%20llu Error recv\n\n",
346
(unsigned long long)s->stats.bytes,
347
(unsigned long long)r->stats.bytes,
348
(unsigned long long)s->stats.messages,
349
(unsigned long long)r->stats.messages,
350
(unsigned long long)s->stats.error,
351
(unsigned long long)r->stats.error);
353
send(fd, buf, size, 0);
301
int mcast_get_fd(struct mcast_sock *m)
307
mcast_snprintf_stats(char *buf, size_t buflen, char *ifname,
308
struct mcast_stats *s, struct mcast_stats *r)
312
size = snprintf(buf, buflen, "multicast traffic (active device=%s):\n"
314
"%20llu Bytes recv\n"
316
"%20llu Pckts recv\n"
318
"%20llu Error recv\n\n",
320
(unsigned long long)s->bytes,
321
(unsigned long long)r->bytes,
322
(unsigned long long)s->messages,
323
(unsigned long long)r->messages,
324
(unsigned long long)s->error,
325
(unsigned long long)r->error);
330
mcast_snprintf_stats2(char *buf, size_t buflen, const char *ifname,
331
const char *status, int active,
332
struct mcast_stats *s, struct mcast_stats *r)
336
size = snprintf(buf, buflen,
337
"multicast traffic device=%s status=%s role=%s:\n"
339
"%20llu Bytes recv\n"
341
"%20llu Pckts recv\n"
343
"%20llu Error recv\n\n",
344
ifname, status, active ? "ACTIVE" : "BACKUP",
345
(unsigned long long)s->bytes,
346
(unsigned long long)r->bytes,
347
(unsigned long long)s->messages,
348
(unsigned long long)r->messages,
349
(unsigned long long)s->error,
350
(unsigned long long)r->error);