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