Den 03-10-2013 11:37, Claus Klein skrev:
what is the reason for different byteorder of port configuration
with snmpUDPDomain and transportDomainUdpIpv6 in snmpTargetAddrTable?
This is a bug, not a feature
It is not clear to me, which port number is really used with this
configuration.
snmpd actually uses the correct port, it is only the address shown in
the snmpTargetAddrTable that is wrong.
You might try the attached patch, which I hope fixes it without adding
new bugs
/Niels
--
Niels Baggesen - @home - Ã…rhus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers --- R W Hamming
diff --git a/snmplib/transports/snmpTCPDomain.c b/snmplib/transports/snmpTCPDomain.c
index b8bdba4..7feb028 100644
--- a/snmplib/transports/snmpTCPDomain.c
+++ b/snmplib/transports/snmpTCPDomain.c
@@ -204,8 +204,8 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
return NULL;
}
memcpy(t->local, (u_char *) & (addr->sin_addr.s_addr), 4);
- t->local[4] = (htons(addr->sin_port) & 0xff00) >> 8;
- t->local[5] = (htons(addr->sin_port) & 0x00ff) >> 0;
+ t->local[4] = (ntohs(addr->sin_port) & 0xff00) >> 8;
+ t->local[5] = (ntohs(addr->sin_port) & 0x00ff) >> 0;
t->local_length = 6;
/*
@@ -257,8 +257,8 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
return NULL;
}
memcpy(t->remote, (u_char *) & (addr->sin_addr.s_addr), 4);
- t->remote[4] = (htons(addr->sin_port) & 0xff00) >> 8;
- t->remote[5] = (htons(addr->sin_port) & 0x00ff) >> 0;
+ t->remote[4] = (ntohs(addr->sin_port) & 0xff00) >> 8;
+ t->remote[5] = (ntohs(addr->sin_port) & 0x00ff) >> 0;
t->remote_length = 6;
/*
diff --git a/snmplib/transports/snmpTCPIPv6Domain.c b/snmplib/transports/snmpTCPIPv6Domain.c
index 3c96856..a8e5527 100644
--- a/snmplib/transports/snmpTCPIPv6Domain.c
+++ b/snmplib/transports/snmpTCPIPv6Domain.c
@@ -210,8 +210,8 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
return NULL;
}
memcpy(t->local, addr->sin6_addr.s6_addr, 16);
- t->local[16] = (addr->sin6_port & 0xff00) >> 8;
- t->local[17] = (addr->sin6_port & 0x00ff) >> 0;
+ t->local[16] = (ntohs(addr->sin6_port) & 0xff00) >> 8;
+ t->local[17] = (ntohs(addr->sin6_port) & 0x00ff) >> 0;
t->local_length = 18;
/*
@@ -263,8 +263,8 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
return NULL;
}
memcpy(t->remote, addr->sin6_addr.s6_addr, 16);
- t->remote[16] = (addr->sin6_port & 0xff00) >> 8;
- t->remote[17] = (addr->sin6_port & 0x00ff) >> 0;
+ t->remote[16] = (ntohs(addr->sin6_port) & 0xff00) >> 8;
+ t->remote[17] = (ntohs(addr->sin6_port) & 0x00ff) >> 0;
t->remote_length = 18;
/*
diff --git a/snmplib/transports/snmpUDPIPv4BaseDomain.c b/snmplib/transports/snmpUDPIPv4BaseDomain.c
index 9c464d7..8c0fb05 100644
--- a/snmplib/transports/snmpUDPIPv4BaseDomain.c
+++ b/snmplib/transports/snmpUDPIPv4BaseDomain.c
@@ -111,8 +111,8 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
return NULL;
}
memcpy(t->local, (u_char *) & (addr->sin_addr.s_addr), 4);
- t->local[4] = (htons(addr->sin_port) & 0xff00) >> 8;
- t->local[5] = (htons(addr->sin_port) & 0x00ff) >> 0;
+ t->local[4] = (ntohs(addr->sin_port) & 0xff00) >> 8;
+ t->local[5] = (ntohs(addr->sin_port) & 0x00ff) >> 0;
t->local_length = 6;
#ifndef WIN32
@@ -210,8 +210,8 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
return NULL;
}
memcpy(t->remote, (u_char *) & (addr->sin_addr.s_addr), 4);
- t->remote[4] = (htons(addr->sin_port) & 0xff00) >> 8;
- t->remote[5] = (htons(addr->sin_port) & 0x00ff) >> 0;
+ t->remote[4] = (ntohs(addr->sin_port) & 0xff00) >> 8;
+ t->remote[5] = (ntohs(addr->sin_port) & 0x00ff) >> 0;
t->remote_length = 6;
memcpy(t->data, &addr_pair, sizeof(netsnmp_indexed_addr_pair));
t->data_length = sizeof(netsnmp_indexed_addr_pair);
diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c
index b3eaae4..faa4a7b 100644
--- a/snmplib/transports/snmpUDPIPv6Domain.c
+++ b/snmplib/transports/snmpUDPIPv6Domain.c
@@ -257,8 +257,8 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
return NULL;
}
memcpy(t->local, addr->sin6_addr.s6_addr, 16);
- t->local[16] = (addr->sin6_port & 0xff00) >> 8;
- t->local[17] = (addr->sin6_port & 0x00ff) >> 0;
+ t->local[16] = (ntohs(addr->sin6_port) & 0xff00) >> 8;
+ t->local[17] = (ntohs(addr->sin6_port) & 0x00ff) >> 0;
t->local_length = 18;
t->data = NULL;
t->data_length = 0;
@@ -286,8 +286,8 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
return NULL;
}
memcpy(t->remote, addr->sin6_addr.s6_addr, 16);
- t->remote[16] = (addr->sin6_port & 0xff00) >> 8;
- t->remote[17] = (addr->sin6_port & 0x00ff) >> 0;
+ t->remote[16] = (ntohs(addr->sin6_port) & 0xff00) >> 8;
+ t->remote[17] = (ntohs(addr->sin6_port) & 0x00ff) >> 0;
t->remote_length = 18;
}
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders