Search in sources :

Example 66 with MacAddress

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

the class HostMonitor method sendRequest.

/**
 * Sends an ARP or NDP request for the given IP address.
 *
 * @param targetIp IP address to send the request for
 */
private void sendRequest(IpAddress targetIp) {
    interfaceService.getMatchingInterfaces(targetIp).forEach(intf -> {
        Port port = deviceService.getPort(intf.connectPoint());
        if (port == null) {
            log.debug("Aborting probing non-existent port: {}", intf);
            return;
        }
        if (!port.isEnabled()) {
            log.debug("Aborting probing disabled port: {}", intf);
            return;
        }
        if (!edgePortService.isEdgePoint(intf.connectPoint())) {
            log.warn("Aborting probing non-edge port: {}", intf);
            return;
        }
        intf.ipAddressesList().stream().filter(ia -> ia.subnetAddress().contains(targetIp)).forEach(ia -> {
            MacAddress probeMac = intf.mac();
            IpAddress probeIp = !probeMac.equals(MacAddress.ONOS) ? ia.ipAddress() : (ia.ipAddress().isIp4() ? Ip4Address.ZERO : Ip6Address.ZERO);
            sendProbe(intf.connectPoint(), targetIp, probeIp, probeMac, intf.vlan());
            // account for use-cases where tagged-vlan config is used
            if (!intf.vlanTagged().isEmpty()) {
                intf.vlanTagged().forEach(tag -> {
                    sendProbe(intf.connectPoint(), targetIp, probeIp, probeMac, tag);
                });
            }
        });
    });
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) Host(org.onosproject.net.Host) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ARP(org.onlab.packet.ARP) InterfaceService(org.onosproject.net.intf.InterfaceService) SharedScheduledExecutors(org.onlab.util.SharedScheduledExecutors) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) NeighborSolicitation(org.onlab.packet.ndp.NeighborSolicitation) ConnectPoint(org.onosproject.net.ConnectPoint) ConcurrentMap(java.util.concurrent.ConcurrentMap) Ethernet(org.onlab.packet.Ethernet) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Port(org.onosproject.net.Port) EdgePortService(org.onosproject.net.edge.EdgePortService) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) Logger(org.slf4j.Logger) HostProvider(org.onosproject.net.host.HostProvider) VlanId(org.onlab.packet.VlanId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PacketService(org.onosproject.net.packet.PacketService) ProviderId(org.onosproject.net.provider.ProviderId) IPv6(org.onlab.packet.IPv6) TimeUnit(java.util.concurrent.TimeUnit) MacAddress(org.onlab.packet.MacAddress) Collections(java.util.Collections) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Port(org.onosproject.net.Port) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress)

Example 67 with MacAddress

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

the class DeviceDescriptionDiscoveryAristaImpl method getMacAddressesByInterface.

private Map<String, MacAddress> getMacAddressesByInterface() {
    DeviceId deviceId = checkNotNull(handler().data().deviceId());
    Map<String, MacAddress> macAddressMap = new HashMap();
    try {
        Optional<JsonNode> result = AristaUtils.retrieveCommandResult(handler(), SHOW_INTERFACES);
        if (!result.isPresent()) {
            log.warn("{} Device unable to get interface information.", deviceId);
            return macAddressMap;
        }
        JsonNode jsonNode = result.get().findValue(INTERFACES);
        jsonNode.fieldNames().forEachRemaining(name -> {
            JsonNode interfaceNode = jsonNode.get(name);
            JsonNode macAddressNode = interfaceNode.get(BURNED_IN_ADDRESS);
            if (macAddressNode == null) {
                log.debug("Interface does not have {}: {}", BURNED_IN_ADDRESS, name);
                return;
            }
            String macAddress = macAddressNode.asText("");
            if (macAddress.isEmpty()) {
                macAddressNode = interfaceNode.get(PHYSICAL_ADDRESS);
                if (macAddressNode == null) {
                    log.debug("Interface does not have {}: {}", PHYSICAL_ADDRESS, name);
                    return;
                }
                macAddress = macAddressNode.asText("");
                if (macAddress.isEmpty()) {
                    log.debug("Interface does not have any mac address: {}", name);
                    return;
                }
            }
            try {
                macAddressMap.put(name, MacAddress.valueOf(macAddress));
            } catch (IllegalArgumentException e) {
                log.error("Cannot parse macAddress: {}", macAddress);
            }
        });
    } catch (Exception e) {
        log.error("Exception occurred because of {}, trace: {}", e, e.getStackTrace());
    }
    return macAddressMap;
}
Also used : HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) MacAddress(org.onlab.packet.MacAddress)

Example 68 with MacAddress

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

the class DeviceDescriptionDiscoveryAristaImpl method discoverPortDetails.

@Override
public List<PortDescription> discoverPortDetails() {
    Map<String, MacAddress> macAddressMap = getMacAddressesByInterface();
    List<PortDescription> ports = Lists.newArrayList();
    DeviceId deviceId = checkNotNull(handler().data().deviceId());
    try {
        Optional<JsonNode> result = AristaUtils.retrieveCommandResult(handler(), SHOW_INTERFACES_STATUS);
        if (!result.isPresent()) {
            log.warn("{} Device unable to get interfaces status information.", deviceId);
            return ports;
        }
        JsonNode jsonNode = result.get().findValue(INTERFACE_STATUSES);
        jsonNode.fieldNames().forEachRemaining(name -> {
            JsonNode interfaceNode = jsonNode.get(name);
            Long bandwidth = interfaceNode.path(BANDWIDTH).asLong() / MBPS;
            String macAddress = macAddressMap.containsKey(name) ? macAddressMap.get(name).toString() : "";
            SparseAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.BANDWIDTH, bandwidth.toString()).set(AnnotationKeys.NAME, name).set(AnnotationKeys.PORT_NAME, name).set(AnnotationKeys.PORT_MAC, macAddress).set(LINK_STATUS, interfaceNode.path(LINK_STATUS).asText()).set(LINE_PROTOCOL_STATUS, interfaceNode.path(LINE_PROTOCOL_STATUS).asText()).set(INTERFACE_TYPE, interfaceNode.path(INTERFACE_TYPE).asText()).build();
            int portNumber;
            try {
                portNumber = getPortNumber(name);
            } catch (Exception e) {
                log.debug("Interface does not have port number: {}", name);
                return;
            }
            PortDescription portDescription = DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(portNumber)).isEnabled(true).type(Port.Type.FIBER).portSpeed(bandwidth).annotations(annotations).build();
            ports.add(portDescription);
        });
    } catch (Exception e) {
        log.error("Exception occurred because of {}, trace: {}", e, e.getStackTrace());
    }
    return ports;
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DeviceId(org.onosproject.net.DeviceId) PortDescription(org.onosproject.net.device.PortDescription) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) JsonNode(com.fasterxml.jackson.databind.JsonNode) MacAddress(org.onlab.packet.MacAddress)

Example 69 with MacAddress

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

the class Dhcp6HandlerImpl method processDhcp6PacketFromServer.

/**
 * process the DHCP6 relay-reply packet from dhcp server.
 *
 * @param context packet context
 * @param receivedPacket server ethernet packet
 * @param recevingInterfaces set of server side interfaces
 * @return internalPacket toward client
 */
private InternalPacket processDhcp6PacketFromServer(PacketContext context, Ethernet receivedPacket, Set<Interface> recevingInterfaces) {
    // get dhcp6 header.
    Ethernet etherReply = receivedPacket.duplicate();
    IPv6 ipv6Packet = (IPv6) etherReply.getPayload();
    UDP udpPacket = (UDP) ipv6Packet.getPayload();
    DHCP6 dhcp6Relay = (DHCP6) udpPacket.getPayload();
    Boolean directConnFlag = Dhcp6HandlerUtil.directlyConnected(dhcp6Relay);
    DHCP6 embeddedDhcp6 = dhcp6Relay.getOptions().stream().filter(opt -> opt instanceof Dhcp6RelayOption).map(BasePacket::getPayload).map(pld -> (DHCP6) pld).findFirst().orElse(null);
    ConnectPoint inPort = context.inPacket().receivedFrom();
    DhcpServerInfo foundServerInfo = findServerInfoFromServer(directConnFlag, inPort);
    if (foundServerInfo == null) {
        log.warn("Cannot find server info for {} server, inPort {}", directConnFlag ? "direct" : "indirect", inPort);
        // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_INFO);
        return null;
    } else {
        if (Dhcp6HandlerUtil.isServerIpEmpty(foundServerInfo)) {
            log.warn("Cannot find server info's ipaddress");
            // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_IP6ADDR);
            return null;
        }
    }
    Dhcp6InterfaceIdOption interfaceIdOption = dhcp6Relay.getOptions().stream().filter(opt -> opt instanceof Dhcp6InterfaceIdOption).map(opt -> (Dhcp6InterfaceIdOption) opt).findFirst().orElse(null);
    if (interfaceIdOption == null) {
        log.warn("Interface Id option is not present, abort packet...");
        // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.OPTION_MISSING_FAIL);
        return null;
    }
    MacAddress peerMac = interfaceIdOption.getMacAddress();
    String clientConnectionPointStr = new String(interfaceIdOption.getInPort());
    ConnectPoint clientConnectionPoint = ConnectPoint.deviceConnectPoint(clientConnectionPointStr);
    VlanId vlanIdInUse = VlanId.vlanId(interfaceIdOption.getVlanId());
    log.debug("processDhcp6PacketFromServer Interface Id Mac {}, port{}, vlan {}", peerMac, clientConnectionPointStr, vlanIdInUse);
    Interface clientInterface = interfaceService.getInterfacesByPort(clientConnectionPoint).stream().filter(iface -> Dhcp6HandlerUtil.interfaceContainsVlan(iface, vlanIdInUse)).findFirst().orElse(null);
    if (clientInterface == null) {
        log.warn("Cannot get client interface for from packet, abort... vlan {}", vlanIdInUse.toString());
        // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_MATCHING_INTF);
        return null;
    }
    etherReply.setVlanID(vlanIdInUse.toShort());
    MacAddress relayAgentMac = clientInterface.mac();
    if (relayAgentMac == null) {
        log.warn("Can not get client interface mac, abort packet..");
        // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
        return null;
    }
    etherReply.setSourceMACAddress(relayAgentMac);
    // find destMac
    MacAddress clientMac;
    Ip6Address peerAddress = Ip6Address.valueOf(dhcp6Relay.getPeerAddress());
    Set<Host> clients = hostService.getHostsByIp(peerAddress);
    if (clients.isEmpty()) {
        log.trace("There's no host found for this address {}", HexString.toHexString(dhcp6Relay.getPeerAddress(), ":"));
        log.trace("Let's look up interfaceId {}", HexString.toHexString(peerMac.toBytes(), ":"));
        clientMac = peerMac;
    } else {
        clientMac = clients.iterator().next().mac();
        if (clientMac == null) {
            log.warn("No client mac address found, abort packet...");
            // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
            return null;
        }
        log.trace("Client mac address found from getHostByIp");
    }
    etherReply.setDestinationMACAddress(clientMac);
    // ip header
    ipv6Packet.setSourceAddress(dhcp6Relay.getLinkAddress());
    ipv6Packet.setDestinationAddress(dhcp6Relay.getPeerAddress());
    // udp header
    udpPacket.setSourcePort(UDP.DHCP_V6_SERVER_PORT);
    if (directConnFlag) {
        udpPacket.setDestinationPort(UDP.DHCP_V6_CLIENT_PORT);
    } else {
        udpPacket.setDestinationPort(UDP.DHCP_V6_SERVER_PORT);
    }
    boolean hostOrRouteAllowed = learnRouteFromLeasequery || Dhcp6HandlerUtil.getDhcp6LeafMessageType(dhcp6Relay) != MsgType.LEASEQUERY_REPLY;
    log.debug("Can add host or route: {}", hostOrRouteAllowed);
    if (hostOrRouteAllowed) {
        // add host or route
        addHostOrRoute(directConnFlag, clientConnectionPoint, dhcp6Relay, embeddedDhcp6, clientMac, clientInterface, vlanIdInUse);
    }
    udpPacket.setPayload(embeddedDhcp6);
    udpPacket.resetChecksum();
    ipv6Packet.setPayload(udpPacket);
    etherReply.setPayload(ipv6Packet);
    return InternalPacket.internalPacket(etherReply, clientConnectionPoint);
}
Also used : UDP(org.onlab.packet.UDP) Dhcp6IaPdOption(org.onlab.packet.dhcp.Dhcp6IaPdOption) DeviceService(org.onosproject.net.device.DeviceService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) ApplicationId(org.onosproject.core.ApplicationId) Dhcp6IaNaOption(org.onlab.packet.dhcp.Dhcp6IaNaOption) Dhcp6IaTaOption(org.onlab.packet.dhcp.Dhcp6IaTaOption) Ip6Address(org.onlab.packet.Ip6Address) DhcpRelayStore(org.onosproject.dhcprelay.store.DhcpRelayStore) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) MsgType(org.onlab.packet.DHCP6.MsgType) PacketService(org.onosproject.net.packet.PacketService) DeviceId(org.onosproject.net.DeviceId) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) LEARN_ROUTE_FROM_LEASE_QUERY_DEFAULT(org.onosproject.dhcprelay.OsgiPropertyConstants.LEARN_ROUTE_FROM_LEASE_QUERY_DEFAULT) Dictionary(java.util.Dictionary) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Pipeliner(org.onosproject.net.behaviour.Pipeliner) REMOVE(org.onosproject.net.flowobjective.Objective.Operation.REMOVE) DhcpFpmPrefixStore(org.onosproject.dhcprelay.store.DhcpFpmPrefixStore) HostProviderRegistry(org.onosproject.net.host.HostProviderRegistry) Tools(org.onlab.util.Tools) RouteStore(org.onosproject.routeservice.RouteStore) Host(org.onosproject.net.Host) ComponentContext(org.osgi.service.component.ComponentContext) LEARN_ROUTE_FROM_LEASE_QUERY(org.onosproject.dhcprelay.OsgiPropertyConstants.LEARN_ROUTE_FROM_LEASE_QUERY) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) Multimaps(com.google.common.collect.Multimaps) ArrayList(java.util.ArrayList) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) FpmRecord(org.onosproject.routing.fpm.api.FpmRecord) Dhcp6LeaseQueryOption(org.onlab.packet.dhcp.Dhcp6LeaseQueryOption) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TpPort(org.onlab.packet.TpPort) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) BasePacket(org.onlab.packet.BasePacket) Executor(java.util.concurrent.Executor) HostProvider(org.onosproject.net.host.HostProvider) VlanId(org.onlab.packet.VlanId) ProviderId(org.onosproject.net.provider.ProviderId) Dhcp6IaAddressOption(org.onlab.packet.dhcp.Dhcp6IaAddressOption) IPv6(org.onlab.packet.IPv6) DHCP6(org.onlab.packet.DHCP6) HexString(org.onlab.util.HexString) DhcpRecord(org.onosproject.dhcprelay.store.DhcpRecord) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Dhcp6Duid(org.onlab.packet.dhcp.Dhcp6Duid) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) Route(org.onosproject.routeservice.Route) HostLocation(org.onosproject.net.HostLocation) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Dhcp6ClientIdOption(org.onlab.packet.dhcp.Dhcp6ClientIdOption) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) HostProviderService(org.onosproject.net.host.HostProviderService) HashMultimap(com.google.common.collect.HashMultimap) Dhcp6IaPrefixOption(org.onlab.packet.dhcp.Dhcp6IaPrefixOption) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DhcpServerInfo(org.onosproject.dhcprelay.api.DhcpServerInfo) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) HostDescription(org.onosproject.net.host.HostDescription) IpPrefix(org.onlab.packet.IpPrefix) Dhcp6ClientDataOption(org.onlab.packet.dhcp.Dhcp6ClientDataOption) ADD(org.onosproject.net.flowobjective.Objective.Operation.ADD) Multimap(com.google.common.collect.Multimap) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Activate(org.osgi.service.component.annotations.Activate) HostEvent(org.onosproject.net.host.HostEvent) HostId(org.onosproject.net.HostId) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Dhcp6Option(org.onlab.packet.dhcp.Dhcp6Option) UDP(org.onlab.packet.UDP) DhcpHandler(org.onosproject.dhcprelay.api.DhcpHandler) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Modified(org.osgi.service.component.annotations.Modified) PacketPriority(org.onosproject.net.packet.PacketPriority) Reference(org.osgi.service.component.annotations.Reference) IPv6(org.onlab.packet.IPv6) Host(org.onosproject.net.Host) HexString(org.onlab.util.HexString) MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) Ip6Address(org.onlab.packet.Ip6Address) Ethernet(org.onlab.packet.Ethernet) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) DHCP6(org.onlab.packet.DHCP6) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpServerInfo(org.onosproject.dhcprelay.api.DhcpServerInfo) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface)

Example 70 with MacAddress

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

the class Dhcp6HandlerImpl method processDhcp6PacketFromClient.

/**
 * build the DHCP6 solicit/request packet with gatewayip.
 *
 * @param context packet context
 * @param clientPacket client ethernet packet
 * @param clientInterfaces set of client side interfaces
 */
private List<InternalPacket> processDhcp6PacketFromClient(PacketContext context, Ethernet clientPacket, Set<Interface> clientInterfaces) {
    ConnectPoint receivedFrom = context.inPacket().receivedFrom();
    Ip6Address relayAgentIp = Dhcp6HandlerUtil.getRelayAgentIPv6Address(clientInterfaces);
    MacAddress relayAgentMac = clientInterfaces.iterator().next().mac();
    if (relayAgentIp == null || relayAgentMac == null) {
        log.warn("Missing DHCP relay agent interface Ipv6 addr config for " + "packet from client on port: {}. Aborting packet processing", clientInterfaces.iterator().next().connectPoint());
        // dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
        return Lists.newArrayList();
    }
    IPv6 clientIpv6 = (IPv6) clientPacket.getPayload();
    UDP clientUdp = (UDP) clientIpv6.getPayload();
    DHCP6 clientDhcp6 = (DHCP6) clientUdp.getPayload();
    boolean directConnFlag = Dhcp6HandlerUtil.directlyConnected(clientDhcp6);
    ConnectPoint clientConnectionPoint = context.inPacket().receivedFrom();
    VlanId vlanIdInUse = VlanId.vlanId(clientPacket.getVlanID());
    Interface clientInterface = interfaceService.getInterfacesByPort(clientConnectionPoint).stream().filter(iface -> Dhcp6HandlerUtil.interfaceContainsVlan(iface, vlanIdInUse)).findFirst().orElse(null);
    List<InternalPacket> internalPackets = new ArrayList<>();
    List<DhcpServerInfo> serverInfoList = findValidServerInfo(directConnFlag);
    List<DhcpServerInfo> copyServerInfoList = new ArrayList<DhcpServerInfo>(serverInfoList);
    for (DhcpServerInfo serverInfo : copyServerInfoList) {
        if (!Dhcp6HandlerUtil.checkDhcpServerConnPt(directConnFlag, serverInfo)) {
            log.warn("Can't get server connect point, ignore");
            continue;
        }
        DhcpServerInfo newServerInfo = getHostInfoForServerInfo(serverInfo, serverInfoList);
        if (newServerInfo == null) {
            log.warn("Can't get server interface with host info resolved, ignore");
            continue;
        }
        Interface serverInterface = getServerInterface(newServerInfo);
        if (serverInterface == null) {
            log.warn("Can't get server interface, ignore");
            continue;
        }
        Ethernet etherReply = Dhcp6HandlerUtil.buildDhcp6PacketFromClient(context, clientPacket, clientInterfaces, newServerInfo, serverInterface);
        removeHostOrRoute(directConnFlag, clientConnectionPoint, clientDhcp6, clientPacket, clientIpv6, clientInterface);
        InternalPacket internalPacket = InternalPacket.internalPacket(etherReply, serverInfo.getDhcpServerConnectPoint().get());
        internalPackets.add(internalPacket);
    }
    log.debug("num of client packets to send is{}", internalPackets.size());
    return internalPackets;
}
Also used : UDP(org.onlab.packet.UDP) IPv6(org.onlab.packet.IPv6) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MacAddress(org.onlab.packet.MacAddress) ConnectPoint(org.onosproject.net.ConnectPoint) Ip6Address(org.onlab.packet.Ip6Address) Ethernet(org.onlab.packet.Ethernet) DHCP6(org.onlab.packet.DHCP6) VlanId(org.onlab.packet.VlanId) Interface(org.onosproject.net.intf.Interface) DhcpServerInfo(org.onosproject.dhcprelay.api.DhcpServerInfo)

Aggregations

MacAddress (org.onlab.packet.MacAddress)131 IpAddress (org.onlab.packet.IpAddress)52 VlanId (org.onlab.packet.VlanId)49 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)42 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)42 ConnectPoint (org.onosproject.net.ConnectPoint)38 Ethernet (org.onlab.packet.Ethernet)31 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 DeviceId (org.onosproject.net.DeviceId)24 Interface (org.onosproject.net.intf.Interface)22 Set (java.util.Set)21 Logger (org.slf4j.Logger)20 Ip4Address (org.onlab.packet.Ip4Address)19 DhcpRecord (org.onosproject.dhcprelay.store.DhcpRecord)19 Device (org.onosproject.net.Device)19 ProviderId (org.onosproject.net.provider.ProviderId)18