Commit Diff


commit - 4c78317f8c99c1d57a6c6f648aa33eb0d299b895
commit + 562d28f366cac1075071ff6c285011ae142a465e
blob - b0653c5416bed7ebe72bbacf514cb82bb28e216f
blob + a0f5ad2fff0198ca581319b5ab0db5d295605398
--- main.c
+++ main.c
@@ -138,7 +138,7 @@ struct tcps {
 } *tn1, *tn2, *tnp;
 
 
-static const char rcsid[] = "$Id: main.c,v 1.71 2012/04/30 15:34:45 pbug Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.72 2012/06/11 20:36:28 pbug Exp $";
 
 /* 
  * MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -452,9 +452,16 @@ main(int argc, char *argv[])
 					&on, sizeof(on)) < 0) {
 #endif
 				syslog(LOG_INFO, "setsockopt: %m");
+				}
+			} else if (res->ai_family == AF_INET6) {
+				/* RFC 3542 page 30 */
+				on = 1;
+     				if (setsockopt(udp[i], IPPROTO_IPV6, 
+					IPV6_RECVHOPLIMIT, &on, sizeof(on)) < 0) {
+					syslog(LOG_INFO, "setsockopt: %m");
 				}
 			}
-			
+
 			ident[i] = bind_list[i];
 
 			/* tcp below */
@@ -611,8 +618,16 @@ main(int argc, char *argv[])
 #endif
 				syslog(LOG_INFO, "setsockopt: %m");
 				}
+			} else if (pifap->ifa_addr->sa_family == AF_INET6) {
+				/* RFC 3542 page 30 */
+				on = 1;
+     				if (setsockopt(udp[i], IPPROTO_IPV6, 
+					IPV6_RECVHOPLIMIT, &on, sizeof(on)) < 0) {
+					syslog(LOG_INFO, "setsockopt: %m");
+				}
 			}
 
+
 			ident[i] = pifap->ifa_name;
 
 			if ((tcp[i] = socket(pifap->ifa_addr->sa_family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
@@ -2673,8 +2688,20 @@ axfrentry:
                               			ttlptr = (int *) CMSG_DATA(cmsg);
                               			received_ttl = (u_int)*ttlptr;
 #endif
-                              			break;
                       				}
+
+									if (cmsg->cmsg_level == IPPROTO_IPV6 &&
+                         				cmsg->cmsg_type == IPV6_HOPLIMIT) {
+
+										if (cmsg->cmsg_len != 
+												CMSG_LEN(sizeof(int))) {
+											syslog(LOG_INFO, "cmsg->cmsg_len == %d", cmsg->cmsg_len);
+											continue;
+										}
+
+										ttlptr = (u_char *) CMSG_DATA(cmsg);
+										received_ttl = (u_int)*ttlptr;
+                     				}
 				}
 	
 				if (rflag) {