Java 类net.floodlightcontroller.core.types.MacVlanPair 实例源码

项目:QoS-floodlight    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:floodlight_with_topoguard    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:floodlight    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan, OFPort portVal) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == VlanVid.FULL_MASK) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = VlanVid.ofVlan(0);
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair, OFPort>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:FloodligtModule    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:smartenit    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:multicastSDN    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:floodlight-qosmanager    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:floodlight-nfv    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:HederaInFloodlight    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:floodlight-oss    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:my-floodlight    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:FL_HAND    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:sdn-project    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, long mac, short vlan, short portVal) {
    Map<MacVlanPair,Short> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == (short) 0xffff) {
        // OFMatch.loadFromPacket sets VLAN ID to 0xffff if the packet contains no VLAN tag;
        // for our purposes that is equivalent to the default VLAN ID 0
        vlan = 0;
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair,Short>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:fresco_floodlight    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan, OFPort portVal) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair, OFPort>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:fresco_floodlight    文件:LearningSwitch.java   
/**
 * Removes a host from the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to remove the mapping from
 * @param mac The MAC address of the host to remove
 * @param vlan The VLAN that the host is on
 */
protected void removeFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK) {
        vlan = VlanVid.ofVlan(0);
    }

    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.remove(new MacVlanPair(mac, vlan));
    }
}
项目:fresco_floodlight    文件:LearningSwitch.java   
/**
 * Get the port that a MAC/VLAN pair is associated with
 * @param sw The switch to get the mapping from
 * @param mac The MAC address to get
 * @param vlan The VLAN number to get
 * @return The port the host is on
 */
public OFPort getFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        return swMap.get(new MacVlanPair(mac, vlan));
    }

    // if none found
    return null;
}
项目:fresco_floodlight    文件:LearningSwitch.java   
/**
 * Clears the MAC/VLAN -> SwitchPort map for a single switch
 * @param sw The switch to clear the mapping for
 */
public void clearLearnedTable(IOFSwitch sw) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.clear();
    }
}
项目:fresco_floodlight    文件:LearningSwitch.java   
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    macVlanToSwitchPortMap = new ConcurrentHashMap<IOFSwitch, Map<MacVlanPair, OFPort>>();
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}
项目:fresco_floodlight    文件:LearningSwitchTable.java   
protected Map<String, Object> formatTableEntry(MacVlanPair key, OFPort port) {
    Map<String, Object> entry = new HashMap<String, Object>();
    entry.put("mac", key.mac.toString());
    entry.put("vlan", key.vlan.getVlan());
    entry.put("port", port.getPortNumber());
    return entry;
}
项目:fresco_floodlight    文件:LearningSwitchTable.java   
protected List<Map<String, Object>> getOneSwitchTable(Map<MacVlanPair, OFPort> switchMap) {
    List<Map<String, Object>> switchTable = new ArrayList<Map<String, Object>>();
    for (Entry<MacVlanPair, OFPort> entry : switchMap.entrySet()) {
        switchTable.add(formatTableEntry(entry.getKey(), entry.getValue()));
    }
    return switchTable;
}
项目:iTAP-controller    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan, OFPort portVal) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair, OFPort>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:iTAP-controller    文件:LearningSwitch.java   
/**
 * Removes a host from the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to remove the mapping from
 * @param mac The MAC address of the host to remove
 * @param vlan The VLAN that the host is on
 */
protected void removeFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK) {
        vlan = VlanVid.ofVlan(0);
    }

    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.remove(new MacVlanPair(mac, vlan));
    }
}
项目:iTAP-controller    文件:LearningSwitch.java   
/**
 * Get the port that a MAC/VLAN pair is associated with
 * @param sw The switch to get the mapping from
 * @param mac The MAC address to get
 * @param vlan The VLAN number to get
 * @return The port the host is on
 */
public OFPort getFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        return swMap.get(new MacVlanPair(mac, vlan));
    }

    // if none found
    return null;
}
项目:iTAP-controller    文件:LearningSwitch.java   
/**
 * Clears the MAC/VLAN -> SwitchPort map for a single switch
 * @param sw The switch to clear the mapping for
 */
public void clearLearnedTable(IOFSwitch sw) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.clear();
    }
}
项目:iTAP-controller    文件:LearningSwitch.java   
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    macVlanToSwitchPortMap = new ConcurrentHashMap<IOFSwitch, Map<MacVlanPair, OFPort>>();
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}
项目:iTAP-controller    文件:LearningSwitchTable.java   
protected Map<String, Object> formatTableEntry(MacVlanPair key, OFPort port) {
    Map<String, Object> entry = new HashMap<String, Object>();
    entry.put("mac", key.mac.toString());
    entry.put("vlan", key.vlan.getVlan());
    entry.put("port", port.getPortNumber());
    return entry;
}
项目:iTAP-controller    文件:LearningSwitchTable.java   
protected List<Map<String, Object>> getOneSwitchTable(Map<MacVlanPair, OFPort> switchMap) {
    List<Map<String, Object>> switchTable = new ArrayList<Map<String, Object>>();
    for (Entry<MacVlanPair, OFPort> entry : switchMap.entrySet()) {
        switchTable.add(formatTableEntry(entry.getKey(), entry.getValue()));
    }
    return switchTable;
}
项目:SDN-Multicast    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan, OFPort portVal) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair, OFPort>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:SDN-Multicast    文件:LearningSwitch.java   
/**
 * Removes a host from the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to remove the mapping from
 * @param mac The MAC address of the host to remove
 * @param vlan The VLAN that the host is on
 */
protected void removeFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK) {
        vlan = VlanVid.ofVlan(0);
    }

    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.remove(new MacVlanPair(mac, vlan));
    }
}
项目:SDN-Multicast    文件:LearningSwitch.java   
/**
 * Get the port that a MAC/VLAN pair is associated with
 * @param sw The switch to get the mapping from
 * @param mac The MAC address to get
 * @param vlan The VLAN number to get
 * @return The port the host is on
 */
public OFPort getFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        return swMap.get(new MacVlanPair(mac, vlan));
    }

    // if none found
    return null;
}
项目:SDN-Multicast    文件:LearningSwitch.java   
/**
 * Clears the MAC/VLAN -> SwitchPort map for a single switch
 * @param sw The switch to clear the mapping for
 */
public void clearLearnedTable(IOFSwitch sw) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.clear();
    }
}
项目:SDN-Multicast    文件:LearningSwitch.java   
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    macVlanToSwitchPortMap = new ConcurrentHashMap<IOFSwitch, Map<MacVlanPair, OFPort>>();
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}
项目:SDN-Multicast    文件:LearningSwitchTable.java   
protected Map<String, Object> formatTableEntry(MacVlanPair key, OFPort port) {
    Map<String, Object> entry = new HashMap<String, Object>();
    entry.put("mac", key.mac.toString());
    entry.put("vlan", key.vlan.getVlan());
    entry.put("port", port.getPortNumber());
    return entry;
}
项目:SDN-Multicast    文件:LearningSwitchTable.java   
protected List<Map<String, Object>> getOneSwitchTable(Map<MacVlanPair, OFPort> switchMap) {
    List<Map<String, Object>> switchTable = new ArrayList<Map<String, Object>>();
    for (Entry<MacVlanPair, OFPort> entry : switchMap.entrySet()) {
        switchTable.add(formatTableEntry(entry.getKey(), entry.getValue()));
    }
    return switchTable;
}
项目:arscheduler    文件:LearningSwitch.java   
/**
 * Adds a host to the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to add the mapping to
 * @param mac The MAC address of the host to add
 * @param vlan The VLAN that the host is on
 * @param portVal The switchport that the host is on
 */
protected void addToPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan, OFPort portVal) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);

    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }

    if (swMap == null) {
        // May be accessed by REST API so we need to make it thread safe
        swMap = Collections.synchronizedMap(new LRULinkedHashMap<MacVlanPair, OFPort>(MAX_MACS_PER_SWITCH));
        macVlanToSwitchPortMap.put(sw, swMap);
    }
    swMap.put(new MacVlanPair(mac, vlan), portVal);
}
项目:arscheduler    文件:LearningSwitch.java   
/**
 * Removes a host from the MAC/VLAN->SwitchPort mapping
 * @param sw The switch to remove the mapping from
 * @param mac The MAC address of the host to remove
 * @param vlan The VLAN that the host is on
 */
protected void removeFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK) {
        vlan = VlanVid.ofVlan(0);
    }

    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.remove(new MacVlanPair(mac, vlan));
    }
}
项目:arscheduler    文件:LearningSwitch.java   
/**
 * Get the port that a MAC/VLAN pair is associated with
 * @param sw The switch to get the mapping from
 * @param mac The MAC address to get
 * @param vlan The VLAN number to get
 * @return The port the host is on
 */
public OFPort getFromPortMap(IOFSwitch sw, MacAddress mac, VlanVid vlan) {
    if (vlan == VlanVid.FULL_MASK || vlan == null) {
        vlan = VlanVid.ofVlan(0);
    }
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        return swMap.get(new MacVlanPair(mac, vlan));
    }

    // if none found
    return null;
}
项目:arscheduler    文件:LearningSwitch.java   
/**
 * Clears the MAC/VLAN -> SwitchPort map for a single switch
 * @param sw The switch to clear the mapping for
 */
public void clearLearnedTable(IOFSwitch sw) {
    Map<MacVlanPair, OFPort> swMap = macVlanToSwitchPortMap.get(sw);
    if (swMap != null) {
        swMap.clear();
    }
}
项目:arscheduler    文件:LearningSwitch.java   
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    macVlanToSwitchPortMap = new ConcurrentHashMap<IOFSwitch, Map<MacVlanPair, OFPort>>();
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}