From 9d3ab08f1e97a7df5a1d17fa2f7e130977676abd Mon Sep 17 00:00:00 2001 From: gardners Date: Sun, 5 Feb 2012 17:53:51 +1030 Subject: [PATCH] added debug output to help track down the recvmsg() control message IDs on linux (seem to be different than on BSD). --- server.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server.c b/server.c index 234fc391..02a66731 100644 --- a/server.c +++ b/server.c @@ -69,15 +69,19 @@ int recvwithttl(int sock,unsigned char *buffer,int bufferlen,int *ttl, cmsg != NULL; cmsg = CMSG_NXTHDR(&msg,cmsg)) { - if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_RECVTTL) && - (cmsg->cmsg_len) ){ + if ((cmsg->cmsg_level == IPPROTO_IP) && + ((cmsg->cmsg_type == IP_RECVTTL) ||(cmsg->cmsg_type == IP_TTL)) + &&(cmsg->cmsg_len) ){ fprintf(stderr," TTL (%p) data location resolves to %p\n", ttl,CMSG_DATA(cmsg)); if (CMSG_DATA(cmsg)) { *ttl = *(unsigned char *) CMSG_DATA(cmsg); fprintf(stderr," TTL of packet is %d\n",*ttl); } - } + } else { + fprintf(stderr,"I didn't expect to see level=%02x, type=%02x\n", + cmsg->cmsg_level,cmsg->cmsg_type); + } } } *recvaddrlen=msg.msg_namelen;