Search in sources :

Example 1 with SubscriberAndDeviceInformation

use of org.opencord.sadis.SubscriberAndDeviceInformation in project aaa by opencord.

the class PortBasedRadiusCommunicator method sendRadiusPacket.

@Override
public void sendRadiusPacket(RADIUS radiusPacket, InboundPacket inPkt) {
    // create the packet
    Ethernet ethReply = new Ethernet();
    ethReply.setSourceMACAddress(nasMacAddress);
    ethReply.setDestinationMACAddress(radiusMacAddress);
    ethReply.setEtherType(Ethernet.TYPE_IPV4);
    ethReply.setVlanID(radiusVlanID);
    ethReply.setPriorityCode(radiusPBit);
    IPv4 ipv4Packet = new IPv4();
    ipv4Packet.setTtl((byte) 64);
    ipv4Packet.setSourceAddress(Ip4Address.valueOf(nasIpAddress).toInt());
    ipv4Packet.setDestinationAddress(Ip4Address.valueOf(radiusIpAddress).toInt());
    UDP udpPacket = new UDP();
    udpPacket.setSourcePort(radiusServerPort);
    udpPacket.setDestinationPort(radiusServerPort);
    udpPacket.setPayload(radiusPacket);
    ipv4Packet.setPayload(udpPacket);
    ethReply.setPayload(ipv4Packet);
    // store the IP address and SN of the device, later to be used
    // for ARP responses
    String serialNo = deviceService.getDevice(inPkt.receivedFrom().deviceId()).serialNumber();
    if (subsService == null) {
        log.warn(SADIS_NOT_RUNNING);
        aaaManager.radiusOperationalStatusService.setStatusServerReqSent(false);
        return;
    }
    SubscriberAndDeviceInformation deviceInfo = subsService.get(serialNo);
    if (deviceInfo == null) {
        log.warn("No Device found with SN {}", serialNo);
        aaaManager.radiusOperationalStatusService.setStatusServerReqSent(false);
        return;
    }
    if (radiusPacket.getIdentifier() == RadiusOperationalStatusManager.AAA_REQUEST_ID_STATUS_REQUEST || radiusPacket.getIdentifier() == RadiusOperationalStatusManager.AAA_REQUEST_ID_FAKE_ACCESS_REQUEST) {
        aaaManager.radiusOperationalStatusService.setOutTimeInMillis(radiusPacket.getIdentifier());
    } else {
        aaaManager.aaaStatisticsManager.putOutgoingIdentifierToMap(radiusPacket.getIdentifier());
    }
    Ip4Address ipAddress = deviceInfo.ipAddress();
    if (ipAddress != null) {
        ipToSnMap.put(ipAddress, serialNo);
    } else {
        log.warn("Cannot Map IpAddress to SerialNo : ipAddress = {}", ipAddress);
    }
    // send the message out
    sendFromRadiusServerPort(pktCustomizer.customizeEthernetIPHeaders(ethReply, inPkt));
    aaaManager.radiusOperationalStatusService.setStatusServerReqSent(true);
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) Ip4Address(org.onlab.packet.Ip4Address) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation)

Example 2 with SubscriberAndDeviceInformation

use of org.opencord.sadis.SubscriberAndDeviceInformation in project dhcpl2relay by opencord.

the class DhcpL2Relay method getUplinkPortsOfOlts.

/**
 * Returns all the uplink ports of OLTs configured in SADIS.
 * Only ports visible in ONOS and for which this instance is master
 * are returned
 */
private List<ConnectPoint> getUplinkPortsOfOlts() {
    if (subsService == null) {
        log.warn(SADIS_NOT_RUNNING);
        return Lists.newArrayList();
    }
    List<ConnectPoint> cps = new ArrayList<>();
    // find all the olt devices and if their uplink ports are visible
    Iterable<Device> devices = deviceService.getDevices();
    for (Device d : devices) {
        // check if this device is provisioned in Sadis
        log.debug("getUplinkPortsOfOlts: Checking mastership of {}", d);
        // do only for devices for which we are the master
        if (!isLocalLeader(d.id())) {
            continue;
        }
        String devSerialNo = d.serialNumber();
        SubscriberAndDeviceInformation deviceInfo = getSubscriberAndDeviceInfo(devSerialNo);
        log.debug("getUplinkPortsOfOlts: Found device: {}", deviceInfo);
        if (deviceInfo != null) {
            // check if the uplink port with that number is available on the device
            PortNumber pNum = PortNumber.portNumber(deviceInfo.uplinkPort());
            Port port = deviceService.getPort(d.id(), pNum);
            log.debug("getUplinkPortsOfOlts: Found port: {}", port);
            if (port != null) {
                cps.add(new ConnectPoint(d.id(), pNum));
            }
        }
    }
    return cps;
}
Also used : Device(org.onosproject.net.Device) Port(org.onosproject.net.Port) TpPort(org.onlab.packet.TpPort) ArrayList(java.util.ArrayList) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 3 with SubscriberAndDeviceInformation

use of org.opencord.sadis.SubscriberAndDeviceInformation in project aaa by opencord.

the class AaaShowUsersCommand method doExecute.

@Override
protected void doExecute() {
    final Comparator<AuthenticationRecord> authenticationRecordComparator = (a1, a2) -> Comparators.CONNECT_POINT_COMPARATOR.compare(a1.supplicantConnectPoint(), a2.supplicantConnectPoint());
    DeviceService devService = get(DeviceService.class);
    SadisService sadisService = get(SadisService.class);
    AuthenticationService authService = get(AuthenticationService.class);
    List<AuthenticationRecord> authentications = newArrayList(authService.getAuthenticationRecords());
    authentications.sort(authenticationRecordComparator);
    if (strDeviceId != null && !strDeviceId.isEmpty()) {
        DeviceId deviceId = DeviceId.deviceId(strDeviceId);
        authentications = authentications.stream().filter(a -> a.supplicantConnectPoint().deviceId().equals(deviceId)).collect(Collectors.toList());
    }
    for (AuthenticationRecord auth : authentications) {
        String username = UNKNOWN;
        if (auth.username() != null) {
            username = new String(auth.username());
        }
        String mac = UNKNOWN;
        if (auth.supplicantAddress() != null) {
            mac = auth.supplicantAddress().toString();
        }
        Port port = devService.getPort(auth.supplicantConnectPoint());
        String nasPortId = UNKNOWN;
        if (port != null) {
            nasPortId = devService.getPort(auth.supplicantConnectPoint()).annotations().value(AnnotationKeys.PORT_NAME);
        }
        String subsId = UNKNOWN;
        SubscriberAndDeviceInformation subscriber = sadisService.getSubscriberInfoService().get(nasPortId);
        if (subscriber != null) {
            subsId = subscriber.nasPortId();
        }
        print("%s: %s, last-changed=%s, mac=%s, subid=%s, username=%s", auth.supplicantConnectPoint(), auth.state(), Tools.timeAgo(auth.lastChanged()), mac, subsId, username);
    }
}
Also used : Comparators(org.onosproject.utils.Comparators) AuthenticationService(org.opencord.aaa.AuthenticationService) Tools(org.onlab.util.Tools) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) DeviceService(org.onosproject.net.device.DeviceService) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) Argument(org.apache.karaf.shell.api.action.Argument) AnnotationKeys(org.onosproject.net.AnnotationKeys) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) SadisService(org.opencord.sadis.SadisService) Port(org.onosproject.net.Port) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) DeviceId(org.onosproject.net.DeviceId) Comparator(java.util.Comparator) DeviceIdCompleter(org.onosproject.cli.net.DeviceIdCompleter) SadisService(org.opencord.sadis.SadisService) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) AuthenticationService(org.opencord.aaa.AuthenticationService)

Example 4 with SubscriberAndDeviceInformation

use of org.opencord.sadis.SubscriberAndDeviceInformation in project dhcpl2relay by opencord.

the class DhcpL2Relay method getUplinkConnectPointOfOlt.

/**
 * Returns the connectPoint which is the uplink port of the OLT.
 */
private ConnectPoint getUplinkConnectPointOfOlt(DeviceId dId) {
    Device d = deviceService.getDevice(dId);
    SubscriberAndDeviceInformation deviceInfo = getSubscriberAndDeviceInfo(d.serialNumber());
    log.debug("getUplinkConnectPointOfOlt DeviceId: {} devInfo: {}", dId, deviceInfo);
    if (deviceInfo != null) {
        PortNumber pNum = PortNumber.portNumber(deviceInfo.uplinkPort());
        Port port = deviceService.getPort(d.id(), pNum);
        if (port != null) {
            return new ConnectPoint(d.id(), pNum);
        }
    }
    return null;
}
Also used : Device(org.onosproject.net.Device) Port(org.onosproject.net.Port) TpPort(org.onlab.packet.TpPort) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 5 with SubscriberAndDeviceInformation

use of org.opencord.sadis.SubscriberAndDeviceInformation in project dhcpl2relay by opencord.

the class DhcpL2Relay method isUplinkPortOfOlt.

/**
 * Returns whether the passed port is the uplink port of the olt device.
 */
private boolean isUplinkPortOfOlt(DeviceId dId, Port p) {
    log.debug("isUplinkPortOfOlt: DeviceId: {} Port: {}", dId, p);
    Device d = deviceService.getDevice(dId);
    SubscriberAndDeviceInformation deviceInfo = getSubscriberAndDeviceInfo(d.serialNumber());
    if (deviceInfo != null) {
        return (deviceInfo.uplinkPort() == p.number().toLong());
    }
    return false;
}
Also used : Device(org.onosproject.net.Device) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation)

Aggregations

SubscriberAndDeviceInformation (org.opencord.sadis.SubscriberAndDeviceInformation)7 Port (org.onosproject.net.Port)4 Ip4Address (org.onlab.packet.Ip4Address)3 Device (org.onosproject.net.Device)3 Ethernet (org.onlab.packet.Ethernet)2 IPv4 (org.onlab.packet.IPv4)2 MacAddress (org.onlab.packet.MacAddress)2 TpPort (org.onlab.packet.TpPort)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 PortNumber (org.onosproject.net.PortNumber)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 UDP (org.onlab.packet.UDP)1