Пример #1
0
Файл: nat.py Проект: yapkke/yapc
    def add_interfaces(self, interfaces):
        """Add interfaces (plus mirror port)
        
        @param interfaces list of interfaces
        """
        for i in interfaces:
            self.switch.add_if(i)
            self.ifmgr.set_ipv4_addr(i, "0.0.0.0")
            # Add mirror interface
            self.mirror[i] = self.add_loif(i)
            ieth = self.ifmgr.ethernet_addr(i)
            self.ifmgr.set_eth_addr(self.mirror[i].client_intf, ieth)
            np = self.switch.get_ports()
            port1 = np[i]
            port2 = np[self.mirror[i].switch_intf]

            # Set perm DHCP rules for mirror
            dreq = flows.udp_entry(portno=68, priority=ofutil.PRIORITY["LOW"])
            dreq.set_in_port(port1)
            dreq.add_output(port2, 65535)
            self.default.add_perm(dreq)
            drep = flows.udp_entry(portno=67, priority=ofutil.PRIORITY["LOW"])
            drep.set_in_port(port2)
            drep.add_output(port1, 65535)
            self.default.add_perm(drep)

            output.dbg(
                "Set " + self.mirror[i].client_intf + " to " + self.ifmgr.ethernet_addr(i), self.__class__.__name__
            )
Пример #2
0
    def __init__(self, server, ofconn):
        """Initialize
        
        @param server yapc core
        @param ofconn refrence to connections
        """
        default.default_entries.__init__(self, server, ofconn)

        self.add(flows.all_entry(flows.flow_entry.DROP,
                                 ofutil.PRIORITY['LOWEST'],
                                 pyof.OFP_FLOW_PERMANENT,
                                 pyof.OFP_FLOW_PERMANENT))
        self.add_perm_output(flows.tcp_entry(priority=ofutil.PRIORITY['LOWER']),
                             max_len=65535)
        self.add_perm_output(flows.udp_entry(priority=ofutil.PRIORITY['LOWER']),
                             max_len=65535)
        self.add_perm_output(flows.icmp_entry(priority=ofutil.PRIORITY['LOWER']),
                             max_len=65535)
        self.add_perm_output(flows.arp_entry(priority=ofutil.PRIORITY['HIGH']),
                             max_len=65535)