コード例 #1
0
ファイル: ph.py プロジェクト: dmohnani/PyTCP
    def perform_ipv6_nd_dad(self, ipv6_unicast_candidate):
        """ Perform IPv6 ND Duplicate Address Detection, return True if passed """

        self.logger.debug(f"ICMPv6 ND DAD - Starting process for {ipv6_unicast_candidate}")
        self.assign_ipv6_multicast(ipv6_solicited_node_multicast(ipv6_unicast_candidate))
        self.ipv6_unicast_candidate = ipv6_unicast_candidate
        self.send_icmpv6_nd_dad_message(ipv6_unicast_candidate)
        if event := self.event_icmpv6_nd_dad.acquire(timeout=1):
            self.logger.warning(f"ICMPv6 ND DAD - Duplicate IPv6 address detected, {ipv6_unicast_candidate} advertised by {self.icmpv6_nd_dad_tlla}")
コード例 #2
0
ファイル: icmpv6_nd_cache.py プロジェクト: dmohnani/PyTCP
 def __send_icmpv6_neighbor_solicitation(icmpv6_ns_target_address):
     """ Enqueue ICMPv6 Neighbor Solicitation packet with TX ring """
     stack.packet_handler.phtx_icmpv6(
         ipv6_src=IPv6Address(
             stack.packet_handler.stack_ipv6_unicast[0] if stack.
             packet_handler.stack_ipv6_unicast else "::"),
         ipv6_dst=ipv6_solicited_node_multicast(icmpv6_ns_target_address),
         ipv6_hop=255,
         icmpv6_type=ps_icmpv6.ICMP6_NEIGHBOR_SOLICITATION,
         icmpv6_ns_target_address=icmpv6_ns_target_address,
     )
コード例 #3
0
ファイル: ph.py プロジェクト: dmohnani/PyTCP
    def send_icmpv6_nd_dad_message(self, ipv6_unicast_candidate):
        """ Send out ICMPv6 ND Duplicate Address Detection message """

        self.phtx_icmpv6(
            ipv6_src=IPv6Address("::"),
            ipv6_dst=ipv6_solicited_node_multicast(ipv6_unicast_candidate),
            ipv6_hop=255,
            icmpv6_type=ps_icmpv6.ICMP6_NEIGHBOR_SOLICITATION,
            icmpv6_ns_target_address=ipv6_unicast_candidate,
        )
        self.logger.debug(f"Sent out ICMPv6 ND DAD message for {ipv6_unicast_candidate}")
コード例 #4
0
ファイル: ph.py プロジェクト: dmohnani/PyTCP
    def remove_ipv6_unicast(self, ipv6_unicast):
        """ Remove IPv6 unicast address from the list stack listens on """

        self.stack_ipv6_unicast.remove(ipv6_unicast)
        self.logger.debug(f"Removed IPv6 unicast {ipv6_unicast}")
        self.remove_ipv6_multicast(ipv6_solicited_node_multicast(ipv6_unicast))
コード例 #5
0
ファイル: ph.py プロジェクト: dmohnani/PyTCP
    def assign_ipv6_unicast(self, ipv6_unicast):
        """ Assign IPv6 unicast address to the list stack listens on """

        self.stack_ipv6_unicast.append(ipv6_unicast)
        self.logger.debug(f"Assigned IPv6 unicast {ipv6_unicast}")
        self.assign_ipv6_multicast(ipv6_solicited_node_multicast(ipv6_unicast))
コード例 #6
0
ファイル: ph.py プロジェクト: dmohnani/PyTCP
        while True:
            self.phrx_ether(stack.rx_ring.dequeue())

    def perform_ipv6_nd_dad(self, ipv6_unicast_candidate):
        """ Perform IPv6 ND Duplicate Address Detection, return True if passed """

        self.logger.debug(f"ICMPv6 ND DAD - Starting process for {ipv6_unicast_candidate}")
        self.assign_ipv6_multicast(ipv6_solicited_node_multicast(ipv6_unicast_candidate))
        self.ipv6_unicast_candidate = ipv6_unicast_candidate
        self.send_icmpv6_nd_dad_message(ipv6_unicast_candidate)
        if event := self.event_icmpv6_nd_dad.acquire(timeout=1):
            self.logger.warning(f"ICMPv6 ND DAD - Duplicate IPv6 address detected, {ipv6_unicast_candidate} advertised by {self.icmpv6_nd_dad_tlla}")
        else:
            self.logger.debug(f"ICMPv6 ND DAD - No duplicate address detected for {ipv6_unicast_candidate}")
        self.ipv6_unicast_candidate = None
        self.remove_ipv6_multicast(ipv6_solicited_node_multicast(ipv6_unicast_candidate))
        return not event

    def create_stack_ipv6_addressing(self):
        """ Create lists of IPv6 unicast and multicast addresses stack should listen on """

        # Check if there are any statically assigned link local addresses
        for ipv6_address_candidate in list(self.stack_ipv6_address_candidate):
            if (
                ipv6_address_candidate.ip.is_link_local
                and ipv6_address_candidate not in self.stack_ipv6_address
                and self.perform_ipv6_nd_dad(ipv6_address_candidate.ip)
            ):
                self.stack_ipv6_address_candidate.remove(ipv6_address_candidate)
                self.stack_ipv6_address.append(ipv6_address_candidate)
                self.assign_ipv6_unicast(ipv6_address_candidate.ip)