Search in sources :

Example 11 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class SdnIpFibTest method setUpInterfaceService.

/**
 * Sets up the interface service.
 */
private void setUpInterfaceService() {
    List<InterfaceIpAddress> iIps1 = Lists.newArrayList();
    iIps1.add(IIP1);
    Interface sw1Eth1 = new Interface("sw1-eth1", SW1_ETH1, iIps1, MAC1, VLAN10);
    interfaces.add(sw1Eth1);
    List<InterfaceIpAddress> iIps2 = Lists.newArrayList();
    iIps2.add(IIP2);
    Interface sw2Eth1 = new Interface("sw2-eth1", SW2_ETH1, iIps2, MAC2, VLAN20);
    interfaces.add(sw2Eth1);
    List<InterfaceIpAddress> iIps3 = Lists.newArrayList();
    iIps3.add(IIP3);
    Interface sw3Eth1 = new Interface("sw3-eth1", SW3_ETH1, iIps3, MAC3, NO_VLAN);
    interfaces.add(sw3Eth1);
    expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(Collections.singleton(sw1Eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IP1)).andReturn(sw1Eth1).anyTimes();
    expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(Collections.singleton(sw2Eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IP2)).andReturn(sw2Eth1).anyTimes();
    expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(Collections.singleton(sw3Eth1)).anyTimes();
    expect(interfaceService.getMatchingInterface(IP3)).andReturn(sw3Eth1).anyTimes();
    expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
}
Also used : InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Interface(org.onosproject.net.intf.Interface)

Example 12 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class InterfaceConfigTest method getIp.

private InterfaceIpAddress getIp(int index, int position) {
    IpPrefix subnet1 = IpPrefix.valueOf("1.2.0.0/16");
    IpAddress ip = IpAddress.valueOf("1.2.3." + Integer.toString(index + ((position - 1) * 10)));
    return new InterfaceIpAddress(ip, subnet1);
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) IpAddress(org.onlab.packet.IpAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 13 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class InterfaceConfig method getIps.

private List<InterfaceIpAddress> getIps(JsonNode node) {
    List<InterfaceIpAddress> ips = Lists.newArrayList();
    JsonNode ipsNode = node.get(IPS);
    if (ipsNode != null) {
        ipsNode.forEach(jsonNode -> ips.add(InterfaceIpAddress.valueOf(jsonNode.asText())));
    }
    return ips;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress)

Example 14 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class IcmpHandler method processPacketIn.

private void processPacketIn(InboundPacket pkt) {
    boolean ipMatches = false;
    Ethernet ethernet = pkt.parsed();
    IPv4 ipv4 = (IPv4) ethernet.getPayload();
    ConnectPoint connectPoint = pkt.receivedFrom();
    IpAddress destIpAddress = IpAddress.valueOf(ipv4.getDestinationAddress());
    Interface targetInterface = interfaceService.getMatchingInterface(destIpAddress);
    if (targetInterface == null) {
        log.trace("No matching interface for {}", destIpAddress);
        return;
    }
    for (InterfaceIpAddress interfaceIpAddress : targetInterface.ipAddressesList()) {
        if (interfaceIpAddress.ipAddress().equals(destIpAddress)) {
            ipMatches = true;
            break;
        }
    }
    if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST && ipMatches) {
        sendIcmpResponse(ethernet, connectPoint);
    }
}
Also used : Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) IpAddress(org.onlab.packet.IpAddress) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) ICMP(org.onlab.packet.ICMP)

Example 15 with InterfaceIpAddress

use of org.onosproject.net.host.InterfaceIpAddress in project onos by opennetworkinglab.

the class InterfaceAddCommand method doExecute.

@Override
protected void doExecute() {
    InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
    List<InterfaceIpAddress> ipAddresses = Lists.newArrayList();
    if (ips != null) {
        for (String strIp : ips) {
            ipAddresses.add(InterfaceIpAddress.valueOf(strIp));
        }
    }
    MacAddress macAddr = mac == null ? null : MacAddress.valueOf(mac);
    VlanId vlanId = vlan == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(vlan));
    Interface intf = new Interface(name, ConnectPoint.deviceConnectPoint(connectPoint), ipAddresses, macAddr, vlanId);
    interfaceService.add(intf);
    print("Interface added");
}
Also used : InterfaceAdminService(org.onosproject.net.intf.InterfaceAdminService) MacAddress(org.onlab.packet.MacAddress) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Aggregations

InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)28 Interface (org.onosproject.net.intf.Interface)21 ConnectPoint (org.onosproject.net.ConnectPoint)16 ArrayList (java.util.ArrayList)11 IpAddress (org.onlab.packet.IpAddress)9 MacAddress (org.onlab.packet.MacAddress)9 VlanId (org.onlab.packet.VlanId)9 DeviceId (org.onosproject.net.DeviceId)9 Ethernet (org.onlab.packet.Ethernet)5 IPv4 (org.onlab.packet.IPv4)5 PortNumber (org.onosproject.net.PortNumber)5 TrafficSelector (org.onosproject.net.flow.TrafficSelector)5 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 HashMultimap (com.google.common.collect.HashMultimap)4 Lists (com.google.common.collect.Lists)4 Sets (com.google.common.collect.Sets)4 Collections (java.util.Collections)4 List (java.util.List)4 Set (java.util.Set)4