socsvn commit: r269724 - soc2014/shonali/head/contrib/bsnmp/snmpd

shonali at FreeBSD.org shonali at FreeBSD.org
Wed Jun 18 17:50:41 UTC 2014


Author: shonali
Date: Wed Jun 18 17:50:39 2014
New Revision: 269724
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269724

Log:
  ipv6 support in main.c
  

Modified:
  soc2014/shonali/head/contrib/bsnmp/snmpd/main.c
  soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/main.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/main.c	Wed Jun 18 16:03:58 2014	(r269723)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/main.c	Wed Jun 18 17:50:39 2014	(r269724)
@@ -1107,11 +1107,11 @@
  * Each receive should return one datagram.
  */
 static int
-recv_dgram(struct port_input *pi, struct in_addr *laddr)
+recv_dgram(struct port_input *pi, struct in6_addr *laddr)
 {
 	u_char embuf[1000];
 	char cbuf[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) +
-	    CMSG_SPACE(sizeof(struct in_addr))];
+	    CMSG_SPACE(sizeof(struct in6_addr))];
 	struct msghdr msg;
 	struct iovec iov[1];
 	ssize_t len;
@@ -1161,9 +1161,9 @@
 
 	for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
 	    cmsg = CMSG_NXTHDR(&msg, cmsg)) {
-		if (cmsg->cmsg_level == IPPROTO_IP &&
-		    cmsg->cmsg_type == IP_RECVDSTADDR)
-			memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in_addr));
+		if (cmsg->cmsg_level == IPPROTO_IPV6 &&
+		    cmsg->cmsg_type == IP_RECVDSTADDR) /* Check for ipv6 alternative */
+			memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in6_addr));
 		if (cmsg->cmsg_level == SOL_SOCKET &&
 		    cmsg->cmsg_type == SCM_CREDS)
 			cred = (struct sockcred *)CMSG_DATA(cmsg);
@@ -1186,7 +1186,7 @@
 	struct snmp_pdu pdu;
 	enum snmpd_input_err ierr, ferr;
 	enum snmpd_proxy_err perr;
-	int32_t vi;
+	int32_t vi[4];
 	int ret;
 	ssize_t slen;
 #ifdef USE_TCPWRAPPERS
@@ -1194,7 +1194,7 @@
 #endif
 	struct msghdr msg;
 	struct iovec iov[1];
-	char cbuf[CMSG_SPACE(sizeof(struct in_addr))];
+	char cbuf[CMSG_SPACE(sizeof(struct in6_addr))];
 	struct cmsghdr *cmsgp;
 
 	/* get input depending on the transport */
@@ -1204,16 +1204,16 @@
 
 		ret = recv_stream(pi);
 	} else {
-		struct in_addr *laddr;
+		struct in6_addr *laddr;
 
-		memset(cbuf, 0, CMSG_SPACE(sizeof(struct in_addr)));
+		memset(cbuf, 0, CMSG_SPACE(sizeof(struct in6_addr)));
 		msg.msg_control = cbuf;
-		msg.msg_controllen = CMSG_SPACE(sizeof(struct in_addr));
+		msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_addr));
 		cmsgp = CMSG_FIRSTHDR(&msg);
-		cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
-		cmsgp->cmsg_level = IPPROTO_IP;
-		cmsgp->cmsg_type = IP_SENDSRCADDR;
-		laddr = (struct in_addr *)CMSG_DATA(cmsgp);
+		cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_addr));
+		cmsgp->cmsg_level = IPPROTO_IPV6; 
+		cmsgp->cmsg_type = IP_SENDSRCADDR; /* Check for ipv6 alternative */ 
+		laddr = (struct in6_addr *)CMSG_DATA(cmsgp);
 		
 		ret = recv_dgram(pi, laddr);
 
@@ -1232,7 +1232,7 @@
 	 */
 	if (pi->peer->sa_family != AF_LOCAL &&
 	    inet_ntop(pi->peer->sa_family,
-	    &((const struct sockaddr_in *)(const void *)pi->peer)->sin_addr,
+	    &((const struct sockaddr_in6 *)(const void *)pi->peer)->sin6_addr,
 	    client, sizeof(client)) != NULL) {
 		request_set(&req, RQ_CLIENT_ADDR, client, 0);
 		if (hosts_access(&req) == 0) {

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c	Wed Jun 18 16:03:58 2014	(r269723)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c	Wed Jun 18 17:50:39 2014	(r269724)
@@ -112,7 +112,6 @@
 		return (SNMP_ERR_RES_UNAVAIL);
 	}
 
-        /* Need to check - modify ip so as to store ipv6 */ 
 	ip[0] = htonl((p->addr[0] << 24) | (p->addr[1] << 16) | (p->addr[2] << 8) |
         p->addr[3]);
 	ip[1] = htonl((p->addr[4] << 24) | (p->addr[5] << 16) | (p->addr[6] << 8) |


More information about the svn-soc-all mailing list