Search in sources :

Example 86 with MacAddress

use of org.onlab.packet.MacAddress in project onos by opennetworkinglab.

the class DefaultFabricNetworkTest method createInterface.

private static Interface createInterface(int index) {
    String name = "INTF_NAME_" + index;
    ConnectPoint cp = ConnectPoint.fromString("of:0011223344556677/" + index);
    InterfaceIpAddress intfIp1 = InterfaceIpAddress.valueOf("10.10.10." + index + "/32");
    InterfaceIpAddress intfIp2 = InterfaceIpAddress.valueOf("20.20.20." + index + "/32");
    List<InterfaceIpAddress> intfIps = ImmutableList.of(intfIp1, intfIp2);
    MacAddress mac = MacAddress.valueOf("00:00:00:00:00:00");
    VlanId vlanId = VlanId.NONE;
    return new Interface(name, cp, intfIps, mac, vlanId);
}
Also used : MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Example 87 with MacAddress

use of org.onlab.packet.MacAddress in project onos by opennetworkinglab.

the class SimpleFabricNeighbour method handleReply.

/**
 * Handles reply messages between VLAN tagged interfaces.
 *
 * @param context the message context
 * @param hostService the host service
 */
protected void handleReply(NeighbourMessageContext context, HostService hostService) {
    // Find target L2 Network, then reply to the host
    FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
    if (fabricNetwork != null) {
        // TODO: need to check and update simpleFabric.DefaultFabricNetwork
        MacAddress mac = simpleFabric.vMacForIp(context.target());
        if (mac != null) {
            log.trace("simple fabric neightbour response message to virtual gateway; drop: {} {} target={}", context.inPort(), context.vlan(), context.target());
            context.drop();
        } else {
            // forward reply to the hosts of the dstMac
            Set<Host> hosts = hostService.getHostsByMac(context.dstMac());
            log.trace("simple fabric neightbour response message forward: {} {} target={} -> {}", context.inPort(), context.vlan(), context.target(), hosts);
            hosts.stream().map(host -> simpleFabric.hostInterface(host)).filter(Objects::nonNull).forEach(context::forward);
        }
    } else {
        // this might be happened when we remove an interface from L2 Network
        // just ignore this message
        log.warn("simple fabric neightbour response message drop for unknown fabricNetwork: {} {}", context.inPort(), context.vlan());
        context.drop();
    }
}
Also used : Host(org.onosproject.net.Host) MacAddress(org.onlab.packet.MacAddress) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork)

Example 88 with MacAddress

use of org.onlab.packet.MacAddress in project onos by opennetworkinglab.

the class HostServiceAdapter method getHost.

@Override
public Host getHost(HostId hostId) {
    ProviderId providerId = ProviderId.NONE;
    MacAddress mac = MacAddress.valueOf("fa:12:3e:56:ee:a2");
    VlanId vlan = VlanId.NONE;
    HostLocation location = HostLocation.NONE;
    Set<IpAddress> ips = Sets.newHashSet();
    Annotations annotations = null;
    return new DefaultHost(providerId, hostId, mac, vlan, location, ips, annotations);
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DefaultHost(org.onosproject.net.DefaultHost) Annotations(org.onosproject.net.Annotations) HostLocation(org.onosproject.net.HostLocation) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress) VlanId(org.onlab.packet.VlanId)

Example 89 with MacAddress

use of org.onlab.packet.MacAddress in project onos by opennetworkinglab.

the class HostEventTest method createHost.

private Host createHost() {
    MacAddress mac = MacAddress.valueOf("00:00:11:00:00:01");
    VlanId vlan = VlanId.vlanId((short) 10);
    HostLocation loc = new HostLocation(DeviceId.deviceId("of:foo"), PortNumber.portNumber(100), 123L);
    Set<IpAddress> ipset = Sets.newHashSet(IpAddress.valueOf("10.0.0.1"), IpAddress.valueOf("10.0.0.2"));
    HostId hid = HostId.hostId(mac, vlan);
    return new DefaultHost(new ProviderId("of", "foo"), hid, mac, vlan, loc, ipset);
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DefaultHost(org.onosproject.net.DefaultHost) HostLocation(org.onosproject.net.HostLocation) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress) HostId(org.onosproject.net.HostId) VlanId(org.onlab.packet.VlanId)

Example 90 with MacAddress

use of org.onlab.packet.MacAddress in project onos by opennetworkinglab.

the class K8sSwitchingArpHandler method processArpReply.

private void processArpReply(PacketContext context, Ethernet ethPacket) {
    ARP arpPacket = (ARP) ethPacket.getPayload();
    IpAddress srcIp = IpAddress.valueOf(INET, arpPacket.getSenderProtocolAddress());
    MacAddress srcMac = MacAddress.valueOf(arpPacket.getSenderHardwareAddress());
    IpAddress dstIp = IpAddress.valueOf(INET, arpPacket.getTargetProtocolAddress());
    if (dstIp.equals(IpAddress.valueOf(NODE_FAKE_IP_STR))) {
        // mutable MAP scenario is not considered for now
        if (!extHostMacStore.containsKey(srcIp)) {
            extHostMacStore.put(srcIp, srcMac);
        }
        K8sNode k8sNode = k8sNodeService.nodes().stream().filter(n -> n.nodeIp().equals(srcIp)).findAny().orElse(null);
        if (k8sNode == null) {
            return;
        } else {
            if (k8sNode.nodeInfo().nodeMac() != null) {
                return;
            }
        }
        // we update node MAC address which will be referred in node port scenario
        K8sNodeInfo nodeInfo = new K8sNodeInfo(k8sNode.nodeIp(), srcMac);
        K8sNode updatedNode = k8sNode.updateNodeInfo(nodeInfo);
        k8sNodeService.updateNode(updatedNode);
    }
}
Also used : K8sNodeInfo(org.onosproject.k8snode.api.K8sNodeInfo) K8sNode(org.onosproject.k8snode.api.K8sNode) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress) ARP(org.onlab.packet.ARP)

Aggregations

MacAddress (org.onlab.packet.MacAddress)123 IpAddress (org.onlab.packet.IpAddress)52 VlanId (org.onlab.packet.VlanId)46 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)41 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)41 ConnectPoint (org.onosproject.net.ConnectPoint)33 Host (org.onosproject.net.Host)30 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)29 TrafficSelector (org.onosproject.net.flow.TrafficSelector)29 HostLocation (org.onosproject.net.HostLocation)27 HostId (org.onosproject.net.HostId)26 Ethernet (org.onlab.packet.Ethernet)24 DeviceId (org.onosproject.net.DeviceId)23 Interface (org.onosproject.net.intf.Interface)22 Set (java.util.Set)20 DhcpRecord (org.onosproject.dhcprelay.store.DhcpRecord)19 Device (org.onosproject.net.Device)19 Logger (org.slf4j.Logger)19 ProviderId (org.onosproject.net.provider.ProviderId)18 Ip4Address (org.onlab.packet.Ip4Address)16