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

shonali at FreeBSD.org shonali at FreeBSD.org
Sun Aug 3 09:46:23 UTC 2014


Author: shonali
Date: Sun Aug  3 09:46:21 2014
New Revision: 271780
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271780

Log:
  Resolved compile errors in trans_XXX.c and trap.c
  

Modified:
  soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h
  soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c
  soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c
  soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c
  soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h	Sun Aug  3 08:32:54 2014	(r271779)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/snmpmod.h	Sun Aug  3 09:46:21 2014	(r271780)
@@ -530,7 +530,6 @@
 struct target_notify *target_new_notify(char *);
 int target_delete_notify (struct target_notify *);
 void target_flush_all(void);
-
 /*
  * Well known OIDs
  */

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c	Sun Aug  3 08:32:54 2014	(r271779)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c	Sun Aug  3 09:46:21 2014	(r271780)
@@ -59,6 +59,7 @@
 static ssize_t lsock_send(struct tport *, const u_char *, size_t,
     const struct sockaddr *, size_t);
 static ssize_t lsock_recv(struct tport *, struct port_input *);
+static int recv_dgram(struct port_input *, struct in_addr *);
 
 /* exported */
 const struct transport_def lsock_trans = {
@@ -68,7 +69,7 @@
 	lsock_stop,
 	lsock_close_port,
 	lsock_init_port,
-	lsock_send
+	lsock_send,
         lsock_recv 
 };
 static struct transport *my_trans;

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c	Sun Aug  3 08:32:54 2014	(r271779)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c	Sun Aug  3 09:46:21 2014	(r271780)
@@ -55,6 +55,7 @@
 static ssize_t udp_send(struct tport *, const u_char *, size_t,
     const struct sockaddr *, size_t);
 static ssize_t udp_recv(struct tport *, struct port_input *);
+static int recv_dgram(struct port_input *, struct in_addr *);
 
 /* exported */
 const struct transport_def udp_trans = {
@@ -64,7 +65,7 @@
 	udp_stop,
 	udp_close_port,
 	udp_init_port,
-	udp_send
+	udp_send,
         udp_recv
 };
 static struct transport *my_trans;

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c	Sun Aug  3 08:32:54 2014	(r271779)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c	Sun Aug  3 09:46:21 2014	(r271780)
@@ -55,6 +55,7 @@
 static ssize_t udpv6_send(struct tport *, const u_char *, size_t,
     const struct sockaddr *, size_t);
 static ssize_t udpv6_recv(struct tport *, struct port_input *); 
+static int recv_v6dgram(struct port_input *, struct in6_addr *);
 
 /* exported */
 const struct transport_def udpv6_trans = {
@@ -64,7 +65,7 @@
 	udpv6_stop,
 	udpv6_close_port,
 	udpv6_init_port,
-	udpv6_send
+	udpv6_send,
         udpv6_recv
 };
 static struct transport *my_trans;

Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c	Sun Aug  3 08:32:54 2014	(r271779)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trap.c	Sun Aug  3 09:46:21 2014	(r271780)
@@ -78,6 +78,8 @@
     OIDX_begemotTrapSinkTable;
 static const struct asn_oid oid_sysUpTime = OIDX_sysUpTime;
 static const struct asn_oid oid_snmpTrapOID = OIDX_snmpTrapOID;
+static void trapsink_create_sock(struct trapsink *);
+static void trapsink_create_sockv6(struct trapsink *);
 
 struct trapsink_dep {
 	struct snmp_dependency dep;
@@ -113,7 +115,7 @@
 	t->comm[0] = '\0';
 	t->version = TRAPSINK_V2;
 
-	switch (t->index.len)) {
+	switch (t->index.len) {
                 /* IPv4 - Check if there is a better way of determining address type */
                 case 6:
         	        trapsink_create_sock(t);
@@ -152,14 +154,12 @@
 	return (SNMP_ERR_NOERROR);
 }
 
-static void 
-trapsink_create_sock(struct trapsink *t)
+static void trapsink_create_sock(struct trapsink *t)
 {
 	struct sockaddr_in sa;
 	if ((t->socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
                 syslog(LOG_ERR, "socket(UDP): %m");
                 free(t);
-                return (SNMP_ERR_RES_UNAVAIL);
         }
         (void)shutdown(t->socket, SHUT_RD);
         memset(&sa, 0, sizeof(sa));
@@ -175,27 +175,24 @@
                     inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
                 (void)close(t->socket);
                 free(t);
-                return (SNMP_ERR_GENERR);
         }
 
 
 }
 
-static void 
-trapsink_create_sockv6(struct trapsink *t)
+static void trapsink_create_sockv6(struct trapsink *t)
 {
 	struct sockaddr_in6 sa;
 	if ((t->socket = socket(PF_INET6, SOCK_DGRAM, 0)) == -1) {
                 syslog(LOG_ERR, "socket(UDP): %m");
                 free(t);
-                return (SNMP_ERR_RES_UNAVAIL);
         }
         (void)shutdown(t->socket, SHUT_RD);
         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) | 
+        *(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];
@@ -207,7 +204,6 @@
                 syslog(LOG_ERR, "connect(%s,%u): %m", dst, ntohs(sa.sin6_port));
                 (void)close(t->socket);
                 free(t);
-                return (SNMP_ERR_GENERR);
         }
 
 
@@ -774,18 +770,19 @@
 target_activate_address(struct target_address *addrs)
 {
         /* XXX - IPv4/IPv6 - Check if there is a better way of determining address type */
+        int len;
         if(addrs->address == NULL && addrs->address6 != NULL)
-        int len = 18; 
+        len = 18; 
         else if (addrs->address != NULL && addrs->address6 == NULL)
-        int len = 6;
+        len = 6;
         else
         syslog(LOG_ERR, "Target address %s does not exist", addrs->name);
-         
+        struct sockaddr_in sa;
+        struct sockaddr_in6 sa6; 
+ 
 	switch (len) {
                 
 		case 6:
-                	struct sockaddr_in sa;
-
 			if ((addrs->socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
                        		 syslog(LOG_ERR, "socket(UDP): %m");
                        		 return (SNMP_ERR_RES_UNAVAIL);
@@ -811,28 +808,27 @@
 				
 
                 case 18:
-			struct sockaddr_in6 sa;
-
 			if ((addrs->socket = socket(PF_INET6, SOCK_DGRAM, 0)) == -1) {
         	                syslog(LOG_ERR, "socket(UDP): %m");
                 	        return (SNMP_ERR_RES_UNAVAIL);
                 	}
 
  	               (void)shutdown(addrs->socket, SHUT_RD);
-	                memset(&sa, 0, sizeof(sa));
-	                sa.sin6_len = sizeof(sa);
-	                sa.sin6_family = AF_INET6;
+	                memset(&sa6, 0, sizeof(sa6));
+	                sa6.sin6_len = sizeof(sa6);
+	                sa6.sin6_family = AF_INET6;
                         /* Host to network byte order not reqd - check */ 
-                        sa.sin6_addr.s6_addr = (addrs->address6[0] << 120) | (addrs->address6[1] << 112) | (addrs->address6[2] << 104) | (addrs->address6[3] << 96) | (addrs->address6[4] << 88) | 
+                        *(sa6.sin6_addr.s6_addr) = (addrs->address6[0] << 120) | (addrs->address6[1] << 112) | (addrs->address6[2] << 104) | 
+                        (addrs->address6[3] << 96) | (addrs->address6[4] << 88) | 
 			(addrs->address6[5] << 80) | (addrs->address6[6] << 72) | (addrs->address6[7] << 64) | (addrs->address6[8] << 56) |
                         (addrs->address6[9] << 48) | (addrs->address6[10] << 40) | (addrs->address6[11] << 32) | (addrs->address6[12] << 24) | 
 		        (addrs->address6[13] << 16) | (addrs->address6[14] << 8) | addrs->address6[15];
-	                sa.sin6_port = htons(addrs->address6[16]) << 8 |
+	                sa6.sin6_port = htons(addrs->address6[16]) << 8 |
 	                htons(addrs->address6[17]) << 0;
                         char dst[INET6_ADDRSTRLEN];
-                        inet_ntop(AF_INET6,&(sa.sin6_addr), dst, INET6_ADDRSTRLEN);
-	                if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin6_len) == -1) {
-	                        syslog(LOG_ERR, "connect(%s,%u): %m", dst, ntohs(sa.sin6_port));
+                        inet_ntop(AF_INET6,&(sa6.sin6_addr), dst, INET6_ADDRSTRLEN);
+	                if (connect(addrs->socket, (struct sockaddr *)&sa6, sa6.sin6_len) == -1) {
+	                        syslog(LOG_ERR, "connect(%s,%u): %m", dst, ntohs(sa6.sin6_port));
 	                        (void)close(addrs->socket);
 	                        return (SNMP_ERR_GENERR);
 	                }


More information about the svn-soc-all mailing list