hpimdm/tree/KernelEntry.py
def new_interface(self, index):
        """
        New interface with VIF index added
        """
        print("NEW_INTERFACE ANTES")
        with self.CHANGE_STATE_LOCK:
            print("NEW_INTERFACE DEPOIS")
            if index in self.interface_state:
                return

            (_, _, _, inbound_interface_index) = UnicastRouting.get_unicast_info(self.source_ip)
            # TODO verificar is directly connected

            interest_state = False
            upstream_state = None
            self._interest_interface_state[index] = interest_state
            self._upstream_interface_state[index] = upstream_state

            # new interface is of type non-root
            if inbound_interface_index != index:
                self.interface_state[index] = TreeInterfaceNonRoot(self, index, self._rpc,
                                                                   best_upstream_router=upstream_state,
                                                                   interest_state=interest_state,
                                                                   was_root=False,
                                                                   previous_tree_state=self._tree_state,
                                                                   current_tree_state=self._tree_state)
            # new interface is of type root and there wasnt any root interface previously configured
            elif inbound_interface_index == index and self.inbound_interface_index is None:
                self.inbound_interface_index = index
                self.interface_state[index] = TreeInterfaceRoot(self, self.inbound_interface_index,
                                                                upstream_state, was_non_root=False,
                                                                previous_tree_state=self._tree_state,
                                                                current_tree_state=self._tree_state)
            # new interface is of type root and there was a root interface previously configured
            elif inbound_interface_index == index and self.inbound_interface_index is not None:
                old_upstream_interface = self.interface_state.get(self.inbound_interface_index, None)

                root_upstream_state = upstream_state
                non_root_interest_state = self._interest_interface_state.get(self.inbound_interface_index, False)
                non_root_upstream_state = self._upstream_interface_state.get(self.inbound_interface_index, None)

                new_tree_state = self._tree_state
                if self.is_tree_active() and root_upstream_state is None:
                    new_tree_state = TreeState.Unsure

                # change type of interfaces
                if self.inbound_interface_index is not None:
                    new_downstream_interface = TreeInterfaceNonRoot(self, self.inbound_interface_index, self._rpc,
                                                                    non_root_upstream_state, non_root_interest_state,
                                                                    was_root=True,
                                                                    previous_tree_state=self._tree_state,
                                                                    current_tree_state=new_tree_state)
                    self.interface_state[self.inbound_interface_index] = new_downstream_interface
                if inbound_interface_index is not None:
                    new_upstream_interface = TreeInterfaceRoot(self, inbound_interface_index, root_upstream_state,
                                                               was_non_root=True,
                                                               previous_tree_state=self._tree_state,
                                                               current_tree_state=new_tree_state)
                    self.interface_state[inbound_interface_index] = new_upstream_interface
                self.inbound_interface_index = inbound_interface_index

                # remove old interfaces
                if old_upstream_interface is not None:
                    old_upstream_interface.delete()

            self.change()
            self.evaluate_in_tree_change()
            self.check_tree_state()

        New interface with VIF index added
        
New interface with VIF index added
New interface with VIF index added
def new_interface(self, index):
        print("NEW_INTERFACE ANTES")
        with self.CHANGE_STATE_LOCK:
            print("NEW_INTERFACE DEPOIS")
            if index in self.interface_state:
                return
            (_, _, _, inbound_interface_index) = UnicastRouting.get_unicast_info(self.source_ip)
            interest_state = False
            upstream_state = None
            self._interest_interface_state[index] = interest_state
            self._upstream_interface_state[index] = upstream_state
            if inbound_interface_index != index:
                self.interface_state[index] = TreeInterfaceNonRoot(self, index, self._rpc,
                                                                   best_upstream_router=upstream_state,
                                                                   interest_state=interest_state,
                                                                   was_root=False,
                                                                   previous_tree_state=self._tree_state,
                                                                   current_tree_state=self._tree_state)
            elif inbound_interface_index == index and self.inbound_interface_index is None:
                self.inbound_interface_index = index
                self.interface_state[index] = TreeInterfaceRoot(self, self.inbound_interface_index,
                                                                upstream_state, was_non_root=False,
                                                                previous_tree_state=self._tree_state,
                                                                current_tree_state=self._tree_state)
            elif inbound_interface_index == index and self.inbound_interface_index is not None:
                old_upstream_interface = self.interface_state.get(self.inbound_interface_index, None)
                root_upstream_state = upstream_state
                non_root_interest_state = self._interest_interface_state.get(self.inbound_interface_index, False)
                non_root_upstream_state = self._upstream_interface_state.get(self.inbound_interface_index, None)
                new_tree_state = self._tree_state
                if self.is_tree_active() and root_upstream_state is None:
                    new_tree_state = TreeState.Unsure
                if self.inbound_interface_index is not None:
                    new_downstream_interface = TreeInterfaceNonRoot(self, self.inbound_interface_index, self._rpc,
                                                                    non_root_upstream_state, non_root_interest_state,
                                                                    was_root=True,
                                                                    previous_tree_state=self._tree_state,
                                                                    current_tree_state=new_tree_state)
                    self.interface_state[self.inbound_interface_index] = new_downstream_interface
                if inbound_interface_index is not None:
                    new_upstream_interface = TreeInterfaceRoot(self, inbound_interface_index, root_upstream_state,
                                                               was_non_root=True,
                                                               previous_tree_state=self._tree_state,
                                                               current_tree_state=new_tree_state)
                    self.interface_state[inbound_interface_index] = new_upstream_interface
                self.inbound_interface_index = inbound_interface_index
                if old_upstream_interface is not None:
                    old_upstream_interface.delete()
            self.change()
            self.evaluate_in_tree_change()
            self.check_tree_state()
def new_interface ( self , index ) : print ( "NEW_INTERFACE ANTES" ) with self . CHANGE_STATE_LOCK : print ( "NEW_INTERFACE DEPOIS" ) if index in self . interface_state : return ( _ , _ , _ , inbound_interface_index ) = UnicastRouting . get_unicast_info ( self . source_ip ) interest_state = False upstream_state = None self . _interest_interface_state [ index ] = interest_state self . _upstream_interface_state [ index ] = upstream_state if inbound_interface_index != index : self . interface_state [ index ] = TreeInterfaceNonRoot ( self , index , self . _rpc , best_upstream_router = upstream_state , interest_state = interest_state , was_root = False , previous_tree_state = self . _tree_state , current_tree_state = self . _tree_state ) elif inbound_interface_index == index and self . inbound_interface_index is None : self . inbound_interface_index = index self . interface_state [ index ] = TreeInterfaceRoot ( self , self . inbound_interface_index , upstream_state , was_non_root = False , previous_tree_state = self . _tree_state , current_tree_state = self . _tree_state ) elif inbound_interface_index == index and self . inbound_interface_index is not None : old_upstream_interface = self . interface_state . get ( self . inbound_interface_index , None ) root_upstream_state = upstream_state non_root_interest_state = self . _interest_interface_state . get ( self . inbound_interface_index , False ) non_root_upstream_state = self . _upstream_interface_state . get ( self . inbound_interface_index , None ) new_tree_state = self . _tree_state if self . is_tree_active ( ) and root_upstream_state is None : new_tree_state = TreeState . Unsure if self . inbound_interface_index is not None : new_downstream_interface = TreeInterfaceNonRoot ( self , self . inbound_interface_index , self . _rpc , non_root_upstream_state , non_root_interest_state , was_root = True , previous_tree_state = self . _tree_state , current_tree_state = new_tree_state ) self . interface_state [ self . inbound_interface_index ] = new_downstream_interface if inbound_interface_index is not None : new_upstream_interface = TreeInterfaceRoot ( self , inbound_interface_index , root_upstream_state , was_non_root = True , previous_tree_state = self . _tree_state , current_tree_state = new_tree_state ) self . interface_state [ inbound_interface_index ] = new_upstream_interface self . inbound_interface_index = inbound_interface_index if old_upstream_interface is not None : old_upstream_interface . delete ( ) self . change ( ) self . evaluate_in_tree_change ( ) self . check_tree_state ( )
New interface with VIF index added
New interface with VIF index added
"""
        New interface with VIF index added
        """ # TODO verificar is directly connected # new interface is of type non-root # new interface is of type root and there wasnt any root interface previously configured # new interface is of type root and there was a root interface previously configured # change type of interfaces # remove old interfaces
self
index