예제 #1
0
    def route_new(self, lvl, dst, gw, rem, event_wait=None):

        if not self.multipath and self.maproute.node_get(lvl, dst).nroutes_synced() >= 1:
                # We don't have multipath and we've already set one route.
                return

        nip = self.maproute.lvlid_to_nip(lvl, dst)
        ip  = self.maproute.nip_to_ip(nip)
        ipstr = ip_to_str(ip)
        neigh = self.neigh.id_to_neigh(gw)
        dev = neigh.bestdev[0]
        gwipstr = ip_to_str(neigh.ip)
        neigh_node = self.maproute.node_get(*self.maproute.routeneigh_get(neigh))

        if neigh_node.nroutes() > 1:
                # Let's wait to add the neighbour first
                while 1:
                        ev_neigh = event_wait[(self.neigh.events, 'NEIGH_NEW')]()
                        if neigh == ev_neigh[0]:
                                # found
                                break

        if neigh_node.routes_tobe_synced > 0:
                # The routes to neigh are still to be synced, let's wait
                while 1:
                        ev_neigh = event_wait[(self.events, 'KRNL_NEIGH_NEW')]()
                        if neigh == ev_neigh[0]:
                                # found
                                break

        # We can add the route in the kernel
        KRoute.add(ipstr, lvl_to_bits(lvl), dev, gwipstr)

        self.maproute.node_get(lvl, dst).routes_tobe_synced-=1
예제 #2
0
    def neigh_new(self, neigh):
        ipstr = ip_to_str(neigh.ip)
        dev = neigh.bestdev[0]
        gwipstr = ipstr

        KRoute.add(ipstr, lvl_to_bits(0), dev, gwipstr)

        self.events.send('KRNL_NEIGH_NEW', (neigh, ))
예제 #3
0
    def neigh_new(self, neigh):
        ipstr = ip_to_str(neigh.ip)
        dev = neigh.bestdev[0]
        gwipstr = ipstr

        KRoute.add(ipstr, lvl_to_bits(0), dev, gwipstr)

        self.events.send('KRNL_NEIGH_NEW', (neigh,))
예제 #4
0
    def route_deleted(self, lvl, dst, gw):
        nip = self.maproute.lvlid_to_nip(lvl, dst)
        ip = self.maproute.nip_to_ip(nip)
        ipstr = ip_to_str(ip)
        neigh = self.neigh.id_to_neigh(gw)
        dev = neigh.bestdev[0]
        gwipstr = ip_to_str(neigh.ip)

        KRoute.delete(ipstr, lvl_to_bits(lvl), gateway=gwipstr)
예제 #5
0
    def route_deleted(self, lvl, dst, gw):
        nip = self.maproute.lvlid_to_nip(lvl, dst)
        ip  = self.maproute.nip_to_ip(nip)
        ipstr = ip_to_str(ip)
        neigh = self.neigh.id_to_neigh(gw)
        dev = neigh.bestdev[0]
        gwipstr = ip_to_str(neigh.ip)

        KRoute.delete(ipstr, lvl_to_bits(lvl), gateway=gwipstr)
예제 #6
0
    def run(self):
        if not self.simulated:
            Route.ip_forward(enable=True)

            for nic in self.nic_manager:
                self.nic_manager[nic].filtering(enable=False)
                rpc.MicroUDPServer(self, ('', 269), nic, self.simnet, self.simme, self.simsock)

        rpc.MicroTCPServer(self, ('', 269), None, self.simnet, self.simme, self.simsock)


        self.radar.run()
        self.hook.hook()
예제 #7
0
파일: ntkd.py 프로젝트: unoffices/netsukuku
    def run(self):
        if not self.simulated:
            Route.ip_forward(enable=True)

            for nic in self.nic_manager:
                self.nic_manager[nic].filtering(enable=False)
                rpc.MicroUDPServer(self, ('', 269), nic, self.simnet,
                                   self.simme, self.simsock)

        rpc.MicroTCPServer(self, ('', 269), None, self.simnet, self.simme,
                           self.simsock)

        self.radar.run()
        self.hook.hook()
예제 #8
0
    def route_new(self, lvl, dst, gw, rem, event_wait=None):

        if not self.multipath and self.maproute.node_get(
                lvl, dst).nroutes_synced() >= 1:
            # We don't have multipath and we've already set one route.
            return

        nip = self.maproute.lvlid_to_nip(lvl, dst)
        ip = self.maproute.nip_to_ip(nip)
        ipstr = ip_to_str(ip)
        neigh = self.neigh.id_to_neigh(gw)
        dev = neigh.bestdev[0]
        gwipstr = ip_to_str(neigh.ip)
        neigh_node = self.maproute.node_get(
            *self.maproute.routeneigh_get(neigh))

        if neigh_node.nroutes() > 1:
            # Let's wait to add the neighbour first
            while 1:
                ev_neigh = event_wait[(self.neigh.events, 'NEIGH_NEW')]()
                if neigh == ev_neigh[0]:
                    # found
                    break

        if neigh_node.routes_tobe_synced > 0:
            # The routes to neigh are still to be synced, let's wait
            while 1:
                ev_neigh = event_wait[(self.events, 'KRNL_NEIGH_NEW')]()
                if neigh == ev_neigh[0]:
                    # found
                    break

        # We can add the route in the kernel
        KRoute.add(ipstr, lvl_to_bits(lvl), dev, gwipstr)

        self.maproute.node_get(lvl, dst).routes_tobe_synced -= 1
예제 #9
0
    def neigh_deleted(self, neigh):
        ipstr = ip_to_str(neigh.ip)

        KRoute.delete(ipstr, lvl_to_bits(0))
예제 #10
0
 def testEnableIPForwarding(self):
     ''' Test enable ip forwarding '''
     Route.ip_forward()
예제 #11
0
 def testFlushCache(self):
     ''' Test flush cache '''
     Route.flush_cache()
예제 #12
0
 def testFlushRoutes(self):
     ''' Test flush routes from `ntk' table '''
     self.testAddRoute()
     Route.flush()
예제 #13
0
 def testDeleteRoute(self):
     ''' Test remove a route '''
     Route.delete(self.ip, self.cidr, dev='eth0')
예제 #14
0
 def testAddRoute(self):
     ''' Test add a new route '''
     Route.add(self.ip, self.cidr, dev='eth0')
예제 #15
0
    def neigh_deleted(self, neigh):
        ipstr = ip_to_str(neigh.ip)

        KRoute.delete(ipstr, lvl_to_bits(0))