Hi all,


I am using net-snmp 5.7.2 in my project .I want to use trap source interface 
feature in my project.

I enabled clientaddr by reading some posts in our community. It’s working fine 
for only Ip address interface.

It’s not working for Ipv6 address interfaces. I gone through the net-snmp code. 
I observed some code is missing for Ipv6 address in snmpUDPIPv6Domain.c

I added the below code to snmpUDPIPv6Domain.c . But,I am getting bind is 
failing with an error (errno 99).Am I missed anything .

Please help me to resolve this issue.

-------------------------------------------------------------------------------------------------------------

--- a/snmplib/transports/snmpUDPIPv6Domain.c 2019-09-03 15:47:53.000000000 -0700

+++ b/snmplib/transports/snmpUDPIPv6Domain.c 2019-09-18 19:11:14.817426615 -0700

@@ -196,6 +196,8 @@

int rc = 0;

char *str = NULL;

int socket_initialized = 0;

+ char *client_socket =NULL;

+ netsnmp_indexed_addr_pair addr_pair;



#ifdef NETSNMP_NO_LISTEN_SUPPORT

if (local)

@@ -206,6 +208,9 @@

return NULL;

}



+ memset(&addr_pair, 0, sizeof(netsnmp_indexed_addr_pair));

+ memcpy(&(addr_pair.remote_addr), addr, sizeof(struct sockaddr_in));

+

t = SNMP_MALLOC_TYPEDEF(netsnmp_transport);

if (t == NULL) {

return NULL;

@@ -285,6 +290,26 @@

return NULL;

#endif /* NETSNMP_NO_LISTEN_SUPPORT */

} else {

+ /* This is a client sessuon.If we've been given a

+ *client address to send frm,then bind to that .

+ Otherwise the send will use "something sesible"

+ */

+ client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,

+ NETSNMP_DS_LIB_CLIENT_ADDR);

+ if (client_socket) {

+ struct sockaddr_in6 client_addr;

+ netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);

+ client_addr.sin6_port=0;

+ rc = bind(t->sock, (struct sockaddr *)&client_addr,

+ sizeof(struct sockaddr_in6));

+ if (rc!=0) {

+ DEBUGMSGTL(("netsnmp_udp6","failed to bind for clientaddr:%d %s\n",

+ errno,strerror(errno)));

+ netsnmp_socketbase_close(t);

+ netsnmp_transport_free(t);

+ }

+ }

/*

* This is a client session. Save the address in the

* transport-specific data pointer for later use by netsnmp_udp6_send.

-------------------------------------------------------------------------------------------------------







Thanks,

Chandra.




Get Outlook for Android<https://aka.ms/ghei36>
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to