WIFI-437: CloudSDK Client DHCP attributes processing

Map enumerated types from AP.
This commit is contained in:
Mike Hansen
2020-09-14 12:40:18 -04:00
parent 410e3c5433
commit b7c1741ce9
6 changed files with 499 additions and 38 deletions

View File

@@ -752,7 +752,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (captivePortId != null) { if (captivePortId != null) {
captiveProfileIds.add(captivePortId); captiveProfileIds.add(captivePortId);
} }
Long bonjourGatewayProfileId = ((SsidConfiguration)ssidProfile.getDetails()).getBonjourGatewayProfileId(); Long bonjourGatewayProfileId = ((SsidConfiguration) ssidProfile.getDetails())
.getBonjourGatewayProfileId();
if (bonjourGatewayProfileId != null) { if (bonjourGatewayProfileId != null) {
bonjourGatewayProfileIds.add(bonjourGatewayProfileId); bonjourGatewayProfileIds.add(bonjourGatewayProfileId);
} }
@@ -1648,6 +1649,22 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
long locationId = ce.getLocationId(); long locationId = ce.getLocationId();
//         "hwaddr":
//         "inet_addr":
//         "hostname":
//         "fingerprint":
//         "vendor_class":
//         "lease_time":
//         "subnet_mask":
//         "gateway":
//         "dhcp_server":
//         "primary_dns":
//         "secondary_dns":
//         "db_status":
//         "device_name":
//         "device_type":
//         "manuf_id":
if (rowUpdateOperation.equals(RowUpdateOperation.INSERT)) { if (rowUpdateOperation.equals(RowUpdateOperation.INSERT)) {
@@ -1763,11 +1780,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails(); ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
if (dhcpLeasedIps.containsKey("inet_addr")) {
}
if (dhcpLeasedIps.containsKey("hostname")) { if (dhcpLeasedIps.containsKey("hostname")) {
clientDetails.setHostName(dhcpLeasedIps.get("hostname")); clientDetails.setHostName(dhcpLeasedIps.get("hostname"));
@@ -1814,6 +1826,23 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Map<String, String> dhcpLeasedIps, MacAddress clientMacAddress) { Map<String, String> dhcpLeasedIps, MacAddress clientMacAddress) {
ClientSession session = clientServiceInterface.getSessionOrNull(customerId, equipmentId, clientMacAddress); ClientSession session = clientServiceInterface.getSessionOrNull(customerId, equipmentId, clientMacAddress);
//         "hwaddr": --
//         "inet_addr": --
//         "hostname": --
//         "fingerprint": --
//         "vendor_class": --
//         "lease_time": --
//         "subnet_mask": --
//         "gateway": --
//         "dhcp_server": --
//         "primary_dns": --
//         "secondary_dns": --
//         "db_status":
//         "device_name":
//         "device_type":
//         "manuf_id":
if (session == null) { if (session == null) {
session = new ClientSession(); session = new ClientSession();
} }
@@ -1849,6 +1878,14 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ClientDhcpDetails clientDhcpDetails = new ClientDhcpDetails(clientSessionDetails.getSessionId()); ClientDhcpDetails clientDhcpDetails = new ClientDhcpDetails(clientSessionDetails.getSessionId());
if (dhcpLeasedIps.containsKey("dhcp_server")) {
try {
clientDhcpDetails.setDhcpServerIp(InetAddress.getByName(dhcpLeasedIps.get("dhcp_server")));
} catch (UnknownHostException e) {
LOG.error("Invalid DhcpServer", e);
}
}
if (dhcpLeasedIps.containsKey("lease_time")) { if (dhcpLeasedIps.containsKey("lease_time")) {
Integer leaseTime = Integer.valueOf(dhcpLeasedIps.get("lease_time")); Integer leaseTime = Integer.valueOf(dhcpLeasedIps.get("lease_time"));
clientDhcpDetails.setLeaseTimeInSeconds(leaseTime); clientDhcpDetails.setLeaseTimeInSeconds(leaseTime);
@@ -1888,8 +1925,28 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
} }
if (dhcpLeasedIps.containsKey("vendor_class")) {
clientSessionDetails.setClassificationName(dhcpLeasedIps.get("vendor_class"));
}
if (dhcpLeasedIps.containsKey("db_status")) {
LOG.info("DHCP_leased_IP db_status {}", dhcpLeasedIps.get("db_status"));
}
if (dhcpLeasedIps.containsKey("device_name")) {
LOG.info("DHCP_leased_IP device_name {}", dhcpLeasedIps.get("device_name"));
}
if (dhcpLeasedIps.containsKey("device_type")) {
LOG.info("DHCP_leased_IP device_type {}", dhcpLeasedIps.get("device_type"));
}
if (dhcpLeasedIps.containsKey("manuf_id")) {
LOG.info("DHCP_leased_IP manuf_id {}", dhcpLeasedIps.get("manuf_id"));
}
clientSessionDetails.setDhcpDetails(clientDhcpDetails); clientSessionDetails.setDhcpDetails(clientDhcpDetails);
session.getDetails().mergeSession(clientSessionDetails); session.getDetails().mergeSession(clientSessionDetails);

View File

@@ -29,6 +29,9 @@ import com.telecominfraproject.wlan.opensync.external.integration.models.Opensyn
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState; import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState;
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncWifiAssociatedClients; import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncWifiAssociatedClients;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao; import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpDbStatus;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpDeviceType;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpManufId;
import com.telecominfraproject.wlan.opensync.util.SslUtil; import com.telecominfraproject.wlan.opensync.util.SslUtil;
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration; import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
import com.vmware.ovsdb.callback.ConnectionCallback; import com.vmware.ovsdb.callback.ConnectionCallback;
@@ -348,7 +351,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
LOG.debug("Could not enable monitor for DHCP_leased_IP table. {}", e.getMessage()); LOG.debug("Could not enable monitor for DHCP_leased_IP table. {}", e.getMessage());
} }
try { try {
monitorCommandStateDbTable(ovsdbClient, key); monitorCommandStateDbTable(ovsdbClient, key);
} catch (OvsdbClientException e) { } catch (OvsdbClientException e) {
@@ -375,7 +378,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
List<Map<String, String>> delete = new ArrayList<>(); List<Map<String, String>> delete = new ArrayList<>();
List<Map<String, String>> update = new ArrayList<>(); List<Map<String, String>> update = new ArrayList<>();
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
@@ -383,7 +385,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
Map<String, String> rowMap = new HashMap<>(); Map<String, String> rowMap = new HashMap<>();
rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> { rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
rowMap.put(c.getKey(), c.getValue().toString()); OvsdbDao.translateDhcpFpValueToString(c, rowMap);
}); });
delete.add(rowMap); delete.add(rowMap);
@@ -393,7 +395,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
Map<String, String> rowMap = new HashMap<>(); Map<String, String> rowMap = new HashMap<>();
rowUpdate.getNew().getColumns().entrySet().stream().forEach(c -> { rowUpdate.getNew().getColumns().entrySet().stream().forEach(c -> {
rowMap.put(c.getKey(), c.getValue().toString()); OvsdbDao.translateDhcpFpValueToString(c, rowMap);
}); });
insert.add(rowMap); insert.add(rowMap);
@@ -404,26 +406,26 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns()); rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> { rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
rowMap.put(c.getKey(), c.getValue().toString()); OvsdbDao.translateDhcpFpValueToString(c, rowMap);
}); });
update.add(rowMap); update.add(rowMap);
} }
} }
} }
if (!insert.isEmpty()) { if (!insert.isEmpty()) {
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(insert, key,RowUpdateOperation.INSERT); extIntegrationInterface.dhcpLeasedIpDbTableUpdate(insert, key, RowUpdateOperation.INSERT);
} }
if (!delete.isEmpty()) { if (!delete.isEmpty()) {
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(delete, key,RowUpdateOperation.DELETE); extIntegrationInterface.dhcpLeasedIpDbTableUpdate(delete, key, RowUpdateOperation.DELETE);
} }
if (!update.isEmpty()) { if (!update.isEmpty()) {
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(update, key,RowUpdateOperation.MODIFY); extIntegrationInterface.dhcpLeasedIpDbTableUpdate(update, key, RowUpdateOperation.MODIFY);
} }
@@ -436,8 +438,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
} }
private void monitorCommandStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { private void monitorCommandStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> csCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> csCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
@@ -750,20 +752,23 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
@Override @Override
public String startDebugEngine(String apId, String gatewayHostname, Integer gatewayPort) { public String startDebugEngine(String apId, String gatewayHostname, Integer gatewayPort) {
LOG.debug("TipWlanOvsdbClient::startDebugEngine apId {} gatewayHostname {} gatewayPort {}", apId,gatewayHostname,gatewayPort); LOG.debug("TipWlanOvsdbClient::startDebugEngine apId {} gatewayHostname {} gatewayPort {}", apId,
gatewayHostname, gatewayPort);
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId); OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
OvsdbClient ovsdbClient = session.getOvsdbClient(); OvsdbClient ovsdbClient = session.getOvsdbClient();
// TODO: need to establish what the command will be to start debug logging, on the AP side // TODO: need to establish what the command will be to start debug
// logging, on the AP side
// For now, use start_debug_engine // For now, use start_debug_engine
// Map will have gateway_host and gateway_port for now // Map will have gateway_host and gateway_port for now
// Delay/Duration TBD, just use 0s for now // Delay/Duration TBD, just use 0s for now
Map<String,String> payload = new HashMap<>(); Map<String, String> payload = new HashMap<>();
payload.put("gateway_hostname", gatewayHostname); payload.put("gateway_hostname", gatewayHostname);
payload.put("gateway_port", gatewayPort.toString()); payload.put("gateway_port", gatewayPort.toString());
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StartDebugEngineApCommand, payload, Long.valueOf(0L), Long.valueOf(0L)); ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StartDebugEngineApCommand, payload, Long.valueOf(0L),
Long.valueOf(0L));
LOG.debug("Started debug engine on AP {} with gateway {} port {}", apId, gatewayHostname, gatewayPort); LOG.debug("Started debug engine on AP {} with gateway {} port {}", apId, gatewayHostname, gatewayPort);
return "Started debug engine on AP " + apId + " with gateway " + gatewayHostname + " port " + gatewayPort; return "Started debug engine on AP " + apId + " with gateway " + gatewayHostname + " port " + gatewayPort;
} }
@@ -771,15 +776,16 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
@Override @Override
public String stopDebugEngine(String apId) { public String stopDebugEngine(String apId) {
LOG.debug("TipWlanOvsdbClient::stopDebugEngine apId {}", apId); LOG.debug("TipWlanOvsdbClient::stopDebugEngine apId {}", apId);
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId); OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
OvsdbClient ovsdbClient = session.getOvsdbClient(); OvsdbClient ovsdbClient = session.getOvsdbClient();
Map<String,String> payload = new HashMap<>(); Map<String, String> payload = new HashMap<>();
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, Long.valueOf(0L), Long.valueOf(0L)); ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, Long.valueOf(0L),
Long.valueOf(0L));
LOG.debug("Stop debug engine on AP {}", apId); LOG.debug("Stop debug engine on AP {}", apId);
return "Stop debug engine on AP " + apId ; return "Stop debug engine on AP " + apId;
} }
} }

View File

@@ -51,6 +51,9 @@ import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiInetConfigInfo
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiRadioConfigInfo; import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiRadioConfigInfo;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiStatsConfigInfo; import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiStatsConfigInfo;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiVifConfigInfo; import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiVifConfigInfo;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpDbStatus;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpDeviceType;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpManufId;
import com.telecominfraproject.wlan.profile.bonjour.models.BonjourGatewayProfile; import com.telecominfraproject.wlan.profile.bonjour.models.BonjourGatewayProfile;
import com.telecominfraproject.wlan.profile.bonjour.models.BonjourServiceSet; import com.telecominfraproject.wlan.profile.bonjour.models.BonjourServiceSet;
import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalAuthenticationType; import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalAuthenticationType;
@@ -187,6 +190,21 @@ public class OvsdbDao {
public static final String StopDebugEngineApCommand = "stop_debug_engine"; public static final String StopDebugEngineApCommand = "stop_debug_engine";
public static void translateDhcpFpValueToString(Entry<String, Value> c, Map<String, String> rowMap) {
if (c.getKey().equals("manuf_id")) {
rowMap.put(c.getKey(), DhcpFpManufId.getById(Integer.valueOf(c.getValue().toString())).getName());
} else if (c.getKey().equals("device_type")) {
rowMap.put(c.getKey(), DhcpFpDeviceType.getById(Integer.valueOf(c.getValue().toString())).getName());
} else if (c.getKey().equals("db_status")) {
rowMap.put(c.getKey(), DhcpFpDbStatus.getById(Integer.valueOf(c.getValue().toString())).getName());
} else {
rowMap.put(c.getKey(), c.getValue().toString());
}
}
public ConnectNodeInfo getConnectNodeInfo(OvsdbClient ovsdbClient) { public ConnectNodeInfo getConnectNodeInfo(OvsdbClient ovsdbClient) {
ConnectNodeInfo ret = new ConnectNodeInfo(); ConnectNodeInfo ret = new ConnectNodeInfo();
@@ -1833,15 +1851,14 @@ public class OvsdbDao {
} }
public void configureInterfaces(OvsdbClient ovsdbClient) { public void configureInterfaces(OvsdbClient ovsdbClient) {
configureWanInterfaces(ovsdbClient); configureWanInterfaces(ovsdbClient);
configureLanInterfaces(ovsdbClient); configureLanInterfaces(ovsdbClient);
} }
private void configureLanInterfaces(OvsdbClient ovsdbClient) { private void configureLanInterfaces(OvsdbClient ovsdbClient) {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>(); Map<String, Value> updateColumns = new HashMap<>();
@@ -3114,7 +3131,7 @@ public class OvsdbDao {
// netmask // netmask
// broadcast // broadcast
} }
Row row = new Row(updateColumns); Row row = new Row(updateColumns);
operations.add(new Update(wifiInetConfigDbTable, conditions, row)); operations.add(new Update(wifiInetConfigDbTable, conditions, row));
@@ -3170,7 +3187,7 @@ public class OvsdbDao {
// netmask // netmask
// broadcast // broadcast
} }
Row row = new Row(insertColumns); Row row = new Row(insertColumns);
operations.add(new Insert(wifiInetConfigDbTable, row)); operations.add(new Insert(wifiInetConfigDbTable, row));

View File

@@ -0,0 +1,107 @@
package com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.telecominfraproject.wlan.core.model.extensibleenum.EnumWithId;
public class DhcpFpDbStatus implements EnumWithId {
private static Object lock = new Object();
private static final Map<Integer, DhcpFpDbStatus> ELEMENTS = new ConcurrentHashMap<>();
private static final Map<String, DhcpFpDbStatus> ELEMENTS_BY_NAME = new ConcurrentHashMap<>();
// typedef enum {
// DHCP_FP_DB_SUCCESS = 0,
// DHCP_FP_DB_FAILURE
// } dhcp_fp_dbstatus_t;
public static final DhcpFpDbStatus DHCP_FP_DB_SUCCESS = new DhcpFpDbStatus(0, "DHCP_FP_DB_SUCCESS"),
DHCP_FP_DB_FAILURE = new DhcpFpDbStatus(1, "DHCP_FP_DB_FAILURE"),
UNSUPPORTED = new DhcpFpDbStatus(-1, "UNSUPPORTED");
private final int id;
private final String name;
protected DhcpFpDbStatus(int id, String name) {
synchronized (lock) {
this.id = id;
this.name = name;
ELEMENTS_BY_NAME.values().forEach(s -> {
if (s.getName().equals(name)) {
throw new IllegalStateException("DhcpFpDbStatus item for " + name
+ " is already defined, cannot have more than one of them");
}
});
if (ELEMENTS.containsKey(id)) {
throw new IllegalStateException("DhcpFpDbStatus item " + name + "(" + id
+ ") is already defined, cannot have more than one of them");
}
ELEMENTS.put(id, this);
ELEMENTS_BY_NAME.put(name, this);
}
}
@Override
public int getId() {
return id;
}
@Override
public String getName() {
return name;
}
public static DhcpFpDbStatus getById(int enumId) {
return ELEMENTS.get(enumId);
}
@JsonCreator
public static DhcpFpDbStatus getByName(String value) {
DhcpFpDbStatus ret = ELEMENTS_BY_NAME.get(value);
if (ret == null) {
ret = UNSUPPORTED;
}
return ret;
}
public static List<DhcpFpDbStatus> getValues() {
return new ArrayList<>(ELEMENTS.values());
}
public static boolean isUnsupported(DhcpFpDbStatus value) {
return (UNSUPPORTED.equals(value));
}
@Override
public int hashCode() {
return id;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof DhcpFpDbStatus)) {
return false;
}
DhcpFpDbStatus other = (DhcpFpDbStatus) obj;
return id == other.id;
}
@Override
public String toString() {
return name;
}
}

View File

@@ -0,0 +1,135 @@
package com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.telecominfraproject.wlan.core.model.extensibleenum.EnumWithId;
public class DhcpFpDeviceType implements EnumWithId {
private static Object lock = new Object();
private static final Map<Integer, DhcpFpDeviceType> ELEMENTS = new ConcurrentHashMap<>();
private static final Map<String, DhcpFpDeviceType> ELEMENTS_BY_NAME = new ConcurrentHashMap<>();
// typedef enum {
// DHCP_FP_DEV_TYPE_MISC = 0,
// DHCP_FP_DEV_TYPE_MOBILE = 1,
// DHCP_FP_DEV_TYPE_PC = 2,
// DHCP_FP_DEV_TYPE_PRINTER = 3,
// DHCP_FP_DEV_TYPE_VIDEO = 4,
// DHCP_FP_DEV_TYPE_GAME = 5,
// DHCP_FP_DEV_TYPE_VOIP = 6,
// DHCP_FP_DEV_TYPE_MONITORING = 7,
// DHCP_FP_DEV_TYPE_MAX = 8
// } dhcp_fp_devicetype_t;
public static final DhcpFpDeviceType DHCP_FP_DEV_TYPE_MISC = new DhcpFpDeviceType(0, "DHCP_FP_DEV_TYPE_MISC"),
DHCP_FP_DEV_TYPE_MOBILE = new DhcpFpDeviceType(1, "DHCP_FP_DEV_TYPE_MOBILE"),
DHCP_FP_DEV_TYPE_PC = new DhcpFpDeviceType(2, "DHCP_FP_DEV_TYPE_PC"),
DHCP_FP_DEV_TYPE_PRINTER = new DhcpFpDeviceType(3, "DHCP_FP_DEV_TYPE_PRINTER"),
DHCP_FP_DEV_TYPE_VIDEO = new DhcpFpDeviceType(4, "DHCP_FP_DEV_TYPE_VIDEO"),
DHCP_FP_DEV_TYPE_GAME = new DhcpFpDeviceType(5, "DHCP_FP_DEV_TYPE_GAME"),
DHCP_FP_DEV_TYPE_VOIP = new DhcpFpDeviceType(6, "DHCP_FP_DEV_TYPE_VOIP"),
DHCP_FP_DEV_TYPE_MONITORING = new DhcpFpDeviceType(7, "DHCP_FP_DEV_TYPE_MONITORING"),
DHCP_FP_DEV_TYPE_MAX = new DhcpFpDeviceType(8, "DHCP_FP_DEV_TYPE_MAX"),
UNSUPPORTED = new DhcpFpDeviceType(-1, "UNSUPPORTED");
private final int id;
private final String name;
protected DhcpFpDeviceType(int id, String name) {
synchronized (lock) {
this.id = id;
this.name = name;
ELEMENTS_BY_NAME.values().forEach(s -> {
if (s.getName().equals(name)) {
throw new IllegalStateException("DhcpFpDeviceType item for " + name
+ " is already defined, cannot have more than one of them");
}
});
if (ELEMENTS.containsKey(id)) {
throw new IllegalStateException("DhcpFpDeviceType item " + name + "(" + id
+ ") is already defined, cannot have more than one of them");
}
ELEMENTS.put(id, this);
ELEMENTS_BY_NAME.put(name, this);
}
}
@Override
public int getId() {
return id;
}
@Override
public String getName() {
return name;
}
public static DhcpFpDeviceType getById(int enumId) {
return ELEMENTS.get(enumId);
}
@JsonCreator
public static DhcpFpDeviceType getByName(String value) {
DhcpFpDeviceType ret = ELEMENTS_BY_NAME.get(value);
if (ret == null) {
ret = UNSUPPORTED;
}
return ret;
}
public static List<DhcpFpDeviceType> getValues() {
return new ArrayList<>(ELEMENTS.values());
}
public static boolean isUnsupported(DhcpFpDeviceType value) {
return (UNSUPPORTED.equals(value));
}
@Override
public int hashCode() {
return id;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof DhcpFpDeviceType)) {
return false;
}
DhcpFpDeviceType other = (DhcpFpDeviceType) obj;
return id == other.id;
}
@Override
public String toString() {
return name;
}
// @Override
// public int getId() {
// // TODO Auto-generated method stub
// return 0;
// }
//
// @Override
// public String getName() {
// // TODO Auto-generated method stub
// return null;
// }
}

View File

@@ -0,0 +1,139 @@
package com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.telecominfraproject.wlan.core.model.extensibleenum.EnumWithId;
public class DhcpFpManufId implements EnumWithId {
private static Object lock = new Object();
private static final Map<Integer, DhcpFpManufId> ELEMENTS = new ConcurrentHashMap<>();
private static final Map<String, DhcpFpManufId> ELEMENTS_BY_NAME = new ConcurrentHashMap<>();
// typedef enum {
// DHCP_FP_DEV_MANUF_MISC = 0,
// DHCP_FP_DEV_MANUF_SAMSUNG = 1,
// DHCP_FP_DEV_MANUF_APPLE = 2,
// DHCP_FP_DEV_MANUF_GOOGLE = 3,
// DHCP_FP_DEV_MANUF_HP = 4,
// DHCP_FP_DEV_MANUF_INTEL = 5,
// DHCP_FP_DEV_MANUF_MICROSOFT = 6,
// DHCP_FP_DEV_MANUF_LG = 7,
// DHCP_FP_DEV_MANUF_CANON = 8,
// DHCP_FP_DEV_MANUF_BROTHER = 9,
// DHCP_FP_DEV_MANUF_DELL = 10,
// DHCP_FP_DEV_MANUF_LENOVO = 11,
// DHCP_FP_DEV_MANUF_VIVO = 12,
// DHCP_FP_DEV_MANUF_ALCATEL = 13,
// DHCP_FP_DEV_MANUF_ZTE = 14,
// DHCP_FP_DEV_MANUF_SONY = 15,
// DHCP_FP_DEV_MANU_MAX = 16
// } dhcp_fp_manufid_t;
public static final DhcpFpManufId DHCP_FP_DEV_MANUF_MISC = new DhcpFpManufId(0, "DHCP_FP_DEV_MANUF_MISC"),
DHCP_FP_DEV_MANUF_SAMSUNG = new DhcpFpManufId(1, "DHCP_FP_DEV_MANUF_SAMSUNG"),
DHCP_FP_DEV_MANUF_APPLE = new DhcpFpManufId(2, "DHCP_FP_DEV_MANUF_APPLE"),
DHCP_FP_DEV_MANUF_GOOGLE = new DhcpFpManufId(3, "DHCP_FP_DEV_MANUF_GOOGLE"),
DHCP_FP_DEV_MANUF_HP = new DhcpFpManufId(4, "DHCP_FP_DEV_MANUF_HP"),
DHCP_FP_DEV_MANUF_INTEL = new DhcpFpManufId(5, "DHCP_FP_DEV_MANUF_INTEL"),
DHCP_FP_DEV_MANUF_MICROSOFT = new DhcpFpManufId(6, "DHCP_FP_DEV_MANUF_MICROSOFT"),
DHCP_FP_DEV_MANUF_LG = new DhcpFpManufId(7, "DHCP_FP_DEV_MANUF_LG"),
DHCP_FP_DEV_MANUF_CANON = new DhcpFpManufId(8, "DHCP_FP_DEV_MANUF_CANON"),
DHCP_FP_DEV_MANUF_BROTHER = new DhcpFpManufId(9, "DHCP_FP_DEV_MANUF_BROTHER"),
DHCP_FP_DEV_MANUF_DELL = new DhcpFpManufId(10, "DHCP_FP_DEV_MANUF_DELL"),
DHCP_FP_DEV_MANUF_LENOVO = new DhcpFpManufId(11, "DHCP_FP_DEV_MANUF_LENOVO"),
DHCP_FP_DEV_MANUF_VIVO = new DhcpFpManufId(12, "DHCP_FP_DEV_MANUF_VIVO"),
DHCP_FP_DEV_MANUF_ALCATEL = new DhcpFpManufId(13, "DHCP_FP_DEV_MANUF_ALCATEL"),
DHCP_FP_DEV_MANUF_ZTE = new DhcpFpManufId(14, "DHCP_FP_DEV_MANUF_ZTE"),
DHCP_FP_DEV_MANUF_SONY = new DhcpFpManufId(15, "DHCP_FP_DEV_MANUF_SONY"),
DHCP_FP_DEV_MANU_MAX = new DhcpFpManufId(16, "DHCP_FP_DEV_MANU_MAX"),
UNSUPPORTED = new DhcpFpManufId(-1, "UNSUPPORTED");
private final int id;
private final String name;
protected DhcpFpManufId(int id, String name) {
synchronized (lock) {
this.id = id;
this.name = name;
ELEMENTS_BY_NAME.values().forEach(s -> {
if (s.getName().equals(name)) {
throw new IllegalStateException("DhcpFpManufId item for " + name
+ " is already defined, cannot have more than one of them");
}
});
if (ELEMENTS.containsKey(id)) {
throw new IllegalStateException("DhcpFpManufId item " + name + "(" + id
+ ") is already defined, cannot have more than one of them");
}
ELEMENTS.put(id, this);
ELEMENTS_BY_NAME.put(name, this);
}
}
@Override
public int getId() {
return id;
}
@Override
public String getName() {
return name;
}
public static DhcpFpManufId getById(int enumId) {
return ELEMENTS.get(enumId);
}
@JsonCreator
public static DhcpFpManufId getByName(String value) {
DhcpFpManufId ret = ELEMENTS_BY_NAME.get(value);
if (ret == null) {
ret = UNSUPPORTED;
}
return ret;
}
public static List<DhcpFpManufId> getValues() {
return new ArrayList<>(ELEMENTS.values());
}
public static boolean isUnsupported(DhcpFpManufId value) {
return (UNSUPPORTED.equals(value));
}
@Override
public int hashCode() {
return id;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof DhcpFpManufId)) {
return false;
}
DhcpFpManufId other = (DhcpFpManufId) obj;
return id == other.id;
}
@Override
public String toString() {
return name;
}
}