Beispiel #1
0
    def test_ipv6_to_str_from_bin(self):
        ipv6_bin = struct.pack('!8H', 0x2013, 0xda8, 0x215, 0x8f2, 0xaa20,
                               0x66ff, 0xfe4c, 0x9c3c)
        val = '2013:da8:215:8f2:aa20:66ff:fe4c:9c3c'

        res = ip.ipv6_to_str(ipv6_bin)
        eq_(val, res)
Beispiel #2
0
    def test_to_string(self):
        ipv6_values = {'version': self.version,
                       'traffic_class': self.traffic_class,
                       'flow_label': self.flow_label,
                       'payload_length': self.payload_length,
                       'nxt': self.nxt,
                       'hop_limit': self.hop_limit,
                       'src': ip.ipv6_to_str(self.src),
                       'dst': ip.ipv6_to_str(self.dst)}
        _ipv6_str = ','.join(['%s=%s' % (k, repr(ipv6_values[k]))
                              for k, v in inspect.getmembers(self.ip)
                              if k in ipv6_values])
        ipv6_str = '%s(%s)' % (ipv6.ipv6.__name__, _ipv6_str)

        eq_(str(self.ip), ipv6_str)
        eq_(repr(self.ip), ipv6_str)
Beispiel #3
0
    def test_ipv6_to_str_from_bin(self):
        ipv6_bin = struct.pack('!8H', 0x2013, 0xda8, 0x215, 0x8f2, 0xaa20,
                               0x66ff, 0xfe4c, 0x9c3c)
        val = '2013:da8:215:8f2:aa20:66ff:fe4c:9c3c'

        res = ip.ipv6_to_str(ipv6_bin)
        eq_(val, res)
Beispiel #4
0
    def test_to_string(self):
        nd_opt = icmpv6.nd_option_la(self.nd_hw_src)
        nd = icmpv6.nd_neighbor(
            self.res, self.dst, self.nd_type, self.nd_length, nd_opt)
        ic = icmpv6.icmpv6(self.type_, self.code, self.csum, nd)

        nd_opt_values = {'hw_src': haddr_to_str(self.nd_hw_src),
                         'data': None}
        _nd_opt_str = ','.join(['%s=%s' % (k, repr(nd_opt_values[k]))
                                for k, v in inspect.getmembers(nd_opt)
                                if k in nd_opt_values])
        nd_opt_str = '%s(%s)' % (icmpv6.nd_option_la.__name__, _nd_opt_str)

        nd_values = {'res': repr(nd.res),
                     'dst': repr(ipv6_to_str(self.dst)),
                     'type_': repr(self.nd_type),
                     'length': repr(self.nd_length),
                     'data': nd_opt_str}
        _nd_str = ','.join(['%s=%s' % (k, nd_values[k])
                            for k, v in inspect.getmembers(nd)
                            if k in nd_values])
        nd_str = '%s(%s)' % (icmpv6.nd_neighbor.__name__, _nd_str)

        icmp_values = {'type_': repr(self.type_),
                       'code': repr(self.code),
                       'csum': repr('0x%x' % self.csum),
                       'data': nd_str}
        _ic_str = ','.join(['%s=%s' % (k, icmp_values[k])
                            for k, v in inspect.getmembers(ic)
                            if k in icmp_values])
        ic_str = '%s(%s)' % (icmpv6.icmpv6.__name__, _ic_str)

        eq_(str(ic), ic_str)
        eq_(repr(ic), ic_str)
Beispiel #5
0
    def test_ipv6_to_str_from_int(self):
        ipv6_int = 0x20130da8021508f2aa2066fffe4c9c3c
        val = '2013:da8:215:8f2:aa20:66ff:fe4c:9c3c'

        res = ip.ipv6_to_str(ipv6_int)
        eq_(val, res)
Beispiel #6
0
    def test_ipv6_to_str_from_int(self):
        ipv6_int = 0x20130da8021508f2aa2066fffe4c9c3c
        val = '2013:da8:215:8f2:aa20:66ff:fe4c:9c3c'

        res = ip.ipv6_to_str(ipv6_int)
        eq_(val, res)