Esempio n. 1
0
 def __init__(self, route, tableid):
     gateway, iface = route.split('@')
     Interface.__init__(self, iface, tableid, route)
     self.gateway = socket.gethostbyname(gateway)
     self._fake_binding = state_publisher.StatePublisher(None)
     netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR).subscribe(self._publish_binding)
     DhcpRouteSetter(iface, tableid, self._fake_binding)
Esempio n. 2
0
 def __init__(self, iface):
     self.iface = iface
     self.ping_timeout = config.get_parameter("ping_timeout", 4)
     self.is_verified = StatePublisher(False)
     self.has_address = False
     iface.ping_tester.update_event.subscribe_repeating(self._update)
     netlink_monitor.get_state_publisher(iface.iface, IFSTATE.ADDR).subscribe(self._has_address_cb, iface)
Esempio n. 3
0
 def __init__(self, route, tableid):
     gateway, iface = route.split('@')
     Interface.__init__(self, iface, tableid, route)
     self.gateway = socket.gethostbyname(gateway)
     self._fake_binding = state_publisher.StatePublisher(None)
     netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR).subscribe(
         self._publish_binding)
     DhcpRouteSetter(iface, tableid, self._fake_binding)
Esempio n. 4
0
 def __init__(self, iface):
     self.iface = iface
     self.ping_timeout = config.get_parameter('ping_timeout', 4)
     self.is_verified = StatePublisher(False)
     self.has_address = False
     iface.ping_tester.update_event.subscribe_repeating(self._update)
     netlink_monitor.get_state_publisher(iface.iface,
                                         IFSTATE.ADDR).subscribe(
                                             self._has_address_cb, iface)
Esempio n. 5
0
 def __init__(self, iface):
     self.iface = iface
     self._lock = DeferredLock()
     CompositeStatePublisher(lambda x: x, [
         netlink_monitor.get_state_publisher(iface, IFSTATE.PLUGGED),
         netlink_monitor.get_state_publisher(iface, IFSTATE.UP),
     ]).subscribe(self._cb)
     self._is_shutdown = False
     self.state = None
     reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
Esempio n. 6
0
 def __init__(self, iface):
     self.iface = iface
     self._lock = DeferredLock()
     CompositeStatePublisher(lambda x: x, [
         netlink_monitor.get_state_publisher(iface, IFSTATE.PLUGGED),
         netlink_monitor.get_state_publisher(iface, IFSTATE.UP),
     ]).subscribe(self._cb)
     self._is_shutdown = False
     self.state = None
     reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
    def __init__(self):
        self.interfaces = {}
        self.update_event = event.Event()
        self.update_interval = 1
        self.radio_manager = radio_manager.RadioManager()
        self.inactive_penalty = config.get_parameter('inactive_penalty', 50)
        self.forced_interface = ""
        self.tunnel_interface = config.get_parameter('tunnel_interface', "")
        self.use_tunnel = True
        self.active_interfaces = []

        self.basestation = config.get_parameter('base_station')
        #        print "Resolving basestation IP. (Blocking operation.)"
        #        self.basestation_ip = socket.gethostbyname(config.get_parameter('base_station'))

        # Add rules to guarantee that local routes go to the main table.
        #        self.local_net_rule = ip_rule.IpRule(RULEID.LOCAL)
        #        for subnet in config.get_parameter('local_networks'):
        #            self.local_net_rule.add('to', subnet, 'lookup', 'main')

        self.local_net_rules = []
        for (i, subnet) in enumerate(config.get_parameter('local_networks')):
            self.local_net_rules.append(ip_rule.IpRule(RULEID.LOCAL + i))
            self.local_net_rules[i].add('to', subnet, 'lookup', 'main')

        # Add a rule to send through the vpn.
        if self.tunnel_interface:
            self.vpn_rule = ip_rule.IpRule(RULEID.DEFAULT)
            # Use LINK here because netlink_monitor's parsing rules don't
            # currently work on vpn interfaces.
            system.system('ip', 'route', 'flush', 'table', str(RULEID.DEFAULT))
            netlink_monitor.get_state_publisher(
                self.tunnel_interface,
                IFSTATE.LINK).subscribe(self._refresh_default_route)

        # Create all the interfaces.
        interface_names = config.get_parameter('interfaces').keys()
        ifaceid = RULEID.FIRST_IFACE
        for iface in interface_names:
            try:
                new_iface = self.interfaces[iface] = interface.construct(
                    iface, ifaceid)
                new_iface.score = InterfaceSelector.TERRIBLE_INTERFACE
                new_iface.prescore = InterfaceSelector.TERRIBLE_INTERFACE
                ifaceid += 1
            except interface.NoType:
                print >> sys.stderr, "Interface %s has no type." % iface
                sys.exit(1)
            except interface.UnknownType, e:
                print >> sys.stderr, "Interface %s has unknown type %s." % (
                    iface, e)
                sys.exit(1)
            except:
Esempio n. 8
0
    def __init__(self):
        self.interfaces = {}
        self.update_event = event.Event()
        self.update_interval = 1
        self.radio_manager = radio_manager.RadioManager()
        self.inactive_penalty = config.get_parameter('inactive_penalty', 50)
        self.forced_interface = ""
        self.tunnel_interface = config.get_parameter('tunnel_interface', "")
        self.use_tunnel = True
        self.active_interfaces = []

        self.basestation = config.get_parameter('base_station')
#        print "Resolving basestation IP. (Blocking operation.)"
#        self.basestation_ip = socket.gethostbyname(config.get_parameter('base_station'))

        # Add rules to guarantee that local routes go to the main table.
#        self.local_net_rule = ip_rule.IpRule(RULEID.LOCAL)
#        for subnet in config.get_parameter('local_networks'):
#            self.local_net_rule.add('to', subnet, 'lookup', 'main')

        self.local_net_rules = []
        for (i, subnet) in enumerate(config.get_parameter('local_networks')):
            self.local_net_rules.append(ip_rule.IpRule(RULEID.LOCAL+i))
            self.local_net_rules[i].add('to', subnet, 'lookup', 'main')

        # Add a rule to send through the vpn.
        if self.tunnel_interface:
            self.vpn_rule = ip_rule.IpRule(RULEID.DEFAULT)
            # Use LINK here because netlink_monitor's parsing rules don't
            # currently work on vpn interfaces.
            system.system('ip', 'route', 'flush', 'table', str(RULEID.DEFAULT))
            netlink_monitor.get_state_publisher(self.tunnel_interface,
                    IFSTATE.LINK).subscribe(self._refresh_default_route)


        # Create all the interfaces.
        interface_names = config.get_parameter('interfaces').keys()
        ifaceid = RULEID.FIRST_IFACE
        for iface in interface_names:
            try:
                new_iface = self.interfaces[iface] = interface.construct(iface, ifaceid)
                new_iface.score = InterfaceSelector.TERRIBLE_INTERFACE 
                new_iface.prescore = InterfaceSelector.TERRIBLE_INTERFACE
                ifaceid += 1
            except interface.NoType:
                print >> sys.stderr, "Interface %s has no type."%iface
                sys.exit(1)
            except interface.UnknownType, e:
                print >> sys.stderr, "Interface %s has unknown type %s."%(iface, e)
                sys.exit(1)
            except:
Esempio n. 9
0
 def __init__(self, iface, table, state_pub):
     _DhcpSetterCommon.__init__(self)
     self.iface = iface
     self.table = str(table)
     self._iface_status_pub = netlink_monitor.get_status_publisher(iface)
     CompositeStatePublisher(lambda (addr, dhcp): None if not addr else dhcp, [
         netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR),
         state_pub
     ]).subscribe(self._cb)
Esempio n. 10
0
 def __init__(self, iface, table, state_pub):
     _DhcpSetterCommon.__init__(self)
     self.iface = iface
     self.table = str(table)
     self._iface_status_pub = netlink_monitor.get_status_publisher(iface)
     CompositeStatePublisher(
         lambda (addr, dhcp): None if not addr else dhcp, [
             netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR),
             state_pub
         ]).subscribe(self._cb)
Esempio n. 11
0
 def __init__(self, iface, rate, pingtarget, state_pub):
     self.update_event = Event()
     reactor.addSystemEventTrigger("before", "shutdown", self._shutdown)
     self.udp_monitor = udpmoncli.MonitorClient(
         [config.get_parameter("ping_max_latency", 0.2)], pingtarget, rate, 32, True
     )
     CompositeStatePublisher(
         lambda (addr, ready): None if not ready else addr,
         [netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR), state_pub],
     ).subscribe(self._addr_cb)
Esempio n. 12
0
 def __init__(self, iface, rate, pingtarget, state_pub):
     self.update_event = Event()
     reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
     self.udp_monitor = udpmoncli.MonitorClient(
         [config.get_parameter('ping_max_latency', 0.2)], pingtarget, rate,
         32, True)
     CompositeStatePublisher(
         lambda (addr, ready): None if not ready else addr, [
             netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR),
             state_pub,
         ]).subscribe(self._addr_cb)
Esempio n. 13
0
 def __init__(self, iface_name):
     self._radio = radio.Radio(iface_name)
     self.iface_name = iface_name
     self._up_state_pub = netlink_monitor.get_state_publisher(iface_name, IFSTATE.UP)
     self.activate_request = state_publisher.StatePublisher(False)
     self.is_active = state_publisher.StatePublisher(False)
     self.scanning_enabled = state_publisher.StatePublisher(False)
     self.associate_request = event.Event()
     self.disactivate_delay = 1
     self.pre_up_sleep = 1
     
     # Copy radio members that we are willing to expose
     self.unassociate = self._radio.unassociate
     self.associated = self._radio.associated
     self.scanning = self._radio.scanning
     self.scan = self._radio.scan
     self.scan_results_event = self._radio.scan_results_event
     self.frequency_list = self._radio.frequency_list
Esempio n. 14
0
    def __init__(self, iface_name):
        self._radio = radio.Radio(iface_name)
        self.iface_name = iface_name
        self._up_state_pub = netlink_monitor.get_state_publisher(
            iface_name, IFSTATE.UP)
        self.activate_request = state_publisher.StatePublisher(False)
        self.is_active = state_publisher.StatePublisher(False)
        self.scanning_enabled = state_publisher.StatePublisher(False)
        self.associate_request = event.Event()
        self.disactivate_delay = 1
        self.pre_up_sleep = 1

        # Copy radio members that we are willing to expose
        self.unassociate = self._radio.unassociate
        self.associated = self._radio.associated
        self.scanning = self._radio.scanning
        self.scan = self._radio.scan
        self.scan_results_event = self._radio.scan_results_event
        self.frequency_list = self._radio.frequency_list
Esempio n. 15
0
 def __init__(self, iface, table, priority):
     self._ip_rule = ip_rule.IpRule(priority)
     self.table = str(table)
     self.state_pub = self._ip_rule.state_pub
     netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR).subscribe(self._cb)
Esempio n. 16
0
 def __init__(self, iface, table, priority):
     self._ip_rule = ip_rule.IpRule(priority)
     self.table = str(table)
     self.state_pub = self._ip_rule.state_pub
     netlink_monitor.get_state_publisher(iface,
                                         IFSTATE.ADDR).subscribe(self._cb)