Esempio n. 1
0
File: Topology.py Progetto: smbz/vns
 def add_interface(self, name, mac, ip, mask):
     """Adds an interface to this node.  mac, ip, and mask must be in
      network-byte order.  The new interface is returned."""
     intf = VNSInterface(name, mac, ip, mask)
     intf.owner = self
     intf.link = None  # will be set by Link.__init__() if connected to another port
     intf.tap = None   # will be set to a TapConfig if tapped
     self.interfaces.append(intf)
     return intf
Esempio n. 2
0
 def add_interface(self, name, mac, ip, mask):
     """Adds an interface to this node.  mac, ip, and mask must be in
      network-byte order.  The new interface is returned."""
     intf = VNSInterface(name, mac, ip, mask)
     intf.owner = self
     intf.link = None  # will be set by Link.__init__() if connected to another port
     intf.tap = None   # will be set to a TapConfig if tapped
     self.interfaces.append(intf)
     return intf
Esempio n. 3
0
 def _handle_RouterInfo(self, event):
     log.debug(
         "SRServerListener catch RouterInfo even for vhost=%s, info=%s, rtable=%s",
         event.vhost, event.info, event.rtable)
     sw_info = event.info
     interfaces = []
     for intf in sw_info.keys():
         ip, mac, rate, port = sw_info[intf]
         ip = pack_ip(ip)
         mac = pack_mac(mac)
         mask = pack_ip('255.255.255.255')
         interfaces.append(VNSInterface(intf, mac, ip, mask))
         # Mapping between of-port and intf-name
         if (event.vhost not in self.intfname_to_port.keys()):
             self.intfname_to_port[event.vhost] = {}
             self.port_to_intfname[event.vhost] = {}
         self.intfname_to_port[event.vhost][intf] = port
         log.info('%s %s %s' % (
             event.vhost,
             intf,
             port,
         ))
         self.port_to_intfname[event.vhost][port] = intf
     # store the list of interfaces...
     self.interfaces[event.vhost] = interfaces
Esempio n. 4
0
 def _handle_RouterInfo(self, event):
   log.debug("SRServerListener catch RouterInfo even, info=%s, rtable=%s", event.info, event.rtable)
   interfaces = []
   for intf in event.info.keys():
     ip, mac, rate, port = event.info[intf]
     ip = pack_ip(ip)
     mac = pack_mac(mac)
     mask = pack_ip('255.255.255.255')
     interfaces.append(VNSInterface(intf, mac, ip, mask))
     # Mapping between of-port and intf-name
     self.intfname_to_port[intf] = port
     self.port_to_intfname[port] = intf
   # store the list of interfaces...
   self.interfaces = interfaces
    def __init__(self, swid, ifaces):
        self.swid = swid
        self.conn = None
        self.intfname_to_port = {}
        self.port_to_intfname = {}

        self.interfaces = []
        for intf in ifaces.keys():
            ip, mask, mac, port = ifaces[intf]
            if (ip is None or mask is None or mac is None):
                self.interfaces.append(VNSSwitchInterface(intf))
            else:
                ip = pack_ip(ip)
                mask = pack_ip(mask)
                mac = pack_mac(mac)
                self.interfaces.append(VNSInterface(intf, mac, ip, mask))
            # Mapping between of-port and intf-name
            self.intfname_to_port[intf] = port
            self.port_to_intfname[port] = intf
Esempio n. 6
0
 def _handle_RouterInfo(self, event):
     log.debug(
         "SRServerListener catch RouterInfo even for vhost=%s, info=%s, rtable=%s",
         event.vhost, event.info, event.rtable)
     sw_info = event.info
     interfaces = []
     for intf in sw_info.keys():
         ip, mac, rate, port = sw_info[intf]
         mask = ''
         static = 0
         if event.vhost == 'vhost1':
             if ip == '10.0.1.1':
                 mask = '255.255.255.0'
                 static = 1
             else:
                 mask = '255.255.255.252'
         elif event.vhost == 'vhost2':
             if ip == '192.168.2.2':
                 mask = '255.255.255.0'
                 static = 1
             else:
                 mask = '255.255.255.252'
         elif event.vhost == 'vhost3':
             if ip == '172.24.3.2':
                 mask = '255.255.255.0'
                 static = 1
             else:
                 mask = '255.255.255.252'
         ip = pack_ip(ip)
         mac = pack_mac(mac)
         mask = pack_ip(mask)
         interfaces.append(VNSInterface(intf, mac, ip, mask, static))
         # Mapping between of-port and intf-name
         if (event.vhost not in self.intfname_to_port.keys()):
             self.intfname_to_port[event.vhost] = {}
             self.port_to_intfname[event.vhost] = {}
         self.intfname_to_port[event.vhost][intf] = port
         self.port_to_intfname[event.vhost][port] = intf
     # store the list of interfaces...
     self.interfaces[event.vhost] = interfaces
Esempio n. 7
0
    def __init__(self, swid, info, address=('127.0.0.1', 8888)):
        port = address[1]
        self.listenTo(core.cs640_ofhandler)
        self.swid = swid
        self.srclients = []
        self.listen_port = port
        self.intfname_to_port = {}
        self.port_to_intfname = {}
        self.server = create_vns_server(port, self._handle_recv_msg,
                                        self._handle_new_client,
                                        self._handle_client_disconnected)
        self.interfaces = []
        for intf in info.keys():
            ip, mask, mac, rate, port = info[intf]
            ip = pack_ip(ip)
            mask = pack_ip(mask)
            mac = pack_mac(mac)
            self.interfaces.append(VNSInterface(intf, mac, ip, mask))
            # Mapping between of-port and intf-name
            self.intfname_to_port[intf] = port
            self.port_to_intfname[port] = intf

        log.info('created server')
        return