python3: Use b'str' for binary literals
Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
79ad56e682
commit
536a42d8c1
@ -19,8 +19,8 @@ from ryu.lib import addrconv
|
||||
# string representation
|
||||
HADDR_PATTERN = r'([0-9a-f]{2}:){5}[0-9a-f]{2}'
|
||||
|
||||
DONTCARE = '\x00' * 6
|
||||
BROADCAST = '\xff' * 6
|
||||
DONTCARE = b'\x00' * 6
|
||||
BROADCAST = b'\xff' * 6
|
||||
DONTCARE_STR = '00:00:00:00:00:00'
|
||||
BROADCAST_STR = 'ff:ff:ff:ff:ff:ff'
|
||||
MULTICAST = 'fe:ff:ff:ff:ff:ff'
|
||||
|
@ -606,7 +606,7 @@ def get_rf(afi, safi):
|
||||
|
||||
def pad(bin, len_):
|
||||
assert len(bin) <= len_
|
||||
return bin + (len_ - len(bin)) * '\0'
|
||||
return bin + b'\0' * (len_ - len(bin))
|
||||
|
||||
|
||||
class _RouteDistinguisher(StringifyMixin, _TypeDisp, _Value):
|
||||
@ -2060,7 +2060,7 @@ class BGPPathAttributeMpReachNLRI(_PathAttribute):
|
||||
self.next_hop_len = len(self._next_hop_bin)
|
||||
|
||||
if RouteFamily(self.afi, self.safi) in (RF_IPv4_VPN, RF_IPv6_VPN):
|
||||
empty_label_stack = '\x00' * self._rd_length
|
||||
empty_label_stack = b'\x00' * self._rd_length
|
||||
next_hop_len = len(self._next_hop_bin) + len(empty_label_stack)
|
||||
next_hop_bin = empty_label_stack
|
||||
next_hop_bin += self._next_hop_bin
|
||||
|
@ -451,11 +451,11 @@ class routing_type3(header):
|
||||
form_e = "%ds" % adrs_len_e
|
||||
while data < (header_len - (adrs_len_e + pad)):
|
||||
(adr, ) = struct.unpack_from(form_i, buf[data:])
|
||||
adr = ('\x00' * cmpi) + adr
|
||||
adr = (b'\x00' * cmpi) + adr
|
||||
adrs.append(addrconv.ipv6.bin_to_text(adr))
|
||||
data += adrs_len_i
|
||||
(adr, ) = struct.unpack_from(form_e, buf[data:])
|
||||
adr = ('\x00' * cmpe) + adr
|
||||
adr = (b'\x00' * cmpe) + adr
|
||||
adrs.append(addrconv.ipv6.bin_to_text(adr))
|
||||
return cls(nxt, size, type_, seg, cmpi, cmpe, adrs)
|
||||
|
||||
|
@ -26,7 +26,7 @@ def carry_around_add(a, b):
|
||||
|
||||
def checksum(data):
|
||||
if len(data) % 2:
|
||||
data += '\x00'
|
||||
data += b'\x00'
|
||||
|
||||
data = str(data) # input can be bytearray.
|
||||
s = sum(array.array('H', data))
|
||||
|
@ -104,7 +104,7 @@ class PcapFileHdr(object):
|
||||
"""
|
||||
_FILE_HDR_FMT = None
|
||||
|
||||
def __init__(self, magic='\xd4\xc3\xb2\xa1', version_major=2,
|
||||
def __init__(self, magic=b'\xd4\xc3\xb2\xa1', version_major=2,
|
||||
version_minor=4, thiszone=0, sigfigs=0, snaplen=0,
|
||||
linktype=0):
|
||||
self.magic = magic
|
||||
@ -117,11 +117,11 @@ class PcapFileHdr(object):
|
||||
|
||||
@classmethod
|
||||
def parser(cls, buf):
|
||||
if buf[:4] == '\xa1\xb2\xc3\xd4':
|
||||
if buf[:4] == b'\xa1\xb2\xc3\xd4':
|
||||
# Big Endian
|
||||
cls._FILE_HDR_FMT = '>IHHIIII'
|
||||
byteorder = '>'
|
||||
elif buf[:4] == '\xd4\xc3\xb2\xa1':
|
||||
elif buf[:4] == b'\xd4\xc3\xb2\xa1':
|
||||
# Little Endian
|
||||
cls._FILE_HDR_FMT = '<IHHIIII'
|
||||
byteorder = '<'
|
||||
|
@ -79,11 +79,11 @@ class IntDescrMlt(TypeDescr):
|
||||
|
||||
def from_user(self, li):
|
||||
assert len(li) == self.num
|
||||
bin = ''
|
||||
bin = b''
|
||||
for i in li:
|
||||
b = ''
|
||||
b = b''
|
||||
for x in range(self.length):
|
||||
b = chr(i & 255) + b
|
||||
b = six.int2byte(i & 255) + b
|
||||
i //= 256
|
||||
bin += b
|
||||
return bin
|
||||
|
@ -933,7 +933,7 @@ class NXActionLearn(NXActionHeader):
|
||||
self.table_id = table_id
|
||||
self.fin_idle_timeout = fin_idle_timeout
|
||||
self.fin_hard_timeout = fin_hard_timeout
|
||||
self.spec = spec + bytearray('\x00' * pad_len)
|
||||
self.spec = spec + bytearray(b'\x00' * pad_len)
|
||||
|
||||
def serialize(self, buf, offset):
|
||||
msg_pack_into(ofproto.NX_ACTION_LEARN_PACK_STR, buf, offset,
|
||||
|
@ -171,7 +171,7 @@ Hello, this is Ryu BGP speaker (version %s).
|
||||
LOG.error("non CSI sequence. do nothing")
|
||||
|
||||
def _send_csi_seq(self, cmd):
|
||||
self.chan.send('\x1b[' + cmd)
|
||||
self.chan.send(b'\x1b[' + cmd)
|
||||
|
||||
def _movcursor(self, curpos):
|
||||
if self.prompted and curpos < len(self.PROMPT):
|
||||
|
@ -90,8 +90,8 @@ def nofitication_factory(code, subcode):
|
||||
class BgpProtocol(Protocol, Activity):
|
||||
"""Protocol that handles BGP messages.
|
||||
"""
|
||||
MESSAGE_MARKER = ('\xff\xff\xff\xff\xff\xff\xff\xff'
|
||||
'\xff\xff\xff\xff\xff\xff\xff\xff')
|
||||
MESSAGE_MARKER = (b'\xff\xff\xff\xff\xff\xff\xff\xff'
|
||||
b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
||||
|
||||
def __init__(self, socket, signal_bus, is_reactive_conn=False):
|
||||
# Validate input.
|
||||
|
@ -135,7 +135,7 @@ class VRRPInterfaceMonitorNetworkDevice(monitor.VRRPInterfaceMonitor):
|
||||
# };
|
||||
group_req = struct.pack('I', self.ifindex)
|
||||
# padding to gr_group. This is environment dependent
|
||||
group_req += '\x00' * (struct.calcsize('P') - struct.calcsize('I'))
|
||||
group_req += b'\x00' * (struct.calcsize('P') - struct.calcsize('I'))
|
||||
if self.config.is_ipv6:
|
||||
# struct sockaddr_in6 {
|
||||
# sa_family_t sin6_family; /* AF_INET6 */
|
||||
@ -171,7 +171,7 @@ class VRRPInterfaceMonitorNetworkDevice(monitor.VRRPInterfaceMonitor):
|
||||
sockaddr += struct.pack('!H', 0)
|
||||
sockaddr += addrconv.ipv4.text_to_bin(vrrp.VRRP_IPV4_DST_ADDRESS)
|
||||
|
||||
sockaddr += '\x00' * (SS_MAXSIZE - len(sockaddr))
|
||||
sockaddr += b'\x00' * (SS_MAXSIZE - len(sockaddr))
|
||||
group_req += sockaddr
|
||||
|
||||
self.ip_socket.setsockopt(family, join_leave, group_req)
|
||||
|
@ -105,7 +105,7 @@ class RunTest(tester.TestFlowBase):
|
||||
return val == 0
|
||||
elif type_ == 'mac':
|
||||
for v in val:
|
||||
if v != '\x00':
|
||||
if v != b'\x00':
|
||||
return False
|
||||
return True
|
||||
elif type_ == 'ipv6':
|
||||
|
@ -467,10 +467,10 @@ class RunTest(tester.TestFlowBase):
|
||||
a2 = dp.ofproto_parser.OFPActionOutput(2, 1500)
|
||||
|
||||
# table_id, cookie, priority, dl_dst, action)
|
||||
tables = {0: [0xffff, 10, '\xee' * 6, a1],
|
||||
1: [0xff00, 10, '\xee' * 6, a2],
|
||||
2: [0xf000, 100, '\xee' * 6, a1],
|
||||
3: [0x0000, 10, '\xff' * 6, a1]}
|
||||
tables = {0: [0xffff, 10, b'\xee' * 6, a1],
|
||||
1: [0xff00, 10, b'\xee' * 6, a2],
|
||||
2: [0xf000, 100, b'\xee' * 6, a1],
|
||||
3: [0x0000, 10, b'\xff' * 6, a1]}
|
||||
|
||||
self._verify = tables
|
||||
for table_id, val in tables.items():
|
||||
@ -546,7 +546,7 @@ class RunTest(tester.TestFlowBase):
|
||||
self._verify[3][3] = action
|
||||
|
||||
match = dp.ofproto_parser.OFPMatch()
|
||||
match.set_dl_dst('\xff' * 6)
|
||||
match.set_dl_dst(b'\xff' * 6)
|
||||
table_id = 3
|
||||
self.mod_flow(dp, command=dp.ofproto.OFPFC_MODIFY,
|
||||
actions=[action], table_id=table_id, match=match)
|
||||
@ -565,7 +565,7 @@ class RunTest(tester.TestFlowBase):
|
||||
self._verify[2][3] = action
|
||||
|
||||
match = dp.ofproto_parser.OFPMatch()
|
||||
match.set_dl_dst('\xee' * 6)
|
||||
match.set_dl_dst(b'\xee' * 6)
|
||||
priority = 100
|
||||
table_id = 2
|
||||
self.mod_flow(dp, command=dp.ofproto.OFPFC_MODIFY_STRICT,
|
||||
@ -653,7 +653,7 @@ class RunTest(tester.TestFlowBase):
|
||||
del self._verify[3]
|
||||
|
||||
match = dp.ofproto_parser.OFPMatch()
|
||||
match.set_dl_dst('\xff' * 6)
|
||||
match.set_dl_dst(b'\xff' * 6)
|
||||
self.mod_flow(dp, command=dp.ofproto.OFPFC_DELETE,
|
||||
table_id=dp.ofproto.OFPTT_ALL, match=match)
|
||||
|
||||
@ -686,7 +686,7 @@ class RunTest(tester.TestFlowBase):
|
||||
del self._verify[2]
|
||||
|
||||
match = dp.ofproto_parser.OFPMatch()
|
||||
match.set_dl_dst('\xee' * 6)
|
||||
match.set_dl_dst(b'\xee' * 6)
|
||||
priority = 100
|
||||
self.mod_flow(dp, command=dp.ofproto.OFPFC_DELETE_STRICT,
|
||||
table_id=dp.ofproto.OFPTT_ALL,
|
||||
|
@ -107,7 +107,7 @@ class Test_hub(unittest.TestCase):
|
||||
|
||||
def _child(s1):
|
||||
hub.sleep(0.5)
|
||||
s1.send("hoge")
|
||||
s1.send(b"hoge")
|
||||
|
||||
s1, s2 = socket.socketpair()
|
||||
with hub.Timeout(1):
|
||||
|
@ -38,7 +38,7 @@ class Test_mac(unittest.TestCase):
|
||||
pass
|
||||
|
||||
def test_mac_is_multicast(self):
|
||||
addr = '\x01\x23\x45\x67\x89\x0a'
|
||||
addr = b'\x01\x23\x45\x67\x89\x0a'
|
||||
val = True
|
||||
|
||||
res = mac.is_multicast(addr)
|
||||
@ -47,7 +47,7 @@ class Test_mac(unittest.TestCase):
|
||||
|
||||
def test_mac_haddr_to_str(self):
|
||||
addr = 'aa:aa:aa:aa:aa:aa'
|
||||
val = '\xaa\xaa\xaa\xaa\xaa\xaa'
|
||||
val = b'\xaa\xaa\xaa\xaa\xaa\xaa'
|
||||
|
||||
res = mac.haddr_to_str(val)
|
||||
|
||||
@ -64,7 +64,7 @@ class Test_mac(unittest.TestCase):
|
||||
|
||||
@raises(AssertionError)
|
||||
def test_mac_haddr_to_str_assert(self):
|
||||
val = '\xaa\xaa\xaa\xaa\xaa'
|
||||
val = b'\xaa\xaa\xaa\xaa\xaa'
|
||||
|
||||
res = mac.haddr_to_str(val)
|
||||
|
||||
@ -86,9 +86,9 @@ class Test_mac(unittest.TestCase):
|
||||
res = mac.haddr_to_bin(addr)
|
||||
|
||||
def test_mac_haddr_bitand(self):
|
||||
addr = '\xaa\xaa\xaa\xaa\xaa\xaa'
|
||||
mask = '\xff\xff\xff\x00\x00\x00'
|
||||
val = '\xaa\xaa\xaa\x00\x00\x00'
|
||||
addr = b'\xaa\xaa\xaa\xaa\xaa\xaa'
|
||||
mask = b'\xff\xff\xff\x00\x00\x00'
|
||||
val = b'\xaa\xaa\xaa\x00\x00\x00'
|
||||
|
||||
res = mac.haddr_bitand(addr, mask)
|
||||
|
||||
|
@ -41,8 +41,8 @@ class Test_stringify(unittest.TestCase):
|
||||
|
||||
def test_jsondict(self):
|
||||
j = {'C1': {'a': 'QUFB', 'c': 'Q0ND'}}
|
||||
eq_(j['C1']['a'], base64.b64encode('AAA'))
|
||||
eq_(j['C1']['c'], base64.b64encode('CCC'))
|
||||
eq_(j['C1']['a'], base64.b64encode(b'AAA'))
|
||||
eq_(j['C1']['c'], base64.b64encode(b'CCC'))
|
||||
c = C1(a='AAA', c='CCC')
|
||||
c2 = C1.from_jsondict(j['C1'])
|
||||
eq_(c.__class__, c2.__class__)
|
||||
|
@ -169,7 +169,7 @@ class TestMsgBase(unittest.TestCase):
|
||||
version = ofproto_v1_0.OFP_VERSION
|
||||
msg_len = ofproto_v1_0.OFP_HEADER_SIZE
|
||||
xid = 2183948390
|
||||
data = '\x00\x01\x02\x03'
|
||||
data = b'\x00\x01\x02\x03'
|
||||
|
||||
fmt = ofproto_v1_0.OFP_HEADER_PACK_STR
|
||||
buf = struct.pack(fmt, version, msg_type, msg_len, xid) \
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1826,7 +1826,7 @@ class TestOFPSwitchFeatures(unittest.TestCase):
|
||||
port_no = i
|
||||
|
||||
fmt = ofproto.OFP_PORT_PACK_STR
|
||||
buf += pack(fmt, port_no, '\x00' * 6, '\x00' * 16, 0, 0, 0,
|
||||
buf += pack(fmt, port_no, b'\x00' * 6, b'\x00' * 16, 0, 0, 0,
|
||||
0, 0, 0, 0, 0)
|
||||
|
||||
res = OFPSwitchFeatures.parser(object, version, msg_type,
|
||||
@ -2091,7 +2091,7 @@ class TestOFPPacketIn(unittest.TestCase):
|
||||
buf += str(buf_match)
|
||||
|
||||
# data
|
||||
buf += '\x00' * 2
|
||||
buf += b'\x00' * 2
|
||||
buf += data
|
||||
|
||||
res = OFPPacketIn.parser(object, version, msg_type, msg_len,
|
||||
@ -4984,7 +4984,7 @@ class TestOFPTableStats(unittest.TestCase):
|
||||
res = OFPTableStats.parser(buf, 0)
|
||||
|
||||
eq_(table_id, res.table_id)
|
||||
eq_(name, res.name.replace('\x00', ''))
|
||||
eq_(name, res.name.replace(b'\x00', ''))
|
||||
eq_(match, res.match)
|
||||
eq_(wildcards, res.wildcards)
|
||||
eq_(write_actions, res.write_actions)
|
||||
|
@ -34,55 +34,55 @@ LOG = logging.getLogger(__name__)
|
||||
class TestBFD(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# BFD packet without authentication.
|
||||
self.data = '\xb0\xa8\x6e\x18\xb8\x08\x64\x87' \
|
||||
+ '\x88\xe9\xcb\xc8\x08\x00\x45\xc0' \
|
||||
+ '\x00\x34\x68\x49\x00\x00\xff\x11' \
|
||||
+ '\xf4\x73\xac\x1c\x03\x01\xac\x1c' \
|
||||
+ '\x03\x02\xc0\x00\x0e\xc8\x00\x20' \
|
||||
+ '\xd9\x02\x21\xc0\x03\x18\x00\x00' \
|
||||
+ '\x00\x06\x00\x00\x00\x07\x00\x00' \
|
||||
+ '\xea\x60\x00\x00\xea\x60\x00\x00' \
|
||||
+ '\x00\x00'
|
||||
self.data = b'\xb0\xa8\x6e\x18\xb8\x08\x64\x87' \
|
||||
+ b'\x88\xe9\xcb\xc8\x08\x00\x45\xc0' \
|
||||
+ b'\x00\x34\x68\x49\x00\x00\xff\x11' \
|
||||
+ b'\xf4\x73\xac\x1c\x03\x01\xac\x1c' \
|
||||
+ b'\x03\x02\xc0\x00\x0e\xc8\x00\x20' \
|
||||
+ b'\xd9\x02\x21\xc0\x03\x18\x00\x00' \
|
||||
+ b'\x00\x06\x00\x00\x00\x07\x00\x00' \
|
||||
+ b'\xea\x60\x00\x00\xea\x60\x00\x00' \
|
||||
+ b'\x00\x00'
|
||||
|
||||
# BFD packet using simple password authentication.
|
||||
self.data_auth_simple = '\x08\x00\x27\xd1\x95\x7c\x08\x00' \
|
||||
+ '\x27\xed\x54\x41\x08\x00\x45\xc0' \
|
||||
+ '\x00\x3d\x0c\x90\x00\x00\xff\x11' \
|
||||
+ '\xbb\x0b\xc0\xa8\x39\x02\xc0\xa8' \
|
||||
+ '\x39\x01\xc0\x00\x0e\xc8\x00\x29' \
|
||||
+ '\x46\x35\x20\x44\x03\x21\x00\x00' \
|
||||
+ '\x00\x01\x00\x00\x00\x00\x00\x0f' \
|
||||
+ '\x42\x40\x00\x0f\x42\x40\x00\x00' \
|
||||
+ '\x00\x00\x01\x09\x02\x73\x65\x63' \
|
||||
+ '\x72\x65\x74'
|
||||
self.data_auth_simple = b'\x08\x00\x27\xd1\x95\x7c\x08\x00' \
|
||||
+ b'\x27\xed\x54\x41\x08\x00\x45\xc0' \
|
||||
+ b'\x00\x3d\x0c\x90\x00\x00\xff\x11' \
|
||||
+ b'\xbb\x0b\xc0\xa8\x39\x02\xc0\xa8' \
|
||||
+ b'\x39\x01\xc0\x00\x0e\xc8\x00\x29' \
|
||||
+ b'\x46\x35\x20\x44\x03\x21\x00\x00' \
|
||||
+ b'\x00\x01\x00\x00\x00\x00\x00\x0f' \
|
||||
+ b'\x42\x40\x00\x0f\x42\x40\x00\x00' \
|
||||
+ b'\x00\x00\x01\x09\x02\x73\x65\x63' \
|
||||
+ b'\x72\x65\x74'
|
||||
|
||||
# BFD packet using md5 authentication.
|
||||
self.data_auth_md5 = '\x08\x00\x27\xd1\x95\x7c\x08\x00' \
|
||||
+ '\x27\xed\x54\x41\x08\x00\x45\xc0' \
|
||||
+ '\x00\x4c\x0c\x44\x00\x00\xff\x11' \
|
||||
+ '\xbb\x48\xc0\xa8\x39\x02\xc0\xa8' \
|
||||
+ '\x39\x01\xc0\x00\x0e\xc8\x00\x38' \
|
||||
+ '\x51\xbc\x20\x44\x03\x30\x00\x00' \
|
||||
+ '\x00\x01\x00\x00\x00\x00\x00\x0f' \
|
||||
+ '\x42\x40\x00\x0f\x42\x40\x00\x00' \
|
||||
+ '\x00\x00\x02\x18\x02\x00\x00\x00' \
|
||||
+ '\x41\xdb\x66\xa8\xf9\x25\x5a\x8b' \
|
||||
+ '\xcb\x7e\x4b\xec\x25\xa6\x2c\x23' \
|
||||
+ '\xda\x0f'
|
||||
self.data_auth_md5 = b'\x08\x00\x27\xd1\x95\x7c\x08\x00' \
|
||||
+ b'\x27\xed\x54\x41\x08\x00\x45\xc0' \
|
||||
+ b'\x00\x4c\x0c\x44\x00\x00\xff\x11' \
|
||||
+ b'\xbb\x48\xc0\xa8\x39\x02\xc0\xa8' \
|
||||
+ b'\x39\x01\xc0\x00\x0e\xc8\x00\x38' \
|
||||
+ b'\x51\xbc\x20\x44\x03\x30\x00\x00' \
|
||||
+ b'\x00\x01\x00\x00\x00\x00\x00\x0f' \
|
||||
+ b'\x42\x40\x00\x0f\x42\x40\x00\x00' \
|
||||
+ b'\x00\x00\x02\x18\x02\x00\x00\x00' \
|
||||
+ b'\x41\xdb\x66\xa8\xf9\x25\x5a\x8b' \
|
||||
+ b'\xcb\x7e\x4b\xec\x25\xa6\x2c\x23' \
|
||||
+ b'\xda\x0f'
|
||||
|
||||
# BFD packet using SHA1 authentication.
|
||||
self.data_auth_sha1 = '\x08\x00\x27\xd1\x95\x7c\x08\x00' \
|
||||
+ '\x27\xed\x54\x41\x08\x00\x45\xc0' \
|
||||
+ '\x00\x50\x0b\x90\x00\x00\xff\x11' \
|
||||
+ '\xbb\xf8\xc0\xa8\x39\x02\xc0\xa8' \
|
||||
+ '\x39\x01\xc0\x00\x0e\xc8\x00\x3c' \
|
||||
+ '\xb9\x92\x20\x44\x03\x34\x00\x00' \
|
||||
+ '\x00\x01\x00\x00\x00\x00\x00\x0f' \
|
||||
+ '\x42\x40\x00\x0f\x42\x40\x00\x00' \
|
||||
+ '\x00\x00\x04\x1c\x02\x00\x00\x00' \
|
||||
+ '\x41\xb1\x46\x20\x10\x81\x03\xd7' \
|
||||
+ '\xf4\xde\x87\x61\x4c\x24\x61\x1f' \
|
||||
+ '\x3c\xc1\x6a\x00\x69\x23'
|
||||
self.data_auth_sha1 = b'\x08\x00\x27\xd1\x95\x7c\x08\x00' \
|
||||
+ b'\x27\xed\x54\x41\x08\x00\x45\xc0' \
|
||||
+ b'\x00\x50\x0b\x90\x00\x00\xff\x11' \
|
||||
+ b'\xbb\xf8\xc0\xa8\x39\x02\xc0\xa8' \
|
||||
+ b'\x39\x01\xc0\x00\x0e\xc8\x00\x3c' \
|
||||
+ b'\xb9\x92\x20\x44\x03\x34\x00\x00' \
|
||||
+ b'\x00\x01\x00\x00\x00\x00\x00\x0f' \
|
||||
+ b'\x42\x40\x00\x0f\x42\x40\x00\x00' \
|
||||
+ b'\x00\x00\x04\x1c\x02\x00\x00\x00' \
|
||||
+ b'\x41\xb1\x46\x20\x10\x81\x03\xd7' \
|
||||
+ b'\xf4\xde\x87\x61\x4c\x24\x61\x1f' \
|
||||
+ b'\x3c\xc1\x6a\x00\x69\x23'
|
||||
|
||||
# BFD Key chain {auth_key_id: auth_key/password}
|
||||
self.auth_keys = {2: b"secret"}
|
||||
|
@ -180,7 +180,7 @@ class Test_bgp(unittest.TestCase):
|
||||
bgp.BGPNotification(error_code=3, error_subcode=4, data="bar"),
|
||||
bgp.BGPNotification(error_code=5, error_subcode=6, data="baz"),
|
||||
]
|
||||
binmsgs = ''.join([bytes(msg.serialize()) for msg in msgs])
|
||||
binmsgs = b''.join([bytes(msg.serialize()) for msg in msgs])
|
||||
sp = bgp.StreamParser()
|
||||
results = []
|
||||
for b in binmsgs:
|
||||
|
@ -123,9 +123,9 @@ class Test_dhcp_offer(unittest.TestCase):
|
||||
eq_(self.giaddr, res.giaddr)
|
||||
eq_(self.chaddr, res.chaddr)
|
||||
# sname is 64 byte length. rest of data is filled by '\x00'.
|
||||
eq_(self.sname.ljust(64, '\x00'), res.sname)
|
||||
eq_(self.sname.ljust(64, b'\x00'), res.sname)
|
||||
# boof_file is 128 byte length. rest of data is filled by '\x00'.
|
||||
eq_(self.boot_file.ljust(128, '\x00'), res.boot_file)
|
||||
eq_(self.boot_file.ljust(128, b'\x00'), res.boot_file)
|
||||
eq_(str(self.options), str(res.options))
|
||||
|
||||
def test_parser_corrupted(self):
|
||||
@ -152,9 +152,9 @@ class Test_dhcp_offer(unittest.TestCase):
|
||||
eq_(self.giaddr, addrconv.ipv4.bin_to_text(res[10]))
|
||||
eq_(self.chaddr, addrconv.mac.bin_to_text(res[11][:6]))
|
||||
# sname is 64 byte length. rest of data is filled by '\x00'.
|
||||
eq_(self.sname.ljust(64, '\x00'), res[12])
|
||||
eq_(self.sname.ljust(64, b'\x00'), res[12])
|
||||
# boof_file is 128 byte length. rest of data is filled by '\x00'.
|
||||
eq_(self.boot_file.ljust(128, '\x00'), res[13])
|
||||
eq_(self.boot_file.ljust(128, b'\x00'), res[13])
|
||||
options = dhcp.options.parser(
|
||||
buf[struct.calcsize(dhcp.dhcp._DHCP_PACK_STR):])
|
||||
eq_(str(self.options), str(options))
|
||||
@ -225,14 +225,14 @@ class Test_dhcp_offer_with_hlen_zero(unittest.TestCase):
|
||||
boot_file = ''
|
||||
|
||||
option_list = [
|
||||
dhcp.option(dhcp.DHCP_MESSAGE_TYPE_OPT, '\x02', 1),
|
||||
dhcp.option(dhcp.DHCP_SUBNET_MASK_OPT, '\xff\xff\xff\x00', 4),
|
||||
dhcp.option(dhcp.DHCP_GATEWAY_ADDR_OPT, '\xc0\xa8\x0a\x09', 4),
|
||||
dhcp.option(dhcp.DHCP_DNS_SERVER_ADDR_OPT, '\xc0\xa8\x0a\x09', 4),
|
||||
dhcp.option(dhcp.DHCP_IP_ADDR_LEASE_TIME_OPT, '\x00\x03\xf4\x80', 4),
|
||||
dhcp.option(dhcp.DHCP_RENEWAL_TIME_OPT, '\x00\x01\xfa\x40', 4),
|
||||
dhcp.option(dhcp.DHCP_REBINDING_TIME_OPT, '\x00\x03\x75\xf0', 4),
|
||||
dhcp.option(dhcp.DHCP_SERVER_IDENTIFIER_OPT, '\xc0\xa8\x0a\x09', 4)]
|
||||
dhcp.option(dhcp.DHCP_MESSAGE_TYPE_OPT, b'\x02', 1),
|
||||
dhcp.option(dhcp.DHCP_SUBNET_MASK_OPT, b'\xff\xff\xff\x00', 4),
|
||||
dhcp.option(dhcp.DHCP_GATEWAY_ADDR_OPT, b'\xc0\xa8\x0a\x09', 4),
|
||||
dhcp.option(dhcp.DHCP_DNS_SERVER_ADDR_OPT, b'\xc0\xa8\x0a\x09', 4),
|
||||
dhcp.option(dhcp.DHCP_IP_ADDR_LEASE_TIME_OPT, b'\x00\x03\xf4\x80', 4),
|
||||
dhcp.option(dhcp.DHCP_RENEWAL_TIME_OPT, b'\x00\x01\xfa\x40', 4),
|
||||
dhcp.option(dhcp.DHCP_REBINDING_TIME_OPT, b'\x00\x03\x75\xf0', 4),
|
||||
dhcp.option(dhcp.DHCP_SERVER_IDENTIFIER_OPT, b'\xc0\xa8\x0a\x09', 4)]
|
||||
magic_cookie = '99.130.83.99'
|
||||
options = dhcp.options(option_list=option_list, options_len=50,
|
||||
magic_cookie=magic_cookie)
|
||||
|
@ -56,12 +56,12 @@ class Test_icmp(unittest.TestCase):
|
||||
def setUp_with_echo(self):
|
||||
self.echo_id = 13379
|
||||
self.echo_seq = 1
|
||||
self.echo_data = '\x30\x0e\x09\x00\x00\x00\x00\x00' \
|
||||
+ '\x10\x11\x12\x13\x14\x15\x16\x17' \
|
||||
+ '\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' \
|
||||
+ '\x20\x21\x22\x23\x24\x25\x26\x27' \
|
||||
+ '\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f' \
|
||||
+ '\x30\x31\x32\x33\x34\x35\x36\x37'
|
||||
self.echo_data = b'\x30\x0e\x09\x00\x00\x00\x00\x00' \
|
||||
+ b'\x10\x11\x12\x13\x14\x15\x16\x17' \
|
||||
+ b'\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' \
|
||||
+ b'\x20\x21\x22\x23\x24\x25\x26\x27' \
|
||||
+ b'\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f' \
|
||||
+ b'\x30\x31\x32\x33\x34\x35\x36\x37'
|
||||
self.data = icmp.echo(
|
||||
id_=self.echo_id, seq=self.echo_seq, data=self.echo_data)
|
||||
|
||||
@ -224,7 +224,7 @@ class Test_icmp(unittest.TestCase):
|
||||
|
||||
eq_(res[0], 8)
|
||||
eq_(res[1], 0)
|
||||
eq_(buf[4:], '\x00\x00\x00\x00')
|
||||
eq_(buf[4:], b'\x00\x00\x00\x00')
|
||||
|
||||
# with data
|
||||
ic = icmp.icmp(type_=icmp.ICMP_DEST_UNREACH, data=icmp.dest_unreach())
|
||||
@ -233,7 +233,7 @@ class Test_icmp(unittest.TestCase):
|
||||
|
||||
eq_(res[0], 3)
|
||||
eq_(res[1], 0)
|
||||
eq_(buf[4:], '\x00\x00\x00\x00')
|
||||
eq_(buf[4:], b'\x00\x00\x00\x00')
|
||||
|
||||
def test_json(self):
|
||||
jsondict = self.ic.to_jsondict()
|
||||
@ -258,12 +258,12 @@ class Test_echo(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.id_ = 13379
|
||||
self.seq = 1
|
||||
self.data = '\x30\x0e\x09\x00\x00\x00\x00\x00' \
|
||||
+ '\x10\x11\x12\x13\x14\x15\x16\x17' \
|
||||
+ '\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' \
|
||||
+ '\x20\x21\x22\x23\x24\x25\x26\x27' \
|
||||
+ '\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f' \
|
||||
+ '\x30\x31\x32\x33\x34\x35\x36\x37'
|
||||
self.data = b'\x30\x0e\x09\x00\x00\x00\x00\x00' \
|
||||
+ b'\x10\x11\x12\x13\x14\x15\x16\x17' \
|
||||
+ b'\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f' \
|
||||
+ b'\x20\x21\x22\x23\x24\x25\x26\x27' \
|
||||
+ b'\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f' \
|
||||
+ b'\x30\x31\x32\x33\x34\x35\x36\x37'
|
||||
self.echo = icmp.echo(
|
||||
self.id_, self.seq, self.data)
|
||||
self.buf = struct.pack('!HH', self.id_, self.seq)
|
||||
|
@ -49,7 +49,7 @@ class Test_icmpv6_header(unittest.TestCase):
|
||||
type_ = 255
|
||||
code = 0
|
||||
csum = 207
|
||||
buf = '\xff\x00\x00\xcf'
|
||||
buf = b'\xff\x00\x00\xcf'
|
||||
icmp = icmpv6.icmpv6(type_, code, 0)
|
||||
|
||||
def setUp(self):
|
||||
@ -112,8 +112,8 @@ class Test_icmpv6_echo_request(unittest.TestCase):
|
||||
csum = 0xa572
|
||||
id_ = 0x7620
|
||||
seq = 0
|
||||
data = '\x01\xc9\xe7\x36\xd3\x39\x06\x00'
|
||||
buf = '\x80\x00\xa5\x72\x76\x20\x00\x00'
|
||||
data = b'\x01\xc9\xe7\x36\xd3\x39\x06\x00'
|
||||
buf = b'\x80\x00\xa5\x72\x76\x20\x00\x00'
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
@ -128,7 +128,7 @@ class Test_icmpv6_echo_request(unittest.TestCase):
|
||||
eq_(echo.data, None)
|
||||
|
||||
def _test_parser(self, data=None):
|
||||
buf = self.buf + str(data or '')
|
||||
buf = self.buf + (data or b'')
|
||||
msg, n, _ = icmpv6.icmpv6.parser(buf)
|
||||
|
||||
eq_(msg.type_, self.type_)
|
||||
@ -146,7 +146,7 @@ class Test_icmpv6_echo_request(unittest.TestCase):
|
||||
self._test_parser(self.data)
|
||||
|
||||
def _test_serialize(self, echo_data=None):
|
||||
buf = self.buf + str(echo_data or '')
|
||||
buf = self.buf + (echo_data or b'')
|
||||
src_ipv6 = '3ffe:507:0:1:200:86ff:fe05:80da'
|
||||
dst_ipv6 = '3ffe:501:0:1001::2'
|
||||
prev = ipv6(6, 0, 0, len(buf), 64, 255, src_ipv6, dst_ipv6)
|
||||
@ -227,7 +227,7 @@ class Test_icmpv6_echo_reply(Test_icmpv6_echo_request):
|
||||
def setUp(self):
|
||||
self.type_ = 129
|
||||
self.csum = 0xa472
|
||||
self.buf = '\x81\x00\xa4\x72\x76\x20\x00\x00'
|
||||
self.buf = b'\x81\x00\xa4\x72\x76\x20\x00\x00'
|
||||
|
||||
def test_default_args(self):
|
||||
prev = ipv6(nxt=inet.IPPROTO_ICMPV6)
|
||||
@ -256,10 +256,10 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase):
|
||||
nd_type = 1
|
||||
nd_length = 1
|
||||
nd_hw_src = '00:60:97:07:69:ea'
|
||||
data = '\x01\x01\x00\x60\x97\x07\x69\xea'
|
||||
buf = '\x87\x00\x95\x2d\x00\x00\x00\x00' \
|
||||
+ '\x3f\xfe\x05\x07\x00\x00\x00\x01' \
|
||||
+ '\x02\x00\x86\xff\xfe\x05\x80\xda'
|
||||
data = b'\x01\x01\x00\x60\x97\x07\x69\xea'
|
||||
buf = b'\x87\x00\x95\x2d\x00\x00\x00\x00' \
|
||||
+ b'\x3f\xfe\x05\x07\x00\x00\x00\x01' \
|
||||
+ b'\x02\x00\x86\xff\xfe\x05\x80\xda'
|
||||
src_ipv6 = '3ffe:507:0:1:200:86ff:fe05:80da'
|
||||
dst_ipv6 = '3ffe:501:0:1001::2'
|
||||
|
||||
@ -276,7 +276,7 @@ class Test_icmpv6_neighbor_solicit(unittest.TestCase):
|
||||
eq_(nd.option, None)
|
||||
|
||||
def _test_parser(self, data=None):
|
||||
buf = self.buf + str(data or '')
|
||||
buf = self.buf + (data or b'')
|
||||
msg, n, _ = icmpv6.icmpv6.parser(buf)
|
||||
|
||||
eq_(msg.type_, self.type_)
|
||||
@ -435,10 +435,10 @@ class Test_icmpv6_neighbor_advert(Test_icmpv6_neighbor_solicit):
|
||||
self.nd_length = 1
|
||||
self.nd_data = None
|
||||
self.nd_hw_src = '00:60:97:07:69:ea'
|
||||
self.data = '\x02\x01\x00\x60\x97\x07\x69\xea'
|
||||
self.buf = '\x88\x00\xb8\xba\xe0\x00\x00\x00' \
|
||||
+ '\x3f\xfe\x05\x07\x00\x00\x00\x01' \
|
||||
+ '\x02\x60\x97\xff\xfe\x07\x69\xea'
|
||||
self.data = b'\x02\x01\x00\x60\x97\x07\x69\xea'
|
||||
self.buf = b'\x88\x00\xb8\xba\xe0\x00\x00\x00' \
|
||||
+ b'\x3f\xfe\x05\x07\x00\x00\x00\x01' \
|
||||
+ b'\x02\x60\x97\xff\xfe\x07\x69\xea'
|
||||
|
||||
def test_serialize_with_data(self):
|
||||
nd_opt = icmpv6.nd_option_tla(self.nd_length, self.nd_hw_src)
|
||||
@ -548,8 +548,8 @@ class Test_icmpv6_router_solicit(unittest.TestCase):
|
||||
nd_type = 1
|
||||
nd_length = 1
|
||||
nd_hw_src = '12:2d:a5:6d:bc:0f'
|
||||
data = '\x00\x00\x00\x00\x01\x01\x12\x2d\xa5\x6d\xbc\x0f'
|
||||
buf = '\x85\x00\x97\xd9'
|
||||
data = b'\x00\x00\x00\x00\x01\x01\x12\x2d\xa5\x6d\xbc\x0f'
|
||||
buf = b'\x85\x00\x97\xd9'
|
||||
src_ipv6 = '3ffe:507:0:1:200:86ff:fe05:80da'
|
||||
dst_ipv6 = '3ffe:501:0:1001::2'
|
||||
|
||||
@ -565,7 +565,7 @@ class Test_icmpv6_router_solicit(unittest.TestCase):
|
||||
eq_(rs.option, None)
|
||||
|
||||
def _test_parser(self, data=None):
|
||||
buf = self.buf + str(data or '')
|
||||
buf = self.buf + (data or b'')
|
||||
msg, n, _ = icmpv6.icmpv6.parser(buf)
|
||||
|
||||
eq_(msg.type_, self.type_)
|
||||
@ -975,9 +975,9 @@ class Test_icmpv6_membership_query(unittest.TestCase):
|
||||
csum = 0xb5a4
|
||||
maxresp = 10000
|
||||
address = 'ff08::1'
|
||||
buf = '\x82\x00\xb5\xa4\x27\x10\x00\x00' \
|
||||
+ '\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
buf = b'\x82\x00\xb5\xa4\x27\x10\x00\x00' \
|
||||
+ b'\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
@ -1075,9 +1075,9 @@ class Test_icmpv6_membership_report(Test_icmpv6_membership_query):
|
||||
csum = 0xb4a4
|
||||
maxresp = 10000
|
||||
address = 'ff08::1'
|
||||
buf = '\x83\x00\xb4\xa4\x27\x10\x00\x00' \
|
||||
+ '\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
buf = b'\x83\x00\xb4\xa4\x27\x10\x00\x00' \
|
||||
+ b'\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
|
||||
def test_json(self):
|
||||
ic1 = icmpv6.icmpv6(
|
||||
@ -1094,9 +1094,9 @@ class Test_icmpv6_membership_done(Test_icmpv6_membership_query):
|
||||
csum = 0xb3a4
|
||||
maxresp = 10000
|
||||
address = 'ff08::1'
|
||||
buf = '\x84\x00\xb3\xa4\x27\x10\x00\x00' \
|
||||
+ '\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
buf = b'\x84\x00\xb3\xa4\x27\x10\x00\x00' \
|
||||
+ b'\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
|
||||
def test_json(self):
|
||||
ic1 = icmpv6.icmpv6(
|
||||
@ -1123,10 +1123,10 @@ class Test_mldv2_query(unittest.TestCase):
|
||||
mld = icmpv6.mldv2_query(
|
||||
maxresp, address, s_flg, qrv, qqic, num, srcs)
|
||||
|
||||
buf = '\x82\x00\xb5\xa4\x27\x10\x00\x00' \
|
||||
+ '\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\x02\x0a\x00\x00'
|
||||
buf = b'\x82\x00\xb5\xa4\x27\x10\x00\x00' \
|
||||
+ b'\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\x02\x0a\x00\x00'
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
@ -1137,14 +1137,14 @@ class Test_mldv2_query(unittest.TestCase):
|
||||
self.mld = icmpv6.mldv2_query(
|
||||
self.maxresp, self.address, self.s_flg, self.qrv, self.qqic,
|
||||
self.num, self.srcs)
|
||||
self.buf = '\x82\x00\xb5\xa4\x27\x10\x00\x00' \
|
||||
+ '\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\x02\x0a\x00\x02' \
|
||||
+ '\xff\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xff\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x02'
|
||||
self.buf = b'\x82\x00\xb5\xa4\x27\x10\x00\x00' \
|
||||
+ b'\xff\x08\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\x02\x0a\x00\x02' \
|
||||
+ b'\xff\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xff\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x02'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
@ -1393,7 +1393,7 @@ class Test_mldv2_report(unittest.TestCase):
|
||||
|
||||
mld = icmpv6.mldv2_report(record_num, records)
|
||||
|
||||
buf = '\x8f\x00\xb5\xa4\x00\x00\x00\x00'
|
||||
buf = b'\x8f\x00\xb5\xa4\x00\x00\x00\x00'
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
@ -1405,37 +1405,37 @@ class Test_mldv2_report(unittest.TestCase):
|
||||
icmpv6.MODE_IS_INCLUDE, 0, 2, 'ff00::2',
|
||||
['fe80::1', 'fe80::2'])
|
||||
self.record3 = icmpv6.mldv2_report_group(
|
||||
icmpv6.MODE_IS_INCLUDE, 1, 0, 'ff00::3', [], 'abc\x00')
|
||||
icmpv6.MODE_IS_INCLUDE, 1, 0, 'ff00::3', [], b'abc\x00')
|
||||
self.record4 = icmpv6.mldv2_report_group(
|
||||
icmpv6.MODE_IS_INCLUDE, 2, 2, 'ff00::4',
|
||||
['fe80::1', 'fe80::2'], 'abcde\x00\x00\x00')
|
||||
['fe80::1', 'fe80::2'], b'abcde\x00\x00\x00')
|
||||
self.records = [self.record1, self.record2, self.record3,
|
||||
self.record4]
|
||||
self.record_num = len(self.records)
|
||||
self.mld = icmpv6.mldv2_report(self.record_num, self.records)
|
||||
self.buf = '\x8f\x00\xb5\xa4\x00\x00\x00\x04' \
|
||||
+ '\x01\x00\x00\x00' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\x01\x00\x00\x02' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ '\x01\x01\x00\x00' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x03' \
|
||||
+ '\x61\x62\x63\x00' \
|
||||
+ '\x01\x02\x00\x02' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x04' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ '\x61\x62\x63\x64\x65\x00\x00\x00'
|
||||
self.buf = b'\x8f\x00\xb5\xa4\x00\x00\x00\x04' \
|
||||
+ b'\x01\x00\x00\x00' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\x01\x00\x00\x02' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ b'\x01\x01\x00\x00' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x03' \
|
||||
+ b'\x61\x62\x63\x00' \
|
||||
+ b'\x01\x02\x00\x02' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x04' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ b'\x61\x62\x63\x64\x65\x00\x00\x00'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
@ -1579,10 +1579,10 @@ class Test_mldv2_report(unittest.TestCase):
|
||||
icmpv6.MODE_IS_INCLUDE, 0, 2, 'ff00::2',
|
||||
['fe80::1', 'fe80::2'])
|
||||
self.record3 = icmpv6.mldv2_report_group(
|
||||
icmpv6.MODE_IS_INCLUDE, 1, 0, 'ff00::3', [], 'abc\x00')
|
||||
icmpv6.MODE_IS_INCLUDE, 1, 0, 'ff00::3', [], b'abc\x00')
|
||||
self.record4 = icmpv6.mldv2_report_group(
|
||||
icmpv6.MODE_IS_INCLUDE, 2, 2, 'ff00::4',
|
||||
['fe80::1', 'fe80::2'], 'abcde\x00\x00\x00')
|
||||
['fe80::1', 'fe80::2'], b'abcde\x00\x00\x00')
|
||||
self.records = [self.record1, self.record2, self.record3,
|
||||
self.record4]
|
||||
self.record_num = len(self.records) + 1
|
||||
@ -1603,10 +1603,10 @@ class Test_mldv2_report(unittest.TestCase):
|
||||
icmpv6.MODE_IS_INCLUDE, 0, 2, 'ff00::2',
|
||||
['fe80::1', 'fe80::2'])
|
||||
self.record3 = icmpv6.mldv2_report_group(
|
||||
icmpv6.MODE_IS_INCLUDE, 1, 0, 'ff00::3', [], 'abc\x00')
|
||||
icmpv6.MODE_IS_INCLUDE, 1, 0, 'ff00::3', [], b'abc\x00')
|
||||
self.record4 = icmpv6.mldv2_report_group(
|
||||
icmpv6.MODE_IS_INCLUDE, 2, 2, 'ff00::4',
|
||||
['fe80::1', 'fe80::2'], 'abcde\x00\x00\x00')
|
||||
['fe80::1', 'fe80::2'], b'abcde\x00\x00\x00')
|
||||
self.records = [self.record1, self.record2, self.record3,
|
||||
self.record4]
|
||||
self.record_num = len(self.records) - 1
|
||||
@ -1696,9 +1696,9 @@ class Test_mldv2_report_group(unittest.TestCase):
|
||||
aux = None
|
||||
mld = icmpv6.mldv2_report_group(
|
||||
type_, aux_len, num, address, srcs, aux)
|
||||
buf = '\x01\x00\x00\x00' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
buf = b'\x01\x00\x00\x00' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
@ -1709,45 +1709,45 @@ class Test_mldv2_report_group(unittest.TestCase):
|
||||
self.mld = icmpv6.mldv2_report_group(
|
||||
self.type_, self.aux_len, self.num, self.address, self.srcs,
|
||||
self.aux)
|
||||
self.buf = '\x01\x00\x00\x03' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x03'
|
||||
self.buf = b'\x01\x00\x00\x03' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x03'
|
||||
|
||||
def setUp_with_aux(self):
|
||||
self.aux = '\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux_len = len(self.aux) // 4
|
||||
self.mld = icmpv6.mldv2_report_group(
|
||||
self.type_, self.aux_len, self.num, self.address, self.srcs,
|
||||
self.aux)
|
||||
self.buf = '\x01\x02\x00\x00' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.buf = b'\x01\x02\x00\x00' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
|
||||
def setUp_with_srcs_and_aux(self):
|
||||
self.srcs = ['fe80::1', 'fe80::2', 'fe80::3']
|
||||
self.num = len(self.srcs)
|
||||
self.aux = '\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux_len = len(self.aux) // 4
|
||||
self.mld = icmpv6.mldv2_report_group(
|
||||
self.type_, self.aux_len, self.num, self.address, self.srcs,
|
||||
self.aux)
|
||||
self.buf = '\x01\x02\x00\x03' \
|
||||
+ '\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ '\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x03' \
|
||||
+ '\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.buf = b'\x01\x02\x00\x03' \
|
||||
+ b'\xff\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x02' \
|
||||
+ b'\xfe\x80\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x03' \
|
||||
+ b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
@ -1928,7 +1928,7 @@ class Test_mldv2_report_group(unittest.TestCase):
|
||||
|
||||
@raises
|
||||
def test_aux_len_larger_than_aux(self):
|
||||
self.aux = '\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux_len = len(self.aux) // 4 + 1
|
||||
self.buf = struct.pack(
|
||||
icmpv6.mldv2_report_group._PACK_STR, self.type_, self.aux_len,
|
||||
@ -1941,7 +1941,7 @@ class Test_mldv2_report_group(unittest.TestCase):
|
||||
|
||||
@raises
|
||||
def test_aux_len_smaller_than_aux(self):
|
||||
self.aux = '\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||
self.aux_len = len(self.aux) // 4 - 1
|
||||
self.buf = struct.pack(
|
||||
icmpv6.mldv2_report_group._PACK_STR, self.type_, self.aux_len,
|
||||
@ -1984,7 +1984,7 @@ class Test_mldv2_report_group(unittest.TestCase):
|
||||
eq_(src3, addrconv.ipv6.text_to_bin(srcs[2]))
|
||||
|
||||
# aux without aux_len
|
||||
rep = icmpv6.mldv2_report_group(aux='\x01\x02\x03')
|
||||
rep = icmpv6.mldv2_report_group(aux=b'\x01\x02\x03')
|
||||
buf = rep.serialize()
|
||||
res = struct.unpack_from(
|
||||
icmpv6.mldv2_report_group._PACK_STR, str(buf))
|
||||
@ -1993,7 +1993,7 @@ class Test_mldv2_report_group(unittest.TestCase):
|
||||
eq_(res[1], 1)
|
||||
eq_(res[2], 0)
|
||||
eq_(res[3], addrconv.ipv6.text_to_bin('::'))
|
||||
eq_(buf[icmpv6.mldv2_report_group._MIN_LEN:], '\x01\x02\x03\x00')
|
||||
eq_(buf[icmpv6.mldv2_report_group._MIN_LEN:], b'\x01\x02\x03\x00')
|
||||
|
||||
def test_json(self):
|
||||
jsondict = self.mld.to_jsondict()
|
||||
|
@ -461,10 +461,10 @@ class Test_igmpv3_report(unittest.TestCase):
|
||||
MODE_IS_INCLUDE, 0, 2, '225.0.0.2',
|
||||
['172.16.10.10', '172.16.10.27'])
|
||||
self.record3 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], 'abc\x00')
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], b'abc\x00')
|
||||
self.record4 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 2, 2, '225.0.0.4',
|
||||
['172.16.10.10', '172.16.10.27'], 'abcde\x00\x00\x00')
|
||||
['172.16.10.10', '172.16.10.27'], b'abcde\x00\x00\x00')
|
||||
self.records = [self.record1, self.record2, self.record3,
|
||||
self.record4]
|
||||
self.record_num = len(self.records)
|
||||
@ -615,10 +615,10 @@ class Test_igmpv3_report(unittest.TestCase):
|
||||
MODE_IS_INCLUDE, 0, 2, '225.0.0.2',
|
||||
['172.16.10.10', '172.16.10.27'])
|
||||
self.record3 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], 'abc\x00')
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], b'abc\x00')
|
||||
self.record4 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 2, '225.0.0.4',
|
||||
['172.16.10.10', '172.16.10.27'], 'abc\x00')
|
||||
['172.16.10.10', '172.16.10.27'], b'abc\x00')
|
||||
self.records = [self.record1, self.record2, self.record3,
|
||||
self.record4]
|
||||
self.record_num = len(self.records) + 1
|
||||
@ -640,10 +640,10 @@ class Test_igmpv3_report(unittest.TestCase):
|
||||
MODE_IS_INCLUDE, 0, 2, '225.0.0.2',
|
||||
['172.16.10.10', '172.16.10.27'])
|
||||
self.record3 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], 'abc\x00')
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], b'abc\x00')
|
||||
self.record4 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 2, '225.0.0.4',
|
||||
['172.16.10.10', '172.16.10.27'], 'abc\x00')
|
||||
['172.16.10.10', '172.16.10.27'], b'abc\x00')
|
||||
self.records = [self.record1, self.record2, self.record3,
|
||||
self.record4]
|
||||
self.record_num = len(self.records) - 1
|
||||
@ -679,10 +679,10 @@ class Test_igmpv3_report(unittest.TestCase):
|
||||
MODE_IS_INCLUDE, 0, 2, '225.0.0.2',
|
||||
['172.16.10.10', '172.16.10.27'])
|
||||
record3 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], 'abc\x00')
|
||||
MODE_IS_INCLUDE, 1, 0, '225.0.0.3', [], b'abc\x00')
|
||||
record4 = igmpv3_report_group(
|
||||
MODE_IS_INCLUDE, 1, 2, '225.0.0.4',
|
||||
['172.16.10.10', '172.16.10.27'], 'abc\x00')
|
||||
['172.16.10.10', '172.16.10.27'], b'abc\x00')
|
||||
records = [record1, record2, record3, record4]
|
||||
g = igmpv3_report(records=records)
|
||||
prev.serialize(g, None)
|
||||
@ -738,7 +738,7 @@ class Test_igmpv3_report_group(unittest.TestCase):
|
||||
self.srcs, self.aux)
|
||||
|
||||
def setUp_with_aux(self):
|
||||
self.aux = '\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux_len = len(self.aux) // 4
|
||||
self.buf = pack(igmpv3_report_group._PACK_STR, self.type_,
|
||||
self.aux_len, self.num,
|
||||
@ -751,7 +751,7 @@ class Test_igmpv3_report_group(unittest.TestCase):
|
||||
def setUp_with_srcs_and_aux(self):
|
||||
self.srcs = ['192.168.1.1', '192.168.1.2', '192.168.1.3']
|
||||
self.num = len(self.srcs)
|
||||
self.aux = '\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux_len = len(self.aux) // 4
|
||||
self.buf = pack(igmpv3_report_group._PACK_STR, self.type_,
|
||||
self.aux_len, self.num,
|
||||
@ -936,7 +936,7 @@ class Test_igmpv3_report_group(unittest.TestCase):
|
||||
|
||||
@raises
|
||||
def test_aux_len_larger_than_aux(self):
|
||||
self.aux = '\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux_len = len(self.aux) // 4 + 1
|
||||
self.buf = pack(igmpv3_report_group._PACK_STR, self.type_,
|
||||
self.aux_len, self.num,
|
||||
@ -949,7 +949,7 @@ class Test_igmpv3_report_group(unittest.TestCase):
|
||||
|
||||
@raises
|
||||
def test_aux_len_smaller_than_aux(self):
|
||||
self.aux = '\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux = b'\x01\x02\x03\x04\x05\x00\x00\x00'
|
||||
self.aux_len = len(self.aux) // 4 - 1
|
||||
self.buf = pack(igmpv3_report_group._PACK_STR, self.type_,
|
||||
self.aux_len, self.num,
|
||||
@ -997,4 +997,4 @@ class Test_igmpv3_report_group(unittest.TestCase):
|
||||
eq_(res[1], 2)
|
||||
eq_(res[2], 0)
|
||||
eq_(res[3], addrconv.ipv4.text_to_bin('0.0.0.0'))
|
||||
eq_(buf[igmpv3_report_group._MIN_LEN:], 'abcde\x00\x00\x00')
|
||||
eq_(buf[igmpv3_report_group._MIN_LEN:], b'abcde\x00\x00\x00')
|
||||
|
@ -51,11 +51,11 @@ class Test_ipv4(unittest.TestCase):
|
||||
src = '131.151.32.21'
|
||||
dst = '131.151.32.129'
|
||||
length = header_length * 4
|
||||
option = '\x86\x28\x00\x00\x00\x01\x01\x22' \
|
||||
+ '\x00\x01\xae\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
option = b'\x86\x28\x00\x00\x00\x01\x01\x22' \
|
||||
+ b'\x00\x01\xae\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00\x00\x01'
|
||||
|
||||
buf = pack(ipv4._PACK_STR, ver_hlen, tos, total_length, identification,
|
||||
flg_off, ttl, proto, csum,
|
||||
|
@ -461,7 +461,7 @@ class Test_ipv6(unittest.TestCase):
|
||||
ip = ipv6.ipv6(
|
||||
nxt=0, ext_hdrs=[
|
||||
ipv6.hop_opts(58, 0, [
|
||||
ipv6.option(5, 2, '\x00\x00'),
|
||||
ipv6.option(5, 2, b'\x00\x00'),
|
||||
ipv6.option(1, 0, None)])])
|
||||
buf = ip.serialize(bytearray(), None)
|
||||
res = struct.unpack(ipv6.ipv6._PACK_STR + '8s', str(buf))
|
||||
@ -472,7 +472,7 @@ class Test_ipv6(unittest.TestCase):
|
||||
eq_(res[3], 255)
|
||||
eq_(res[4], addrconv.ipv6.text_to_bin('10::10'))
|
||||
eq_(res[5], addrconv.ipv6.text_to_bin('20::20'))
|
||||
eq_(res[6], '\x3a\x00\x05\x02\x00\x00\x01\x00')
|
||||
eq_(res[6], b'\x3a\x00\x05\x02\x00\x00\x01\x00')
|
||||
|
||||
def test_json(self):
|
||||
jsondict = self.ip.to_jsondict()
|
||||
@ -560,13 +560,13 @@ class Test_hop_opts(unittest.TestCase):
|
||||
opt4 = ipv6.option.parser(str(buf[offset:]))
|
||||
eq_(5, opt1.type_)
|
||||
eq_(2, opt1.len_)
|
||||
eq_('\x00\x00', opt1.data)
|
||||
eq_(b'\x00\x00', opt1.data)
|
||||
eq_(1, opt2.type_)
|
||||
eq_(0, opt2.len_)
|
||||
eq_(None, opt2.data)
|
||||
eq_(0xc2, opt3.type_)
|
||||
eq_(4, opt3.len_)
|
||||
eq_('\x00\x01\x00\x00', opt3.data)
|
||||
eq_(b'\x00\x01\x00\x00', opt3.data)
|
||||
eq_(1, opt4.type_)
|
||||
eq_(0, opt4.len_)
|
||||
eq_(None, opt4.data)
|
||||
@ -581,7 +581,7 @@ class Test_hop_opts(unittest.TestCase):
|
||||
|
||||
eq_(res[0], 6)
|
||||
eq_(res[1], 0)
|
||||
opt = ipv6.option(type_=1, len_=4, data='\x00\x00\x00\x00')
|
||||
opt = ipv6.option(type_=1, len_=4, data=b'\x00\x00\x00\x00')
|
||||
eq_(str(buf[2:]), opt.serialize())
|
||||
|
||||
|
||||
@ -641,13 +641,13 @@ class Test_dst_opts(unittest.TestCase):
|
||||
opt4 = ipv6.option.parser(str(buf[offset:]))
|
||||
eq_(5, opt1.type_)
|
||||
eq_(2, opt1.len_)
|
||||
eq_('\x00\x00', opt1.data)
|
||||
eq_(b'\x00\x00', opt1.data)
|
||||
eq_(1, opt2.type_)
|
||||
eq_(0, opt2.len_)
|
||||
eq_(None, opt2.data)
|
||||
eq_(0xc2, opt3.type_)
|
||||
eq_(4, opt3.len_)
|
||||
eq_('\x00\x01\x00\x00', opt3.data)
|
||||
eq_(b'\x00\x01\x00\x00', opt3.data)
|
||||
eq_(1, opt4.type_)
|
||||
eq_(0, opt4.len_)
|
||||
eq_(None, opt4.data)
|
||||
@ -1110,7 +1110,7 @@ class Test_auth(unittest.TestCase):
|
||||
size = 5
|
||||
auth = ipv6.auth(
|
||||
0, size, 256, 1,
|
||||
'\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8\xf8\xf8\xf8\xf8')
|
||||
b'\x21\xd3\xa9\x5c\x5f\xfd\x4d\x18\x46\x22\xb9\xf8\xf8\xf8\xf8\xf8')
|
||||
eq_((size + 2) * 4, len(auth))
|
||||
|
||||
def test_default_args(self):
|
||||
@ -1124,4 +1124,4 @@ class Test_auth(unittest.TestCase):
|
||||
eq_(res[1], 2)
|
||||
eq_(res[2], 0)
|
||||
eq_(res[3], 0)
|
||||
eq_(buf[ipv6.auth._MIN_LEN:], '\x00\x00\x00\x00')
|
||||
eq_(buf[ipv6.auth._MIN_LEN:], b'\x00\x00\x00\x00')
|
||||
|
@ -36,17 +36,17 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
# http://wiki.wireshark.org/LinkLayerDiscoveryProtocol
|
||||
#
|
||||
# mandatory TLV only
|
||||
self.data = '\x01\x80\xc2\x00\x00\x0e\x00\x04' \
|
||||
+ '\x96\x1f\xa7\x26\x88\xcc\x02\x07' \
|
||||
+ '\x04\x00\x04\x96\x1f\xa7\x26\x04' \
|
||||
+ '\x04\x05\x31\x2f\x33\x06\x02\x00' \
|
||||
+ '\x78\x00\x00'
|
||||
self.data = b'\x01\x80\xc2\x00\x00\x0e\x00\x04' \
|
||||
+ b'\x96\x1f\xa7\x26\x88\xcc\x02\x07' \
|
||||
+ b'\x04\x00\x04\x96\x1f\xa7\x26\x04' \
|
||||
+ b'\x04\x05\x31\x2f\x33\x06\x02\x00' \
|
||||
+ b'\x78\x00\x00'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_get_tlv_type(self):
|
||||
buf = str(bytearray('\x02\x07\x04\x00\x04\x96\x1f\xa7\x26'))
|
||||
buf = str(bytearray(b'\x02\x07\x04\x00\x04\x96\x1f\xa7\x26'))
|
||||
eq_(lldp.LLDPBasicTLV.get_type(buf), lldp.LLDP_TLV_CHASSIS_ID)
|
||||
|
||||
def test_parse_without_ethernet(self):
|
||||
@ -58,7 +58,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
eq_(tlvs[0].tlv_type, lldp.LLDP_TLV_CHASSIS_ID)
|
||||
eq_(tlvs[0].len, 7)
|
||||
eq_(tlvs[0].subtype, lldp.ChassisID.SUB_MAC_ADDRESS)
|
||||
eq_(tlvs[0].chassis_id, '\x00\x04\x96\x1f\xa7\x26')
|
||||
eq_(tlvs[0].chassis_id, b'\x00\x04\x96\x1f\xa7\x26')
|
||||
eq_(tlvs[1].tlv_type, lldp.LLDP_TLV_PORT_ID)
|
||||
eq_(tlvs[1].len, 4)
|
||||
eq_(tlvs[1].subtype, lldp.PortID.SUB_INTERFACE_NAME)
|
||||
@ -78,15 +78,15 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
|
||||
def test_tlv(self):
|
||||
tlv = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
chassis_id='\x00\x04\x96\x1f\xa7\x26')
|
||||
chassis_id=b'\x00\x04\x96\x1f\xa7\x26')
|
||||
eq_(tlv.tlv_type, lldp.LLDP_TLV_CHASSIS_ID)
|
||||
eq_(tlv.len, 7)
|
||||
(typelen, ) = struct.unpack('!H', '\x02\x07')
|
||||
(typelen, ) = struct.unpack('!H', b'\x02\x07')
|
||||
eq_(tlv.typelen, typelen)
|
||||
|
||||
def test_serialize_without_ethernet(self):
|
||||
tlv_chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
chassis_id='\x00\x04\x96\x1f\xa7\x26')
|
||||
chassis_id=b'\x00\x04\x96\x1f\xa7\x26')
|
||||
tlv_port_id = lldp.PortID(subtype=lldp.PortID.SUB_INTERFACE_NAME,
|
||||
port_id='1/3')
|
||||
tlv_ttl = lldp.TTL(ttl=120)
|
||||
@ -124,7 +124,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
|
||||
def test_to_string(self):
|
||||
chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
chassis_id='\x00\x04\x96\x1f\xa7\x26')
|
||||
chassis_id=b'\x00\x04\x96\x1f\xa7\x26')
|
||||
port_id = lldp.PortID(subtype=lldp.PortID.SUB_INTERFACE_NAME,
|
||||
port_id='1/3')
|
||||
ttl = lldp.TTL(ttl=120)
|
||||
@ -133,7 +133,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
lldp_pkt = lldp.lldp(tlvs)
|
||||
|
||||
chassis_id_values = {'subtype': lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
'chassis_id': '\x00\x04\x96\x1f\xa7\x26',
|
||||
'chassis_id': b'\x00\x04\x96\x1f\xa7\x26',
|
||||
'len': chassis_id.len,
|
||||
'typelen': chassis_id.typelen}
|
||||
_ch_id_str = ','.join(['%s=%s' % (k, repr(chassis_id_values[k]))
|
||||
@ -180,7 +180,7 @@ class TestLLDPMandatoryTLV(unittest.TestCase):
|
||||
|
||||
def test_json(self):
|
||||
chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
chassis_id='\x00\x04\x96\x1f\xa7\x26')
|
||||
chassis_id=b'\x00\x04\x96\x1f\xa7\x26')
|
||||
port_id = lldp.PortID(subtype=lldp.PortID.SUB_INTERFACE_NAME,
|
||||
port_id='1/3')
|
||||
ttl = lldp.TTL(ttl=120)
|
||||
@ -198,40 +198,40 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
# http://wiki.wireshark.org/LinkLayerDiscoveryProtocol
|
||||
#
|
||||
# include optional TLV
|
||||
self.data = '\x01\x80\xc2\x00\x00\x0e\x00\x01' \
|
||||
+ '\x30\xf9\xad\xa0\x88\xcc\x02\x07' \
|
||||
+ '\x04\x00\x01\x30\xf9\xad\xa0\x04' \
|
||||
+ '\x04\x05\x31\x2f\x31\x06\x02\x00' \
|
||||
+ '\x78\x08\x17\x53\x75\x6d\x6d\x69' \
|
||||
+ '\x74\x33\x30\x30\x2d\x34\x38\x2d' \
|
||||
+ '\x50\x6f\x72\x74\x20\x31\x30\x30' \
|
||||
+ '\x31\x00\x0a\x0d\x53\x75\x6d\x6d' \
|
||||
+ '\x69\x74\x33\x30\x30\x2d\x34\x38' \
|
||||
+ '\x00\x0c\x4c\x53\x75\x6d\x6d\x69' \
|
||||
+ '\x74\x33\x30\x30\x2d\x34\x38\x20' \
|
||||
+ '\x2d\x20\x56\x65\x72\x73\x69\x6f' \
|
||||
+ '\x6e\x20\x37\x2e\x34\x65\x2e\x31' \
|
||||
+ '\x20\x28\x42\x75\x69\x6c\x64\x20' \
|
||||
+ '\x35\x29\x20\x62\x79\x20\x52\x65' \
|
||||
+ '\x6c\x65\x61\x73\x65\x5f\x4d\x61' \
|
||||
+ '\x73\x74\x65\x72\x20\x30\x35\x2f' \
|
||||
+ '\x32\x37\x2f\x30\x35\x20\x30\x34' \
|
||||
+ '\x3a\x35\x33\x3a\x31\x31\x00\x0e' \
|
||||
+ '\x05\x01\x00\x14\x00\x14\x10\x0e' \
|
||||
+ '\x07' \
|
||||
+ '\x06\x00\x01\x30\xf9\xad\xa0\x02' \
|
||||
+ '\x00\x00\x03\xe9\x00\xfe\x07\x00' \
|
||||
+ '\x12\x0f\x02\x07\x01\x00\xfe\x09' \
|
||||
+ '\x00\x12\x0f\x01\x03\x6c\x00\x00' \
|
||||
+ '\x10\xfe\x09\x00\x12\x0f\x03\x01' \
|
||||
+ '\x00\x00\x00\x00\xfe\x06\x00\x12' \
|
||||
+ '\x0f\x04\x05\xf2\xfe\x06\x00\x80' \
|
||||
+ '\xc2\x01\x01\xe8\xfe\x07\x00\x80' \
|
||||
+ '\xc2\x02\x01\x00\x00\xfe\x17\x00' \
|
||||
+ '\x80\xc2\x03\x01\xe8\x10\x76\x32' \
|
||||
+ '\x2d\x30\x34\x38\x38\x2d\x30\x33' \
|
||||
+ '\x2d\x30\x35\x30\x35\x00\xfe\x05' \
|
||||
+ '\x00\x80\xc2\x04\x00\x00\x00'
|
||||
self.data = b'\x01\x80\xc2\x00\x00\x0e\x00\x01' \
|
||||
+ b'\x30\xf9\xad\xa0\x88\xcc\x02\x07' \
|
||||
+ b'\x04\x00\x01\x30\xf9\xad\xa0\x04' \
|
||||
+ b'\x04\x05\x31\x2f\x31\x06\x02\x00' \
|
||||
+ b'\x78\x08\x17\x53\x75\x6d\x6d\x69' \
|
||||
+ b'\x74\x33\x30\x30\x2d\x34\x38\x2d' \
|
||||
+ b'\x50\x6f\x72\x74\x20\x31\x30\x30' \
|
||||
+ b'\x31\x00\x0a\x0d\x53\x75\x6d\x6d' \
|
||||
+ b'\x69\x74\x33\x30\x30\x2d\x34\x38' \
|
||||
+ b'\x00\x0c\x4c\x53\x75\x6d\x6d\x69' \
|
||||
+ b'\x74\x33\x30\x30\x2d\x34\x38\x20' \
|
||||
+ b'\x2d\x20\x56\x65\x72\x73\x69\x6f' \
|
||||
+ b'\x6e\x20\x37\x2e\x34\x65\x2e\x31' \
|
||||
+ b'\x20\x28\x42\x75\x69\x6c\x64\x20' \
|
||||
+ b'\x35\x29\x20\x62\x79\x20\x52\x65' \
|
||||
+ b'\x6c\x65\x61\x73\x65\x5f\x4d\x61' \
|
||||
+ b'\x73\x74\x65\x72\x20\x30\x35\x2f' \
|
||||
+ b'\x32\x37\x2f\x30\x35\x20\x30\x34' \
|
||||
+ b'\x3a\x35\x33\x3a\x31\x31\x00\x0e' \
|
||||
+ b'\x05\x01\x00\x14\x00\x14\x10\x0e' \
|
||||
+ b'\x07' \
|
||||
+ b'\x06\x00\x01\x30\xf9\xad\xa0\x02' \
|
||||
+ b'\x00\x00\x03\xe9\x00\xfe\x07\x00' \
|
||||
+ b'\x12\x0f\x02\x07\x01\x00\xfe\x09' \
|
||||
+ b'\x00\x12\x0f\x01\x03\x6c\x00\x00' \
|
||||
+ b'\x10\xfe\x09\x00\x12\x0f\x03\x01' \
|
||||
+ b'\x00\x00\x00\x00\xfe\x06\x00\x12' \
|
||||
+ b'\x0f\x04\x05\xf2\xfe\x06\x00\x80' \
|
||||
+ b'\xc2\x01\x01\xe8\xfe\x07\x00\x80' \
|
||||
+ b'\xc2\x02\x01\x00\x00\xfe\x17\x00' \
|
||||
+ b'\x80\xc2\x03\x01\xe8\x10\x76\x32' \
|
||||
+ b'\x2d\x30\x34\x38\x38\x2d\x30\x33' \
|
||||
+ b'\x2d\x30\x35\x30\x35\x00\xfe\x05' \
|
||||
+ b'\x00\x80\xc2\x04\x00\x00\x00'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
@ -249,18 +249,18 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
|
||||
# Port Description
|
||||
eq_(tlvs[3].tlv_type, lldp.LLDP_TLV_PORT_DESCRIPTION)
|
||||
eq_(tlvs[3].port_description, 'Summit300-48-Port 1001\x00')
|
||||
eq_(tlvs[3].port_description, b'Summit300-48-Port 1001\x00')
|
||||
|
||||
# System Name
|
||||
eq_(tlvs[4].tlv_type, lldp.LLDP_TLV_SYSTEM_NAME)
|
||||
eq_(tlvs[4].system_name, 'Summit300-48\x00')
|
||||
eq_(tlvs[4].system_name, b'Summit300-48\x00')
|
||||
|
||||
# System Description
|
||||
|
||||
eq_(tlvs[5].tlv_type, lldp.LLDP_TLV_SYSTEM_DESCRIPTION)
|
||||
eq_(tlvs[5].system_description,
|
||||
'Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ 'by Release_Master 05/27/05 04:53:11\x00')
|
||||
+ b'by Release_Master 05/27/05 04:53:11\x00')
|
||||
|
||||
# SystemCapabilities
|
||||
eq_(tlvs[6].tlv_type, lldp.LLDP_TLV_SYSTEM_CAPABILITIES)
|
||||
@ -275,12 +275,12 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
# Management Address
|
||||
eq_(tlvs[7].tlv_type, lldp.LLDP_TLV_MANAGEMENT_ADDRESS)
|
||||
eq_(tlvs[7].addr_len, 7)
|
||||
eq_(tlvs[7].addr, '\x00\x01\x30\xf9\xad\xa0')
|
||||
eq_(tlvs[7].addr, b'\x00\x01\x30\xf9\xad\xa0')
|
||||
eq_(tlvs[7].intf_num, 1001)
|
||||
|
||||
# Organizationally Specific
|
||||
eq_(tlvs[8].tlv_type, lldp.LLDP_TLV_ORGANIZATIONALLY_SPECIFIC)
|
||||
eq_(tlvs[8].oui, '\x00\x12\x0f') # IEEE 802.3
|
||||
eq_(tlvs[8].oui, b'\x00\x12\x0f') # IEEE 802.3
|
||||
eq_(tlvs[8].subtype, 0x02) # Power Via MDI
|
||||
|
||||
# End
|
||||
@ -306,21 +306,21 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
port_id='1/1')
|
||||
tlv_ttl = lldp.TTL(ttl=120)
|
||||
tlv_port_description = lldp.PortDescription(
|
||||
port_description='Summit300-48-Port 1001\x00')
|
||||
tlv_system_name = lldp.SystemName(system_name='Summit300-48\x00')
|
||||
port_description=b'Summit300-48-Port 1001\x00')
|
||||
tlv_system_name = lldp.SystemName(system_name=b'Summit300-48\x00')
|
||||
tlv_system_description = lldp.SystemDescription(
|
||||
system_description='Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ 'by Release_Master 05/27/05 04:53:11\x00')
|
||||
system_description=b'Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ b'by Release_Master 05/27/05 04:53:11\x00')
|
||||
tlv_system_capabilities = lldp.SystemCapabilities(
|
||||
subtype=lldp.ChassisID.SUB_CHASSIS_COMPONENT,
|
||||
system_cap=0x14,
|
||||
enabled_cap=0x14)
|
||||
tlv_management_address = lldp.ManagementAddress(
|
||||
addr_subtype=0x06, addr='\x00\x01\x30\xf9\xad\xa0',
|
||||
addr_subtype=0x06, addr=b'\x00\x01\x30\xf9\xad\xa0',
|
||||
intf_subtype=0x02, intf_num=1001,
|
||||
oid='')
|
||||
tlv_organizationally_specific = lldp.OrganizationallySpecific(
|
||||
oui='\x00\x12\x0f', subtype=0x02, info='\x07\x01\x00')
|
||||
oui=b'\x00\x12\x0f', subtype=0x02, info=b'\x07\x01\x00')
|
||||
tlv_end = lldp.End()
|
||||
tlvs = (tlv_chassis_id, tlv_port_id, tlv_ttl, tlv_port_description,
|
||||
tlv_system_name, tlv_system_description,
|
||||
@ -339,26 +339,26 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
|
||||
def test_to_string(self):
|
||||
chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
chassis_id='\x00\x01\x30\xf9\xad\xa0')
|
||||
chassis_id=b'\x00\x01\x30\xf9\xad\xa0')
|
||||
port_id = lldp.PortID(subtype=lldp.PortID.SUB_INTERFACE_NAME,
|
||||
port_id='1/1')
|
||||
ttl = lldp.TTL(ttl=120)
|
||||
port_desc = lldp.PortDescription(
|
||||
port_description='Summit300-48-Port 1001\x00')
|
||||
sys_name = lldp.SystemName(system_name='Summit300-48\x00')
|
||||
port_description=b'Summit300-48-Port 1001\x00')
|
||||
sys_name = lldp.SystemName(system_name=b'Summit300-48\x00')
|
||||
sys_desc = lldp.SystemDescription(
|
||||
system_description='Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ 'by Release_Master 05/27/05 04:53:11\x00')
|
||||
system_description=b'Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ b'by Release_Master 05/27/05 04:53:11\x00')
|
||||
sys_cap = lldp.SystemCapabilities(
|
||||
subtype=lldp.ChassisID.SUB_CHASSIS_COMPONENT,
|
||||
system_cap=0x14,
|
||||
enabled_cap=0x14)
|
||||
man_addr = lldp.ManagementAddress(
|
||||
addr_subtype=0x06, addr='\x00\x01\x30\xf9\xad\xa0',
|
||||
addr_subtype=0x06, addr=b'\x00\x01\x30\xf9\xad\xa0',
|
||||
intf_subtype=0x02, intf_num=1001,
|
||||
oid='')
|
||||
org_spec = lldp.OrganizationallySpecific(
|
||||
oui='\x00\x12\x0f', subtype=0x02, info='\x07\x01\x00')
|
||||
oui=b'\x00\x12\x0f', subtype=0x02, info=b'\x07\x01\x00')
|
||||
end = lldp.End()
|
||||
tlvs = (chassis_id, port_id, ttl, port_desc, sys_name,
|
||||
sys_desc, sys_cap, man_addr, org_spec, end)
|
||||
@ -366,7 +366,7 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
|
||||
# ChassisID string
|
||||
chassis_id_values = {'subtype': lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
'chassis_id': '\x00\x01\x30\xf9\xad\xa0',
|
||||
'chassis_id': b'\x00\x01\x30\xf9\xad\xa0',
|
||||
'len': chassis_id.len,
|
||||
'typelen': chassis_id.typelen}
|
||||
_ch_id_str = ','.join(['%s=%s' % (k, repr(chassis_id_values[k]))
|
||||
@ -437,7 +437,7 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
|
||||
# ManagementAddress string
|
||||
man_addr_values = {'addr_subtype': 0x06,
|
||||
'addr': '\x00\x01\x30\xf9\xad\xa0',
|
||||
'addr': b'\x00\x01\x30\xf9\xad\xa0',
|
||||
'addr_len': man_addr.addr_len,
|
||||
'intf_subtype': 0x02,
|
||||
'intf_num': 1001,
|
||||
@ -452,9 +452,9 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
_man_addr_str)
|
||||
|
||||
# OrganizationallySpecific string
|
||||
org_spec_values = {'oui': '\x00\x12\x0f',
|
||||
org_spec_values = {'oui': b'\x00\x12\x0f',
|
||||
'subtype': 0x02,
|
||||
'info': '\x07\x01\x00',
|
||||
'info': b'\x07\x01\x00',
|
||||
'len': org_spec.len,
|
||||
'typelen': org_spec.typelen}
|
||||
_org_spec_str = ','.join(['%s=%s' % (k, repr(org_spec_values[k]))
|
||||
@ -494,26 +494,26 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
|
||||
def test_json(self):
|
||||
chassis_id = lldp.ChassisID(subtype=lldp.ChassisID.SUB_MAC_ADDRESS,
|
||||
chassis_id='\x00\x01\x30\xf9\xad\xa0')
|
||||
chassis_id=b'\x00\x01\x30\xf9\xad\xa0')
|
||||
port_id = lldp.PortID(subtype=lldp.PortID.SUB_INTERFACE_NAME,
|
||||
port_id='1/1')
|
||||
ttl = lldp.TTL(ttl=120)
|
||||
port_desc = lldp.PortDescription(
|
||||
port_description='Summit300-48-Port 1001\x00')
|
||||
sys_name = lldp.SystemName(system_name='Summit300-48\x00')
|
||||
port_description=b'Summit300-48-Port 1001\x00')
|
||||
sys_name = lldp.SystemName(system_name=b'Summit300-48\x00')
|
||||
sys_desc = lldp.SystemDescription(
|
||||
system_description='Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ 'by Release_Master 05/27/05 04:53:11\x00')
|
||||
system_description=b'Summit300-48 - Version 7.4e.1 (Build 5) '
|
||||
+ b'by Release_Master 05/27/05 04:53:11\x00')
|
||||
sys_cap = lldp.SystemCapabilities(
|
||||
subtype=lldp.ChassisID.SUB_CHASSIS_COMPONENT,
|
||||
system_cap=0x14,
|
||||
enabled_cap=0x14)
|
||||
man_addr = lldp.ManagementAddress(
|
||||
addr_subtype=0x06, addr='\x00\x01\x30\xf9\xad\xa0',
|
||||
addr_subtype=0x06, addr=b'\x00\x01\x30\xf9\xad\xa0',
|
||||
intf_subtype=0x02, intf_num=1001,
|
||||
oid='')
|
||||
org_spec = lldp.OrganizationallySpecific(
|
||||
oui='\x00\x12\x0f', subtype=0x02, info='\x07\x01\x00')
|
||||
oui=b'\x00\x12\x0f', subtype=0x02, info=b'\x07\x01\x00')
|
||||
end = lldp.End()
|
||||
tlvs = (chassis_id, port_id, ttl, port_desc, sys_name,
|
||||
sys_desc, sys_cap, man_addr, org_spec, end)
|
||||
|
@ -44,10 +44,10 @@ class TestPacket(unittest.TestCase):
|
||||
src_port = 50001
|
||||
dst_port = 50002
|
||||
src_ip_bin = addrconv.ipv4.text_to_bin(src_ip)
|
||||
payload = '\x06\x06\x47\x50\x00\x00\x00\x00' \
|
||||
+ '\xcd\xc5\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x10\x11\x12\x13\x14\x15\x16\x17' \
|
||||
+ '\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
|
||||
payload = b'\x06\x06\x47\x50\x00\x00\x00\x00' \
|
||||
+ b'\xcd\xc5\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x10\x11\x12\x13\x14\x15\x16\x17' \
|
||||
+ b'\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
|
||||
|
||||
def get_protocols(self, pkt):
|
||||
protocols = {}
|
||||
@ -79,14 +79,14 @@ class TestPacket(unittest.TestCase):
|
||||
# ethernet !6s6sH
|
||||
e_buf = self.dst_mac_bin \
|
||||
+ self.src_mac_bin \
|
||||
+ '\x08\x06'
|
||||
+ b'\x08\x06'
|
||||
|
||||
# arp !HHBBH6sI6sI
|
||||
a_buf = '\x00\x01' \
|
||||
+ '\x08\x00' \
|
||||
+ '\x06' \
|
||||
+ '\x04' \
|
||||
+ '\x00\x02' \
|
||||
a_buf = b'\x00\x01' \
|
||||
+ b'\x08\x00' \
|
||||
+ b'\x06' \
|
||||
+ b'\x04' \
|
||||
+ b'\x00\x02' \
|
||||
+ self.src_mac_bin \
|
||||
+ self.src_ip_bin \
|
||||
+ self.dst_mac_bin \
|
||||
@ -170,18 +170,18 @@ class TestPacket(unittest.TestCase):
|
||||
# ethernet !6s6sH
|
||||
e_buf = self.dst_mac_bin \
|
||||
+ self.src_mac_bin \
|
||||
+ '\x81\x00'
|
||||
+ b'\x81\x00'
|
||||
|
||||
# vlan !HH
|
||||
v_buf = '\xF0\x03' \
|
||||
+ '\x08\x06'
|
||||
v_buf = b'\xF0\x03' \
|
||||
+ b'\x08\x06'
|
||||
|
||||
# arp !HHBBH6sI6sI
|
||||
a_buf = '\x00\x01' \
|
||||
+ '\x08\x00' \
|
||||
+ '\x06' \
|
||||
+ '\x04' \
|
||||
+ '\x00\x02' \
|
||||
a_buf = b'\x00\x01' \
|
||||
+ b'\x08\x00' \
|
||||
+ b'\x06' \
|
||||
+ b'\x04' \
|
||||
+ b'\x00\x02' \
|
||||
+ self.src_mac_bin \
|
||||
+ self.src_ip_bin \
|
||||
+ self.dst_mac_bin \
|
||||
@ -286,25 +286,25 @@ class TestPacket(unittest.TestCase):
|
||||
# ethernet !6s6sH
|
||||
e_buf = self.dst_mac_bin \
|
||||
+ self.src_mac_bin \
|
||||
+ '\x08\x00'
|
||||
+ b'\x08\x00'
|
||||
|
||||
# ipv4 !BBHHHBBHII
|
||||
ip_buf = '\x45' \
|
||||
+ '\x01' \
|
||||
+ '\x00\x3C' \
|
||||
+ '\x00\x03' \
|
||||
+ '\x20\x04' \
|
||||
+ '\x40' \
|
||||
+ '\x11' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x45' \
|
||||
+ b'\x01' \
|
||||
+ b'\x00\x3C' \
|
||||
+ b'\x00\x03' \
|
||||
+ b'\x20\x04' \
|
||||
+ b'\x40' \
|
||||
+ b'\x11' \
|
||||
+ b'\x00\x00' \
|
||||
+ self.src_ip_bin \
|
||||
+ self.dst_ip_bin
|
||||
|
||||
# udp !HHHH
|
||||
u_buf = '\x19\x0F' \
|
||||
+ '\x1F\x90' \
|
||||
+ '\x00\x28' \
|
||||
+ '\x00\x00'
|
||||
u_buf = b'\x19\x0F' \
|
||||
+ b'\x1F\x90' \
|
||||
+ b'\x00\x28' \
|
||||
+ b'\x00\x00'
|
||||
|
||||
buf = e_buf + ip_buf + u_buf + self.payload
|
||||
|
||||
@ -413,7 +413,7 @@ class TestPacket(unittest.TestCase):
|
||||
ip = ipv4.ipv4(4, 5, 0, 0, 0, 0, 0, 64, inet.IPPROTO_TCP, 0,
|
||||
self.src_ip, self.dst_ip)
|
||||
t = tcp.tcp(0x190F, 0x1F90, 0x123, 1, 6, 0b101010, 2048, 0, 0x6f,
|
||||
'\x01\x02')
|
||||
b'\x01\x02')
|
||||
|
||||
p = packet.Packet()
|
||||
p.add_protocol(e)
|
||||
@ -425,31 +425,31 @@ class TestPacket(unittest.TestCase):
|
||||
# ethernet !6s6sH
|
||||
e_buf = self.dst_mac_bin \
|
||||
+ self.src_mac_bin \
|
||||
+ '\x08\x00'
|
||||
+ b'\x08\x00'
|
||||
|
||||
# ipv4 !BBHHHBBHII
|
||||
ip_buf = '\x45' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x4C' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x40' \
|
||||
+ '\x06' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x45' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x4C' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x40' \
|
||||
+ b'\x06' \
|
||||
+ b'\x00\x00' \
|
||||
+ self.src_ip_bin \
|
||||
+ self.dst_ip_bin
|
||||
|
||||
# tcp !HHIIBBHHH + option
|
||||
t_buf = '\x19\x0F' \
|
||||
+ '\x1F\x90' \
|
||||
+ '\x00\x00\x01\x23' \
|
||||
+ '\x00\x00\x00\x01' \
|
||||
+ '\x60' \
|
||||
+ '\x2A' \
|
||||
+ '\x08\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x6F' \
|
||||
+ '\x01\x02\x00\x00'
|
||||
t_buf = b'\x19\x0F' \
|
||||
+ b'\x1F\x90' \
|
||||
+ b'\x00\x00\x01\x23' \
|
||||
+ b'\x00\x00\x00\x01' \
|
||||
+ b'\x60' \
|
||||
+ b'\x2A' \
|
||||
+ b'\x08\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x6F' \
|
||||
+ b'\x01\x02\x00\x00'
|
||||
|
||||
buf = e_buf + ip_buf + t_buf + self.payload
|
||||
|
||||
@ -574,34 +574,34 @@ class TestPacket(unittest.TestCase):
|
||||
ipaddr = addrconv.ipv4.text_to_bin('0.0.0.0')
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = '\xff\xff\xff\xff\xff\xff' \
|
||||
+ '\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x08\x00'
|
||||
e_buf = b'\xff\xff\xff\xff\xff\xff' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x08\x00'
|
||||
|
||||
# ipv4 !BBHHHBBHII
|
||||
ip_buf = '\x45' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x50' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\xff' \
|
||||
+ '\x84' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x45' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x50' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\xff' \
|
||||
+ b'\x84' \
|
||||
+ b'\x00\x00' \
|
||||
+ ipaddr \
|
||||
+ ipaddr
|
||||
|
||||
# sctp !HHII + chunk_data !BBHIHHI + payload
|
||||
s_buf = '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
s_buf = b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ self.payload
|
||||
|
||||
buf = e_buf + ip_buf + s_buf
|
||||
@ -730,28 +730,28 @@ class TestPacket(unittest.TestCase):
|
||||
ipaddr = addrconv.ipv4.text_to_bin('0.0.0.0')
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = '\xff\xff\xff\xff\xff\xff' \
|
||||
+ '\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x08\x00'
|
||||
e_buf = b'\xff\xff\xff\xff\xff\xff' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x08\x00'
|
||||
|
||||
# ipv4 !BBHHHBBHII
|
||||
ip_buf = '\x45' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x1c' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\xff' \
|
||||
+ '\x01' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x45' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x1c' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\xff' \
|
||||
+ b'\x01' \
|
||||
+ b'\x00\x00' \
|
||||
+ ipaddr \
|
||||
+ ipaddr
|
||||
|
||||
# icmp !BBH + echo !HH
|
||||
ic_buf = '\x08' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00'
|
||||
ic_buf = b'\x08' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00'
|
||||
|
||||
buf = e_buf + ip_buf + ic_buf
|
||||
|
||||
@ -864,24 +864,24 @@ class TestPacket(unittest.TestCase):
|
||||
ipaddr = addrconv.ipv6.text_to_bin('::')
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = '\xff\xff\xff\xff\xff\xff' \
|
||||
+ '\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x86\xdd'
|
||||
e_buf = b'\xff\xff\xff\xff\xff\xff' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x86\xdd'
|
||||
|
||||
# ipv6 !IHBB16s16s'
|
||||
ip_buf = '\x60\x00\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x11' \
|
||||
+ '\xff' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x60\x00\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x11' \
|
||||
+ b'\xff' \
|
||||
+ b'\x00\x00' \
|
||||
+ ipaddr \
|
||||
+ ipaddr
|
||||
|
||||
# udp !HHHH
|
||||
u_buf = '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x28' \
|
||||
+ '\x00\x00'
|
||||
u_buf = b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x28' \
|
||||
+ b'\x00\x00'
|
||||
|
||||
buf = e_buf + ip_buf + u_buf + self.payload
|
||||
|
||||
@ -977,7 +977,7 @@ class TestPacket(unittest.TestCase):
|
||||
# build packet
|
||||
e = ethernet.ethernet(ethertype=ether.ETH_TYPE_IPV6)
|
||||
ip = ipv6.ipv6()
|
||||
t = tcp.tcp(option='\x01\x02')
|
||||
t = tcp.tcp(option=b'\x01\x02')
|
||||
|
||||
p = e / ip / t / self.payload
|
||||
p.serialize()
|
||||
@ -985,30 +985,30 @@ class TestPacket(unittest.TestCase):
|
||||
ipaddr = addrconv.ipv6.text_to_bin('::')
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = '\xff\xff\xff\xff\xff\xff' \
|
||||
+ '\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x86\xdd'
|
||||
e_buf = b'\xff\xff\xff\xff\xff\xff' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x86\xdd'
|
||||
|
||||
# ipv6 !IHBB16s16s'
|
||||
ip_buf = '\x60\x00\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x06' \
|
||||
+ '\xff' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x60\x00\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x06' \
|
||||
+ b'\xff' \
|
||||
+ b'\x00\x00' \
|
||||
+ ipaddr \
|
||||
+ ipaddr
|
||||
|
||||
# tcp !HHIIBBHHH + option
|
||||
t_buf = '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x60' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x01\x02\x00\x00'
|
||||
t_buf = b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x60' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x01\x02\x00\x00'
|
||||
|
||||
buf = e_buf + ip_buf + t_buf + self.payload
|
||||
|
||||
@ -1123,31 +1123,31 @@ class TestPacket(unittest.TestCase):
|
||||
ipaddr = addrconv.ipv6.text_to_bin('::')
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = '\xff\xff\xff\xff\xff\xff' \
|
||||
+ '\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x86\xdd'
|
||||
e_buf = b'\xff\xff\xff\xff\xff\xff' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x86\xdd'
|
||||
|
||||
# ipv6 !IHBB16s16s'
|
||||
ip_buf = '\x60\x00\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x84' \
|
||||
+ '\xff' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x60\x00\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x84' \
|
||||
+ b'\xff' \
|
||||
+ b'\x00\x00' \
|
||||
+ ipaddr \
|
||||
+ ipaddr
|
||||
|
||||
# sctp !HHII + chunk_data !BBHIHHI + payload
|
||||
s_buf = '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x00\x00\x00\x00' \
|
||||
s_buf = b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x00\x00\x00\x00' \
|
||||
+ self.payload
|
||||
|
||||
buf = e_buf + ip_buf + s_buf
|
||||
@ -1266,23 +1266,23 @@ class TestPacket(unittest.TestCase):
|
||||
ipaddr = addrconv.ipv6.text_to_bin('::')
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = '\xff\xff\xff\xff\xff\xff' \
|
||||
+ '\x00\x00\x00\x00\x00\x00' \
|
||||
+ '\x86\xdd'
|
||||
e_buf = b'\xff\xff\xff\xff\xff\xff' \
|
||||
+ b'\x00\x00\x00\x00\x00\x00' \
|
||||
+ b'\x86\xdd'
|
||||
|
||||
# ipv6 !IHBB16s16s'
|
||||
ip_buf = '\x60\x00\x00\x00' \
|
||||
+ '\x00\x00' \
|
||||
+ '\x3a' \
|
||||
+ '\xff' \
|
||||
+ '\x00\x00' \
|
||||
ip_buf = b'\x60\x00\x00\x00' \
|
||||
+ b'\x00\x00' \
|
||||
+ b'\x3a' \
|
||||
+ b'\xff' \
|
||||
+ b'\x00\x00' \
|
||||
+ ipaddr \
|
||||
+ ipaddr
|
||||
|
||||
# icmpv6 !BBH
|
||||
ic_buf = '\x00' \
|
||||
+ '\x00' \
|
||||
+ '\x00\x00'
|
||||
ic_buf = b'\x00' \
|
||||
+ b'\x00' \
|
||||
+ b'\x00\x00'
|
||||
|
||||
buf = e_buf + ip_buf + ic_buf
|
||||
|
||||
@ -1395,26 +1395,26 @@ class TestPacket(unittest.TestCase):
|
||||
p.serialize()
|
||||
|
||||
# ethernet !6s6sH
|
||||
e_buf = self.dst_mac + self.src_mac + '\x05\xdc'
|
||||
e_buf = self.dst_mac + self.src_mac + b'\x05\xdc'
|
||||
|
||||
# llc !BBB
|
||||
l_buf = ('\x42'
|
||||
'\x42'
|
||||
'\x03')
|
||||
l_buf = (b'\x42'
|
||||
b'\x42'
|
||||
b'\x03')
|
||||
|
||||
# bpdu !HBBBQIQHHHHH
|
||||
b_buf = ('\x00\x00'
|
||||
'\x00'
|
||||
'\x00'
|
||||
'\x00'
|
||||
'\x80\x64\xaa\xaa\xaa\xaa\xaa\xaa'
|
||||
'\x00\x00\x00\x04'
|
||||
'\x80\x64\xbb\xbb\xbb\xbb\xbb\xbb'
|
||||
'\x80\x04'
|
||||
'\x01\x00'
|
||||
'\x14\x00'
|
||||
'\x02\x00'
|
||||
'\x0f\x00')
|
||||
b_buf = (b'\x00\x00'
|
||||
b'\x00'
|
||||
b'\x00'
|
||||
b'\x00'
|
||||
b'\x80\x64\xaa\xaa\xaa\xaa\xaa\xaa'
|
||||
b'\x00\x00\x00\x04'
|
||||
b'\x80\x64\xbb\xbb\xbb\xbb\xbb\xbb'
|
||||
b'\x80\x04'
|
||||
b'\x01\x00'
|
||||
b'\x14\x00'
|
||||
b'\x02\x00'
|
||||
b'\x0f\x00')
|
||||
|
||||
buf = e_buf + l_buf + b_buf
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf = '\x16\x2e\x04\xd2\x05\xe3\x0a\x78\x00\x00\x00\x00'
|
||||
self.buf = b'\x16\x2e\x04\xd2\x05\xe3\x0a\x78\x00\x00\x00\x00'
|
||||
|
||||
def setUp_with_data(self):
|
||||
self.unordered = 1
|
||||
@ -57,7 +57,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.sid = 1
|
||||
self.seq = 0
|
||||
self.payload_id = 0
|
||||
self.payload_data = '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
|
||||
self.payload_data = b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
|
||||
|
||||
self.data = sctp.chunk_data(
|
||||
unordered=self.unordered, begin=self.begin, end=self.end,
|
||||
@ -69,8 +69,8 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x00\x07\x00\x1a\x00\x00\x30\x39\x00\x01\x00\x00' + \
|
||||
'\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
|
||||
self.buf += b'\x00\x07\x00\x1a\x00\x00\x30\x39\x00\x01\x00\x00' + \
|
||||
b'\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
|
||||
|
||||
def setUp_with_init(self):
|
||||
self.flags = 0
|
||||
@ -85,7 +85,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.p_ipv6 = sctp.param_ipv6('fe80::647e:1aff:fec4:8284')
|
||||
self.p_cookie_preserve = sctp.param_cookie_preserve(5000)
|
||||
self.p_ecn = sctp.param_ecn()
|
||||
self.p_host_addr = sctp.param_host_addr('test host\x00')
|
||||
self.p_host_addr = sctp.param_host_addr(b'test host\x00')
|
||||
self.p_support_type = sctp.param_supported_addr(
|
||||
[sctp.PTYPE_IPV4, sctp.PTYPE_IPV6, sctp.PTYPE_COOKIE_PRESERVE,
|
||||
sctp.PTYPE_ECN, sctp.PTYPE_HOST_ADDR])
|
||||
@ -103,18 +103,18 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x01\x00\x00\x5c\x00\x01\xe2\x40\x00\x00\x26\x94' + \
|
||||
'\x00\x03\x00\x03\x00\x01\xe2\x40' + \
|
||||
'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
'\x00\x06\x00\x14' + \
|
||||
'\xfe\x80\x00\x00\x00\x00\x00\x00' + \
|
||||
'\x64\x7e\x1a\xff\xfe\xc4\x82\x84' + \
|
||||
'\x00\x09\x00\x08\x00\x00\x13\x88' + \
|
||||
'\x80\x00\x00\x04' + \
|
||||
'\x00\x0b\x00\x0e' + \
|
||||
'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \
|
||||
'\x00\x0c\x00\x0e\x00\x05\x00\x06\x00\x09\x80\x00' + \
|
||||
'\x00\x0b\x00\x00'
|
||||
self.buf += b'\x01\x00\x00\x5c\x00\x01\xe2\x40\x00\x00\x26\x94' + \
|
||||
b'\x00\x03\x00\x03\x00\x01\xe2\x40' + \
|
||||
b'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
b'\x00\x06\x00\x14' + \
|
||||
b'\xfe\x80\x00\x00\x00\x00\x00\x00' + \
|
||||
b'\x64\x7e\x1a\xff\xfe\xc4\x82\x84' + \
|
||||
b'\x00\x09\x00\x08\x00\x00\x13\x88' + \
|
||||
b'\x80\x00\x00\x04' + \
|
||||
b'\x00\x0b\x00\x0e' + \
|
||||
b'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \
|
||||
b'\x00\x0c\x00\x0e\x00\x05\x00\x06\x00\x09\x80\x00' + \
|
||||
b'\x00\x0b\x00\x00'
|
||||
|
||||
def setUp_with_init_ack(self):
|
||||
self.flags = 0
|
||||
@ -125,13 +125,13 @@ class Test_sctp(unittest.TestCase):
|
||||
self.mis = 3
|
||||
self.i_tsn = 123456
|
||||
|
||||
self.p_state_cookie = sctp.param_state_cookie('\x01\x02\x03')
|
||||
self.p_state_cookie = sctp.param_state_cookie(b'\x01\x02\x03')
|
||||
self.p_ipv4 = sctp.param_ipv4('192.168.1.1')
|
||||
self.p_ipv6 = sctp.param_ipv6('fe80::647e:1aff:fec4:8284')
|
||||
self.p_unrecognized_param = sctp.param_unrecognized_param(
|
||||
'\xff\xff\x00\x04')
|
||||
b'\xff\xff\x00\x04')
|
||||
self.p_ecn = sctp.param_ecn()
|
||||
self.p_host_addr = sctp.param_host_addr('test host\x00')
|
||||
self.p_host_addr = sctp.param_host_addr(b'test host\x00')
|
||||
self.params = [
|
||||
self.p_state_cookie, self.p_ipv4, self.p_ipv6,
|
||||
self.p_unrecognized_param, self.p_ecn, self.p_host_addr]
|
||||
@ -146,17 +146,17 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x02\x00\x00\x54\x00\x01\xe2\x40\x00\x00\x26\x94' + \
|
||||
'\x00\x03\x00\x03\x00\x01\xe2\x40' + \
|
||||
'\x00\x07\x00\x07\x01\x02\x03\x00' + \
|
||||
'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
'\x00\x06\x00\x14' + \
|
||||
'\xfe\x80\x00\x00\x00\x00\x00\x00' + \
|
||||
'\x64\x7e\x1a\xff\xfe\xc4\x82\x84' + \
|
||||
'\x00\x08\x00\x08\xff\xff\x00\x04' + \
|
||||
'\x80\x00\x00\x04' + \
|
||||
'\x00\x0b\x00\x0e' + \
|
||||
'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00'
|
||||
self.buf += b'\x02\x00\x00\x54\x00\x01\xe2\x40\x00\x00\x26\x94' + \
|
||||
b'\x00\x03\x00\x03\x00\x01\xe2\x40' + \
|
||||
b'\x00\x07\x00\x07\x01\x02\x03\x00' + \
|
||||
b'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
b'\x00\x06\x00\x14' + \
|
||||
b'\xfe\x80\x00\x00\x00\x00\x00\x00' + \
|
||||
b'\x64\x7e\x1a\xff\xfe\xc4\x82\x84' + \
|
||||
b'\x00\x08\x00\x08\xff\xff\x00\x04' + \
|
||||
b'\x80\x00\x00\x04' + \
|
||||
b'\x00\x0b\x00\x0e' + \
|
||||
b'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00'
|
||||
|
||||
def setUp_with_sack(self):
|
||||
self.flags = 0
|
||||
@ -179,18 +179,18 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x03\x00\x00\x38\x00\x01\xe2\x40' + \
|
||||
'\x00\x00\x26\x94\x00\x05\x00\x05' + \
|
||||
'\x00\x02\x00\x03\x00\x0a\x00\x0c\x00\x14\x00\x18' + \
|
||||
'\x00\x33\x00\x34\x00\x3e\x00\x3f' + \
|
||||
'\x00\x01\xe2\x42\x00\x01\xe2\x4a\x00\x01\xe2\x54' + \
|
||||
'\x00\x01\xe2\x73\x00\x01\xe2\x7e'
|
||||
self.buf += b'\x03\x00\x00\x38\x00\x01\xe2\x40' + \
|
||||
b'\x00\x00\x26\x94\x00\x05\x00\x05' + \
|
||||
b'\x00\x02\x00\x03\x00\x0a\x00\x0c\x00\x14\x00\x18' + \
|
||||
b'\x00\x33\x00\x34\x00\x3e\x00\x3f' + \
|
||||
b'\x00\x01\xe2\x42\x00\x01\xe2\x4a\x00\x01\xe2\x54' + \
|
||||
b'\x00\x01\xe2\x73\x00\x01\xe2\x7e'
|
||||
|
||||
def setUp_with_heartbeat(self):
|
||||
self.flags = 0
|
||||
self.length = 4 + 8
|
||||
|
||||
self.p_heartbeat = sctp.param_heartbeat('\x01\x02\x03\x04')
|
||||
self.p_heartbeat = sctp.param_heartbeat(b'\x01\x02\x03\x04')
|
||||
|
||||
self.heartbeat = sctp.chunk_heartbeat(info=self.p_heartbeat)
|
||||
|
||||
@ -200,16 +200,16 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x04\x00\x00\x0c' + \
|
||||
'\x00\x01\x00\x08' + \
|
||||
'\x01\x02\x03\x04'
|
||||
self.buf += b'\x04\x00\x00\x0c' + \
|
||||
b'\x00\x01\x00\x08' + \
|
||||
b'\x01\x02\x03\x04'
|
||||
|
||||
def setUp_with_heartbeat_ack(self):
|
||||
self.flags = 0
|
||||
self.length = 4 + 12
|
||||
|
||||
self.p_heartbeat = sctp.param_heartbeat(
|
||||
'\xff\xee\xdd\xcc\xbb\xaa\x99\x88')
|
||||
b'\xff\xee\xdd\xcc\xbb\xaa\x99\x88')
|
||||
|
||||
self.heartbeat_ack = sctp.chunk_heartbeat_ack(info=self.p_heartbeat)
|
||||
|
||||
@ -219,9 +219,9 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x05\x00\x00\x10' + \
|
||||
'\x00\x01\x00\x0c' + \
|
||||
'\xff\xee\xdd\xcc\xbb\xaa\x99\x88'
|
||||
self.buf += b'\x05\x00\x00\x10' + \
|
||||
b'\x00\x01\x00\x0c' + \
|
||||
b'\xff\xee\xdd\xcc\xbb\xaa\x99\x88'
|
||||
|
||||
def setUp_with_abort(self):
|
||||
self.tflag = 0
|
||||
@ -232,23 +232,23 @@ class Test_sctp(unittest.TestCase):
|
||||
self.c_missing_param = sctp.cause_missing_param(
|
||||
[sctp.PTYPE_IPV4, sctp.PTYPE_IPV6,
|
||||
sctp.PTYPE_COOKIE_PRESERVE, sctp.PTYPE_HOST_ADDR])
|
||||
self.c_stale_cookie = sctp.cause_stale_cookie('\x00\x00\x13\x88')
|
||||
self.c_stale_cookie = sctp.cause_stale_cookie(b'\x00\x00\x13\x88')
|
||||
self.c_out_of_resource = sctp.cause_out_of_resource()
|
||||
self.c_unresolvable_addr = sctp.cause_unresolvable_addr(
|
||||
sctp.param_host_addr('test host\x00'))
|
||||
sctp.param_host_addr(b'test host\x00'))
|
||||
self.c_unrecognized_chunk = sctp.cause_unrecognized_chunk(
|
||||
'\xff\x00\x00\x04')
|
||||
b'\xff\x00\x00\x04')
|
||||
self.c_invalid_param = sctp.cause_invalid_param()
|
||||
self.c_unrecognized_param = sctp.cause_unrecognized_param(
|
||||
'\xff\xff\x00\x04')
|
||||
self.c_no_userdata = sctp.cause_no_userdata('\x00\x01\xe2\x40')
|
||||
b'\xff\xff\x00\x04')
|
||||
self.c_no_userdata = sctp.cause_no_userdata(b'\x00\x01\xe2\x40')
|
||||
self.c_cookie_while_shutdown = sctp.cause_cookie_while_shutdown()
|
||||
self.c_restart_with_new_addr = sctp.cause_restart_with_new_addr(
|
||||
sctp.param_ipv4('192.168.1.1'))
|
||||
self.c_user_initiated_abort = sctp.cause_user_initiated_abort(
|
||||
'Key Interrupt.\x00')
|
||||
b'Key Interrupt.\x00')
|
||||
self.c_protocol_violation = sctp.cause_protocol_violation(
|
||||
'Unknown reason.\x00')
|
||||
b'Unknown reason.\x00')
|
||||
|
||||
self.causes = [
|
||||
self.c_invalid_stream_id, self.c_missing_param,
|
||||
@ -267,28 +267,28 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x06\x00\x00\x90' + \
|
||||
'\x00\x01\x00\x08\x10\x00\x00\x00' + \
|
||||
'\x00\x02\x00\x10\x00\x00\x00\x04' + \
|
||||
'\x00\x05\x00\x06\x00\x09\x00\x0b' + \
|
||||
'\x00\x03\x00\x08\x00\x00\x13\x88' + \
|
||||
'\x00\x04\x00\x04' + \
|
||||
'\x00\x05\x00\x14' + \
|
||||
'\x00\x0b\x00\x0e' + \
|
||||
'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \
|
||||
'\x00\x06\x00\x08\xff\x00\x00\x04' + \
|
||||
'\x00\x07\x00\x04' + \
|
||||
'\x00\x08\x00\x08\xff\xff\x00\x04' + \
|
||||
'\x00\x09\x00\x08\x00\x01\xe2\x40' + \
|
||||
'\x00\x0a\x00\x04' + \
|
||||
'\x00\x0b\x00\x0c' + \
|
||||
'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
'\x00\x0c\x00\x13' + \
|
||||
'\x4b\x65\x79\x20\x49\x6e\x74\x65' + \
|
||||
'\x72\x72\x75\x70\x74\x2e\x00\x00' + \
|
||||
'\x00\x0d\x00\x14' + \
|
||||
'\x55\x6e\x6b\x6e\x6f\x77\x6e\x20' + \
|
||||
'\x72\x65\x61\x73\x6f\x6e\x2e\x00'
|
||||
self.buf += b'\x06\x00\x00\x90' + \
|
||||
b'\x00\x01\x00\x08\x10\x00\x00\x00' + \
|
||||
b'\x00\x02\x00\x10\x00\x00\x00\x04' + \
|
||||
b'\x00\x05\x00\x06\x00\x09\x00\x0b' + \
|
||||
b'\x00\x03\x00\x08\x00\x00\x13\x88' + \
|
||||
b'\x00\x04\x00\x04' + \
|
||||
b'\x00\x05\x00\x14' + \
|
||||
b'\x00\x0b\x00\x0e' + \
|
||||
b'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \
|
||||
b'\x00\x06\x00\x08\xff\x00\x00\x04' + \
|
||||
b'\x00\x07\x00\x04' + \
|
||||
b'\x00\x08\x00\x08\xff\xff\x00\x04' + \
|
||||
b'\x00\x09\x00\x08\x00\x01\xe2\x40' + \
|
||||
b'\x00\x0a\x00\x04' + \
|
||||
b'\x00\x0b\x00\x0c' + \
|
||||
b'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
b'\x00\x0c\x00\x13' + \
|
||||
b'\x4b\x65\x79\x20\x49\x6e\x74\x65' + \
|
||||
b'\x72\x72\x75\x70\x74\x2e\x00\x00' + \
|
||||
b'\x00\x0d\x00\x14' + \
|
||||
b'\x55\x6e\x6b\x6e\x6f\x77\x6e\x20' + \
|
||||
b'\x72\x65\x61\x73\x6f\x6e\x2e\x00'
|
||||
|
||||
def setUp_with_shutdown(self):
|
||||
self.flags = 0
|
||||
@ -303,7 +303,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x07\x00\x00\x08\x00\x01\xe2\x40'
|
||||
self.buf += b'\x07\x00\x00\x08\x00\x01\xe2\x40'
|
||||
|
||||
def setUp_with_shutdown_ack(self):
|
||||
self.flags = 0
|
||||
@ -317,7 +317,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x08\x00\x00\x04'
|
||||
self.buf += b'\x08\x00\x00\x04'
|
||||
|
||||
def setUp_with_error(self):
|
||||
self.flags = 0
|
||||
@ -328,23 +328,23 @@ class Test_sctp(unittest.TestCase):
|
||||
self.c_missing_param = sctp.cause_missing_param(
|
||||
[sctp.PTYPE_IPV4, sctp.PTYPE_IPV6,
|
||||
sctp.PTYPE_COOKIE_PRESERVE, sctp.PTYPE_HOST_ADDR])
|
||||
self.c_stale_cookie = sctp.cause_stale_cookie('\x00\x00\x13\x88')
|
||||
self.c_stale_cookie = sctp.cause_stale_cookie(b'\x00\x00\x13\x88')
|
||||
self.c_out_of_resource = sctp.cause_out_of_resource()
|
||||
self.c_unresolvable_addr = sctp.cause_unresolvable_addr(
|
||||
sctp.param_host_addr('test host\x00'))
|
||||
sctp.param_host_addr(b'test host\x00'))
|
||||
self.c_unrecognized_chunk = sctp.cause_unrecognized_chunk(
|
||||
'\xff\x00\x00\x04')
|
||||
b'\xff\x00\x00\x04')
|
||||
self.c_invalid_param = sctp.cause_invalid_param()
|
||||
self.c_unrecognized_param = sctp.cause_unrecognized_param(
|
||||
'\xff\xff\x00\x04')
|
||||
self.c_no_userdata = sctp.cause_no_userdata('\x00\x01\xe2\x40')
|
||||
b'\xff\xff\x00\x04')
|
||||
self.c_no_userdata = sctp.cause_no_userdata(b'\x00\x01\xe2\x40')
|
||||
self.c_cookie_while_shutdown = sctp.cause_cookie_while_shutdown()
|
||||
self.c_restart_with_new_addr = sctp.cause_restart_with_new_addr(
|
||||
sctp.param_ipv4('192.168.1.1'))
|
||||
self.c_user_initiated_abort = sctp.cause_user_initiated_abort(
|
||||
'Key Interrupt.\x00')
|
||||
b'Key Interrupt.\x00')
|
||||
self.c_protocol_violation = sctp.cause_protocol_violation(
|
||||
'Unknown reason.\x00')
|
||||
b'Unknown reason.\x00')
|
||||
|
||||
self.causes = [
|
||||
self.c_invalid_stream_id, self.c_missing_param,
|
||||
@ -363,33 +363,33 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x09\x00\x00\x90' + \
|
||||
'\x00\x01\x00\x08\x10\x00\x00\x00' + \
|
||||
'\x00\x02\x00\x10\x00\x00\x00\x04' + \
|
||||
'\x00\x05\x00\x06\x00\x09\x00\x0b' + \
|
||||
'\x00\x03\x00\x08\x00\x00\x13\x88' + \
|
||||
'\x00\x04\x00\x04' + \
|
||||
'\x00\x05\x00\x14' + \
|
||||
'\x00\x0b\x00\x0e' + \
|
||||
'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \
|
||||
'\x00\x06\x00\x08\xff\x00\x00\x04' + \
|
||||
'\x00\x07\x00\x04' + \
|
||||
'\x00\x08\x00\x08\xff\xff\x00\x04' + \
|
||||
'\x00\x09\x00\x08\x00\x01\xe2\x40' + \
|
||||
'\x00\x0a\x00\x04' + \
|
||||
'\x00\x0b\x00\x0c' + \
|
||||
'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
'\x00\x0c\x00\x13' + \
|
||||
'\x4b\x65\x79\x20\x49\x6e\x74\x65' + \
|
||||
'\x72\x72\x75\x70\x74\x2e\x00\x00' + \
|
||||
'\x00\x0d\x00\x14' + \
|
||||
'\x55\x6e\x6b\x6e\x6f\x77\x6e\x20' + \
|
||||
'\x72\x65\x61\x73\x6f\x6e\x2e\x00'
|
||||
self.buf += b'\x09\x00\x00\x90' + \
|
||||
b'\x00\x01\x00\x08\x10\x00\x00\x00' + \
|
||||
b'\x00\x02\x00\x10\x00\x00\x00\x04' + \
|
||||
b'\x00\x05\x00\x06\x00\x09\x00\x0b' + \
|
||||
b'\x00\x03\x00\x08\x00\x00\x13\x88' + \
|
||||
b'\x00\x04\x00\x04' + \
|
||||
b'\x00\x05\x00\x14' + \
|
||||
b'\x00\x0b\x00\x0e' + \
|
||||
b'\x74\x65\x73\x74\x20\x68\x6f\x73\x74\x00\x00\x00' + \
|
||||
b'\x00\x06\x00\x08\xff\x00\x00\x04' + \
|
||||
b'\x00\x07\x00\x04' + \
|
||||
b'\x00\x08\x00\x08\xff\xff\x00\x04' + \
|
||||
b'\x00\x09\x00\x08\x00\x01\xe2\x40' + \
|
||||
b'\x00\x0a\x00\x04' + \
|
||||
b'\x00\x0b\x00\x0c' + \
|
||||
b'\x00\x05\x00\x08\xc0\xa8\x01\x01' + \
|
||||
b'\x00\x0c\x00\x13' + \
|
||||
b'\x4b\x65\x79\x20\x49\x6e\x74\x65' + \
|
||||
b'\x72\x72\x75\x70\x74\x2e\x00\x00' + \
|
||||
b'\x00\x0d\x00\x14' + \
|
||||
b'\x55\x6e\x6b\x6e\x6f\x77\x6e\x20' + \
|
||||
b'\x72\x65\x61\x73\x6f\x6e\x2e\x00'
|
||||
|
||||
def setUp_with_cookie_echo(self):
|
||||
self.flags = 0
|
||||
self.length = 8
|
||||
self.cookie = '\x12\x34\x56\x78'
|
||||
self.cookie = b'\x12\x34\x56\x78'
|
||||
|
||||
self.cookie_echo = sctp.chunk_cookie_echo(cookie=self.cookie)
|
||||
|
||||
@ -399,7 +399,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x0a\x00\x00\x08\x12\x34\x56\x78'
|
||||
self.buf += b'\x0a\x00\x00\x08\x12\x34\x56\x78'
|
||||
|
||||
def setUp_with_cookie_ack(self):
|
||||
self.flags = 0
|
||||
@ -413,7 +413,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x0b\x00\x00\x04'
|
||||
self.buf += b'\x0b\x00\x00\x04'
|
||||
|
||||
def setUp_with_ecn_echo(self):
|
||||
self.flags = 0
|
||||
@ -428,7 +428,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x0c\x00\x00\x08\x00\x01\xe2\x40'
|
||||
self.buf += b'\x0c\x00\x00\x08\x00\x01\xe2\x40'
|
||||
|
||||
def setUp_with_cwr(self):
|
||||
self.flags = 0
|
||||
@ -443,7 +443,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x0d\x00\x00\x08\x00\x01\xe2\x40'
|
||||
self.buf += b'\x0d\x00\x00\x08\x00\x01\xe2\x40'
|
||||
|
||||
def setUp_with_shutdown_complete(self):
|
||||
self.tflag = 0
|
||||
@ -457,7 +457,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x0e\x00\x00\x04'
|
||||
self.buf += b'\x0e\x00\x00\x04'
|
||||
|
||||
def setUp_with_multi_chunks(self):
|
||||
self.s_flags = 0
|
||||
@ -480,7 +480,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.d1_sid = 1
|
||||
self.d1_seq = 0
|
||||
self.d1_payload_id = 0
|
||||
self.d1_payload_data = '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
|
||||
self.d1_payload_data = b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a'
|
||||
|
||||
self.data1 = sctp.chunk_data(
|
||||
begin=self.d1_begin, tsn=self.d1_tsn, sid=self.d1_sid,
|
||||
@ -494,7 +494,7 @@ class Test_sctp(unittest.TestCase):
|
||||
self.d2_sid = 1
|
||||
self.d2_seq = 1
|
||||
self.d2_payload_id = 0
|
||||
self.d2_payload_data = '\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a'
|
||||
self.d2_payload_data = b'\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a'
|
||||
|
||||
self.data2 = sctp.chunk_data(
|
||||
end=self.d2_end, tsn=self.d2_tsn, sid=self.d2_sid,
|
||||
@ -506,12 +506,12 @@ class Test_sctp(unittest.TestCase):
|
||||
self.src_port, self.dst_port, self.vtag, self.csum,
|
||||
self.chunks)
|
||||
|
||||
self.buf += '\x03\x00\x00\x10\x00\x01\xe2\x40' + \
|
||||
'\x00\x00\x26\x94\x00\x00\x00\x00' + \
|
||||
'\x00\x02\x00\x1a\x00\x00\x30\x39\x00\x01\x00\x00' + \
|
||||
'\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a' + \
|
||||
'\x00\x01\x00\x1a\x00\x00\x30\x3a\x00\x01\x00\x01' + \
|
||||
'\x00\x00\x00\x00\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a'
|
||||
self.buf += b'\x03\x00\x00\x10\x00\x01\xe2\x40' + \
|
||||
b'\x00\x00\x26\x94\x00\x00\x00\x00' + \
|
||||
b'\x00\x02\x00\x1a\x00\x00\x30\x39\x00\x01\x00\x00' + \
|
||||
b'\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a' + \
|
||||
b'\x00\x01\x00\x1a\x00\x00\x30\x3a\x00\x01\x00\x01' + \
|
||||
b'\x00\x00\x00\x00\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a'
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
@ -740,7 +740,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res5 = struct.unpack_from(sctp.param_host_addr._PACK_STR, buf)
|
||||
eq_(sctp.param_host_addr.param_type(), res5[0])
|
||||
eq_(14, res5[1])
|
||||
eq_('test host\x00',
|
||||
eq_(b'test host\x00',
|
||||
buf[sctp.param_host_addr._MIN_LEN:
|
||||
sctp.param_host_addr._MIN_LEN + 10])
|
||||
|
||||
@ -780,7 +780,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res1 = struct.unpack_from(sctp.param_state_cookie._PACK_STR, buf)
|
||||
eq_(sctp.param_state_cookie.param_type(), res1[0])
|
||||
eq_(7, res1[1])
|
||||
eq_('\x01\x02\x03',
|
||||
eq_(b'\x01\x02\x03',
|
||||
buf[sctp.param_state_cookie._MIN_LEN:
|
||||
sctp.param_state_cookie._MIN_LEN + 3])
|
||||
|
||||
@ -803,7 +803,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.param_unrecognized_param._PACK_STR, buf)
|
||||
eq_(sctp.param_unrecognized_param.param_type(), res4[0])
|
||||
eq_(8, res4[1])
|
||||
eq_('\xff\xff\x00\x04',
|
||||
eq_(b'\xff\xff\x00\x04',
|
||||
buf[sctp.param_unrecognized_param._MIN_LEN:
|
||||
sctp.param_unrecognized_param._MIN_LEN + 4])
|
||||
|
||||
@ -816,7 +816,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res6 = struct.unpack_from(sctp.param_host_addr._PACK_STR, buf)
|
||||
eq_(sctp.param_host_addr.param_type(), res6[0])
|
||||
eq_(14, res6[1])
|
||||
eq_('test host\x00',
|
||||
eq_(b'test host\x00',
|
||||
buf[sctp.param_host_addr._MIN_LEN:
|
||||
sctp.param_host_addr._MIN_LEN + 10])
|
||||
|
||||
@ -861,7 +861,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res1 = struct.unpack_from(sctp.param_heartbeat._PACK_STR, buf)
|
||||
eq_(sctp.param_heartbeat.param_type(), res1[0])
|
||||
eq_(8, res1[1])
|
||||
eq_('\x01\x02\x03\x04',
|
||||
eq_(b'\x01\x02\x03\x04',
|
||||
buf[sctp.param_heartbeat._MIN_LEN:
|
||||
sctp.param_heartbeat._MIN_LEN + 4])
|
||||
|
||||
@ -877,7 +877,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res1 = struct.unpack_from(sctp.param_heartbeat._PACK_STR, buf)
|
||||
eq_(sctp.param_heartbeat.param_type(), res1[0])
|
||||
eq_(12, res1[1])
|
||||
eq_('\xff\xee\xdd\xcc\xbb\xaa\x99\x88',
|
||||
eq_(b'\xff\xee\xdd\xcc\xbb\xaa\x99\x88',
|
||||
buf[sctp.param_heartbeat._MIN_LEN:
|
||||
sctp.param_heartbeat._MIN_LEN + 8])
|
||||
|
||||
@ -914,7 +914,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res3 = struct.unpack_from(sctp.cause_stale_cookie._PACK_STR, buf)
|
||||
eq_(sctp.cause_stale_cookie.cause_code(), res3[0])
|
||||
eq_(8, res3[1])
|
||||
eq_('\x00\x00\x13\x88',
|
||||
eq_(b'\x00\x00\x13\x88',
|
||||
buf[sctp.cause_stale_cookie._MIN_LEN:
|
||||
sctp.cause_stale_cookie._MIN_LEN + 4])
|
||||
|
||||
@ -928,8 +928,8 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_unresolvable_addr._PACK_STR, buf)
|
||||
eq_(sctp.cause_unresolvable_addr.cause_code(), res5[0])
|
||||
eq_(20, res5[1])
|
||||
eq_('\x00\x0b\x00\x0e\x74\x65\x73\x74' +
|
||||
'\x20\x68\x6f\x73\x74\x00\x00\x00',
|
||||
eq_(b'\x00\x0b\x00\x0e\x74\x65\x73\x74' +
|
||||
b'\x20\x68\x6f\x73\x74\x00\x00\x00',
|
||||
buf[sctp.cause_unresolvable_addr._MIN_LEN:
|
||||
sctp.cause_unresolvable_addr._MIN_LEN + 16])
|
||||
|
||||
@ -938,7 +938,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_unrecognized_chunk._PACK_STR, buf)
|
||||
eq_(sctp.cause_unrecognized_chunk.cause_code(), res6[0])
|
||||
eq_(8, res6[1])
|
||||
eq_('\xff\x00\x00\x04',
|
||||
eq_(b'\xff\x00\x00\x04',
|
||||
buf[sctp.cause_unrecognized_chunk._MIN_LEN:
|
||||
sctp.cause_unrecognized_chunk._MIN_LEN + 4])
|
||||
|
||||
@ -952,7 +952,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_unrecognized_param._PACK_STR, buf)
|
||||
eq_(sctp.cause_unrecognized_param.cause_code(), res8[0])
|
||||
eq_(8, res8[1])
|
||||
eq_('\xff\xff\x00\x04',
|
||||
eq_(b'\xff\xff\x00\x04',
|
||||
buf[sctp.cause_unrecognized_param._MIN_LEN:
|
||||
sctp.cause_unrecognized_param._MIN_LEN + 4])
|
||||
|
||||
@ -960,7 +960,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res9 = struct.unpack_from(sctp.cause_no_userdata._PACK_STR, buf)
|
||||
eq_(sctp.cause_no_userdata.cause_code(), res9[0])
|
||||
eq_(8, res9[1])
|
||||
eq_('\x00\x01\xe2\x40',
|
||||
eq_(b'\x00\x01\xe2\x40',
|
||||
buf[sctp.cause_no_userdata._MIN_LEN:
|
||||
sctp.cause_no_userdata._MIN_LEN + 4])
|
||||
|
||||
@ -975,7 +975,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_restart_with_new_addr._PACK_STR, buf)
|
||||
eq_(sctp.cause_restart_with_new_addr.cause_code(), res11[0])
|
||||
eq_(12, res11[1])
|
||||
eq_('\x00\x05\x00\x08\xc0\xa8\x01\x01',
|
||||
eq_(b'\x00\x05\x00\x08\xc0\xa8\x01\x01',
|
||||
buf[sctp.cause_restart_with_new_addr._MIN_LEN:
|
||||
sctp.cause_restart_with_new_addr._MIN_LEN + 8])
|
||||
|
||||
@ -984,7 +984,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_user_initiated_abort._PACK_STR, buf)
|
||||
eq_(sctp.cause_user_initiated_abort.cause_code(), res12[0])
|
||||
eq_(19, res12[1])
|
||||
eq_('Key Interrupt.\x00',
|
||||
eq_(b'Key Interrupt.\x00',
|
||||
buf[sctp.cause_user_initiated_abort._MIN_LEN:
|
||||
sctp.cause_user_initiated_abort._MIN_LEN + 15])
|
||||
|
||||
@ -993,7 +993,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_protocol_violation._PACK_STR, buf)
|
||||
eq_(sctp.cause_protocol_violation.cause_code(), res13[0])
|
||||
eq_(20, res13[1])
|
||||
eq_('Unknown reason.\x00',
|
||||
eq_(b'Unknown reason.\x00',
|
||||
buf[sctp.cause_protocol_violation._MIN_LEN:
|
||||
sctp.cause_protocol_violation._MIN_LEN + 16])
|
||||
|
||||
@ -1046,7 +1046,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res3 = struct.unpack_from(sctp.cause_stale_cookie._PACK_STR, buf)
|
||||
eq_(sctp.cause_stale_cookie.cause_code(), res3[0])
|
||||
eq_(8, res3[1])
|
||||
eq_('\x00\x00\x13\x88',
|
||||
eq_(b'\x00\x00\x13\x88',
|
||||
buf[sctp.cause_stale_cookie._MIN_LEN:
|
||||
sctp.cause_stale_cookie._MIN_LEN + 4])
|
||||
|
||||
@ -1060,8 +1060,8 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_unresolvable_addr._PACK_STR, buf)
|
||||
eq_(sctp.cause_unresolvable_addr.cause_code(), res5[0])
|
||||
eq_(20, res5[1])
|
||||
eq_('\x00\x0b\x00\x0e\x74\x65\x73\x74' +
|
||||
'\x20\x68\x6f\x73\x74\x00\x00\x00',
|
||||
eq_(b'\x00\x0b\x00\x0e\x74\x65\x73\x74' +
|
||||
b'\x20\x68\x6f\x73\x74\x00\x00\x00',
|
||||
buf[sctp.cause_unresolvable_addr._MIN_LEN:
|
||||
sctp.cause_unresolvable_addr._MIN_LEN + 16])
|
||||
|
||||
@ -1070,7 +1070,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_unrecognized_chunk._PACK_STR, buf)
|
||||
eq_(sctp.cause_unrecognized_chunk.cause_code(), res6[0])
|
||||
eq_(8, res6[1])
|
||||
eq_('\xff\x00\x00\x04',
|
||||
eq_(b'\xff\x00\x00\x04',
|
||||
buf[sctp.cause_unrecognized_chunk._MIN_LEN:
|
||||
sctp.cause_unrecognized_chunk._MIN_LEN + 4])
|
||||
|
||||
@ -1084,7 +1084,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_unrecognized_param._PACK_STR, buf)
|
||||
eq_(sctp.cause_unrecognized_param.cause_code(), res8[0])
|
||||
eq_(8, res8[1])
|
||||
eq_('\xff\xff\x00\x04',
|
||||
eq_(b'\xff\xff\x00\x04',
|
||||
buf[sctp.cause_unrecognized_param._MIN_LEN:
|
||||
sctp.cause_unrecognized_param._MIN_LEN + 4])
|
||||
|
||||
@ -1092,7 +1092,7 @@ class Test_sctp(unittest.TestCase):
|
||||
res9 = struct.unpack_from(sctp.cause_no_userdata._PACK_STR, buf)
|
||||
eq_(sctp.cause_no_userdata.cause_code(), res9[0])
|
||||
eq_(8, res9[1])
|
||||
eq_('\x00\x01\xe2\x40',
|
||||
eq_(b'\x00\x01\xe2\x40',
|
||||
buf[sctp.cause_no_userdata._MIN_LEN:
|
||||
sctp.cause_no_userdata._MIN_LEN + 4])
|
||||
|
||||
@ -1107,7 +1107,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_restart_with_new_addr._PACK_STR, buf)
|
||||
eq_(sctp.cause_restart_with_new_addr.cause_code(), res11[0])
|
||||
eq_(12, res11[1])
|
||||
eq_('\x00\x05\x00\x08\xc0\xa8\x01\x01',
|
||||
eq_(b'\x00\x05\x00\x08\xc0\xa8\x01\x01',
|
||||
buf[sctp.cause_restart_with_new_addr._MIN_LEN:
|
||||
sctp.cause_restart_with_new_addr._MIN_LEN + 8])
|
||||
|
||||
@ -1116,7 +1116,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_user_initiated_abort._PACK_STR, buf)
|
||||
eq_(sctp.cause_user_initiated_abort.cause_code(), res12[0])
|
||||
eq_(19, res12[1])
|
||||
eq_('Key Interrupt.\x00',
|
||||
eq_(b'Key Interrupt.\x00',
|
||||
buf[sctp.cause_user_initiated_abort._MIN_LEN:
|
||||
sctp.cause_user_initiated_abort._MIN_LEN + 15])
|
||||
|
||||
@ -1125,7 +1125,7 @@ class Test_sctp(unittest.TestCase):
|
||||
sctp.cause_protocol_violation._PACK_STR, buf)
|
||||
eq_(sctp.cause_protocol_violation.cause_code(), res13[0])
|
||||
eq_(20, res13[1])
|
||||
eq_('Unknown reason.\x00',
|
||||
eq_(b'Unknown reason.\x00',
|
||||
buf[sctp.cause_protocol_violation._MIN_LEN:
|
||||
sctp.cause_protocol_violation._MIN_LEN + 16])
|
||||
|
||||
|
@ -150,7 +150,7 @@ class Test_slow(unittest.TestCase):
|
||||
assert None != last
|
||||
|
||||
def test_invalid_subtype(self):
|
||||
invalid_buf = "\xff" + self.buf[1:]
|
||||
invalid_buf = b'\xff' + self.buf[1:]
|
||||
(instance, nexttype, last) = slow.parser(invalid_buf)
|
||||
assert None == instance
|
||||
assert None == nexttype
|
||||
|
@ -43,7 +43,7 @@ class Test_tcp(unittest.TestCase):
|
||||
window_size = 2048
|
||||
csum = 12345
|
||||
urgent = 128
|
||||
option = '\x01\x02\x03\x04'
|
||||
option = b'\x01\x02\x03\x04'
|
||||
|
||||
t = tcp(src_port, dst_port, seq, ack, offset, bits,
|
||||
window_size, csum, urgent, option)
|
||||
@ -119,7 +119,7 @@ class Test_tcp(unittest.TestCase):
|
||||
def test_serialize_option(self):
|
||||
offset = 6
|
||||
csum = 0
|
||||
option = '\x01\x02'
|
||||
option = b'\x01\x02'
|
||||
|
||||
src_ip = '192.168.10.1'
|
||||
dst_ip = '192.168.100.1'
|
||||
@ -154,7 +154,7 @@ class Test_tcp(unittest.TestCase):
|
||||
eq_(res[8], 0)
|
||||
|
||||
# with option, without offset
|
||||
t = tcp(option='\x01\x02\x03')
|
||||
t = tcp(option=b'\x01\x02\x03')
|
||||
buf = t.serialize(bytearray(), prev)
|
||||
res = struct.unpack(tcp._PACK_STR + '4s', buf)
|
||||
|
||||
@ -166,10 +166,10 @@ class Test_tcp(unittest.TestCase):
|
||||
eq_(res[5], 0)
|
||||
eq_(res[6], 0)
|
||||
eq_(res[8], 0)
|
||||
eq_(res[9], '\x01\x02\x03\x00')
|
||||
eq_(res[9], b'\x01\x02\x03\x00')
|
||||
|
||||
# with option, with long offset
|
||||
t = tcp(offset=7, option='\x01\x02\x03')
|
||||
t = tcp(offset=7, option=b'\x01\x02\x03')
|
||||
buf = t.serialize(bytearray(), prev)
|
||||
res = struct.unpack(tcp._PACK_STR + '8s', buf)
|
||||
|
||||
@ -181,7 +181,7 @@ class Test_tcp(unittest.TestCase):
|
||||
eq_(res[5], 0)
|
||||
eq_(res[6], 0)
|
||||
eq_(res[8], 0)
|
||||
eq_(res[9], '\x01\x02\x03\x00\x00\x00\x00\x00')
|
||||
eq_(res[9], b'\x01\x02\x03\x00\x00\x00\x00\x00')
|
||||
|
||||
def test_json(self):
|
||||
jsondict = self.t.to_jsondict()
|
||||
|
Loading…
Reference in New Issue
Block a user