pysnmp-sky/pysnmp/carrier/asyncio/dgram/udp6.py

41 lines
1.2 KiB
Python
Raw Normal View History

2015-11-20 21:57:28 +01:00
#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com>
2015-11-20 21:57:28 +01:00
# License: http://pysnmp.sf.net/license.html
#
import socket
from pysnmp.carrier.base import AbstractTransportAddress
from pysnmp.carrier.asyncio.dgram.base import DgramAsyncioProtocol
2016-04-02 23:43:14 +02:00
try:
import asyncio
except ImportError:
import trollius as asyncio
loop = asyncio.get_event_loop()
domainName = snmpUDP6Domain = (1, 3, 6, 1, 2, 1, 100, 1, 2)
2016-04-02 23:43:14 +02:00
class Udp6TransportAddress(tuple, AbstractTransportAddress):
pass
2016-04-02 23:43:14 +02:00
class Udp6AsyncioTransport(DgramAsyncioProtocol):
sockFamily = socket.has_ipv6 and socket.AF_INET6 or None
addressType = Udp6TransportAddress
def normalizeAddress(self, transportAddress):
if '%' in transportAddress[0]: # strip zone ID
return self.addressType((transportAddress[0].split('%')[0],
transportAddress[1],
0, # flowinfo
2016-04-02 23:43:14 +02:00
0)) # scopeid
else:
return self.addressType((transportAddress[0],
transportAddress[1], 0, 0))
2016-04-02 23:43:14 +02:00
Udp6Transport = Udp6AsyncioTransport