本文整理汇总了Java中net.floodlightcontroller.util.MACAddress类的典型用法代码示例。如果您正苦于以下问题:Java MACAddress类的具体用法?Java MACAddress怎么用?Java MACAddress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MACAddress类属于net.floodlightcontroller.util包,在下文中一共展示了MACAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addHost
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Put
public String addHost(String postData) {
IVirtualNetworkService vns =
(IVirtualNetworkService)getContext().getAttributes().
get(IVirtualNetworkService.class.getCanonicalName());
HostDefinition host = new HostDefinition();
host.port = (String) getRequestAttributes().get("port");
host.guid = (String) getRequestAttributes().get("network");
try {
jsonToHostDefinition(postData, host);
} catch (IOException e) {
log.error("Could not parse JSON {}", e.getMessage());
}
vns.addHost(MACAddress.valueOf(host.mac), host.guid, host.port);
setStatus(Status.SUCCESS_OK);
return "{\"status\":\"ok\"}";
}
示例2: addHost
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void addHost(MACAddress mac, String guid, String port) {
if (guid != null) {
if (log.isDebugEnabled()) {
log.debug("Adding {} to network ID {} on port {}",
new Object[] {mac, guid, port});
}
// 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});
}
}
示例3: deleteHost
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void deleteHost(MACAddress mac, String port) {
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) {
if (!portToMac.isEmpty()) {
for (Entry<String, MACAddress> entry : portToMac.entrySet()) {
if (entry.getValue().equals(mac)) {
if(vNetsByGuid.get(macToGuid.get(entry.getValue())) != null)
vNetsByGuid.get(macToGuid.get(entry.getValue())).removeHost(entry.getValue());
portToMac.remove(entry.getKey());
macToGuid.remove(entry.getValue());
return;
}
}
}
}
}
示例4: init
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
restApi = context.getServiceImpl(IRestApiService.class);
deviceService = context.getServiceImpl(IDeviceService.class);
vNetsByGuid = new ConcurrentHashMap<String, VirtualNetwork>();
nameToGuid = new ConcurrentHashMap<String, String>();
guidToGateway = new ConcurrentHashMap<String, Integer>();
gatewayToGuid = new ConcurrentHashMap<Integer, Set<String>>();
macToGuid = new ConcurrentHashMap<MACAddress, String>();
portToMac = new ConcurrentHashMap<String, MACAddress>();
macToGateway = new ConcurrentHashMap<MACAddress, Integer>();
deviceListener = new DeviceListenerImpl();
}
示例5: isDefaultGateway
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
/**
* Checks whether the frame is destined to or from a gateway.
* @param frame The ethernet frame to check.
* @return True if it is to/from a gateway, false otherwise.
*/
protected boolean isDefaultGateway(Ethernet frame) {
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;
}
}
return false;
}
示例6: init
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
restApi = context.getServiceImpl(IRestApiService.class);
counterStore = context.getServiceImpl(ICounterStoreService.class);
deviceManager = context.getServiceImpl(IDeviceService.class);
routingEngine = context.getServiceImpl(IRoutingService.class);
topology = context.getServiceImpl(ITopologyService.class);
sfp = context.getServiceImpl(IStaticFlowEntryPusherService.class);
messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
EnumSet.of(OFType.FLOW_MOD),
OFMESSAGE_DAMPER_TIMEOUT);
vips = new HashMap<String, LBVip>();
pools = new HashMap<String, LBPool>();
members = new HashMap<String, LBMember>();
vipIpToId = new HashMap<Integer, String>();
vipIpToMac = new HashMap<Integer, MACAddress>();
memberIpToId = new HashMap<Integer, String>();
}
示例7: LBVip
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
public LBVip() {
this.id = String.valueOf((int) (Math.random()*10000));
this.name = null;
this.tenantId = null;
this.netId = null;
this.address = 0;
this.protocol = 0;
this.lbMethod = 0;
this.port = 0;
this.pools = new ArrayList<String>();
this.sessionPersistence = false;
this.connectionLimit = 0;
this.address = 0;
this.status = 0;
this.proxyMac = MACAddress.valueOf(LB_PROXY_MAC);
}
示例8: checkPerSourceMacRate
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
/**
* Check if we have sampled this mac in the last second.
* Since we check every packetInRatePerMacThreshold packets,
* the presence of the mac in the macCache means the rate is
* above the threshold in a statistical sense.
*
* Take care not to block topology probing packets. Also don't
* push blocking flow mod if we have already done so within the
* last 5 seconds.
*
* @param pin
* @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);
}
}
示例9: fromImmutablePort
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
public static SyncedPort fromImmutablePort(ImmutablePort p) {
SyncedPort rv = new SyncedPort();
rv.portNumber = p.getPortNumber();
if (p.getHardwareAddress() == null) {
rv.hardwareAddress = 0;
} else {
rv.hardwareAddress =
MACAddress.valueOf(p.getHardwareAddress()).toLong();
}
rv.name = p.getName();
rv.config = EnumBitmaps.toBitmap(p.getConfig());
rv.state = p.getStpState().getValue();
if (p.isLinkDown())
rv.state |= OFPortState.OFPPS_LINK_DOWN.getValue();
rv.currentFeatures = EnumBitmaps.toBitmap(p.getCurrentFeatures());
rv.advertisedFeatures =
EnumBitmaps.toBitmap(p.getAdvertisedFeatures());
rv.supportedFeatures =
EnumBitmaps.toBitmap(p.getSupportedFeatures());
rv.peerFeatures = EnumBitmaps.toBitmap(p.getPeerFeatures());
return rv;
}
示例10: addHost
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void addHost(MACAddress mac, String guid, String port) {
if (guid != null) {
if (log.isDebugEnabled()) {
log.debug("Adding {} to network ID {} on port {}",
new Object[] {mac, guid, port});
}
// We ignore old mappings
macToGuid.put(mac, guid);
portToMac.put(port, mac);
if(vNetsByGuid.get(guid)!=null)
vNetsByGuid.get(guid).addHost(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});
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:18,代码来源:VirtualNetworkFilter.java
示例11: deleteHost
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void deleteHost(MACAddress mac, String port) {
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(vNetsByGuid.get(macToGuid.get(host)) != null)
vNetsByGuid.get(macToGuid.get(host)).removeHost(host);
macToGuid.remove(host);
} else if (mac != null) {
if (!portToMac.isEmpty()) {
for (Entry<String, MACAddress> entry : portToMac.entrySet()) {
if (entry.getValue().equals(mac)) {
if(vNetsByGuid.get(macToGuid.get(entry.getValue())) != null)
vNetsByGuid.get(macToGuid.get(entry.getValue())).removeHost(entry.getValue());
portToMac.remove(entry.getKey());
macToGuid.remove(entry.getValue());
return;
}
}
}
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:26,代码来源:VirtualNetworkFilter.java
示例12: isDefaultGateway
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
/**
* Checks whether the frame is destined to or from a gateway.
* @param frame The ethernet frame to check.
* @return True if it is to/from a gateway, false otherwise.
*/
protected boolean isDefaultGateway(Ethernet frame) {
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;
}
}
return false;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:23,代码来源:VirtualNetworkFilter.java
示例13: serialize
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
@Override
public void serialize(VirtualNetwork vNet, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("name", vNet.name);
jGen.writeStringField("guid", vNet.guid);
jGen.writeStringField("gateway", vNet.gateway);
jGen.writeArrayFieldStart("mac");
Iterator<MACAddress> hit = vNet.hosts.iterator();
while (hit.hasNext())
jGen.writeString(hit.next().toString());
jGen.writeEndArray();
jGen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:19,代码来源:VirtualNetworkSerializer.java
示例14: generateICMPPing
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
protected byte[] generateICMPPing(InetAddress ip, MACAddress mac){
targetIP = ip;
targetMAC = mac;
IPacket packet = new IPv4()
.setProtocol(IPv4.PROTOCOL_ICMP)
.setSourceAddress(ControllerIP)
.setDestinationAddress(ip.hashCode()) //this is tricky
.setPayload(new ICMP()
.setIcmpType((byte) 8)
.setIcmpCode((byte) 0)
.setPayload(new Data(new byte[]
{0x76, (byte) 0xf2, 0x0, 0x2, 0x1, 0x1, 0x1}))
);
Ethernet ethernet = new Ethernet().setSourceMACAddress(senderMAC.toBytes())
.setDestinationMACAddress(targetMAC.toBytes())
.setEtherType(Ethernet.TYPE_IPv4);
ethernet.setPayload(packet);
return ethernet.serialize();
}
示例15: generateARPPing
import net.floodlightcontroller.util.MACAddress; //导入依赖的package包/类
protected byte[] generateARPPing(InetAddress ip, MACAddress mac){
targetIP = ip;
ARP arp = new ARP().setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_RARP_REQUEST)
.setSenderHardwareAddress(senderMAC.toBytes())
.setSenderProtocolAddress(senderIP.getAddress())
.setTargetHardwareAddress(emptyMAC.toBytes())
.setTargetProtocolAddress(targetIP.getAddress());
Ethernet ethernet = new Ethernet().setSourceMACAddress(senderMAC.toBytes())
.setDestinationMACAddress(broadcastMAC.toBytes())
.setEtherType(Ethernet.TYPE_ARP);
ethernet.setPayload(arp);
return ethernet.serialize();
}