Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Aug 2014 10:09:07 GMT
From:      shonali@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r272164 - soc2014/shonali/head/contrib/bsnmp/snmpd
Message-ID:  <201408101009.s7AA97RX007782@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: shonali
Date: Sun Aug 10 10:09:07 2014
New Revision: 272164
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272164

Log:
  Removed redundant host to network byte order conversion in trap.c
  

Modified:
  soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c	Sun Aug 10 09:11:44 2014	(r272163)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c	Sun Aug 10 10:09:07 2014	(r272164)
@@ -116,13 +116,13 @@
 	t->version = TRAPSINK_V2;
 
 	switch (t->index.len) {
-                /* IPv4 - Check if there is a better way of determining address type */
-                case 6:
+                case SNMP_UDP_ADDR_SIZ:
         	        trapsink_create_sock(t);
+			break;
 
-                /* IPv6 - Check if there is a better way of determining address type */
-                case 18:
+                case SNMP_UDP_ADDRv6_SIZ:
 			trapsink_create_sockv6(t);
+			break;
 
                 default:
                         return (NULL);
@@ -191,11 +191,7 @@
         memset(&sa, 0, sizeof(sa));
         sa.sin6_len = sizeof(sa);
         sa.sin6_family = AF_INET6;
-        /* Host to network byte order not reqd - check */ 
-        *(sa.sin6_addr.s6_addr) = (t->index.subs[0] << 120) | (t->index.subs[1] << 112) | (t->index.subs[2] << 104) | (t->index.subs[3] << 96) | (t->index.subs[4] << 88) | 
-	   (t->index.subs[5] << 80) | (t->index.subs[6] << 72) | (t->index.subs[7] << 64) | (t->index.subs[8] << 56) |
-           (t->index.subs[9] << 48) | (t->index.subs[10] << 40) | (t->index.subs[11] << 32) | (t->index.subs[12] << 24) | 
-	   (t->index.subs[13] << 16) | (t->index.subs[14] << 8) | t->index.subs[15];
+	inet_pton(AF_INET6, &(t->index.subs), &(sa.sin6_addr.s6_addr));
         sa.sin6_port = htons(t->index.subs[16]);
         
         char dst[INET6_ADDRSTRLEN];
@@ -810,12 +806,7 @@
 	                memset(&sa6, 0, sizeof(sa6));
 	                sa6.sin6_len = sizeof(sa6);
 	                sa6.sin6_family = AF_INET6;
-                        /* Host to network byte order not reqd - check */ 
-                        *(sa6.sin6_addr.s6_addr) = (addrs->address.address6[0] << 120) | (addrs->address.address6[1] << 112) | (addrs->address.address6[2] << 104) | 
-                        (addrs->address.address6[3] << 96) | (addrs->address.address6[4] << 88) | 
-			(addrs->address.address6[5] << 80) | (addrs->address.address6[6] << 72) | (addrs->address.address6[7] << 64) | (addrs->address.address6[8] << 56) |
-                        (addrs->address.address6[9] << 48) | (addrs->address.address6[10] << 40) | (addrs->address.address6[11] << 32) | (addrs->address.address6[12] << 24) | 
-		        (addrs->address.address6[13] << 16) | (addrs->address.address6[14] << 8) | addrs->address.address6[15];
+			inet_pton(AF_INET6, &(addrs->address.address6), &(sa6.sin6_addr.s6_addr));
 	                sa6.sin6_port = htons(addrs->address.address6[16]) << 8 |
 	                htons(addrs->address.address6[17]) << 0;
                         char dst[INET6_ADDRSTRLEN];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408101009.s7AA97RX007782>