You set the IP_PKTINFO option using setsockopt and then use recvmsg and get a in_pktinfo structure in the msg_control member of struct msghdr. the in_pktinfo has a field with the destination address of the packet.
You set the IP_PKTINFO option using setsockopt and then use recvmsg and get a in_pktinfo structure in the msg_control member of struct msghdr. the in_pktinfo has a field with the destination address of the packet. See: linuxquestions.org/questions/programming... where I found the answer for more details.
I've constructed an example that extracts the source, destination and interface addresses. For brevity, no error checking is provided. // sock is bound AF_INET socket, usually SOCK_DGRAM // include struct in_pktinfo in the message "ancilliary" control data setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &opt, sizeof(opt)); // the control data is dumped here char cmbuf0x100; // the remote/source sockaddr is put here struct sockaddr_in peeraddr; // if you want access to the data you need to init the msg_iovec fields struct msghdr mh = { .
Msg_name = &peeraddr, . Msg_namelen = sizeof(peeraddr), . Msg_control = cmbuf, .
Msg_controllen = sizeof(cmbuf), }; recvmsg(sock, &mh, 0); for ( // iterate through all the control headers struct cmsghdr *cmsg = CMSG_FIRSTHDR(&mh); cmsg! = NULL; cmsg = CMSG_NXTHDR(&mh, cmsg)) { // ignore the control headers that don't match what we want if (cmsg->cmsg_level! = IPPROTO_IP || cmsg->cmsg_type!
= IP_PKTINFO) { continue; } struct in_pktinfo *pi = CMSG_DATA(cmsg); // at this point, peeraddr is the source sockaddr // pi->ipi_spec_dst is the destination in_addr // pi->ipi_addr is the receiving interface in_addr }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.