Package net.floodlightcontroller.util

Examples of net.floodlightcontroller.util.MACAddress


     * @return
     */
    private void checkPerSourceMacRate(OFPacketIn pin) {
        byte[] data = pin.getPacketData();
        byte[] mac = Arrays.copyOfRange(data, 6, 12);
        MACAddress srcMac = MACAddress.valueOf(mac);
        short ethType = (short) (((data[12] & 0xff) << 8) + (data[13] & 0xff));
        if (ethType != Ethernet.TYPE_LLDP && ethType != Ethernet.TYPE_BSN &&
                macCache.update(srcMac.toLong())) {
            // Check if we already pushed a flow in the last 5 seconds
            if (macBlockedCache.update(srcMac.toLong())) {
                return;
            }
            // write out drop flow per srcMac
            int port = pin.getInPort();
            SwitchPort swPort = new SwitchPort(getId(), port);
            ForwardingBase.blockHost(floodlightProvider,
                    swPort, srcMac.toLong(), (short) 5,
                    AppCookie.makeCookie(OFSWITCH_APP_ID, 0));
            floodlightProvider.addSwitchEvent(this.datapathId,
                    "SWITCH_PORT_BLOCKED_TEMPORARILY " +
                    "OFPort " + port + " mac " + srcMac, false);
            log.info("Excessive packet in from {} on {}, block host for 5 sec",
                    srcMac.toString(), swPort);
        }
    }
View Full Code Here


            }
            // We ignore old mappings
            macToGuid.put(mac, guid);
            portToMac.put(port, mac);
            if(vNetsByGuid.get(guid)!=null)
                vNetsByGuid.get(guid).addHost(port,new MACAddress(mac.toBytes()));
        } else {
            log.warn("Could not add MAC {} to network ID {} on port {}, the network does not exist",
                     new Object[] {mac, guid, port});
        }
    }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Removing host {} from port {}", mac, port);
        }
        if (mac == null && port == null) return;
        if (port != null) {
            MACAddress host = portToMac.remove(port);
            if(host !=null && vNetsByGuid.get(macToGuid.get(host)) != null)
                vNetsByGuid.get(macToGuid.get(host)).removeHost(host);
      if(host !=null)
              macToGuid.remove(host);
        } else if (mac != null) {
View Full Code Here

        if (macToGateway.containsKey(frame.getSourceMAC()))
            return true;

        Integer gwIp = macToGateway.get(frame.getDestinationMAC());
        if (gwIp != null) {
            MACAddress host = frame.getSourceMAC();
            String srcNet = macToGuid.get(host);
            if (srcNet != null) {
                Integer gwIpSrcNet = guidToGateway.get(srcNet);
                if ((gwIpSrcNet != null) && (gwIp.equals(gwIpSrcNet)))
                    return true;
View Full Code Here

        @Override
        public void deviceAdded(IDevice device) {
            if (device.getIPv4Addresses() == null) return;
            for (Integer i : device.getIPv4Addresses()) {
                if (gatewayToGuid.containsKey(i)) {
                    MACAddress mac = MACAddress.valueOf(device.getMACAddress());
                    if (log.isDebugEnabled())
                        log.debug("Adding MAC {} with IP {} a a gateway",
                                    HexString.toHexString(mac.toBytes()),
                                    IPv4.fromIPv4Address(i));
                        macToGateway.put(mac, i);
                    }
                }
            }
View Full Code Here

            }

            @Override
        public void deviceRemoved(IDevice device) {
            // if device is a gateway remove
            MACAddress mac = MACAddress.valueOf(device.getMACAddress());
            if (macToGateway.containsKey(mac)) {
                if (log.isDebugEnabled())
                    log.debug("Removing MAC {} as a gateway",
                                HexString.toHexString(mac.toBytes()));
                macToGateway.remove(mac);
             }
        }
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.util.MACAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.