Skip to content

Instantly share code, notes, and snippets.

@Hugne
Last active December 12, 2015 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hugne/4721151 to your computer and use it in GitHub Desktop.
Save Hugne/4721151 to your computer and use it in GitHub Desktop.
Packets sent to node-local scoped addresses escape out on the network
#include <sys/socket.h>
#include <netinet/ip6.h>
#include <string.h>
int main(int argc, char *argv[])
{
int s;
struct sockaddr_in6 si_iflocal = {0};
const char *msg = "hello";
s=socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
si_iflocal.sin6_family = AF_INET6;
si_iflocal.sin6_port = htons(51000);
inet_pton(AF_INET6, "ff01::1", &si_iflocal.sin6_addr);
sendto(s, msg, strlen(msg), 0, (struct sockaddr *) &si_iflocal, sizeof(si_iflocal));
close(s);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment