1

I'm opening a RAW socket in Linux and reading all messages.

recvmsg(mysock, &msg, 0);

I'm traversing on all cmsg on that msg buffer and I get only one.

    for (c = CMSG_FIRSTHDR(&msg); c; c = CMSG_NXTHDR(&msg, c)) {

How can I extract the ifindex on which it received on ?

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
User121212
  • 35
  • 5

1 Answers1

1

Found it. I had to set the IP_PKTINFO flag first:

setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &hold, sizeof(hold));
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
User121212
  • 35
  • 5