summaryrefslogtreecommitdiff
path: root/pysnmp/carrier
diff options
context:
space:
mode:
Diffstat (limited to 'pysnmp/carrier')
-rw-r--r--pysnmp/carrier/asyncore/dgram/base.py13
-rw-r--r--pysnmp/carrier/asyncore/dgram/udp6.py12
2 files changed, 15 insertions, 10 deletions
diff --git a/pysnmp/carrier/asyncore/dgram/base.py b/pysnmp/carrier/asyncore/dgram/base.py
index 7b2cce3f..c6ac1fe2 100644
--- a/pysnmp/carrier/asyncore/dgram/base.py
+++ b/pysnmp/carrier/asyncore/dgram/base.py
@@ -44,6 +44,8 @@ class DgramSocketTransport(AbstractSocketTransport):
)
debug.logger & debug.flagIO and debug.logger('sendMessage: outgoingMessage queued (%d octets) %s' % (len(outgoingMessage), debug.hexdump(outgoingMessage)))
+ def normalizeAddress(self, addr): return addr
+
def __getsockname(self):
# one evil OS does not seem to support getsockname() for DGRAM sockets
try:
@@ -72,16 +74,7 @@ class DgramSocketTransport(AbstractSocketTransport):
def handle_read(self):
try:
incomingMessage, transportAddress = self.socket.recvfrom(65535)
- if '%' in transportAddress[0]: # strip zone ID
- transportAddress = (transportAddress[0].split('%')[0],
- transportAddress[1],
- 0, # flowinfo
- 0) # scopeid
- else:
- transportAddress = (transportAddress[0],
- transportAddress[1],
- 0, # flowinfo
- 0) # scopeid
+ transportAddress = self.normalizeAddress(transportAddress)
debug.logger & debug.flagIO and debug.logger('handle_read: transportAddress %r -> %r incomingMessage (%d octets) %s' % (transportAddress, self.__getsockname(), len(incomingMessage), debug.hexdump(incomingMessage)))
if not incomingMessage:
self.handle_close()
diff --git a/pysnmp/carrier/asyncore/dgram/udp6.py b/pysnmp/carrier/asyncore/dgram/udp6.py
index 649a4afb..17d4431b 100644
--- a/pysnmp/carrier/asyncore/dgram/udp6.py
+++ b/pysnmp/carrier/asyncore/dgram/udp6.py
@@ -10,4 +10,16 @@ domainName = snmpUDP6Domain = (1, 3, 6, 1, 2, 1, 100, 1, 2)
class Udp6SocketTransport(DgramSocketTransport):
sockFamily = AF_INET6
+ def normalizeAddress(self, addr):
+ if '%' in transportAddress[0]: # strip zone ID
+ return (transportAddress[0].split('%')[0],
+ transportAddress[1],
+ 0, # flowinfo
+ 0) # scopeid
+ else:
+ return (transportAddress[0],
+ transportAddress[1],
+ 0, # flowinfo
+ 0) # scopeid
+
Udp6Transport = Udp6SocketTransport