Compare commits

..

14 Commits

Author SHA1 Message Date
Norm Traxler
75c943211a [WIFI-2670] Add more counters to the ClientSessionCounts 2021-06-17 12:14:38 -04:00
norm-traxler
a200fcc12e Merge pull request #118 from Telecominfraproject/WIFI-2664
WIFI-2664 added private macs to return map
2021-06-17 12:12:39 -04:00
Kareem Dabbour
1f6996abb2 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2664 2021-06-17 11:46:20 -04:00
Kareem Dabbour
1ebaa4a539 WIFI-2664 added private macs to return map 2021-06-17 11:44:02 -04:00
norm-traxler
f1e1bdffd7 Merge pull request #117 from Telecominfraproject/WIFI-2664
WIFI-2664 added private mac address filtering to /oui/list endpoint
2021-06-16 13:36:26 -04:00
Kareem Dabbour
37f5872552 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2664 2021-06-16 12:59:23 -04:00
Kareem Dabbour
367b9ec428 WIFI-2664 adjusting unit tests to reflect added oui of ffffff 2021-06-16 12:55:57 -04:00
Kareem Dabbour
87ca619ad5 WIFI-2664 added private mac address filtering to /oui/list endpoint 2021-06-16 12:28:01 -04:00
norm-traxler
622f78f681 Merge pull request #116 from Telecominfraproject/WIFI-2664
WIFI-2664 Non-global mac addresses will now return an Uknown (private address) rather than null
2021-06-15 16:44:59 -04:00
Kareem Dabbour
faeb65d8d6 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2664 2021-06-15 16:43:14 -04:00
Kareem Dabbour
34841a3a04 WIFI-2664 moving logic from in memory and DAO to controller 2021-06-15 16:37:30 -04:00
Kareem Dabbour
4fc8bc4018 WIFI-2664 renamed group to global address and did some refractoring 2021-06-15 15:26:51 -04:00
Kareem Dabbour
cce36019fe WIFI-2664 Non-global mac addresses will now return an Uknown (private address) rather than null 2021-06-15 14:46:14 -04:00
norm-traxler
4596280090 Merge pull request #115 from Telecominfraproject/WIFI-2670
[WIFI-2670] Client Session API support OUI attribute and count query
2021-06-15 14:44:44 -04:00
4 changed files with 114 additions and 22 deletions

View File

@@ -517,26 +517,52 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
@Override
public ClientSessionCounts getSessionCounts(int customerId) {
ClientSessionCounts counts = new ClientSessionCounts();
int totalCount = 0;
Map<String, Integer> perOuiMap = new HashMap<>();
counts.setCustomerId(customerId);
long totalCount = 0;
Map<String, Long> perEquipmentMap = new HashMap<>();
Map<String, Long> perOuiMap = new HashMap<>();
Map<String, Long> perRadioMap = new HashMap<>();
for (ClientSession session : idToClientSessionMap.values()) {
if (session.getCustomerId() == customerId) {
totalCount++;
String equipmentIdString = Long.toString(session.getEquipmentId());
Long cnt = perEquipmentMap.get(equipmentIdString);
if (cnt == null) {
cnt = 0L;
} else {
cnt++;
}
perEquipmentMap.put(equipmentIdString, cnt);
if (session.getOui() != null) {
Integer cnt = perOuiMap.get(session.getOui());
cnt = perOuiMap.get(session.getOui());
if (cnt == null) {
cnt = 0;
cnt = 0L;
} else {
cnt++;
}
perOuiMap.put(session.getOui(), cnt);
}
if (session.getDetails() != null && session.getDetails().getRadioType() != null) {
String radioTypeString = session.getDetails().getRadioType().toString();
cnt = perRadioMap.get(radioTypeString);
if (cnt == null) {
cnt = 0L;
} else {
cnt++;
}
perRadioMap.put(radioTypeString, cnt);
}
}
}
counts.setTotalCount(totalCount);
counts.setEquipmentCounts(perEquipmentMap);
counts.setOuiCounts(perOuiMap);
counts.setRadioCounts(perRadioMap);
return counts;
}

View File

@@ -7,38 +7,84 @@ import java.util.Map;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
/**
* Total and per-oui counts of the Client Sessions
* Total and per-oui/equipment/radio counts of the Client Sessions
*/
public class ClientSessionCounts extends BaseJsonModel {
private static final long serialVersionUID = 7697349699510565184L;
private int totalCount;
private Map<String, Integer> ouiCounts = new HashMap<>();
private int customerId;
/**
* Total count of all client sessions for the customer Id.
*/
private long totalCount;
/**
* Counts of client sessions per equipment Id.
*/
private Map<String, Long> equipmentCounts = new HashMap<>();
/**
* Counts of client sessions per OUI.
*/
private Map<String, Long> ouiCounts = new HashMap<>();
/**
* Counts of client sessions per Radio Type.
*/
private Map<String, Long> radioCounts = new HashMap<>();
public Map<String, Integer> getOuiCounts() {
return ouiCounts;
public int getCustomerId() {
return customerId;
}
public void setOuiCounts(Map<String, Integer> ouiCounts) {
this.ouiCounts = ouiCounts;
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
public int getTotalCount() {
public long getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
public void setTotalCount(long totalCount) {
this.totalCount = totalCount;
}
public Map<String, Long> getEquipmentCounts() {
return equipmentCounts;
}
public void setEquipmentCounts(Map<String, Long> equipmentCounts) {
this.equipmentCounts = equipmentCounts;
}
public Map<String, Long> getOuiCounts() {
return ouiCounts;
}
public void setOuiCounts(Map<String, Long> ouiCounts) {
this.ouiCounts = ouiCounts;
}
public Map<String, Long> getRadioCounts() {
return radioCounts;
}
public void setRadioCounts(Map<String, Long> radioCounts) {
this.radioCounts = radioCounts;
}
@Override
public ClientSessionCounts clone() {
ClientSessionCounts ret = (ClientSessionCounts) super.clone();
if (equipmentCounts != null) {
ret.equipmentCounts = new HashMap<>(equipmentCounts);
}
if (ouiCounts != null) {
ret.ouiCounts = new HashMap<>(ouiCounts);
}
if (radioCounts != null) {
ret.radioCounts = new HashMap<>(radioCounts);
}
return ret;
}
}

View File

@@ -191,18 +191,18 @@ public class ManufacturerServiceRemoteTest extends BaseRemoteTest {
Set<String> ouiList = new HashSet<>();
ouiList.add(oui1);
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
assertTrue(ouiListSearchResult.size() == 1);
assertTrue(ouiListSearchResult.size() == 2);
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
ouiList.add(oui2);
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
assertTrue(ouiListSearchResult.size() == 2);
assertTrue(ouiListSearchResult.size() == 3);
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
ouiList.add(oui3);
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
assertTrue(ouiListSearchResult.size() == 3);
assertTrue(ouiListSearchResult.size() == 4);
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
assertTrue(ouiListSearchResult.get(oui3).equals(ret3));
@@ -211,7 +211,7 @@ public class ManufacturerServiceRemoteTest extends BaseRemoteTest {
ouiList.add(String.format("%06d", i));
}
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
assertEquals(3,ouiListSearchResult.size());
assertEquals(4,ouiListSearchResult.size());
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
assertTrue(ouiListSearchResult.get(oui3).equals(ret3));

View File

@@ -35,7 +35,10 @@ import com.telecominfraproject.wlan.manufacturer.models.ManufacturerOuiDetails;
public class ManufacturerController {
private static final Logger LOG = LoggerFactory.getLogger(ManufacturerController.class);
private static final int GLOBE_BIT = (0x1 << 1);
private static final ManufacturerOuiDetails PRIVATE_MAC_RESPONSE = new ManufacturerOuiDetails();
@Autowired
private ManufacturerDatastoreInterface manufacturerDatastore;
@@ -43,6 +46,11 @@ public class ManufacturerController {
private static final long serialVersionUID = -8035392255039609079L;
}
static {
PRIVATE_MAC_RESPONSE.setOui("ffffff");
PRIVATE_MAC_RESPONSE.setManufacturerName("Unknown (Private Address)");
PRIVATE_MAC_RESPONSE.setManufacturerAlias("Unknown");
}
@PostMapping(value = "/oui")
public ManufacturerOuiDetails createOuiDetails(@RequestBody ManufacturerOuiDetails ouiDetails) {
LOG.debug("Creating OUI details {} ", ouiDetails);
@@ -76,9 +84,7 @@ public class ManufacturerController {
@GetMapping(value = "/oui")
public ManufacturerOuiDetails getByOui(@RequestParam String oui) {
LOG.debug("Retrieving OUI details for OUI {} ", oui);
ManufacturerOuiDetails ret = manufacturerDatastore.getByOui(oui);
ManufacturerOuiDetails ret = isGlobalAddress(oui) ? manufacturerDatastore.getByOui(oui) : PRIVATE_MAC_RESPONSE;
LOG.debug("Retrieved OUI details {} ", ret);
return ret;
}
@@ -157,7 +163,11 @@ public class ManufacturerController {
public Map<String, ManufacturerOuiDetails> getManufacturerDetailsForOuiList(
@RequestParam List<String> ouiList) {
LOG.debug("calling getManufacturerDetailsForOuiList ");
return manufacturerDatastore.getManufacturerDetailsForOuiList(ouiList);
Map<String, ManufacturerOuiDetails> manufMap = manufacturerDatastore.getManufacturerDetailsForOuiList(ouiList);
ouiList.forEach(oui -> {if (!isGlobalAddress(oui)) manufMap.put(oui, PRIVATE_MAC_RESPONSE);});
manufMap.put(PRIVATE_MAC_RESPONSE.getOui(), PRIVATE_MAC_RESPONSE);
return manufMap;
}
@PutMapping(value = "/oui/alias")
@@ -180,4 +190,14 @@ public class ManufacturerController {
LOG.debug("Retrieving alias values that begin with {}", prefix);
return manufacturerDatastore.getAliasValuesThatBeginWith(prefix, maxResults);
}
private boolean isGlobalAddress(String oui) {
if (oui != null && oui.length() == 6) {
// we only need to check the first Byte of the OUI
Integer hex = Integer.parseInt(oui.substring(0, 2), 16);
byte firstByte = hex.byteValue();
return (firstByte & GLOBE_BIT) == 0;
}
return false;
}
}