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();
}
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);
}
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;
}
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);
}
}
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");
}
Aggregations