2019-12-07 IPPROTO_RAW
2019-12-07 本文已影响0人
阿群1986
if (sendfd < 0) {
if ((sendfd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
perror ("socket() failed ");
exit (EXIT_FAILURE);
}
if (setsockopt (sendfd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)) < 0) {
perror ("setsockopt() failed to set IP_HDRINCL ");
exit (EXIT_FAILURE);
}
}