Usages of

org.onosproject.net.host.HostService.getAddressBindingsForPort(?)
private HostService hostService; // code omitted ... /** * Creates both a PortAddresses and an Interface for the given inputs and * places them in the correct global data stores. * * @param cp the connect point * @param ipAddresses the set of interface IP addresses * @param mac the MAC address * @param vlan the VLAN ID */ private void createPortAddressesAndInterface( ConnectPoint cp, Set<InterfaceIpAddress> ipAddresses, MacAddress mac, VlanId vlan) { PortAddresses pa = new PortAddresses(cp, ipAddresses, mac, vlan); portAddresses.add(pa); expect(hostService.getAddressBindingsForPort(cp)).andReturn( Collections.singleton(pa)).anyTimes(); Interface intf = new Interface(cp, ipAddresses, mac, vlan); interfaces.put(cp, intf); }
private HostService hostService; // code omitted ... /** * Creates both a PortAddresses and an Interface for the given inputs and * places them in the correct global data stores. * * @param cp the connect point * @param ipAddresses the set of interface IP addresses * @param mac the MAC address */ private void createPortAddressesAndInterface( ConnectPoint cp, Set<InterfaceIpAddress> ipAddresses, MacAddress mac) { PortAddresses pa = new PortAddresses(cp, ipAddresses, mac); portAddresses.add(pa); expect(hostService.getAddressBindingsForPort(cp)).andReturn( Collections.singleton(pa)).anyTimes(); Interface intf = new Interface(cp, ipAddresses, mac); interfaces.put(cp, intf); }
public HostToInterfaceAdaptor(HostService hostService) { // code omitted ... public Interface getInterface(ConnectPoint connectPoint) { checkNotNull(connectPoint); Set<PortAddresses> portAddresses = hostService.getAddressBindingsForPort(connectPoint); for (PortAddresses addresses : portAddresses) { if (addresses.connectPoint().equals(connectPoint)) { return new Interface(addresses); } } return null; }
public HostToInterfaceAdaptor(HostService hostService) { // code omitted ... @Override public Interface getInterface(ConnectPoint connectPoint) { checkNotNull(connectPoint); Set<PortAddresses> portAddresses = hostService.getAddressBindingsForPort(connectPoint); for (PortAddresses addresses : portAddresses) { if (addresses.connectPoint().equals(connectPoint)) { return new Interface(addresses); } } return null; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public void reply(Ethernet eth, ConnectPoint inPort) { checkNotNull(eth, REQUEST_NULL); checkArgument(eth.getEtherType() == Ethernet.TYPE_ARP, REQUEST_NOT_ARP); ARP arp = (ARP) eth.getPayload(); checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); checkNotNull(inPort); // If the request came from outside the network, only reply if it was // for one of our external addresses. if (isOutsidePort(inPort)) { Ip4Address target = Ip4Address.valueOf(arp.getTargetProtocolAddress()); Set<PortAddresses> addressSet = hostService.getAddressBindingsForPort(inPort); for (PortAddresses addresses : addressSet) { for (InterfaceIpAddress ia : addresses.ipAddresses()) { if (ia.ipAddress().equals(target)) { Ethernet arpReply = buildArpReply(target, addresses.mac(), eth); sendTo(arpReply, inPort); } } } return; } else { // If the source address matches one of our external addresses // it could be a request from an internal host to an external // address. Forward it over to the correct ports. Ip4Address source = Ip4Address.valueOf(arp.getSenderProtocolAddress()); Set<PortAddresses> sourceAddresses = findPortsInSubnet(source); boolean matched = false; for (PortAddresses pa : sourceAddresses) { for (InterfaceIpAddress ia : pa.ipAddresses()) { if (ia.ipAddress().equals(source)) { matched = true; sendTo(eth, pa.connectPoint()); } } } if (matched) { return; } } // Continue with normal proxy ARP case VlanId vlan = VlanId.vlanId(eth.getVlanID()); Set<Host> hosts = hostService.getHostsByIp( Ip4Address.valueOf(arp.getTargetProtocolAddress())); Host dst = null; Host src = hostService.getHost(HostId.hostId(eth.getSourceMAC(), VlanId.vlanId(eth.getVlanID()))); for (Host host : hosts) { if (host.vlan().equals(vlan)) { dst = host; break; } } if (src == null || dst == null) { flood(eth); return; } // // TODO find the correct IP address. // Right now we use the first IPv4 address that is found. // for (IpAddress ipAddress : dst.ipAddresses()) { Ip4Address ip4Address = ipAddress.getIp4Address(); if (ip4Address != null) { Ethernet arpReply = buildArpReply(ip4Address, dst.mac(), eth); // TODO: check send status with host service. sendTo(arpReply, src.location()); break; } } }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private void replyArp(Ethernet eth, ConnectPoint inPort) { ARP arp = (ARP) eth.getPayload(); checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); checkNotNull(inPort); Ip4Address targetAddress = Ip4Address.valueOf(arp.getTargetProtocolAddress()); VlanId vlan = VlanId.vlanId(eth.getVlanID()); if (isOutsidePort(inPort)) { // If the request came from outside the network, only reply if it was // for one of our external addresses. Set<PortAddresses> addressSet = hostService.getAddressBindingsForPort(inPort); for (PortAddresses addresses : addressSet) { for (InterfaceIpAddress ia : addresses.ipAddresses()) { if (ia.ipAddress().equals(targetAddress)) { Ethernet arpReply = buildArpReply(targetAddress, addresses.mac(), eth); sendTo(arpReply, inPort); } } } return; } // See if we have the target host in the host store Set<Host> hosts = hostService.getHostsByIp(targetAddress); Host dst = null; Host src = hostService.getHost(HostId.hostId(eth.getSourceMAC(), VlanId.vlanId(eth.getVlanID()))); for (Host host : hosts) { if (host.vlan().equals(vlan)) { dst = host; break; } } if (src != null && dst != null) { // We know the target host so we can respond Ethernet arpReply = buildArpReply(targetAddress, dst.mac(), eth); sendTo(arpReply, inPort); return; } // If the source address matches one of our external addresses // it could be a request from an internal host to an external // address. Forward it over to the correct port. Ip4Address source = Ip4Address.valueOf(arp.getSenderProtocolAddress()); Set<PortAddresses> sourceAddresses = findPortsInSubnet(source); boolean matched = false; for (PortAddresses pa : sourceAddresses) { for (InterfaceIpAddress ia : pa.ipAddresses()) { if (ia.ipAddress().equals(source) && pa.vlan().equals(vlan)) { matched = true; sendTo(eth, pa.connectPoint()); break; } } } if (matched) { return; } // // The request couldn't be resolved. // Flood the request on all ports except the incoming port. // flood(eth, inPort); return; }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private void replyArp(Ethernet eth, ConnectPoint inPort) { ARP arp = (ARP) eth.getPayload(); checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); checkNotNull(inPort); Ip4Address targetAddress = Ip4Address.valueOf(arp.getTargetProtocolAddress()); VlanId vlan = VlanId.vlanId(eth.getVlanID()); if (isOutsidePort(inPort)) { // If the request came from outside the network, only reply if it was // for one of our external addresses. Set<PortAddresses> addressSet = hostService.getAddressBindingsForPort(inPort); for (PortAddresses addresses : addressSet) { for (InterfaceIpAddress ia : addresses.ipAddresses()) { if (ia.ipAddress().equals(targetAddress)) { Ethernet arpReply = ARP.buildArpReply(targetAddress, addresses.mac(), eth); sendTo(arpReply, inPort); } } } return; } // See if we have the target host in the host store Set<Host> hosts = hostService.getHostsByIp(targetAddress); Host dst = null; Host src = hostService.getHost(HostId.hostId(eth.getSourceMAC(), VlanId.vlanId(eth.getVlanID()))); for (Host host : hosts) { if (host.vlan().equals(vlan)) { dst = host; break; } } if (src != null && dst != null) { // We know the target host so we can respond Ethernet arpReply = ARP.buildArpReply(targetAddress, dst.mac(), eth); sendTo(arpReply, inPort); return; } // If the source address matches one of our external addresses // it could be a request from an internal host to an external // address. Forward it over to the correct port. Ip4Address source = Ip4Address.valueOf(arp.getSenderProtocolAddress()); Set<PortAddresses> sourceAddresses = findPortsInSubnet(source); boolean matched = false; for (PortAddresses pa : sourceAddresses) { for (InterfaceIpAddress ia : pa.ipAddresses()) { if (ia.ipAddress().equals(source) && pa.vlan().equals(vlan)) { matched = true; sendTo(eth, pa.connectPoint()); break; } } } if (matched) { return; } // // The request couldn't be resolved. // Flood the request on all ports except the incoming port. // flood(eth, inPort); return; }
private HostService hostService; // code omitted ... private void addAddressBindings() { Set<PortAddresses> addresses = Sets.newHashSet(); for (int i = 1; i <= NUM_ADDRESS_PORTS; i++) { ConnectPoint cp = new ConnectPoint(getDeviceId(i), P1); Ip4Prefix prefix1 = Ip4Prefix.valueOf("10.0." + (2 * i - 1) + ".0/24"); Ip4Address addr1 = Ip4Address.valueOf("10.0." + (2 * i - 1) + ".1"); Ip4Prefix prefix2 = Ip4Prefix.valueOf("10.0." + (2 * i) + ".0/24"); Ip4Address addr2 = Ip4Address.valueOf("10.0." + (2 * i) + ".1"); InterfaceIpAddress ia1 = new InterfaceIpAddress(addr1, prefix1); InterfaceIpAddress ia2 = new InterfaceIpAddress(addr2, prefix2); PortAddresses pa1 = new PortAddresses(cp, Sets.newHashSet(ia1), MacAddress.valueOf(2 * i - 1), VlanId.vlanId((short) 1)); PortAddresses pa2 = new PortAddresses(cp, Sets.newHashSet(ia2), MacAddress.valueOf(2 * i), VlanId.NONE); addresses.add(pa1); addresses.add(pa2); expect(hostService.getAddressBindingsForPort(cp)) .andReturn(Sets.newHashSet(pa1, pa2)).anyTimes(); } expect(hostService.getAddressBindings()).andReturn(addresses).anyTimes(); for (int i = 1; i <= NUM_FLOOD_PORTS; i++) { ConnectPoint cp = new ConnectPoint(getDeviceId(i + NUM_ADDRESS_PORTS), P1); expect(hostService.getAddressBindingsForPort(cp)) .andReturn(Collections.<PortAddresses>emptySet()).anyTimes(); } }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... @Override public void reply(Ethernet eth, ConnectPoint inPort) { checkNotNull(eth, REQUEST_NULL); checkArgument(eth.getEtherType() == Ethernet.TYPE_ARP, REQUEST_NOT_ARP); ARP arp = (ARP) eth.getPayload(); checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); checkNotNull(inPort); // If the request came from outside the network, only reply if it was // for one of our external addresses. if (isOutsidePort(inPort)) { Ip4Address target = Ip4Address.valueOf(arp.getTargetProtocolAddress()); Set<PortAddresses> addressSet = hostService.getAddressBindingsForPort(inPort); for (PortAddresses addresses : addressSet) { for (InterfaceIpAddress ia : addresses.ipAddresses()) { if (ia.ipAddress().equals(target)) { Ethernet arpReply = buildArpReply(target, addresses.mac(), eth); sendTo(arpReply, inPort); } } } return; } else { // If the source address matches one of our external addresses // it could be a request from an internal host to an external // address. Forward it over to the correct ports. Ip4Address source = Ip4Address.valueOf(arp.getSenderProtocolAddress()); Set<PortAddresses> sourceAddresses = findPortsInSubnet(source); boolean matched = false; for (PortAddresses pa : sourceAddresses) { for (InterfaceIpAddress ia : pa.ipAddresses()) { if (ia.ipAddress().equals(source)) { matched = true; sendTo(eth, pa.connectPoint()); } } } if (matched) { return; } } // Continue with normal proxy ARP case VlanId vlan = VlanId.vlanId(eth.getVlanID()); Set<Host> hosts = hostService.getHostsByIp( Ip4Address.valueOf(arp.getTargetProtocolAddress())); Host dst = null; Host src = hostService.getHost(HostId.hostId(eth.getSourceMAC(), VlanId.vlanId(eth.getVlanID()))); for (Host host : hosts) { if (host.vlan().equals(vlan)) { dst = host; break; } } if (src == null || dst == null) { flood(eth, inPort); return; } // // TODO find the correct IP address. // Right now we use the first IPv4 address that is found. // for (IpAddress ipAddress : dst.ipAddresses()) { Ip4Address ip4Address = ipAddress.getIp4Address(); if (ip4Address != null) { Ethernet arpReply = buildArpReply(ip4Address, dst.mac(), eth); // TODO: check send status with host service. sendTo(arpReply, src.location()); break; } } }
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected HostService hostService; // code omitted ... private void replyArp(Ethernet eth, ConnectPoint inPort) { ARP arp = (ARP) eth.getPayload(); checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); checkNotNull(inPort); Ip4Address targetAddress = Ip4Address.valueOf(arp.getTargetProtocolAddress()); VlanId vlan = vlanId(eth.getVlanID()); if (isOutsidePort(inPort)) { // If the request came from outside the network, only reply if it was // for one of our external addresses. Set<PortAddresses> addressSet = hostService.getAddressBindingsForPort(inPort); for (PortAddresses addresses : addressSet) { for (InterfaceIpAddress ia : addresses.ipAddresses()) { if (ia.ipAddress().equals(targetAddress)) { Ethernet arpReply = ARP.buildArpReply(targetAddress, addresses.mac(), eth); sendTo(arpReply, inPort); } } } return; } // See if we have the target host in the host store Set<Host> hosts = hostService.getHostsByIp(targetAddress); Host dst = null; Host src = hostService.getHost(hostId(eth.getSourceMAC(), vlanId(eth.getVlanID()))); for (Host host : hosts) { if (host.vlan().equals(vlan)) { dst = host; break; } } if (src != null && dst != null) { // We know the target host so we can respond Ethernet arpReply = ARP.buildArpReply(targetAddress, dst.mac(), eth); sendTo(arpReply, inPort); return; } // If the source address matches one of our external addresses // it could be a request from an internal host to an external // address. Forward it over to the correct port. Ip4Address source = Ip4Address.valueOf(arp.getSenderProtocolAddress()); Set<PortAddresses> sourceAddresses = findPortsInSubnet(source); boolean matched = false; for (PortAddresses pa : sourceAddresses) { for (InterfaceIpAddress ia : pa.ipAddresses()) { if (ia.ipAddress().equals(source) && pa.vlan().equals(vlan)) { matched = true; sendTo(eth, pa.connectPoint()); break; } } } if (matched) { return; } // // The request couldn't be resolved. // Flood the request on all ports except the incoming port. // flood(eth, inPort); }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes