当前位置: 首页>>代码示例>>Java>>正文


Java MacAddress类代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.types.MacAddress的典型用法代码示例。如果您正苦于以下问题:Java MacAddress类的具体用法?Java MacAddress怎么用?Java MacAddress使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MacAddress类属于org.projectfloodlight.openflow.types包,在下文中一共展示了MacAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isDefaultGateway

import org.projectfloodlight.openflow.types.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.getSourceMACAddress()))
		return true;

	IPv4Address gwIp = macToGateway.get(frame.getDestinationMACAddress());
	if (gwIp != null) {
		MacAddress host = frame.getSourceMACAddress();
		String srcNet = macToGuid.get(host);
		if (srcNet != null) {
			IPv4Address gwIpSrcNet = guidToGateway.get(srcNet);
			if ((gwIpSrcNet != null) && (gwIp.equals(gwIpSrcNet)))
				return true;
		}
	}

	return false;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:VirtualNetworkFilter.java

示例2: testUncastPacket

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
@Test
public void testUncastPacket() {
    // Generate the VerificationPacket
    OFPacketOut packet = pvs.generateVerificationPacket(sw1, OFPort.of(1), sw2);

    // Source MAC will always be that of sw1 for both Unicast and Broadcast
    byte[] srcMacActual = Arrays.copyOfRange(packet.getData(), 6, 12);
    assertArrayEquals(MacAddress.of(sw1HwAddrTarget).getBytes(), srcMacActual);

    // Destination MAC should be that of sw2 for Unicast Packet
    byte[] dstMacActual = Arrays.copyOfRange(packet.getData(), 0, 6);
    assertArrayEquals(MacAddress.of(sw2HwAddrTarget).getBytes(), dstMacActual);

    // Source and Destination IP's are the respective switch IP's
    byte[] srcIpActual = Arrays.copyOfRange(packet.getData(), 26, 30);
    assertArrayEquals(srcIpTarget.getAddress().getAddress(), srcIpActual);
    byte[] dstIpActual = Arrays.copyOfRange(packet.getData(), 30, 34);
    assertArrayEquals(dstIpTarget.getAddress().getAddress(), dstIpActual);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:20,代码来源:PathVerificationPacketOutTest.java

示例3: verifyDevice

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
/**
 * Verify that the given device exactly matches the given fields. E.g.,
 * if ip is not null we expect the device to have exactly one IP address.
 * swId and port are the attachment point port.
 * Vlan and ip are optional all other fields must be specified.
 * @return
 */
private static void verifyDevice(IDevice d, MacAddress mac, VlanVid vlan, IPv4Address ipv4,
		IPv6Address ipv6, DatapathId swId, OFPort port) {
	assertNotNull(d);
	if (!mac.equals(MacAddress.NONE)) {
		assertEquals(mac, d.getMACAddress());
	}
	if (vlan != null) {
		assertArrayEquals(new VlanVid[] { vlan }, d.getVlanId());
	}
	if (!ipv4.equals(IPv4Address.NONE)) {
		assertArrayEquals(new IPv4Address[] { ipv4 }, d.getIPv4Addresses());
	}
	if (!ipv6.equals(IPv6Address.NONE)) {
		assertArrayEquals(new IPv6Address[] { ipv6 }, d.getIPv6Addresses());
	}
	if (!swId.equals(DatapathId.NONE) && !port.equals(OFPort.ZERO)) {
		SwitchPort expectedAp = new SwitchPort(swId, port);
		assertArrayEquals(new SwitchPort[] { expectedAp }, d.getAttachmentPoints());
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:DeviceManagerImplTest.java

示例4: testGetSwitchPortVlanId

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
@Test
public void testGetSwitchPortVlanId() {
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
	Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(3), IPv4Address.NONE, IPv6Address.NONE,  DatapathId.of(1L), OFPort.of(1), new Date());
	Entity entity4 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(42), IPv4Address.NONE, IPv6Address.NONE,  DatapathId.of(1L), OFPort.of(1), new Date());
	Entity[] entities = new Entity[] { entity1, entity2,
			entity3, entity4
	};
	Device d = new Device(null,1L, null, null, null,
			Arrays.asList(entities), null);
	SwitchPort swp1x1 = new SwitchPort(DatapathId.of(1L), OFPort.of(1));
	SwitchPort swp1x2 = new SwitchPort(DatapathId.of(1L), OFPort.of(2));
	SwitchPort swp2x1 = new SwitchPort(DatapathId.of(2L), OFPort.of(1));
	SwitchPort swp10x1 = new SwitchPort(DatapathId.of(10L), OFPort.of(1));
	assertArrayEquals(new VlanVid[] { VlanVid.ZERO, VlanVid.ofVlan(1)},
			d.getSwitchPortVlanIds(swp10x1));
	assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(3), VlanVid.ofVlan(42)},
			d.getSwitchPortVlanIds(swp1x1));
	assertArrayEquals(new VlanVid[0],
			d.getSwitchPortVlanIds(swp1x2));
	assertArrayEquals(new VlanVid[0],
			d.getSwitchPortVlanIds(swp2x1));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:DeviceManagerImplTest.java

示例5: DeviceIterator

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
/**
 * Construct a new device iterator over the key fields
 * @param subIterator an iterator over the full data structure to scan
 * @param entityClasses the entity classes to search for
 * @param macAddress The MAC address
 * @param vlan the VLAN
 * @param ipv4Address the ipv4 address
 * @param ipv6Address the ipv6 address
 * @param switchDPID the switch DPID
 * @param switchPort the switch port
 */
public DeviceIterator(Iterator<Device> subIterator, 
                      IEntityClass[] entityClasses,
                      MacAddress macAddress,
                      VlanVid vlan, 
                      IPv4Address ipv4Address, 
                      IPv6Address ipv6Address,
                      DatapathId switchDPID,
                      OFPort switchPort) {
    super(subIterator);
    this.entityClasses = entityClasses;
    this.subIterator = subIterator;
    this.macAddress = macAddress;
    this.vlan = vlan;
    this.ipv4Address = ipv4Address;
    this.ipv6Address = ipv6Address;
    this.switchDPID = switchDPID;
    this.switchPort = switchPort;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:30,代码来源:DeviceIterator.java

示例6: init

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
		throws FloodlightModuleException {
	floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
	restApiService = context.getServiceImpl(IRestApiService.class);
	deviceService = context.getServiceImpl(IDeviceService.class);

	vNetsByGuid = new ConcurrentHashMap<String, VirtualNetwork>();
	nameToGuid = new ConcurrentHashMap<String, String>();
	guidToGateway = new ConcurrentHashMap<String, IPv4Address>();
	gatewayToGuid = new ConcurrentHashMap<IPv4Address, Set<String>>();
	macToGuid = new ConcurrentHashMap<MacAddress, String>();
	portToMac = new ConcurrentHashMap<String, MacAddress>();
	macToGateway = new ConcurrentHashMap<MacAddress, IPv4Address>();
	deviceListener = new DeviceListenerImpl();

}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:VirtualNetworkFilter.java

示例7: addHost

import org.projectfloodlight.openflow.types.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, mac);
	} else {
		log.warn("Could not add MAC {} to network ID {} on port {}, the network does not exist",
				new Object[] {mac.toString(), guid, port});
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:VirtualNetworkFilter.java

示例8: createMatchFromPacket

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
	// The packet in match will only contain the port number.
	// We need to add in specifics for the hosts we're routing between.
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	MacAddress srcMac = eth.getSourceMACAddress();
	MacAddress dstMac = eth.getDestinationMACAddress();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	mb.setExact(MatchField.IN_PORT, inPort)
	.setExact(MatchField.ETH_SRC, srcMac)
	.setExact(MatchField.ETH_DST, dstMac);

	if (!vlan.equals(VlanVid.ZERO)) {
		mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
	}

	return mb.build();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:LearningSwitch.java

示例9: addHost

import org.projectfloodlight.openflow.types.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.of(host.mac), host.guid, host.port);
    setStatus(Status.SUCCESS_OK);
    return "{\"status\":\"ok\"}";
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:HostResource.java

示例10: testLastSeen

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
@Test
public void testLastSeen() throws Exception {
	Calendar c = Calendar.getInstance();
	Date d1 = c.getTime();
	Entity entity1 = new Entity(MacAddress.of(1L), null, null, null, null, d1);
	c.add(Calendar.SECOND, 1);
	Entity entity2 = new Entity(MacAddress.of(1L), null, IPv4Address.of(1), null, null, c.getTime());

	IDevice d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(c.getTime(), d.getLastSeen());

	deviceManager.startUp(null);
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(d1, d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:DeviceManagerImplTest.java

示例11: deleteHost

import org.projectfloodlight.openflow.types.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;
				}
			}
		}
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:27,代码来源:VirtualNetworkFilter.java

示例12: LBVip

import org.projectfloodlight.openflow.types.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.of(LB_PROXY_MAC);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:LBVip.java

示例13: decode_set_src_mac

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
/**
 * Parse set_dl_src actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder.
 * 
 * TODO should consider using MacAddress's built-in parser....
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetDlSrc decode_set_src_mac(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("(?:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+))").matcher(actionToDecode); 
	if (n.matches()) {
		MacAddress macaddr = MacAddress.of(get_mac_addr(n, actionToDecode, log));
		if (macaddr != null) {
			OFActionSetDlSrc.Builder ab = OFFactories.getFactory(version).actions().buildSetDlSrc();
			ab.setDlAddr(macaddr);
			log.debug("action {}", ab.build());
			return ab.build();
		}            
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:30,代码来源:ActionUtils.java

示例14: DhcpDiscoveryRequestOFPacketIn

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
    	packetInBuilder
    		.setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
    	packetInBuilder
    	.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:PacketFactory.java

示例15: DeviceIterator

import org.projectfloodlight.openflow.types.MacAddress; //导入依赖的package包/类
/**
 * Construct a new device iterator over the key fields
 * @param subIterator an iterator over the full data structure to scan
 * @param entityClasses the entity classes to search for
 * @param macAddress The MAC address
 * @param vlan the VLAN
 * @param ipv4Address the ipv4 address
 * @param switchDPID the switch DPID
 * @param switchPort the switch port
 */
public DeviceIterator(Iterator<Device> subIterator, 
                      IEntityClass[] entityClasses,
                      MacAddress macAddress,
                      VlanVid vlan, 
                      IPv4Address ipv4Address, 
                      DatapathId switchDPID,
                      OFPort switchPort) {
    super(subIterator);
    this.entityClasses = entityClasses;
    this.subIterator = subIterator;
    this.macAddress = macAddress;
    this.vlan = vlan;
    this.ipv4Address = ipv4Address;
    this.switchDPID = switchDPID;
    this.switchPort = switchPort;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:27,代码来源:DeviceIterator.java


注:本文中的org.projectfloodlight.openflow.types.MacAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。