• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MacAddress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testSingleHostByMacAndVlanFetch

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Tests fetch of one host by mac and vlan.
 */
@Test
public void testSingleHostByMacAndVlanFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01/1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:HostResourceTest.java


示例2: testSingleHostByIdFetch

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Tests fetch of one host by Id.
 */
@Test
public void testSingleHostByIdFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01%2F1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:HostResourceTest.java


示例3: createHost

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Creates a default host connected at the given edge device and port. Note
 * that an identifying hex character ("a" - "f") should be supplied. This
 * will be included in the MAC address of the host (and equivalent value
 * as last byte in IP address).
 *
 * @param device  edge device
 * @param port    port number
 * @param hexChar identifying hex character
 * @return host connected at that location
 */
protected static Host createHost(Device device, int port, String hexChar) {
    DeviceId deviceId = device.id();
    String devNum = deviceId.toString().substring(1);

    MacAddress mac = MacAddress.valueOf(HOST_MAC_PREFIX + devNum + hexChar);
    HostId hostId = hostId(String.format("%s/-1", mac));

    int ipByte = Integer.valueOf(hexChar, 16);
    if (ipByte < 10 || ipByte > 15) {
        throw new IllegalArgumentException("hexChar must be a-f");
    }
    HostLocation loc = new HostLocation(deviceId, portNumber(port), 0);

    IpAddress ip = ip("10." + devNum + ".0." + ipByte);

    return new DefaultHost(ProviderId.NONE, hostId, mac, VlanId.NONE,
            loc, ImmutableSet.of(ip));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:AbstractTopoModelTest.java


示例4: createVbng

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Creates a new vBNG.
 *
 * @param privateIpAddress a private IP address
 * @param publicIpAddress the public IP address for the private IP address
 * @param hostMacAddress the MAC address for the private IP address
 * @param hostName the host name for the private IP address
 */
private void createVbng(IpAddress privateIpAddress,
                        IpAddress publicIpAddress,
                        MacAddress hostMacAddress,
                        String hostName) {
    boolean result = vbngConfigurationService
            .assignSpecifiedPublicIp(publicIpAddress, privateIpAddress);
    if (!result) {
        log.info("Assign public IP address {} for private IP address {} "
                + "failed!", publicIpAddress, privateIpAddress);
        log.info("Failed to create vBNG for private IP address {}",
                 privateIpAddress);
        return;
    }
    log.info("[ADD] Private IP to Public IP mapping: {} --> {}",
             privateIpAddress, publicIpAddress);

    // Setup paths between the host configured with private IP and
    // next hop
    if (!setupForwardingPaths(privateIpAddress, publicIpAddress,
                              hostMacAddress, hostName)) {
        privateIpAddressMap.put(privateIpAddress,
                                new VcpeHost(hostMacAddress, hostName));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:VbngManager.java


示例5: createPeerGroup

import org.onlab.packet.MacAddress; //导入依赖的package包/类
private int createPeerGroup(MacAddress srcMac, MacAddress dstMac,
        VlanId vlanId, DeviceId deviceId, PortNumber port) {
    int nextId = flowObjectiveService.allocateNextId();
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
            .withId(nextId)
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(appId);

    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    ttBuilder.setEthSrc(srcMac);
    ttBuilder.setEthDst(dstMac);
    ttBuilder.setOutput(port);
    nextObjBuilder.addTreatment(ttBuilder.build());

    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    VlanId matchVlanId = (vlanId.equals(VlanId.NONE)) ?
            VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN) :
            vlanId;
    metabuilder.matchVlanId(matchVlanId);
    nextObjBuilder.withMeta(metabuilder.build());

    flowObjectiveService.next(deviceId, nextObjBuilder.add());
    return nextId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ControlPlaneRedirectManager.java


示例6: processAppConfigUpdated

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Processes Segment Routing App Config updated event.
 *
 * @param event network config updated event
 */
protected void processAppConfigUpdated(NetworkConfigEvent event) {
    log.info("Processing vRouter CONFIG_UPDATED");
    SegmentRoutingAppConfig config = (SegmentRoutingAppConfig) event.config().get();
    SegmentRoutingAppConfig prevConfig = (SegmentRoutingAppConfig) event.prevConfig().get();
    deviceService.getAvailableDevices().forEach(device -> {
        Set<MacAddress> macAddresses = new HashSet<>(getMacAddresses(config));
        Set<MacAddress> prevMacAddresses = new HashSet<>(getMacAddresses(prevConfig));
        // Avoid removing and re-adding unchanged MAC addresses since
        // FlowObjective does not guarantee the execution order.
        Set<MacAddress> sameMacAddresses = new HashSet<>(macAddresses);
        sameMacAddresses.retainAll(prevMacAddresses);
        macAddresses.removeAll(sameMacAddresses);
        prevMacAddresses.removeAll(sameMacAddresses);

        revokeVRouter(device.id(), prevMacAddresses);
        populateVRouter(device.id(), macAddresses);
    });

}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:AppConfigHandler.java


示例7: getMacFromOpenstack

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Returns MAC address of a host with a given target IP address by asking to
 * OpenStack. It does not support overlapping IP.
 *
 * @param targetIp target ip address
 * @return mac address, or null if it fails to fetch the mac
 */
private MacAddress getMacFromOpenstack(IpAddress targetIp) {
    checkNotNull(targetIp);

    OpenstackPort openstackPort = openstackService.ports()
            .stream()
            .filter(port -> port.fixedIps().containsValue(targetIp))
            .findFirst()
            .orElse(null);

    if (openstackPort != null) {
        log.debug("Found MAC from OpenStack for {}", targetIp.toString());
        return openstackPort.macAddress();
    } else {
        return null;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OpenstackArpHandler.java


示例8: buildArpRequest

import org.onlab.packet.MacAddress; //导入依赖的package包/类
private Ethernet buildArpRequest(IpAddress targetIp, IpAddress sourceIp,
                                 MacAddress sourceMac) {
    ARP arp = new ARP();
    arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
       .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
       .setProtocolType(ARP.PROTO_TYPE_IP)
       .setProtocolAddressLength((byte) Ip4Address.BYTE_LENGTH)
       .setOpCode(ARP.OP_REQUEST);

    arp.setSenderHardwareAddress(sourceMac.toBytes())
       .setSenderProtocolAddress(sourceIp.getIp4Address().toInt())
       .setTargetHardwareAddress(ZERO_MAC_ADDRESS)
       .setTargetProtocolAddress(targetIp.getIp4Address().toInt());

    Ethernet ethernet = new Ethernet();
    ethernet.setEtherType(Ethernet.TYPE_ARP)
            .setDestinationMACAddress(MacAddress.BROADCAST)
            .setSourceMACAddress(sourceMac)
            .setPayload(arp);

    ethernet.setPad(true);
    return ethernet;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:VtnManager.java


示例9: populateFloatingIpOutgoingRules

import org.onlab.packet.MacAddress; //导入依赖的package包/类
private void populateFloatingIpOutgoingRules(OpenstackFloatingIP floatingIP, OpenstackPort port) {
    Port outputPort = checkNotNull(getPortOfExternalInterface(), PORTNOTNULL);

    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();

    sBuilder.matchEthType(Ethernet.TYPE_IPV4)
            .matchTunnelId(getVni(port.networkId()))
            .matchIPSrc(IpPrefix.valueOf(floatingIP.fixedIpAddress(), 32));

    tBuilder.setIpSrc(floatingIP.floatingIpAddress())
            .setEthSrc(MacAddress.valueOf(config.gatewayExternalInterfaceMac()))
            .setEthDst(MacAddress.valueOf(config.physicalRouterMac()))
            .setOutput(outputPort.number());

    ForwardingObjective fo = DefaultForwardingObjective.builder()
            .withSelector(sBuilder.build())
            .withTreatment(tBuilder.build())
            .withFlag(ForwardingObjective.Flag.VERSATILE)
            .withPriority(FLOATING_RULE_PRIORITY)
            .fromApp(appId)
            .add();

    flowObjectiveService.forward(getGatewayNode().id(), fo);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:OpenstackRoutingRulePopulator.java


示例10: setUp

import org.onlab.packet.MacAddress; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();
    Host hostOne = createMock(Host.class);
    expect(hostOne.mac()).andReturn(new MacAddress(HOST_ONE_MAC.getBytes())).anyTimes();
    expect(hostOne.vlan()).andReturn(VlanId.vlanId()).anyTimes();
    replay(hostOne);

    Host hostTwo = createMock(Host.class);
    expect(hostTwo.mac()).andReturn(new MacAddress(HOST_TWO_MAC.getBytes())).anyTimes();
    expect(hostTwo.vlan()).andReturn(VlanId.vlanId()).anyTimes();
    replay(hostTwo);

    mockHostService = createMock(HostService.class);
    expect(mockHostService.getHost(eq(hostOneId))).andReturn(hostOne).anyTimes();
    expect(mockHostService.getHost(eq(hostTwoId))).andReturn(hostTwo).anyTimes();
    replay(mockHostService);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:HostToHostIntentCompilerTest.java


示例11: testTrafficTreatmentEncode

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Tests encoding of a traffic treatment object.
 */
@Test
public void testTrafficTreatmentEncode() {

    Instruction output = Instructions.createOutput(PortNumber.portNumber(0));
    Instruction modL2Src = Instructions.modL2Src(MacAddress.valueOf("11:22:33:44:55:66"));
    Instruction modL2Dst = Instructions.modL2Dst(MacAddress.valueOf("44:55:66:77:88:99"));
    MeterId meterId = MeterId.meterId(0);
    Instruction meter = Instructions.meterTraffic(meterId);
    Instruction transition = Instructions.transition(1);
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
    TrafficTreatment treatment = tBuilder
            .add(output)
            .add(modL2Src)
            .add(modL2Dst)
            .add(meter)
            .add(transition)
            .build();

    ObjectNode treatmentJson = trafficTreatmentCodec.encode(treatment, context);
    assertThat(treatmentJson, TrafficTreatmentJsonMatcher.matchesTrafficTreatment(treatment));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:TrafficTreatmentCodecTest.java


示例12: inPacket

import org.onlab.packet.MacAddress; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
    RouterAdvertisement ns = new RouterAdvertisement();
    ICMP6 icmp6 = new ICMP6();
    icmp6.setPayload(ns);
    IPv6 ipv6 = new IPv6();
    ipv6.setPayload(icmp6);
    ipv6.setDestinationAddress(Ip6Address.valueOf("ff02::1").toOctets());
    ipv6.setSourceAddress(IP2);
    Ethernet eth = new Ethernet();
    eth.setEtherType(Ethernet.TYPE_IPV6)
            .setVlanID(VLAN.toShort())
            .setSourceMACAddress(MAC2.toBytes())
            .setDestinationMACAddress(MacAddress.valueOf("33:33:00:00:00:01"))
            .setPayload(ipv6);
    ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId),
                                                 portNumber(INPORT));
    return new DefaultInboundPacket(receivedFrom, eth,
                                    ByteBuffer.wrap(eth.serialize()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:HostLocationProviderTest.java


示例13: removeStaticIP

import org.onlab.packet.MacAddress; //导入依赖的package包/类
@Override
public boolean removeStaticIP(MacAddress macID) {
    HostId host = HostId.hostId(macID);
    if (allocationMap.containsKey(host)) {
        IpAssignment assignment = allocationMap.get(host).value();

        if (assignment.assignmentStatus().equals(Option_RangeNotEnforced)) {
            allocationMap.remove(host);
            return true;
        }

        Ip4Address freeIP = assignment.ipAddress();
        if (assignment.leasePeriod() < 0) {
            allocationMap.remove(host);
            if (ipWithinRange(freeIP)) {
                freeIPPool.add(freeIP);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DistributedDhcpStore.java


示例14: revokeIpRuleForHost

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Removes IP rules for host when the host is gone.
 *
 * @param deviceId device ID of the device that host attaches to
 * @param hostIp IP address of the host
 * @param hostMac MAC address of the host
 * @param outPort port that host attaches to
 */
public void revokeIpRuleForHost(DeviceId deviceId, Ip4Address hostIp,
        MacAddress hostMac, PortNumber outPort) {
    log.debug("Revoke IP table entry for host {} at {}:{}",
            hostIp, deviceId, outPort);
    ForwardingObjective.Builder fwdBuilder;
    try {
        fwdBuilder = getForwardingObjectiveBuilder(
                deviceId, hostIp, hostMac, outPort);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting revokeIpRuleForHost.");
        return;
    }
    ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("IP rule for host {} revoked", hostIp),
            (objective, error) ->
                    log.warn("Failed to revoke IP rule for host {}: {}", hostIp, error));
    srManager.flowObjectiveService.forward(deviceId, fwdBuilder.remove(context));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:RoutingRulePopulator.java


示例15: populateIpRuleForHost

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Populates IP flow rules for specific hosts directly connected to the
 * switch.
 *
 * @param deviceId switch ID to set the rules
 * @param hostIp host IP address
 * @param hostMac host MAC address
 * @param outPort port where the host is connected
 */
public void populateIpRuleForHost(DeviceId deviceId, Ip4Address hostIp,
                                  MacAddress hostMac, PortNumber outPort) {
    log.debug("Populate IP table entry for host {} at {}:{}",
            hostIp, deviceId, outPort);
    ForwardingObjective.Builder fwdBuilder;
    try {
        fwdBuilder = getForwardingObjectiveBuilder(
                deviceId, hostIp, hostMac, outPort);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting populateIpRuleForHost.");
        return;
    }
    if (fwdBuilder == null) {
        log.warn("Aborting host routing table entries due "
                + "to error for dev:{} host:{}", deviceId, hostIp);
        return;
    }
    ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("IP rule for host {} populated", hostIp),
            (objective, error) ->
                    log.warn("Failed to populate IP rule for host {}: {}", hostIp, error));
    srManager.flowObjectiveService.forward(deviceId, fwdBuilder.add(context));
    rulePopulationCounter.incrementAndGet();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:RoutingRulePopulator.java


示例16: sendRequestPacketToExt

import org.onlab.packet.MacAddress; //导入依赖的package包/类
private void sendRequestPacketToExt(IPv4 icmpRequestIpv4, ICMP icmpRequest, DeviceId deviceId,
                                    Ip4Address pNatIpAddress) {
    icmpRequest.resetChecksum();
    icmpRequestIpv4.setSourceAddress(pNatIpAddress.toInt())
            .resetChecksum();
    icmpRequestIpv4.setPayload(icmpRequest);

    Ethernet icmpRequestEth = new Ethernet();

    icmpRequestEth.setEtherType(Ethernet.TYPE_IPV4)
            .setSourceMACAddress(MacAddress.valueOf(config.gatewayExternalInterfaceMac()))
            .setDestinationMACAddress(MacAddress.valueOf(config.physicalRouterMac()))
            .setPayload(icmpRequestIpv4);

    TrafficTreatment treatment = DefaultTrafficTreatment.builder()
            .setOutput(getPortForAnnotationPortName(DeviceId.deviceId(config.gatewayBridgeId()),
                    config.gatewayExternalInterfaceName()))
            .build();

    OutboundPacket packet = new DefaultOutboundPacket(deviceId,
            treatment, ByteBuffer.wrap(icmpRequestEth.serialize()));

    packetService.emit(packet);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:OpenstackIcmpHandler.java


示例17: createSouthboundGroupEntry

import org.onlab.packet.MacAddress; //导入依赖的package包/类
private Group createSouthboundGroupEntry(GroupId gId,
                                         List<PortNumber> ports,
                                         long referenceCount, DeviceId deviceId) {
    List<PortNumber> outPorts = new ArrayList<>();
    outPorts.addAll(ports);

    List<GroupBucket> buckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber)
                .setEthDst(MacAddress.valueOf("00:00:00:00:00:02"))
                .setEthSrc(MacAddress.valueOf("00:00:00:00:00:01"))
                .pushMpls()
                .setMpls(MplsLabel.mplsLabel(106));
        buckets.add(DefaultGroupBucket.createSelectGroupBucket(
                tBuilder.build()));
    }
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    StoredGroupEntry group = new DefaultGroup(
            gId, deviceId, Group.Type.SELECT, groupBuckets);
    group.setReferenceCount(referenceCount);
    return group;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:GroupManagerTest.java


示例18: pickForwardPathIfPossible

import org.onlab.packet.MacAddress; //导入依赖的package包/类
private Path pickForwardPathIfPossible(Set<Path> paths, PortNumber notToPort,
                                           MacAddress srcHost, MacAddress destHost) {
        Path lastPath = null;
        boolean match = false;
        List<DeviceId> route = pathForSecurity;

        for (Path path : paths) {
//            for (int i = 0; i < 2; i++) {
//                Path targetPath = i == 0 ? path.primary() : path.backup();
                Path targetPath = path;

                for (Link link : targetPath.links()) {
                    DeviceId srcDpid = link.src().deviceId();
                    DeviceId dstDpid = link.dst().deviceId();

                    if (route.contains(srcDpid) && route.contains(dstDpid)) {
                        match = true;
                    } else {
                        match = false;
                        break;
                    }
                }
            if (match) {
                lastPath = targetPath;
                break;
            }
//        }
//            if (match) {
//                break;
//            }
        }
        return lastPath;
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:SimpleSecurityRouting.java


示例19: setupMockFlows

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Populates some flows used as testing data.
 */
private void setupMockFlows() {
    flow2.treatment = DefaultTrafficTreatment.builder()
            .setEthDst(MacAddress.BROADCAST)
            .build();
    flow2.selector = DefaultTrafficSelector.builder()
            .matchEthType((short) 3)
            .matchIPProtocol((byte) 9)
            .build();
    flow4.treatment = DefaultTrafficTreatment.builder()
            .build();
    final Set<FlowEntry> flows1 = new HashSet<>();
    flows1.add(flow1);
    flows1.add(flow2);

    final Set<FlowEntry> flows2 = new HashSet<>();
    flows2.add(flow3);
    flows2.add(flow4);

    rules.put(deviceId1, flows1);
    rules.put(deviceId2, flows2);

    expect(mockFlowService.getFlowEntries(deviceId1))
            .andReturn(rules.get(deviceId1)).anyTimes();
    expect(mockFlowService.getFlowEntries(deviceId2))
            .andReturn(rules.get(deviceId2)).anyTimes();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:FlowsResourceTest.java


示例20: testReplyToRequestFromUsIpv6

import org.onlab.packet.MacAddress; //导入依赖的package包/类
/**
 * Test NDP request from internal network to an external host.
 */
@Test
public void testReplyToRequestFromUsIpv6() {
    Ip6Address ourIp = Ip6Address.valueOf("1000::1");
    MacAddress ourMac = MacAddress.valueOf(1L);
    Ip6Address theirIp = Ip6Address.valueOf("1000::100");

    expect(hostService.getHostsByIp(theirIp)).andReturn(Collections.emptySet());
    expect(interfaceService.getInterfacesByIp(ourIp))
            .andReturn(Collections.singleton(new Interface(getLocation(1),
                    Collections.singletonList(new InterfaceIpAddress(
                            ourIp,
                            IpPrefix.valueOf("1000::1/64"))),
                            ourMac,
                            VLAN1)));
    expect(hostService.getHost(HostId.hostId(ourMac, VLAN1))).andReturn(null);
    replay(hostService);
    replay(interfaceService);

    // This is a request from something inside our network (like a BGP
    // daemon) to an external host.
    Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
            ourMac,
            MacAddress.valueOf("33:33:ff:00:00:01"),
            ourIp,
            theirIp);

    proxyArp.reply(ndpRequest, getLocation(5));
    assertEquals(1, packetService.packets.size());
    verifyPacketOut(ndpRequest, getLocation(1), packetService.packets.get(0));

    // The same request from a random external port should fail
    packetService.packets.clear();
    proxyArp.reply(ndpRequest, getLocation(2));
    assertEquals(0, packetService.packets.size());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:ProxyArpManagerTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NonResizableHandleKit类代码示例发布时间:2022-05-22
下一篇:
Java PlayerChatEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap