diff --git a/Makefile.am b/Makefile.am index 835e2e6f..8eafb03f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,10 @@ lib_LTLIBRARIES=libwifi.la libwifi_la_CPPFLAGS = -D_ANSC_LINUX -D_ANSC_USER -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/custom -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/include -I$(top_srcdir)/../CcspCommonLibrary/source/debug_api/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/include/linux -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/package/slap/include -I$(top_srcdir)/../hal/include -I$(top_srcdir)/../CcspCommonLibrary/source/util_api/http/include -I$(top_srcdir)/../CcspCommonLibrary/source/util_api/ansc/include -I$(top_srcdir)/lib -I$(top_srcdir)/lib/common -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/common/MessageBusHelper/include -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/common/PoamIrepFolder -I$(top_srcdir)/include/wifi_ssp -I$(top_srcdir)/./include -libwifi_la_CPPFLAGS +=-I$(top_srcdir)/source/dml/dml_webconfig -I$(top_srcdir)/source/dml/tr_181/ml -I$(top_srcdir)/source/dml/tr_181/sbapi -I$(top_srcdir)/include/tr_181/ml +libwifi_la_CPPFLAGS +=-I$(top_srcdir)/source/dml/dml_webconfig +if ONEWIFI_DML_SUPPORT +libwifi_la_CPPFLAGS += -I$(top_srcdir)/source/dml/tr_181/ml -I$(top_srcdir)/source/dml/tr_181/sbapi -I$(top_srcdir)/include/tr_181/ml +endif if CCSP_ARCH_ARM libwifi_la_CPPFLAGS += -D_ANSC_LITTLE_ENDIAN_ @@ -37,10 +40,12 @@ endif libwifi_la_LDFLAGS= libwifi_la_SOURCES= +if ONEWIFI_DML_SUPPORT EXTRA_DEPENDENCIES= \ source/dml/tr_181/sbapi/libCcspWifiAgent_sbapi.la \ source/dml/tr_181/ml/libCcspWifiAgent_ml.la \ - source/dml/dml_webconfig/libCcspWifiAgent_dml_webconfig.la + source/dml/dml_webconfig/libCcspWifiAgent_dml_webconfig.la +endif libwifi_la_DEPENDENCIES= \ $(EXTRA_DEPENDENCIES) diff --git a/config/bus_dml_config.json b/config/bus_dml_config.json new file mode 100644 index 00000000..2e430d14 --- /dev/null +++ b/config/bus_dml_config.json @@ -0,0 +1,1773 @@ +{ + "definitions": { + "uint32_t": { + "type": "integer", + "minimum": 0, + "maximum": 4294967295 + }, + "int32_t": { + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "uint16_t": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "uint8_t": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "boolean": { + "type": "bool", + "minimum": 0, + "maximum": 1 + }, + "string": { + "type": "string", + "minimum": 1, + "maximum": 64 + }, + "timestamp_t": { + "title": "Timestamp", + "type": "string", + "format": "date-time" + }, + "macaddr_t": { + "title": "MAC Address", + "type": "string", + "minLength": 17, + "maxLength": 17, + "pattern": "^([0-9a-fA-F][0-9a-fA-F]:){5}[0-9a-fA-F][0-9a-fA-F]$" + }, + "rssi_t": { + "title": "RSSI", + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "txpower_t": { + "title": "Tx Power", + "type": "integer", + "minimum": -1, + "maximum": 100 + }, + "whix_log_interval_t": { + "title": "WHIX Log Interval", + "type": "integer", + "minimum": 300, + "maximum": 3600 + }, + "whix_ch_utility_log_interval_t": { + "title": "whix ch utility log interval", + "type": "integer", + "minimum": 5, + "maximum": 3600 + }, + "channel_t": { + "title": "Channel", + "type": "unsigned_int", + "minimum": 0, + "maximum": 255 + }, + "rssi_threshold_t": { + "title": "rssi threshold", + "type": "integer", + "minimum": -100, + "maximum": -30 + }, + "rts_threshold_t": { + "title": "rts threshold", + "type": "unsigned_int", + "minimum": 0, + "maximum": 2347 + }, + "frag_threshold_t": { + "title": "frag threshold", + "type": "unsigned_int", + "minimum": 256, + "maximum": 2346 + }, + "dtim_interval_t": { + "title": "dtim interval", + "type": "unsigned_int", + "minimum": 0, + "maximum": 255 + }, + "beacon_interval_t": { + "title": "beacon interval", + "type": "unsigned_int", + "minimum": 100, + "maximum": 3500 + }, + "cts_protection_t": { + "title": "cts protection", + "type": "unsigned_int", + "minimum": 0, + "maximum": 1 + }, + "tx_rate_t": { + "title": "tx rate", + "type": "unsigned_int", + "minimum": 1, + "maximum": 9 + }, + "basic_rate_t": { + "title": "basic rate", + "type": "unsigned_int", + "minimum": 1, + "maximum": 3 + }, + "ap_retry_limit_t": { + "title": "ap retry limit", + "type": "unsigned_int", + "minimum": 0, + "maximum": 255 + }, + "rapid_reconnect_max_time_t": { + "title": "rapid reconnect max time", + "type": "integer", + "minimum": 15, + "maximum": 1200 + }, + "eapol_key_timeout_t": { + "title": "eapol key timeout", + "type": "unsigned_int", + "minimum": 100, + "maximum": 5000 + }, + "eap_identity_req_timeout_t": { + "title": "eap identity req timeout", + "type": "unsigned_int", + "minimum": 0, + "maximum": 5000 + }, + "eap_req_timeout_t": { + "title": "eap_req_timeout_t", + "type": "unsigned_int", + "minimum": 10, + "maximum": 5000 + }, + "bandwidth_t": { + "title": "Radio Bandwidth", + "type": "string", + "enum": [ + "Auto", + "20MHz", + "40MHz", + "80MHz", + "160MHz", + "80_80MHz", + "320MHz" + ] + }, + "guard_interval_t": { + "title": "guard interval", + "type": "string", + "enum": [ + "400nsec", + "800nsec", + "Auto", + "1600nsec", + "3200nsec" + ] + }, + "encryption_method_t": { + "title": "encryption method", + "type": "string", + "enum": [ + "TKIP", + "AES", + "AES+TKIP" + ] + }, + "wifi_status_t": { + "title": "WiFi radio/Vap status information", + "type": "string", + "enum": [ + "Up", + "Down", + "Unknown", + "Dormant", + "NotPresent", + "LowerLayerDown", + "Error", + "DeepSleep" + ] + } + }, + "Device": { + "WiFi": { + "List_Of_Def": { + "ApplyRadioSettings": { + "type": "boolean", + "writable": true + }, + "ApplyAccessPointSettings": { + "type": "boolean", + "writable": true + }, + "X_CISCO_COM_FactoryReset": { + "type": "boolean", + "writable": true + }, + "X_CISCO_COM_EnableTelnet": { + "type": "boolean", + "writable": true + }, + "X_CISCO_COM_ResetRadios": { + "type": "boolean", + "writable": true + }, + "WiFiStuckDetect": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_WiFiHost_Sync": { + "type": "boolean", + "writable": true + }, + "2G80211axEnable": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_PreferPrivate": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_RapidReconnectIndicationEnable": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_vAPStatsEnable": { + "type": "boolean", + "writable": true + }, + "FeatureMFPConfig": { + "type": "boolean", + "writable": true + }, + "TxOverflowSelfheal": { + "type": "boolean", + "writable": true + }, + "X_RDK-CENTRAL_COM_ForceDisable": { + "type": "boolean", + "writable": true + }, + "Managed_WiFi_Enabled": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_EnableRadiusGreyList": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_EnableHostapdAuthenticator": { + "type": "boolean", + "writable": true + }, + "DFS": { + "type": "boolean", + "writable": true + }, + "Levl": { + "type": "boolean", + "writable": true + }, + "DFSatBootUp": { + "type": "boolean", + "writable": true + }, + "WiFi-Interworking": { + "type": "boolean", + "writable": true + }, + "WiFi-Passpoint": { + "type": "boolean", + "writable": true + }, + "WiFi-OffChannelScan-APP": { + "type": "boolean", + "writable": true + }, + "WiFi-OffChannelScan": { + "type": "boolean", + "writable": true + }, + "WPA3_Personal_Transition": { + "type": "boolean", + "writable": true + }, + "Log_Upload": { + "type": "boolean", + "writable": true + }, + "X_RDKCENTRAL-COM_AssocCountThreshold": { + "type": "int32_t", + "writable": true + }, + "X_RDKCENTRAL-COM_AssocMonitorDuration": { + "type": "int32_t", + "writable": true + }, + "X_RDKCENTRAL-COM_AssocGateTime": { + "type": "int32_t", + "writable": true + }, + "WHIX_LogInterval": { + "type": "whix_log_interval_t", + "writable": true + }, + "WHIX_ChUtility_LogInterval": { + "type": "whix_ch_utility_log_interval_t", + "writable": true + }, + "X_RDKCENTRAL-COM_GoodRssiThreshold": { + "type": "rssi_threshold_t", + "writable": true + }, + "RadioNumberOfEntries": { + "type": "uint32_t", + "writable": false + }, + "SSIDNumberOfEntries": { + "type": "uint32_t", + "writable": false + }, + "AccessPointNumberOfEntries": { + "type": "uint32_t", + "writable": false + }, + "X_CISCO_COM_RadioPower": { + "type": "string", + "writable": true + }, + "X_CISCO_COM_FactoryResetRadioAndAp": { + "type": "string", + "writable": true + }, + "X_RDK_VapData": { + "type": "string", + "writable": true + }, + "X_RDK_RadioData": { + "type": "string", + "writable": true + }, + "X_RDKCENTRAL-COM_WiFi_Notification": { + "type": "string", + "writable": true + }, + "X_RDKCENTRAL-COM_Connected-Client": { + "type": "string", + "writable": true + }, + "X_RDKCENTRAL-COM_Br0_Sync": { + "type": "string", + "writable": true + }, + "Status": { + "type": "wifi_status_t", + "writable": true + }, + "X_RDKCENTRAL-COM_GASConfiguration": { + "type": "string", + "writable": true + }, + "Log_Enable": { + "type": "string", + "writable": true + } + }, + "X_RDKCENTRAL-COM_Report":{ + "List_Of_Def": { + "WifiClient": { + "List_Of_Def": { + "Enabled": { + "type": "boolean", + "writable": true + }, + "ReportingPeriod": { + "type": "uint32_t", + "writable": true + }, + "MacAddress": { + "type": "string", + "writable": true + }, + "Schema": { + "type": "string", + "writable": false + }, + "SchemaID": { + "type": "string", + "writable": false + }, + "Default": { + "List_Of_Def": { + "ReportingPeriod": { + "type": "uint32_t", + "writable": true + }, + "OverrideTTL": { + "type": "uint32_t", + "writable": true + } + } + } + } + } + } + }, + "X_RDKCENTRAL-COM_Syndication":{ + "List_Of_Def": { + "WiFiRegion": { + "List_Of_Def": { + "Code": { + "type": "string", + "writable": true + } + } + } + } + }, + "Radio": { + "Num_Of_Objects": 3, + "List_Of_Def": [ + { + "Enable": { + "type": "boolean", + "writable": true + } + }, + { + "AutoChannelSupported": { + "type": "boolean", + "writable": false + } + }, + { + "AutoChannelEnable": { + "type": "boolean", + "writable": true + } + }, + { + "IEEE80211hSupported": { + "type": "boolean", + "writable": false + } + }, + { + "IEEE80211hEnabled": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_FrameBurst": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_APIsolation": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_ApplySetting": { + "type": "boolean", + "writable": true + } + }, + { + "X_COMCAST_COM_DFSSupport": { + "type": "boolean", + "writable": false + } + }, + { + "X_COMCAST_COM_DFSEnable": { + "type": "boolean", + "writable": true + } + }, + { + "X_COMCAST-COM_DCSEnable": { + "type": "boolean", + "writable": true + } + }, + { + "X_COMCAST-COM_RtsThresholdSupported": { + "type": "boolean", + "writable": false + } + }, + { + "X_RDK_EcoPowerDown": { + "type": "boolean", + "writable": true + } + }, + { + "MCS": { + "type": "int32_t", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_clientInactivityTimeout": { + "type": "int32_t", + "writable": false + } + }, + { + "TransmitPower": { + "type": "txpower_t", + "writable": true + } + }, + { + "AutoChannelRefreshPeriod": { + "type": "uint32_t", + "writable": true + } + }, + { + "Channel": { + "type": "channel_t", + "writable": true + } + }, + { + "X_CISCO_COM_RTSThreshold": { + "type": "rts_threshold_t", + "writable": true + } + }, + { + "X_CISCO_COM_FragmentationThreshold": { + "type": "frag_threshold_t", + "writable": true + } + }, + { + "X_CISCO_COM_DTIMInterval": { + "type": "dtim_interval_t", + "writable": true + } + }, + { + "X_COMCAST-COM_BeaconInterval": { + "type": "beacon_interval_t", + "writable": true + } + }, + { + "BeaconPeriod": { + "type": "beacon_interval_t", + "writable": true + } + }, + { + "X_CISCO_COM_CTSProtectionMode": { + "type": "cts_protection_t", + "writable": true + } + }, + { + "X_CISCO_COM_TxRate": { + "type": "tx_rate_t", + "writable": false + } + }, + { + "X_CISCO_COM_BasicRate": { + "type": "basic_rate_t", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_ChannelUtilThreshold": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_ChanUtilSelfHealEnable": { + "type": "uint32_t", + "writable": false + } + }, + { + "RadioResetCount": { + "type": "uint32_t", + "writable": false + } + }, + { + "ExtensionChannel": { + "type": "uint32_t", + "writable": true + } + }, + { + "Alias": { + "type": "string", + "writable": true + } + }, + { + "Status": { + "type": "wifi_status_t", + "writable": false + } + }, + { + "Name": { + "type": "string", + "writable": false + } + }, + { + "SupportedFrequencyBands": { + "type": "string", + "writable": false + } + }, + { + "OperatingFrequencyBand": { + "type": "string", + "writable": false + } + }, + { + "SupportedStandards": { + "type": "string", + "writable": false + } + }, + { + "OperatingStandards": { + "type": "string", + "writable": true + } + }, + { + "PossibleChannels": { + "type": "string", + "writable": false + } + }, + { + "OperatingChannelBandwidth": { + "type": "bandwidth_t", + "writable": true + } + }, + { + "GuardInterval": { + "type": "guard_interval_t", + "writable": true + } + }, + { + "TransmitPowerSupported": { + "type": "string", + "writable": false + } + }, + { + "RegulatoryDomain": { + "type": "string", + "writable": true + } + }, + { + "BasicDataTransmitRates": { + "type": "string", + "writable": true + } + }, + { + "SupportedDataTransmitRates": { + "type": "string", + "writable": false + } + }, + { + "OperationalDataTransmitRates": { + "type": "string", + "writable": true + } + }, + { + "X_CISCO_COM_ApChannelScan": { + "type": "string", + "writable": false + } + }, + { + "ChannelsInUse": { + "type": "string", + "writable": false + } + } + ] + }, + "AccessPoint": { + "Num_Of_Objects": 24, + "List_Of_Def": [ + { + "Enable": { + "type": "boolean", + "writable": true + } + }, + { + "WMMCapability": { + "type": "boolean", + "writable": false + } + }, + { + "UAPSDCapability": { + "type": "boolean", + "writable": false + } + }, + { + "WMMEnable": { + "type": "boolean", + "writable": true + } + }, + { + "UAPSDEnable": { + "type": "boolean", + "writable": true + } + }, + { + "IsolationEnable": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_BssCountStaAsCpe": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_BssHotSpot": { + "type": "boolean", + "writable": true + } + }, + { + "SSIDAdvertisementEnabled": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_KickAssocDevices": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_InterworkingServiceCapability": { + "type": "boolean", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_InterworkingServiceEnable": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_InterworkingApplySettings": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_rapidReconnectCountEnable": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_StatsEnable": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_WirelessManagementImplemented": { + "type": "boolean", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_BSSTransitionImplemented": { + "type": "boolean", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_BSSTransitionActivated": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_NeighborReportActivated": { + "type": "boolean", + "writable": true + } + }, + { + "Connected_Building_Enabled": { + "type": "boolean", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_HostapMgtFrameCtrl": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_WmmNoAck": { + "type": "int32_t", + "writable": true + } + }, + { + "X_CISCO_COM_MulticastRate": { + "type": "int32_t", + "writable": true + } + }, + { + "X_CISCO_COM_BssMaxNumSta": { + "type": "int32_t", + "writable": true + } + }, + { + "X_CISCO_COM_BssUserStatus": { + "type": "int32_t", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_ManagementFramePowerControl": { + "type": "int32_t", + "writable": true + } + }, + { + "X_RDKCENTRAL-COM_rapidReconnectMaxTime": { + "type": "rapid_reconnect_max_time_t", + "writable": true + } + }, + { + "AssociatedDeviceNumberOfEntries": { + "type": "uint32_t", + "writable": false + } + }, + { + "MaxAssociatedDevices": { + "type": "uint32_t", + "writable": true + } + }, + { + "X_COMCAST-COM_AssociatedDevicesHighWatermarkThreshold": { + "type": "uint32_t", + "writable": true + } + }, + { + "X_COMCAST-COM_AssociatedDevicesHighWatermarkThresholdReached": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_AssociatedDevicesHighWatermark": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_AssociatedDevicesHighWatermarkDate": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_TXOverflow": { + "type": "uint32_t", + "writable": false + } + }, + { + "RetryLimit": { + "type": "ap_retry_limit_t", + "writable": true + } + }, + { + "X_CISCO_COM_LongRetryLimit": { + "type": "ap_retry_limit_t", + "writable": true + } + }, + { + "X_CISCO_COM_MacFilterTableNumberOfEntries": { + "type": "uint32_t", + "writable": false + } + }, + { + "Status": { + "type": "wifi_status_t", + "writable": false + } + }, + { + "Alias": { + "type": "string", + "writable": false + } + }, + { + "SSIDReference": { + "type": "string", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_BeaconRate": { + "type": "string", + "writable": true + } + }, + { + "X_COMCAST-COM_MAC_FilteringMode": { + "type": "string", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_InterworkingElement": { + "List_Of_Def": { + "Internet": { + "type": "boolean", + "writable": true + }, + "ASRA": { + "type": "boolean", + "writable": true + }, + "ESR": { + "type": "boolean", + "writable": true + }, + "UESA": { + "type": "boolean", + "writable": true + }, + "HESSOptionPresent": { + "type": "boolean", + "writable": true + }, + "AccessNetworkType": { + "type": "uint32_t", + "writable": true + }, + "VenueInfo.Group": { + "type": "uint32_t", + "writable": true + }, + "VenueInfo.Type": { + "type": "uint32_t", + "writable": true + }, + "HESSID": { + "type": "string", + "writable": true + } + } + } + }, + { + "X_CISCO_COM_MACFilter": { + "List_Of_Def": { + "Enable": { + "type": "boolean", + "writable": true + }, + "FilterAsBlackList": { + "type": "boolean", + "writable": true + } + } + } + }, + { + "Security": { + "List_Of_Def": { + "X_RDKCENTRAL-COM_TransitionDisable": { + "type": "boolean", + "writable": true + }, + "Reset": { + "type": "boolean", + "writable": true + }, + "X_CISCO_COM_RadiusReAuthInterval": { + "type": "int32_t", + "writable": true + }, + "X_CISCO_COM_DefaultKey": { + "type": "int32_t", + "writable": true + }, + "RekeyingInterval": { + "type": "uint32_t", + "writable": true + }, + "RadiusServerPort": { + "type": "uint32_t", + "writable": true + }, + "SecondaryRadiusServerPort": { + "type": "uint32_t", + "writable": true + }, + "RadiusDASPort": { + "type": "uint32_t", + "writable": true + }, + "X_CISCO_COM_WEPKey64BitNumberOfEntries": { + "type": "uint32_t", + "writable": false + }, + "X_CISCO_COM_WEPKey128BitNumberOfEntries": { + "type": "uint32_t", + "writable": false + }, + "ModesSupported": { + "type": "string", + "writable": false + }, + "ModeEnabled": { + "type": "string", + "writable": true + }, + "WEPKey": { + "type": "string", + "writable": true + }, + "X_CISCO_COM_WEPKey": { + "type": "string", + "writable": true + }, + "X_COMCAST-COM_WEPKey": { + "type": "string", + "writable": true + }, + "PreSharedKey": { + "type": "string", + "writable": true + }, + "KeyPassphrase":{ + "type": "string", + "writable": true + }, + "SAEPassphrase":{ + "type": "string", + "writable": true + }, + "X_COMCAST-COM_DefaultKeyPassphrase":{ + "type": "string", + "writable": false + }, + "X_COMCAST-COM_KeyPassphrase":{ + "type": "string", + "writable": true + }, + "X_CISCO_COM_EncryptionMethod":{ + "type": "encryption_method_t", + "writable": true + }, + "RadiusServerIPAddr":{ + "type": "string", + "writable": true + }, + "RadiusSecret":{ + "type": "string", + "writable": true + }, + "SecondaryRadiusServerIPAddr":{ + "type": "string", + "writable": true + }, + "SecondaryRadiusSecret":{ + "type": "string", + "writable": true + }, + "RadiusDASIPAddr":{ + "type": "string", + "writable": true + }, + "RadiusDASSecret":{ + "type": "string", + "writable": true + }, + "MFPConfig":{ + "type": "string", + "writable": true + }, + "X_COMCAST-COM_RadiusSettings": { + "List_Of_Def": { + "PMKCaching": { + "type": "boolean", + "writable": true + }, + "RadiusServerRetries": { + "type": "int32_t", + "writable": true + }, + "RadiusServerRequestTimeout": { + "type": "int32_t", + "writable": true + }, + "PMKLifetime": { + "type": "int32_t", + "writable": true + }, + "PMKCacheInterval": { + "type": "int32_t", + "writable": true + }, + "MaxAuthenticationAttempts": { + "type": "int32_t", + "writable": true + }, + "BlacklistTableTimeout": { + "type": "int32_t", + "writable": true + }, + "IdentityRequestRetryInterval": { + "type": "int32_t", + "writable": true + }, + "QuietPeriodAfterFailedAuthentication": { + "type": "int32_t", + "writable": true + } + } + }, + "X_RDKCENTRAL-COM_Authenticator": { + "List_Of_Def": { + "EAPOLKeyTimeout": { + "type": "eapol_key_timeout_t", + "writable": true + }, + "EAPOLKeyRetries": { + "type": "uint32_t", + "writable": true + }, + "EAPIdentityRequestTimeout": { + "type": "eap_identity_req_timeout_t", + "writable": true + }, + "EAPIdentityRequestRetries": { + "type": "uint32_t", + "writable": true + }, + "EAPRequestTimeout": { + "type": "eap_req_timeout_t", + "writable": true + }, + "EAPRequestRetries": { + "type": "uint32_t", + "writable": true + } + } + } + } + } + }, + { + "ConnectionControl": { + "List_Of_Def": { + "ClientForceDisassociation": { + "type": "string", + "writable": true + }, + "ClientDenyAssociation": { + "type": "string", + "writable": true + }, + "PreAssocDeny":{ + "List_Of_Def": { + "RssiUpThresholdSupported": { + "type": "string", + "writable": false + }, + "RssiUpThreshold": { + "type": "string", + "writable": true + }, + "SnrThresholdSupported": { + "type": "string", + "writable": false + }, + "SnrThreshold": { + "type": "string", + "writable": true + }, + "CuThresholdSupported": { + "type": "string", + "writable": false + }, + "CuThreshold": { + "type": "string", + "writable": true + }, + "BasicDataTransmitRates": { + "type": "string", + "writable": true + }, + "OperationalDataTransmitRates": { + "type": "string", + "writable": true + }, + "SupportedDataTransmitRates": { + "type": "string", + "writable": true + }, + "MinimumAdvertisedMCS": { + "type": "string", + "writable": true + }, + "6GOpInfoMinRate": { + "type": "string", + "writable": true + } + } + }, + "PostAssocDisc": { + "List_Of_Def": { + "RssiUpThresholdSupported": { + "type": "string", + "writable": false + }, + "RssiUpThreshold": { + "type": "string", + "writable": true + }, + "SamplingIntervalSupported": { + "type": "string", + "writable": false + }, + "SamplingInterval": { + "type": "string", + "writable": true + }, + "SnrThresholdSupported": { + "type": "string", + "writable": false + }, + "SnrThreshold": { + "type": "string", + "writable": true + }, + "SamplingCountSupported": { + "type": "string", + "writable": false + }, + "SamplingCount": { + "type": "string", + "writable": true + }, + "CuThresholdSupported": { + "type": "string", + "writable": false + }, + "CuThreshold": { + "type": "string", + "writable": true + } + } + } + } + } + }, + { + "WPS": { + "List_Of_Def": { + "Enable": { + "type": "boolean", + "writable": true + }, + "X_CISCO_COM_ActivatePushButton": { + "type": "boolean", + "writable": true + }, + "X_Comcast_com_Configured": { + "type": "boolean", + "writable": false + }, + "X_CISCO_COM_CancelSession": { + "type": "boolean", + "writable": true + }, + "X_CISCO_COM_WpsPushButton": { + "type": "int32_t", + "writable": true + }, + "ConfigMethodsSupported": { + "type": "string", + "writable": false + }, + "ConfigMethodsEnabled": { + "type": "string", + "writable": true + }, + "X_CISCO_COM_Pin": { + "type": "string", + "writable": false + }, + "X_CISCO_COM_ClientPin": { + "type": "string", + "writable": true + } + } + } + }, + { + "X_RDKCENTRAL-COM_InterworkingService": { + "List_Of_Def": { + "Parameters": { + "type": "string", + "writable": true + } + } + } + }, + { + "X_RDKCENTRAL-COM_Passpoint": { + "List_Of_Def": { + "Capability": { + "type": "boolean", + "writable": false + }, + "Enable": { + "type": "boolean", + "writable": true + }, + "Parameters": { + "type": "string", + "writable": true + }, + "WANMetrics": { + "type": "string", + "writable": false + }, + "Stats": { + "type": "string", + "writable": false + } + } + } + }, + { + "AssociatedDevice": { + "Num_Of_Objects": 0, + "List_Of_Def": [ + { + "AuthenticationState": { + "type": "boolean", + "writable": false + } + }, + { + "Active": { + "type": "boolean", + "writable": false + } + }, + { + "SignalStrength": { + "type": "int32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_SNR": { + "type": "int32_t", + "writable": false + } + }, + { + "X_RDKCENTRAL-COM_SNR": { + "type": "int32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_RSSI": { + "type": "int32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_MinRSSI": { + "type": "int32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_MaxRSSI": { + "type": "int32_t", + "writable": false + } + }, + { + "LastDataDownlinkRate": { + "type": "uint32_t", + "writable": false + } + }, + { + "LastDataUplinkRate": { + "type": "uint32_t", + "writable": false + } + }, + { + "Retransmissions": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_DataFramesSentAck": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_DataFramesSentNoAck": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_BytesSent": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_BytesReceived": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_Disassociations": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_AuthenticationFailures": { + "type": "uint32_t", + "writable": false + } + }, + { + "MACAddress": { + "type": "macaddr_t", + "writable": false + } + }, + { + "X_COMCAST-COM_OperatingStandard": { + "type": "string", + "writable": false + } + }, + { + "X_COMCAST-COM_OperatingChannelBandwidth": { + "type": "string", + "writable": false + } + }, + { + "X_COMCAST-COM_InterferenceSources": { + "type": "string", + "writable": false + } + } + ] + } + }, + { + "X_CISCO_COM_MacFilterTable":{ + "Num_Of_Objects": 0, + "List_Of_Def": [ + { + "MACAddress": { + "type": "macaddr_t", + "writable": true + } + }, + { + "DeviceName": { + "type": "string", + "writable": true + } + } + ] + } + } + ] + }, + "SSID": { + "Num_Of_Objects": 24, + "List_Of_Def": [ + { + "Enable": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_EnableOnline": { + "type": "boolean", + "writable": true + } + }, + { + "X_CISCO_COM_RouterEnabled": { + "type": "boolean", + "writable": true + } + }, + { + "LastChange": { + "type": "uint32_t", + "writable": false + } + }, + { + "Status": { + "type": "wifi_status_t", + "writable": false + } + }, + { + "Alias": { + "type": "string", + "writable": false + } + }, + { + "Name": { + "type": "string", + "writable": false + } + }, + { + "LowerLayers": { + "type": "string", + "writable": false + } + }, + { + "BSSID": { + "type": "macaddr_t", + "writable": false + } + }, + { + "MACAddress": { + "type": "macaddr_t", + "writable": false + } + }, + { + "SSID": { + "type": "string", + "writable": true + } + }, + { + "X_COMCAST-COM_DefaultSSID": { + "type": "string", + "writable": false + } + }, + { + "Repurposed_VapName": { + "type": "string", + "writable": false + } + } + ] + }, + "NeighboringWiFiDiagnostic": { + "List_Of_Def": { + "Enable": { + "type": "boolean", + "writable": true + }, + "DiagnosticsState": { + "type": "string", + "writable": true + }, + "ResultNumberOfEntries": { + "type": "uint32_t", + "writable": false + }, + "Result": { + "Num_Of_Objects": 0, + "List_Of_Def": [ + { + "SignalStrength": { + "type": "int32_t", + "writable": false + } + }, + { + "Noise": { + "type": "int32_t", + "writable": false + } + }, + { + "Channel": { + "type": "uint32_t", + "writable": false + } + }, + { + "BeaconPeriod": { + "type": "uint32_t", + "writable": false + } + }, + { + "DTIMPeriod": { + "type": "uint32_t", + "writable": false + } + }, + { + "X_COMCAST-COM_ChannelUtilization": { + "type": "uint32_t", + "writable": false + } + }, + { + "Radio": { + "type": "string", + "writable": false + } + }, + { + "SSID": { + "type": "string", + "writable": false + } + }, + { + "BSSID": { + "type": "string", + "writable": false + } + }, + { + "Mode": { + "type": "string", + "writable": false + } + }, + { + "SecurityModeEnabled": { + "type": "string", + "writable": false + } + }, + { + "EncryptionMode": { + "type": "string", + "writable": false + } + }, + { + "OperatingFrequencyBand": { + "type": "string", + "writable": false + } + }, + { + "SupportedStandards": { + "type": "string", + "writable": false + } + }, + { + "OperatingStandards": { + "type": "string", + "writable": false + } + }, + { + "OperatingChannelBandwidth": { + "type": "string", + "writable": false + } + }, + { + "BasicDataTransferRates": { + "type": "string", + "writable": false + } + }, + { + "SupportedDataTransferRates": { + "type": "string", + "writable": false + } + } + ] + } + } + } + } + } +} diff --git a/configure.ac b/configure.ac index 4b2121fb..e06e5abd 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,7 @@ AM_CONDITIONAL([EASYCONNECT_SUPPORT], [test x$EASYCONNECT_SUPPORT_ENABLE = xtrue AM_CONDITIONAL([HAL_IPC], [test x$HAL_IPC = xtrue]) AM_CONDITIONAL([ONEWIFI_CAC_APP_SUPPORT], [test x$ONEWIFI_CAC_APP_SUPPORT = xtrue]) +AM_CONDITIONAL([ONEWIFI_DML_SUPPORT], [test x$ONEWIFI_DML_SUPPORT_MAKEFILE = xtrue]) # Specify ccsp cpu arch diff --git a/include/wifi_base.h b/include/wifi_base.h index 5e33e41d..f72cf184 100644 --- a/include/wifi_base.h +++ b/include/wifi_base.h @@ -102,6 +102,20 @@ extern "C" { #define DEFAULT_SOUNDING_DURATION_MS 2000 +#if (defined SIMULATION) +#define NEIGHBORHOOD_SCAN_AVRO_FILENAME "GatewayAccessPointNeighborScanReport.avsc" +#define INTERFACE_DEVICES_WIFI_AVRO_FILENAME "InterfaceDevicesWifi.avsc" +#define WIFI_SINGLE_CLIENT_AVRO_FILENAME "/usr/ccsp/wifi/WifiSingleClient.avsc" +#define RADIO_INTERFACE_STATS_AVRO_FILENAME "RadioInterfacesStatistics.avsc" +#else +#define NEIGHBORHOOD_SCAN_AVRO_FILENAME "/usr/ccsp/harvester/GatewayAccessPointNeighborScanReport.avsc" +#define INTERFACE_DEVICES_WIFI_AVRO_FILENAME "/usr/ccsp/harvester/InterfaceDevicesWifi.avsc" +#define WIFI_SINGLE_CLIENT_AVRO_FILENAME "/usr/ccsp/wifi/WifiSingleClient.avsc" +#define RADIO_INTERFACE_STATS_AVRO_FILENAME "/usr/ccsp/harvester/RadioInterfacesStatistics.avsc" +#define WIFI_SINGLE_CLIENT_BLASTER_AVRO_FILENAME "/usr/ccsp/wifi/WifiSingleClientActiveMeasurement.avsc" +#endif +#define CHK_AVRO_ERR (strlen(avro_strerror()) > 0) + #define CFG_ID_LEN 64 typedef char stats_cfg_id_t[CFG_ID_LEN]; diff --git a/source/Makefile.am b/source/Makefile.am index 6a910ba4..05c0f48c 100644 --- a/source/Makefile.am +++ b/source/Makefile.am @@ -24,7 +24,9 @@ endif SUBDIRS += test/core SUBDIRS += sampleapps +if ONEWIFI_DML_SUPPORT SUBDIRS += dml +endif if WITH_GTEST_SUPPORT SUBDIRS += test diff --git a/source/apps/blaster/wifi_blaster.c b/source/apps/blaster/wifi_blaster.c index 61e8421c..d5e950df 100644 --- a/source/apps/blaster/wifi_blaster.c +++ b/source/apps/blaster/wifi_blaster.c @@ -42,7 +42,6 @@ #include #include #include -#include "harvester.h" #include "wifi_passpoint.h" #include "safec_lib_common.h" #include diff --git a/source/apps/blaster/wifi_single_client_msmt.c b/source/apps/blaster/wifi_single_client_msmt.c index 7ace7df5..cb3eb21b 100644 --- a/source/apps/blaster/wifi_single_client_msmt.c +++ b/source/apps/blaster/wifi_single_client_msmt.c @@ -41,7 +41,6 @@ #include #endif #include -#include "harvester.h" #include "ext_blaster.pb-c.h" #include "qm_conn.h" #include "wifi_util.h" @@ -50,6 +49,7 @@ #include "wifi_blaster.h" #include "const.h" #include +#include "misc.h" #define PROTOBUF_MAC_SIZE 13 @@ -553,7 +553,7 @@ void upload_single_client_active_msmt_data(blaster_hashmap_t *sta_info) /* MAC - Get CPE mac address, do it only pointer is NULL */ if ( macStr == NULL ) { - macStr = getDeviceMac(); + macStr = get_stubs_descriptor()->getDeviceMac_fn(); if (macStr != NULL) { strncpy( CpemacStr, macStr, sizeof(CpemacStr)); wifi_util_dbg_print(WIFI_BLASTER, "%s:%d: RDK_LOG_DEBUG, Received DeviceMac from Atom side: %s\n",__func__, __LINE__, macStr); @@ -1098,7 +1098,7 @@ void upload_single_client_active_msmt_data(blaster_hashmap_t *sta_info) size += MAGIC_NUMBER_SIZE + SCHEMA_ID_LENGTH; wifi_util_dbg_print(WIFI_BLASTER, ":%s TraceParent:%s, TraceState:%s \n", __func__,blaster->active_msmt.t_header.traceParent, blaster->active_msmt.t_header.traceState); - sendWebpaMsg((char *)(serviceName), (char *)(dest), trans_id, blaster->active_msmt.t_header.traceParent, blaster->active_msmt.t_header.traceState, (char *)(contentType), buff, size);//ONE_WIFI TBD + get_misc_descriptor()->sendWebpaMsg_fn((char *)(serviceName), (char *)(dest), trans_id, blaster->active_msmt.t_header.traceParent, blaster->active_msmt.t_header.traceState, (char *)(contentType), buff, size); telemetry_buf = malloc(sizeof(char)*1024); if (telemetry_buf == NULL) { wifi_util_error_print(WIFI_BLASTER,"%s:%d telemetry_buf allocation failed\r\n", __func__, __LINE__); diff --git a/source/apps/harvester/wifi_harvester.c b/source/apps/harvester/wifi_harvester.c index b53f440c..b4501fe2 100644 --- a/source/apps/harvester/wifi_harvester.c +++ b/source/apps/harvester/wifi_harvester.c @@ -25,7 +25,6 @@ #include #include #include -#include "harvester.h" #include #include "collection.h" #include "wifi_hal.h" @@ -44,6 +43,8 @@ #include "wifi_passpoint.h" #include "safec_lib_common.h" #include +#include "wifi_stubs.h" +#include "misc.h" typedef enum { single_client_msmt_type_all, @@ -294,7 +295,7 @@ void upload_single_client_msmt_data(sta_data_t *sta_info) /* MAC - Get CPE mac address, do it only pointer is NULL */ if ( macStr == NULL ) { - macStr = getDeviceMac(); + macStr = get_stubs_descriptor()->getDeviceMac_fn(); strncpy( CpemacStr, macStr, sizeof(CpemacStr)); wifi_util_dbg_print(WIFI_HARVESTER, "%s:%d:RDK_LOG_DEBUG, Received DeviceMac from Atom side: %s\n",__func__,__LINE__,macStr); } @@ -592,7 +593,7 @@ void upload_single_client_msmt_data(sta_data_t *sta_info) avro_writer_free(writer); size += MAGIC_NUMBER_SIZE + SCHEMA_ID_LENGTH; - sendWebpaMsg((char *)(serviceName), (char *)(dest), trans_id, NULL, NULL, (char *)(contentType), buff, size);//ONE_WIFI + get_misc_descriptor()->sendWebpaMsg_fn((char *)(serviceName), (char *)(dest), trans_id, NULL, NULL, (char *)(contentType), buff, size); wifi_util_dbg_print(WIFI_HARVESTER, "Creating telemetry record successful\n"); wifi_mgr->wifi_ccsp.desc.CcspTraceInfoRdkb_fn("%s-%d Creation of Telemetry record is successful\n", __FUNCTION__, __LINE__); } diff --git a/source/apps/wifi_apps_mgr.c b/source/apps/wifi_apps_mgr.c index 748aada3..9c88255c 100644 --- a/source/apps/wifi_apps_mgr.c +++ b/source/apps/wifi_apps_mgr.c @@ -312,7 +312,10 @@ int apps_mgr_init(wifi_ctrl_t *ctrl, wifi_app_descriptor_t *descriptor, unsigned apps_mgr->ctrl = ctrl; apps_mgr->apps_map = hash_map_create(); + wifi_util_info_print(WIFI_APPS,"%s:%d Total number of apps:%d\n", __func__, __LINE__, num_apps); for (i = 0; i < num_apps; i++) { + wifi_util_info_print(WIFI_APPS,"%s:%d desc:%s rfc:%d enable:%d\n", __func__, __LINE__, + descriptor->desc, descriptor->rfc, descriptor->enable); if (descriptor->rfc == true) { app_register(apps_mgr, descriptor); } diff --git a/source/ccsp/ccsp.c b/source/ccsp/ccsp.c index 8a16bc19..7709210a 100644 --- a/source/ccsp/ccsp.c +++ b/source/ccsp/ccsp.c @@ -78,6 +78,21 @@ void CcspTraceDebugRdkb(char *format, ...) { } + +char *psm_get_value_Rdkb(char *recName, char *strValue) +{ + return NULL; +} + +int psm_set_value_Rdkb(char *recName, char *strValue) +{ + return 0; +} + +int get_partner_id_Rdkb(char *partner_id) +{ + return get_partner_id(partner_id); +} #endif void wifi_ccsp_rdkb_init(wifi_ccsp_t *ccsp) @@ -91,4 +106,7 @@ void wifi_ccsp_rdkb_init(wifi_ccsp_t *ccsp) ccsp->desc.CcspTraceNoticeRdkb_fn = CcspTraceNoticeRdkb; ccsp->desc.CcspTraceInfoRdkb_fn = CcspTraceInfoRdkb; ccsp->desc.CcspTraceDebugRdkb_fn = CcspTraceDebugRdkb; + ccsp->desc.psm_get_value_fn = psm_get_value_Rdkb; + ccsp->desc.psm_set_value_fn = psm_set_value_Rdkb; + ccsp->desc.get_partner_id_fn = get_partner_id_Rdkb; } diff --git a/source/ccsp/ccsp.h b/source/ccsp/ccsp.h index eedb160d..a0ff4b52 100644 --- a/source/ccsp/ccsp.h +++ b/source/ccsp/ccsp.h @@ -55,6 +55,9 @@ typedef void (* wifi_ccsp_trace_alert_t) (char *format, ...); typedef void (* wifi_ccsp_trace_notice_t) (char *format, ...); typedef void (* wifi_ccsp_trace_info_t) (char *format, ...); typedef void (* wifi_ccsp_trace_debug_t) (char *format, ...); +typedef char * (* psm_get_value_t) (char *recName, char *strValue); +typedef int (* psm_set_value_t) (char *recName, char *strValue); +typedef int (* get_partner_id_t) (char *partner_id); typedef struct { wifi_ccsp_init_t init_fn; @@ -66,6 +69,9 @@ typedef struct { wifi_ccsp_trace_notice_t CcspTraceNoticeRdkb_fn; wifi_ccsp_trace_info_t CcspTraceInfoRdkb_fn; wifi_ccsp_trace_debug_t CcspTraceDebugRdkb_fn; + psm_get_value_t psm_get_value_fn; + psm_set_value_t psm_set_value_fn; + get_partner_id_t get_partner_id_fn; } wifi_ccsp_desc_t; typedef struct { @@ -95,6 +101,10 @@ typedef struct { syslog_event("OneWifi", LOG_NOTICE, "%s", logmsg); \ } +char *psm_get_value_Rdkb(char *recName, char *strValue); +int psm_set_value_Rdkb(char *recName, char *strValue); +int get_partner_id_Rdkb(char *partner_id); + #ifdef __cplusplus } #endif diff --git a/source/ccsp/ccsp_api.c b/source/ccsp/ccsp_api.c index 0271ee59..9b9be9d0 100644 --- a/source/ccsp/ccsp_api.c +++ b/source/ccsp/ccsp_api.c @@ -24,8 +24,12 @@ #include "ccsp_trace.h" #include "util.h" #include "wifi_hal.h" +#include "wifi_util.h" #include +extern void* bus_handle; +extern char g_Subsystem[32]; + void init_ccsp() { /* Placeholder for time being */ @@ -126,3 +130,52 @@ void CcspTraceDebugRdkb(char *format, ...) } va_end(args); } + +char *psm_get_value_Rdkb(char *recName, char *strValue) +{ + int retry = 0; + int ret_psm_get = RETURN_ERR; + + while (retry++ < 2) { + ret_psm_get = PSM_Get_Record_Value2(bus_handle, g_Subsystem, recName, NULL, &strValue); + if (ret_psm_get == RDKB_CCSP_SUCCESS) { + wifi_util_dbg_print(WIFI_MGR,"%s:%d ret_psm_get success for %s and strValue is %s\n", __func__, + __LINE__, recName, strValue); + return strValue; + } else if (ret_psm_get == CCSP_CR_ERR_INVALID_PARAM) { + wifi_util_dbg_print(WIFI_MGR,"%s:%d PSM_Get_Record_Value2 (%s) returned error %d \n", __func__, + __LINE__, recName, ret_psm_get); + return NULL; + } else { + wifi_util_dbg_print(WIFI_MGR,"%s:%d PSM_Get_Record_Value2 param (%s) returned error %d" + " retry in 10 seconds \n", __func__, __LINE__, recName, ret_psm_get); + continue; + } + } + + return NULL; +} + +int psm_set_value_Rdkb(char *recName, char *strValue) +{ + int retPsmSet; + int ret = RETURN_ERR; + + wifi_util_dbg_print(WIFI_MGR, "%s:%d record_name:%s\n",__func__, __LINE__, recName); + + retPsmSet = PSM_Set_Record_Value2(bus_handle, g_Subsystem, recName, ccsp_rdkb_string, strValue); + if(retPsmSet == RDKB_CCSP_SUCCESS) { + wifi_util_dbg_print(WIFI_MGR, "%s:%d set bool value:%s\n",__func__, __LINE__, strValue); + ret = RETURN_OK; + } else { + wifi_util_dbg_print(WIFI_MGR, "%s:%d PSM_Set_Record_Value2 returned error %d while" + " setting bool param:%s\n",__func__, __LINE__, retPsmSet, strValue); + } + + return ret; +} + +int get_partner_id_Rdkb(char *partner_id) +{ + return ((getPartnerId(partner_id) == RDKB_CCSP_SUCCESS) ? RETURN_OK : RETURN_ERR); +} diff --git a/source/core/Makefile.am b/source/core/Makefile.am index 68dd1052..4f11e903 100644 --- a/source/core/Makefile.am +++ b/source/core/Makefile.am @@ -47,8 +47,10 @@ if WITH_LIBWEBCONFIG AM_LDFLAGS += -L$(top_builddir)/source/webconfig/ endif AM_LDFLAGS += -lwifi_webconfig +if ONEWIFI_DML_SUPPORT AM_LDFLAGS += -L$(top_builddir)/../CcspCommonLibrary/lib AM_LDFLAGS += -lccsp_common +endif AM_LDFLAGS += -lrdk_wifihal AM_CPPFLAGS = -Wall -Werror @@ -61,7 +63,15 @@ OneWifi_CPPFLAGS = -I/var/tmp/pc-rdkb/include/dbus-1.0 -I$(top_srcdir)/../CcspCo OneWifi_CPPFLAGS += -I$(top_srcdir)/source/platform/rdkb/ -I$(top_srcdir)/source/platform/common/ -OneWifi_CPPFLAGS += -I$(top_srcdir)/source/dml/rdkb/ -I$(top_srcdir)/source/dml/wifi_ssp -I$(top_srcdir)/source/dml/dml_webconfig -I$(top_srcdir)/source/dml/tr_181/ml -I$(top_srcdir)/source/dml/tr_181/sbapi -I$(top_srcdir)/include/tr_181/ml -I$(top_srcdir)/source/apps -I$(top_srcdir)/source/apps/analytics -I$(top_srcdir)/source/apps/levl -I$(top_srcdir)/source/apps/sm -I$(top_srcdir)/source/apps/csi -I$(top_srcdir)/source/apps/motion -I$(top_srcdir)/source/apps/whix -I$(top_srcdir)/source/apps/harvester -I$(top_srcdir)/source/apps/blaster -I$(top_srcdir)/source/apps/ocs -I$(top_srcdir)/source/ccsp +if ONEWIFI_DML_SUPPORT +OneWifi_CPPFLAGS += -I$(top_srcdir)/source/dml/wifi_ssp -I$(top_srcdir)/source/dml/tr_181/ml -I$(top_srcdir)/source/dml/tr_181/sbapi -I$(top_srcdir)/include/tr_181/ml +else +OneWifi_CPPFLAGS += -I$(top_srcdir)/source/platform/common/data_model/ +endif +OneWifi_CPPFLAGS += -I$(top_srcdir)/source/dml/rdkb/ +OneWifi_CPPFLAGS += -I$(top_srcdir)/source/dml/dml_webconfig + +OneWifi_CPPFLAGS += -I$(top_srcdir)/source/apps -I$(top_srcdir)/source/apps/analytics -I$(top_srcdir)/source/apps/levl -I$(top_srcdir)/source/apps/sm -I$(top_srcdir)/source/apps/csi -I$(top_srcdir)/source/apps/motion -I$(top_srcdir)/source/apps/whix -I$(top_srcdir)/source/apps/harvester -I$(top_srcdir)/source/apps/blaster -I$(top_srcdir)/source/apps/ocs -I$(top_srcdir)/source/ccsp OneWifi_CFLAGS = $(SYSTEMD_CFLAGS) OneWifi_CFLAGS += $(JOURNALCTL_ENABLE_FLAG) @@ -81,11 +91,20 @@ OneWifi_SOURCES += $(top_srcdir)/source/stats/wifi_monitor.c $(top_srcdir)/sourc OneWifi_SOURCES += $(top_srcdir)/source/stubs/wifi_stubs.c -OneWifi_SOURCES += $(top_srcdir)/source/platform/rdkb/bus.c $(top_srcdir)/source/platform/common/common.c $(top_srcdir)/source/platform/common/bus_common.c $(top_srcdir)/source/ccsp/ccsp.c $(top_srcdir)/source/ccsp/ccsp_api.c $(top_srcdir)/source/platform/rdkb/misc.c +OneWifi_SOURCES += $(top_srcdir)/source/platform/rdkb/bus.c $(top_srcdir)/source/platform/common/common.c $(top_srcdir)/source/platform/common/bus_common.c +OneWifi_SOURCES += $(top_srcdir)/source/ccsp/ccsp.c + +if ONEWIFI_DML_SUPPORT +OneWifi_SOURCES += $(top_srcdir)/source/ccsp/ccsp_api.c +endif +OneWifi_SOURCES += $(top_srcdir)/source/platform/rdkb/misc.c + +if ONEWIFI_DML_SUPPORT if EASYCONNECT_SUPPORT OneWifi_SOURCES += wifi_easy_connect.c endif +endif OneWifi_SOURCES += $(top_srcdir)/source/stats/wifi_associated_devices_msmt.c OneWifi_SOURCES += $(top_srcdir)/lib/log/log_journal.c OneWifi_SOURCES += $(top_srcdir)/source/apps/wifi_apps.c $(top_srcdir)/source/apps/wifi_apps_mgr.c $(top_srcdir)/source/apps/analytics/wifi_analytics.c $(top_srcdir)/source/apps/levl/wifi_levl.c $(top_srcdir)/source/apps/csi/wifi_csi.c $(top_srcdir)/source/apps/motion/wifi_motion.c $(top_srcdir)/source/apps/whix/wifi_whix.c $(top_srcdir)/source/apps/harvester/wifi_harvester.c $(top_srcdir)/source/apps/blaster/wifi_blaster.c $(top_srcdir)/source/apps/blaster/wifi_single_client_msmt.c $(top_srcdir)/source/apps/ocs/wifi_ocs.c @@ -98,7 +117,13 @@ OneWifi_SOURCES += $(top_srcdir)/source/apps/cac/wifi_cac.c OneWifi_CPPFLAGS += -I$(top_srcdir)/source/apps/cac/ endif +if ONEWIFI_DML_SUPPORT OneWifi_SOURCES += $(top_srcdir)/source/dml/wifi_ssp/ssp_main.c $(top_srcdir)/source/dml/wifi_ssp/ssp_loop.c $(top_srcdir)/source/dml/wifi_ssp/ssp_messagebus_interface.c $(top_srcdir)/source/dml/wifi_ssp/ssp_action.c $(top_srcdir)/source/dml/wifi_ssp/dm_pack_datamodel.c $(top_srcdir)/source/dml/tr_181/sbapi/webpa_interface.c $(top_srcdir)/source/dml/tr_181/sbapi/webpa_interface_without_seshat.c $(top_srcdir)/source/dml/tr_181/sbapi/webpa_interface_with_seshat.c $(top_srcdir)/source/dml/tr_181/sbapi/cosa_dbus_api.c +else +OneWifi_SOURCES += $(top_srcdir)/source/platform/common/data_model/wifi_data_model.c $(top_srcdir)/source/platform/common/data_model/wifi_data_model_parse.c $(top_srcdir)/source/platform/common/data_model/wifi_dml_cb.c $(top_srcdir)/source/platform/common/data_model/wifi_dml_api.c +#we need this file for new dml implementation +OneWifi_SOURCES += $(top_srcdir)/source/dml/dml_webconfig/dml_onewifi_api.c +endif OneWifi_SOURCES += $(top_srcdir)/source/dml/rdkb/wifi_dml.c @@ -106,7 +131,10 @@ OneWifi_SOURCES += $(top_srcdir)/lib/common/os_time.c $(top_srcdir)/lib/common/u OneWifi_LDFLAGS = -rdynamic -lwebconfig_framework -lsecure_wrapper $(SYSTEMD_LDFLAGS) -luuid -lsecure_wrapper -lmsgpackc -lcjson -lm -ljansson -lev -lprotobuf-c -ltrower-base64 -OneWifi_LDFLAGS += -lccsp_common -lutapi -lsyscfg -lprint_uptime -lsysevent -lrdk_wifihal -lavro +if ONEWIFI_DML_SUPPORT +OneWifi_LDFLAGS += -lccsp_common +endif +OneWifi_LDFLAGS += -lutapi -lsyscfg -lprint_uptime -lsysevent -lrdk_wifihal -lavro OneWifi_CPPFLAGS += -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/rdk-wifi-libhostap/ -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/rdk-wifi-libhostap/src/ -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/rdk-wifi-libhostap/src/ap -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/rdk-wifi-libhostap/src/utils -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/rdk-wifi-libhostap/src/drivers/ -I$(PKG_CONFIG_SYSROOT_DIR)$(includedir)/qca/qca-wifi/os/linux/include/ -I${PKG_CONFIG_SYSROOT_DIR}${libdir}/ -DEXTERNAL_USE_ONLY diff --git a/source/core/wifi_ctrl.h b/source/core/wifi_ctrl.h index f8ccb5cb..d5285f09 100644 --- a/source/core/wifi_ctrl.h +++ b/source/core/wifi_ctrl.h @@ -124,6 +124,8 @@ extern "C" { #define MESH_BACKHAUL 0b100000 #define LNF 0b1000000 +#define BUS_DML_CONFIG_FILE "bus_dml_config.json" + typedef enum { ctrl_webconfig_state_none = 0, ctrl_webconfig_state_radio_cfg_rsp_pending = 0x0001, diff --git a/source/core/wifi_easy_connect.c b/source/core/wifi_easy_connect.c index f4c073ac..0472e511 100644 --- a/source/core/wifi_easy_connect.c +++ b/source/core/wifi_easy_connect.c @@ -16,7 +16,6 @@ See the License for the specific language governing permissions and limitations under the License. **************************************************************************/ -#include "plugin_main_apis.h" #include #include #include diff --git a/source/core/wifi_mgr.h b/source/core/wifi_mgr.h index e0cd49a3..d211a811 100644 --- a/source/core/wifi_mgr.h +++ b/source/core/wifi_mgr.h @@ -60,6 +60,8 @@ typedef struct { } wifi_mgr_t; wifi_mgr_t *get_wifimgr_obj(); +wifi_dml_t *get_wifidml_obj(void); + #ifdef __cplusplus } #endif diff --git a/source/core/wifi_passpoint.c b/source/core/wifi_passpoint.c index f26a05ab..47c9454b 100644 --- a/source/core/wifi_passpoint.c +++ b/source/core/wifi_passpoint.c @@ -20,7 +20,6 @@ #include "webconfig_framework.h" #include "wifi_data_plane.h" #include "wifi_monitor.h" -#include "plugin_main_apis.h" #include #include #include @@ -50,7 +49,8 @@ wifi_GASConfiguration_t g_gas_config; wifi_vap_info_map_t g_vap_maps[2]; -#ifndef FEATURE_SUPPORT_PASSPOINT +#ifdef FEATURE_SUPPORT_PASSPOINT +#ifndef ENABLE_FEATURE_MESHWIFI static long readFileToBuffer(const char *fileName, char **buffer) { FILE *infile = NULL; @@ -108,7 +108,8 @@ static long readFileToBuffer(const char *fileName, char **buffer) } return numbytes; } -#endif +#endif //ENABLE_FEATURE_MESHWIFI +#endif //FEATURE_SUPPORT_PASSPOINT void process_passpoint_timeout() { diff --git a/source/db/wifi_db_apis.c b/source/db/wifi_db_apis.c index 2694186d..e47e1e0c 100644 --- a/source/db/wifi_db_apis.c +++ b/source/db/wifi_db_apis.c @@ -17,7 +17,6 @@ limitations under the License. **************************************************************************/ -#include "plugin_main_apis.h" #include "wifi_data_plane.h" #include "wifi_monitor.h" #include @@ -53,8 +52,6 @@ #include "wifi_util.h" #include "wifi_mgr.h" #include "wifi_dml.h" -#include "ssp_loop.h" -#include "ccsp_base_api.h" #include "wifi_monitor.h" #define MAX_BUF_SIZE 128 @@ -94,9 +91,6 @@ ovsdb_table_t table_Wifi_Postassoc_Control_Config; ovsdb_table_t table_Wifi_Connection_Control_Config; ovsdb_table_t table_Wifi_Rfc_Config; -extern void* bus_handle; -extern char g_Subsystem[32]; - static char *ApMFPConfig = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.Security.MFPConfig"; static char *CTSProtection = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.Radio.%d.CTSProtection"; static char *BeaconInterval = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.Radio.%d.BeaconInterval"; @@ -170,8 +164,8 @@ static char *Nscan = "Device.WiFi.Radio.%d.Radio_X_RDK_OffChannelNscan"; static char *Tidle = "Device.WiFi.Radio.%d.Radio_X_RDK_OffChannelTidle"; #endif //FEATURE_OFF_CHANNEL_SCAN_5G - #ifdef ONEWIFI_DB_SUPPORT + void wifidb_init_gas_config_default(wifi_GASConfiguration_t *config); /************************************************************************************ @@ -1818,8 +1812,9 @@ int wifidb_update_wifi_radio_config(int radio_index, wifi_radio_operationParam_t { wifidb_print("%s:%d Updated WIFI DB. Insert Wifi_Radio_Config table completed successful. \n",__func__, __LINE__); #ifndef NEWPLATFORM_PORT - push_data_to_ssp_queue(config, sizeof(wifi_radio_operationParam_t), ssp_event_type_psm_write, radio_config); - push_data_to_ssp_queue(feat_config, sizeof(wifi_radio_feature_param_t), ssp_event_type_psm_write, radio_feature_config); + wifidml_desc_t *p_desc = &get_wifidml_obj()->desc; + p_desc->push_data_to_ssp_queue_fn(config, sizeof(wifi_radio_operationParam_t), ssp_event_type_psm_write, radio_config); + p_desc->push_data_to_ssp_queue_fn(feat_config, sizeof(wifi_radio_feature_param_t), ssp_event_type_psm_write, radio_feature_config); #endif // NEWPLATFORM_PORT } @@ -2317,7 +2312,6 @@ extern const char* get_passpoint_json_by_vap_name(const char* vap_name); extern const char* get_anqp_json_by_vap_name(const char* vap_name); extern void reset_passpoint_json(const char* vap_name); extern void reset_anqp_json(const char* vap_name); -extern char* Get_PSM_Record_Status(char *recName, char *strValue); extern int get_wifi_last_reboot_reason_psm_value(char *last_reboot_reason); void wifidb_reset_macfilter_hashmap() @@ -2571,7 +2565,8 @@ int wifidb_update_wifi_vap_info(char *vap_name, wifi_vap_info_t *config, { wifidb_print("%s:%d Updated WIFI DB. table_Wifi_VAP_Config table updated successful\n",__func__, __LINE__); #ifndef NEWPLATFORM_PORT - push_data_to_ssp_queue(config, sizeof(wifi_vap_info_t), ssp_event_type_psm_write, vap_config); + wifidml_desc_t *p_desc = &get_wifidml_obj()->desc; + p_desc->push_data_to_ssp_queue_fn(config, sizeof(wifi_vap_info_t), ssp_event_type_psm_write, vap_config); #endif // NEWPLATFORM_PORT } return RETURN_OK; @@ -2945,7 +2940,8 @@ int wifidb_update_wifi_global_config(wifi_global_param_t *config) cfg.txrx_rate_list[sizeof(cfg.txrx_rate_list)-1] = '\0'; #ifndef NEWPLATFORM_PORT - push_data_to_ssp_queue(config, sizeof(wifi_global_param_t), ssp_event_type_psm_write, global_config); + wifidml_desc_t *p_desc = &get_wifidml_obj()->desc; + p_desc->push_data_to_ssp_queue_fn(config, sizeof(wifi_global_param_t), ssp_event_type_psm_write, global_config); #endif // NEWPLATFORM_PORT wifi_util_dbg_print(WIFI_DB,"\n %s:%d notify_wifi_changes %d prefer_private %d prefer_private_configure %d factory_reset %d tx_overflow_selfheal %d inst_wifi_client_enabled %d inst_wifi_client_reporting_period %d inst_wifi_client_mac = %s inst_wifi_client_def_reporting_period %d wifi_active_msmt_enabled %d wifi_active_msmt_pktsize %d wifi_active_msmt_num_samples %d wifi_active_msmt_sample_duration %d vlan_cfg_version %d wps_pin = %s bandsteering_enable %d good_rssi_threshold %d assoc_count_threshold %d assoc_gate_time %d assoc_monitor_duration %d rapid_reconnect_enable %d vap_stats_feature %d mfp_config_feature %d force_disable_radio_feature %d force_disable_radio_status %d fixed_wmm_params %d wifi_region_code %s diagnostic_enable %d validate_ssid %d device_network_mode:%d normalized_rssi_list %s snr_list %s cli_stat_list %s txrx_rate_list %s\r\n", __func__, __LINE__, config->notify_wifi_changes,config->prefer_private,config->prefer_private_configure,config->factory_reset,config->tx_overflow_selfheal,config->inst_wifi_client_enabled,config->inst_wifi_client_reporting_period,config->inst_wifi_client_mac, config->inst_wifi_client_def_reporting_period,config->wifi_active_msmt_enabled,config->wifi_active_msmt_pktsize,config->wifi_active_msmt_num_samples,config->wifi_active_msmt_sample_duration,config->vlan_cfg_version,config->wps_pin, config->bandsteering_enable,config->good_rssi_threshold,config->assoc_count_threshold,config->assoc_gate_time,config->assoc_monitor_duration,config->rapid_reconnect_enable,config->vap_stats_feature,config->mfp_config_feature,config->force_disable_radio_feature,config->force_disable_radio_status,config->fixed_wmm_params,config->wifi_region_code,config->diagnostic_enable,config->validate_ssid, config->device_network_mode,config->normalized_rssi_list,config->snr_list,config->cli_stat_list,config->txrx_rate_list); @@ -3987,7 +3983,7 @@ void get_wifi_country_code_from_bootstrap_json(char *country_code, int len) free(data); return; } else { - if (RDKB_CCSP_SUCCESS == getPartnerId(PartnerID)) { + if (RETURN_OK == get_wificcsp_obj()->desc.get_partner_id_fn(PartnerID)) { if (PartnerID[0] != '\0') { wifi_util_dbg_print(WIFI_DB,"%s:%d: Partner = %s \n",__func__, __LINE__, PartnerID); cJSON *partnerObj = cJSON_GetObjectItem(json, PartnerID); @@ -4023,6 +4019,7 @@ void get_wifi_country_code_from_bootstrap_json(char *country_code, int len) data=NULL; return; } + return; } @@ -4230,6 +4227,7 @@ static void wifidb_global_config_upgrade() char *str = NULL; char strValue[256] = {0}; wifi_mgr_t *g_wifidb = get_wifimgr_obj(); + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; if (g_wifidb->db_version == 0) { return; @@ -4238,9 +4236,9 @@ static void wifidb_global_config_upgrade() wifi_util_dbg_print(WIFI_DB, "%s:%d upgrade global config, old db version %d \n", __func__, __LINE__, g_wifidb->db_version); memset(strValue, 0, sizeof(strValue)); - str = (char *) Get_PSM_Record_Status(WhixLoginterval, strValue); + str = (char *) p_ccsp_desc->psm_get_value_fn(WhixLoginterval, strValue); if (str != NULL) { - g_wifidb->global_config.global_parameters.whix_log_interval = _ansc_atoi(str); + g_wifidb->global_config.global_parameters.whix_log_interval = atoi(str); wifi_util_dbg_print(WIFI_DB,"whix_log_interval is %d and str is %s \n", g_wifidb->global_config.global_parameters.whix_log_interval, str); } else { wifi_util_error_print(WIFI_DB,":%s:%d str value for whix_log_interval is null \r\n", __func__, __LINE__); @@ -4251,9 +4249,9 @@ static void wifidb_global_config_upgrade() wifi_util_dbg_print(WIFI_DB, "%s:%d upgrade global config, old db version %d \n", __func__, __LINE__, g_wifidb->db_version); memset(strValue, 0, sizeof(strValue)); - str = (char *) Get_PSM_Record_Status(WhixChUtilityLoginterval, strValue); + str = (char *) p_ccsp_desc->psm_get_value_fn(WhixChUtilityLoginterval, strValue); if (str != NULL) { - g_wifidb->global_config.global_parameters.whix_chutility_loginterval = _ansc_atoi(str); + g_wifidb->global_config.global_parameters.whix_chutility_loginterval = atoi(str); wifi_util_dbg_print(WIFI_DB,"%s:%d whix_chutility_loginterval is %d and str is %s \n", __func__, __LINE__, g_wifidb->global_config.global_parameters.whix_chutility_loginterval, str); } else { wifi_util_error_print(WIFI_DB,":%s:%d str value for whix_chutility_loginterval is null \r\n", __func__, __LINE__); @@ -5779,9 +5777,10 @@ int wifidb_update_wifi_security_config(char *vap_name, wifi_vap_security_t *sec) { wifidb_print("%s:%d Updated WIFI DB. Wifi Security Config table updated successful. \n",__func__, __LINE__); #ifndef NEWPLATFORM_PORT + wifidml_desc_t *p_desc = &get_wifidml_obj()->desc; psm_security_cfg.vap_index = convert_vap_name_to_index(&((wifi_mgr_t*) get_wifimgr_obj())->hal_cap.wifi_prop, vap_name); strncpy(psm_security_cfg.mfp, cfg_sec.mfp_config, sizeof(psm_security_cfg.mfp)-1); - push_data_to_ssp_queue(&psm_security_cfg, sizeof(wifi_security_psm_param_t), ssp_event_type_psm_write, security_config); + p_desc->push_data_to_ssp_queue_fn(&psm_security_cfg, sizeof(wifi_security_psm_param_t), ssp_event_type_psm_write, security_config); #endif // NEWPLATFORM_PORT } return RETURN_OK; @@ -5828,7 +5827,8 @@ int wifidb_update_wifi_macfilter_config(char *macfilter_key, acl_entry_t *config strncpy(l_mac_entry.device_name, config->device_name, sizeof(l_mac_entry.device_name)-1); strncpy(l_mac_entry.mac, tmp_mac_str, sizeof(l_mac_entry.mac)-1); #ifndef NEWPLATFORM_PORT - push_data_to_ssp_queue(&l_mac_entry, sizeof(l_mac_entry), ssp_event_type_psm_write, mac_config_delete); + wifidml_desc_t *p_desc = &get_wifidml_obj()->desc; + p_desc->push_data_to_ssp_queue_fn(&l_mac_entry, sizeof(l_mac_entry), ssp_event_type_psm_write, mac_config_delete); #endif // NEWPLATFORM_PORT if (ret != 1) { @@ -5871,7 +5871,8 @@ int wifidb_update_wifi_macfilter_config(char *macfilter_key, acl_entry_t *config strncpy(l_mac_entry.device_name, cfg_mac.device_name, sizeof(l_mac_entry.device_name)-1); strncpy(l_mac_entry.mac, cfg_mac.device_mac, sizeof(l_mac_entry.mac)-1); #ifndef NEWPLATFORM_PORT - push_data_to_ssp_queue(&l_mac_entry, sizeof(l_mac_entry), ssp_event_type_psm_write, mac_config_add); + wifidml_desc_t *p_desc = &get_wifidml_obj()->desc; + p_desc->push_data_to_ssp_queue_fn(&l_mac_entry, sizeof(l_mac_entry), ssp_event_type_psm_write, mac_config_add); #endif // NEWPLATFORM_PORT if (onewifi_ovsdb_table_upsert_with_parent(g_wifidb->wifidb_sock_path, &table_Wifi_MacFilter_Config, &cfg_mac, false, filter_mac, SCHEMA_TABLE(Wifi_VAP_Config), onewifi_ovsdb_where_simple(SCHEMA_COLUMN(Wifi_VAP_Config,vap_name), vap_name), SCHEMA_COLUMN(Wifi_VAP_Config, mac_filter)) == false) { wifidb_print("%s:%d WIFI DB update error !!!. Failed to update Wifi_MacFilter Config table \n",__func__, __LINE__); @@ -7273,38 +7274,18 @@ void init_wifidb(void) start_wifidb_monitor(); } - -char* Get_PSM_Record_Status(char *recName, char *strValue) -{ - int retry = 0; - int retPsmGet = RETURN_ERR; - while(retry++ < 2) { - retPsmGet = PSM_Get_Record_Value2(bus_handle, g_Subsystem, recName, NULL, &strValue); - if (retPsmGet == RDKB_CCSP_SUCCESS) { - wifi_util_dbg_print(WIFI_MGR,"%s:%d retPsmGet success for %s and strValue is %s\n", __FUNCTION__,__LINE__, recName, strValue); - return strValue; - } else if (retPsmGet == CCSP_CR_ERR_INVALID_PARAM) { - wifi_util_dbg_print(WIFI_MGR,"%s:%d PSM_Get_Record_Value2 (%s) returned error %d \n",__FUNCTION__,__LINE__,recName,retPsmGet); - return NULL; - } else { - wifi_util_dbg_print(WIFI_MGR,"%s:%d PSM_Get_Record_Value2 param (%s) returned error %d retry in 10 seconds \n",__FUNCTION__,__LINE__,recName,retPsmGet); - continue; - } - } - return NULL; -} - int wifi_db_update_global_config(wifi_global_param_t *global_cfg) { char *str = NULL; char strValue[256] = {0}; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; memset(global_cfg, 0, sizeof(wifi_global_param_t)); get_wifidb_obj()->desc.init_global_config_default_fn(global_cfg); memset(strValue, 0, sizeof(strValue)); #ifndef NEWPLATFORM_PORT - str = Get_PSM_Record_Status(WiFivAPStatsFeatureEnable, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFivAPStatsFeatureEnable, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, &global_cfg->vap_stats_feature); wifi_util_dbg_print(WIFI_MGR,"global_cfg->vap_stats_feature; is %d and str is %s\n", global_cfg->vap_stats_feature, str); @@ -7313,25 +7294,25 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WifiVlanCfgVersion, strValue); + str = p_ccsp_desc->psm_get_value_fn(WifiVlanCfgVersion, strValue); if (str != NULL) { - global_cfg->vlan_cfg_version = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->vlan_cfg_version is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->vlan_cfg_version, str, _ansc_atoi(str)); + global_cfg->vlan_cfg_version = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->vlan_cfg_version is %d and str is %s and atoi(str) is %d\n", global_cfg->vlan_cfg_version, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for vlan_cfg_version:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(PreferPrivate, strValue); + str = p_ccsp_desc->psm_get_value_fn(PreferPrivate, strValue); if (str != NULL) { - global_cfg->prefer_private = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->prefer_private is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->prefer_private, str, _ansc_atoi(str)); + global_cfg->prefer_private = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->prefer_private is %d and str is %s and atoi(str) is %d\n", global_cfg->prefer_private, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for prefer_private:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(NotifyWiFiChanges, strValue); + str = p_ccsp_desc->psm_get_value_fn(NotifyWiFiChanges, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, &global_cfg->notify_wifi_changes); wifi_util_dbg_print(WIFI_MGR,"global_cfg->notify_wifi_changes is %d and str is %s\n", global_cfg->notify_wifi_changes, str); @@ -7340,70 +7321,70 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(DiagnosticEnable, strValue); + str = p_ccsp_desc->psm_get_value_fn(DiagnosticEnable, strValue); if (str != NULL) { - global_cfg->diagnostic_enable = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->diagnostic_enable is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->diagnostic_enable, str, _ansc_atoi(str)); + global_cfg->diagnostic_enable = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->diagnostic_enable is %d and str is %s and atoi(str) is %d\n", global_cfg->diagnostic_enable, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for diagnostic_enable:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(GoodRssiThreshold, strValue); + str = p_ccsp_desc->psm_get_value_fn(GoodRssiThreshold, strValue); if (str != NULL) { - global_cfg->good_rssi_threshold = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->good_rssi_threshold is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->good_rssi_threshold, str, _ansc_atoi(str)); + global_cfg->good_rssi_threshold = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->good_rssi_threshold is %d and str is %s and atoi(str) is %d\n", global_cfg->good_rssi_threshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for good_rssi_threshold:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(AssocCountThreshold, strValue); + str = p_ccsp_desc->psm_get_value_fn(AssocCountThreshold, strValue); if (str != NULL) { - global_cfg->assoc_count_threshold = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->assoc_count_threshold is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->assoc_count_threshold, str, _ansc_atoi(str)); + global_cfg->assoc_count_threshold = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->assoc_count_threshold is %d and str is %s and atoi(str) is %d\n", global_cfg->assoc_count_threshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for assoc_count_threshold:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(AssocMonitorDuration, strValue); + str = p_ccsp_desc->psm_get_value_fn(AssocMonitorDuration, strValue); if (str != NULL) { - global_cfg->assoc_monitor_duration = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->assoc_monitor_duration is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->assoc_monitor_duration, str, _ansc_atoi(str)); + global_cfg->assoc_monitor_duration = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->assoc_monitor_duration is %d and str is %s and atoi(str) is %d\n", global_cfg->assoc_monitor_duration, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for assoc_monitor_duration:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(AssocGateTime, strValue); + str = p_ccsp_desc->psm_get_value_fn(AssocGateTime, strValue); if (str != NULL) { - global_cfg->assoc_gate_time = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->assoc_gate_time is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->assoc_gate_time, str, _ansc_atoi(str)); + global_cfg->assoc_gate_time = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->assoc_gate_time is %d and str is %s and atoi(str) is %d\n", global_cfg->assoc_gate_time, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for assoc_gate_time:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WhixLoginterval, strValue); + str = p_ccsp_desc->psm_get_value_fn(WhixLoginterval, strValue); if (str != NULL) { - global_cfg->whix_log_interval = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->whix_log_interval is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->whix_log_interval, str, _ansc_atoi(str)); + global_cfg->whix_log_interval = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->whix_log_interval is %d and str is %s and atoi(str) is %d\n", global_cfg->whix_log_interval, str, atoi(str)); } else { wifi_util_error_print(WIFI_MGR,":%s:%d str value for whix_log_interval is null \n", __func__, __LINE__); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WhixChUtilityLoginterval, strValue); + str = p_ccsp_desc->psm_get_value_fn(WhixChUtilityLoginterval, strValue); if (str != NULL) { - global_cfg->whix_chutility_loginterval = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"%s:%d global_cfg->whix_chutility_log_interval is %d and str is %s and _ansc_atoi(str) is %d\n", __func__, __LINE__, global_cfg->whix_chutility_loginterval, str, _ansc_atoi(str)); + global_cfg->whix_chutility_loginterval = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"%s:%d global_cfg->whix_chutility_log_interval is %d and str is %s and atoi(str) is %d\n", __func__, __LINE__, global_cfg->whix_chutility_loginterval, str, atoi(str)); } else { wifi_util_error_print(WIFI_MGR,":%s:%d str value for whix_chutility_loginterval is null \n", __func__, __LINE__); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(RapidReconnectIndicationEnable, strValue); + str = p_ccsp_desc->psm_get_value_fn(RapidReconnectIndicationEnable, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, &global_cfg->rapid_reconnect_enable); wifi_util_dbg_print(WIFI_MGR,"global_cfg->rapid_reconnect_enable is %d and str is %s\n", global_cfg->rapid_reconnect_enable, str); @@ -7412,16 +7393,16 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(FeatureMFPConfig, strValue); + str = p_ccsp_desc->psm_get_value_fn(FeatureMFPConfig, strValue); if (str != NULL) { - global_cfg->mfp_config_feature = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->mfp_config_feature is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->mfp_config_feature, str, _ansc_atoi(str)); + global_cfg->mfp_config_feature = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->mfp_config_feature is %d and str is %s and atoi(str) is %d\n", global_cfg->mfp_config_feature, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for mfp_config_feature:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiTxOverflowSelfheal, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiTxOverflowSelfheal, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, &global_cfg->tx_overflow_selfheal); wifi_util_dbg_print(WIFI_MGR,"global_cfg->tx_overflow_selfheal is %d and str is %s\n", global_cfg->tx_overflow_selfheal, str); @@ -7430,7 +7411,7 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiForceDisableWiFiRadio, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiForceDisableWiFiRadio, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, &global_cfg->force_disable_radio_feature); wifi_util_dbg_print(WIFI_MGR,"global_cfg->force_disable_radio_feature is %d and str is %s\n", global_cfg->force_disable_radio_feature, str); @@ -7439,35 +7420,35 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiForceDisableRadioStatus, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiForceDisableRadioStatus, strValue); if (str != NULL) { - global_cfg->force_disable_radio_status = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->force_disable_radio_status is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->force_disable_radio_status, str, _ansc_atoi(str)); + global_cfg->force_disable_radio_status = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->force_disable_radio_status is %d and str is %s and atoi(str) is %d\n", global_cfg->force_disable_radio_status, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for force_disable_radio_status:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(ValidateSSIDName, strValue); + str = p_ccsp_desc->psm_get_value_fn(ValidateSSIDName, strValue); if (str != NULL) { - global_cfg->validate_ssid = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->validate_ssid is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->validate_ssid, str, _ansc_atoi(str)); + global_cfg->validate_ssid = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->validate_ssid is %d and str is %s and atoi(str) is %d\n", global_cfg->validate_ssid, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for validate_ssid:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(FixedWmmParams, strValue); + str = p_ccsp_desc->psm_get_value_fn(FixedWmmParams, strValue); if (str != NULL) { - global_cfg->fixed_wmm_params = _ansc_atoi(strValue); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->fixed_wmm_params is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->fixed_wmm_params, str, _ansc_atoi(str)); + global_cfg->fixed_wmm_params = atoi(strValue); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->fixed_wmm_params is %d and str is %s and atoi(str) is %d\n", global_cfg->fixed_wmm_params, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for fixed_wmm_params:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); #endif // NEWPLATFORM_PORT - str = Get_PSM_Record_Status(TR181_WIFIREGION_Code, strValue); + str = p_ccsp_desc->psm_get_value_fn(TR181_WIFIREGION_Code, strValue); if (str != NULL) { strcpy(global_cfg->wifi_region_code, str); wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_region_code is %s and str is %s \n", global_cfg->wifi_region_code, str); @@ -7477,62 +7458,62 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) #ifndef NEWPLATFORM_PORT memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WpsPin, strValue); + str = p_ccsp_desc->psm_get_value_fn(WpsPin, strValue); if (str != NULL) { - //global_cfg->wps_pin = _ansc_atoi(str); + //global_cfg->wps_pin = atoi(str); strcpy(global_cfg->wps_pin, str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->wps_pin is %s and str is %s and _ansc_atoi(str) is %d\n", global_cfg->wps_pin, str, _ansc_atoi(str)); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->wps_pin is %s and str is %s and atoi(str) is %d\n", global_cfg->wps_pin, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for wps_pin:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(PreferPrivateConfigure, strValue); + str = p_ccsp_desc->psm_get_value_fn(PreferPrivateConfigure, strValue); if (str != NULL) { - global_cfg->prefer_private_configure = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->prefer_private_configure is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->prefer_private_configure, str, _ansc_atoi(str)); + global_cfg->prefer_private_configure = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->prefer_private_configure is %d and str is %s and atoi(str) is %d\n", global_cfg->prefer_private_configure, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for prefer_private_configure:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(FactoryReset, strValue); + str = p_ccsp_desc->psm_get_value_fn(FactoryReset, strValue); if (str != NULL) { - global_cfg->factory_reset = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->factory_reset is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->factory_reset, str, _ansc_atoi(str)); + global_cfg->factory_reset = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->factory_reset is %d and str is %s and atoi(str) is %d\n", global_cfg->factory_reset, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for factory_reset:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(BandSteer_Enable, strValue); + str = p_ccsp_desc->psm_get_value_fn(BandSteer_Enable, strValue); if (str != NULL) { - global_cfg->bandsteering_enable = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->bandsteering_enable is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->bandsteering_enable, str, _ansc_atoi(str)); + global_cfg->bandsteering_enable = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->bandsteering_enable is %d and str is %s and atoi(str) is %d\n", global_cfg->bandsteering_enable, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for bandsteering_enable:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(InstWifiClientEnabled, strValue); + str = p_ccsp_desc->psm_get_value_fn(InstWifiClientEnabled, strValue); if (str != NULL) { - global_cfg->inst_wifi_client_enabled = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->inst_wifi_client_enabled is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->inst_wifi_client_enabled, str, _ansc_atoi(str)); + global_cfg->inst_wifi_client_enabled = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->inst_wifi_client_enabled is %d and str is %s and atoi(str) is %d\n", global_cfg->inst_wifi_client_enabled, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for inst_wifi_client_enabled:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(InstWifiClientReportingPeriod, strValue); + str = p_ccsp_desc->psm_get_value_fn(InstWifiClientReportingPeriod, strValue); if (str != NULL) { - global_cfg->inst_wifi_client_reporting_period = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->inst_wifi_client_reporting_period is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->inst_wifi_client_reporting_period, str, _ansc_atoi(str)); + global_cfg->inst_wifi_client_reporting_period = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->inst_wifi_client_reporting_period is %d and str is %s and atoi(str) is %d\n", global_cfg->inst_wifi_client_reporting_period, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for inst_wifi_client_reporting_period:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(InstWifiClientMacAddress, strValue); + str = p_ccsp_desc->psm_get_value_fn(InstWifiClientMacAddress, strValue); if (str != NULL) { str_to_mac_bytes(str, global_cfg->inst_wifi_client_mac); //strncpy(global_cfg->inst_wifi_client_mac,str,sizeof(global_cfg->inst_wifi_client_mac)-1); @@ -7542,16 +7523,16 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(InstWifiClientDefReportingPeriod, strValue); + str = p_ccsp_desc->psm_get_value_fn(InstWifiClientDefReportingPeriod, strValue); if (str != NULL) { - global_cfg->inst_wifi_client_def_reporting_period = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->inst_wifi_client_def_reporting_period is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->inst_wifi_client_def_reporting_period, str, _ansc_atoi(str)); + global_cfg->inst_wifi_client_def_reporting_period = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->inst_wifi_client_def_reporting_period is %d and str is %s and atoi(str) is %d\n", global_cfg->inst_wifi_client_def_reporting_period, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for inst_wifi_client_def_reporting_period:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiActiveMsmtEnabled, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiActiveMsmtEnabled, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, &global_cfg->wifi_active_msmt_enabled); wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_enabled is %d and str is %s\r\n", global_cfg->wifi_active_msmt_enabled, str); @@ -7560,28 +7541,28 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiActiveMsmtPktSize, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiActiveMsmtPktSize, strValue); if (str != NULL) { - global_cfg->wifi_active_msmt_pktsize = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_pktsize is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->wifi_active_msmt_pktsize, str, _ansc_atoi(str)); + global_cfg->wifi_active_msmt_pktsize = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_pktsize is %d and str is %s and atoi(str) is %d\n", global_cfg->wifi_active_msmt_pktsize, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for wifi_active_msmt_pktsize:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiActiveMsmtNumberOfSample, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiActiveMsmtNumberOfSample, strValue); if (str != NULL) { - global_cfg->wifi_active_msmt_num_samples = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_num_samples is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->wifi_active_msmt_num_samples, str, _ansc_atoi(str)); + global_cfg->wifi_active_msmt_num_samples = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_num_samples is %d and str is %s and atoi(str) is %d\n", global_cfg->wifi_active_msmt_num_samples, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for wifi_active_msmt_num_samples:%s \r\n", __func__, __LINE__, str); } memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WiFiActiveMsmtSampleDuration, strValue); + str = p_ccsp_desc->psm_get_value_fn(WiFiActiveMsmtSampleDuration, strValue); if (str != NULL) { - global_cfg->wifi_active_msmt_sample_duration = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_sample_duration is %d and str is %s and _ansc_atoi(str) is %d\n", global_cfg->wifi_active_msmt_sample_duration, str, _ansc_atoi(str)); + global_cfg->wifi_active_msmt_sample_duration = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"global_cfg->wifi_active_msmt_sample_duration is %d and str is %s and atoi(str) is %d\n", global_cfg->wifi_active_msmt_sample_duration, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,":%s:%d str value for wifi_active_msmt_sample_duration:%s \r\n", __func__, __LINE__, str); } @@ -7600,17 +7581,17 @@ int wifi_db_update_global_config(wifi_global_param_t *global_cfg) int get_total_mac_list_from_psm(int instance_number, unsigned int *total_entries, char *mac_list) { int l_total_entries = 0; - int retPsmGet = RDKB_CCSP_SUCCESS; char recName[256] = {0}; char strValue[256] = {0}; char *l_strValue = NULL; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; memset(recName, '\0', sizeof(recName)); snprintf(recName, sizeof(recName), MacFilterList, instance_number); memset(strValue, 0, sizeof(strValue)); wifi_util_dbg_print(WIFI_MGR, "%s:%d recName: %s instance_number:%d\n",__func__, __LINE__, recName, instance_number); - retPsmGet = PSM_Get_Record_Value2(bus_handle, g_Subsystem, recName, NULL, &l_strValue); - if((retPsmGet == RDKB_CCSP_SUCCESS) && (strlen(l_strValue) > 0) ) + l_strValue = p_ccsp_desc->psm_get_value_fn(recName, l_strValue); + if ((l_strValue != NULL) && (strlen(l_strValue) > 0)) { wifi_util_dbg_print(WIFI_MGR, "%s:%d mac list data:%s\n",__func__, __LINE__, l_strValue); strncpy(strValue, l_strValue, (strlen(l_strValue) + 1)); @@ -7623,7 +7604,7 @@ int get_total_mac_list_from_psm(int instance_number, unsigned int *total_entries return RETURN_OK; } } else { - wifi_util_dbg_print(WIFI_MGR, "%s:%d PSM maclist get failure:%d mac list data:%s\n",__func__, __LINE__, retPsmGet, l_strValue); + wifi_util_dbg_print(WIFI_MGR, "%s:%d PSM maclist get failure mac list data:%s\n",__func__, __LINE__, l_strValue); } return RETURN_ERR; @@ -7635,6 +7616,7 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar char recName[256] = {0}; char strValue[256] = {0}; unsigned int instance_number = radio_index + 1; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; memset(radio_cfg, 0, sizeof(wifi_radio_operationParam_t)); memset(radio_feat_cfg, 0, sizeof(wifi_radio_feature_param_t)); @@ -7647,10 +7629,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), Tscan, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_feat_cfg->OffChanTscanInMsec = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_feat_cfg->OffChanTscanInMsec is %d and str is %s and _ansc_atoi(str) is %d\n", radio_feat_cfg->OffChanTscanInMsec, str, _ansc_atoi(str)); + radio_feat_cfg->OffChanTscanInMsec = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_feat_cfg->OffChanTscanInMsec is %d and str is %s and atoi(str) is %d\n", radio_feat_cfg->OffChanTscanInMsec, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for Tscan:%s \r\n", __func__, __LINE__, str); } @@ -7658,10 +7640,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), Nscan, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_feat_cfg->OffChanNscanInSec = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_feat_cfg->OffChanNscanInSec is %d and str is %s and _ansc_atoi(str) is %d\n", radio_feat_cfg->OffChanNscanInSec, str, _ansc_atoi(str)); + radio_feat_cfg->OffChanNscanInSec = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_feat_cfg->OffChanNscanInSec is %d and str is %s and atoi(str) is %d\n", radio_feat_cfg->OffChanNscanInSec, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for Nscan:%s \r\n", __func__, __LINE__, str); } @@ -7669,10 +7651,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), Tidle, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_feat_cfg->OffChanTidleInSec = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_feat_cfg->OffChanTidleInSec is %d and str is %s and _ansc_atoi(str) is %d\n", radio_feat_cfg->OffChanTidleInSec, str, _ansc_atoi(str)); + radio_feat_cfg->OffChanTidleInSec = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_feat_cfg->OffChanTidleInSec is %d and str is %s and atoi(str) is %d\n", radio_feat_cfg->OffChanTidleInSec, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for Tidle:%s \r\n", __func__, __LINE__, str); } @@ -7682,10 +7664,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), CTSProtection, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->ctsProtection = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->ctsProtection is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->ctsProtection, str, _ansc_atoi(str)); + radio_cfg->ctsProtection = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->ctsProtection is %d and str is %s and atoi(str) is %d\n", radio_cfg->ctsProtection, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for ctsProtection:%s \r\n", __func__, __LINE__, str); } @@ -7693,10 +7675,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), BeaconInterval, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->beaconInterval = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->beaconInterval is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->beaconInterval, str, _ansc_atoi(str)); + radio_cfg->beaconInterval = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->beaconInterval is %d and str is %s and atoi(str) is %d\n", radio_cfg->beaconInterval, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for beaconInterval:%s \r\n", __func__, __LINE__, str); } @@ -7704,10 +7686,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), DTIMInterval, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->dtimPeriod = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->dtimPeriod is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->dtimPeriod, str, _ansc_atoi(str)); + radio_cfg->dtimPeriod = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->dtimPeriod is %d and str is %s and atoi(str) is %d\n", radio_cfg->dtimPeriod, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for dtimPeriod:%s \r\n", __func__, __LINE__,str); } @@ -7715,10 +7697,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), FragThreshold, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->fragmentationThreshold = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->fragmentationThreshold is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->fragmentationThreshold, str, _ansc_atoi(str)); + radio_cfg->fragmentationThreshold = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->fragmentationThreshold is %d and str is %s and atoi(str) is %d\n", radio_cfg->fragmentationThreshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for fragmentationThreshold:%s \r\n", __func__, __LINE__, str); } @@ -7726,10 +7708,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), RTSThreshold, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->rtsThreshold = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->rtsThreshold is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->rtsThreshold, str, _ansc_atoi(str)); + radio_cfg->rtsThreshold = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->rtsThreshold is %d and str is %s and atoi(str) is %d\n", radio_cfg->rtsThreshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for rtsThreshold:%s \r\n", __func__, __LINE__, str); } @@ -7737,10 +7719,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), ObssCoex, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->obssCoex = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->obssCoex is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->obssCoex, str, _ansc_atoi(str)); + radio_cfg->obssCoex = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->obssCoex is %d and str is %s and atoi(str) is %d\n", radio_cfg->obssCoex, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for obssCoex:%s \r\n", __func__, __LINE__, str); } @@ -7748,10 +7730,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), STBCEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->stbcEnable = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->stbcEnable is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->stbcEnable, str, _ansc_atoi(str)); + radio_cfg->stbcEnable = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->stbcEnable is %d and str is %s and atoi(str) is %d\n", radio_cfg->stbcEnable, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for stbcEnable:%s \r\n", __func__, __LINE__, str); } @@ -7759,10 +7741,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), GuardInterval, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->guardInterval = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->guardInterval is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->guardInterval, str, _ansc_atoi(str)); + radio_cfg->guardInterval = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->guardInterval is %d and str is %s and atoi(str) is %d\n", radio_cfg->guardInterval, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for guardInterval:%s \r\n", __func__, __LINE__, str); } @@ -7770,10 +7752,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), GreenField, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->greenFieldEnable = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->greenFieldEnable is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->greenFieldEnable, str, _ansc_atoi(str)); + radio_cfg->greenFieldEnable = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->greenFieldEnable is %d and str is %s and atoi(str) is %d\n", radio_cfg->greenFieldEnable, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for greenFieldEnable:%s \r\n", __func__, __LINE__, str); } @@ -7781,10 +7763,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), TransmitPower, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->transmitPower = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->transmitPower is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->transmitPower, str, _ansc_atoi(str)); + radio_cfg->transmitPower = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->transmitPower is %d and str is %s and atoi(str) is %d\n", radio_cfg->transmitPower, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for transmitPower:%s \r\n", __func__, __LINE__, str); } @@ -7792,10 +7774,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), UserControl, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->userControl = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->userControl is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->userControl, str, _ansc_atoi(str)); + radio_cfg->userControl = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->userControl is %d and str is %s and atoi(str) is %d\n", radio_cfg->userControl, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for userControl:%s \r\n", __func__, __LINE__, str); } @@ -7803,10 +7785,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), AdminControl, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->adminControl = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->adminControl is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->adminControl, str, _ansc_atoi(str)); + radio_cfg->adminControl = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->adminControl is %d and str is %s and atoi(str) is %d\n", radio_cfg->adminControl, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for adminControl:%s \r\n", __func__, __LINE__, str); } @@ -7814,10 +7796,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), MeasuringRateRd, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->radioStatsMeasuringRate = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->radioStatsMeasuringRate is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->radioStatsMeasuringRate, str, _ansc_atoi(str)); + radio_cfg->radioStatsMeasuringRate = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->chanUtilThreshold is %d and str is %s and ansc_atoi-str is %d\n", radio_cfg->chanUtilThreshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for radioStatsMeasuringRate:%s \r\n", __func__, __LINE__, str); } @@ -7825,10 +7807,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), MeasuringIntervalRd, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->radioStatsMeasuringInterval = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->radioStatsMeasuringInterval is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->radioStatsMeasuringInterval, str, _ansc_atoi(str)); + radio_cfg->radioStatsMeasuringInterval = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->radioStatsMeasuringInterval is %d and str is %s and atoi(str) is %d\n", radio_cfg->radioStatsMeasuringInterval, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for radioStatsMeasuringInterval:%s \r\n", __func__, __LINE__, str); } @@ -7836,10 +7818,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), SetChanUtilThreshold, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->chanUtilThreshold = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->chanUtilThreshold is %d and str is %s and ansc_atoi-str is %d\n", radio_cfg->chanUtilThreshold, str, _ansc_atoi(str)); + radio_cfg->chanUtilThreshold = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->chanUtilThreshold is %d and str is %s and ansc_atoi-str is %d\n", radio_cfg->chanUtilThreshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for chanUtilThreshold:%s \r\n", __func__, __LINE__, str); } @@ -7847,10 +7829,10 @@ void get_radio_params_from_psm(unsigned int radio_index, wifi_radio_operationPar memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), SetChanUtilSelfHealEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - radio_cfg->chanUtilSelfHealEnable = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"radio_cfg->chanUtilSelfHealEnable is %d and str is %s and _ansc_atoi(str) is %d\n", radio_cfg->chanUtilSelfHealEnable, str, _ansc_atoi(str)); + radio_cfg->chanUtilSelfHealEnable = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"radio_cfg->chanUtilSelfHealEnable is %d and str is %s and atoi(str) is %d\n", radio_cfg->chanUtilSelfHealEnable, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d: str value for chanUtilSelfHealEnable:%s \r\n", __func__, __LINE__, str); } @@ -7912,6 +7894,8 @@ void get_psm_mac_list_entry(unsigned int instance_number, char *l_vap_name, unsi unsigned int index = 0; acl_entry_t *temp_psm_mac_param; mac_addr_str_t new_mac_str; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; + memset(new_mac_str, 0, sizeof(new_mac_str)); memset(macfilterkey, 0, sizeof(macfilterkey)); @@ -7928,7 +7912,7 @@ void get_psm_mac_list_entry(unsigned int instance_number, char *l_vap_name, unsi memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), MacFilterDevice, instance_number, index); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { strcpy(temp_psm_mac_param->device_name, str); wifi_util_dbg_print(WIFI_MGR,"psm get device_name is %s\r\n", str); @@ -7939,7 +7923,7 @@ void get_psm_mac_list_entry(unsigned int instance_number, char *l_vap_name, unsi memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), MacFilter, instance_number, index); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { str_to_mac_bytes(str, temp_psm_mac_param->mac); wifi_util_dbg_print(WIFI_MGR,"psm get mac is %s\n", str); @@ -7966,6 +7950,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, char strValue[256] = {0}; unsigned int instance_number = vap_index + 1; int ret = -1; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; memset(vap_config, 0, sizeof(wifi_vap_info_t)); get_wifidb_obj()->desc.init_vap_config_default_fn((instance_number - 1), vap_config, rdk_vap_config); @@ -7977,10 +7962,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), WmmEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->wmm_enabled = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->wmm_enabled is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->wmm_enabled, str, _ansc_atoi(str)); + bss_cfg->wmm_enabled = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->wmm_enabled is %d and str is %s and atoi(str) is %d\n", bss_cfg->wmm_enabled, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for wmm_enabled:%s \r\n", __func__, __LINE__, str); } @@ -7988,10 +7973,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), UAPSDEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->UAPSDEnabled = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->UAPSDEnabled is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->UAPSDEnabled, str, _ansc_atoi(str)); + bss_cfg->UAPSDEnabled = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->UAPSDEnabled is %d and str is %s and atoi(str) is %d\n", bss_cfg->UAPSDEnabled, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for UAPSDEnabled:%s \r\n", __func__, __LINE__, str); } @@ -7999,7 +7984,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), vAPStatsEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, (bool *)&bss_cfg->vapStatsEnable); wifi_util_dbg_print(WIFI_MGR,"bss_cfg->vapStatsEnable is %d and str is %s\n", bss_cfg->vapStatsEnable, str); @@ -8010,10 +7995,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), WmmNoAck, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->wmmNoAck = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->wmmNoAck is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->wmmNoAck, str, _ansc_atoi(str)); + bss_cfg->wmmNoAck = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->wmmNoAck is %d and str is %s and atoi(str) is %d\n", bss_cfg->wmmNoAck, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for wmmNoAck:%s \r\n", __func__, __LINE__, str); } @@ -8021,15 +8006,15 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), BssMaxNumSta, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - if ((isVapPrivate(vap_config->vap_index)) && (_ansc_atoi(str) == 0)) { + if ((isVapPrivate(vap_config->vap_index)) && (atoi(str) == 0)) { bss_cfg->bssMaxSta = wifi_mgr->hal_cap.wifi_prop.BssMaxStaAllow; wifi_util_info_print(WIFI_MGR, "wrong max clients configured in psm, changing max associated clients to %d on vap:%d\n", wifi_mgr->hal_cap.wifi_prop.BssMaxStaAllow, vap_index); } else { - bss_cfg->bssMaxSta = _ansc_atoi(str); + bss_cfg->bssMaxSta = atoi(str); } - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->bssMaxSta is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->bssMaxSta, str, _ansc_atoi(str)); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->bssMaxSta is %d and str is %s and atoi(str) is %d\n", bss_cfg->bssMaxSta, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for bssMaxSta:%s \r\n", __func__, __LINE__, str); } @@ -8037,9 +8022,9 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), MacFilterMode, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - unsigned int mf_mode = _ansc_atoi(str); + unsigned int mf_mode = atoi(str); if (mf_mode == 0) { bss_cfg->mac_filter_enable = false; bss_cfg->mac_filter_mode = wifi_mac_filter_mode_black_list; @@ -8050,7 +8035,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, bss_cfg->mac_filter_enable = true; bss_cfg->mac_filter_mode = wifi_mac_filter_mode_black_list; } - wifi_util_info_print(WIFI_MGR,"bss_cfg->mac_filter_mode is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->mac_filter_mode, str, _ansc_atoi(str)); + wifi_util_info_print(WIFI_MGR,"bss_cfg->mac_filter_mode is %d and str is %s and atoi(str) is %d\n", bss_cfg->mac_filter_mode, str, atoi(str)); } else { wifi_util_error_print(WIFI_MGR,"%s:%d mac_filter_mode not found for:%s\r\n", __func__, __LINE__, recName); } @@ -8058,10 +8043,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), ApIsolationEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->isolation = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->isolation is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->isolation, str, _ansc_atoi(str)); + bss_cfg->isolation = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->isolation is %d and str is %s and atoi(str) is %d\n", bss_cfg->isolation, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for isolation:%s \r\n", __func__, __LINE__, str); } @@ -8069,7 +8054,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), BSSTransitionActivated, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, (bool *)&bss_cfg->bssTransitionActivated); wifi_util_dbg_print(WIFI_MGR,"bss_cfg->bssTransitionActivated is %d and str is %s\n", bss_cfg->bssTransitionActivated, str); @@ -8080,10 +8065,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), BssHotSpot, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->bssHotspot = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->bssHotspot is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->bssHotspot, str, _ansc_atoi(str)); + bss_cfg->bssHotspot = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->bssHotspot is %d and str is %s and atoi(str) is %d\n", bss_cfg->bssHotspot, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for bssHotspot:%s \r\n", __func__, __LINE__, str); } @@ -8091,10 +8076,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), WpsPushButton, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->wpsPushButton = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->wpsPushButton is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->wpsPushButton, str, _ansc_atoi(str)); + bss_cfg->wpsPushButton = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->wpsPushButton is %d and str is %s and atoi(str) is %d\n", bss_cfg->wpsPushButton, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for wpsPushButton:%s \r\n", __func__, __LINE__, str); } @@ -8102,10 +8087,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), RapidReconnThreshold, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->rapidReconnThreshold = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->rapidReconnThreshold is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->rapidReconnThreshold, str, _ansc_atoi(str)); + bss_cfg->rapidReconnThreshold = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->rapidReconnThreshold is %d and str is %s and atoi(str) is %d\n", bss_cfg->rapidReconnThreshold, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for rapidReconnThreshold:%s \r\n", __func__, __LINE__, str); } @@ -8113,10 +8098,10 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), RapidReconnCountEnable, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { - bss_cfg->rapidReconnectEnable = _ansc_atoi(str); - wifi_util_dbg_print(WIFI_MGR,"bss_cfg->rapidReconnectEnable is %d and str is %s and _ansc_atoi(str) is %d\n", bss_cfg->rapidReconnectEnable, str, _ansc_atoi(str)); + bss_cfg->rapidReconnectEnable = atoi(str); + wifi_util_dbg_print(WIFI_MGR,"bss_cfg->rapidReconnectEnable is %d and str is %s and atoi(str) is %d\n", bss_cfg->rapidReconnectEnable, str, atoi(str)); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d str value for rapidReconnectEnable:%s \r\n", __func__, __LINE__, str); } @@ -8124,7 +8109,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), NeighborReportActivated, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { convert_ascii_string_to_bool(str, (bool *)&bss_cfg->nbrReportActivated); wifi_util_dbg_print(WIFI_MGR,"bss_cfg->nbrReportActivated is %d and str is %s\n", bss_cfg->nbrReportActivated, str); @@ -8135,7 +8120,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), ApMFPConfig, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); int security_mfp = 0; if (str != NULL) { convert_security_mode_string_to_integer((int *)&security_mfp, str); @@ -8147,7 +8132,7 @@ int get_vap_params_from_psm(unsigned int vap_index, wifi_vap_info_t *vap_config, memset(recName, 0, sizeof(recName)); memset(strValue, 0, sizeof(strValue)); snprintf(recName, sizeof(recName), BeaconRateCtl, instance_number); - str = Get_PSM_Record_Status(recName, strValue); + str = p_ccsp_desc->psm_get_value_fn(recName, strValue); if (str != NULL) { strcpy(bss_cfg->beaconRateCtl,str); wifi_util_dbg_print(WIFI_MGR,"bss_cfg->beaconRateCtl is %s and str is %s \r\n", bss_cfg->beaconRateCtl, str); @@ -8340,11 +8325,12 @@ int get_wifi_db_psm_enable_status(bool *wifi_psm_db_enabled) { char *str = NULL; char strValue[256] = {0}; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(WIFI_PSM_DB_NAMESPACE, strValue); + str = p_ccsp_desc->psm_get_value_fn(WIFI_PSM_DB_NAMESPACE, strValue); if (str != NULL) { - *wifi_psm_db_enabled = _ansc_atoi(str); + *wifi_psm_db_enabled = atoi(str); wifi_util_dbg_print(WIFI_MGR,"str is %s and wifi_psm_db_enabled is %d\n", str, *wifi_psm_db_enabled); } else { wifi_util_dbg_print(WIFI_MGR,"%s:%d wifi_psm_db_enabled:%d\r\n", __func__, __LINE__, *wifi_psm_db_enabled); @@ -8358,9 +8344,10 @@ int get_wifi_last_reboot_reason_psm_value(char *last_reboot_reason) { char *str = NULL; char strValue[256] = {0}; + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; memset(strValue, 0, sizeof(strValue)); - str = Get_PSM_Record_Status(LAST_REBOOT_REASON_NAMESPACE, strValue); + str = p_ccsp_desc->psm_get_value_fn(LAST_REBOOT_REASON_NAMESPACE, strValue); if (str != NULL) { strcpy(last_reboot_reason, str); wifi_util_dbg_print(WIFI_MGR,"str is %s and last_reboot_reason is %s\n", str, last_reboot_reason); @@ -8372,25 +8359,6 @@ int get_wifi_last_reboot_reason_psm_value(char *last_reboot_reason) return RETURN_OK; } -int set_bool_psm_value(bool data_value, char *recName) -{ - char instanceNumStr[64] = {0}; - int retPsmSet; - - _ansc_itoa(data_value, instanceNumStr, 10); - wifi_util_dbg_print(WIFI_MGR, "%s:%d record_name:%s\n",__func__, __LINE__, recName); - - retPsmSet = PSM_Set_Record_Value2(bus_handle, g_Subsystem, recName, ccsp_string, instanceNumStr); - if(retPsmSet == RDKB_CCSP_SUCCESS) { - wifi_util_dbg_print(WIFI_MGR, "%s:%d set bool value:%d\n",__func__, __LINE__, data_value); - } else { - wifi_util_dbg_print(WIFI_MGR, "%s:%d PSM_Set_Record_Value2 returned error %d while setting bool param %d\n",__func__, __LINE__, retPsmSet, data_value); - return RETURN_ERR; - } - - return RETURN_OK; -} - int get_all_param_from_psm_and_set_into_db(void) { char inactive_firmware[64] = { 0 }; @@ -8489,7 +8457,8 @@ int get_all_param_from_psm_and_set_into_db(void) } if (wifi_psm_db_enabled == true) { - set_bool_psm_value(false, WIFI_PSM_DB_NAMESPACE); + wifi_ccsp_desc_t *p_ccsp_desc = &get_wificcsp_obj()->desc; + p_ccsp_desc->psm_set_value_fn(WIFI_PSM_DB_NAMESPACE, "false"); } if ((strncmp(last_reboot_reason, "factory-reset", strlen("factory-reset")) == 0) || (strncmp(last_reboot_reason, "WPS-Factory-Reset", strlen("WPS-Factory-Reset")) == 0) || diff --git a/source/dml/dml_webconfig/Makefile.am b/source/dml/dml_webconfig/Makefile.am index 9e01e2a6..7869a6db 100644 --- a/source/dml/dml_webconfig/Makefile.am +++ b/source/dml/dml_webconfig/Makefile.am @@ -43,7 +43,7 @@ ACLOCAL_AMFLAGS = -I m4 hardware_platform = i686-linux-gnu noinst_LTLIBRARIES = libCcspWifiAgent_dml_webconfig.la -libCcspWifiAgent_dml_webconfig_la_CPPFLAGS = -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/custom -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/include -I$(top_srcdir)/../CcspCommonLibrary/source/debug_api/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/include/linux -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/package/slap/include -I$(top_srcdir)/../hal/include -I$(top_srcdir)/../CcspCommonLibrary/source/util_api/http/include -I$(top_srcdir)/../CcspCommonLibrary/source/util_api/ansc/include -I$(top_srcdir)/source/dml/dml_webconfig -I$(top_srcdir)/source/dml/tr_181/ml -I$(top_srcdir)/source/dml/tr_181/sbapi -I$(top_srcdir)/include/tr_181/ml -I$(top_srcdir)/source/dml/wifi_ssp -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/common/MessageBusHelper/include -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/common/PoamIrepFolder -I$(top_srcdir)/include/wifi_ssp -I$(top_srcdir)/./include -I$(top_srcdir)/source/core -I$(top_srcdir)/source/stats -I$(top_srcdir)/source/db -I$(top_srcdir)/source/utils -I$(top_srcdir)/source/core/services -I$(top_srcdir)/source/apps -I$(top_srcdir)/source/apps/analytics -I$(top_srcdir)/source/apps/levl -I$(top_srcdir)/source/apps/cac -I$(top_srcdir)/source/apps/sm -I$(top_srcdir)/lib/const -I$(top_srcdir)/source/apps/motion -I$(top_srcdir)/source/apps/csi -I$(top_srcdir)/source/apps/whix -I$(top_srcdir)/source/apps/harvester -I$(top_srcdir)/source/apps/blaster -I$(top_srcdir)/source/apps/ocs -I$(top_srcdir)/source/platform/rdkb/ -I$(top_srcdir)/source/platform/common -I$(top_srcdir)/source/ccsp -I$(top_srcdir)/source/dml/rdkb/ $(CPPFLAGS) +libCcspWifiAgent_dml_webconfig_la_CPPFLAGS = -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/custom -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/include -I$(top_srcdir)/../CcspCommonLibrary/source/debug_api/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/include/linux -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/include -I$(top_srcdir)/../CcspCommonLibrary/source/cosa/package/slap/include -I$(top_srcdir)/../hal/include -I$(top_srcdir)/../CcspCommonLibrary/source/util_api/http/include -I$(top_srcdir)/../CcspCommonLibrary/source/util_api/ansc/include -I$(top_srcdir)/source/dml/dml_webconfig -I$(top_srcdir)/source/dml/tr_181/ml -I$(top_srcdir)/source/dml/tr_181/sbapi -I$(top_srcdir)/include/tr_181/ml -I$(top_srcdir)/source/dml/wifi_ssp -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/common/MessageBusHelper/include -I$(top_srcdir)/../CcspCommonLibrary/source/ccsp/components/common/PoamIrepFolder -I$(top_srcdir)/include/wifi_ssp -I$(top_srcdir)/./include -I$(top_srcdir)/source/core -I$(top_srcdir)/source/stats -I$(top_srcdir)/source/db -I$(top_srcdir)/source/utils -I$(top_srcdir)/source/core/services -I$(top_srcdir)/source/apps -I$(top_srcdir)/source/apps/analytics -I$(top_srcdir)/source/apps/levl -I$(top_srcdir)/source/apps/cac -I$(top_srcdir)/source/apps/sm -I$(top_srcdir)/lib/const -I$(top_srcdir)/source/apps/motion -I$(top_srcdir)/source/apps/csi -I$(top_srcdir)/source/apps/whix -I$(top_srcdir)/source/apps/harvester -I$(top_srcdir)/source/apps/blaster -I$(top_srcdir)/source/apps/ocs -I$(top_srcdir)/source/platform/rdkb/ -I$(top_srcdir)/source/platform/common -I$(top_srcdir)/source/ccsp -I$(top_srcdir)/source/dml/rdkb/ -I$(top_srcdir)/source/stubs $(CPPFLAGS) libCcspWifiAgent_dml_webconfig_la_SOURCES = dml_onewifi_api.c libCcspWifiAgent_dml_webconfig_la_LDFLAGS = -lccsp_common -lsecure_wrapper diff --git a/source/dml/dml_webconfig/dml_onewifi_api.c b/source/dml/dml_webconfig/dml_onewifi_api.c index ef7e9549..bf31dac3 100644 --- a/source/dml/dml_webconfig/dml_onewifi_api.c +++ b/source/dml/dml_webconfig/dml_onewifi_api.c @@ -31,7 +31,7 @@ #include "dml_onewifi_api.h" #include "wifi_util.h" #include "wifi_mgr.h" -#include "../../../stubs/wifi_stubs.h" +#include "wifi_stubs.h" webconfig_dml_t webconfig_dml; @@ -159,6 +159,18 @@ UINT get_total_num_vap_dml() return numberOfVap; } +UINT get_max_num_vaps_per_radio_dml(uint32_t radio_index) +{ + webconfig_dml_t* pwebconfig = get_webconfig_dml(); + + if (pwebconfig == NULL){ + wifi_util_error_print(WIFI_DMCLI,"%s:%d Error: value is NULL\n", __func__, __LINE__); + return MAX_NUM_VAP_PER_RADIO; + } else { + return pwebconfig->hal_cap.wifi_prop.radiocap[radio_index].maxNumberVAPs; + } +} + UINT get_max_num_vap_dml() { webconfig_dml_t* pwebconfig = get_webconfig_dml(); @@ -290,6 +302,105 @@ void mac_filter_dml_cache_update(webconfig_subdoc_data_t *data) } } +void full_assoc_list_update(webconfig_subdoc_decoded_data_t *params) +{ + int r_index = 0, v_index = 0; + assoc_dev_data_t *assoc_dev_data, *temp_assoc_dev_data; + char key[64] = {0}; + + pthread_mutex_lock(&webconfig_dml.assoc_dev_lock); + for (r_index = 0; r_index < (int)get_num_radio_dml(); r_index++) { + for (v_index = 0; v_index < MAX_NUM_VAP_PER_RADIO; v_index++) { + hash_map_t** assoc_dev_map = get_dml_assoc_dev_hash_map(r_index, v_index); + if ((assoc_dev_map != NULL) && (*assoc_dev_map != NULL)) { + assoc_dev_data = hash_map_get_first(*assoc_dev_map); + while (assoc_dev_data != NULL) { + memset(key, 0, sizeof(key)); + to_mac_str(assoc_dev_data->dev_stats.cli_MACAddress, key); + assoc_dev_data = hash_map_get_next(*assoc_dev_map, assoc_dev_data); + temp_assoc_dev_data = hash_map_remove(*assoc_dev_map, key); + if (temp_assoc_dev_data != NULL) { + free(temp_assoc_dev_data); + } + } + hash_map_destroy(*assoc_dev_map); + } + *assoc_dev_map = params->radios[r_index].vaps.rdk_vap_array[v_index].associated_devices_map; + } + } + pthread_mutex_unlock(&webconfig_dml.assoc_dev_lock); +} + +void existing_assoc_list_update(webconfig_subdoc_decoded_data_t *params) +{ + int r_index = 0, v_index = 0; + assoc_dev_data_t *assoc_dev_data, *temp_assoc_dev_data; + char key[64] = {0}; + hash_map_t *associated_devices_map = NULL; + assoc_dev_data_t *dml_temp_assoc_data; + + pthread_mutex_lock(&webconfig_dml.assoc_dev_lock); + for (r_index = 0; r_index < (int)get_num_radio_dml(); r_index++) { + for (v_index = 0; v_index < MAX_NUM_VAP_PER_RADIO; v_index++) { + associated_devices_map = params->radios[r_index].vaps.rdk_vap_array[v_index].associated_devices_diff_map; + if (associated_devices_map != NULL) { + hash_map_t** dml_assoc_dev_map = get_dml_assoc_dev_hash_map(r_index, v_index); + if (*dml_assoc_dev_map == NULL) { + *dml_assoc_dev_map = hash_map_create(); + } + + assoc_dev_data = hash_map_get_first(associated_devices_map); + while (assoc_dev_data != NULL) { + memset(key, 0, sizeof(key)); + to_mac_str(assoc_dev_data->dev_stats.cli_MACAddress, key); + assoc_dev_data = hash_map_get_next(associated_devices_map, assoc_dev_data); + temp_assoc_dev_data = hash_map_remove(associated_devices_map, key); + if (temp_assoc_dev_data == NULL) { + continue; + } + + dml_temp_assoc_data = hash_map_get(*dml_assoc_dev_map, key); + if (temp_assoc_dev_data->client_state == client_state_disconnected) { + if (dml_temp_assoc_data != NULL) { + assoc_dev_data_t *p_dml_temp_assoc = hash_map_remove(*dml_assoc_dev_map, key); + if (p_dml_temp_assoc != NULL) { + free(p_dml_temp_assoc); + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d:disconnect client not present:%s\n", __func__, __LINE__, key); + } + } else if (temp_assoc_dev_data->client_state == client_state_connected) { + if (dml_temp_assoc_data == NULL) { + hash_map_put(*dml_assoc_dev_map, strdup(key), temp_assoc_dev_data); + continue; + } else { + memcpy(dml_temp_assoc_data, temp_assoc_dev_data, sizeof(assoc_dev_data_t)); + } + } + free(temp_assoc_dev_data); + } + } + } + } + pthread_mutex_unlock(&webconfig_dml.assoc_dev_lock); +} + +void update_dml_assoc_list(webconfig_subdoc_data_t *data) +{ + webconfig_subdoc_decoded_data_t *params; + + params = &data->u.decoded; + + if (params->assoclist_notifier_type == assoclist_notifier_full) { + full_assoc_list_update(params); + } else if (params->assoclist_notifier_type == assoclist_notifier_diff) { + existing_assoc_list_update(params); + } else { + wifi_util_error_print(WIFI_DMCLI,"%s %d wrong assoclist_notifier_type:%d\r\n", __func__, + __LINE__, params->assoclist_notifier_type); + } +} + void dml_cache_update(webconfig_subdoc_data_t *data) { webconfig_subdoc_decoded_data_t *params; @@ -310,11 +421,29 @@ void dml_cache_update(webconfig_subdoc_data_t *data) memcpy((unsigned char *)&webconfig_dml.config, (unsigned char *)&data->u.decoded.config, sizeof(wifi_global_config_t)); memcpy((unsigned char *)&webconfig_dml.hal_cap,(unsigned char *)&data->u.decoded.hal_cap, sizeof(wifi_hal_capability_t)); webconfig_dml.hal_cap.wifi_prop.numRadios = data->u.decoded.num_radios; +#ifndef ONEWIFI_DML_SUPPORT + sync_dml_macfilter_table_entries(); +#endif break; case webconfig_subdoc_type_wifi_config: wifi_util_info_print(WIFI_DMCLI,"%s:%d subdoc parse and update global config:%d\n",__func__, __LINE__, data->type); memcpy((unsigned char *)&webconfig_dml.config, (unsigned char *)&data->u.decoded.config, sizeof(wifi_global_config_t)); break; + case webconfig_subdoc_type_mac_filter: + wifi_util_info_print(WIFI_DMCLI,"%s:%d subdoc parse and update macfilter entries:%d\n", __func__, + __LINE__, data->type); +#ifndef ONEWIFI_DML_SUPPORT + sync_dml_macfilter_table_entries(); +#endif + break; + case webconfig_subdoc_type_associated_clients: + wifi_util_info_print(WIFI_DMCLI,"%s:%d subdoc parse and update assoc entries\n", __func__, + __LINE__); + update_dml_assoc_list(data); +#ifndef ONEWIFI_DML_SUPPORT + sync_dml_sta_assoc_table_entries(); +#endif + break; default: update_dml_subdoc_vap_data(data); break; @@ -373,6 +502,9 @@ void bus_dmlwebconfig_register(webconfig_dml_t *consumer) false }, // DML Subdoc { WIFI_WEBCONFIG_INIT_DML_DATA, NULL, 0, 0, set_webconfig_dml_data, NULL, NULL, NULL, false }, // DML Subdoc + { + WIFI_WEBCONFIG_GET_ASSOC, NULL, 0, 0, set_webconfig_dml_data, NULL, NULL, NULL, false + } }; wifi_util_dbg_print(WIFI_DMCLI, "%s bus_open_fn open \n", __FUNCTION__); @@ -673,6 +805,11 @@ int init(webconfig_dml_t *consumer) update_dml_global_default(); update_dml_stats_default(); +#ifndef ONEWIFI_DML_SUPPORT + sync_dml_macfilter_table_entries(); + sync_dml_sta_assoc_table_entries(); +#endif + webconfig_data_free(&data); get_bus_descriptor()->bus_data_free_fn(&raw_data); @@ -696,6 +833,16 @@ wifi_vap_info_map_t* get_dml_cache_vap_map(uint8_t radio_index) return NULL; } +rdk_wifi_radio_t* get_dml_cache_radio_map_param(uint8_t radio_index) +{ + if (radio_index < get_num_radio_dml()) { + return &webconfig_dml.radios[radio_index]; + } else { + wifi_util_error_print(WIFI_DMCLI, "%s: wrong radio_index %d\n", __FUNCTION__, radio_index); + return NULL; + } +} + wifi_radio_operationParam_t* get_dml_cache_radio_map(uint8_t radio_index) { if(radio_index < get_num_radio_dml()) @@ -1464,3 +1611,146 @@ wifi_channelBandwidth_t sync_bandwidth_and_hw_variant(uint32_t variant, wifi_cha return 0; } } + +bool wifi_factory_reset(bool factory_reset_all_vaps) +{ + wifi_vap_info_t default_vap; + wifi_vap_info_t *p_vapInfo = NULL; + rdk_wifi_vap_info_t rdk_default_vap; + rdk_wifi_vap_info_t *rdk_vap_info; + acl_entry_t *temp_acl_entry, *acl_entry; + mac_addr_str_t mac_str; + wifi_global_config_t *global_wifi_config; + global_wifi_config = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + wifi_radio_operationParam_t *wifiRadioOperParam = NULL; + unsigned int vap_index; + wifi_radio_operationParam_t rcfg; + wifi_radio_feature_param_t *wifiRadioFeatParam = NULL; + wifi_radio_feature_param_t fcfg; + + wifi_util_info_print(WIFI_DMCLI,"Enter %s:%d \n",__func__, __LINE__); + if (global_wifi_config == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to get Global Config\n", __FUNCTION__,__LINE__); + return FALSE; + } + + //Reset to all radios params to default + for (UINT i= 0; i < getNumberRadios(); i++) { + wifiRadioOperParam = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(i); + wifiRadioFeatParam = (wifi_radio_feature_param_t *) get_dml_cache_radio_feat_map(i); + if (wifiRadioOperParam == NULL || wifiRadioFeatParam == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param and Radio Feat Param for instance_number:%d\n", __FUNCTION__,__LINE__,i); + return FALSE; + } + wifidb_init_radio_config_default(i,&rcfg,&fcfg); + + wifi_rfc_dml_parameters_t *rfc_param = get_wifi_db_rfc_parameters(); + if (wifidb_get_rfc_config(0,rfc_param) != 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Error getting RFC config\n",__func__, __LINE__); + } + + //Update the 2.4Ghz radio AX mode based on the RFC twoG80211axEnable_rfc + if (WIFI_FREQUENCY_2_4_BAND == rcfg.band) { + if(rfc_param->twoG80211axEnable_rfc) { + rcfg.variant = rcfg.variant | WIFI_80211_VARIANT_AX; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Updated default config with twoG80211axEnable_rfc\n",__func__, __LINE__); + } + } + + //Update DFS RFC for 5GHz radio + if( (WIFI_FREQUENCY_5_BAND == rcfg.band) || (WIFI_FREQUENCY_5L_BAND == rcfg.band) || (WIFI_FREQUENCY_5H_BAND == rcfg.band) ) { + rcfg.DfsEnabled = rfc_param->dfs_rfc; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Updated default config for DFS RFC %d\n",__func__, __LINE__, rfc_param->dfs_rfc); + } + + memcpy((unsigned char *)wifiRadioOperParam,(unsigned char *)&rcfg,sizeof(wifi_radio_operationParam_t)); + memcpy((unsigned char *)wifiRadioFeatParam, (unsigned char *)&fcfg, sizeof(wifi_radio_feature_param_t)); + is_radio_config_changed = TRUE; + } + + remove(WIFI_STUCK_DETECT_FILE_NAME); + wifi_util_info_print(WIFI_MGR,"%s:%d removed selfHeal wifi stuck file:%s\n", __FUNCTION__,__LINE__, WIFI_STUCK_DETECT_FILE_NAME); + + if (factory_reset_all_vaps) { + wifi_util_dbg_print(WIFI_DMCLI, "%s:%d remove xhs/lnf flag file:%s\n", __FUNCTION__, __LINE__, WIFI_XHS_LNF_FLAG_FILE_NAME); + (void)remove(WIFI_XHS_LNF_FLAG_FILE_NAME); + } + + for (UINT index = 0; index < getTotalNumberVAPs(); index++) { + vap_index = VAP_INDEX(((webconfig_dml_t *)get_webconfig_dml())->hal_cap, index); + + if (!factory_reset_all_vaps && !isVapPrivate(vap_index)) + continue; + + p_vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(vap_index); + rdk_vap_info = (rdk_wifi_vap_info_t *)get_dml_cache_rdk_vap_info(vap_index); + + if (p_vapInfo != NULL) { + hash_map_t** acl_dev_map = (hash_map_t **)get_acl_hash_map(p_vapInfo); + + if ((acl_dev_map != NULL) && (*acl_dev_map)) { + acl_entry =(acl_entry_t *)hash_map_get_first(*acl_dev_map); + while (acl_entry != NULL) { + to_mac_str(acl_entry->mac,mac_str); + wifi_util_dbg_print(WIFI_DMCLI,"Mac address in acl_entry %s\n",mac_str); + acl_entry = hash_map_get_next(*acl_dev_map,acl_entry); + temp_acl_entry = hash_map_remove(*acl_dev_map, mac_str); + if (temp_acl_entry != NULL) { + free(temp_acl_entry); + } + } + } + + if ((acl_dev_map != NULL) && (*acl_dev_map)) { + hash_map_destroy(*acl_dev_map); + *acl_dev_map = NULL; + } + + wifidb_init_vap_config_default(vap_index,&default_vap,&rdk_default_vap); + wifidb_init_interworking_config_default(vap_index,&default_vap.u.bss_info.interworking); + memcpy((unsigned char *)p_vapInfo,(unsigned char *)&default_vap,sizeof(wifi_vap_info_t)); +#if !defined(_WNXL11BWL_PRODUCT_REQ_) && !defined(_PP203X_PRODUCT_REQ_) + if(rdk_default_vap.exists == false) { +#if defined(_SR213_PRODUCT_REQ_) + if(vap_index != 2 && vap_index != 3) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d VAP_EXISTS_FALSE for vap_index=%d, setting to TRUE. \n",__FUNCTION__,__LINE__,vap_index); + rdk_default_vap.exists = true; + } +#else + wifi_util_error_print(WIFI_DMCLI,"%s:%d VAP_EXISTS_FALSE for vap_index=%d, setting to TRUE. \n",__FUNCTION__,__LINE__,vap_index); + rdk_default_vap.exists = true; +#endif /*_SR213_PRODUCT_REQ_*/ + } +#endif /*!defined(_WNXL11BWL_PRODUCT_REQ_) && !defined(_PP203X_PRODUCT_REQ_)*/ + rdk_vap_info->exists = rdk_default_vap.exists; + set_dml_cache_vap_config_changed(vap_index); + } + } + + if (push_radio_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Failed in setting Radios to default\n",__func__, __LINE__); + return FALSE; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d RadioSettings are set to default \n",__func__, __LINE__); + if (push_acl_list_dml_cache_to_one_wifidb(p_vapInfo) != RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d MacFilter deletion falied \n",__func__, __LINE__); + return FALSE; + } + + create_onewifi_factory_reset_flag(); + wifi_util_info_print(WIFI_MGR,"%s FactoryReset is done and preferPprivate=%d \n",__func__, global_wifi_config->global_parameters.prefer_private); + if (global_wifi_config->global_parameters.prefer_private) { + global_wifi_config->global_parameters.prefer_private = false; + push_global_config_dml_cache_to_one_wifidb(); + push_prefer_private_ctrl_queue(false); + } + + if (push_vap_dml_cache_to_one_wifidb() == RETURN_ERR) + { + wifi_util_info_print(WIFI_DMCLI,"%s:%d ApplyAccessPointSettings falied \n",__func__, __LINE__); + return FALSE; + } + wifi_util_info_print(WIFI_DMCLI,"Exit %s:%d \n",__func__, __LINE__); + return TRUE; +} diff --git a/source/dml/dml_webconfig/dml_onewifi_api.h b/source/dml/dml_webconfig/dml_onewifi_api.h index 762c6c72..d6d5e03e 100644 --- a/source/dml/dml_webconfig/dml_onewifi_api.h +++ b/source/dml/dml_webconfig/dml_onewifi_api.h @@ -27,6 +27,8 @@ extern "C" { #endif +#define WIFI_XHS_LNF_FLAG_FILE_NAME "/nvram/.bcmwifi_xhs_lnf_enabled" + typedef struct { void *acl_vap_context; queue_t* new_entry_queue[MAX_NUM_RADIOS][MAX_NUM_VAP_PER_RADIO]; @@ -109,6 +111,7 @@ typedef struct { INT ReceivedSignalLevelNumberOfEntries; }__attribute__((packed)) dml_stats_default; +int init(webconfig_dml_t *consumer); webconfig_dml_t* get_webconfig_dml(); active_msmt_t* get_dml_blaster(void); active_msmt_t *get_dml_cache_blaster(void); @@ -157,6 +160,8 @@ dml_radio_default *get_radio_default_obj(int r_index) ; dml_global_default *get_global_default_obj(); dml_stats_default *get_stats_default_obj(int r_index); wifi_channelBandwidth_t sync_bandwidth_and_hw_variant(uint32_t variant, wifi_channelBandwidth_t current_bw); +UINT get_max_num_vaps_per_radio_dml(uint32_t radio_index); +rdk_wifi_radio_t* get_dml_cache_radio_map_param(uint8_t radio_index); #ifdef __cplusplus } diff --git a/source/dml/linux/wifi_dml.c b/source/dml/linux/wifi_dml.c index fc3c7b09..73359957 100644 --- a/source/dml/linux/wifi_dml.c +++ b/source/dml/linux/wifi_dml.c @@ -34,10 +34,16 @@ void ssp_init() } +int push_data_to_ssp_queue(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type) +{ + return 0; +} + void wifi_dml_init(wifi_dml_t *dml) { dml->desc.start_dml_fn = start_dml; dml->desc.set_dml_init_status_fn = set_dml_init_status; dml->desc.ssp_init_fn = ssp_init; + dml->desc.push_data_to_ssp_queue_fn = push_data_to_ssp_queue; } diff --git a/source/dml/linux/wifi_dml.h b/source/dml/linux/wifi_dml.h index 961591e4..aca957df 100644 --- a/source/dml/linux/wifi_dml.h +++ b/source/dml/linux/wifi_dml.h @@ -20,6 +20,7 @@ #ifndef _WIFI_DML_H_ #define _WIFI_DML_H_ +#include #include "stdbool.h" #include @@ -35,11 +36,13 @@ extern "C" typedef void (* wifi_start_dml_t)(); typedef void (* wifi_set_dml_init_status_t)(bool status); typedef void (* wifi_ssp_init_t)(); +typedef int (* push_data_to_ssp_queue_t)(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type); typedef struct { wifi_start_dml_t start_dml_fn; wifi_set_dml_init_status_t set_dml_init_status_fn; wifi_ssp_init_t ssp_init_fn; + push_data_to_ssp_queue_t push_data_to_ssp_queue_fn; } wifidml_desc_t; typedef struct { diff --git a/source/dml/openwrt/wifi_dml.c b/source/dml/openwrt/wifi_dml.c index f44f6dca..6e2df853 100644 --- a/source/dml/openwrt/wifi_dml.c +++ b/source/dml/openwrt/wifi_dml.c @@ -33,6 +33,11 @@ void ssp_init() } +int push_data_to_ssp_queue(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type) +{ + return 0; +} + void wifi_dml_init() { wifi_dml_t *dml = (wifi_dml_t *) get_wifidml_obj(); @@ -40,5 +45,6 @@ void wifi_dml_init() dml.desc.start_dml_fn = start_dml; dml.desc.set_dml_init_status_fn = set_dml_init_status; dml.desc.ssp_init_fn = ssp_init; + dml.desc.push_data_to_ssp_queue_fn = push_data_to_ssp_queue; } diff --git a/source/dml/openwrt/wifi_dml.h b/source/dml/openwrt/wifi_dml.h index 13fb412a..82eafe25 100644 --- a/source/dml/openwrt/wifi_dml.h +++ b/source/dml/openwrt/wifi_dml.h @@ -32,11 +32,13 @@ extern "C" typedef void (* wifi_start_dml_t)(); typedef void (* wifi_set_dml_init_status_t)(bool status); typedef void (* wifi_ssp_init_t)(); +typedef int (* push_data_to_ssp_queue_t)(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type); typedef struct { wifi_start_dml_t start_dml_fn; wifi_set_dml_init_status_t set_dml_init_status_fn; wifi_ssp_init_t ssp_init_fn; + push_data_to_ssp_queue_t push_data_to_ssp_queue_fn; } wifidml_desc_t; typedef struct { diff --git a/source/dml/rdkb/wifi_dml.c b/source/dml/rdkb/wifi_dml.c index 2dbf1da3..27e5601b 100644 --- a/source/dml/rdkb/wifi_dml.c +++ b/source/dml/rdkb/wifi_dml.c @@ -70,4 +70,5 @@ void wifi_dml_init(wifi_dml_t *dml) dml->desc.start_dml_fn = start_dml; dml->desc.set_dml_init_status_fn = set_dml_init_status; dml->desc.ssp_init_fn = ssp_init; + dml->desc.push_data_to_ssp_queue_fn = push_data_to_ssp_queue; } diff --git a/source/dml/rdkb/wifi_dml.h b/source/dml/rdkb/wifi_dml.h index b9f7a3c7..fd3df593 100644 --- a/source/dml/rdkb/wifi_dml.h +++ b/source/dml/rdkb/wifi_dml.h @@ -20,9 +20,9 @@ #ifndef _WIFI_DML_H_ #define _WIFI_DML_H_ +#include #include #include -#include "ssp_main.h" #ifdef __cplusplus extern "C" @@ -36,16 +36,40 @@ extern "C" //extern char* Get_PSM_Record_Status(char *recName, char *strValue); //extern int get_wifi_last_reboot_reason_psm_value(char *last_reboot_reason); +typedef enum { + ssp_event_type_psm_read, + ssp_event_type_psm_write, + ssp_event_type_max +} ssp_event_type_t; + +typedef enum { + radio_config, + radio_feature_config, + vap_config, + global_config, + security_config, + mac_config_add, + mac_config_delete +} ssp_event_subtype_t; + typedef void (* wifi_start_dml_t)(); typedef void (* wifi_set_dml_init_status_t)(bool status); typedef void (* wifi_ssp_init_t)(); +typedef int (* push_data_to_ssp_queue_t)(const void *msg, unsigned int len, ssp_event_type_t type, ssp_event_subtype_t sub_type); typedef struct { wifi_start_dml_t start_dml_fn; wifi_set_dml_init_status_t set_dml_init_status_fn; wifi_ssp_init_t ssp_init_fn; + push_data_to_ssp_queue_t push_data_to_ssp_queue_fn; } wifidml_desc_t; +typedef struct { + pthread_t tid; + int argc; + char **argv; +} wifi_ssp_t; + typedef struct { wifidml_desc_t desc; wifi_ssp_t ssp; @@ -55,6 +79,8 @@ typedef struct { } dml_init_status; } wifi_dml_t; +int push_data_to_ssp_queue(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type); + #ifdef __cplusplus } #endif diff --git a/source/dml/tr_181/sbapi/cosa_wifi_apis.c b/source/dml/tr_181/sbapi/cosa_wifi_apis.c index a96ac92a..bc4227b0 100644 --- a/source/dml/tr_181/sbapi/cosa_wifi_apis.c +++ b/source/dml/tr_181/sbapi/cosa_wifi_apis.c @@ -150,8 +150,6 @@ #define MAX_NEIGHBOURS 250 #endif -static const char WIFI_XHS_LNF_FLAG_FILE_NAME[] = "/nvram/.bcmwifi_xhs_lnf_enabled"; - static char *FactoryReset = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.FactoryReset"; extern bool is_radio_config_changed; struct wifiSecEncrCosaHalMap wifiSecEncrMap[] = @@ -2084,146 +2082,3 @@ bool get_inst_override_ttl() instant_measurement_config_t *pcfg = (instant_measurement_config_t *) get_dml_harvester(); return pcfg->u_inst_client_def_override_ttl; } -bool wifi_factory_reset(bool factory_reset_all_vaps) -{ - wifi_vap_info_t default_vap; - wifi_vap_info_t *p_vapInfo = NULL; - rdk_wifi_vap_info_t rdk_default_vap; - rdk_wifi_vap_info_t *rdk_vap_info; - acl_entry_t *temp_acl_entry, *acl_entry; - mac_addr_str_t mac_str; - wifi_global_config_t *global_wifi_config; - global_wifi_config = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); - wifi_radio_operationParam_t *wifiRadioOperParam = NULL; - unsigned int vap_index; - wifi_radio_operationParam_t rcfg; - wifi_radio_feature_param_t *wifiRadioFeatParam = NULL; - wifi_radio_feature_param_t fcfg; - - wifi_util_info_print(WIFI_DMCLI,"Enter %s:%d \n",__func__, __LINE__); - if (global_wifi_config == NULL) { - wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to get Global Config\n", __FUNCTION__,__LINE__); - return FALSE; - } - - //Reset to all radios params to default - for (UINT i= 0; i < getNumberRadios(); i++) { - wifiRadioOperParam = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(i); - wifiRadioFeatParam = (wifi_radio_feature_param_t *) get_dml_cache_radio_feat_map(i); - if (wifiRadioOperParam == NULL || wifiRadioFeatParam == NULL) { - wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param and Radio Feat Param for instance_number:%d\n", __FUNCTION__,__LINE__,i); - return FALSE; - } - wifidb_init_radio_config_default(i,&rcfg,&fcfg); - - wifi_rfc_dml_parameters_t *rfc_param = get_wifi_db_rfc_parameters(); - if (wifidb_get_rfc_config(0,rfc_param) != 0) { - wifi_util_error_print(WIFI_DMCLI,"%s:%d: Error getting RFC config\n",__func__, __LINE__); - } - - //Update the 2.4Ghz radio AX mode based on the RFC twoG80211axEnable_rfc - if (WIFI_FREQUENCY_2_4_BAND == rcfg.band) { - if(rfc_param->twoG80211axEnable_rfc) { - rcfg.variant = rcfg.variant | WIFI_80211_VARIANT_AX; - wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Updated default config with twoG80211axEnable_rfc\n",__func__, __LINE__); - } - } - - //Update DFS RFC for 5GHz radio - if( (WIFI_FREQUENCY_5_BAND == rcfg.band) || (WIFI_FREQUENCY_5L_BAND == rcfg.band) || (WIFI_FREQUENCY_5H_BAND == rcfg.band) ) { - rcfg.DfsEnabled = rfc_param->dfs_rfc; - wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Updated default config for DFS RFC %d\n",__func__, __LINE__, rfc_param->dfs_rfc); - } - - memcpy((unsigned char *)wifiRadioOperParam,(unsigned char *)&rcfg,sizeof(wifi_radio_operationParam_t)); - memcpy((unsigned char *)wifiRadioFeatParam, (unsigned char *)&fcfg, sizeof(wifi_radio_feature_param_t)); - is_radio_config_changed = TRUE; - } - - remove(WIFI_STUCK_DETECT_FILE_NAME); - wifi_util_info_print(WIFI_MGR,"%s:%d removed selfHeal wifi stuck file:%s\n", __FUNCTION__,__LINE__, WIFI_STUCK_DETECT_FILE_NAME); - - if (factory_reset_all_vaps) { - wifi_util_dbg_print(WIFI_DMCLI, "%s:%d remove xhs/lnf flag file:%s\n", __FUNCTION__, __LINE__, WIFI_XHS_LNF_FLAG_FILE_NAME); - (void)remove(WIFI_XHS_LNF_FLAG_FILE_NAME); - } - - for (UINT index = 0; index < getTotalNumberVAPs(); index++) { - vap_index = VAP_INDEX(((webconfig_dml_t *)get_webconfig_dml())->hal_cap, index); - - if (!factory_reset_all_vaps && !isVapPrivate(vap_index)) - continue; - - p_vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(vap_index); - rdk_vap_info = (rdk_wifi_vap_info_t *)get_dml_cache_rdk_vap_info(vap_index); - - if (p_vapInfo != NULL) { - hash_map_t** acl_dev_map = (hash_map_t **)get_acl_hash_map(p_vapInfo); - - if ((acl_dev_map != NULL) && (*acl_dev_map)) { - acl_entry =(acl_entry_t *)hash_map_get_first(*acl_dev_map); - while (acl_entry != NULL) { - to_mac_str(acl_entry->mac,mac_str); - wifi_util_dbg_print(WIFI_DMCLI,"Mac address in acl_entry %s\n",mac_str); - acl_entry = hash_map_get_next(*acl_dev_map,acl_entry); - temp_acl_entry = hash_map_remove(*acl_dev_map, mac_str); - if (temp_acl_entry != NULL) { - free(temp_acl_entry); - } - } - } - - if ((acl_dev_map != NULL) && (*acl_dev_map)) { - hash_map_destroy(*acl_dev_map); - *acl_dev_map = NULL; - } - - wifidb_init_vap_config_default(vap_index,&default_vap,&rdk_default_vap); - wifidb_init_interworking_config_default(vap_index,&default_vap.u.bss_info.interworking); - memcpy((unsigned char *)p_vapInfo,(unsigned char *)&default_vap,sizeof(wifi_vap_info_t)); -#if !defined(_WNXL11BWL_PRODUCT_REQ_) && !defined(_PP203X_PRODUCT_REQ_) - if(rdk_default_vap.exists == false) { -#if defined(_SR213_PRODUCT_REQ_) - if(vap_index != 2 && vap_index != 3) { - wifi_util_error_print(WIFI_DMCLI,"%s:%d VAP_EXISTS_FALSE for vap_index=%d, setting to TRUE. \n",__FUNCTION__,__LINE__,vap_index); - rdk_default_vap.exists = true; - } -#else - wifi_util_error_print(WIFI_DMCLI,"%s:%d VAP_EXISTS_FALSE for vap_index=%d, setting to TRUE. \n",__FUNCTION__,__LINE__,vap_index); - rdk_default_vap.exists = true; -#endif /*_SR213_PRODUCT_REQ_*/ - } -#endif /*!defined(_WNXL11BWL_PRODUCT_REQ_) && !defined(_PP203X_PRODUCT_REQ_)*/ - rdk_vap_info->exists = rdk_default_vap.exists; - set_dml_cache_vap_config_changed(vap_index); - } - } - - if (push_radio_dml_cache_to_one_wifidb() == RETURN_ERR) { - wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Failed in setting Radios to default\n",__func__, __LINE__); - return FALSE; - } - - wifi_util_info_print(WIFI_DMCLI,"%s:%d RadioSettings are set to default \n",__func__, __LINE__); - - if (push_acl_list_dml_cache_to_one_wifidb(p_vapInfo) != RETURN_OK) { - wifi_util_info_print(WIFI_DMCLI,"%s:%d MacFilter deletion falied \n",__func__, __LINE__); - return FALSE; - } - - create_onewifi_factory_reset_flag(); - wifi_util_info_print(WIFI_MGR,"%s FactoryReset is done and preferPprivate=%d \n",__func__, global_wifi_config->global_parameters.prefer_private); - if (global_wifi_config->global_parameters.prefer_private) { - global_wifi_config->global_parameters.prefer_private = false; - push_global_config_dml_cache_to_one_wifidb(); - push_prefer_private_ctrl_queue(false); - } - - if (push_vap_dml_cache_to_one_wifidb() == RETURN_ERR) - { - wifi_util_info_print(WIFI_DMCLI,"%s:%d ApplyAccessPointSettings falied \n",__func__, __LINE__); - return FALSE; - } - wifi_util_info_print(WIFI_DMCLI,"Exit %s:%d \n",__func__, __LINE__); - return TRUE; -} diff --git a/source/dml/tr_181/sbapi/cosa_wifi_apis.h b/source/dml/tr_181/sbapi/cosa_wifi_apis.h index fdd4a17c..9738cd57 100755 --- a/source/dml/tr_181/sbapi/cosa_wifi_apis.h +++ b/source/dml/tr_181/sbapi/cosa_wifi_apis.h @@ -294,4 +294,6 @@ INT getSecurityTypeFromString(const char *securityName, wifi_security_modes_t *s void WriteWiFiLog(char *); void AssociatedDevice_callback_register(); +int decode_json_obj(bus_handle_t *handle, const char *json_name); +int get_partner_id(char *partner_id); #endif diff --git a/source/dml/wifi_ssp/ssp_loop.h b/source/dml/wifi_ssp/ssp_loop.h index a4551040..930d0302 100644 --- a/source/dml/wifi_ssp/ssp_loop.h +++ b/source/dml/wifi_ssp/ssp_loop.h @@ -42,22 +42,7 @@ extern "C" { #endif #include "wifi_base.h" - -typedef enum { - ssp_event_type_psm_read, - ssp_event_type_psm_write, - ssp_event_type_max -} ssp_event_type_t; - -typedef enum { - radio_config, - radio_feature_config, - vap_config, - global_config, - security_config, - mac_config_add, - mac_config_delete -} ssp_event_subtype_t; +#include "wifi_dml.h" typedef int (* ssp_loop_post)(const void *msg, unsigned int len, ssp_event_type_t type, ssp_event_subtype_t sub_type); diff --git a/source/dml/wifi_ssp/ssp_main.h b/source/dml/wifi_ssp/ssp_main.h index 9bcb9eb4..d8ed95d7 100644 --- a/source/dml/wifi_ssp/ssp_main.h +++ b/source/dml/wifi_ssp/ssp_main.h @@ -27,12 +27,6 @@ extern "C" { #endif -typedef struct { - pthread_t tid; - int argc; - char **argv; -} wifi_ssp_t; - #ifdef __cplusplus } #endif diff --git a/source/platform/common/bus_common.c b/source/platform/common/bus_common.c index 4186c65e..a958ab43 100644 --- a/source/platform/common/bus_common.c +++ b/source/platform/common/bus_common.c @@ -24,6 +24,16 @@ #include "bus.h" #include "bus_common.h" +#define COMPARE_INT_RANGE(min_value, max_value, set_value) do { \ + if ((set_value) < (min_value)) { \ + wifi_util_info_print(WIFI_BUS, "Value %d is less than the minimum value (%d)\n", (set_value), (min_value)); \ + return RETURN_ERR; \ + } else if ((set_value) > (max_value)) { \ + wifi_util_info_print(WIFI_BUS, "Value %d is greater than the maximum value (%d)\n", (set_value), (max_value)); \ + return RETURN_ERR; \ + } \ +} while (0) + pthread_mutex_t *get_bus_mux_mutex(void) { wifi_bus_t *p_bus = get_bus_obj(); @@ -685,3 +695,79 @@ bus_error_t bus_table_remove_row(elem_node_map_t *p_root_node, char *p_name_spac } return bus_error_destination_not_found; } + +int check_dm_min_max_data_range(long int min_data, long int max_data, raw_data_t *bus_set_data) +{ + if (min_data == 0 && max_data == 0) { + wifi_util_info_print(WIFI_BUS,"%s:%d: int range validation is not needed\n",__func__, __LINE__); + return RETURN_OK; + } + + wifi_util_info_print(WIFI_BUS,"%s:%d: set data type:%d\n",__func__, __LINE__, bus_set_data->data_type); + if (bus_set_data->data_type == bus_data_type_boolean) { + COMPARE_INT_RANGE((bool)min_data, (bool)max_data, bus_set_data->raw_data.b); + } else if (bus_set_data->data_type == bus_data_type_int8) { + COMPARE_INT_RANGE((int8_t)min_data, (int8_t)max_data, bus_set_data->raw_data.i8); + } else if (bus_set_data->data_type == bus_data_type_uint8) { + COMPARE_INT_RANGE((uint8_t)min_data, (uint8_t)max_data, bus_set_data->raw_data.u8); + } else if (bus_set_data->data_type == bus_data_type_int16) { + COMPARE_INT_RANGE((int16_t)min_data, (int16_t)max_data, bus_set_data->raw_data.i16); + } else if (bus_set_data->data_type == bus_data_type_uint16) { + COMPARE_INT_RANGE((uint16_t)min_data, (uint16_t)max_data, bus_set_data->raw_data.u16); + } else if (bus_set_data->data_type == bus_data_type_int32) { + COMPARE_INT_RANGE((int32_t)min_data, (int32_t)max_data, bus_set_data->raw_data.i32); + } else if (bus_set_data->data_type == bus_data_type_uint32) { + COMPARE_INT_RANGE((uint32_t)min_data, (uint32_t)max_data, bus_set_data->raw_data.u32); + } + + return RETURN_OK; +} + +int validate_dm_string_param(uint32_t num_of_str, char **str, char *set_str) +{ + if (num_of_str == 0) { + wifi_util_info_print(WIFI_BUS,"%s:%d: string validation is not set\n",__func__, __LINE__); + } else if (str == NULL || set_str == NULL) { + wifi_util_info_print(WIFI_BUS,"%s:%d: input string is NULL:%p:%p\n", __func__, __LINE__, str, set_str); + } else { + uint32_t index; + bool str_found = false; + + for(index = 0; index < num_of_str; index++) { + if (str[index] && (strncmp(str[index], set_str, strlen(set_str) + 1) == 0)) { + str_found = true; + break; + } + } + if (str_found == false) { + wifi_util_info_print(WIFI_BUS,"%s:%d: string:%s validation is failed:%d\n",__func__, + __LINE__, set_str, num_of_str); + return RETURN_ERR; + } + } + + return RETURN_OK; +} + +int validate_dm_set_parameters(data_model_properties_t *data_model_prop, raw_data_t *bus_set_data) +{ + int ret = RETURN_ERR; + + BUS_CHECK_NULL_WITH_RC(data_model_prop, ret); + + if (data_model_prop->data_permission == false) { + wifi_util_error_print(WIFI_BUS,"%s:%d: data is not permit to set\n",__func__, __LINE__); + return ret; + } + + ret = check_dm_min_max_data_range(data_model_prop->min_data_range, data_model_prop->max_data_range, bus_set_data); + if (ret != RETURN_OK) { + wifi_util_error_print(WIFI_BUS,"%s:%d: set data min/max data range is not propered\n",__func__, __LINE__); + return ret; + } else if (bus_set_data->data_type == bus_data_type_string) { + ret = validate_dm_string_param(data_model_prop->num_of_str_validation, data_model_prop->str_validation, + (char *)bus_set_data->raw_data.bytes); + } + + return ret; +} diff --git a/source/platform/common/bus_common.h b/source/platform/common/bus_common.h index 145c49c9..9e8e2eb3 100644 --- a/source/platform/common/bus_common.h +++ b/source/platform/common/bus_common.h @@ -258,6 +258,9 @@ typedef bus_error_t (* wifi_bus_event_subscribe_ex_t) (bus_handle_t *h typedef bus_error_t (* wifi_bus_event_subscribe_ex_async_t) (bus_handle_t *handle, bus_event_sub_t *l_sub_info_map, int num_sub, void *l_sub_handler, int timeout); typedef bus_error_t (* wifi_bus_reg_elements_t) (bus_handle_t *handle, bus_data_element_t *data_element, uint32_t num_of_element); typedef bus_error_t (* wifi_bus_method_invoke_t) (bus_handle_t *handle, void *paramName, char *event, raw_data_t *input_data, raw_data_t *output_data, bool input_bus_data); +typedef bus_error_t (* wifi_bus_reg_table_row_t) (bus_handle_t *handle, char const *name, uint32_t row_index, char const *alias); +typedef bus_error_t (* wifi_bus_unreg_table_row_t) (bus_handle_t *handle, char const *name); +typedef bus_error_t (* wifi_bus_remove_table_row_t) (bus_handle_t *handle, char const *name); typedef struct { wifi_bus_init_t bus_init_fn; @@ -275,6 +278,9 @@ typedef struct { wifi_bus_event_subscribe_ex_async_t bus_event_subs_ex_async_fn; wifi_bus_method_invoke_t bus_method_invoke_fn; wifi_bus_get_trace_context_t bus_get_trace_context_fn; + wifi_bus_reg_table_row_t bus_reg_table_row_fn; + wifi_bus_unreg_table_row_t bus_unreg_table_row_fn; + wifi_bus_remove_table_row_t bus_remove_table_row_fn; } wifi_bus_desc_t; typedef struct bus_event_sub { @@ -376,6 +382,8 @@ bus_error_t bus_table_add_row(elem_node_map_t *p_root_node, char *name_space, ui bus_error_t bus_table_remove_row(elem_node_map_t *p_root_node, char *p_name_space); void print_registered_elems(elem_node_map_t *root, int level); +int validate_dm_set_parameters(data_model_properties_t *data_model_prop, raw_data_t *bus_set_data); + #ifdef __cplusplus } #endif diff --git a/source/platform/common/data_model/wifi_data_model.c b/source/platform/common/data_model/wifi_data_model.c new file mode 100644 index 00000000..be8131fa --- /dev/null +++ b/source/platform/common/data_model/wifi_data_model.c @@ -0,0 +1,1687 @@ +#include +#include +#include +#include "bus.h" +#include "wifi_data_model_parse.h" +#include "wifi_data_model.h" +#include "wifi_dml_cb.h" +#include "wifi_dml_api.h" +#include "wifi_monitor.h" + +wifi_dml_data_model_t g_dml_data_model; + +wifi_dml_data_model_t *get_dml_data_model_param(void) +{ + return &g_dml_data_model; +} + +bus_error_t wifi_elem_num_of_table_row(char *event_name, uint32_t *table_row_size) +{ + if (!strncmp(event_name, RADIO_OBJ_TREE_NAME, strlen(RADIO_OBJ_TREE_NAME) + 1)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Number of radio:%d\n",__func__, __LINE__, getNumberRadios()); + *table_row_size = getNumberRadios(); + } else if (!strncmp(event_name, ACCESSPOINT_OBJ_TREE_NAME, strlen(ACCESSPOINT_OBJ_TREE_NAME) + 1)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Total number of vaps:%d getTotalNumberVAPs():%d\n",__func__, __LINE__, getNumberRadios() * MAX_NUM_VAP_PER_RADIO, getTotalNumberVAPs()); + *table_row_size = getTotalNumberVAPs(); + } else if (!strncmp(event_name, SSID_OBJ_TREE_NAME, strlen(SSID_OBJ_TREE_NAME) + 1)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Total number of vaps:%d get total num vap dml:%d\n",__func__, __LINE__, getNumberRadios() * MAX_NUM_VAP_PER_RADIO, getTotalNumberVAPs()); + *table_row_size = getTotalNumberVAPs(); + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Table is not found for [%s]\n", __func__, __LINE__, event_name); + return bus_error_invalid_input; + } + + return bus_error_success; +} + +uint32_t convert_vap_index_from_inst(uint32_t vap_instance_cnt) +{ + wifi_mgr_t *mgr = get_wifimgr_obj(); + unsigned int vap_index; + + vap_index = VAP_INDEX(mgr->hal_cap, vap_instance_cnt) + 1; + + return vap_index; +} + +bus_error_t dml_get_set_param_value(dml_callback_table_t *p_dml_cb, uint8_t cb_table_type, void *obj_ins_context, char *param_name, raw_data_t *p_data) +{ + bus_error_t status = bus_error_success; + + DM_CHECK_NULL_WITH_RC(obj_ins_context, bus_error_invalid_input); + DM_CHECK_NULL_WITH_RC(param_name, bus_error_invalid_input); + DM_CHECK_NULL_WITH_RC(p_data, bus_error_invalid_input); + DM_CHECK_NULL_WITH_RC(p_dml_cb, bus_error_invalid_input); + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d [%d] param:%s type:%d\n", __func__, __LINE__, cb_table_type, param_name, p_data->data_type); + switch(p_data->data_type) { + case bus_data_type_boolean: + if ((cb_table_type == DML_GET_CB) && (p_dml_cb->get_bool_value != NULL)) { + if (p_dml_cb->get_bool_value(obj_ins_context, param_name, &p_data->raw_data.b) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d get bool param:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.b, param_name); + status = bus_error_invalid_input; + } + } else if ((cb_table_type == DML_SET_CB) && (p_dml_cb->set_bool_value != NULL)) { + if (p_dml_cb->set_bool_value(obj_ins_context, param_name, p_data->raw_data.b) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d set bool param:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.b, param_name); + status = bus_error_invalid_input; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d cb is not found:%d for [%s]\n", __func__, + __LINE__, cb_table_type, param_name); + status = bus_error_invalid_input; + } + break; + case bus_data_type_int32: + if ((cb_table_type == DML_GET_CB) && (p_dml_cb->get_int_value != NULL)) { + if (p_dml_cb->get_int_value(obj_ins_context, param_name, &p_data->raw_data.i32) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d get int param:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.i32, param_name); + status = bus_error_invalid_input; + } + } else if ((cb_table_type == DML_SET_CB) && (p_dml_cb->set_int_value != NULL)) { + if (p_dml_cb->set_int_value(obj_ins_context, param_name, p_data->raw_data.i32) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d set int param:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.i32, param_name); + status = bus_error_invalid_input; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d cb is not found:%d for [%s]\n", __func__, + __LINE__, cb_table_type, param_name); + status = bus_error_invalid_input; + } + break; + case bus_data_type_uint32: + if ((cb_table_type == DML_GET_CB) && (p_dml_cb->get_uint_value != NULL)) { + if (p_dml_cb->get_uint_value(obj_ins_context, param_name, &p_data->raw_data.u32) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d get uint param:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.u32, param_name); + status = bus_error_invalid_input; + } + } else if ((cb_table_type == DML_SET_CB) && (p_dml_cb->set_uint_value != NULL)) { + if (p_dml_cb->set_uint_value(obj_ins_context, param_name, p_data->raw_data.u32) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d set uint param:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.u32, param_name); + status = bus_error_invalid_input; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d cb is not found:%d for [%s]\n", __func__, + __LINE__, cb_table_type, param_name); + status = bus_error_invalid_input; + } + break; + case bus_data_type_string: + scratch_data_buff_t temp_buff = { 0 }; + if ((cb_table_type == DML_GET_CB) && (p_dml_cb->get_string_value != NULL)) { + + if (p_dml_cb->get_string_value(obj_ins_context, param_name, &temp_buff) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d get string param:%s:%d failed for [%s]\n", __func__, __LINE__, temp_buff.buff, temp_buff.buff_len, param_name); + status = bus_error_invalid_input; + } else { + p_data->raw_data.bytes = temp_buff.buff; + p_data->raw_data_len = temp_buff.buff_len; + p_data->data_type = bus_data_type_string; + } + } else if ((cb_table_type == DML_SET_CB) && (p_dml_cb->set_string_value != NULL)) { + temp_buff.buff = (char *)p_data->raw_data.bytes; + temp_buff.buff_len = p_data->raw_data_len; + if (p_dml_cb->set_string_value(obj_ins_context, param_name, &temp_buff) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d set string param:%s:%d failed for [%s]\n", __func__, __LINE__, p_data->raw_data.bytes, p_data->raw_data_len, param_name); + status = bus_error_invalid_input; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d cb is not found:%d for [%s]\n", __func__, + __LINE__, cb_table_type, param_name); + status = bus_error_invalid_input; + } + break; + case bus_data_type_none: + wifi_util_error_print(WIFI_DMCLI,"%s:%d unsupported param failed for [%s]\n", __func__, __LINE__, param_name); + status = bus_error_invalid_input; + break; + default: + wifi_util_error_print(WIFI_DMCLI,"%s:%d unsupported param:%x failed for [%s]\n", __func__, __LINE__, p_data->data_type, param_name); + status = bus_error_invalid_input; + break; + } + + return status; +} + +bus_error_t wifi_get_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_wifidb_wifi_global_param(); + dml_callback_table_t dml_data_cb = { + wifi_get_param_bool_value, wifi_get_param_int_value, wifi_get_param_uint_value, wifi_get_param_string_value, + wifi_set_param_bool_value, wifi_set_param_int_value, wifi_set_param_uint_value, wifi_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_set_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_wifidb_wifi_global_param(); + dml_callback_table_t dml_data_cb = { + wifi_get_param_bool_value, wifi_get_param_int_value, wifi_get_param_uint_value, wifi_get_param_string_value, + wifi_set_param_bool_value, wifi_set_param_int_value, wifi_set_param_uint_value, wifi_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t neig_wifi_diag_get_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_wifidb_wifi_global_param(); + dml_callback_table_t dml_data_cb = { + neig_wifi_diag_get_param_bool_value, neig_wifi_diag_get_param_int_value, + neig_wifi_diag_get_param_uint_value, neig_wifi_diag_get_param_string_value, + neig_wifi_diag_set_param_bool_value, neig_wifi_diag_set_param_int_value, + neig_wifi_diag_set_param_uint_value, neig_wifi_diag_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.NeighboringWiFiDiagnostic.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d neig wifi diag param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t neig_wifi_diag_set_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_wifidb_wifi_global_param(); + dml_callback_table_t dml_data_cb = { + neig_wifi_diag_get_param_bool_value, neig_wifi_diag_get_param_int_value, + neig_wifi_diag_get_param_uint_value, neig_wifi_diag_get_param_string_value, + neig_wifi_diag_set_param_bool_value, neig_wifi_diag_set_param_int_value, + neig_wifi_diag_set_param_uint_value, neig_wifi_diag_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.NeighboringWiFiDiagnostic.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d neig wifi diag param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t neig_wifi_diag_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +wifi_neighbor_ap2_t *get_neig_diag_result_obj(uint32_t ap_instance) +{ + uint32_t index = 0; + uint32_t count = 0; + uint32_t array_index = ap_instance - 1; + + wifi_monitor_t *p_monitor_param = (wifi_monitor_t *)get_wifi_monitor(); + if (p_monitor_param->neighbor_scan_cfg.ResultCount <= 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d neig_diag result not valid:%d\r\n", __func__, + __LINE__, p_monitor_param->neighbor_scan_cfg.ResultCount); + return NULL; + } + + for (index = 0; index < (uint32_t)get_num_radio_dml(); index++) { + if (array_index < (p_monitor_param->neighbor_scan_cfg.resultCountPerRadio[index] + count)) { + return &p_monitor_param->neighbor_scan_cfg.pResult[index][array_index]; + } + count += p_monitor_param->neighbor_scan_cfg.resultCountPerRadio[index]; + array_index -= count; + } + + return NULL; +} + +bus_error_t neig_diag_result_get_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + uint32_t index = 0; + dml_callback_table_t dml_data_cb = { + NULL, neig_diag_result_get_param_int_value, + neig_diag_result_get_param_uint_value, neig_diag_result_get_param_string_value, + NULL, NULL, NULL, NULL + }; + + sscanf(event_name, "Device.WiFi.NeighboringWiFiDiagnostic.Result.%d.%s", &index, extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + wifi_neighbor_ap2_t *pcfg = get_neig_diag_result_obj(index); + DM_CHECK_NULL_WITH_RC(pcfg, bus_error_invalid_input); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d neig wifi diag param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t neig_diag_result_table_add_row_cb(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)aliasName; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter\r\n", __func__, __LINE__); + p_dml_param->table_neig_diag_result_index++; + *instNum = p_dml_param->table_neig_diag_result_index; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s, index:%d\r\n", __func__, + __LINE__, tableName, *instNum); + return bus_error_success; +} + +bus_error_t neig_diag_result_table_remove_row_cb(char const* rowName) +{ + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + p_dml_param->table_neig_diag_result_index--; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s:index:%d\r\n", __func__, + __LINE__, rowName, p_dml_param->table_neig_diag_result_index); + return bus_error_success; +} + +bus_error_t neig_diag_result_event_sub_cb(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t radio_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_radio_operationParam_t *radio_param; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + dml_callback_table_t dml_data_cb = { + radio_get_param_bool_value, radio_get_param_int_value, radio_get_param_uint_value, radio_get_param_string_value, + radio_set_param_bool_value, radio_set_param_int_value, radio_set_param_uint_value, radio_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.Radio.%d.%s", &index, extension); + if (p_dml_param->table_radio_index < index) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong radio get index for:[%s]:%d\r\n", __func__, __LINE__, event_name, index); + return bus_error_invalid_input; + } + radio_param = (wifi_radio_operationParam_t *)get_wifidb_radio_map(index - 1); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d radio enable:%d event:[%s][%s]\n", __func__, __LINE__, radio_param->enable, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)radio_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d radio param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t radio_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_radio_operationParam_t *radio_param; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + dml_callback_table_t dml_data_cb = { + radio_get_param_bool_value, radio_get_param_int_value, radio_get_param_uint_value, radio_get_param_string_value, + radio_set_param_bool_value, radio_set_param_int_value, radio_set_param_uint_value, radio_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.Radio.%d.%s", &index, extension); + if (p_dml_param->table_radio_index < index) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong radio set index for:[%s]:%d\r\n", __func__, __LINE__, event_name, index); + return bus_error_invalid_input; + } + radio_param = (wifi_radio_operationParam_t *)get_wifidb_radio_map(index - 1); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d radio enable:%d event:[%s][%s]\n", __func__, __LINE__, radio_param->enable, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)radio_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d radio param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t radio_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)aliasName; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter\r\n", __func__, __LINE__); + p_dml_param->table_radio_index++; + *instNum = p_dml_param->table_radio_index; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s table_radio_index:%d\r\n", __func__, __LINE__, tableName, p_dml_param->table_radio_index); + return bus_error_success; +} + +bus_error_t radio_table_remove_row_handler(char const* rowName) +{ + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s\r\n", __func__, __LINE__, rowName); + p_dml_param->table_radio_index--; + return bus_error_success; +} + +bus_error_t radio_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t accesspoint_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + accesspoint_get_param_bool_value, accesspoint_get_param_int_value, accesspoint_get_param_uint_value, accesspoint_get_param_string_value, + accesspoint_set_param_bool_value, accesspoint_set_param_int_value, accesspoint_set_param_uint_value, accesspoint_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d AccessPoint get event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d accesspoint param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t accesspoint_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + accesspoint_get_param_bool_value, accesspoint_get_param_int_value, accesspoint_get_param_uint_value, accesspoint_get_param_string_value, + accesspoint_set_param_bool_value, accesspoint_set_param_int_value, accesspoint_set_param_uint_value, accesspoint_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d AccessPoint set event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d accesspoint param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t accesspoint_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)instNum; + (void)aliasName; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter\r\n", __func__, __LINE__); + *instNum = convert_vap_index_from_inst(p_dml_param->table_ap_index); + p_dml_param->table_ap_index++; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s table_ap_index:%d-%d\r\n", __func__, + __LINE__, tableName, p_dml_param->table_ap_index, *instNum); + return bus_error_success; +} + +bus_error_t accesspoint_table_remove_row_handler(char const* rowName) +{ + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s\r\n", __func__, __LINE__, rowName); + p_dml_param->table_ap_index--; + return bus_error_success; +} + +bus_error_t accesspoint_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t security_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + security_get_param_bool_value, security_get_param_int_value, security_get_param_uint_value, security_get_param_string_value, + security_set_param_bool_value, security_set_param_int_value, security_set_param_uint_value, security_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.Security.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d security param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t security_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + security_get_param_bool_value, security_get_param_int_value, security_get_param_uint_value, security_get_param_string_value, + security_set_param_bool_value, security_set_param_int_value, security_set_param_uint_value, security_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.Security.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d security param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t security_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t ssid_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + dml_callback_table_t dml_data_cb = { + ssid_get_param_bool_value, ssid_get_param_int_value, ssid_get_param_uint_value, ssid_get_param_string_value, + ssid_set_param_bool_value, ssid_set_param_int_value, ssid_set_param_uint_value, ssid_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.SSID.%d.%s", &index, extension); + if (p_dml_param->table_ssid_index < index) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong ssid get index for:[%s]:%d\r\n", __func__, __LINE__, event_name, index); + return bus_error_invalid_input; + } + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d SSID Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d ssid param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t ssid_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + dml_callback_table_t dml_data_cb = { + ssid_get_param_bool_value, ssid_get_param_int_value, ssid_get_param_uint_value, ssid_get_param_string_value, + ssid_set_param_bool_value, ssid_set_param_int_value, ssid_set_param_uint_value, ssid_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.SSID.%d.%s", &index, extension); + if (p_dml_param->table_ssid_index < index) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong ssid set index for:[%s]:%d\r\n", __func__, __LINE__, event_name, index); + return bus_error_invalid_input; + } + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d SSID Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d ssid param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t ssid_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)instNum; + (void)aliasName; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter\r\n", __func__, __LINE__); + *instNum = convert_vap_index_from_inst(p_dml_param->table_ssid_index); + p_dml_param->table_ssid_index++; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s table_ssid_index:%d-%d\r\n", __func__, + __LINE__, tableName, p_dml_param->table_ssid_index, *instNum); + return bus_error_success; +} + +bus_error_t ssid_table_remove_row_handler(char const* rowName) +{ + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s\r\n", __func__, __LINE__, rowName); + p_dml_param->table_ssid_index--; + return bus_error_success; +} + +bus_error_t ssid_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t macfilter_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0, acl_index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + bus_error_t status = bus_error_general; + acl_entry_t *acl_entry; + dml_callback_table_t dml_data_cb = { + macfilter_get_param_bool_value, macfilter_get_param_int_value, macfilter_get_param_uint_value, macfilter_get_param_string_value, + macfilter_set_param_bool_value, macfilter_set_param_int_value, macfilter_set_param_uint_value, macfilter_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.%d.%s", &index, &acl_index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d vap map not found for:[%s][%d]\r\n", __func__, + __LINE__, event_name, index); + return status; + } + + acl_entry = get_macfilter_entry(vap_param, acl_index - 1); + if (acl_entry == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter entry not found index::%d\r\n", __func__, __LINE__, acl_index); + return status; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)acl_entry, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t macfilter_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0, acl_index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + bus_error_t status = bus_error_general; + acl_entry_t *acl_entry; + mac_filter_set_param_arg_t l_mac_filter_args; + dml_callback_table_t dml_data_cb = { + macfilter_get_param_bool_value, macfilter_get_param_int_value, macfilter_get_param_uint_value, macfilter_get_param_string_value, + macfilter_set_param_bool_value, macfilter_set_param_int_value, macfilter_set_param_uint_value, macfilter_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.%d.%s", &index, &acl_index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d vap map not found for:[%s][%d]\r\n", __func__, + __LINE__, event_name, index); + return status; + } + + acl_entry = get_macfilter_entry(vap_param, acl_index - 1); + if (acl_entry == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter entry not found index::%d\r\n", __func__, __LINE__, acl_index); + return status; + } + + l_mac_filter_args.acl_param = acl_entry; + l_mac_filter_args.vap_info_param = vap_param; + wifi_util_info_print(WIFI_DMCLI,"%s:%d Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)&l_mac_filter_args, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t macfilter_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)aliasName; + wifi_vap_info_t *vap_param; + int vap_index = 0; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter tableName:%s\r\n", __func__, __LINE__, tableName); + sscanf(tableName, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.", &vap_index); + + vap_param = (wifi_vap_info_t *)getVapInfo(vap_index - 1); + DM_CHECK_NULL_WITH_RC(vap_param, bus_error_general); + + macfilter_tab_add_entry(vap_param, instNum); + p_dml_param->table_macfilter_index[vap_param->vap_index]++; + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s vap:%d macfilter table index:%d-%d\r\n", __func__, + __LINE__, tableName, vap_index, *instNum, p_dml_param->table_macfilter_index[vap_param->vap_index]); + + return bus_error_success; +} + +bus_error_t macfilter_table_remove_row_handler(char const* rowName) +{ + wifi_vap_info_t *vap_param; + int vap_index = 0, macfilter_entry_index = 0; + acl_entry_t *acl_entry; + bus_error_t ret = bus_error_general; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter rowName:%s\r\n", __func__, __LINE__, rowName); + sscanf(rowName, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.%d", &vap_index, &macfilter_entry_index); + + vap_param = (wifi_vap_info_t *)getVapInfo(vap_index - 1); + DM_CHECK_NULL_WITH_RC(vap_param, ret); + + acl_entry = get_macfilter_entry(vap_param, macfilter_entry_index - 1); + if (acl_entry == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter entry is not found index:%d\r\n", __func__, + __LINE__, macfilter_entry_index); + return ret; + } + + int status = macfilter_tab_del_entry(vap_param, acl_entry); + if (status != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter acl entry del failure for vap:%d index:%d\r\n", __func__, + __LINE__, vap_index, macfilter_entry_index); + return ret; + } + uint32_t *cur_macfilter_index = &p_dml_param->table_macfilter_index[vap_param->vap_index]; + + if (*cur_macfilter_index > 0) { + if (*cur_macfilter_index == (uint32_t)macfilter_entry_index) { + (*cur_macfilter_index)--; + } else { + sync_dml_macfilter_table(vap_param->vap_index, (char *)rowName); + } + } + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d rowName:%s removed for vap_index:%d index:%d\r\n", __func__, + __LINE__, rowName, vap_index, p_dml_param->table_macfilter_index[vap_param->vap_index]); + return bus_error_success; +} + +bus_error_t macfilter_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t associated_sta_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0, sta_index = 0; + char extension[64] = {0}; + bus_error_t status = bus_error_general; + assoc_dev_data_t *p_assoc_sta_entry; + dml_callback_table_t dml_data_cb = { + associated_sta_get_param_bool_value, associated_sta_get_param_int_value, associated_sta_get_param_uint_value, associated_sta_get_param_string_value, + NULL, NULL, NULL, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.AssociatedDevice.%d.%s", &index, &sta_index, extension); + + p_assoc_sta_entry = get_sta_assoc_data_map(index, sta_index); + wifi_util_info_print(WIFI_DMCLI,"%s:%d Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)p_assoc_sta_entry, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d associated sta param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t associated_sta_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)instNum; + (void)aliasName; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter\r\n", __func__, __LINE__); + uint32_t index; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_vap_info_t *vap_param; + + sscanf(tableName, "Device.WiFi.AccessPoint.%d.AssociatedDevice.", &index); + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + DM_CHECK_NULL_WITH_RC(vap_param, bus_error_general); + + p_dml_param->table_sta_assoc_index[vap_param->vap_index]++; + *instNum = p_dml_param->table_sta_assoc_index[vap_param->vap_index]; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s index:%d vap_index:%d\r\n", __func__, + __LINE__, tableName, *instNum, vap_param->vap_index); + return bus_error_success; +} + +bus_error_t associated_sta_table_remove_row_handler(char const* rowName) +{ + uint32_t index, sta_index; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + wifi_vap_info_t *vap_param; + + sscanf(rowName, "Device.WiFi.AccessPoint.%d.AssociatedDevice.%d", &index, &sta_index); + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + DM_CHECK_NULL_WITH_RC(vap_param, bus_error_general); + + if (p_dml_param->table_sta_assoc_index[vap_param->vap_index] > 0) { + p_dml_param->table_sta_assoc_index[vap_param->vap_index]--; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s vap_index:%d sta_cnt:%d sta_index:%d\r\n", __func__, + __LINE__, rowName, vap_param->vap_index, p_dml_param->table_sta_assoc_index[vap_param->vap_index], sta_index); + return bus_error_success; +} + +bus_error_t associated_sta_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t interworking_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + interworking_get_param_bool_value, interworking_get_param_int_value, + interworking_get_param_uint_value, interworking_get_param_string_value, + interworking_set_param_bool_value, interworking_set_param_int_value, + interworking_set_param_uint_value, interworking_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_InterworkingElement.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Get interworking Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d interworking param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t interworking_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + interworking_get_param_bool_value, interworking_get_param_int_value, + interworking_get_param_uint_value, interworking_get_param_string_value, + interworking_set_param_bool_value, interworking_set_param_int_value, + interworking_set_param_uint_value, interworking_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_InterworkingElement.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Set interworking Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d interworking param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t interworking_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, + __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t wps_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + wps_get_param_bool_value, wps_get_param_int_value, wps_get_param_uint_value, wps_get_param_string_value, + wps_set_param_bool_value, wps_set_param_int_value, wps_set_param_uint_value, wps_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.WPS.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Get wps Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wps param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wps_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + wps_get_param_bool_value, wps_get_param_int_value, wps_get_param_uint_value, wps_get_param_string_value, + wps_set_param_bool_value, wps_set_param_int_value, wps_set_param_uint_value, wps_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.WPS.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Set wps Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wps param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wps_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t ap_macfilter_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + ap_macfilter_get_param_bool_value, NULL, NULL, NULL, + ap_macfilter_set_param_bool_value, NULL, NULL, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MACFilter.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Get ap macfilter Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d ap macfilter param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t ap_macfilter_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + ap_macfilter_get_param_bool_value, NULL, NULL, NULL, + ap_macfilter_set_param_bool_value, NULL, NULL, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MACFilter.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Set ap macfilter Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d ap macfilter param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t ap_macfilter_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t radius_sec_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + radius_sec_get_param_bool_value, radius_sec_get_param_int_value, NULL, NULL, + radius_sec_set_param_bool_value, radius_sec_set_param_int_value, NULL, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.Security.X_COMCAST-COM_RadiusSettings.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Radius sec Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d radius sec param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t radius_sec_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + radius_sec_get_param_bool_value, radius_sec_get_param_int_value, NULL, NULL, + radius_sec_set_param_bool_value, radius_sec_set_param_int_value, NULL, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.Security.X_COMCAST-COM_RadiusSettings.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d Set Radius sec Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d radius sec param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t radius_sec_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t auth_sec_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, auth_sec_get_param_uint_value, NULL, + NULL, NULL, auth_sec_set_param_uint_value, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.Security.X_RDKCENTRAL-COM_Authenticator.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d auth sec Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d auth sec param get failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t auth_sec_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, auth_sec_get_param_uint_value, NULL, + NULL, NULL, auth_sec_set_param_uint_value, NULL + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.Security.X_RDKCENTRAL-COM_Authenticator.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set auth sec Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d auth sec param set failed for:[%s][%s]\r\n", __func__, __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t auth_sec_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t conn_ctrl_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, conn_ctrl_get_param_string_value, + NULL, NULL, NULL, conn_ctrl_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.ConnectionControl.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get connection control Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d connection control param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t conn_ctrl_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, conn_ctrl_get_param_string_value, + NULL, NULL, NULL, conn_ctrl_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.ConnectionControl.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set connection control Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d connection control param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t conn_ctrl_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t pre_conn_ctrl_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, pre_conn_ctrl_get_param_string_value, + NULL, NULL, NULL, pre_conn_ctrl_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.ConnectionControl.PreAssocDeny.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get pre connection control Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d pre connection control param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t pre_conn_ctrl_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, pre_conn_ctrl_get_param_string_value, + NULL, NULL, NULL, pre_conn_ctrl_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.ConnectionControl.PreAssocDeny.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set pre connection control Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d pre connection control param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t pre_conn_ctrl_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t post_conn_ctrl_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, post_conn_ctrl_get_param_string_value, + NULL, NULL, NULL, post_conn_ctrl_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.ConnectionControl.PostAssocDisc.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get post connection control Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d post connection control param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t post_conn_ctrl_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, post_conn_ctrl_get_param_string_value, + NULL, NULL, NULL, post_conn_ctrl_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.ConnectionControl.PostAssocDisc.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set post connection control Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d post connection control param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t post_conn_ctrl_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t interworking_serv_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, interworking_serv_get_param_string_value, + NULL, NULL, NULL, interworking_serv_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_InterworkingService.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get interwoking serv Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d interwoking serv param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t interworking_serv_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, interworking_serv_get_param_string_value, + NULL, NULL, NULL, interworking_serv_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_InterworkingService.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set interwoking serv Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d interwoking serv param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t interworking_serv_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t passpoint_get_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + passpoint_get_param_bool_value, NULL, NULL, passpoint_get_param_string_value, + passpoint_set_param_bool_value, NULL, NULL, passpoint_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_Passpoint.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get passpoint Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d passpoint param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t passpoint_set_param_value(char *event_name, raw_data_t *p_data) +{ + uint32_t index = 0; + char extension[64] = {0}; + wifi_vap_info_t *vap_param; + dml_callback_table_t dml_data_cb = { + passpoint_get_param_bool_value, NULL, NULL, passpoint_get_param_string_value, + passpoint_set_param_bool_value, NULL, NULL, passpoint_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_Passpoint.%s", &index, extension); + + vap_param = (wifi_vap_info_t *)getVapInfo(index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong vap index:%d for:[%s]\r\n", __func__, + __LINE__, index, event_name); + return bus_error_invalid_input; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set passpoint Event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)vap_param, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d passpoint param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t passpoint_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t wifi_client_report_get_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) get_dml_harvester(); + dml_callback_table_t dml_data_cb = { + wifi_client_report_get_param_bool_value, NULL, + wifi_client_report_get_param_uint_value, wifi_client_report_get_param_string_value, + wifi_client_report_set_param_bool_value, NULL, + wifi_client_report_set_param_uint_value, wifi_client_report_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.X_RDKCENTRAL-COM_Report.WifiClient.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi client report param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_client_report_set_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) get_dml_harvester(); + dml_callback_table_t dml_data_cb = { + wifi_client_report_get_param_bool_value, NULL, + wifi_client_report_get_param_uint_value, wifi_client_report_get_param_string_value, + wifi_client_report_set_param_bool_value, NULL, + wifi_client_report_set_param_uint_value, wifi_client_report_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.X_RDKCENTRAL-COM_Report.WifiClient.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi client report param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_client_report_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t wifi_client_def_report_get_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) get_dml_harvester(); + dml_callback_table_t dml_data_cb = { + NULL, NULL, wifi_client_def_report_get_param_uint_value, NULL, + NULL, NULL, wifi_client_def_report_set_param_uint_value, NULL + }; + + sscanf(event_name, "Device.WiFi.X_RDKCENTRAL-COM_Report.WifiClient.Default.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi client report param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_client_def_report_set_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) get_dml_harvester(); + dml_callback_table_t dml_data_cb = { + NULL, NULL, wifi_client_def_report_get_param_uint_value, NULL, + NULL, NULL, wifi_client_def_report_set_param_uint_value, NULL + }; + + sscanf(event_name, "Device.WiFi.X_RDKCENTRAL-COM_Report.WifiClient.Default.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d set event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi client report param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_client_def_report_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} + +bus_error_t wifi_region_code_get_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_dml_wifi_global_param(); + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, wifi_region_code_get_param_string_value, + NULL, NULL, NULL, wifi_region_code_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.X_RDKCENTRAL-COM_Syndication.WiFiRegion.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_GET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi region code param get failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t wifi_region_code_set_param_value(char *event_name, raw_data_t *p_data) +{ + char extension[64] = {0}; + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_dml_wifi_global_param(); + dml_callback_table_t dml_data_cb = { + NULL, NULL, NULL, wifi_region_code_get_param_string_value, + NULL, NULL, NULL, wifi_region_code_set_param_string_value + }; + + sscanf(event_name, "Device.WiFi.X_RDKCENTRAL-COM_Syndication.WiFiRegion.%s", extension); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d get event:[%s][%s]\n", __func__, __LINE__, event_name, extension); + + bus_error_t status = dml_get_set_param_value(&dml_data_cb, DML_SET_CB, (void *)pcfg, extension, p_data); + if (status != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wifi region code param set failed for:[%s][%s]\r\n", __func__, + __LINE__, event_name, extension); + } + + return status; +} + +bus_error_t default_get_param_value(char *event_name, raw_data_t *p_data) +{ + (void)p_data; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s\r\n", __func__, __LINE__, event_name); + return bus_error_success; +} + +bus_error_t default_set_param_value(char *event_name, raw_data_t *p_data) +{ + (void)p_data; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s\r\n", __func__, __LINE__, event_name); + return bus_error_success; +} + +bus_error_t default_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum) +{ + (void)instNum; + (void)aliasName; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter\r\n", __func__, __LINE__); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Added table:%s\r\n", __func__, __LINE__, tableName); + return bus_error_success; +} + +bus_error_t default_table_remove_row_handler(char const* rowName) +{ + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s\r\n", __func__, __LINE__, rowName); + return bus_error_success; +} + +bus_error_t default_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish) +{ + (void)autoPublish; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d enter:%s: action:%d interval:%d\r\n", __func__, __LINE__, eventName, action, interval); + return bus_error_success; +} diff --git a/source/platform/common/data_model/wifi_data_model.h b/source/platform/common/data_model/wifi_data_model.h new file mode 100644 index 00000000..ef7b0bb0 --- /dev/null +++ b/source/platform/common/data_model/wifi_data_model.h @@ -0,0 +1,160 @@ +#ifndef WIFI_DATA_MODEL_H +#define WIFI_DATA_MODEL_H + +#include +#include +#include +#include "bus.h" +#include "wifi_util.h" + +#define DM_CHECK_NULL_WITH_RC(ptr, rc) \ + do { \ + if ((ptr) == NULL) { \ + wifi_util_error_print(WIFI_DMCLI, "%s:%d Parameter '%s' is NULL\n", \ + __func__, __LINE__, #ptr); \ + return (rc); \ + } \ + } while (0) + +typedef struct scratch_data_buff { + void *buff; + uint32_t buff_len; +} scratch_data_buff_t; + +typedef struct wifi_dml_data_model { + uint32_t table_radio_index; + uint32_t table_ap_index; + uint32_t table_ssid_index; + uint32_t table_macfilter_index[MAX_VAP]; + uint32_t table_sta_assoc_index[MAX_VAP]; + uint32_t table_neig_diag_result_index; + char str_wifi_region_update_source[16]; +} wifi_dml_data_model_t; + +typedef bool (*dml_get_bool_cb_t) (void *obj_ins_context, char *param_name, bool *value); +typedef bool (*dml_set_bool_cb_t) (void *obj_ins_context, char *param_name, bool value); +typedef bool (*dml_get_int_cb_t) (void *obj_ins_context, char *param_name, int *value); +typedef bool (*dml_set_int_cb_t) (void *obj_ins_context, char *param_name, int value); +typedef bool (*dml_get_uint_cb_t) (void *obj_ins_context, char *param_name, uint32_t *value); +typedef bool (*dml_set_uint_cb_t) (void *obj_ins_context, char *param_name, uint32_t value); +typedef bool (*dml_get_string_cb_t) (void *obj_ins_context, char *param_name, scratch_data_buff_t *value); +typedef bool (*dml_set_string_cb_t) (void *obj_ins_context, char *param_name, scratch_data_buff_t *value); + +typedef struct dml_callback_table { + dml_get_bool_cb_t get_bool_value; + dml_get_int_cb_t get_int_value; + dml_get_uint_cb_t get_uint_value; + dml_get_string_cb_t get_string_value; + dml_set_bool_cb_t set_bool_value; + dml_set_int_cb_t set_int_value; + dml_set_uint_cb_t set_uint_value; + dml_set_string_cb_t set_string_value; +} dml_callback_table_t; + +bus_error_t wifi_elem_num_of_table_row(char *event_name, uint32_t *table_row_size); + +bus_error_t wifi_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t neig_wifi_diag_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t neig_wifi_diag_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t neig_wifi_diag_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t neig_diag_result_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t neig_diag_result_table_add_row_cb(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t neig_diag_result_table_remove_row_cb(char const* rowName); +bus_error_t neig_diag_result_event_sub_cb(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t radio_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t radio_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t radio_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t radio_table_remove_row_handler(char const* rowName); +bus_error_t radio_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t accesspoint_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t accesspoint_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t accesspoint_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t accesspoint_table_remove_row_handler(char const* rowName); +bus_error_t accesspoint_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t ssid_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t ssid_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t ssid_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t ssid_table_remove_row_handler(char const* rowName); +bus_error_t ssid_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t security_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t security_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t security_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t macfilter_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t macfilter_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t macfilter_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t macfilter_table_remove_row_handler(char const* rowName); +bus_error_t macfilter_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t associated_sta_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t associated_sta_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t associated_sta_table_remove_row_handler(char const* rowName); +bus_error_t associated_sta_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t interworking_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t interworking_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t interworking_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t ap_macfilter_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t ap_macfilter_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t ap_macfilter_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t radius_sec_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t radius_sec_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t radius_sec_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t auth_sec_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t auth_sec_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t auth_sec_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t conn_ctrl_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t conn_ctrl_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t conn_ctrl_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t pre_conn_ctrl_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t pre_conn_ctrl_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t pre_conn_ctrl_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t post_conn_ctrl_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t post_conn_ctrl_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t post_conn_ctrl_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t wps_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wps_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wps_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t interworking_serv_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t interworking_serv_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t interworking_serv_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t passpoint_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t passpoint_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t passpoint_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t wifi_client_report_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_client_report_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_client_report_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t wifi_client_def_report_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_client_def_report_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_client_def_report_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t default_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t default_set_param_value(char *event_name, raw_data_t *p_data); +bus_error_t default_table_add_row_handler(char const* tableName, char const* aliasName, uint32_t* instNum); +bus_error_t default_table_remove_row_handler(char const* rowName); +bus_error_t default_event_sub_handler(char *eventName, bus_event_sub_action_t action, int32_t interval, bool* autoPublish); + +bus_error_t wifi_region_code_get_param_value(char *event_name, raw_data_t *p_data); +bus_error_t wifi_region_code_set_param_value(char *event_name, raw_data_t *p_data); + +wifi_dml_data_model_t *get_dml_data_model_param(void); +#endif//WIFI_DATA_MODEL_H diff --git a/source/platform/common/data_model/wifi_data_model_parse.c b/source/platform/common/data_model/wifi_data_model_parse.c new file mode 100644 index 00000000..bceee7b4 --- /dev/null +++ b/source/platform/common/data_model/wifi_data_model_parse.c @@ -0,0 +1,513 @@ +#include +#include +#include +#include +#include "bus.h" +#include "wifi_data_model_parse.h" +#include "wifi_data_model.h" +#include "wifi_dml_api.h" + +int set_bus_callbackfunc_pointers(char *full_namespace, bus_callback_table_t *cb_table) +{ + bus_data_cb_func_t bus_data_cb[] = { + //wifi event cb func + { WIFI_OBJ_TREE_NAME, + { wifi_get_param_value, wifi_set_param_value, NULL, + NULL, wifi_event_sub_handler, NULL }}, + + //wifi radio event cb func + { RADIO_OBJ_TREE_NAME, + { radio_get_param_value, radio_set_param_value, radio_table_add_row_handler, + radio_table_remove_row_handler, radio_event_sub_handler, NULL }}, + + //wifi accesspoint event cb func + { ACCESSPOINT_OBJ_TREE_NAME, + { accesspoint_get_param_value, accesspoint_set_param_value, accesspoint_table_add_row_handler, + accesspoint_table_remove_row_handler, accesspoint_event_sub_handler, NULL }}, + + //wifi ssid event cb func + { SSID_OBJ_TREE_NAME, + { ssid_get_param_value, ssid_set_param_value, ssid_table_add_row_handler, + ssid_table_remove_row_handler, ssid_event_sub_handler, NULL }}, + + //wifi security event cb func + { SECURITY_OBJ_TREE_NAME, + { security_get_param_value, security_set_param_value, NULL, + NULL, security_event_sub_handler, NULL }}, + + //wifi radius security event cb func + { RADIUS_SEC_OBJ_TREE_NAME, + { radius_sec_get_param_value, radius_sec_set_param_value, NULL, + NULL, radius_sec_event_sub_handler, NULL }}, + + //wifi radius security event cb func + { AUTH_SEC_OBJ_TREE_NAME, + { auth_sec_get_param_value, auth_sec_set_param_value, NULL, + NULL, auth_sec_event_sub_handler, NULL }}, + + //wifi macfilter event cb func + { MACFILTER_OBJ_TREE_NAME, + { macfilter_get_param_value, macfilter_set_param_value, macfilter_table_add_row_handler, + macfilter_table_remove_row_handler, macfilter_event_sub_handler, NULL }}, + + //wifi associated_sta event cb func + { ASSOCIATED_STA_OBJ_TREE_NAME, + { associated_sta_get_param_value, NULL, associated_sta_table_add_row_handler, + associated_sta_table_remove_row_handler, associated_sta_event_sub_handler, NULL }}, + + //wifi interworking event cb func + { INTERWORKING_OBJ_TREE_NAME, + { interworking_get_param_value, interworking_set_param_value, NULL, + NULL, interworking_event_sub_handler, NULL }}, + + //wifi connection control event cb func + { CONN_CTRL_OBJ_TREE_NAME, + { conn_ctrl_get_param_value, conn_ctrl_set_param_value, NULL, + NULL, conn_ctrl_event_sub_handler, NULL }}, + + //wifi pre connection control event cb func + { PRE_CONN_CTRL_OBJ_TREE_NAME, + { pre_conn_ctrl_get_param_value, pre_conn_ctrl_set_param_value, NULL, + NULL, pre_conn_ctrl_event_sub_handler, NULL }}, + + //wifi post connection control event cb func + { POST_CONN_CTRL_OBJ_TREE_NAME, + { post_conn_ctrl_get_param_value, post_conn_ctrl_set_param_value, NULL, + NULL, post_conn_ctrl_event_sub_handler, NULL }}, + + //wifi wps event cb func + { WPS_OBJ_TREE_NAME, + { wps_get_param_value, wps_set_param_value, NULL, + NULL, wps_event_sub_handler, NULL }}, + + //wifi interworking serv event cb func + { INTERWORKING_SERV_OBJ_NAME, + { interworking_serv_get_param_value, interworking_serv_set_param_value, NULL, + NULL, interworking_serv_event_sub_handler, NULL }}, + + //wifi passpoint event cb func + { PASSPOINT_OBJ_TREE_NAME, + { passpoint_get_param_value, passpoint_set_param_value, NULL, + NULL, passpoint_event_sub_handler, NULL }}, + + //wifi client report event cb func + { WIFI_CLIENT_REPORT_OBJ_NAME, + { wifi_client_report_get_param_value, wifi_client_report_set_param_value, NULL, + NULL, wifi_client_report_event_sub_handler, NULL }}, + + //wifi client default report event cb func + { WIFI_CLIENT_DEF_REPORT_OBJ_NAME, + { wifi_client_def_report_get_param_value, wifi_client_def_report_set_param_value, NULL, + NULL, wifi_client_def_report_event_sub_handler, NULL }}, + + //wifi event cb func + { NEIG_WIFI_DIAG_OBJ_NAME, + { neig_wifi_diag_get_param_value, neig_wifi_diag_set_param_value, NULL, + NULL, neig_wifi_diag_event_sub_handler, NULL }}, + + //wifi event cb func + { NEIG_DIAG_RESULT_OBJ_NAME, + { neig_diag_result_get_param_value, NULL, + neig_diag_result_table_add_row_cb, neig_diag_result_table_remove_row_cb, + neig_diag_result_event_sub_cb, NULL }}, + + //wifi ap macfilter event cb func + { AP_MACFILTER_TREE_NAME, + { ap_macfilter_get_param_value, ap_macfilter_set_param_value, NULL, + NULL, ap_macfilter_event_sub_handler, NULL }}, + + //wifi region code event cb func + { WIFI_REGION_OBJ_NAME, + { wifi_region_code_get_param_value, wifi_region_code_set_param_value, NULL, + NULL, NULL, NULL }} + }; + + bus_data_cb_func_t bus_default_data_cb = { " ", + { default_get_param_value, default_set_param_value, default_table_add_row_handler, + default_table_remove_row_handler, default_event_sub_handler, NULL } + }; + + uint32_t index = 0; + bool table_found = false; + + for (index = 0; index < (uint32_t)ARRAY_SZ(bus_data_cb); index++) { + if (STR_CMP(full_namespace, bus_data_cb[index].cb_table_name)) { + memcpy(cb_table, &bus_data_cb[index].cb_func, sizeof(bus_callback_table_t)); + table_found = true; + break; + } + } + + if (table_found == false) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d:default cb set for namespace:[%s]\n", __func__, __LINE__, full_namespace); + memcpy(cb_table, &bus_default_data_cb.cb_func, sizeof(bus_callback_table_t)); + } + + return RETURN_OK; +} + +int bus_register_namespace(bus_handle_t *handle, char *full_namespace, bus_element_type_t element_type, + bus_callback_table_t cb_table, data_model_properties_t data_model_value, int num_of_rows) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: register_namespace:[%s] element_type:%d\n", __func__, __LINE__, full_namespace, element_type); + + bus_data_element_t dataElements = { 0 }; + + dataElements.full_name = full_namespace; + //snprintf(dataElements.full_name, BUS_MAX_NAME_LENGTH,"%s", full_namespace); + dataElements.type = element_type; + dataElements.cb_table = cb_table; + dataElements.bus_speed = slow_speed; + dataElements.data_model_prop = data_model_value; + + if (element_type == bus_element_type_table) { + //@TODO Add get handler to get table size. + uint32_t num_of_table_rows; + if (wifi_elem_num_of_table_row(full_namespace, &num_of_table_rows) == bus_error_success) { + dataElements.num_of_table_row = num_of_table_rows; + } else { + dataElements.num_of_table_row = num_of_rows; + } + wifi_util_info_print(WIFI_DMCLI,"%s:%d: Add number of row:%d input value:%d\n", __func__, __LINE__, dataElements.num_of_table_row, num_of_rows); + + //Tomporary added this @TODO TBD + if (strcmp(full_namespace, ACCESSPOINT_OBJ_TREE_NAME) == 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: register_namespace avoid for this:[%s]\n", __func__, __LINE__, full_namespace); + return 0; + } + } + +#if 0 + element_node_t *node = bus_insert_element(handle, handle->root_element, &dataElements); + if (node != NULL) { + node->data_model_value = data_model_value; + } +#else + uint32_t num_elements = 1; + + bus_error_t rc = get_bus_descriptor()->bus_reg_data_element_fn(handle, &dataElements, num_elements); + if (rc != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d bus: bus_regDataElements failed:%s\n", __func__, __LINE__, full_namespace); + } +#endif + + return RETURN_OK; +} + +int get_int_type_from_str(char *int_str_type, bus_data_type_t *data_format) +{ + if (!strncmp(int_str_type, "uint32_t", strlen("uint32_t"))) { + *data_format = bus_data_type_uint32; + } else if (!strncmp(int_str_type, "uint16_t", strlen("uint16_t"))) { + *data_format = bus_data_type_uint16; + } else if (!strncmp(int_str_type, "uint8_t", strlen("uint8_t"))) { + *data_format = bus_data_type_uint8; + } else if (!strncmp(int_str_type, "int32_t", strlen("int32_t"))) { + *data_format = bus_data_type_int32; + } else if (!strncmp(int_str_type, "int16_t", strlen("int16_t"))) { + *data_format = bus_data_type_int16; + } else if (!strncmp(int_str_type, "int8_t", strlen("int8_t"))) { + *data_format = bus_data_type_int8; + } else { + *data_format = bus_data_type_int32; + } + return RETURN_OK; +} + +int decode_definition_str_type(char *str_value, char *data_str_type, bus_data_type_t *data_format) +{ + if (!strncmp(str_value, "integer", strlen("integer"))) { + get_int_type_from_str(data_str_type, data_format); + } else if (!strncmp(str_value, "bool", strlen("bool"))) { + *data_format = bus_data_type_boolean; + } else if (!strncmp(str_value, "string", strlen("string"))) { + *data_format = bus_data_type_string; + } else if (!strncmp(str_value, "unsigned_int", strlen("unsigned_int"))) { + *data_format = bus_data_type_uint32; + } + + return RETURN_OK; +} + +int get_data_model_properties(cJSON *wifi_def_obj, char *data_str_type, data_model_properties_t *data_model_value) +{ + cJSON *param; + decode_json_param_object(wifi_def_obj, data_str_type, param); + + param = param->child; + while(param != NULL) { + if (!strncmp(param->string, "type", strlen("type"))) { + decode_definition_str_type(param->valuestring, data_str_type, &data_model_value->data_format); + } else if (!strncmp(param->string, "minimum", strlen("minimum"))) { + data_model_value->min_data_range = param->valuedouble; + } else if (!strncmp(param->string, "maximum", strlen("maximum"))) { + data_model_value->max_data_range = param->valuedouble; + } else if (!strncmp(param->string, "enum", strlen("enum"))) { + data_model_value->num_of_str_validation = cJSON_GetArraySize(param); + data_model_value->str_validation = malloc(sizeof(char *) * data_model_value->num_of_str_validation); + VERIFY_NULL_WITH_RETURN_INT(data_model_value->str_validation); + for (uint32_t i = 0; i < data_model_value->num_of_str_validation; i++) { + cJSON *item = cJSON_GetArrayItem(param, i); + if (item != NULL && cJSON_IsString(item)) { + data_model_value->str_validation[i] = malloc(strlen(item->valuestring) + 1); + strncpy(data_model_value->str_validation[i], item->valuestring, strlen(item->valuestring) + 1); + } + } + } + param = param->next; + } + + return RETURN_OK; +} + +static int add_array_node_elem(cJSON *main_array_obj, uint32_t num_of_elements, char *name_prefix, + cJSON *wifi_def_obj, bus_handle_t *handle, bus_callback_table_t cb_table) +{ + cJSON *current_element; + cJSON *param; + char full_namespace[128]; + bus_element_type_t element_type = bus_element_type_property; + data_model_properties_t data_model_value = { 0 }; + + for (uint32_t index = 0; index < num_of_elements; index++) { + current_element = cJSON_GetArrayItem(main_array_obj, index); + current_element = current_element->child; + VERIFY_NULL_WITH_RETURN_INT(current_element); + if (current_element->child != NULL) { + param = current_element->child; + if (strncmp(param->string, LIST_OF_DEFINITION_NAME, strlen(LIST_OF_DEFINITION_NAME)) == 0) { + uint32_t sub_num_of_elem = cJSON_GetArraySize(param); + bus_callback_table_t sub_elem_cb_table; + snprintf(full_namespace, sizeof(full_namespace), "%s.%s", name_prefix, current_element->string); + set_bus_callbackfunc_pointers(full_namespace, &sub_elem_cb_table); + add_array_node_elem(param, sub_num_of_elem, full_namespace, wifi_def_obj, handle, sub_elem_cb_table); + continue; + } else if (strncmp(param->string, MAX_NUM_OF_OBJECTS_NAME, strlen(MAX_NUM_OF_OBJECTS_NAME) + 1) == 0) { + uint32_t sub_num_of_elem = cJSON_GetArraySize(param->next); + uint32_t l_num_of_tables = param->valuedouble; + bus_element_type_t temp_element_type = bus_element_type_table; + bus_callback_table_t temp_cb_table, fetch_cb_table; + + //main table register + snprintf(full_namespace, sizeof(full_namespace), "%s.%s", name_prefix, current_element->string); + set_bus_callbackfunc_pointers(full_namespace, &fetch_cb_table); + + temp_cb_table = fetch_cb_table; + temp_cb_table.get_handler = NULL; + temp_cb_table.set_handler = NULL; + + strcat(full_namespace, ".{i}"); + memset(&data_model_value, 0, sizeof(data_model_value)); + bus_register_namespace(handle, full_namespace, temp_element_type, temp_cb_table, data_model_value, l_num_of_tables); + + //We don't need table handlers callback for table paramters. + fetch_cb_table.table_remove_row_handler = NULL; + fetch_cb_table.table_add_row_handler = NULL; + add_array_node_elem(param->next, sub_num_of_elem, full_namespace, wifi_def_obj, handle, fetch_cb_table); + continue; + } + } + snprintf(full_namespace, sizeof(full_namespace), "%s.%s", name_prefix, current_element->string); + decode_json_param_string(current_element, "type", param); + memset(&data_model_value, 0, sizeof(data_model_value)); + get_data_model_properties(wifi_def_obj, param->valuestring, &data_model_value); + decode_json_param_bool(current_element, "writable", param); + data_model_value.data_permission = (param->type & cJSON_True) ? true : false; + bus_register_namespace(handle, full_namespace, element_type, cb_table, data_model_value, 0); + } + return RETURN_OK; +} + +static int construct_namespace_and_register(bus_handle_t *handle, cJSON* cfg_param, cJSON *wifi_def_obj, char *l_name_prefix) +{ + bus_name_string_t name_prefix; + bus_element_type_t element_type = bus_element_type_property; + bus_callback_table_t cb_table = { 0 }; + data_model_properties_t data_model_value = { 0 }; + + strcpy(name_prefix, l_name_prefix); + wifi_util_info_print(WIFI_DMCLI,"%s:%d: namespace:%s\n", __func__, __LINE__, name_prefix); + + if (cJSON_IsObject(cfg_param) == true) { + //decode individual param and set it to bus. + cJSON *current_element = cfg_param->child; + cJSON *param; + cJSON *tmp; + char full_namespace[128]; + element_type = bus_element_type_method; + + set_bus_callbackfunc_pointers(name_prefix, &cb_table); + while(current_element != NULL) { + validate_current_json_obj_param_name(current_element); + snprintf(full_namespace, sizeof(full_namespace), "%s.%s", name_prefix, current_element->string); + tmp = current_element->child; + if (tmp->string != NULL && strncmp(tmp->string, LIST_OF_DEFINITION_NAME, strlen(LIST_OF_DEFINITION_NAME)) == 0) { + construct_namespace_and_register(handle, tmp, wifi_def_obj, full_namespace); + } else if (tmp->string != NULL && strncmp(tmp->string, MAX_NUM_OF_OBJECTS_NAME, strlen(MAX_NUM_OF_OBJECTS_NAME)) == 0) { + construct_namespace_and_register(handle, tmp->prev, wifi_def_obj, full_namespace); + } else { + decode_json_param_string(current_element, "type", param); + memset(&data_model_value, 0, sizeof(data_model_value)); + get_data_model_properties(wifi_def_obj, param->valuestring, &data_model_value); + decode_json_param_bool(current_element, "writable", param); + data_model_value.data_permission = (param->type & cJSON_True) ? true : false; + bus_register_namespace(handle, full_namespace, element_type, cb_table, data_model_value, 0); + } + current_element = current_element->next; + } + } else if (cJSON_IsArray(cfg_param) == true) { + int num_of_tables = 0; + + if (cfg_param->prev != NULL && cfg_param->prev->string != NULL) { + if ((strncmp(cfg_param->prev->string, MAX_NUM_OF_OBJECTS_NAME, strlen(MAX_NUM_OF_OBJECTS_NAME) + 1) == 0) + && (cJSON_IsNumber(cfg_param->prev) == true)) { + num_of_tables = cfg_param->prev->valuedouble; + } + } + + //snprintf(name_prefix, BUS_MAX_NAME_LENGTH, "%s.%s", name_prefix, "{i}"); + strcat(name_prefix, "."); + strcat(name_prefix, "{i}"); + element_type = bus_element_type_table; + set_bus_callbackfunc_pointers(name_prefix, &cb_table); + + bus_callback_table_t temp_cb_table = cb_table; + temp_cb_table.get_handler = NULL; + temp_cb_table.set_handler = NULL; + memset(&data_model_value, 0, sizeof(data_model_value)); + //main table register + bus_register_namespace(handle, name_prefix, element_type, temp_cb_table, data_model_value, num_of_tables); + + //We don't need table handlers callback for table paramters. + cb_table.table_remove_row_handler = NULL; + cb_table.table_add_row_handler = NULL; + + int num_of_elements = cJSON_GetArraySize(cfg_param); + cJSON *current_element; + + for (int index = 0; index < num_of_elements; index++) { + current_element = cJSON_GetArrayItem(cfg_param, index); + if (current_element == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s Item at index %d not found.\n", __func__, index); + continue; + } + + if(cJSON_IsObject(current_element) == true) { + construct_namespace_and_register(handle, current_element, wifi_def_obj, name_prefix); + } else { + uint32_t temp_num_of_elements = cJSON_GetArraySize(cfg_param); + add_array_node_elem(cfg_param, temp_num_of_elements, name_prefix, wifi_def_obj, handle, cb_table); + } + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: wrong wifi config object type\n", __func__, __LINE__); + return RETURN_ERR; + } + + return RETURN_OK; +} + +static void decode_wifi_object_recurse(bus_handle_t *handle, cJSON* node, cJSON *wifi_def_obj, char *l_name_prefix) +{ + VERIFY_NULL(node); + cJSON* child = node->child; + bus_name_string_t name_prefix; + char new_name_prefix[128]; + + snprintf(name_prefix, BUS_MAX_NAME_LENGTH, "%s", l_name_prefix); + + while(child) + { + cJSON* tmp = child; + if (tmp->string != NULL && strncmp(tmp->string, LIST_OF_DEFINITION_NAME, strlen(LIST_OF_DEFINITION_NAME)) == 0) { + construct_namespace_and_register(handle, tmp, wifi_def_obj, name_prefix); + child = child->next; + continue; + } + snprintf(new_name_prefix, sizeof(new_name_prefix), "%s.%s", name_prefix, tmp->string); + child = child->next; + decode_wifi_object_recurse(handle, tmp, wifi_def_obj, new_name_prefix); + } +} + +static int decode_wifi_objects(bus_handle_t *handle, cJSON *root_obj) +{ + if (root_obj == NULL) { + return RETURN_ERR; + } + cJSON *wifi_def_obj; + + decode_json_param_object(root_obj, WIFI_OBJ_DEFINITIONS_NAME, wifi_def_obj); + + cJSON* temp_obj = wifi_def_obj->next; + bus_name_string_t name_prefix; + + while(temp_obj) + { + cJSON* tmp = temp_obj; + snprintf(name_prefix, BUS_MAX_NAME_LENGTH, "%s", tmp->string); + temp_obj = temp_obj->next; + decode_wifi_object_recurse(handle, tmp, wifi_def_obj, name_prefix); + } + return RETURN_OK; +} + +int decode_json_obj(bus_handle_t *handle, const char *json_name) +{ + char *raw_buffer; + FILE *file = fopen(json_name, "r"); + if (file == NULL) { + wifi_util_error_print(WIFI_DMCLI,"Error: opening JSON file:%s\n", json_name); + perror("Error opening file"); + return RETURN_ERR; + } + + // Seek to the end of the file + fseek(file, 0, SEEK_END); + + // Get the current position (which is the size of the file) + size_t fileSize = ftell(file); + if ((long int)fileSize == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"Error getting file:%s size\n", json_name); + fclose(file); + return RETURN_ERR; + } + + raw_buffer = calloc(1, (fileSize + 1)); + printf("File size: %d bytes\n", fileSize); + + // Seek to the start of the file + fseek(file, 0, SEEK_SET); + size_t bytesRead = fread(raw_buffer, 1, fileSize, file); + fclose(file); + + if (fileSize != bytesRead) { + wifi_util_error_print(WIFI_DMCLI,"Error reading file:%s\n", json_name); + free(raw_buffer); + return RETURN_ERR; + } + + raw_buffer[fileSize] = '\0'; // Null terminate the string + + cJSON *root_json = cJSON_Parse(raw_buffer); + if (root_json == NULL) { + const char *error_ptr = cJSON_GetErrorPtr(); + if (error_ptr != NULL) { + wifi_util_error_print(WIFI_DMCLI,"Error before:%s\n", error_ptr); + } + wifi_util_error_print(WIFI_DMCLI,"JSON parse failure for file:%s\n", json_name); + free(raw_buffer); + cJSON_Delete(root_json); + return RETURN_ERR; + } + wifi_util_info_print(WIFI_DMCLI,"[%s]JSON parse success for file:%s\njson content:\n%s\n", __func__, + json_name, raw_buffer); + + decode_wifi_objects(handle, root_json); + + free(raw_buffer); + //cJSON_free(root_json); + cJSON_Delete(root_json); + + return RETURN_OK; +} diff --git a/source/platform/common/data_model/wifi_data_model_parse.h b/source/platform/common/data_model/wifi_data_model_parse.h new file mode 100644 index 00000000..621ee2c1 --- /dev/null +++ b/source/platform/common/data_model/wifi_data_model_parse.h @@ -0,0 +1,97 @@ +#ifndef WIFI_DATA_MODEL_PARSE_H +#define WIFI_DATA_MODEL_PARSE_H + +#include +#include +#include +#include "cJSON.h" +#include "bus_common.h" + +#define WIFI_OBJ_DEFINITIONS_NAME "definitions" +#define RADIO_OBJ_NAME "Radio" +#define ACCESSPOINT_OBJ_NAME "AccessPoint" + +#define LIST_OF_DEFINITION_NAME "List_Of_Def" +#define MAX_NUM_OF_OBJECTS_NAME "Num_Of_Objects" + +#define WIFI_OBJ_TREE_NAME "Device.WiFi" +#define NEIG_WIFI_DIAG_OBJ_NAME "Device.WiFi.NeighboringWiFiDiagnostic" +#define NEIG_DIAG_RESULT_OBJ_NAME "Device.WiFi.NeighboringWiFiDiagnostic.Result" +#define WIFI_REGION_OBJ_NAME "Device.WiFi.X_RDKCENTRAL-COM_Syndication.WiFiRegion" +#define WIFI_CLIENT_REPORT_OBJ_NAME "Device.WiFi.X_RDKCENTRAL-COM_Report.WifiClient" +#define WIFI_CLIENT_DEF_REPORT_OBJ_NAME "Device.WiFi.X_RDKCENTRAL-COM_Report.WifiClient.Default" +#define RADIO_OBJ_TREE_NAME "Device.WiFi.Radio.{i}" +#define ACCESSPOINT_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}" +#define SECURITY_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.Security" +#define RADIUS_SEC_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.Security.X_COMCAST-COM_RadiusSettings" +#define AUTH_SEC_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.Security.X_RDKCENTRAL-COM_Authenticator" +#define AP_MACFILTER_TREE_NAME "Device.WiFi.AccessPoint.{i}.X_CISCO_COM_MACFilter" +#define MACFILTER_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.X_CISCO_COM_MacFilterTable.{i}" +#define ASSOCIATED_STA_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}" +#define INTERWORKING_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.X_RDKCENTRAL-COM_InterworkingElement" +#define CONN_CTRL_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.ConnectionControl" +#define PRE_CONN_CTRL_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.ConnectionControl.PreAssocDeny" +#define POST_CONN_CTRL_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.ConnectionControl.PostAssocDisc" +#define WPS_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.WPS" +#define INTERWORKING_SERV_OBJ_NAME "Device.WiFi.AccessPoint.{i}.X_RDKCENTRAL-COM_InterworkingService" +#define PASSPOINT_OBJ_TREE_NAME "Device.WiFi.AccessPoint.{i}.X_RDKCENTRAL-COM_Passpoint" +#define SSID_OBJ_TREE_NAME "Device.WiFi.SSID.{i}" + +#define DML_GET_CB 1 +#define DML_SET_CB 2 + +#define decode_json_param_object(json, key, value) \ +{ \ + value = cJSON_GetObjectItem(json, key); \ + if ((value == NULL) || (cJSON_IsObject(value) == false)) { \ + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Validation failed for key:%s\n", __func__, __LINE__, key); \ + return RETURN_ERR; \ + } \ +} \ + +#define decode_json_param_string(json, key, value) \ +{ \ + value = cJSON_GetObjectItem(json, key); \ + if ((value == NULL) || (cJSON_IsString(value) == false) || \ + (value->valuestring == NULL) || (strcmp(value->valuestring, "") == 0)) { \ + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Validation failed for key:%s\n", __func__, __LINE__, key); \ + return RETURN_ERR; \ + } \ +} \ + +#define decode_json_param_integer(json, key, value) \ +{ \ + value = cJSON_GetObjectItem(json, key); \ + if ((value == NULL) || (cJSON_IsNumber(value) == false)) { \ + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Validation failed for key:%s\n", __func__, __LINE__, key); \ + return RETURN_ERR; \ + } \ +} \ + +#define validate_current_json_obj_param_name(json) \ +{ \ + if (json == NULL || json->string == NULL) { \ + wifi_util_error_print(WIFI_DMCLI,"%s:%d: current json obj param name not found\n", __func__, __LINE__); \ + return RETURN_ERR; \ + } \ +} \ + +#define decode_json_param_bool(json, key, value) \ +{ \ + value = cJSON_GetObjectItem(json, key); \ + if ((value == NULL) || (cJSON_IsBool(value) == false)) { \ + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Validation failed for key:%s\n", __func__, __LINE__, key); \ + return RETURN_ERR; \ + } \ +} \ + +#define get_func_address dlsym + +typedef struct bus_data_cb_func { + char *cb_table_name; + bus_callback_table_t cb_func; +} bus_data_cb_func_t; + +int decode_json_obj(bus_handle_t *handle, const char *json_name); + +#endif //WIFI_DATA_MODEL_PARSE_H diff --git a/source/platform/common/data_model/wifi_dml_api.c b/source/platform/common/data_model/wifi_dml_api.c new file mode 100644 index 00000000..fe2c16cd --- /dev/null +++ b/source/platform/common/data_model/wifi_dml_api.c @@ -0,0 +1,1928 @@ +#include "scheduler.h" +#include "wifi_dml_api.h" +#include "wifi_stubs.h" +#include "wifi_util.h" +#include "dml_onewifi_api.h" +#include "wifi_events.h" +#include "wifi_ctrl.h" +#include "wifi_mgr.h" +#include +#include +#include +#include +#include +#include +#include + +extern sem_t *sem; + +#define PARTNERS_INFO_FILE "/nvram/partners_defaults.json" +#define BOOTSTRAP_INFO_FILE "/nvram/bootstrap.json" + +int set_output_string(scratch_data_buff_t *output_value, char *str) +{ + if (str == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: input string buffer is NULL\n",__func__, __LINE__); + return RETURN_ERR; + } else if (output_value == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: output buffer is NULL:%s\n",__func__, __LINE__, str); + return RETURN_ERR; + } + + uint32_t str_size = strlen(str) + 1; + + if (output_value->buff == NULL) { + output_value->buff = malloc(str_size); + } + + if (str_size > 1) { + strncpy(output_value->buff, str, str_size); + } else { + memset(output_value->buff, 0, str_size); + } + output_value->buff_len = str_size; + return RETURN_OK; +} + +uint32_t get_sec_mode_string_from_int(wifi_security_modes_t security_mode, char *security_name) +{ + uint32_t index; + wifi_sec_mode_hal_map_t wifi_sec_mode_map[] = { + { wifi_security_mode_none, "None" }, + { wifi_security_mode_wep_64, "WEP_64" }, + { wifi_security_mode_wep_128, "WEP_128" }, + { wifi_security_mode_wpa_personal, "WPA-Personal" }, + { wifi_security_mode_wpa2_personal, "WPA2-Personal" }, + { wifi_security_mode_wpa3_personal, "WPA3-Personal" }, + { wifi_security_mode_wpa_wpa2_personal, "WPA-WPA2-Personal" }, + { wifi_security_mode_wpa3_transition, "WPA3-Personal-Transition" }, + { wifi_security_mode_wpa_enterprise, "WPA-Enterprise" }, + { wifi_security_mode_wpa2_enterprise, "WPA2-Enterprise" }, + { wifi_security_mode_wpa3_enterprise, "WPA3-Enterprise" }, + { wifi_security_mode_wpa_wpa2_enterprise, "WPA-WPA2-Enterprise" }, + { wifi_security_mode_enhanced_open, "Enhanced-Open" } + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_sec_mode_map) ; index++) { + if (security_mode & wifi_sec_mode_map[index].hal_sec_mode) { + if (strlen(security_name) != 0) { + strcat(security_name, ","); + strcat(security_name, wifi_sec_mode_map[index].str_sec_mode); + } else { + strcpy(security_name, wifi_sec_mode_map[index].str_sec_mode); + } + } + } + + if (strlen(security_name) == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid Security type:%d enum\n",__func__, __LINE__, security_mode); + } else { + return strlen(security_name) + 1; + } + + return 0; +} + +int get_sec_mode_int_from_string(const char *p_sec_name, wifi_security_modes_t *p_sec_mode) +{ + DM_CHECK_NULL_WITH_RC(p_sec_name, 0); + DM_CHECK_NULL_WITH_RC(p_sec_mode, 0); + uint32_t index; + wifi_sec_mode_hal_map_t wifi_sec_mode_map[] = { + { wifi_security_mode_none, "None" }, + { wifi_security_mode_wep_64, "WEP_64" }, + { wifi_security_mode_wep_128, "WEP_128" }, + { wifi_security_mode_wpa_personal, "WPA-Personal" }, + { wifi_security_mode_wpa2_personal, "WPA2-Personal" }, + { wifi_security_mode_wpa3_personal, "WPA3-Personal" }, + { wifi_security_mode_wpa_wpa2_personal, "WPA-WPA2-Personal" }, + { wifi_security_mode_wpa3_transition, "WPA3-Personal-Transition" }, + { wifi_security_mode_wpa_enterprise, "WPA-Enterprise" }, + { wifi_security_mode_wpa2_enterprise, "WPA2-Enterprise" }, + { wifi_security_mode_wpa3_enterprise, "WPA3-Enterprise" }, + { wifi_security_mode_wpa_wpa2_enterprise, "WPA-WPA2-Enterprise" }, + { wifi_security_mode_enhanced_open, "Enhanced-Open" } + }; + + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_sec_mode_map) ; index++) { + if(STR_CMP(p_sec_name, wifi_sec_mode_map[index].str_sec_mode)) { + *p_sec_mode = wifi_sec_mode_map[index].hal_sec_mode; + return wifi_sec_mode_map[index].hal_sec_mode; + } + } + + return 0; +} + +int get_sec_modes_supported(int vap_index, int *mode) +{ + int band; + uint32_t radio_index; + wifi_vap_info_t *vap_info; + bool passpoint_enabled; + + radio_index = getRadioIndexFromAp((unsigned int)vap_index); + if (convert_radio_index_to_freq_band(&get_webconfig_dml()->hal_cap.wifi_prop, radio_index, + &band) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d failed to convert radio index %u to band\n", + __func__, __LINE__, radio_index); + return RETURN_ERR; + } + + vap_info = get_dml_cache_vap_info(vap_index); + if (vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d failed to get vap info for index %d\n", + __func__, __LINE__, vap_index); + return RETURN_ERR; + } + passpoint_enabled = vap_info->u.bss_info.interworking.passpoint.enable; + + if (band == WIFI_FREQUENCY_6_BAND) { + *mode = passpoint_enabled ? wifi_security_mode_wpa3_enterprise : + wifi_security_mode_wpa3_personal | wifi_security_mode_wpa3_enterprise | + wifi_security_mode_enhanced_open; + } else if (passpoint_enabled) { + *mode = wifi_security_mode_wpa_enterprise | wifi_security_mode_wpa2_enterprise | + wifi_security_mode_wpa_wpa2_enterprise | wifi_security_mode_wpa3_enterprise; + } else { + *mode = wifi_security_mode_none | wifi_security_mode_enhanced_open | + wifi_security_mode_wpa_personal | wifi_security_mode_wpa_enterprise | + wifi_security_mode_wpa2_personal | wifi_security_mode_wpa2_enterprise | + wifi_security_mode_wpa_wpa2_personal | wifi_security_mode_wpa_wpa2_enterprise | + wifi_security_mode_wpa3_personal | wifi_security_mode_wpa3_transition | + wifi_security_mode_wpa3_enterprise; + } + + return RETURN_OK; +} + +int get_mfp_type_from_string(const char *p_mfp_name, wifi_mfp_cfg_t *p_mfp_type) +{ + int ret = RETURN_ERR; + uint32_t counter = 0; + DM_CHECK_NULL_WITH_RC(p_mfp_name, ret); + DM_CHECK_NULL_WITH_RC(p_mfp_type, ret); + + wifi_sec_mfp_hal_map_t wifi_sec_mfp_map[] = { + { wifi_mfp_cfg_disabled, "Disabled" }, + { wifi_mfp_cfg_optional, "Optional" }, + { wifi_mfp_cfg_required, "Required" }, + }; + + for (counter = 0 ; counter < (uint32_t)ARRAY_SZ(wifi_sec_mfp_map) ; ++counter) { + if(STR_CMP(p_mfp_name, wifi_sec_mfp_map[counter].str_sec_mfp)) { + *p_mfp_type = wifi_sec_mfp_map[counter].hal_sec_mfp; + return RETURN_OK; + } + } + return ret; +} + +int get_sec_encr_int_from_string(const char *p_sec_encr_name, wifi_encryption_method_t *p_sec_encr_type) +{ + int ret = RETURN_ERR; + uint32_t counter = 0; + DM_CHECK_NULL_WITH_RC(p_sec_encr_name, ret); + DM_CHECK_NULL_WITH_RC(p_sec_encr_type, ret); + + wifi_sec_encr_hal_map_t wifi_sec_encr_map[] = { + { wifi_encryption_none, "NONE" }, + { wifi_encryption_tkip, "TKIP" }, + { wifi_encryption_aes, "AES" }, + { wifi_encryption_aes_tkip, "AES+TKIP" } + }; + + for (counter = 0 ; counter < (uint32_t)ARRAY_SZ(wifi_sec_encr_map) ; ++counter) { + if(STR_CMP(p_sec_encr_name, wifi_sec_encr_map[counter].str_sec_encr_type)) { + *p_sec_encr_type = wifi_sec_encr_map[counter].hal_sec_encr_method; + return RETURN_OK; + } + } + return ret; +} + +int get_sec_encr_string_from_int(wifi_encryption_method_t l_sec_encr_type, char *p_sec_encr_name) +{ + DM_CHECK_NULL_WITH_RC(p_sec_encr_name, 0); + + uint32_t index; + bool str_found = false; + wifi_sec_encr_hal_map_t wifi_sec_encr_map[] = { + { wifi_encryption_none, "NONE" }, + { wifi_encryption_tkip, "TKIP" }, + { wifi_encryption_aes, "AES" }, + { wifi_encryption_aes_tkip, "AES+TKIP" } + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_sec_encr_map) ; index++) { + if(l_sec_encr_type == wifi_sec_encr_map[index].hal_sec_encr_method) { + STR_COPY(p_sec_encr_name, wifi_sec_encr_map[index].str_sec_encr_type); + str_found = true; + } + } + + if(str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid Security type:%d enum\n",__func__, __LINE__, l_sec_encr_type); + } else { + return strlen(p_sec_encr_name) + 1; + } + + return 0; +} + +int get_radio_band_string_from_int(wifi_freq_bands_t l_radio_band, char *p_str_radio_band) +{ + wifi_freq_band_hal_map_t wifi_freq_band[] = { + { WIFI_FREQUENCY_2_4_BAND, "2.4GHz"}, + { WIFI_FREQUENCY_5_BAND, "5GHz"}, + { WIFI_FREQUENCY_5L_BAND, "Low 5GHz"}, + { WIFI_FREQUENCY_5H_BAND, "High 5Ghz"}, + { WIFI_FREQUENCY_6_BAND, "6GHz"}, + { WIFI_FREQUENCY_60_BAND, "60GHz"} + }; + uint32_t index = 0; + int ret = RETURN_ERR; + + DM_CHECK_NULL_WITH_RC(p_str_radio_band, ret); + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_freq_band); index++) { + if (l_radio_band == wifi_freq_band[index].hal_wifi_freq_band) { + STR_COPY(p_str_radio_band, wifi_freq_band[index].str_wifi_freq_band); + ret = RETURN_OK; + break; + } + } + + if (ret != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s invalid band input:%d str freq band:%s\n", __func__, + l_radio_band, p_str_radio_band); + } + + return ret; +} + +int get_radio_band_int_from_string(const char *p_str_radio_band, wifi_freq_bands_t *p_radio_band) +{ + wifi_freq_band_hal_map_t wifi_freq_band[] = { + { WIFI_FREQUENCY_2_4_BAND, "2.4GHz"}, + { WIFI_FREQUENCY_5_BAND, "5GHz"}, + { WIFI_FREQUENCY_5L_BAND, "Low 5GHz"}, + { WIFI_FREQUENCY_5H_BAND, "High 5Ghz"}, + { WIFI_FREQUENCY_6_BAND, "6GHz"}, + { WIFI_FREQUENCY_60_BAND, "60GHz"} + }; + uint32_t index = 0; + int ret = RETURN_ERR; + + DM_CHECK_NULL_WITH_RC(p_str_radio_band, ret); + DM_CHECK_NULL_WITH_RC(p_radio_band, ret); + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_freq_band); index++) { + if (STR_CMP((char *)p_str_radio_band, wifi_freq_band[index].str_wifi_freq_band)) { + *p_radio_band = wifi_freq_band[index].hal_wifi_freq_band; + wifi_util_dbg_print(WIFI_DMCLI,"%s input :%s freq band:%d\n", __func__, p_str_radio_band, *p_radio_band); + return RETURN_OK; + } + } + + return ret; +} + +int get_radio_bandwidth_int_from_string(const char *p_chan_width_name, wifi_channelBandwidth_t *p_chan_width) +{ + int ret = RETURN_ERR; + DM_CHECK_NULL_WITH_RC(p_chan_width_name, ret); + DM_CHECK_NULL_WITH_RC(p_chan_width, ret); + + wifi_chan_width_hal_map_t wifi_chan_width_map[] = { + { WIFI_CHANNELBANDWIDTH_20MHZ, "20MHz" }, + { WIFI_CHANNELBANDWIDTH_40MHZ, "40MHz" }, + { WIFI_CHANNELBANDWIDTH_80MHZ, "80MHz" }, + { WIFI_CHANNELBANDWIDTH_160MHZ, "160MHz" }, + { WIFI_CHANNELBANDWIDTH_80_80MHZ, "80+80MHz" }, +#ifdef CONFIG_IEEE80211BE + { WIFI_CHANNELBANDWIDTH_320MHZ, "320MHz" } +#endif /* CONFIG_IEEE80211BE */ + }; + uint32_t index; + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_chan_width_map); index++) { + if (STR_CMP(p_chan_width_name, wifi_chan_width_map[index].str_wifi_chan_width)) { + *p_chan_width = wifi_chan_width_map[index].hal_wifi_chan_width; + return RETURN_OK; + } + } + + return ret; +} + +int get_radio_bandwidth_string_from_int(wifi_channelBandwidth_t l_chan_width, char *p_chan_width_name) +{ + DM_CHECK_NULL_WITH_RC(p_chan_width_name, 0); + + wifi_chan_width_hal_map_t wifi_chan_width_map[] = { + { WIFI_CHANNELBANDWIDTH_20MHZ, "20MHz" }, + { WIFI_CHANNELBANDWIDTH_40MHZ, "40MHz" }, + { WIFI_CHANNELBANDWIDTH_80MHZ, "80MHz" }, + { WIFI_CHANNELBANDWIDTH_160MHZ, "160MHz" }, + { WIFI_CHANNELBANDWIDTH_80_80MHZ, "80+80MHz" }, +#ifdef CONFIG_IEEE80211BE + { WIFI_CHANNELBANDWIDTH_320MHZ, "320MHz" } +#endif /* CONFIG_IEEE80211BE */ + }; + bool str_found = false; + uint32_t index; + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_chan_width_map); index++) { + if (l_chan_width == wifi_chan_width_map[index].hal_wifi_chan_width) { + STR_COPY(p_chan_width_name, wifi_chan_width_map[index].str_wifi_chan_width); + wifi_util_dbg_print(WIFI_DMCLI, "%s:%d inputBw: %d str bw:[%s]\n", + __func__, __LINE__, l_chan_width, wifi_chan_width_map[index].str_wifi_chan_width); + str_found = true; + break; + } + } + + if (str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid radio bandwidth:%d\n",__func__, __LINE__, l_chan_width); + } else { + return strlen(p_chan_width_name) + 1; + } + + return 0; +} + +int get_radio_guard_interval_int_from_string(const char *p_guard_interval_name, wifi_guard_interval_t *p_guard_interval) +{ + int ret = RETURN_ERR; + uint32_t index = 0; + DM_CHECK_NULL_WITH_RC(p_guard_interval_name, ret); + DM_CHECK_NULL_WITH_RC(p_guard_interval, ret); + + wifi_guard_interval_map_t wifi_guard_interval[] ={ + { wifi_guard_interval_400, "400ns" }, + { wifi_guard_interval_800, "800ns" }, + { wifi_guard_interval_1600, "1600ns" }, + { wifi_guard_interval_3200, "3200ns" }, + { wifi_guard_interval_auto, "Auto" } + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_guard_interval) ; index++) { + if(STR_CMP(p_guard_interval_name, wifi_guard_interval[index].str_guard_interval)) { + *p_guard_interval = wifi_guard_interval[index].hal_guard_interval; + return RETURN_OK; + } + } + return ret; +} + +int get_radio_guard_interval_string_from_int(wifi_guard_interval_t l_guard_interval, char *p_guard_interval_name) +{ + DM_CHECK_NULL_WITH_RC(p_guard_interval_name, 0); + + uint32_t index; + bool str_found = false; + wifi_guard_interval_map_t wifi_guard_interval[] ={ + { wifi_guard_interval_400, "400ns" }, + { wifi_guard_interval_800, "800ns" }, + { wifi_guard_interval_1600, "1600ns" }, + { wifi_guard_interval_3200, "3200ns" }, + { wifi_guard_interval_auto, "Auto" } + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_guard_interval) ; index++) { + if(l_guard_interval == wifi_guard_interval[index].hal_guard_interval) { + STR_COPY(p_guard_interval_name, wifi_guard_interval[index].str_guard_interval); + str_found = true; + } + } + + if(str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid guard interval:%d\n",__func__, __LINE__, l_guard_interval); + } else { + return strlen(p_guard_interval_name) + 1; + } + + return 0; +} + +int get_radio_variant_string_from_int(wifi_ieee80211Variant_t l_radio_variant, char *p_radio_variant_name) +{ + DM_CHECK_NULL_WITH_RC(p_radio_variant_name, 0); + + uint32_t index; + bool str_found = false; + wifi_variant_hal_map_t wifi_variant_map[] = { + { WIFI_80211_VARIANT_A, "a" }, + { WIFI_80211_VARIANT_B, "b" }, + { WIFI_80211_VARIANT_G, "g" }, + { WIFI_80211_VARIANT_N, "n" }, + { WIFI_80211_VARIANT_H, "h" }, + { WIFI_80211_VARIANT_AC, "ac" }, + { WIFI_80211_VARIANT_AD, "ad" }, + { WIFI_80211_VARIANT_AX, "ax" }, +#ifdef CONFIG_IEEE80211BE + { WIFI_80211_VARIANT_BE, "be" } +#endif /* CONFIG_IEEE80211BE */ + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_variant_map) ; index++) { + if (l_radio_variant & wifi_variant_map[index].hal_radio_variant) + { + if (str_found == false) { + STR_COPY(p_radio_variant_name, wifi_variant_map[index].str_radio_variant); + } else { + STR_CAT(p_radio_variant_name, ","); + STR_CAT(p_radio_variant_name, wifi_variant_map[index].str_radio_variant); + } + str_found = true; + } + } + + if(str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid radio variant type:%d enum\n",__func__, __LINE__, l_radio_variant); + } else { + return strlen(p_radio_variant_name) + 1; + } + + return 0; +} + +int get_radio_variant_int_from_string(const char *p_radio_variant_name, wifi_ieee80211Variant_t *p_radio_variant) +{ + int ret = RETURN_ERR; + DM_CHECK_NULL_WITH_RC(p_radio_variant_name, ret); + DM_CHECK_NULL_WITH_RC(p_radio_variant, ret); + + wifi_variant_hal_map_t wifi_variant_map[] = { + { WIFI_80211_VARIANT_A, "a" }, + { WIFI_80211_VARIANT_B, "b" }, + { WIFI_80211_VARIANT_G, "g" }, + { WIFI_80211_VARIANT_N, "n" }, + { WIFI_80211_VARIANT_H, "h" }, + { WIFI_80211_VARIANT_AC, "ac" }, + { WIFI_80211_VARIANT_AD, "ad" }, + { WIFI_80211_VARIANT_AX, "ax" }, +#ifdef CONFIG_IEEE80211BE + { WIFI_80211_VARIANT_BE, "be" } +#endif /* CONFIG_IEEE80211BE */ + }; + + uint32_t index = 0; + bool is_radio_variant_invalid = true; + char *token; + char tmp_input_string[64] = {0}; + + *p_radio_variant = 0; + snprintf(tmp_input_string, sizeof(tmp_input_string), "%s", p_radio_variant_name); + + token = strtok(tmp_input_string, ","); + while (token != NULL) + { + + is_radio_variant_invalid = TRUE; + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_variant_map); index++) + { + if (STR_CMP(token, wifi_variant_map[index].str_radio_variant)) + { + *p_radio_variant |= wifi_variant_map[index].hal_radio_variant; + wifi_util_dbg_print(WIFI_DMCLI,"%s input:%s radio_variant:%d\n", __func__, + p_radio_variant_name, *p_radio_variant); + is_radio_variant_invalid = FALSE; + } + } + + if (is_radio_variant_invalid == TRUE) + { + wifi_util_error_print(WIFI_DMCLI,"%s Invalid Wifi Standard:%s\n", __func__, p_radio_variant_name); + return ret; + } + + token = strtok(NULL, ","); + } + return RETURN_OK; +} + +int radio_wifi_channel_is_valid(uint32_t radio_index, uint32_t input_channel) +{ + uint32_t arr_len = 0; + uint32_t seq_counter = 0; + wifi_radio_capabilities_t *p_radio_cap = NULL; + uint32_t band_arr_index = 0; + bool is_band_found = false; + wifi_radio_operationParam_t *p_radio_cfg = NULL; + wifi_radio_operationParam_t l_pcfg; + + //Get the radio capability for further comparision + p_radio_cap = getRadioCapability(radio_index); + if (p_radio_cap == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s Failed for unable to get RadioCapability wlan_Index=%d\n", __func__, radio_index); + return RETURN_ERR; + } + + wifi_util_dbg_print(WIFI_DMCLI,"%s %d for radio_index : %d\n", __func__, __LINE__, radio_index); + //Get the RadioOperation structure + p_radio_cfg = getRadioOperationParam(radio_index); + if (p_radio_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s Input radio_index = %d not found for p_radio_cfg\n", __func__, radio_index); + return RETURN_ERR; + } + memcpy(&l_pcfg, p_radio_cfg, sizeof(l_pcfg)); + p_radio_cfg = &l_pcfg; + + //Compare the Band from capability and operation + for (band_arr_index = 0; band_arr_index < p_radio_cap->numSupportedFreqBand; band_arr_index++) { + if (p_radio_cap->band[band_arr_index] == p_radio_cfg->band) { + wifi_util_info_print(WIFI_DMCLI,"%s Band = %d is present at array index of cap:%d\n", __func__, + p_radio_cfg->band, band_arr_index); + is_band_found = true; + break; + } + } + + if (is_band_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s Input radio_index=%d Band=%d is not found in cap\n", __func__, + radio_index, p_radio_cfg->band); + return RETURN_ERR; + } + + arr_len = p_radio_cap->channel_list[band_arr_index].num_channels; + for (seq_counter = 0; seq_counter < arr_len; seq_counter++) { + if (input_channel == (uint32_t)p_radio_cap->channel_list[band_arr_index].channels_list[seq_counter]) { + wifi_util_info_print(WIFI_DMCLI,"%s %d For radio_index:%d input_channel:%d is supported\n", __func__, + __LINE__, radio_index, input_channel); + return RETURN_OK; + } + } + wifi_util_error_print(WIFI_DMCLI,"%s Failed for radio_index:%d for input_channel:%d\n", __func__, + radio_index, input_channel); + return RETURN_ERR; +} + +bool is_radio_tx_power_valid(char *p_supported_power_list, int l_tx_power) +{ + DM_CHECK_NULL_WITH_RC(p_supported_power_list, false); + + char power_list[64] = {0} , *tok; + size_t power_list_size = strlen(p_supported_power_list) + 1; + + if ((power_list_size == 0) || (power_list_size >= sizeof(power_list))) + { + wifi_util_error_print(WIFI_DMCLI,"%s: failed to get supported Transmit power list:%d\n", __func__, power_list_size); + return false; + } + strncpy(power_list, p_supported_power_list, power_list_size); + tok = strtok(power_list, ","); + while (tok) { + if (atoi(tok) == l_tx_power) { + return true; + } + tok = strtok(NULL, ","); + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d Given Tx power value:%d is not supported and supported values:%s\n",__func__, + __LINE__, l_tx_power, p_supported_power_list); + return false; +} + +uint32_t get_reg_domain_string_from_int(wifi_countrycode_type_t l_country_code, + wifi_operating_env_t l_oper_env, char *str_reg_domain) +{ + DM_CHECK_NULL_WITH_RC(str_reg_domain, 0); + unsigned int i; + char tmp_country_str[4]; + char tmp_environment[4]; + + memset(tmp_country_str, 0, sizeof(tmp_country_str)); + memset(tmp_environment, 0, sizeof(tmp_environment)); + for (i = 0 ; i < (uint32_t)ARRAY_SZ(wifiCountryMapMembers); ++i) { + if (l_country_code == wifiCountryMapMembers[i].countryCode) { + strncpy(tmp_country_str, wifiCountryMapMembers[i].countryStr, sizeof(tmp_country_str)-1); + break; + } + } + + for (i = 0; i < (uint32_t)ARRAY_SZ(wifiEnviromentMap); ++i) { + if (l_oper_env == wifiEnviromentMap[i].operatingEnvironment) { + strncpy(tmp_environment, wifiEnviromentMap[i].environment, sizeof(wifiEnviromentMap[i].environment)-1); + break; + } + } + + snprintf(str_reg_domain, 4, "%s%s", tmp_country_str, tmp_environment); + if (strlen(str_reg_domain) == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s Invalid Country code enum:%d\n", __func__, l_country_code); + return 0; + } + return strlen(str_reg_domain) + 1; +} + +int get_reg_domain_int_from_string(const char *p_reg_domain, wifi_countrycode_type_t *p_country_code, + wifi_operating_env_t *p_oper_env) +{ + int ret = RETURN_ERR; + DM_CHECK_NULL_WITH_RC(p_reg_domain, ret); + DM_CHECK_NULL_WITH_RC(p_country_code, ret); + DM_CHECK_NULL_WITH_RC(p_oper_env, ret); + + uint32_t index = 0; + bool str_found = false; + char tmp_reg_domain_str[REG_DOMAIN_SZ+1]; + char environment[ENV_SZ+1] = {'I', '\0'}; + unsigned int len = 0; + + len = strlen(p_reg_domain); + if ((len > REG_DOMAIN_SZ) || (len < ENV_SZ)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid country code \n", __func__, __LINE__); + return ret; + } + + memset(tmp_reg_domain_str, 0, sizeof(tmp_reg_domain_str)); + strncpy(tmp_reg_domain_str, p_reg_domain, sizeof(tmp_reg_domain_str)-1); + environment[0] = tmp_reg_domain_str[REG_DOMAIN_SZ-1]; + if (environment[0] == '\0') { + environment[0] = ' '; + } else if(environment[0] != 'I' && environment[0] != 'O' && environment[0] != ' ' && environment[0] != 'X') { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid environment \n", __func__, __LINE__); + return ret; + } + + tmp_reg_domain_str[REG_DOMAIN_SZ-1] = '\0'; + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifiCountryMapMembers); index++) { + if (STR_CMP(tmp_reg_domain_str, wifiCountryMapMembers[index].countryStr)) { + *p_country_code = wifiCountryMapMembers[index].countryCode; + wifi_util_info_print(WIFI_DMCLI,"%s input:%s Countrycode:%d\n", __func__, p_reg_domain, *p_country_code); + str_found = true; + break; + } + } + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifiEnviromentMap); index++) { + if (STR_CMP(environment, wifiEnviromentMap[index].environment)) { + *p_oper_env = wifiEnviromentMap[index].operatingEnvironment; + wifi_util_info_print(WIFI_DMCLI,"%s input:%s OperatingEnvironment:%d\n", __func__, p_reg_domain, *p_oper_env); + str_found = true; + break; + } + } + + if (str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s Invalid Regulatory Domain:%s\n", __func__, p_reg_domain); + return ret; + } + + return RETURN_OK; +} + +int get_wifi_data_tx_rate_int_from_string(const char *p_tx_rate_name, wifi_bitrate_t *p_tx_rate) +{ + int ret = RETURN_ERR; + uint32_t index = 0; + char *token; + bool is_rate_invalid = true; + char tmp_input_str[64] = {0}; + DM_CHECK_NULL_WITH_RC(p_tx_rate_name, ret); + DM_CHECK_NULL_WITH_RC(p_tx_rate, ret); + + wifi_data_tx_rate_hal_map_t wifi_data_tx_rate[] = { + { WIFI_BITRATE_DEFAULT, "Default" }, + { WIFI_BITRATE_1MBPS, "1" }, + { WIFI_BITRATE_2MBPS, "2" }, + { WIFI_BITRATE_5_5MBPS, "5.5" }, + { WIFI_BITRATE_6MBPS, "6" }, + { WIFI_BITRATE_9MBPS, "9" }, + { WIFI_BITRATE_11MBPS, "11" }, + { WIFI_BITRATE_12MBPS, "12" }, + { WIFI_BITRATE_18MBPS, "18" }, + { WIFI_BITRATE_24MBPS, "24" }, + { WIFI_BITRATE_36MBPS, "36" }, + { WIFI_BITRATE_48MBPS, "48" }, + { WIFI_BITRATE_54MBPS, "54" } + }; + + snprintf(tmp_input_str, sizeof(tmp_input_str), "%s", p_tx_rate_name); + token = strtok(tmp_input_str, ","); + while (token != NULL) { + is_rate_invalid = true; + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_data_tx_rate); index++) { + if (STR_CMP(token, wifi_data_tx_rate[index].str_data_tx_rate)) { + *p_tx_rate |= wifi_data_tx_rate[index].hal_data_tx_rate; + is_rate_invalid = false; + } + } + + if (is_rate_invalid == true) { + wifi_util_info_print(WIFI_DMCLI,"%s Invalid txrate Token : %s\n", __func__, token); + return ret; + } + + token = strtok(NULL, ","); + } + + return RETURN_OK; +} + +uint32_t get_wifi_data_tx_rate_string_from_int(wifi_bitrate_t l_tx_rate, char *p_tx_rate_name) +{ + DM_CHECK_NULL_WITH_RC(p_tx_rate_name, 0); + + uint32_t index; + bool str_found = false; + wifi_data_tx_rate_hal_map_t wifi_data_tx_rate[] = { + { WIFI_BITRATE_DEFAULT, "Default" }, + { WIFI_BITRATE_1MBPS, "1" }, + { WIFI_BITRATE_2MBPS, "2" }, + { WIFI_BITRATE_5_5MBPS, "5.5" }, + { WIFI_BITRATE_6MBPS, "6" }, + { WIFI_BITRATE_9MBPS, "9" }, + { WIFI_BITRATE_11MBPS, "11" }, + { WIFI_BITRATE_12MBPS, "12" }, + { WIFI_BITRATE_18MBPS, "18" }, + { WIFI_BITRATE_24MBPS, "24" }, + { WIFI_BITRATE_36MBPS, "36" }, + { WIFI_BITRATE_48MBPS, "48" }, + { WIFI_BITRATE_54MBPS, "54" } + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_data_tx_rate) ; index++) { + if(l_tx_rate & wifi_data_tx_rate[index].hal_data_tx_rate) { + if (str_found == false) { + STR_COPY(p_tx_rate_name, wifi_data_tx_rate[index].str_data_tx_rate); + } else { + STR_CAT(p_tx_rate_name, ","); + STR_CAT(p_tx_rate_name, wifi_data_tx_rate[index].str_data_tx_rate); + } + str_found = true; + } + } + + if(str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid data tx rate:%d\n",__func__, __LINE__, l_tx_rate); + } else { + return strlen(p_tx_rate_name) + 1; + } + + return 0; +} + +uint32_t get_beacon_rate_string_from_int(wifi_bitrate_t beacon_type, char *beacon_name) +{ + uint32_t index = 0; + wifi_data_tx_rate_hal_map_t wifi_data_tx_rate[] = { + { WIFI_BITRATE_DEFAULT, "Default" }, + { WIFI_BITRATE_1MBPS, "1" }, + { WIFI_BITRATE_2MBPS, "2" }, + { WIFI_BITRATE_5_5MBPS, "5.5" }, + { WIFI_BITRATE_6MBPS, "6" }, + { WIFI_BITRATE_9MBPS, "9" }, + { WIFI_BITRATE_11MBPS, "11" }, + { WIFI_BITRATE_12MBPS, "12" }, + { WIFI_BITRATE_18MBPS, "18" }, + { WIFI_BITRATE_24MBPS, "24" }, + { WIFI_BITRATE_36MBPS, "36" }, + { WIFI_BITRATE_48MBPS, "48" }, + { WIFI_BITRATE_54MBPS, "54" } + }; + DM_CHECK_NULL_WITH_RC(beacon_name, 0); + + for (index = 0; index < (uint32_t)ARRAY_SZ(wifi_data_tx_rate); index++) { + if (beacon_type == wifi_data_tx_rate[index].hal_data_tx_rate) { + char buff[16] = { 0 }; + snprintf(buff, sizeof(buff), "%sMbps", wifi_data_tx_rate[index].str_data_tx_rate); + STR_COPY(beacon_name, buff); + return strlen(beacon_name) + 1; + } + } + + return 0; +} + +int get_beacon_rate_int_from_string(const char *beacon_name, wifi_bitrate_t *beacon_type) +{ + int ret = RETURN_ERR; + wifi_data_tx_rate_hal_map_t wifi_data_tx_rate[] = { + { WIFI_BITRATE_DEFAULT, "Default" }, + { WIFI_BITRATE_1MBPS, "1" }, + { WIFI_BITRATE_2MBPS, "2" }, + { WIFI_BITRATE_5_5MBPS, "5.5" }, + { WIFI_BITRATE_6MBPS, "6" }, + { WIFI_BITRATE_9MBPS, "9" }, + { WIFI_BITRATE_11MBPS, "11" }, + { WIFI_BITRATE_12MBPS, "12" }, + { WIFI_BITRATE_18MBPS, "18" }, + { WIFI_BITRATE_24MBPS, "24" }, + { WIFI_BITRATE_36MBPS, "36" }, + { WIFI_BITRATE_48MBPS, "48" }, + { WIFI_BITRATE_54MBPS, "54" } + }; + + DM_CHECK_NULL_WITH_RC(beacon_name, ret); + DM_CHECK_NULL_WITH_RC(beacon_type, ret); + char temp_beacon_name[16] = { 0 }; + + snprintf(temp_beacon_name, sizeof(temp_beacon_name), "%s", beacon_name); + char * token = strtok(temp_beacon_name, "Mbps"); + DM_CHECK_NULL_WITH_RC(token, ret); + + for (uint32_t index = 0 ; index < (uint32_t)ARRAY_SZ(wifi_data_tx_rate); ++index) { + if(STR_CMP(token, wifi_data_tx_rate[index].str_data_tx_rate)) { + *beacon_type = wifi_data_tx_rate[index].hal_data_tx_rate; + return RETURN_OK; + } + } + + return ret; +} + +bool is_valid_transmit_rate(char *input_str) +{ + bool is_valid = false; + + DM_CHECK_NULL_WITH_RC(input_str, is_valid); + + int i = 0; + int len; + len = strlen(input_str); + for(i = 0; i < len; i++) { + if(isdigit(input_str[i]) || input_str[i]==',' || input_str[i]=='.') { + is_valid = true; + } else { + is_valid = false; + break; + } + } + + return is_valid; +} + +int read_remote_ip(char *s_ip, int size,char *s_name) +{ + FILE *fp1; + char buf[1024] = {0}; + char *url_ptr = NULL; + int ret = RETURN_ERR; + + // Grab the ARM or ATOM RPC IP address + + fp1 = fopen("/etc/device.properties", "r"); + if (fp1 == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d:Error opening properties file!\n",__func__, __LINE__); + return RETURN_ERR; + } + + while (fgets(buf, 1024, fp1) != NULL) { + // Look for ARM_ARPING_IP or ATOM_ARPING_IP + if (strstr(buf, s_name) != NULL) { + buf[strcspn(buf, "\r\n")] = 0; // Strip off any carriage returns + + // grab URL from string + url_ptr = strstr(buf, "="); + url_ptr++; + strncpy(s_ip, url_ptr, size); + ret = RETURN_OK; + break; + } + } + + fclose(fp1); + return ret; +} + +int enable_wifi_telnet(bool enabled) +{ + int ret = RETURN_ERR; + + if (enabled) { + // Attempt to start the telnet daemon on ATOM + char np_remote_ip[128]=""; + + read_remote_ip(np_remote_ip, 128,"ATOM_ARPING_IP"); + if (np_remote_ip[0] != 0 && strlen(np_remote_ip) > 0) { + if (get_stubs_descriptor()->v_secure_system_fn("/usr/sbin/telnetd -b %s") != 0) { + return ret; + } + } + } else { + // Attempt to kill the telnet daemon on ATOM + if (get_stubs_descriptor()->v_secure_system_fn("pkill telnetd") != 0 ) { + return ret; + } + } + + return RETURN_OK; +} + +int dm_wifi_set_webconfig(char *webconfstr, uint32_t size) +{ + push_event_to_ctrl_queue(webconfstr, size, wifi_event_type_webconfig, wifi_event_webconfig_set_data_webconfig, NULL); + + return RETURN_OK; +} + +uint32_t get_total_dbg_log_enable_str_value(char *p_output_str) +{ + const char *exist_dbg_log_str[] = { + "wifiDbDbg", + "wifiMgrDbg", + "wifiWebConfigDbg", + "wifiCtrlDbg", + "wifiPasspointDbg", + "wifiDppDbg", + "wifiMonDbg", + "wifiDMCLI", + "wifiLib", + "wifiPsm", + "wifiLibhostapDbg", + "wifiHalDbg" + }; + uint32_t index; + bool str_found = false; + size_t num_strings = (size_t)ARRAY_SZ(exist_dbg_log_str); + char temp_buff[32]; + + for (index = 0 ; index < num_strings; index++) { + memset(temp_buff, 0, sizeof(temp_buff)); + + snprintf(temp_buff, sizeof(temp_buff), "/nvram/%s", exist_dbg_log_str[index]); + if(access(temp_buff, F_OK) == 0) { + if (str_found == false) { + STR_COPY(p_output_str, exist_dbg_log_str[index]); + } else { + STR_CAT(p_output_str, ","); + STR_CAT(p_output_str, exist_dbg_log_str[index]); + } + str_found = true; + } + } + + if(str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Dbg logs are not enabled\n",__func__, __LINE__); + } else { + return strlen(p_output_str) + 1; + } + + return 0; +} + +int disable_dbg_logs(char *p_input_str) +{ + const char *exist_dbg_log_str[] = { + "wifiDbDbg", + "wifiMgrDbg", + "wifiWebConfigDbg", + "wifiCtrlDbg", + "wifiPasspointDbg", + "wifiDppDbg", + "wifiMonDbg", + "wifiDMCLI", + "wifiLib", + "wifiPsm", + "wifiLibhostapDbg", + "wifiHalDbg" + }; + uint32_t index = 0; + bool is_invalid_input = true; + char *token; + char tmp_input_string[256] = {0}; + char temp_dbg_log_name[32]; + size_t num_strings = (size_t)ARRAY_SZ(exist_dbg_log_str); + + if ((p_input_str == NULL) || (strlen(p_input_str) == 0)) { + wifi_util_error_print(WIFI_DMCLI,"%s input string is not valid\n", __func__); + return RETURN_ERR; + } + + snprintf(tmp_input_string, sizeof(tmp_input_string), "%s", p_input_str); + + //validate input string + token = strtok(tmp_input_string, ","); + while (token != NULL) { + is_invalid_input = true; + for (index = 0; index < num_strings; index++) { + if (STR_CMP(token, exist_dbg_log_str[index])) { + wifi_util_dbg_print(WIFI_DMCLI,"%s dbg log name found:%s\n", __func__, + exist_dbg_log_str[index]); + is_invalid_input = false; + } + } + + if (is_invalid_input == true) { + wifi_util_error_print(WIFI_DMCLI,"%s Invalid Wifi Standard:%s\n", __func__, p_input_str); + return RETURN_ERR; + } + + token = strtok(NULL, ","); + } + + snprintf(tmp_input_string, sizeof(tmp_input_string), "%s", p_input_str); + token = strtok(tmp_input_string, ","); + while (token != NULL) { + for (index = 0; index < num_strings; index++) { + if (STR_CMP(token, exist_dbg_log_str[index])) { + memset(temp_dbg_log_name, 0, sizeof(temp_dbg_log_name)); + + snprintf(temp_dbg_log_name, sizeof(temp_dbg_log_name), "/nvram/%s", exist_dbg_log_str[index]); + remove(temp_dbg_log_name); + wifi_util_info_print(WIFI_DMCLI,"%s removed dbg log:%s\n", __func__, + temp_dbg_log_name); + } + } + + token = strtok(NULL, ","); + } + + return RETURN_OK; +} + +bool is_valid_mac_address(char *mac) +{ + int iter = 0, len = 0; + + len = strlen(mac); + if (len != MAX_STR_MAC_ADDR_LEN) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d MACAddress:%s:%d is not valid!!!\n", __func__, __LINE__, mac, len); + return false; + } + if (mac[2] == ':' && mac[5] == ':' && mac[8] == ':' && mac[11] == ':' && mac[14] == ':') { + for (iter = 0; iter < MAX_STR_MAC_ADDR_LEN; iter++) { + if((iter == 2 || iter == 5 || iter == 8 || iter == 11 || iter == 14)) { + continue; + } else if ((mac[iter] > 47 && mac[iter] <= 57) || + (mac[iter] > 64 && mac[iter] < 71) || + (mac[iter] > 96 && mac[iter] < 103)) { + continue; + } else { + wifi_util_error_print(WIFI_DMCLI,"(%s), MACAdress:%s is not valid:%d\n", __func__, mac, iter); + return false; + } + } + } else { + wifi_util_error_print(WIFI_DMCLI,"(%s), MACAdress:%s is not valid\n", __func__, mac); + return false; + } + + return true; +} + +assoc_dev_data_t *get_sta_assoc_data_map(uint32_t ap_index, uint32_t sta_index) +{ + wifi_vap_info_t *vap_param; + assoc_dev_data_t *p_assoc_sta_entry; + hash_map_t *p_assoc_sta_map; + + vap_param = (wifi_vap_info_t *)getVapInfo(ap_index - 1); + if (vap_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d vap map not found for:[%d]\r\n", __func__, + __LINE__, ap_index); + return NULL; + } + + pthread_mutex_lock(&((webconfig_dml_t*) get_webconfig_dml())->assoc_dev_lock); + //Will be returning the entire stats structure later just returning mac address as of now + p_assoc_sta_map = (hash_map_t *)get_associated_devices_hash_map(vap_param->vap_index); + if (p_assoc_sta_map == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d assoc sta is NULL pointer:%d\n", __func__, __LINE__, vap_param->vap_index); + pthread_mutex_unlock(&((webconfig_dml_t*) get_webconfig_dml())->assoc_dev_lock); + return NULL; + } + + hash_element_t *hash_ele_queue_data = (hash_element_t *)queue_peek(p_assoc_sta_map->queue, sta_index - 1); + if (hash_ele_queue_data == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d wrong assoc sta entry index:%d\r\n", __func__, __LINE__, sta_index); + return NULL; + } + p_assoc_sta_entry = (assoc_dev_data_t *)hash_ele_queue_data->data; + pthread_mutex_unlock(&((webconfig_dml_t*) get_webconfig_dml())->assoc_dev_lock); + + return p_assoc_sta_entry; +} + +int init_dm_params(void) +{ + webconfig_dml_t *webconfig_dml; + + webconfig_dml = (webconfig_dml_t *)get_webconfig_dml(); + if(webconfig_dml == NULL){ + wifi_util_error_print(WIFI_DMCLI, "%s: get_webconfig_dml return NULLL pointer\n", __func__); + return RETURN_ERR; + } + + if (init(webconfig_dml) != 0) { + wifi_util_error_print(WIFI_DMCLI, "%s: Failed to init\n", __func__); + return RETURN_ERR; + } + + return RETURN_OK; +} + +int detach_onewifi_main_process(void) +{ + FILE *fd = NULL; + char cmd[1024] = {0}; + fd = fopen("/var/tmp/OneWifi.pid", "w+"); + if ( !fd ) + { + wifi_util_error_print(WIFI_DMCLI, "Create /var/tmp/OneWifi.pid error. \n"); + return RETURN_ERR; + } + else + { + sprintf(cmd, "%d", getpid()); + fputs(cmd, fd); + fclose(fd); + } + breakpad_ExceptionHandler(); + /* Inform Webconfig framework if component is coming after crash */ + check_component_crash("/tmp/wifi_initialized"); + /* For some reason, touching the file via system command was not working consistently. + * We'll fopen the file and dump in a value */ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: Checking wifi_initialized!\n", __func__, __LINE__); + if ((fd = fopen ("/tmp/wifi_initialized", "w+")) != NULL) { + fprintf(fd,"1"); + fclose(fd); + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d: Semaphore post:%p\n", __func__, __LINE__, sem); + sem_post(sem); + sem_close(sem); + + return RETURN_OK; +} + +int start_dml_main(void *arg) +{ + int ret; + wifi_ctrl_t *ctrl = NULL; + + ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + + decode_json_obj(&ctrl->handle, BUS_DML_CONFIG_FILE); + print_registered_elems(get_bus_mux_reg_cb_map(), 0); + + get_wifidb_obj()->desc.init_data_fn(); + /* Set Wifi Global Parameters */ + init_wifi_global_config(); + + init_dm_params(); + ret = detach_onewifi_main_process(); + get_wifidml_obj()->desc.set_dml_init_status_fn(true); + + return ret; +} + +int ssp_loop_init(void) +{ + return RETURN_OK; +} + +uint32_t get_wifi_wps_method_string_from_int(wifi_onboarding_methods_t l_wps_method, char *p_wps_method_name) +{ + DM_CHECK_NULL_WITH_RC(p_wps_method_name, 0); + + uint32_t index; + bool str_found = false; + wifi_wps_method_hal_map_t wps_method_map[] = { + { WIFI_ONBOARDINGMETHODS_USBFLASHDRIVE, "USBFlashDrive" }, + { WIFI_ONBOARDINGMETHODS_ETHERNET, "Ethernet" }, + { WIFI_ONBOARDINGMETHODS_EXTERNALNFCTOKEN, "ExternalNFCToken" }, + { WIFI_ONBOARDINGMETHODS_INTEGRATEDNFCTOKEN, "IntegratedNFCToken" }, + { WIFI_ONBOARDINGMETHODS_NFCINTERFACE, "NFCInterface" }, + { WIFI_ONBOARDINGMETHODS_PUSHBUTTON, "PushButton" }, + { WIFI_ONBOARDINGMETHODS_PIN, "PIN" } + }; + + for (index = 0 ; index < (uint32_t)ARRAY_SZ(wps_method_map) ; index++) { + if (l_wps_method & wps_method_map[index].hal_wifi_wps_method) + { + if (str_found == false) { + STR_COPY(p_wps_method_name, wps_method_map[index].str_wifi_wps_method); + } else { + STR_CAT(p_wps_method_name, ","); + STR_CAT(p_wps_method_name, wps_method_map[index].str_wifi_wps_method); + } + str_found = true; + } + } + + if(str_found == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Invalid wifi wps method:%d enum\n",__func__, __LINE__, l_wps_method); + } else { + return strlen(p_wps_method_name) + 1; + } + + return 0; +} + +int get_wifi_wps_method_int_from_string(const char *p_wps_method_name, wifi_onboarding_methods_t *p_wps_method) +{ + int ret = RETURN_ERR; + DM_CHECK_NULL_WITH_RC(p_wps_method_name, ret); + DM_CHECK_NULL_WITH_RC(p_wps_method, ret); + + wifi_wps_method_hal_map_t wps_method_map[] = { + { WIFI_ONBOARDINGMETHODS_USBFLASHDRIVE, "USBFlashDrive" }, + { WIFI_ONBOARDINGMETHODS_ETHERNET, "Ethernet" }, + { WIFI_ONBOARDINGMETHODS_EXTERNALNFCTOKEN, "ExternalNFCToken" }, + { WIFI_ONBOARDINGMETHODS_INTEGRATEDNFCTOKEN, "IntegratedNFCToken" }, + { WIFI_ONBOARDINGMETHODS_NFCINTERFACE, "NFCInterface" }, + { WIFI_ONBOARDINGMETHODS_PUSHBUTTON, "PushButton" }, + { WIFI_ONBOARDINGMETHODS_PIN, "PIN" } + }; + + uint32_t index = 0; + bool is_wps_method_invalid = true; + char *token; + char tmp_input_string[128] = {0}; + + *p_wps_method = 0; + snprintf(tmp_input_string, sizeof(tmp_input_string), "%s", p_wps_method_name); + + token = strtok(tmp_input_string, ","); + while (token != NULL) { + is_wps_method_invalid = true; + for (index = 0; index < (uint32_t)ARRAY_SZ(wps_method_map); index++) { + if (STR_CMP(token, wps_method_map[index].str_wifi_wps_method)) { + *p_wps_method |= wps_method_map[index].hal_wifi_wps_method; + wifi_util_dbg_print(WIFI_DMCLI,"%s input:%s wps_method:%d\n", __func__, + p_wps_method_name, *p_wps_method); + is_wps_method_invalid = false; + } + } + + if (is_wps_method_invalid == true) { + wifi_util_error_print(WIFI_DMCLI,"%s Invalid Wifi Standard:%s\n", __func__, p_wps_method_name); + return ret; + } + + token = strtok(NULL, ","); + } + return RETURN_OK; +} + +bool validate_def_reporting_period_value(unsigned long period) +{ + uint32_t index; + unsigned long inst_client_reproting_periods[] = { 0,1,5,15,30,60,300,900,1800,3600,10800,21600,43200,86400 }; + + for (index=0; index < (uint32_t)(ARRAY_SZ(inst_client_reproting_periods)); index++) { + if (inst_client_reproting_periods[index] == period) + return true; + } + return false; +} + +bool validate_inst_client_mac_value(char * phys_address) +{ + + wifi_util_dbg_print(WIFI_DMCLI,"%s-%d mac is ***%s***\n", __func__, __LINE__, phys_address); + if (phys_address && phys_address[0]) { + if (strlen(phys_address) != MIN_STR_MAC_ADDR_LEN) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d mac:%s length is not 12\n", __func__, __LINE__, phys_address); + return false; + } + + if (STR_CMP(phys_address, "000000000000")) { + wifi_util_error_print(WIFI_DMCLI, "%s-%d mac is all 0\n", __func__, __LINE__); + return false; + } + + return true; + } else { + wifi_util_error_print(WIFI_DMCLI, "%s-%d mac is NULL\n",__func__, __LINE__); + } + return false; +} + +int is_sec_mode_open_for_private_ap(uint32_t vap_index) +{ + wifi_radio_operationParam_t *p_radio_oper_param = NULL; + wifi_vap_info_t *p_vap_info = NULL; + wifi_util_dbg_print(WIFI_DMCLI,"%s for vap_index:%d\n", __func__, vap_index); + + //Check is the Vap is private + if(isVapPrivate(vap_index) != true) { + wifi_util_error_print(WIFI_DMCLI,"%s vap_index %d is not private VAP\n", __func__, vap_index); + return RETURN_ERR; + } + + p_vap_info = getVapInfo(vap_index); + if (p_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s Unable to get VAP info for vap_index : %d\n", __func__, vap_index); + return RETURN_ERR; + } + + p_radio_oper_param = getRadioOperationParam(p_vap_info->radio_index); + if (p_radio_oper_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s Input radioIndex = %d not found for radio_oper_param\n", __func__, + p_vap_info->radio_index); + return RETURN_ERR; + } + + //Check for 6Ghz + if ((p_radio_oper_param->band == WIFI_FREQUENCY_6_BAND)) { + wifi_util_error_print(WIFI_DMCLI,"%s Input radioIndex = %d with 6G Band doesnot support WPS:%d\n", __func__, + p_vap_info->radio_index, p_vap_info->u.bss_info.security.mode); + return RETURN_ERR; + } + + //Check for open security + if (p_vap_info->u.bss_info.security.mode == wifi_security_mode_none) { + wifi_util_error_print(WIFI_DMCLI,"%s Open Security for vap_index : %d, WPS doesnot support \n", __func__, + vap_index); + return RETURN_ERR; + } + + if ((p_vap_info->u.bss_info.security.mode == wifi_security_mode_wpa3_personal) || + (p_vap_info->u.bss_info.security.mode == wifi_security_mode_wpa3_enterprise)) { + wifi_util_error_print(WIFI_DMCLI,"%s Input radioIndex = %d WPS doesnot support WPA3 Mode:%d\n", __func__, + p_vap_info->radio_index, p_vap_info->u.bss_info.security.mode); + return RETURN_ERR; + } + + return RETURN_OK; +} + +int max_macfilter_number_of_entries(wifi_vap_info_t *vap_param, uint32_t *p_max_macfilter_entries) +{ + int status = RETURN_ERR; + uint32_t count = 0; + + DM_CHECK_NULL_WITH_RC(vap_param, status); + DM_CHECK_NULL_WITH_RC(p_max_macfilter_entries, status); + *p_max_macfilter_entries = 0; + + hash_map_t** acl_device_map = (hash_map_t **)get_acl_hash_map(vap_param); + queue_t** acl_new_entry_queue = (queue_t **)get_acl_new_entry_queue(vap_param); + + if ((acl_device_map != NULL) && (*acl_device_map != NULL)) { + count = hash_map_count(*acl_device_map); + } + + if ((acl_new_entry_queue != NULL) && (*acl_new_entry_queue != NULL)) { + count = count + queue_count(*acl_new_entry_queue); + } else { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d ERROR NULL queue Pointer \n",__func__, __LINE__); + } + + *p_max_macfilter_entries = count; + + return RETURN_OK; +} + +acl_entry_t *get_macfilter_entry(wifi_vap_info_t *vap_info, uint32_t acl_entry_index) +{ + uint32_t count_hash = 0, count_queue = 0; + acl_entry_t *acl_entry = NULL; + + DM_CHECK_NULL_WITH_RC(vap_info, NULL); + + if (vap_info->vap_index > MAX_VAP) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d vap_index:%d is out of range\n",__func__, + __LINE__, vap_info->vap_index); + return NULL; + } + + hash_map_t **acl_device_map = (hash_map_t **)get_acl_hash_map(vap_info); + queue_t **acl_new_entry_queue = (queue_t **)get_acl_new_entry_queue(vap_info); + if (*acl_new_entry_queue == NULL) { + *acl_new_entry_queue = queue_create(); + } + + if (*acl_device_map != NULL) { + count_hash = hash_map_count(*acl_device_map); + } + + if (*acl_new_entry_queue != NULL) { + count_queue = queue_count(*acl_new_entry_queue); + } + + if (acl_entry_index > (count_hash + count_queue)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Wrong acl_entry_index\n",__func__, __LINE__); + return NULL; + } + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d vap_index:%d acl_entry_index:%d" + " count_hash:%d count_queue:%d\n",__func__, __LINE__, vap_info->vap_index, + acl_entry_index, count_hash, count_queue); + if ((*acl_device_map != NULL) && (acl_entry_index < count_hash)) { + uint32_t index = 0; + + acl_entry = hash_map_get_first(*acl_device_map); + for (index = 0; (index < acl_entry_index) && (acl_entry != NULL); index++) { + acl_entry = hash_map_get_next(*acl_device_map,acl_entry); + } + } else if (*acl_new_entry_queue != NULL) { + acl_entry = (acl_entry_t *) queue_peek(*acl_new_entry_queue, (acl_entry_index - count_hash)); + } + + return acl_entry; +} + +static int sync_bus_macfilter_table_vap_entries(bus_handle_t *handle, wifi_vap_info_t *vap_param) +{ + uint32_t max_acl_cnt = 0; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + max_macfilter_number_of_entries(vap_param, &max_acl_cnt); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d max macfilter cnt:%d for vap:%d, dml table_cnt:%d\n", __func__, + __LINE__, max_acl_cnt, vap_param->vap_index, + p_dml_param->table_macfilter_index[vap_param->vap_index]); + if (p_dml_param->table_macfilter_index[vap_param->vap_index] != max_acl_cnt) { + char buff[64] = { 0 }; + char row_rem_buff[64] = { 0 }; + wifi_bus_desc_t *p_bus_desc = get_bus_descriptor(); + uint32_t index = 0; + + snprintf(buff, sizeof(buff), "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.", vap_param->vap_index + 1); + if (p_dml_param->table_macfilter_index[vap_param->vap_index] < max_acl_cnt) { + index = p_dml_param->table_macfilter_index[vap_param->vap_index] + 1; + while(index <= max_acl_cnt) { + if (p_bus_desc->bus_reg_table_row_fn(handle, buff, index, NULL) != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter table_reg row:%s failed for index:%d\n", + __func__, __LINE__, buff, index); + } else { + p_dml_param->table_macfilter_index[vap_param->vap_index]++; + } + index++; + } + } else { + index = p_dml_param->table_macfilter_index[vap_param->vap_index]; + while (index > max_acl_cnt) { + snprintf(row_rem_buff, sizeof(row_rem_buff), "%s%d", buff, index); + if (p_bus_desc->bus_remove_table_row_fn(handle, row_rem_buff) != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d macfilter table remove row:%s failed\n", + __func__, __LINE__, row_rem_buff); + } + index--; + } + } + } + + return RETURN_OK; +} + +int sync_dml_macfilter_table_entries(void) +{ + uint32_t r_index = 0, v_index = 0; + wifi_ctrl_t *ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + wifi_vap_info_map_t *vap_map; + static bool sync_started = false; + + if (sync_started == true) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d sync_dml_macfilter is already started\n", + __func__, __LINE__); + return RETURN_ERR; + } else { + sync_started = true; + } + ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + + for (r_index = 0; r_index < get_num_radio_dml(); r_index++) { + vap_map = get_dml_cache_vap_map(r_index); + for (v_index = 0; v_index < get_max_num_vaps_per_radio_dml(r_index); v_index++) { + sync_bus_macfilter_table_vap_entries(&ctrl->handle, &vap_map->vap_array[v_index]); + } + } + + sync_started = false; + return RETURN_OK; +} + +static int sync_dml_macfilter_index(void *arg) +{ + table_index_timer_arg_t *input_arg = (table_index_timer_arg_t *)arg; + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + uint32_t *cur_macfilter_index = &p_dml_param->table_macfilter_index[input_arg->vap_index]; + int vap_index = 0, macfilter_entry_index = 0; + char new_row_name[64] = { 0 }; + wifi_bus_desc_t *p_bus_desc = get_bus_descriptor(); + wifi_ctrl_t *ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + + sscanf(input_arg->table_row, "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.%d", &vap_index, &macfilter_entry_index); + snprintf(input_arg->table_row, sizeof(input_arg->table_row), "Device.WiFi.AccessPoint.%d.X_CISCO_COM_MacFilterTable.", vap_index); + snprintf(new_row_name, sizeof(new_row_name), "%s%d", input_arg->table_row, *cur_macfilter_index); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d table add:%s = remove:%s for vap:%d remove index:%d add back index:%d \n", + __func__, __LINE__, input_arg->table_row, new_row_name, input_arg->vap_index, *cur_macfilter_index, macfilter_entry_index); + + if (p_bus_desc->bus_reg_table_row_fn(&ctrl->handle, input_arg->table_row, macfilter_entry_index, NULL) != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d table_reg row:%s failed for index:%d\n", + __func__, __LINE__, input_arg->table_row, macfilter_entry_index); + } else { + if (p_bus_desc->bus_unreg_table_row_fn(&ctrl->handle, new_row_name) != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d table remove row:%s failed\n", + __func__, __LINE__, new_row_name); + } else { + (*cur_macfilter_index)--; + } + } + + if (input_arg != NULL) { + free(input_arg); + } + + return TIMER_TASK_COMPLETE; +} + +int sync_dml_macfilter_table(uint32_t vap_index, char *table_row_name) +{ + wifi_ctrl_t *ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + table_index_timer_arg_t *input_arg = malloc(sizeof(table_index_timer_arg_t)); + + DM_CHECK_NULL_WITH_RC(input_arg, RETURN_ERR); + DM_CHECK_NULL_WITH_RC(table_row_name, RETURN_ERR); + + input_arg->vap_index = vap_index; + strcpy(input_arg->table_row, table_row_name); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d macfilter table:%s sync start for vap:%d\n", + __func__, __LINE__, table_row_name, vap_index); + scheduler_add_timer_task(ctrl->sched, FALSE, NULL, sync_dml_macfilter_index, + input_arg, (MACFILTER_TABLE_SYNC_TIME_IN_SEC * 1000), 1, FALSE); + + return RETURN_OK; +} + +static int sync_bus_sta_assoc_table_vap_entries(bus_handle_t *handle, uint32_t vap_index, uint32_t max_sta_count) +{ + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + wifi_util_info_print(WIFI_DMCLI,"%s:%d max sta assoc cnt:%d for vap:%d, dml table_cnt:%d\n", __func__, + __LINE__, max_sta_count, vap_index, + p_dml_param->table_sta_assoc_index[vap_index]); + if (p_dml_param->table_sta_assoc_index[vap_index] != max_sta_count) { + char buff[64] = { 0 }; + char row_rem_buff[64] = { 0 }; + wifi_bus_desc_t *p_bus_desc = get_bus_descriptor(); + uint32_t index = 0; + + snprintf(buff, sizeof(buff), "Device.WiFi.AccessPoint.%d.AssociatedDevice.", vap_index + 1); + if (p_dml_param->table_sta_assoc_index[vap_index] < max_sta_count) { + index = p_dml_param->table_sta_assoc_index[vap_index] + 1; + while(index <= max_sta_count) { + if (p_bus_desc->bus_reg_table_row_fn(handle, buff, index, NULL) != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d sta assoc table_reg row:%s failed for index:%d\n", + __func__, __LINE__, buff, index); + } else { + p_dml_param->table_sta_assoc_index[vap_index]++; + } + index++; + } + } else { + index = p_dml_param->table_sta_assoc_index[vap_index]; + while (index > max_sta_count) { + snprintf(row_rem_buff, sizeof(row_rem_buff), "%s%d", buff, index); + if (p_bus_desc->bus_unreg_table_row_fn(handle, row_rem_buff) != bus_error_success) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d sta assoc table remove row:%s failed\n", + __func__, __LINE__, row_rem_buff); + } else { + p_dml_param->table_sta_assoc_index[vap_index]--; + } + index--; + } + } + } + + return RETURN_OK; +} + +int get_dml_total_associated_devices_count(uint32_t radio_index, uint32_t vap_array_index, uint32_t *count) +{ + int ret = RETURN_ERR; + if (radio_index < 0 || vap_array_index < 0) { + wifi_util_error_print(WIFI_DMCLI,"%s %d invalid radio_%d/vap_array_%d index\n", __func__, + __LINE__, radio_index, vap_array_index); + return ret; + } + + pthread_mutex_lock(&((webconfig_dml_t*) get_webconfig_dml())->assoc_dev_lock); + hash_map_t **assoc_dev_hash_map = get_dml_assoc_dev_hash_map(radio_index, vap_array_index); + + if ((assoc_dev_hash_map == NULL) || (*assoc_dev_hash_map == NULL)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s %d No hash_map returning zero\n", __func__, __LINE__); + } else { + *count = (uint32_t)hash_map_count(*assoc_dev_hash_map); + wifi_util_dbg_print(WIFI_DMCLI,"%s %d returning hash_map count as %d\n", __func__, __LINE__, *count); + ret = RETURN_OK; + } + pthread_mutex_unlock(&((webconfig_dml_t*) get_webconfig_dml())->assoc_dev_lock); + return ret; +} + +int sync_dml_sta_assoc_table_entries(void) +{ + uint32_t r_index = 0, v_index = 0; + wifi_ctrl_t *ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + static bool sync_started = false; + + if (sync_started == true) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d sync_dml_macfilter is already started\n", + __func__, __LINE__); + return RETURN_ERR; + } else { + sync_started = true; + } + ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + rdk_wifi_radio_t *radio_map; + uint32_t vap_index = 0; + uint32_t max_sta_count; + + for (r_index = 0; r_index < get_num_radio_dml(); r_index++) { + radio_map = get_dml_cache_radio_map_param(r_index); + for (v_index = 0; v_index < get_max_num_vaps_per_radio_dml(r_index); v_index++) { + if (get_dml_total_associated_devices_count(r_index, v_index, &max_sta_count) == RETURN_OK) { + vap_index = radio_map->vaps.rdk_vap_array[v_index].vap_index; + sync_bus_sta_assoc_table_vap_entries(&ctrl->handle, vap_index, max_sta_count); + } + } + } + + sync_started = false; + return RETURN_OK; +} + +char *getDeviceMac(void) +{ + static char device_mac[MAX_STR_MAC_ADDR_LEN + 1] = { 0 }; +#if defined(_COSA_BCM_MIPS_) +#define CPE_MAC_NAMESPACE "Device.DPoE.Mac_address" +#else +#ifdef _SKY_HUB_COMMON_PRODUCT_REQ_ +#define CPE_MAC_NAMESPACE "Device.DeviceInfo.X_COMCAST-COM_WAN_MAC" +#else +#define CPE_MAC_NAMESPACE "Device.X_CISCO_COM_CableModem.MACAddress" +#endif +#endif /*_COSA_BCM_MIPS_*/ + + if (strlen(device_mac) == 0) { + wifi_ctrl_t *ctrl; + ctrl = (wifi_ctrl_t *)get_wifictrl_obj(); + bus_error_t rc = bus_error_success; + raw_data_t data; + memset(&data, 0, sizeof(raw_data_t)); + + rc = get_bus_descriptor()->bus_data_get_fn(&ctrl->handle, CPE_MAC_NAMESPACE, &data); + if (rc != bus_error_success || (data.data_type != bus_data_type_string)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d bus_data_get_fn failed for [%s]" + " with error [%d]\n", __func__, __LINE__, CPE_MAC_NAMESPACE, rc); + get_bus_descriptor()->bus_data_free_fn(&data); + return NULL; + } + strcpy(device_mac, (char *)data.raw_data.bytes); + wifi_util_info_print(WIFI_DMCLI,"%s:%d device cpe mac[%s]:%d\n", __func__, __LINE__, + device_mac, data.raw_data_len); + get_bus_descriptor()->bus_data_free_fn(&data); + } + + return device_mac; +} + +int initparodusTask(void) +{ + return RETURN_OK; +} + +void get_cur_time_str(char *str_time, uint32_t str_len) +{ + time_t timer; + struct tm* tm_info; + + time(&timer); + tm_info = localtime(&timer); + strftime(str_time, str_len, "%Y-%m-%d %H:%M:%S ", tm_info); +} + +int get_requestor_string(char *str) +{ + DM_CHECK_NULL_WITH_RC(str, RETURN_ERR); + strcpy(str, BS_SOURCE_RFC_STR); + return RETURN_OK; +} + +int set_wifi_region_update_source(char *str_input) +{ + DM_CHECK_NULL_WITH_RC(str_input, RETURN_ERR); + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + snprintf(p_dml_param->str_wifi_region_update_source, + sizeof(p_dml_param->str_wifi_region_update_source), "%s", str_input); + + return RETURN_OK; +} + +int get_wifi_region_update_source(char *str_output) +{ + DM_CHECK_NULL_WITH_RC(str_output, RETURN_ERR); + wifi_dml_data_model_t *p_dml_param = get_dml_data_model_param(); + + strcpy(str_output, p_dml_param->str_wifi_region_update_source); + + return RETURN_OK; +} + +static int write_to_json(char *data, char *file) +{ + FILE *fp; + fp = fopen(file, "w"); + if (fp == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s : %d Failed to open file %s\n", __func__, __LINE__, file); + return RETURN_ERR; + } + + fwrite(data, strlen(data), 1, fp); + fclose(fp); + + return RETURN_OK; +} + +static int update_json_param_legacy(char *p_key, char *partner_id, char *p_value) +{ + cJSON *partner_obj = NULL; + cJSON *json = NULL; + FILE *file_read = NULL; + char *cjson_out = NULL; + char *data = NULL; + int len ; + int config_update_status = -1; + + file_read = fopen(PARTNERS_INFO_FILE, "r"); + if (file_read == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : Error in opening JSON file\n" , __func__, __LINE__); + return RETURN_ERR; + } + + fseek(file_read, 0, SEEK_END); + len = ftell(file_read); + if (len < 0) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : file_read Negative \n", __func__, __LINE__); + fclose(file_read); + return RETURN_ERR; + } + fseek(file_read, 0, SEEK_SET); + data = ( char* )malloc(sizeof(char) * (len + 1)); + if (data != NULL) { + memset(data, 0, (sizeof(char) * (len + 1))); + if(1 != fread(data, len, 1, file_read)) { + fclose(file_read); + return RETURN_ERR; + } + data[len] ='\0'; + } else { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : Memory allocation failed \n", __func__, __LINE__); + fclose(file_read); + return RETURN_ERR; + } + fclose(file_read); + if (data == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : file_read failed \n", __func__, __LINE__); + return RETURN_ERR; + } else if (strlen(data) != 0) { + json = cJSON_Parse(data); + if(!json) { + wifi_util_error_print(WIFI_DMCLI, "%s : json file parser error : [%d]\n", __func__, __LINE__); + free(data); + return RETURN_ERR; + } else { + partner_obj = cJSON_GetObjectItem(json, partner_id); + if (NULL != partner_obj) { + if (NULL != cJSON_GetObjectItem(partner_obj, p_key)) { + cJSON_ReplaceItemInObject(partner_obj, p_key, cJSON_CreateString(p_value)); + cjson_out = cJSON_Print(json); + wifi_util_error_print(WIFI_DMCLI, "Updated json content is %s\n", cjson_out); + config_update_status = write_to_json(cjson_out, PARTNERS_INFO_FILE); + cJSON_free(cjson_out); + if (!config_update_status) { + wifi_util_error_print(WIFI_DMCLI, "Updated Value for %s partner\n", partner_id); + wifi_util_error_print(WIFI_DMCLI, "Param:%s - Value:%s\n", p_key, p_value); + } else { + wifi_util_error_print(WIFI_DMCLI, "Failed to update value for %s partner\n", partner_id); + wifi_util_error_print(WIFI_DMCLI, "Param:%s\n", p_key); + cJSON_Delete(json); + return RETURN_ERR; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s - OBJECT Value is NULL %s\n", p_key, __func__); + cJSON_Delete(json); + return RETURN_ERR; + } + + } else { + wifi_util_error_print(WIFI_DMCLI,"%s - PARTNER ID OBJECT Value is NULL\n", __func__ ); + cJSON_Delete(json); + return RETURN_ERR; + } + cJSON_Delete(json); + } + } else { + wifi_util_error_print(WIFI_DMCLI,"PARTNERS_INFO_FILE %s is empty\n", PARTNERS_INFO_FILE); + free(data); + return RETURN_ERR; + } + + return RETURN_OK; +} + +int update_json_param(char *p_key, char *partner_id, char *p_value, char *p_source, char *p_current_time) +{ + cJSON *partner_obj = NULL; + cJSON *json = NULL; + FILE *file_read = NULL; + char * cjson_out = NULL; + char* data = NULL; + int len ; + int config_update_status = -1; + + file_read = fopen(BOOTSTRAP_INFO_FILE, "r"); + if (file_read == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : Error in opening JSON file\n" , __func__, __LINE__); + return RETURN_ERR; + } + + fseek(file_read, 0, SEEK_END); + len = ftell( file_read ); + if (len < 0) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : file_read negative \n", __func__, __LINE__); + fclose(file_read); + return RETURN_ERR; + } + fseek(file_read, 0, SEEK_SET); + data = (char *)malloc(sizeof(char) * (len + 1)); + if (data != NULL) { + memset(data, 0, (sizeof(char) * (len + 1))); + if (1 != fread(data, len, 1, file_read)) { + fclose(file_read); + return RETURN_ERR; + } + data[len] ='\0'; + } else { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : Memory allocation failed \n", __func__, __LINE__); + fclose(file_read); + return RETURN_ERR; + } + + fclose(file_read); + if (data == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s-%d : file_read failed \n", __func__, __LINE__); + return RETURN_ERR; + } else if (strlen(data) != 0) { + json = cJSON_Parse(data); + if (!json) { + wifi_util_error_print(WIFI_DMCLI, "%s : json file parser error : [%d]\n", __func__,__LINE__); + free(data); + return RETURN_ERR; + } else { + partner_obj = cJSON_GetObjectItem(json, partner_id); + if (NULL != partner_obj) { + cJSON *param_obj = cJSON_GetObjectItem(partner_obj, p_key); + if (NULL != param_obj) { + cJSON_ReplaceItemInObject(param_obj, "ActiveValue", cJSON_CreateString(p_value)); + cJSON_ReplaceItemInObject(param_obj, "UpdateTime", cJSON_CreateString(p_current_time)); + cJSON_ReplaceItemInObject(param_obj, "UpdateSource", cJSON_CreateString(p_source)); + + cjson_out = cJSON_Print(json); + wifi_util_error_print(WIFI_DMCLI, "Updated json content is %s\n", cjson_out); + config_update_status = write_to_json(cjson_out, BOOTSTRAP_INFO_FILE); + cJSON_free(cjson_out); + if (!config_update_status) { + wifi_util_error_print(WIFI_DMCLI, "Bootstrap config update: %s, %s, %s, %s \n", p_key, + p_value, partner_id, p_source); + } else { + wifi_util_error_print(WIFI_DMCLI, "Failed to update value for %s partner\n",partner_id); + wifi_util_error_print(WIFI_DMCLI, "Param:%s\n",p_key); + cJSON_Delete(json); + return RETURN_ERR; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s - OBJECT Value is NULL %s\n", p_key, __func__); + cJSON_Delete(json); + return RETURN_ERR; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s - PARTNER ID OBJECT Value is NULL\n", __func__); + cJSON_Delete(json); + return RETURN_ERR; + } + cJSON_Delete(json); + } + } else { + wifi_util_error_print(WIFI_DMCLI,"BOOTSTRAP_INFO_FILE %s is empty\n", BOOTSTRAP_INFO_FILE); + free(data); + return RETURN_ERR; + } + + update_json_param_legacy(p_key, partner_id, p_value); + + return RETURN_OK; +} + +void sendWebpaMsg(char *serviceName, char *dest, char *trans_id, char *traceParent, char *traceState, char *contentType, char *payload, unsigned int payload_len) +{ + wifi_util_info_print(WIFI_DMCLI,"serviceName:%s dest:%s\n", serviceName, dest); +} + +int push_data_to_ssp_queue(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type) +{ + return RETURN_OK; +} diff --git a/source/platform/common/data_model/wifi_dml_api.h b/source/platform/common/data_model/wifi_dml_api.h new file mode 100644 index 00000000..78b341b7 --- /dev/null +++ b/source/platform/common/data_model/wifi_dml_api.h @@ -0,0 +1,135 @@ +#ifndef WIFI_DML_API_H +#define WIFI_DML_API_H + +#include +#include +#include +#include +#include "wifi_data_model.h" +#include "wifi_hal.h" + +#define REG_DOMAIN_SZ 3 +#define ENV_SZ 1 + +#define BS_SOURCE_WEBPA_STR "webpa" +#define BS_SOURCE_RFC_STR "rfc" +#define MACFILTER_TABLE_SYNC_TIME_IN_SEC 2 + +#define MAX_STR_MAC_ADDR_LEN 17 +#define MIN_STR_MAC_ADDR_LEN 12 + +#define STR_CMP(PARAM_NAME, STR) (strncmp(PARAM_NAME, STR, strlen(STR) + 1) == 0) +#define STR_COPY(PARAM_NAME, STR) (strncpy(PARAM_NAME, STR, strlen(STR) + 1)) +#define ARRAY_SZ(x) (sizeof(x) / sizeof((x)[0])) + +#define STR_CAT(DEST, SRC) \ + do { \ + strncat((DEST), (SRC), sizeof(DEST) - strlen(DEST) - 1); \ + } while (0) + +typedef struct wifi_freq_band_hal_map { + wifi_freq_bands_t hal_wifi_freq_band; + char str_wifi_freq_band[16]; +} wifi_freq_band_hal_map_t; + +typedef struct wifi_sec_mode_hal_map { + wifi_security_modes_t hal_sec_mode; + char str_sec_mode[32]; +} wifi_sec_mode_hal_map_t; + +typedef struct wifi_sec_mfp_hal_map { + wifi_mfp_cfg_t hal_sec_mfp; + char str_sec_mfp[32]; +} wifi_sec_mfp_hal_map_t; + +typedef struct wifi_sec_encr_hal_map { + wifi_encryption_method_t hal_sec_encr_method; + char str_sec_encr_type[16]; +} wifi_sec_encr_hal_map_t; + +typedef struct wifi_guard_interval_map { + wifi_guard_interval_t hal_guard_interval; + char str_guard_interval[8]; +} wifi_guard_interval_map_t; + +typedef struct wifi_variant_hal_map { + wifi_ieee80211Variant_t hal_radio_variant; + char str_radio_variant[4]; +} wifi_variant_hal_map_t; + +typedef struct wifi_chan_width_hal_map { + wifi_channelBandwidth_t hal_wifi_chan_width; + char str_wifi_chan_width[16]; +} wifi_chan_width_hal_map_t; + +typedef struct wifi_data_tx_rate_hal_map { + wifi_bitrate_t hal_data_tx_rate; + char str_data_tx_rate[8]; +} wifi_data_tx_rate_hal_map_t; + +typedef struct wifi_wps_method_hal_map { + wifi_onboarding_methods_t hal_wifi_wps_method; + char str_wifi_wps_method[32]; +} wifi_wps_method_hal_map_t; + +typedef struct table_index_timer_arg { + uint32_t vap_index; + char table_row[64]; +} table_index_timer_arg_t; + +int set_output_string(scratch_data_buff_t *output_value, char *str); +uint32_t get_sec_mode_string_from_int(wifi_security_modes_t security_mode, char *security_name); +int get_sec_mode_int_from_string(const char *p_sec_name, wifi_security_modes_t *p_sec_mode); +int get_sec_modes_supported(int vap_index, int *mode); +int get_mfp_type_from_string(const char *p_mfp_name, wifi_mfp_cfg_t *p_mfp_type); +int get_sec_encr_int_from_string(const char *p_sec_encr_name, wifi_encryption_method_t *p_sec_encr_type); +int get_sec_encr_string_from_int(wifi_encryption_method_t l_sec_encr_type, char *p_sec_encr_name); +int get_radio_band_string_from_int(wifi_freq_bands_t l_radio_band, char *p_str_radio_band); +int get_radio_guard_interval_string_from_int(wifi_guard_interval_t l_guard_interval, char *p_guard_interval_name); +int get_radio_guard_interval_int_from_string(const char *p_guard_interval_name, wifi_guard_interval_t *p_guard_interval); +int get_radio_variant_string_from_int(wifi_ieee80211Variant_t l_radio_variant, char *p_radio_variant_name); +int get_radio_variant_int_from_string(const char *p_radio_variant_name, wifi_ieee80211Variant_t *p_radio_variant); +int get_radio_bandwidth_string_from_int(wifi_channelBandwidth_t l_chan_width, char *p_chan_width_name); +int get_radio_bandwidth_int_from_string(const char *p_chan_width_name, wifi_channelBandwidth_t *p_chan_width); +uint32_t get_reg_domain_string_from_int(wifi_countrycode_type_t l_country_code, + wifi_operating_env_t l_oper_env, char *str_reg_domain); +int get_reg_domain_int_from_string(const char *p_reg_domain, wifi_countrycode_type_t *p_country_code, + wifi_operating_env_t *p_oper_env); +int get_wifi_data_tx_rate_int_from_string(const char *p_tx_rate_name, wifi_bitrate_t *p_tx_rate); +uint32_t get_wifi_data_tx_rate_string_from_int(wifi_bitrate_t l_tx_rate, char *p_tx_rate_name); +int get_beacon_rate_int_from_string(const char *beacon_name, wifi_bitrate_t *beacon_type); +uint32_t get_beacon_rate_string_from_int(wifi_bitrate_t beacon_type, char *beacon_name); +int get_wifi_wps_method_int_from_string(const char *p_wps_method_name, wifi_onboarding_methods_t *p_wps_method); +uint32_t get_wifi_wps_method_string_from_int(wifi_onboarding_methods_t l_wps_method, char *p_wps_method_name); +int get_radio_band_int_from_string(const char *p_str_radio_band, wifi_freq_bands_t *p_radio_band); + +uint32_t get_total_dbg_log_enable_str_value(char *p_output_str); +int disable_dbg_logs(char *p_input_str); + +bool is_valid_transmit_rate(char *input_str); + +int radio_wifi_channel_is_valid(uint32_t radio_index, uint32_t input_channel); +bool is_radio_tx_power_valid(char *p_supported_power_list, int l_tx_power); +int enable_wifi_telnet(bool enabled); +int dm_wifi_set_webconfig(char *webconfstr, uint32_t size); +bool is_valid_mac_address(char *mac); +assoc_dev_data_t *get_sta_assoc_data_map(uint32_t ap_index, uint32_t sta_index); +int init_dm_params(void); +bool validate_def_reporting_period_value(unsigned long period); +bool validate_inst_client_mac_value(char * phys_address); +int is_sec_mode_open_for_private_ap(uint32_t vap_index); +int max_macfilter_number_of_entries(wifi_vap_info_t *vap_param, uint32_t *p_max_macfilter_entries); +acl_entry_t *get_macfilter_entry(wifi_vap_info_t *vap_info, uint32_t acl_entry_index); +int sync_dml_macfilter_table(uint32_t vap_index, char *table_row_name); +int sync_dml_macfilter_table_entries(void); +int sync_dml_sta_assoc_table_entries(void); +char *getDeviceMac(void); +int initparodusTask(void); +int get_requestor_string(char *str); +void get_cur_time_str(char *str_time, uint32_t str_len); +int get_wifi_region_update_source(char *str_output); +int set_wifi_region_update_source(char *str_input); +int update_json_param(char *p_key, char *partner_id, char *p_value, char *p_source, char *p_current_time); +int push_data_to_ssp_queue(const void *msg, unsigned int len, uint32_t type, uint32_t sub_type); + +#endif//WIFI_DML_API_H diff --git a/source/platform/common/data_model/wifi_dml_cb.c b/source/platform/common/data_model/wifi_dml_cb.c new file mode 100644 index 00000000..2024f511 --- /dev/null +++ b/source/platform/common/data_model/wifi_dml_cb.c @@ -0,0 +1,5630 @@ +#include +#include +#include +#include "bus.h" +#include "wifi_dml_cb.h" +#include "wifi_data_model.h" +#include "wifi_events.h" +#include "wifi_stubs.h" +#include "wifi_util.h" +#include "dml_onewifi_api.h" +#include "wifi_dml_api.h" + +extern bool is_radio_config_changed; +extern bool g_update_wifi_region; +static int radio_reset_count; +long long int last_vap_change; +long long int last_radio_change; +static int g_chan_switch_count; + +static inline bool is_open_sec(wifi_security_modes_t mode) +{ + return mode == wifi_security_mode_none || + mode == wifi_security_mode_enhanced_open; +} + +static inline bool is_personal_sec(wifi_security_modes_t mode) +{ + return mode == wifi_security_mode_wpa_personal || + mode == wifi_security_mode_wpa2_personal || + mode == wifi_security_mode_wpa_wpa2_personal || + mode == wifi_security_mode_wpa3_personal || + mode == wifi_security_mode_wpa3_transition; +} + +static inline bool is_enterprise_sec(wifi_security_modes_t mode) +{ + return mode == wifi_security_mode_wpa_enterprise || + mode == wifi_security_mode_wpa2_enterprise || + mode == wifi_security_mode_wpa_wpa2_enterprise || + mode == wifi_security_mode_wpa3_enterprise; +} + +bool wifi_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_dml_wifi_global_param(); + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "ApplyRadioSettings")) { + *output_value = false; + } else if (STR_CMP(param_name, "ApplyAccessPointSettings")) { + *output_value = false; + } else if (STR_CMP(param_name, "X_CISCO_COM_FactoryReset")) { + *output_value = false; + } else if (STR_CMP(param_name, "X_CISCO_COM_EnableTelnet")) { + *output_value = false; + } else if (STR_CMP(param_name, "X_CISCO_COM_ResetRadios")) { + *output_value = false; + } else if (STR_CMP(param_name, "WiFiStuckDetect")) { + if ((access(WIFI_STUCK_DETECT_FILE_NAME, R_OK)) != 0) { + *output_value = false; + } else { + *output_value = true; + } + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_WiFiHost_Sync")) { + *output_value = false; + } else if (STR_CMP(param_name, "2G80211axEnable")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->twoG80211axEnable_rfc; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_PreferPrivate")) { + *output_value = pcfg->prefer_private; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_RapidReconnectIndicationEnable")) { + *output_value = pcfg->rapid_reconnect_enable; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_vAPStatsEnable")) { + *output_value = pcfg->vap_stats_feature; + } else if (STR_CMP(param_name, "FeatureMFPConfig")) { + *output_value = pcfg->mfp_config_feature; + } else if (STR_CMP(param_name, "TxOverflowSelfheal")) { + *output_value = pcfg->tx_overflow_selfheal; + } else if (STR_CMP(param_name, "X_RDK-CENTRAL_COM_ForceDisable")) { + *output_value = pcfg->force_disable_radio_feature; + } else if (STR_CMP(param_name, "Managed_WiFi_Enabled")) { + *output_value = 0; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s param get is not supported\n", __func__, + __LINE__, param_name); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_EnableRadiusGreyList")) { +#if defined (FEATURE_SUPPORT_RADIUSGREYLIST) + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->radiusgreylist_rfc; +#else + *output_value = false; +#endif + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_EnableHostapdAuthenticator")) { + *output_value = true; + } else if (STR_CMP(param_name, "DFS")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->dfs_rfc; + } else if (STR_CMP(param_name, "Levl")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->levl_enabled_rfc; + } else if (STR_CMP(param_name, "DFSatBootUp")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->dfsatbootup_rfc; + } else if (STR_CMP(param_name, "WiFi-Interworking")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->wifiinterworking_rfc; + } else if (STR_CMP(param_name, "WiFi-Passpoint")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->wifipasspoint_rfc; + } else if (STR_CMP(param_name, "WiFi-OffChannelScan")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->wifi_offchannelscan_sm_rfc; + } else if (STR_CMP(param_name, "WPA3_Personal_Transition")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + *output_value = rfc_params->wpa3_rfc; + } else if (STR_CMP(param_name, "Log_Upload")) { + char path[32] = {0}; + int val = 0; + FILE *fp; + + fp = popen("crontab -l | grep -c copy_wifi_logs.sh","r"); + while(fgets(path, sizeof(path), fp) != NULL) { + val = atoi(path); + if(val == 1) { + *output_value = true; + } + else { + *output_value = false; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Log_upload got %s and val=%d\n", __func__, __LINE__, path, val); + } + fclose(fp); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_param_t *pcfg = (wifi_global_param_t *) get_dml_wifi_global_param(); + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "X_RDKCENTRAL-COM_GoodRssiThreshold")) { + *output_value = pcfg->good_rssi_threshold; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_AssocCountThreshold")) { + *output_value = pcfg->assoc_count_threshold; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_AssocMonitorDuration")) { + *output_value = pcfg->assoc_monitor_duration; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_AssocGateTime")) { + *output_value = pcfg->assoc_gate_time; + } else if (STR_CMP(param_name, "WHIX_LogInterval")) { + *output_value = pcfg->whix_log_interval; //seconds + } else if (STR_CMP(param_name, "WHIX_ChUtility_LogInterval")) { + *output_value = pcfg->whix_chutility_loginterval; //seconds + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + + if (STR_CMP(param_name, "RadioNumberOfEntries")) { + *output_value = getNumberRadios(); + } else if (STR_CMP(param_name, "AccessPointNumberOfEntries")) { + *output_value = getTotalNumberVAPs(); + } else if (STR_CMP(param_name, "SSIDNumberOfEntries")) { + *output_value = getTotalNumberVAPs(); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + return true; +} + +bool wifi_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + dml_global_default *p_global_def = (dml_global_default *) get_global_default_obj(); + DM_CHECK_NULL_WITH_RC(p_global_def, false); + + if (STR_CMP(param_name, "X_CISCO_COM_RadioPower")) { + set_output_string(output_value, p_global_def->RadioPower); + } else if (STR_CMP(param_name, "X_CISCO_COM_FactoryResetRadioAndAp")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "X_RDK_VapData")) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: This param get:%s is not supported\n",__func__, + __LINE__, param_name); + return false; + } else if (STR_CMP(param_name, "X_RDK_RadioData")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_WiFi_Notification")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_Connected-Client")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_Br0_Sync")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "Status")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_GASConfiguration")) { + char buff[2048] = { 0 }; + WiFi_GetGasConfig(buff); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "Log_Enable")) { + char buff[512] = { 0 }; + + if (get_total_dbg_log_enable_str_value(buff) != 0) { + set_output_string(output_value, buff); + } else { + set_output_string(output_value, " "); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + + if (STR_CMP(param_name, "ApplyRadioSettings")) { + if (output_value == true) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d ApplyRadioSettings push to queue \n",__func__, __LINE__); + if (push_radio_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d ApplyRadioSettings falied \n",__func__, __LINE__); + return false; + } + radio_reset_count++; + last_radio_change = get_current_time_in_sec(); + if (g_update_wifi_region) { + push_global_config_dml_cache_to_one_wifidb(); + } + } + } else if (STR_CMP(param_name, "ApplyAccessPointSettings")) { + if (output_value == true){ + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d ApplyAccessPointSettings push to queue \n",__func__, __LINE__); + if (push_vap_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d ApplyAccessPointSettings falied \n",__func__, __LINE__); + return false; + } + last_vap_change = get_current_time_in_sec(); + } + } else if (STR_CMP(param_name, "X_CISCO_COM_FactoryReset")) { + if (wifi_factory_reset(true) != true) { + return false; + } + } else if (STR_CMP(param_name, "X_CISCO_COM_EnableTelnet")) { + if (enable_wifi_telnet(output_value) != RETURN_OK) { + } + } else if (STR_CMP(param_name, "X_CISCO_COM_ResetRadios")) { + radio_reset_count++; + } else if (STR_CMP(param_name, "WiFiStuckDetect")) { + if (output_value) { + FILE *fp = fopen(WIFI_STUCK_DETECT_FILE_NAME, "a+"); + if (fp != NULL) { + fclose(fp); + } + } else { + remove(WIFI_STUCK_DETECT_FILE_NAME); + } + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_WiFiHost_Sync")) { + if (push_wifi_host_sync_to_ctrl_queue() == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Failed to push host sync to ctrl queue\n", __func__, __LINE__); + return false; + } + } else if (STR_CMP(param_name, "2G80211axEnable")) { +#ifndef ALWAYS_ENABLE_AX_2G + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->twoG80211axEnable_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_twoG80211axEnable_rfc); + } +#endif + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_PreferPrivate")) { + wifi_global_config_t *p_global_wifi_cfg; + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if(p_global_wifi_cfg->global_parameters.prefer_private == output_value) { + return true; + } + + if (output_value && p_rfc_cfg->radiusgreylist_rfc) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:RadiussGreyList enabled=%d hence cannot enable preferPrivate\n",__func__, + __LINE__, p_rfc_cfg->radiusgreylist_rfc); + return false; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:prefer_private=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.prefer_private, output_value); + p_global_wifi_cfg->global_parameters.prefer_private = output_value; + push_global_config_dml_cache_to_one_wifidb(); + push_prefer_private_ctrl_queue(output_value); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_RapidReconnectIndicationEnable")) { + wifi_global_config_t *p_global_wifi_cfg; + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if(p_global_wifi_cfg->global_parameters.rapid_reconnect_enable == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:rapid_reconnect_enable=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.rapid_reconnect_enable,output_value); + p_global_wifi_cfg->global_parameters.rapid_reconnect_enable = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_vAPStatsEnable")) { + wifi_global_config_t *p_global_wifi_cfg; + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if(p_global_wifi_cfg->global_parameters.vap_stats_feature == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:vap_stats_feature=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.vap_stats_feature, output_value); + p_global_wifi_cfg->global_parameters.vap_stats_feature = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "FeatureMFPConfig")) { + wifi_global_config_t *p_global_wifi_cfg; + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if(p_global_wifi_cfg->global_parameters.mfp_config_feature == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:mfp_config_feature=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.mfp_config_feature, output_value); + p_global_wifi_cfg->global_parameters.mfp_config_feature = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "TxOverflowSelfheal")) { + wifi_global_config_t *p_global_wifi_cfg; + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if(p_global_wifi_cfg->global_parameters.tx_overflow_selfheal == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:tx_overflow_selfheal=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.tx_overflow_selfheal, output_value); + p_global_wifi_cfg->global_parameters.tx_overflow_selfheal = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "X_RDK-CENTRAL_COM_ForceDisable")) { + wifi_global_config_t *p_global_wifi_cfg; + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if(p_global_wifi_cfg->global_parameters.force_disable_radio_feature == output_value) { + return true; + } + + uint32_t instance_number; + wifi_radio_operationParam_t *dm_wifi_radio_op_param = NULL; + for (instance_number = 0; instance_number < (uint32_t)getNumberRadios(); instance_number++) { + dm_wifi_radio_op_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(instance_number); + if (dm_wifi_radio_op_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param for instance_number:%d\n", __func__, + __LINE__,instance_number); + return false; + } + if(output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d WIFI_FORCE_DISABLE_CHANGED_TO_TRUE\n", __func__, __LINE__); + if(dm_wifi_radio_op_param->enable) { + dm_wifi_radio_op_param->enable = false; + is_radio_config_changed = true; + if(push_radio_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d ApplyRadioSettings failed\n", __func__, __LINE__); + return false; + } + } + } else { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d WIFI_FORCE_DISABLE_CHANGED_TO_FALSE\n", __func__, __LINE__); + dm_wifi_radio_op_param->enable = true; + is_radio_config_changed = true; + if(push_radio_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d ApplyRadioSettings failed\n", __func__, __LINE__); + return false; + } + } + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:force_disable_radio_status=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.force_disable_radio_feature, output_value); + p_global_wifi_cfg->global_parameters.force_disable_radio_feature = output_value; + push_global_config_dml_cache_to_one_wifidb(); + if(output_value) { + wifi_util_info_print(WIFI_DMCLI,"RDK_LOG_WARN, WIFI_FORCE_DISABLE_CHANGED_TO_TRUE\n"); + } + else { + wifi_util_info_print(WIFI_DMCLI,"RDK_LOG_WARN, WIFI_FORCE_DISABLE_CHANGED_TO_FALSE\n"); + } + } else if (STR_CMP(param_name, "Managed_WiFi_Enabled")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d push_managed_wifi_disable_to_ctrl_queue to ctrl queue\n", __func__, __LINE__); + if (!output_value) { + if (push_managed_wifi_disable_to_ctrl_queue() == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Failed to push_managed_wifi_disable_to_ctrl_queue to ctrl queue\n", __func__, __LINE__); + return false; + } + } else { + wifi_util_error_print(WIFI_DMCLI,"Managed-WIFI cannot be enabled through TR-181\n"); + return false; + } + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_EnableRadiusGreyList")) { +#if defined (FEATURE_SUPPORT_RADIUSGREYLIST) + wifi_global_config_t *p_global_wifi_cfg; + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + p_global_wifi_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + if (output_value != p_rfc_cfg->radiusgreylist_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value,wifi_event_type_radius_grey_list_rfc); + } + + if (output_value && p_global_wifi_cfg->global_parameters.prefer_private) { + wifi_util_dbg_print(WIFI_DMCLI,"prefer_private is set to false when radiusgreylist is enabled\n"); + p_global_wifi_cfg->global_parameters.prefer_private = false; + push_global_config_dml_cache_to_one_wifidb(); + push_prefer_private_ctrl_queue(false); + } +#if 0 + if (ANSC_STATUS_SUCCESS == CosaDmlWiFiSetEnableRadiusGreylist( output_value )) + { + return true; + } +#endif//TBD +#endif + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_EnableHostapdAuthenticator")) { + } else if (STR_CMP(param_name, "DFS")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->dfs_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_dfs_rfc); + } + } else if (STR_CMP(param_name, "Levl")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->levl_enabled_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_levl_rfc); + } + } else if (STR_CMP(param_name, "DFSatBootUp")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->dfsatbootup_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_dfs_atbootup_rfc); + } + } else if (STR_CMP(param_name, "WiFi-Interworking")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->wifiinterworking_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_wifi_interworking_rfc); + } + } else if (STR_CMP(param_name, "WiFi-Passpoint")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->wifipasspoint_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_wifi_passpoint_rfc); + } + } else if (STR_CMP(param_name, "WiFi-OffChannelScan")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->wifi_offchannelscan_sm_rfc) { + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_wifi_offchannelscan_sm_rfc); + } + } else if (STR_CMP(param_name, "WPA3_Personal_Transition")) { + wifi_rfc_dml_parameters_t *p_rfc_cfg = (wifi_rfc_dml_parameters_t *)get_ctrl_rfc_parameters(); + DM_CHECK_NULL_WITH_RC(p_rfc_cfg, false); + + if(output_value != p_rfc_cfg->wpa3_rfc){ + push_rfc_dml_cache_to_one_wifidb(output_value, wifi_event_type_wpa3_rfc); + } + } else if (STR_CMP(param_name, "Log_Upload")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Log_upload set\n", __func__, __LINE__); + if (output_value) { + get_stubs_descriptor()->v_secure_system_fn("/usr/ccsp/wifi/wifi_logupload.sh start"); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Log_upload started\n", __func__, __LINE__); + } else { + get_stubs_descriptor()->v_secure_system_fn("/usr/ccsp/wifi/wifi_logupload.sh stop"); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Log_upload stopped\n", __func__, __LINE__); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_config_t *p_global_wifi_cfg = (wifi_global_config_t *) get_dml_cache_global_wifi_config(); + + DM_CHECK_NULL_WITH_RC(p_global_wifi_cfg, false); + + /* check the parameter name and set the corresponding value */ + if (STR_CMP(param_name, "X_RDKCENTRAL-COM_GoodRssiThreshold")) { + if(p_global_wifi_cfg->global_parameters.good_rssi_threshold == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:good_rssi_threshold=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.good_rssi_threshold, output_value); + p_global_wifi_cfg->global_parameters.good_rssi_threshold = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_AssocCountThreshold")) { + if (p_global_wifi_cfg->global_parameters.assoc_count_threshold == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:assoc_count_threshold=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.assoc_count_threshold, output_value); + p_global_wifi_cfg->global_parameters.assoc_count_threshold = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_AssocMonitorDuration")) { + if (p_global_wifi_cfg->global_parameters.assoc_monitor_duration == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:assoc_monitor_duration=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.assoc_monitor_duration, output_value); + p_global_wifi_cfg->global_parameters.assoc_monitor_duration = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_AssocGateTime")) { + if (p_global_wifi_cfg->global_parameters.assoc_gate_time == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:assoc_gate_time=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.assoc_gate_time, output_value); + p_global_wifi_cfg->global_parameters.assoc_gate_time = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "WHIX_LogInterval")) { + if (p_global_wifi_cfg->global_parameters.whix_log_interval == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: WHIX_LogInterval=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.whix_log_interval, output_value); + p_global_wifi_cfg->global_parameters.whix_log_interval = output_value; //update global structure + if (push_global_config_dml_cache_to_one_wifidb() != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Failed to push WHIX_LogInterval to onewifi db\n",__func__, __LINE__); + } + } else if (STR_CMP(param_name, "WHIX_ChUtility_LogInterval")) { + if (p_global_wifi_cfg->global_parameters.whix_chutility_loginterval == output_value) { + return true; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: WHIX_chutility_LogInterval=%d Value=%d\n",__func__, __LINE__, + p_global_wifi_cfg->global_parameters.whix_chutility_loginterval, output_value); + p_global_wifi_cfg->global_parameters.whix_chutility_loginterval = output_value; //update global structure + if (push_global_config_dml_cache_to_one_wifidb() != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Failed to push WHIX_LogInterval to onewifi db\n",__func__, __LINE__); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + + return true; +} + +bool wifi_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + DM_CHECK_NULL_WITH_RC(output_value, false); + DM_CHECK_NULL_WITH_RC(output_value->buff, false); + + dml_global_default *p_global_def = (dml_global_default *) get_global_default_obj(); + if(p_global_def == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointerr get fail\n", __func__, __LINE__); + return false; + } + + if (STR_CMP(param_name, "X_CISCO_COM_RadioPower")) { + STR_COPY(p_global_def->RadioPower, output_value->buff); + } else if (STR_CMP(param_name, "X_CISCO_COM_FactoryResetRadioAndAp")) { + fprintf(stderr, "-- %s X_CISCO_COM_FactoryResetRadioAndAp %s\n", __func__, (char *)output_value->buff); + if (wifi_factory_reset(false) != true) { + return false; + } + } else if (STR_CMP(param_name, "X_RDK_VapData")) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: This param set:%s is not supported\n",__func__, + __LINE__, param_name); + return false; + } else if (STR_CMP(param_name, "X_RDK_RadioData")) { +#if defined (FEATURE_SUPPORT_WEBCONFIG) + if (dm_wifi_set_webconfig(output_value->buff, output_value->buff_len) == RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"Success in parsing Radio Config\n"); + return true; + } else { + wifi_util_error_print(WIFI_DMCLI,"Failed to parse Radio blob\n"); + return false; + } +#else + return false; +#endif + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_WiFi_Notification")) { + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_Connected-Client")) { + + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_Br0_Sync")) { + } else if (STR_CMP(param_name, "Status")) { + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_GASConfiguration")) { + if(WiFi_SetGasConfig(output_value->buff) == RETURN_OK) { + return true; + } else { + wifi_util_error_print(WIFI_DMCLI,"Failed to Set GAS Configuration\n"); + return false; + } + } else if (STR_CMP(param_name, "Log_Enable")) { + if (disable_dbg_logs(output_value->buff) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d log disable is failed:%s\n", __func__, __LINE__, + output_value->buff); + return RETURN_ERR; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + + if (STR_CMP(param_name, "Enable")) { + *output_value = pcfg->enable; + } else if (STR_CMP(param_name, "AutoChannelSupported")) { + *output_value = true; + } else if (STR_CMP(param_name, "AutoChannelEnable")) { + *output_value = pcfg->autoChannelEnabled; + } else if (STR_CMP(param_name, "IEEE80211hSupported")) { + *output_value = true; + } else if (STR_CMP(param_name, "IEEE80211hEnabled")) { + *output_value = dm_radio_default->IEEE80211hEnabled; + } else if (STR_CMP(param_name, "X_CISCO_COM_FrameBurst")) { + *output_value = dm_radio_default->FrameBurst; + } else if (STR_CMP(param_name, "X_CISCO_COM_APIsolation")) { + *output_value = dm_radio_default->APIsolation; + } else if (STR_CMP(param_name, "X_CISCO_COM_ApplySetting")) { + + } else if (STR_CMP(param_name, "X_COMCAST_COM_DFSSupport")) { + wifi_radio_capabilities_t radio_capab = ((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop.radiocap[radio_index]; + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d X_COMCAST_COM_DFSSupport band %d num_channels %d\n", __func__, __LINE__, + pcfg->band, radio_capab.channel_list[0].num_channels); + for (int i = 0; i < radio_capab.channel_list[0].num_channels; i++) { + if ((pcfg->band == WIFI_FREQUENCY_5_BAND || pcfg->band == WIFI_FREQUENCY_5L_BAND || pcfg->band == WIFI_FREQUENCY_5H_BAND) + && (radio_capab.channel_list[0].channels_list[i] >= 52 && radio_capab.channel_list[0].channels_list[i] <= 144)) { + *output_value = true; + return true; + } + } + *output_value = false; + } else if (STR_CMP(param_name, "X_COMCAST_COM_DFSEnable")) { + *output_value = pcfg->DfsEnabled; + } else if (STR_CMP(param_name, "X_COMCAST-COM_RtsThresholdSupported")) { + *output_value = false; + } else if (STR_CMP(param_name, "X_RDK_EcoPowerDown")) { +#if defined (FEATURE_SUPPORT_ECOPOWERDOWN) + *output_value = pcfg->EcoPowerDown; +#else + *output_value = false; +#endif // defined (FEATURE_SUPPORT_ECOPOWERDOWN) + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + + if (STR_CMP(param_name, "MCS")) { + *output_value = dm_radio_default->MCS; + } else if (STR_CMP(param_name, "TransmitPower")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: tx_power:%d\n",__func__, __LINE__, pcfg->transmitPower); + *output_value = pcfg->transmitPower; + } else if (STR_CMP(param_name, "X_CISCO_COM_MbssUserControl")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: userControl:%d\n",__func__, __LINE__, pcfg->userControl); + *output_value = pcfg->userControl; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_clientInactivityTimeout")) { + *output_value = 0; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + if (STR_CMP(param_name, "Channel")) { + /* collect value */ + *output_value = pcfg->channel; + } else if (STR_CMP(param_name, "AutoChannelRefreshPeriod")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + *output_value = dm_radio_default->AutoChannelRefreshPeriod; + } else if (STR_CMP(param_name, "X_CISCO_COM_RTSThreshold")) { + *output_value = pcfg->rtsThreshold; + } else if (STR_CMP(param_name, "X_CISCO_COM_FragmentationThreshold")) { + *output_value = pcfg->fragmentationThreshold; + } else if (STR_CMP(param_name, "X_CISCO_COM_DTIMInterval")) { + *output_value = pcfg->dtimPeriod; + } else if (STR_CMP(param_name, "X_COMCAST-COM_BeaconInterval") || + (STR_CMP(param_name, "BeaconPeriod"))) { + *output_value = pcfg->beaconInterval; + } else if (STR_CMP(param_name, "X_CISCO_COM_CTSProtectionMode")) { + *output_value = (false == pcfg->ctsProtection) ? 0 : 1; + } else if (STR_CMP(param_name, "X_CISCO_COM_TxRate")) { + *output_value = pcfg->transmitPower; + } else if (STR_CMP(param_name, "X_CISCO_COM_BasicRate")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + *output_value = dm_radio_default->BasicRate; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_ChannelUtilThreshold")) { + *output_value = pcfg->chanUtilThreshold; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_ChanUtilSelfHealEnable")) { + *output_value = pcfg->chanUtilSelfHealEnable; + } else if (STR_CMP(param_name, "RadioResetCount")) { + *output_value = radio_reset_count; + } else if (STR_CMP(param_name, "ExtensionChannel")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + *output_value = dm_radio_default->ExtensionChannel; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + wifi_global_config_t *dm_wifi_global_cfg; + + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + + if (STR_CMP(param_name, "Name")) { + /* collect value */ + wifi_interface_name_t str_ifname; + wifi_platform_property_t *wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + + if (convert_radio_index_to_ifname(wifi_prop, radio_index, str_ifname, sizeof(str_ifname) - 1) != RETURN_OK) { + set_output_string(output_value, "Invalid_Radio"); + } + set_output_string(output_value, str_ifname); + } else if (STR_CMP(param_name, "Status")) { + wifi_platform_property_t *wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + + if (dm_wifi_global_cfg->global_parameters.force_disable_radio_feature == true) { + set_output_string(output_value, "Down"); + } else if (get_radio_presence(wifi_prop, radio_index) == false) { + set_output_string(output_value, "DeepSleep"); + } else if (pcfg->enable == true) { + set_output_string(output_value, "Up"); + } else { + set_output_string(output_value, "Down"); + } + } else if (STR_CMP(param_name, "OperatingFrequencyBand") || STR_CMP(param_name, "SupportedFrequencyBands")) { + /* collect value */ + char buff[16] = { 0 }; + + if (get_radio_band_string_from_int(pcfg->band, buff) != RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: radio band string convert failed:%d\n",__func__, __LINE__, pcfg->band); + return false; + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "SupportedStandards")) { + set_output_string(output_value, dm_radio_default->SupportedStandards); + } else if (STR_CMP(param_name, "OperatingStandards")) { + char buff[16] = { 0 }; + + if (get_radio_variant_string_from_int(pcfg->variant, buff) == 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: radio variant string convert failed:%d\n",__func__, __LINE__, pcfg->variant); + return false; + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "PossibleChannels")) { + wifi_rfc_dml_parameters_t *rfc_params = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + wifi_radio_capabilities_t *radio_cap; + char buff[256] = { 0 }; + + radio_cap = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop.radiocap[radio_index]; + if (get_allowed_channels_str(pcfg->band, radio_cap, buff, sizeof(buff), rfc_params->dfs_rfc) != RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: get allowed_channels_str is failed:%d\n",__func__, __LINE__, radio_index); + return false; + } + + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "ChannelsInUse")) { + char buff[16] = { 0 }; + snprintf(buff, sizeof(buff), "%d", pcfg->channel); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "X_CISCO_COM_ApChannelScan")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "OperatingChannelBandwidth")) { + char buff[16] = { 0 }; + + if (get_radio_bandwidth_string_from_int(pcfg->channelWidth, buff) == 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: get radio bw is failed:%d\n",__func__, __LINE__, radio_index); + return false; + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "GuardInterval")) { + char buff[8] = { 0 }; + + if (get_radio_guard_interval_string_from_int(pcfg->guardInterval, buff) == 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: get radio guardInterval is failed:%d\n",__func__, + __LINE__, radio_index); + return false; + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "TransmitPowerSupported")) { + set_output_string(output_value, dm_radio_default->TransmitPowerSupported); + } else if (STR_CMP(param_name, "RegulatoryDomain")) { + char reg_domain_str[4]; + memset(reg_domain_str, 0, sizeof(reg_domain_str)); + if (get_reg_domain_string_from_int(pcfg->countryCode, pcfg->operatingEnvironment, reg_domain_str) == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: get regulatory domain is failed:%d\n",__func__, + __LINE__, pcfg->countryCode); + return false; + } + + set_output_string(output_value, reg_domain_str); + } else if (STR_CMP(param_name, "BasicDataTransmitRates")) { + char buff[64] = { 0 }; + + if (get_wifi_data_tx_rate_string_from_int(pcfg->basicDataTransmitRates, buff) == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: get basic data tx rates is failed:%d\n",__func__, + __LINE__, pcfg->basicDataTransmitRates); + return false; + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "SupportedDataTransmitRates")) { + set_output_string(output_value, "6,9,12,18,24,36,48,54"); + } else if (STR_CMP(param_name, "OperationalDataTransmitRates")) { + char buff[64] = { 0 }; + + if (get_wifi_data_tx_rate_string_from_int(pcfg->operationalDataTransmitRates, buff) == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: get operational data tx rates is failed:%d\n",__func__, + __LINE__, pcfg->operationalDataTransmitRates); + return false; + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "Alias")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + set_output_string(output_value, dm_radio_default->Alias); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + wifi_global_config_t *dm_wifi_global_cfg; + wifi_radio_operationParam_t *dm_radio_param; + + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + dm_radio_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(radio_index); + if (dm_radio_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param for radio_index:%d\n", __func__, __LINE__, radio_index); + return false; + } + + if ((radio_index < 0) || (radio_index > (int)get_num_radio_dml())) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Radio index:%d out of range\n", radio_index); + return false; + } + + if(STR_CMP(param_name, "Enable")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: enable=%d set value=%d radio_index=%d\n", __func__, __LINE__, + dm_radio_param->enable, output_value, radio_index); + if(dm_wifi_global_cfg->global_parameters.force_disable_radio_feature) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, __LINE__); + return false; + } + if (get_radio_presence(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, radio_index) == false) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Not allowed to change config when radio is not present in CPE \n", __func__, __LINE__); + return false; + } + if (dm_radio_param->enable == output_value) { + return true; + } + /* save update to backup */ + dm_radio_param->enable = output_value; + is_radio_config_changed = true; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: RadioEnable : %d\n",__func__, __LINE__, dm_radio_param->enable); + } else if (STR_CMP(param_name, "AutoChannelEnable")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:autoChannelEnabled=%d set value=%d\n",__func__, __LINE__, + dm_radio_param->autoChannelEnabled, output_value); + if (dm_radio_param->autoChannelEnabled == output_value) { + return true; + } + /* save update to backup */ + dm_radio_param->autoChannelEnabled = output_value; + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "IEEE80211hEnabled")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + dm_radio_default->IEEE80211hEnabled = output_value; + } else if (STR_CMP(param_name, "X_CISCO_COM_FrameBurst")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + dm_radio_default->FrameBurst = output_value; + } else if (STR_CMP(param_name, "APIsolation")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + dm_radio_default->APIsolation = output_value; + } else if (STR_CMP(param_name, "X_CISCO_COM_ApplySetting")) { + + } else if (STR_CMP(param_name, "X_COMCAST_COM_DFSEnable")) { + wifi_rfc_dml_parameters_t *rfc_pcfg = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + if (!(rfc_pcfg->dfs_rfc)) { + wifi_util_info_print(WIFI_DMCLI,"DFS RFC DISABLED\n"); + return false; + } + dm_radio_param->DfsEnabled = output_value; + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "X_RDK_EcoPowerDown")) { +#if defined (FEATURE_SUPPORT_ECOPOWERDOWN) + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: EcoPowerDown=%d input=%d\n", __func__, __LINE__, + dm_radio_param->EcoPowerDown, output_value); + if (dm_radio_param->EcoPowerDown == output_value) { + return true; + } + /* save update to backup */ + dm_radio_param->EcoPowerDown = output_value; +#ifdef FEATURE_SUPPORT_ECOPOWERDOWN + dm_radio_param->enable = ((dm_radio_param->EcoPowerDown) ? false : true); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: Updated radio enable status based on EcoPowerDown,=%d, Enable=%d\n", __func__, + __LINE__, dm_radio_param->EcoPowerDown, dm_radio_param->enable); +#endif // FEATURE_SUPPORT_ECOPOWERDOWN + is_radio_config_changed = true; +#endif // defined (FEATURE_SUPPORT_ECOPOWERDOWN) + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + wifi_radio_operationParam_t *dm_radio_param; + dm_radio_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(radio_index); + if (dm_radio_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param for radio_index:%d\n", __func__, __LINE__, radio_index); + return false; + } + + if ((radio_index < 0) || (radio_index > (int)get_num_radio_dml())) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Radio index:%d out of range\n", radio_index); + return false; + } + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + + if (STR_CMP(param_name, "MCS")) { + dm_radio_default->MCS = output_value; + } else if (STR_CMP(param_name, "TransmitPower")) { + if (dm_radio_param->transmitPower == (uint32_t)output_value) { + return true; + } else if (is_radio_tx_power_valid(dm_radio_default->TransmitPowerSupported, output_value) != true) { + return false; + } + dm_radio_param->transmitPower = output_value; + is_radio_config_changed = true; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:transmitPower=%d radio_index=%d\n",__func__, __LINE__, + dm_radio_param->transmitPower, radio_index); + } else if (STR_CMP(param_name, "X_CISCO_COM_MbssUserControl")) { + if (dm_radio_param->userControl == (uint32_t)output_value) { + return true; + } + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:userControl=%d\n",__func__, __LINE__, dm_radio_param->userControl); + dm_radio_param->userControl = output_value; + is_radio_config_changed = true; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + wifi_radio_operationParam_t *dm_radio_param; + dm_radio_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(radio_index); + if (dm_radio_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param for radio_index:%d\n", __func__, __LINE__, radio_index); + return false; + } + + if ((radio_index < 0) || (radio_index > (int)get_num_radio_dml())) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Radio index:%d out of range\n", radio_index); + return false; + } + + if (STR_CMP(param_name, "Channel")) { + if (radio_wifi_channel_is_valid(radio_index, output_value) != RETURN_OK) { + return false; + } + if (dm_radio_param->channel == output_value) { + return true; + } + else if ((dm_radio_param->band == WIFI_FREQUENCY_5_BAND) || + (dm_radio_param->band == WIFI_FREQUENCY_5L_BAND) || + (dm_radio_param->band == WIFI_FREQUENCY_5H_BAND)) { + if (is_dfs_channel_allowed(output_value) == false) { + return false; + } + } + + dm_radio_param->channel = output_value; + dm_radio_param->autoChannelEnabled = false; + wifi_util_dbg_print(WIFI_DMCLI,"%s Channel:%d\n", __func__, dm_radio_param->channel); + g_chan_switch_count++; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:channel=%d output_value=%d\n",__func__, __LINE__, + dm_radio_param->channel, output_value); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "AutoChannelRefreshPeriod")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + dm_radio_default->AutoChannelRefreshPeriod = output_value; + } else if (STR_CMP(param_name, "X_CISCO_COM_RTSThreshold")) { + if (dm_radio_param->rtsThreshold == output_value) { + return true; + } + dm_radio_param->rtsThreshold = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s rtsThreshold:%d\n", __func__, dm_radio_param->rtsThreshold); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "X_CISCO_COM_FragmentationThreshold")) { + if (dm_radio_param->fragmentationThreshold == output_value) { + return true; + } + dm_radio_param->fragmentationThreshold = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s fragmentationThreshold:%d\n", __func__, dm_radio_param->fragmentationThreshold); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "X_CISCO_COM_DTIMInterval")) { + if (dm_radio_param->dtimPeriod == output_value) { + return true; + } + dm_radio_param->dtimPeriod = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s dtimPeriod:%d\n", __func__, dm_radio_param->dtimPeriod); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "X_COMCAST-COM_BeaconInterval") || + (STR_CMP(param_name, "BeaconPeriod"))) { + if (dm_radio_param->beaconInterval == output_value) { + return true; + } + dm_radio_param->beaconInterval = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s beaconInterval:%d\n", __func__, dm_radio_param->beaconInterval); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "X_CISCO_COM_CTSProtectionMode")) { + if(dm_radio_param->ctsProtection == output_value) { + return true; + } + + dm_radio_param->ctsProtection = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:ctsProtection=%d\n",__func__, __LINE__, dm_radio_param->ctsProtection); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "ExtensionChannel")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + if (dm_radio_default->ExtensionChannel != output_value) { + dm_radio_default->ExtensionChannel = output_value; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radio_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_radio_operationParam_t *pcfg = (wifi_radio_operationParam_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(output_value, false); + DM_CHECK_NULL_WITH_RC(output_value->buff, false); + + int radio_index = 0; + if (convert_freq_band_to_radio_index(pcfg->band, &radio_index) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Invalid frequency band %X\n", __func__, __LINE__, pcfg->band); + return false; + } + + wifi_radio_operationParam_t *dm_radio_param; + dm_radio_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(radio_index); + if (dm_radio_param == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get Radio Param for radio_index:%d\n", __func__, __LINE__, radio_index); + return false; + } + + if ((radio_index < 0) || (radio_index > (int)get_num_radio_dml())) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Radio index:%d out of range\n", radio_index); + return false; + } + + if (STR_CMP(param_name, "OperatingStandards")) { + wifi_ieee80211Variant_t radio_variant = 0; + wifi_rfc_dml_parameters_t *rfc_pcfg = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + + if ((pcfg->band == WIFI_FREQUENCY_2_4_BAND) && + (rfc_pcfg->twoG80211axEnable_rfc == false) && + (strstr(output_value->buff, "ax") != NULL)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: wifi hw variant:%s radio_band:%d 80211axEnable rfc:%d\n", + __func__, __LINE__, output_value->buff, pcfg->band, rfc_pcfg->twoG80211axEnable_rfc); + return false; + } + + if (get_radio_variant_int_from_string(output_value->buff, &radio_variant) != RETURN_OK) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: wrong wifi std String=%s\n",__func__, __LINE__, output_value->buff); + return false; + } + + wifi_util_dbg_print(WIFI_DMCLI, "WIFI MODE SET[%d]\n", radio_variant); + + if (validate_wifi_hw_variant(pcfg->band, radio_variant) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: wifi hw mode validation failure string=%s hw variant:%d\n",__func__, + __LINE__,output_value->buff, radio_variant); + return false; + } + + uint32_t temp_channel_width = sync_bandwidth_and_hw_variant(radio_variant, dm_radio_param->channelWidth); + if (temp_channel_width != 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d:change bandwidth from %d to %d\r\n",__func__, __LINE__, + dm_radio_param->channelWidth, temp_channel_width); + dm_radio_param->channelWidth = temp_channel_width; + } + + dm_radio_param->variant = radio_variant; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:variant=%d str_variant=%s\n",__func__, __LINE__, radio_variant, output_value->buff); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "OperatingChannelBandwidth")) { + wifi_channelBandwidth_t tmp_chan_width = 0; + wifi_rfc_dml_parameters_t *rfc_pcfg = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + + if (get_radio_bandwidth_int_from_string(output_value->buff, &tmp_chan_width) != RETURN_OK) { + return false; + } else if (dm_radio_param->channelWidth == tmp_chan_width) { + return true; + } + + if ((tmp_chan_width == WIFI_CHANNELBANDWIDTH_160MHZ) && (dm_radio_param->band == WIFI_FREQUENCY_5_BAND) + && (rfc_pcfg->dfs_rfc != true)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: DFS Disabled!! Cannot set to chan_width=%d\n",__func__, + __LINE__, tmp_chan_width); + return false; + } + + if (dm_radio_param->band == WIFI_FREQUENCY_2_4_BAND) { + if ((tmp_chan_width != WIFI_CHANNELBANDWIDTH_20MHZ) && + (tmp_chan_width != WIFI_CHANNELBANDWIDTH_40MHZ)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d:Cannot set chan_width=%d for band:%d\n",__func__, __LINE__, + tmp_chan_width, dm_radio_param->band); + return false; + } + } + + if (is_bandwidth_and_hw_variant_compatible(dm_radio_param->variant, tmp_chan_width) != true) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d:chan_width=%d variant:%d\n",__func__, __LINE__, + tmp_chan_width, dm_radio_param->variant); + return false; + } + + dm_radio_param->channelWidth = tmp_chan_width; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: New channelWidth=%d\n", __func__, __LINE__, dm_radio_param->channelWidth); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "GuardInterval")) { + wifi_guard_interval_t tmp_guard_interval = 0; + + if (get_radio_guard_interval_int_from_string(output_value->buff, &tmp_guard_interval) != RETURN_OK) { + return false; + } else if(dm_radio_param->guardInterval == tmp_guard_interval) { + return true; + } + + dm_radio_param->guardInterval = tmp_guard_interval; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:guardInterval=%d tmpChanWidth=%d\n",__func__, __LINE__, + dm_radio_param->guardInterval, tmp_guard_interval); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "RegulatoryDomain")) { + wifi_countrycode_type_t temp_country_code = 0; + wifi_operating_env_t temp_oper_env = 0; + char partner_id[PARTNER_ID_LEN] = {0}; + char current_time[50] = { 0 }; + char requestor_str[16] = { 0 }; + + get_requestor_string(requestor_str); + get_cur_time_str(current_time, sizeof(current_time)); + + if (get_reg_domain_int_from_string(output_value->buff, &temp_country_code, &temp_oper_env) != RETURN_OK) { + return false; + } else if ((dm_radio_param->countryCode == temp_country_code) && + (dm_radio_param->operatingEnvironment == temp_oper_env)) { + return true; + } + + dm_radio_param->countryCode = temp_country_code; + dm_radio_param->operatingEnvironment = temp_oper_env; + + if (radio_index == 1) { + wifi_global_config_t *dm_wifi_global_cfg; + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + snprintf(dm_wifi_global_cfg->global_parameters.wifi_region_code, + sizeof(dm_wifi_global_cfg->global_parameters.wifi_region_code), "%s", (char *)output_value->buff); + g_update_wifi_region = true; + if((RETURN_OK == get_partner_id(partner_id)) && (partner_id[ 0 ] != '\0')) { + if (update_json_param("Device.WiFi.X_RDKCENTRAL-COM_Syndication.WiFiRegion.Code",partner_id, + output_value->buff, requestor_str, current_time) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to update WifiRegion to Json file\n", __func__, __LINE__); + } + } + set_wifi_region_update_source(requestor_str); + } + + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: country code=%d environment=%d input=%s\n",__func__, + __LINE__, dm_radio_param->countryCode, dm_radio_param->operatingEnvironment, output_value->buff); + is_radio_config_changed = true; + } else if (STR_CMP(param_name, "BasicDataTransmitRates")) { + uint32_t tx_rate = 0; + + if (is_valid_transmit_rate(output_value->buff)) { + if (get_wifi_data_tx_rate_int_from_string(output_value->buff, &tx_rate) != RETURN_OK) { + return false; + } + + if(dm_radio_param->basicDataTransmitRates == tx_rate) { + return true; + } + dm_radio_param->basicDataTransmitRates = tx_rate; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:BasicDataTransmitRates=%d\n",__func__, __LINE__, + dm_radio_param->basicDataTransmitRates); + is_radio_config_changed = true; + } + } else if (STR_CMP(param_name, "OperationalDataTransmitRates")) { + uint32_t tx_rate = 0; + + if (is_valid_transmit_rate(output_value->buff)) { + if (get_wifi_data_tx_rate_int_from_string(output_value->buff, &tx_rate) != RETURN_OK) { + return false; + } + + if(dm_radio_param->operationalDataTransmitRates == tx_rate) { + return true; + } + dm_radio_param->operationalDataTransmitRates = tx_rate; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:operational Data Transmit Rates = %d\n",__func__, __LINE__, + dm_radio_param->operationalDataTransmitRates); + is_radio_config_changed = true; + } + } else if (STR_CMP(param_name, "Alias")) { + dml_radio_default *dm_radio_default = get_radio_default_obj(radio_index); + DM_CHECK_NULL_WITH_RC(dm_radio_default, false); + + if (STR_CMP(dm_radio_default->Alias, output_value->buff)) { + return true; + } + STR_COPY(dm_radio_default->Alias, output_value->buff); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (isVapSTAMesh(pcfg->vap_index) && !STR_CMP(param_name, "Enable")) { + *output_value = true; + return true; + } + + if (STR_CMP(param_name, "Enable")) { + /* collect value */ + if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = pcfg->u.sta_info.enabled; + } else { + *output_value = pcfg->u.bss_info.enabled; + } + } else if(STR_CMP(param_name, "IsolationEnable")) { + *output_value = pcfg->u.bss_info.isolation; + } else if(STR_CMP(param_name, "SSIDAdvertisementEnabled")) { + *output_value = pcfg->u.bss_info.showSsid; + } else if(STR_CMP(param_name, "WMMCapability")) { + *output_value = true; + } else if(STR_CMP(param_name, "UAPSDCapability")) { + *output_value = true; + } else if(STR_CMP(param_name, "WMMEnable")) { + *output_value = pcfg->u.bss_info.wmm_enabled; + } else if(STR_CMP(param_name, "UAPSDEnable")) { + *output_value = pcfg->u.bss_info.UAPSDEnabled; + } else if(STR_CMP(param_name, "X_CISCO_COM_BssCountStaAsCpe")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->bss_count_sta_as_cpe; + } else if(STR_CMP(param_name, "X_CISCO_COM_BssHotSpot")) { + *output_value = pcfg->u.bss_info.bssHotspot; + } else if(STR_CMP(param_name, "X_CISCO_COM_KickAssocDevices")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->kick_assoc_devices; + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_InterworkingServiceCapability")) { +#if defined (FEATURE_SUPPORT_INTERWORKING) + return true; +#else + *output_value = false; +#endif + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_InterworkingServiceEnable")) { +#if defined (FEATURE_SUPPORT_INTERWORKING) + *output_value = pcfg->u.bss_info.interworking.interworking.interworkingEnabled; +#else + *output_value = false; +#endif + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_rapidReconnectCountEnable")) { + *output_value = pcfg->u.bss_info.rapidReconnectEnable; + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_StatsEnable")) { + *output_value = pcfg->u.bss_info.vapStatsEnable; + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_BSSTransitionImplemented")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapHotspot(vap_index) || isVapSTAMesh(vap_index) || (vap_index == 3)) { + *output_value = false; + } else { + *output_value = true; + } + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_BSSTransitionActivated")) { + *output_value = pcfg->u.bss_info.bssTransitionActivated; + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_NeighborReportActivated")) { + *output_value = pcfg->u.bss_info.nbrReportActivated; + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_WirelessManagementImplemented")) { + *output_value = 1; + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_InterworkingApplySettings")) { + *output_value = true; + } else if(STR_CMP(param_name, "Connected_Building_Enabled")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if(isVapHotspot(vap_index)) { + *output_value = pcfg->u.bss_info.connected_building_enabled; + } else { + *output_value = false; + } + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_HostapMgtFrameCtrl")) { + *output_value = pcfg->u.bss_info.hostap_mgt_frame_ctrl; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (STR_CMP(param_name, "X_CISCO_COM_WmmNoAck")) { + if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = 0; + } else { + *output_value = pcfg->u.bss_info.wmmNoAck; + } + } else if (STR_CMP(param_name, "X_CISCO_COM_MulticastRate")) { + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->multicast_rate; + } else if (STR_CMP(param_name, "X_CISCO_COM_BssMaxNumSta")) { + *output_value = pcfg->u.bss_info.bssMaxSta; + } else if (STR_CMP(param_name, "X_CISCO_COM_BssUserStatus")) { + if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = (pcfg->u.sta_info.enabled == TRUE)? 1 : 2; + } else { + *output_value = (pcfg->u.bss_info.enabled == TRUE)? 1 : 2; + } + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_ManagementFramePowerControl")) { + if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = 0; + } else { + *output_value = pcfg->u.bss_info.mgmtPowerControl; + wifi_util_info_print(WIFI_DMCLI,"RDK_LOG_INFO,X_RDKCENTRAL-COM_ManagementFramePowerControl:%d\n", pcfg->u.bss_info.mgmtPowerControl); + wifi_util_info_print(WIFI_DMCLI,"X_RDKCENTRAL-COM_ManagementFramePowerControl_Get:<%d>\n", pcfg->u.bss_info.mgmtPowerControl); + } + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_rapidReconnectMaxTime")) { + if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = 180; + } else { + *output_value = pcfg->u.bss_info.rapidReconnThreshold; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (STR_CMP(param_name, "RetryLimit")) { + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->retry_limit; + } else if (STR_CMP(param_name, "X_CISCO_COM_LongRetryLimit")) { + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->long_retry_limit; + } else if (STR_CMP(param_name, "MaxAssociatedDevices")) { + *output_value = pcfg->u.bss_info.bssMaxSta; + } else if (STR_CMP(param_name, "X_COMCAST-COM_AssociatedDevicesHighWatermarkThreshold")) { + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->associated_devices_highwatermark_threshold; + } else if (STR_CMP(param_name, "X_COMCAST-COM_AssociatedDevicesHighWatermarkThresholdReached")) { + *output_value = 3; + } else if (STR_CMP(param_name, "X_COMCAST-COM_AssociatedDevicesHighWatermark")) { + *output_value = 3; + } else if (STR_CMP(param_name, "X_COMCAST-COM_AssociatedDevicesHighWatermarkDate")) { + //TODO: need cacultion for the time + *output_value = (uint32_t)get_current_time_in_sec(); + } else if (STR_CMP(param_name, "X_COMCAST-COM_TXOverflow")) { + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->txoverflow; + } else if (STR_CMP(param_name, "X_CISCO_COM_MacFilterTableNumberOfEntries")) { + max_macfilter_number_of_entries(pcfg, output_value); + } else if (STR_CMP(param_name, "AssociatedDeviceNumberOfEntries")) { + *output_value = (uint32_t)get_associated_devices_count(pcfg); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + + if (STR_CMP(param_name, "Status")) { + if (isVapSTAMesh(pcfg->vap_index)) { + if (pcfg->u.sta_info.enabled == true) { + set_output_string(output_value, "Enabled"); + } else { + set_output_string(output_value, "Disabled"); + } + } else { + if (pcfg->u.bss_info.enabled == true) { + set_output_string(output_value, "Enabled"); + } else { + set_output_string(output_value, "Disabled"); + } + } + } else if (STR_CMP(param_name, "Alias")) { + char buff[16] = { 0 }; + + snprintf(buff, sizeof(buff), "AccessPoint%d", instance_number); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "SSIDReference")) { + char buff[32] = { 0 }; + + snprintf(buff, sizeof(buff), "Device.WiFi.SSID.%d.", instance_number); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_BeaconRate")) { + char buff[32] = { 0 }; + + if (isVapSTAMesh(pcfg->vap_index)) { + set_output_string(output_value, "6Mbps"); + return true; + } + + if (get_beacon_rate_string_from_int(pcfg->u.bss_info.beaconRate, buff) == 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: beacon rate str not found:%d\n",__func__, + __LINE__, pcfg->u.bss_info.beaconRate); + set_output_string(output_value, " "); + } else { + set_output_string(output_value, buff); + } + } else if (STR_CMP(param_name, "X_COMCAST-COM_MAC_FilteringMode")) { + char buff[32] = { 0 }; + + if (isVapHotspot(pcfg->vap_index)) { + snprintf(buff, sizeof(buff), "%s", "Deny"); + } else { + if (pcfg->u.bss_info.mac_filter_enable == TRUE) { + if (pcfg->u.bss_info.mac_filter_mode == wifi_mac_filter_mode_black_list) { + snprintf(buff, sizeof(buff), "%s", "Deny"); + } else { + snprintf(buff, sizeof(buff), "%s", "Allow"); + } + } else { + snprintf(buff, sizeof(buff), "%s", "Allow-ALL"); + } + } + set_output_string(output_value, buff); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_global_config_t *dm_wifi_global_cfg; + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + + if (isVapSTAMesh(pcfg->vap_index) && !STR_CMP(param_name, "Enable")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + if(STR_CMP(param_name, "Enable")) { + if (dm_wifi_global_cfg->global_parameters.force_disable_radio_feature) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, __LINE__); + return false; + } + if (isVapSTAMesh(pcfg->vap_index)) { + p_dm_vap_info->u.sta_info.enabled = output_value; + } else { + p_dm_vap_info->u.bss_info.enabled = output_value; + } + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "IsolationEnable")) { + if (p_dm_vap_info->u.bss_info.isolation == output_value) { + return true; + } + + /* save update to backup */ + p_dm_vap_info->u.bss_info.isolation = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "SSIDAdvertisementEnabled")) { + if (p_dm_vap_info->u.bss_info.showSsid == output_value) { + return true; + } + + /* save update to backup */ + p_dm_vap_info->u.bss_info.showSsid = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "WMMEnable")) { + if (p_dm_vap_info->u.bss_info.wmm_enabled == output_value) { + return true; + } + + /* save update to backup */ + p_dm_vap_info->u.bss_info.wmm_enabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "UAPSDEnable")) { + if (p_dm_vap_info->u.bss_info.UAPSDEnabled == output_value) { + return true; + } + /* save update to backup */ + p_dm_vap_info->u.bss_info.UAPSDEnabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "X_CISCO_COM_BssCountStaAsCpe")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + p_dm_vap_default->bss_count_sta_as_cpe = output_value; + } else if(STR_CMP(param_name, "X_CISCO_COM_BssHotSpot")) { + if (p_dm_vap_info->u.bss_info.bssHotspot == output_value) { + return true; + } + /* save update to backup */ + p_dm_vap_info->u.bss_info.bssHotspot = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "X_CISCO_COM_KickAssocDevices")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + p_dm_vap_default->kick_assoc_devices = output_value; + if (p_dm_vap_default->kick_assoc_devices) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Pushing Kick assoc to control queue:%d\n", __func__, + __LINE__, vap_index); + push_kick_assoc_to_ctrl_queue(vap_index); + p_dm_vap_default->kick_assoc_devices = false; + } + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_BSSTransitionActivated")) { + if (p_dm_vap_info->u.bss_info.bssTransitionActivated == output_value) { + return true; + } + p_dm_vap_info->u.bss_info.bssTransitionActivated = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + if (push_vap_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Apply BSSTransitionActivated falied\n",__func__, __LINE__); + return false; + } + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_rapidReconnectCountEnable")) { + if (p_dm_vap_info->u.bss_info.rapidReconnectEnable == output_value) { + return true; + } + p_dm_vap_info->u.bss_info.rapidReconnectEnable = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_StatsEnable")) { + if (p_dm_vap_info->u.bss_info.vapStatsEnable == output_value) { + return true; + } + p_dm_vap_info->u.bss_info.vapStatsEnable = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_NeighborReportActivated")) { + if (p_dm_vap_info->u.bss_info.nbrReportActivated == output_value) { + return true; + } + p_dm_vap_info->u.bss_info.nbrReportActivated = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + if (push_vap_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Apply NeighborReportActivated falied\n",__func__, __LINE__); + return false; + } + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_InterworkingServiceEnable")) { + if (p_dm_vap_info->u.bss_info.interworking.interworking.interworkingEnabled == output_value) { + return true; + } + p_dm_vap_info->u.bss_info.interworking.interworking.interworkingEnabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_InterworkingApplySettings")) { + if (output_value == true) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d X_RDKCENTRAL-COM_InterworkingApplySettings push to queue \n",__func__, __LINE__); + if (push_vap_dml_cache_to_one_wifidb() == RETURN_ERR) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d X_RDKCENTRAL-COM_InterworkingApplySettings falied \n",__func__, __LINE__); + return false; + } + last_vap_change = get_current_time_in_sec(); + } + } else if(STR_CMP(param_name, "connected_building_enabled")) { + if (!isVapHotspot(instance_number - 1)) { + wifi_util_error_print(WIFI_DMCLI,"RDK_LOG_ERROR, %s connected_building_enabled not supported for vaps other than public vaps\n", __func__); + return false; + } + p_dm_vap_info->u.bss_info.connected_building_enabled = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: connected_building_enabled Value=%d\n",__func__, + __LINE__, p_dm_vap_info->u.bss_info.connected_building_enabled); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "X_RDKCENTRAL-COM_HostapMgtFrameCtrl")) { + p_dm_vap_info->u.bss_info.hostap_mgt_frame_ctrl = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + + wifi_util_dbg_print(WIFI_DMCLI, "%s:%d: hostap_mgt_frame_ctrl value=%d\n", __func__, + __LINE__, p_dm_vap_info->u.bss_info.hostap_mgt_frame_ctrl); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "X_CISCO_COM_WmmNoAck")) { + if (p_dm_vap_info->u.bss_info.wmmNoAck == (uint32_t)output_value) { + return true; + } + /* save update to backup */ + p_dm_vap_info->u.bss_info.wmmNoAck = (uint32_t)output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "X_CISCO_COM_MulticastRate")) { + dml_vap_default *p_dm_vap_default = get_vap_default(instance_number - 1); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + p_dm_vap_default->multicast_rate = output_value; + } else if (STR_CMP(param_name, "X_CISCO_COM_BssMaxNumSta")) { + if (p_dm_vap_info->u.bss_info.bssMaxSta == (uint32_t)output_value) { + return true; + } + + /* Allow users to set max station for given VAP */ + p_dm_vap_info->u.bss_info.bssMaxSta = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_ManagementFramePowerControl")) { + if ((output_value < -20) || (output_value > 0)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unsupported Value for ManagementFramePowerControl" + ": Supports in the Range [-20,0]:%d\n", __func__, __LINE__, output_value); + return false; + } else if (p_dm_vap_info->u.bss_info.mgmtPowerControl == output_value) { + return true; + } else { + /* save update to backup */ + p_dm_vap_info->u.bss_info.mgmtPowerControl = output_value; + wifi_util_info_print(WIFI_DMCLI,"RDK_LOG_INFO,X_RDKCENTRAL-COM_ManagementFramePowerControl:%d\n", output_value); + wifi_util_info_print(WIFI_DMCLI,"X_RDKCENTRAL-COM_ManagementFramePowerControl_Get:<%d>\n", output_value); + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_rapidReconnectMaxTime")) { + if (p_dm_vap_info->u.bss_info.rapidReconnThreshold == (uint32_t)output_value) { + return true; + } + /* save update to backup */ + p_dm_vap_info->u.bss_info.rapidReconnThreshold = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (STR_CMP(param_name, "RetryLimit")) { + dml_vap_default *p_dm_vap_default = get_vap_default(instance_number - 1); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + p_dm_vap_default->retry_limit = output_value; + } else if (STR_CMP(param_name, "X_CISCO_COM_LongRetryLimit")) { + dml_vap_default *p_dm_vap_default = get_vap_default(instance_number - 1); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + p_dm_vap_default->long_retry_limit = output_value; + } else if (STR_CMP(param_name, "MaxAssociatedDevices")) { + + if (isVapSTAMesh(p_dm_vap_info->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, p_dm_vap_info->vap_name); + return TRUE; + } else if (p_dm_vap_info->u.bss_info.bssMaxSta != output_value) { + p_dm_vap_info->u.bss_info.bssMaxSta = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "X_COMCAST-COM_AssociatedDevicesHighWatermarkThreshold")) { + dml_vap_default *p_dm_vap_default = get_vap_default(instance_number - 1); + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + p_dm_vap_default->associated_devices_highwatermark_threshold = output_value; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool accesspoint_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "X_RDKCENTRAL-COM_BeaconRate")) { + wifi_bitrate_t beacon_rate_type = 0; + + if (get_beacon_rate_int_from_string((char *)output_value->buff, &beacon_rate_type) != RETURN_OK) + { + wifi_util_error_print(WIFI_DMCLI,"%s BeaconRate Parameter Invalid :%s\n", __func__, (char *)output_value->buff); + return false; + } + p_dm_vap_info->u.bss_info.beaconRate = beacon_rate_type; + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ssid_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_global_config_t *dm_wifi_global_cfg; + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + + if(STR_CMP(param_name, "Enable")) { + if (dm_wifi_global_cfg->global_parameters.force_disable_radio_feature == true) { + *output_value = false; + } else if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = pcfg->u.sta_info.enabled; + } else { + *output_value = pcfg->u.bss_info.enabled; + } + } else if(STR_CMP(param_name, "X_CISCO_COM_EnableOnline")) { + if (isVapSTAMesh(pcfg->vap_index)) { + *output_value = pcfg->u.sta_info.enabled; + } else { + *output_value = pcfg->u.bss_info.enabled; + } + } else if(STR_CMP(param_name, "X_CISCO_COM_RouterEnabled")) { + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + *output_value = p_dm_vap_default->router_enabled; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ssid_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool ssid_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + if (STR_CMP(param_name, "LastChange")) { + *output_value = (uint32_t)get_current_time_in_sec(); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ssid_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_global_config_t *dm_wifi_global_cfg; + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + uint8_t instance_number = (uint8_t)convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + + if (STR_CMP(param_name, "SSID")) { + /* collect value */ + if (isVapSTAMesh(pcfg->vap_index)) { + set_output_string(output_value, pcfg->u.sta_info.ssid); + } else { + set_output_string(output_value, pcfg->u.bss_info.ssid); + } + } else if (STR_CMP(param_name, "Status")) { + wifi_radio_operationParam_t *p_dm_radio_param = get_dml_cache_radio_map(pcfg->radio_index); + DM_CHECK_NULL_WITH_RC(p_dm_radio_param, false); + + if (dm_wifi_global_cfg->global_parameters.force_disable_radio_feature == true || + p_dm_radio_param->enable == false) { + set_output_string(output_value, "Down"); + } else if (isVapSTAMesh(pcfg->vap_index)) { + if (pcfg->u.sta_info.enabled == true) { + set_output_string(output_value, "Up"); + } else { + set_output_string(output_value, "Down"); + } + } else if(pcfg->u.bss_info.enabled == true) { + set_output_string(output_value, "Up"); + } else { + set_output_string(output_value, "Down"); + } + } else if (STR_CMP(param_name, "Alias")) { + char buff[32] = { 0 }; + + convert_apindex_to_ifname(p_wifi_prop, instance_number - 1, buff, sizeof(buff) - 1); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "Name")) { + set_output_string(output_value, pcfg->vap_name); + } else if (STR_CMP(param_name, "LowerLayers")) { + char buff[32] = { 0 }; + int radioIndex = convert_vap_name_to_radio_array_index(p_wifi_prop, pcfg->vap_name); + + snprintf(buff, sizeof(buff), "Device.WiFi.Radio.%d.", radioIndex + 1); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "BSSID")) { + char buff[24] = {0}; + + if (isVapSTAMesh(pcfg->vap_index)) { + sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", + pcfg->u.sta_info.bssid[0], pcfg->u.sta_info.bssid[1], + pcfg->u.sta_info.bssid[2], pcfg->u.sta_info.bssid[3], + pcfg->u.sta_info.bssid[4], pcfg->u.sta_info.bssid[5]); + } else { + sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", + pcfg->u.bss_info.bssid[0], pcfg->u.bss_info.bssid[1], + pcfg->u.bss_info.bssid[2], pcfg->u.bss_info.bssid[3], + pcfg->u.bss_info.bssid[4], pcfg->u.bss_info.bssid[5]); + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "MACAddress")) { + char buff[24] = {0}; + + if (isVapSTAMesh(pcfg->vap_index)) { + sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", + pcfg->u.sta_info.mac[0], pcfg->u.sta_info.mac[1], + pcfg->u.sta_info.mac[2], pcfg->u.sta_info.mac[3], + pcfg->u.sta_info.mac[4], pcfg->u.sta_info.mac[5]); + } else { + sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", + pcfg->u.bss_info.bssid[0], pcfg->u.bss_info.bssid[1], + pcfg->u.bss_info.bssid[2], pcfg->u.bss_info.bssid[3], + pcfg->u.bss_info.bssid[4], pcfg->u.bss_info.bssid[5]); + } + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "X_COMCAST-COM_DefaultSSID")) { + char temp_ssid[64] = {0}; + + if (wifi_hal_get_default_ssid(temp_ssid, pcfg->vap_index) == RETURN_OK) { + set_output_string(output_value, temp_ssid); + } + } else if (STR_CMP(param_name, "Repurposed_VapName")) { + if (strlen(pcfg->repurposed_vap_name) != 0) { + set_output_string(output_value, pcfg->repurposed_vap_name); + } else { + set_output_string(output_value, " "); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ssid_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_global_config_t *dm_wifi_global_cfg; + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (STR_CMP(param_name, "Enable")) { + rdk_wifi_vap_info_t *dm_rdk_vap_info; + + dm_rdk_vap_info = (rdk_wifi_vap_info_t *)get_dml_cache_rdk_vap_info(p_dm_vap_info->vap_index); + DM_CHECK_NULL_WITH_RC(dm_rdk_vap_info, false); + + if (output_value == true) { + dm_rdk_vap_info->exists = output_value; + } + +#if !defined(_WNXL11BWL_PRODUCT_REQ_) && !defined(_PP203X_PRODUCT_REQ_) + if (output_value == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d User is Trying to disable SSID for vap_index=%d\n", __func__, + __LINE__, p_dm_vap_info->vap_index); + } +#endif + set_dml_cache_vap_config_changed(instance_number - 1); + + if (isVapSTAMesh(pcfg->vap_index)) { + if (p_dm_vap_info->u.sta_info.enabled == output_value) + { + return true; + } + + p_dm_vap_info->u.sta_info.enabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + return true; + } + + /* SSID Enable object can be modified only when ForceDisableRadio feature is disabled */ + if(!(dm_wifi_global_cfg->global_parameters.force_disable_radio_feature)) { + if (p_dm_vap_info->u.bss_info.enabled == output_value) + { + return true; + } + + p_dm_vap_info->u.bss_info.enabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, + __LINE__, pcfg->vap_name); + return false; + } + } else if (STR_CMP(param_name, "X_CISCO_COM_EnableOnline")) { + if (isVapSTAMesh(pcfg->vap_index)) { + if (p_dm_vap_info->u.sta_info.enabled == output_value) { + return true; + } + + p_dm_vap_info->u.sta_info.enabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (!(dm_wifi_global_cfg->global_parameters.force_disable_radio_feature)) { + if (p_dm_vap_info->u.bss_info.enabled == output_value) { + return true; + } + + p_dm_vap_info->u.bss_info.enabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d [%s]WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, + __LINE__, pcfg->vap_name); + return false; + } + } else if (STR_CMP(param_name, "X_CISCO_COM_RouterEnabled")) { + dml_vap_default *p_dm_vap_default = get_vap_default(instance_number - 1); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + /* SSID Enable object can be modified only when ForceDisableRadio feature is disabled */ + if (!(dm_wifi_global_cfg->global_parameters.force_disable_radio_feature)) { + if (p_dm_vap_default->router_enabled == output_value) { + return true; + } + p_dm_vap_default->router_enabled = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d [%s]WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ssid_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool ssid_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool ssid_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + DM_CHECK_NULL_WITH_RC(output_value, false); + DM_CHECK_NULL_WITH_RC(output_value->buff, false); + + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_global_config_t *dm_wifi_global_cfg; + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (STR_CMP(param_name, "SSID")) { + if(dm_wifi_global_cfg->global_parameters.force_disable_radio_feature) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, __LINE__, pcfg->vap_name); + return false; + } + if (isVapSTAMesh(p_dm_vap_info->vap_index)) { + if (STR_CMP(p_dm_vap_info->u.sta_info.ssid, output_value->buff)) { + return true; + } + snprintf(p_dm_vap_info->u.sta_info.ssid,sizeof(p_dm_vap_info->u.sta_info.ssid), "%s", (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + return true; + } else if(STR_CMP(p_dm_vap_info->u.bss_info.ssid, output_value->buff)) { + return true; + } else if (p_dm_vap_info->u.bss_info.bssHotspot) { + if(STR_CMP(output_value->buff, "OutOfService")) { + p_dm_vap_info->u.bss_info.enabled = false; + fprintf(stderr, "%s: Disable HHS SSID since it's set to OutOfService\n", __func__); + } + } + snprintf(p_dm_vap_info->u.bss_info.ssid, sizeof(p_dm_vap_info->u.bss_info.ssid), "%s", (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + wifi_radio_operationParam_t *p_dm_radio_param = (wifi_radio_operationParam_t *)get_dml_cache_radio_map(pcfg->radio_index); + wifi_rfc_dml_parameters_t *rfc_pcfg = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + + DM_CHECK_NULL_WITH_RC(p_dm_radio_param, false); + + if (STR_CMP(param_name, "X_RDKCENTRAL-COM_TransitionDisable")) { + if ((p_dm_radio_param->band != WIFI_FREQUENCY_6_BAND) && (rfc_pcfg->wpa3_rfc)) { + *output_value = p_sec_cfg->wpa3_transition_disable; + } else { + *output_value = false; + } + } else if (STR_CMP(param_name, "Reset")) { + *output_value = false; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "X_CISCO_COM_RadiusReAuthInterval")) { + *output_value = 0; + } else if (STR_CMP(param_name, "X_CISCO_COM_DefaultKey")) { + *output_value = 0; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "RekeyingInterval")) { + *output_value = p_sec_cfg->rekey_interval; + } else if (STR_CMP(param_name, "RadiusServerPort")) { + *output_value = p_sec_cfg->u.radius.port; + } else if (STR_CMP(param_name, "SecondaryRadiusServerPort")) { + *output_value = p_sec_cfg->u.radius.s_port; + } else if (STR_CMP(param_name, "RadiusDASPort")) { + *output_value = p_sec_cfg->u.radius.dasport; + } else if (STR_CMP(param_name, "X_CISCO_COM_WEPKey64BitNumberOfEntries")) { + *output_value = 0; + } else if (STR_CMP(param_name, "X_CISCO_COM_WEPKey128BitNumberOfEntries")) { + *output_value = 0; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "ModeEnabled")) { + /* collect value */ + char buff[32] = {0}; + uint32_t str_len = 0; + + str_len = get_sec_mode_string_from_int(p_sec_cfg->mode, buff); + if (str_len == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d:hal security mode:%d conversion failure\n",__func__, __LINE__, p_sec_cfg->mode); + return false; + } + + set_output_string(output_value, buff); + } else if((STR_CMP(param_name, "KeyPassphrase")) || + (STR_CMP(param_name, "X_COMCAST-COM_KeyPassphrase")) || + (STR_CMP(param_name, "SAEPassphrase"))) { + /* collect value */ + if (strlen(p_sec_cfg->u.key.key) > 0) { + set_output_string(output_value, p_sec_cfg->u.key.key); + } else { + set_output_string(output_value, " "); + } + } else if(STR_CMP(param_name, "ModesSupported")) { + char buf[512] = {0}; + int mode = 0; + + get_sec_modes_supported(vap_index, &mode); + + if (get_sec_mode_string_from_int((wifi_security_modes_t)mode, buf) != 0) { + set_output_string(output_value, buf); + } else { + return false; + } + } else if(STR_CMP(param_name, "MFPConfig")) { + char buff[16] = {0}; + convert_security_mode_integer_to_string(p_sec_cfg->mfp, buff); + set_output_string(output_value, buff); + } else if(STR_CMP(param_name, "X_CISCO_COM_EncryptionMethod")) { + char buff[16] = {0}; + if(get_sec_encr_string_from_int(p_sec_cfg->encr, buff) == 0) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d:hal sec encr:%d conversion failure\n",__func__, __LINE__, p_sec_cfg->encr); + return false; + } + set_output_string(output_value, buff); + } else if ((STR_CMP(param_name, "WEPKey")) || (STR_CMP(param_name, "X_CISCO_COM_WEPKey")) || + (STR_CMP(param_name, "X_COMCAST-COM_WEPKey"))) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "PreSharedKey")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "X_COMCAST-COM_DefaultKeyPassphrase")) { + char default_password[64] = { 0 }; + + if (wifi_hal_get_default_keypassphrase(default_password, vap_index) == RETURN_OK) { + set_output_string(output_value, default_password); + } else { + set_output_string(output_value, " "); + } + } else if (STR_CMP(param_name, "RadiusServerIPAddr")) { + if (strcmp((char *)&p_sec_cfg->u.radius.ip, "") != 0) { + set_output_string(output_value, (char *)&p_sec_cfg->u.radius.ip); + } else { + set_output_string(output_value, "0.0.0.0"); + } + } else if (STR_CMP(param_name, "RadiusSecret")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "SecondaryRadiusServerIPAddr")) { + if (strcmp((char *)&p_sec_cfg->u.radius.s_ip, "") != 0) { + set_output_string(output_value, (char *)&p_sec_cfg->u.radius.s_ip); + } else { + set_output_string(output_value, "0.0.0.0"); + } + } else if (STR_CMP(param_name, "SecondaryRadiusSecret")) { + set_output_string(output_value, " "); + } else if (STR_CMP(param_name, "RadiusDASIPAddr")) { + char buff[64] = { 0 }; + getIpStringFromAdrress(buff, &p_sec_cfg->u.radius.dasip); + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "RadiusDASSecret")) { + set_output_string(output_value, " "); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_dm_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t vap_index = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name); + wifi_radio_operationParam_t *p_dm_radio_param = get_dml_cache_radio_map(pcfg->radio_index); + DM_CHECK_NULL_WITH_RC(p_dm_radio_param, false); + + if (isVapSTAMesh(vap_index)) { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_sta_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache sta security parameter\n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } else { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_bss_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache bss security parameter \n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } + wifi_rfc_dml_parameters_t *rfc_pcfg = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + + if (STR_CMP(param_name, "X_RDKCENTRAL-COM_TransitionDisable")) { + if (p_dm_radio_param->band == WIFI_FREQUENCY_6_BAND) { + wifi_util_error_print(WIFI_DMCLI,"%s Transition Mode not supported for 6GHz radio\n", __func__); + return false; + } + if ((output_value == true) && (!rfc_pcfg->wpa3_rfc)) { + wifi_util_error_print(WIFI_DMCLI,"%s: WPA3 Transition RFC is not enabled\n",__func__); + return false; + } + if ((p_dm_sec_cfg->mode != wifi_security_mode_wpa3_transition) && (rfc_pcfg->wpa3_rfc)) { + wifi_util_error_print(WIFI_DMCLI,"%s: Security mode is not WPA3-Personal-Transition\n",__func__); + return false; + } + p_dm_sec_cfg->wpa3_transition_disable = output_value; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:wpa3_transition_disable=%d Value=%d\n",__func__, + __LINE__, p_dm_sec_cfg->wpa3_transition_disable, output_value); + set_dml_cache_vap_config_changed(vap_index); + } else if (STR_CMP(param_name, "Reset")) { + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + if (STR_CMP(param_name, "X_CISCO_COM_RadiusReAuthInterval")) { + //nothing we need to do + } else if (STR_CMP(param_name, "X_CISCO_COM_DefaultKey")) { + //nothing we need to do + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_dm_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t vap_index = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name); + uint8_t instance_number = vap_index + 1; + wifi_radio_operationParam_t *p_dm_radio_param = get_dml_cache_radio_map(pcfg->radio_index); + DM_CHECK_NULL_WITH_RC(p_dm_radio_param, false); + + if (isVapSTAMesh(vap_index)) { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_sta_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache sta security parameter\n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } else { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_bss_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache bss security parameter \n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "RekeyingInterval")) { + if (p_dm_sec_cfg->rekey_interval != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:RekeyingInterval=%d Value=%d\n",__func__, + __LINE__, p_dm_sec_cfg->rekey_interval, output_value); + /* save update to backup */ + p_dm_sec_cfg->rekey_interval = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "RadiusServerPort")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + if (p_dm_sec_cfg->u.radius.port != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:RadiusServerPort=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.port, output_value); + p_dm_sec_cfg->u.radius.port = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "SecondaryRadiusServerPort")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + if (p_dm_sec_cfg->u.radius.s_port != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:s_RadiusServerPort=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.s_port, output_value); + p_dm_sec_cfg->u.radius.s_port = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "RadiusDASPort")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n",__func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + if (p_dm_sec_cfg->u.radius.dasport != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:RadiusDASPort=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.dasport, output_value); + p_dm_sec_cfg->u.radius.dasport = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool security_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_dm_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(output_value, false); + DM_CHECK_NULL_WITH_RC(output_value->buff, false); + + uint8_t vap_index = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name); + uint8_t instance_number = vap_index + 1; + wifi_global_config_t *dm_wifi_global_cfg; + wifi_radio_operationParam_t *p_dm_radio_param = get_dml_cache_radio_map(pcfg->radio_index); + DM_CHECK_NULL_WITH_RC(p_dm_radio_param, false); + + dm_wifi_global_cfg = (wifi_global_config_t*) get_dml_cache_global_wifi_config(); + DM_CHECK_NULL_WITH_RC(dm_wifi_global_cfg, false); + + if (isVapSTAMesh(vap_index)) { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_sta_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache sta security parameter\n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } else { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_bss_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache bss security parameter \n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } + + if(STR_CMP(param_name, "ModeEnabled")) { + wifi_security_modes_t l_tmp_sec_mode; + + if (!get_sec_mode_int_from_string(output_value->buff, &l_tmp_sec_mode)) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d failed to parse mode: %s\n", __func__, + __LINE__, output_value->buff); + return false; + } + + wifi_util_dbg_print(WIFI_DMCLI, "%s:%d old mode: %d new mode: %d\n", __func__, __LINE__, + p_dm_sec_cfg->mode, l_tmp_sec_mode); + + if (l_tmp_sec_mode == p_dm_sec_cfg->mode) { + return true; + } + + if (p_dm_radio_param->band == WIFI_FREQUENCY_6_BAND && + l_tmp_sec_mode != wifi_security_mode_wpa3_personal && + l_tmp_sec_mode != wifi_security_mode_wpa3_enterprise && + l_tmp_sec_mode != wifi_security_mode_enhanced_open) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d invalid mode %d for 6GHz\n", __func__, + __LINE__, l_tmp_sec_mode); + return false; + } + + /* GET the WPA3 Transition RFC value */ + wifi_rfc_dml_parameters_t *rfc_pcfg = (wifi_rfc_dml_parameters_t *)get_wifi_db_rfc_parameters(); + if (p_dm_radio_param->band != WIFI_FREQUENCY_6_BAND && rfc_pcfg->wpa3_rfc == false && + (l_tmp_sec_mode == wifi_security_mode_wpa3_transition || + l_tmp_sec_mode == wifi_security_mode_wpa3_personal)) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d WPA3 mode is not supported when " + "TransitionDisable RFC is false\n", __func__, __LINE__); + return false; + } + + // cleanup key/radius for personal-enterprise-open mode change + if ((is_personal_sec(l_tmp_sec_mode) && !is_personal_sec(p_dm_sec_cfg->mode)) || + (is_enterprise_sec(l_tmp_sec_mode) && !is_enterprise_sec(p_dm_sec_cfg->mode)) || + (is_open_sec(l_tmp_sec_mode) && !is_open_sec(p_dm_sec_cfg->mode))) { + memset(&p_dm_sec_cfg->u, 0, sizeof(p_dm_sec_cfg->u)); + } + + p_dm_sec_cfg->mode = l_tmp_sec_mode; + switch (p_dm_sec_cfg->mode) { + case wifi_security_mode_none: + p_dm_sec_cfg->mfp = wifi_mfp_cfg_disabled; + break; + case wifi_security_mode_wep_64: + case wifi_security_mode_wep_128: + p_dm_sec_cfg->u.key.type = wifi_security_key_type_pass; + p_dm_sec_cfg->mfp = wifi_mfp_cfg_disabled; + break; + case wifi_security_mode_wpa_personal: + case wifi_security_mode_wpa2_personal: + case wifi_security_mode_wpa_wpa2_personal: + p_dm_sec_cfg->u.key.type = wifi_security_key_type_psk; + p_dm_sec_cfg->mfp = wifi_mfp_cfg_disabled; + break; + case wifi_security_mode_wpa_enterprise: + case wifi_security_mode_wpa2_enterprise: + case wifi_security_mode_wpa_wpa2_enterprise: + p_dm_sec_cfg->mfp = wifi_mfp_cfg_disabled; + break; + case wifi_security_mode_wpa3_personal: + p_dm_sec_cfg->u.key.type = wifi_security_key_type_sae; + p_dm_sec_cfg->mfp = wifi_mfp_cfg_required; + break; + case wifi_security_mode_wpa3_enterprise: + p_dm_sec_cfg->mfp = wifi_mfp_cfg_required; + break; + case wifi_security_mode_wpa3_transition: + p_dm_sec_cfg->u.key.type = wifi_security_key_type_psk_sae; + p_dm_sec_cfg->mfp = wifi_mfp_cfg_optional; + break; + case wifi_security_mode_enhanced_open: + p_dm_sec_cfg->mfp = wifi_mfp_cfg_required; + break; + default: + break; + } + set_dml_cache_vap_config_changed(instance_number - 1); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Set Value=%d success\n", __func__, __LINE__, l_tmp_sec_mode); + + } else if((STR_CMP(param_name, "KeyPassphrase")) || + (STR_CMP(param_name, "X_COMCAST-COM_KeyPassphrase"))) { + if(dm_wifi_global_cfg->global_parameters.force_disable_radio_feature) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d WIFI_ATTEMPT_TO_CHANGE_CONFIG_WHEN_FORCE_DISABLED\n", __func__, __LINE__); + return false; + } + if ((output_value->buff_len < 8 ) || (output_value->buff_len > 63)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Size is too large value=%s\n",__func__, __LINE__, + output_value->buff, output_value->buff_len); + return false; + } + + if(STR_CMP(p_dm_sec_cfg->u.key.key, output_value->buff)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value remains unchanged\n",__func__, __LINE__); + return true; + } + /* save update to backup */ + if (security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Security mode %d does not support passphrase configuration \n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + + STR_COPY(p_dm_sec_cfg->u.key.key, output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if(STR_CMP(param_name, "MFPConfig")) { + wifi_mfp_cfg_t mfp; + + if (get_mfp_type_from_string(output_value->buff, &mfp) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s invalide mfp string %s\n", __func__, output_value->buff); + return false; + } else if (p_dm_sec_cfg->mfp == mfp) { + return true; + } + + p_dm_sec_cfg->mfp = mfp; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "X_CISCO_COM_EncryptionMethod")) { + wifi_encryption_method_t l_sec_encr_type; + + if (get_sec_encr_int_from_string(output_value->buff, &l_sec_encr_type) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s invalide sec encr string %s\n", __func__, output_value->buff); + return false; + } + + if (p_dm_sec_cfg->encr != l_sec_encr_type) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: sec encryption method=%d Value=%d\n", __func__, __LINE__, p_dm_sec_cfg->encr, l_sec_encr_type); + /* collect value */ + p_dm_sec_cfg->encr = l_sec_encr_type; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if ((STR_CMP(param_name, "WEPKey")) || (STR_CMP(param_name, "X_CISCO_COM_WEPKey")) || + (STR_CMP(param_name, "X_COMCAST-COM_WEPKey"))) { + if((p_dm_sec_cfg->mode == wifi_security_mode_wep_64) || + (p_dm_sec_cfg->mode == wifi_security_mode_wep_128)) { + /* Return an error only if the security mode enabled is WEP - For UI */ + return false; + } + } else if (STR_CMP(param_name, "PreSharedKey")) { + if((strlen((char *)output_value->buff) >= sizeof(p_dm_sec_cfg->u.key.key))) { + return false; + } + + if (security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support" + " passphrase configuration \n",__func__, __LINE__, p_dm_sec_cfg->mode); + return false; + } + + STR_COPY(p_dm_sec_cfg->u.key.key, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SAEPassphrase")) { + if ((p_dm_sec_cfg->mode != wifi_security_mode_wpa3_transition) && + (p_dm_sec_cfg->mode != wifi_security_mode_wpa3_personal)) { + wifi_util_error_print(WIFI_DMCLI,"WPA3 security mode is not enabled in VAP %d\n", instance_number); + return false; + } + if (security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support passphrase configuration\n",__func__, + __LINE__,p_dm_sec_cfg->mode); + return false; + } + if (STR_CMP(p_dm_sec_cfg->u.key.key, (char *)output_value->buff)) { + return true; + } + + if ((strlen((char *)output_value->buff) < SAE_PASSPHRASE_MIN_LENGTH) || + (strlen((char *)output_value->buff) >= SAE_PASSPHRASE_MAX_LENGTH)) { + return false; + } + STR_COPY((char*)p_dm_sec_cfg->u.key.key, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "RadiusServerIPAddr")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__,p_dm_sec_cfg->mode); + return false; + } + if (STR_CMP((char*)p_dm_sec_cfg->u.radius.ip, (char *)output_value->buff)) { + return true; + } + + if (strlen((char *)output_value->buff) >= sizeof(p_dm_sec_cfg->u.radius.ip)) { + return false; + } + + STR_COPY((char*)p_dm_sec_cfg->u.radius.ip, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "RadiusSecret")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } else if (STR_CMP(p_dm_sec_cfg->u.radius.key, (char *)output_value->buff)) { + return true; + } else if (strlen((char *)output_value->buff) >= sizeof(p_dm_sec_cfg->u.radius.key)) { + return false; + } + + STR_COPY(p_dm_sec_cfg->u.radius.key, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SecondaryRadiusServerIPAddr")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__,p_dm_sec_cfg->mode); + return false; + } + if (STR_CMP((char*)p_dm_sec_cfg->u.radius.s_ip, (char *)output_value->buff)) { + return true; + } + + if (strlen((char *)output_value->buff) >= sizeof(p_dm_sec_cfg->u.radius.s_ip)) { + return false; + } + + STR_COPY((char*)p_dm_sec_cfg->u.radius.s_ip, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SecondaryRadiusSecret")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } else if (STR_CMP(p_dm_sec_cfg->u.radius.s_key, (char *)output_value->buff)) { + return true; + } else if (strlen((char *)output_value->buff) >= sizeof(p_dm_sec_cfg->u.radius.s_key)) { + return false; + } + + STR_COPY(p_dm_sec_cfg->u.radius.s_key, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "RadiusDASIPAddr")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__,p_dm_sec_cfg->mode); + return false; + } + ip_addr_t parameter_ip; + if (getIpAddressFromString((char *)output_value->buff, ¶meter_ip) != 1) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d getIpAddressFromString failed \n",__func__, __LINE__); + return false; + } + if ((parameter_ip.family == wifi_ip_family_ipv4) && (parameter_ip.u.IPv4addr == p_dm_sec_cfg->u.radius.dasip.u.IPv4addr)) { + return true; + } + + if ((parameter_ip.family == wifi_ip_family_ipv6) && (!memcmp(p_dm_sec_cfg->u.radius.dasip.u.IPv6addr,parameter_ip.u.IPv6addr, 16))) { + return true; + } + + memcpy(&p_dm_sec_cfg->u.radius.dasip, ¶meter_ip, sizeof(ip_addr_t)); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "RadiusDASSecret")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + + if (STR_CMP(p_dm_sec_cfg->u.radius.daskey, (char *)output_value->buff)) { + return true; + } + + if (strlen((char *)output_value->buff) >= sizeof(p_dm_sec_cfg->u.radius.daskey)) { + return false; + } + + STR_COPY(p_dm_sec_cfg->u.radius.daskey, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radius_sec_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "PMKCaching")) { + *output_value = p_sec_cfg->disable_pmksa_caching; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radius_sec_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "RadiusServerRetries")) { + *output_value = p_sec_cfg->u.radius.server_retries; + } else if (STR_CMP(param_name, "RadiusServerRequestTimeout")) { + *output_value = 0; + } else if (STR_CMP(param_name, "PMKLifetime")) { + *output_value = 0; + } else if (STR_CMP(param_name, "PMKCacheInterval")) { + *output_value = 0; + } else if (STR_CMP(param_name, "MaxAuthenticationAttempts")) { + *output_value = p_sec_cfg->u.radius.max_auth_attempts; + } else if (STR_CMP(param_name, "BlacklistTableTimeout")) { + *output_value = p_sec_cfg->u.radius.blacklist_table_timeout; + } else if (STR_CMP(param_name, "IdentityRequestRetryInterval")) { + *output_value = p_sec_cfg->u.radius.identity_req_retry_interval; + } else if (STR_CMP(param_name, "QuietPeriodAfterFailedAuthentication")) { + *output_value = 0; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radius_sec_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_dm_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t vap_index = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name); + uint8_t instance_number = vap_index + 1; + + if (isVapSTAMesh(vap_index)) { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_sta_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache sta security parameter\n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } else { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_bss_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache bss security parameter \n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "PMKCaching")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d disable_pmksa_caching=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->disable_pmksa_caching, output_value); + if(p_dm_sec_cfg->disable_pmksa_caching != output_value) { + p_dm_sec_cfg->disable_pmksa_caching = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool radius_sec_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_dm_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t vap_index = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name); + uint8_t instance_number = vap_index + 1; + + if (isVapSTAMesh(vap_index)) { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_sta_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache sta security parameter\n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } else { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_bss_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache bss security parameter \n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "RadiusServerRetries")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d server_retries=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.server_retries, output_value); + if(p_dm_sec_cfg->u.radius.server_retries != ((unsigned int) output_value)) { + p_dm_sec_cfg->u.radius.server_retries = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "RadiusServerRequestTimeout")) { + } else if (STR_CMP(param_name, "PMKLifetime")) { + } else if (STR_CMP(param_name, "PMKCacheInterval")) { + } else if (STR_CMP(param_name, "MaxAuthenticationAttempts")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d max_auth_attempts=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.max_auth_attempts, output_value); + if (p_dm_sec_cfg->u.radius.max_auth_attempts != ((unsigned int) output_value)) { + p_dm_sec_cfg->u.radius.max_auth_attempts = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "BlacklistTableTimeout")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d blacklist_table_timeout=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.blacklist_table_timeout, output_value); + if (p_dm_sec_cfg->u.radius.blacklist_table_timeout != ((unsigned int) output_value)) { + p_dm_sec_cfg->u.radius.blacklist_table_timeout = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "IdentityRequestRetryInterval")) { + if (!security_mode_support_radius(p_dm_sec_cfg->mode)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Security mode %d does not support radius configuration\n", __func__, + __LINE__, p_dm_sec_cfg->mode); + return false; + } + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d identity_req_retry_interval=%d Value=%d\n", __func__, + __LINE__, p_dm_sec_cfg->u.radius.identity_req_retry_interval, output_value); + if (p_dm_sec_cfg->u.radius.identity_req_retry_interval != ((unsigned int) output_value)) { + p_dm_sec_cfg->u.radius.identity_req_retry_interval = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "QuietPeriodAfterFailedAuthentication")) { + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool auth_sec_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint8_t vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + + if (isVapSTAMesh(vap_index)) { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_sta_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid Get_wifi_object_sta_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } else { + p_sec_cfg = (wifi_vap_security_t *) Get_wifi_object_bss_security_parameter(pcfg->vap_index); + if(p_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get_dml_cache_security_parameter\n",__func__, + __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "EAPOLKeyTimeout")) { + *output_value = p_sec_cfg->eapol_key_timeout; + } else if (STR_CMP(param_name, "EAPOLKeyRetries")) { + *output_value = p_sec_cfg->eapol_key_retries; + } else if (STR_CMP(param_name, "EAPIdentityRequestTimeout")) { + *output_value = p_sec_cfg->eap_identity_req_timeout; + } else if (STR_CMP(param_name, "EAPIdentityRequestRetries")) { + *output_value = p_sec_cfg->eap_identity_req_retries ; + } else if (STR_CMP(param_name, "EAPRequestTimeout")) { + *output_value = p_sec_cfg->eap_req_timeout; + } else if (STR_CMP(param_name, "EAPRequestRetries")) { + *output_value = p_sec_cfg->eap_req_retries ; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool auth_sec_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + wifi_vap_security_t *p_dm_sec_cfg = NULL; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t vap_index = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name); + uint8_t instance_number = vap_index + 1; + + if (isVapSTAMesh(vap_index)) { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_sta_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache sta security parameter\n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } else { + p_dm_sec_cfg = (wifi_vap_security_t *) get_dml_cache_bss_security_parameter(pcfg->vap_index); + if(p_dm_sec_cfg == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: %s invalid get dml cache bss security parameter \n",__func__, __LINE__, pcfg->vap_name); + return false; + } + } + + if (STR_CMP(param_name, "EAPOLKeyTimeout")) { + if (p_dm_sec_cfg->eapol_key_timeout != output_value) { + p_dm_sec_cfg->eapol_key_timeout = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "EAPOLKeyRetries")) { + if (p_dm_sec_cfg->eapol_key_retries != output_value) { + p_dm_sec_cfg->eapol_key_retries = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "EAPIdentityRequestTimeout")) { + if (p_dm_sec_cfg->eap_identity_req_timeout != output_value) { + p_dm_sec_cfg->eap_identity_req_timeout = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "EAPIdentityRequestRetries")) { + if (p_dm_sec_cfg->eap_identity_req_retries != output_value) { + p_dm_sec_cfg->eap_identity_req_retries = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "EAPRequestTimeout")) { + if (p_dm_sec_cfg->eap_req_timeout != output_value) { + p_dm_sec_cfg->eap_req_timeout = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "EAPRequestRetries")) { + if (p_dm_sec_cfg->eap_req_retries != output_value) { + p_dm_sec_cfg->eap_req_retries = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool macfilter_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool macfilter_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool macfilter_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool macfilter_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + acl_entry_t *p_acl_entry = (acl_entry_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(p_acl_entry, false); + + /* check the parameter name and return the corresponding value */ + if (STR_CMP(param_name, "MACAddress")) { + char buff[24] = {0}; + + sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", p_acl_entry->mac[0], + p_acl_entry->mac[1], + p_acl_entry->mac[2], + p_acl_entry->mac[3], + p_acl_entry->mac[4], + p_acl_entry->mac[5]); + + set_output_string(output_value, buff); + } else if (STR_CMP(param_name, "DeviceName")) { + set_output_string(output_value, p_acl_entry->device_name); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool macfilter_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool macfilter_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool macfilter_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool macfilter_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + mac_filter_set_param_arg_t *p_mac_filter_set_arg = (mac_filter_set_param_arg_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(p_mac_filter_set_arg, false); + + acl_entry_t *acl_entry = p_mac_filter_set_arg->acl_param; + wifi_vap_info_t *vap_info = p_mac_filter_set_arg->vap_info_param; + mac_address_t new_mac; + unsigned int count = 0, itr; + mac_address_t zero_mac = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + acl_entry_t *mac_acl_entry; + int mac_length = -1; + char formatted_mac[MAX_STR_MAC_ADDR_LEN + 1] = {0}; + + DM_CHECK_NULL_WITH_RC(acl_entry, false); + DM_CHECK_NULL_WITH_RC(vap_info, false); + + hash_map_t **acl_device_map = (hash_map_t **)get_acl_hash_map(vap_info); + queue_t **acl_new_entry_queue = (queue_t **)get_acl_new_entry_queue(vap_info); + if (*acl_new_entry_queue == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unexpected ERROR!!! acl_new_entry_queue" + " should not be NULL\n", __func__,__LINE__); + *acl_new_entry_queue = queue_create(); + } + + if (STR_CMP(param_name, "MACAddress")) { + str_tolower(output_value->buff); + mac_length = strlen(output_value->buff); + if (mac_length != MAX_STR_MAC_ADDR_LEN && mac_length != MIN_STR_MAC_ADDR_LEN) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid mac:%s\n", __func__, + __LINE__, (char *)output_value->buff); + return false; + } + + if (mac_length == MIN_STR_MAC_ADDR_LEN) { + itr = 0; + for (count = 0; count < MIN_STR_MAC_ADDR_LEN; count++) { + formatted_mac[itr++] = (char)*(char *)(output_value->buff + count); + if (((count % 2) == 1) && (count != MIN_STR_MAC_ADDR_LEN - 1)) { + formatted_mac[itr++] = ':'; + } + } + formatted_mac[itr++] = '\0'; + + if (is_valid_mac_address(formatted_mac) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid mac:%s\n", __func__, + __LINE__, formatted_mac); + return false; + } + } else { + if (is_valid_mac_address(output_value->buff) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid mac:%s\n", __func__, + __LINE__, (char *)output_value->buff); + return false; + } + } + + str_to_mac_bytes(output_value->buff, new_mac); + if (memcmp(new_mac, zero_mac, sizeof(mac_address_t)) == 0) { + //Invalid value returning false + return false; + } + + if (memcmp(acl_entry->mac, zero_mac, sizeof(mac_address_t)) == 0) { + memcpy(acl_entry->mac, new_mac, sizeof(mac_address_t)); + if (*acl_device_map == NULL) { + *acl_device_map = hash_map_create(); + } + + if (*acl_device_map == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d NULL Pointer\n", __func__, __LINE__); + return false; + } + hash_map_put(*acl_device_map, strdup(output_value->buff), acl_entry); + + if (*acl_new_entry_queue == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d NULL Pointer\n", __func__, __LINE__); + return false; + } + count = queue_count(*acl_new_entry_queue); + for (itr = 0; itr < count; itr++) { + mac_acl_entry = (acl_entry_t *)queue_peek(*acl_new_entry_queue, itr); + if (mac_acl_entry == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d NULL Pointer\n", __func__, __LINE__); + return false; + } + + if (mac_acl_entry == acl_entry) { + mac_acl_entry = queue_remove(*acl_new_entry_queue, itr); + break; + } + } + } else if (memcmp(acl_entry->mac, new_mac, sizeof(mac_address_t)) != 0) { + memcpy(acl_entry->mac, new_mac, sizeof(mac_address_t)); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: mac filter same entry found:%s\n", __func__, + __LINE__, (char *)output_value->buff); + return true; + } + + //macfilter commit + if (push_acl_list_dml_cache_to_one_wifidb(vap_info) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Mac_Filter failed \n",__func__, __LINE__); + return false; + } + } else if (STR_CMP(param_name, "DeviceName")) { + strncpy(acl_entry->device_name, output_value->buff, sizeof(acl_entry->device_name)-1); + //macfilter commit + if (push_acl_list_dml_cache_to_one_wifidb(vap_info) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Mac_Filter failed \n",__func__, __LINE__); + return false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_interworking_info = &vap_pcfg->u.bss_info.interworking; + + if (STR_CMP(param_name, "Internet")) { + if(isVapHotspot(vap_pcfg->vap_index)) { + *output_value = p_interworking_info->interworking.internetAvailable; + } else { + *output_value = p_interworking_info->interworking.internetAvailable; + } + } else if (STR_CMP(param_name, "ASRA")) { + *output_value = p_interworking_info->interworking.asra; + } else if (STR_CMP(param_name, "ESR")) { + *output_value = p_interworking_info->interworking.esr; + } else if (STR_CMP(param_name, "UESA")) { + *output_value = p_interworking_info->interworking.uesa; + } else if (STR_CMP(param_name, "VenueOptionPresent")) { + *output_value = p_interworking_info->interworking.venueOptionPresent; + } else if (STR_CMP(param_name, "HESSOptionPresent")) { + *output_value = p_interworking_info->interworking.hessOptionPresent; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool interworking_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_interworking_info = &vap_pcfg->u.bss_info.interworking; + + if (STR_CMP(param_name, "AccessNetworkType")) { + *output_value = p_interworking_info->interworking.accessNetworkType; + } else if (STR_CMP(param_name, "VenueInfo.Group")) { + *output_value = p_interworking_info->interworking.venueGroup; + } else if (STR_CMP(param_name, "VenueInfo.Type")) { + *output_value = p_interworking_info->interworking.venueType; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_interworking_info = &vap_pcfg->u.bss_info.interworking; + + if (STR_CMP(param_name, "HESSID")) { + set_output_string(output_value, p_interworking_info->interworking.hessid); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_dm_interworking_info = &p_dm_vap_info->u.bss_info.interworking; + + if (STR_CMP(param_name, "Internet")) { + if (p_dm_interworking_info->interworking.internetAvailable != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d internet=%d output_value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.internetAvailable, output_value); + p_dm_interworking_info->interworking.internetAvailable = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "ASRA")) { + if (p_dm_interworking_info->interworking.asra != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d asra=%d output_value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.asra, output_value); + p_dm_interworking_info->interworking.asra = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "ESR")) { + if (p_dm_interworking_info->interworking.esr != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d esr=%d output_value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.esr, output_value); + p_dm_interworking_info->interworking.esr = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "UESA")) { + if (p_dm_interworking_info->interworking.uesa != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d uesa=%d output_value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.uesa, output_value); + p_dm_interworking_info->interworking.uesa = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "VenueOptionPresent")) { + if (p_dm_interworking_info->interworking.venueOptionPresent != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d venue=%d output_value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.venueOptionPresent, output_value); + p_dm_interworking_info->interworking.venueOptionPresent = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "HESSOptionPresent")) { + if (p_dm_interworking_info->interworking.hessOptionPresent != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d hessOptionPresent=%d output_value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.hessOptionPresent, output_value); + p_dm_interworking_info->interworking.hessOptionPresent = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool interworking_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_dm_interworking_info = &p_dm_vap_info->u.bss_info.interworking; + + if (STR_CMP(param_name, "AccessNetworkType")) { + if ((output_value < 6) || ((output_value < 16) && (output_value > 13))) { + if(p_dm_interworking_info->interworking.accessNetworkType != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d accessNetworkType=%d Value=%d\n", __func__, + __LINE__, p_dm_interworking_info->interworking.accessNetworkType, output_value); + p_dm_interworking_info->interworking.accessNetworkType = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d invalid AccessNetworkType cfg:%d\n", __func__, + __LINE__, output_value); + return false; + } + } else if (STR_CMP(param_name, "VenueInfo.Type")) { + bool update_invalid_type = false; + if (output_value < 256) { + switch (p_dm_interworking_info->interworking.venueGroup) { + case 0: + if (output_value != 0) { + update_invalid_type = true; + } + break; + case 1: + if (!(output_value < 16)) { + update_invalid_type = true; + } + break; + case 2: + if (!(output_value < 10)) { + update_invalid_type = true; + } + break; + case 3: + if (!(output_value < 4)) { + update_invalid_type = true; + } + break; + case 4: + if (!(output_value < 2)) { + update_invalid_type = true; + } + break; + + case 5: + if (!(output_value < 6)) { + update_invalid_type = true; + } + break; + case 6: + if (!(output_value < 6)) { + update_invalid_type = true; + } + break; + case 7: + if (!(output_value < 5)) { + update_invalid_type = true; + } + break; + case 8: + if (output_value != 0) { + update_invalid_type = true; + } + break; + case 9: + if (output_value != 0) { + update_invalid_type = true; + } + break; + case 10: + if (!(output_value < 8)) { + update_invalid_type = true; + } + break; + case 11: + if (!(output_value < 7)) { + update_invalid_type = true; + } + break; + } + } else { + update_invalid_type = true; + } + + if (update_invalid_type == false) { + if(p_dm_interworking_info->interworking.venueType != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d venueType=%d Value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.venueType, output_value); + p_dm_interworking_info->interworking.venueType = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: invalid config:%d for param name:%s\n",__func__, + __LINE__, output_value, param_name); + return false; + } + } else if (STR_CMP(param_name, "VenueInfo.Group")) { + if (output_value < 12) { + if(p_dm_interworking_info->interworking.venueGroup != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d venueGroup=%d Value=%d\n",__func__, + __LINE__, p_dm_interworking_info->interworking.venueGroup, output_value); + p_dm_interworking_info->interworking.venueGroup = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: invalid VenueInfo.Group config param:%d\n",__func__, + __LINE__, output_value); + return false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_dm_interworking_info = &p_dm_vap_info->u.bss_info.interworking; + + if (STR_CMP(param_name, "HESSID")) { + if (is_valid_mac_address((char *)output_value->buff) == false) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d HESSID is not valid:%s\n", __func__, + __LINE__, (char *)output_value->buff); + return false; + } + STR_COPY(p_dm_interworking_info->interworking.hessid, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +void *macfilter_tab_add_entry(void *obj_ins_context, uint32_t *p_ins_number) +{ + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Inside AddEntry \n",__func__, __LINE__); + wifi_vap_info_t *vap_info = (wifi_vap_info_t *)obj_ins_context; + acl_entry_t *acl_entry; + unsigned int count = 0; + + if (vap_info->vap_index > MAX_VAP) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d vap_index:%d is out of range\n",__func__, + __LINE__, vap_info->vap_index); + return NULL; + } + + hash_map_t **acl_device_map = (hash_map_t **)get_acl_hash_map(vap_info); + queue_t **acl_new_entry_queue = (queue_t **)get_acl_new_entry_queue(vap_info); + + acl_entry = (acl_entry_t *)malloc(sizeof(acl_entry_t)); + DM_CHECK_NULL_WITH_RC(acl_entry, NULL); + + if (*acl_new_entry_queue == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unexpected ERROR!!! acl_new_entry_queue" + " should not be NULL\n", __func__, __LINE__); + *acl_new_entry_queue = queue_create(); + } + + memset(acl_entry, 0, sizeof(acl_entry_t)); + + if (*acl_new_entry_queue != NULL) { + queue_push(*acl_new_entry_queue, acl_entry); + count = count + queue_count(*acl_new_entry_queue); + } + + if (*acl_device_map != NULL) { + count = count + hash_map_count(*acl_device_map); + } + + //new entry index + *p_ins_number = count; + + //dont send the blob now because there is no valid mac entry. waits the update + + return acl_entry; +} + +int macfilter_tab_del_entry(void *obj_ins_context, void *p_instance) +{ + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Inside DelEntry \n",__func__, __LINE__); + wifi_vap_info_t *vap_info = (wifi_vap_info_t *)obj_ins_context; + acl_entry_t *acl_entry = (acl_entry_t *) p_instance; + mac_address_t zero_mac = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + acl_entry_t *map_acl_entry, *tmp_acl_entry; + unsigned int count, itr; + mac_addr_str_t mac_str; + if (vap_info->vap_index > MAX_VAP) { + return RETURN_ERR; + } + + DM_CHECK_NULL_WITH_RC(acl_entry, RETURN_ERR); + + queue_t **acl_new_entry_queue = (queue_t **)get_acl_new_entry_queue(vap_info); + hash_map_t **acl_device_map = (hash_map_t **)get_acl_hash_map(vap_info); + if (*acl_new_entry_queue == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unexpected ERROR!!! acl_new_entry_queue" + " should not be NULL\n", __func__,__LINE__); + *acl_new_entry_queue = queue_create(); + } + + if (memcmp(acl_entry->mac, zero_mac, sizeof(mac_address_t)) == 0) { + if (*acl_new_entry_queue != NULL) { + count = queue_count(*acl_new_entry_queue); + for (itr = 0; itr < count; itr++) { + map_acl_entry = (acl_entry_t *)queue_peek(*acl_new_entry_queue, itr); + if (map_acl_entry == acl_entry) { + map_acl_entry = queue_remove(*acl_new_entry_queue, itr); + if (map_acl_entry) { + free(map_acl_entry); + } + break; + } + } + return RETURN_OK; + } + } else { + to_mac_str(acl_entry->mac, mac_str); + tmp_acl_entry = hash_map_remove(*acl_device_map, mac_str); + if (tmp_acl_entry != NULL) { + free(tmp_acl_entry); + } + + // Send blob + if(push_acl_list_dml_cache_to_one_wifidb(vap_info) == RETURN_ERR) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Mac_Filter falied \n",__func__, __LINE__); + return RETURN_ERR; + } + return RETURN_OK; + } + + return RETURN_ERR; +} + +bool associated_sta_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + assoc_dev_data_t *assoc_dev_data = (assoc_dev_data_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(assoc_dev_data, false); + + /* check the parameter name and return the corresponding value */ + if (STR_CMP(param_name, "AuthenticationState")) { + *output_value = assoc_dev_data->dev_stats.cli_AuthenticationState; + } else if (STR_CMP(param_name, "Active")) { + *output_value = assoc_dev_data->dev_stats.cli_Active; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool associated_sta_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + assoc_dev_data_t *assoc_dev_data = (assoc_dev_data_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(assoc_dev_data, false); + + if (STR_CMP(param_name, "SignalStrength")) { + *output_value = assoc_dev_data->dev_stats.cli_SignalStrength; + } else if (STR_CMP(param_name, "X_COMCAST-COM_SNR")) { + *output_value = assoc_dev_data->dev_stats.cli_SNR; + } else if (STR_CMP(param_name, "X_RDKCENTRAL-COM_SNR")) { + *output_value = assoc_dev_data->dev_stats.cli_SNR; + } else if(STR_CMP(param_name, "X_COMCAST-COM_RSSI")) { + *output_value = assoc_dev_data->dev_stats.cli_RSSI; + } else if(STR_CMP(param_name, "X_COMCAST-COM_MinRSSI")) { + *output_value = assoc_dev_data->dev_stats.cli_MinRSSI; + } else if(STR_CMP(param_name, "X_COMCAST-COM_MaxRSSI")) { + *output_value = assoc_dev_data->dev_stats.cli_MaxRSSI; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool associated_sta_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + assoc_dev_data_t *assoc_dev_data = (assoc_dev_data_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(assoc_dev_data, false); + + if (STR_CMP(param_name, "LastDataDownlinkRate")) { + *output_value = assoc_dev_data->dev_stats.cli_LastDataDownlinkRate; + } else if (STR_CMP(param_name, "LastDataUplinkRate")) { + *output_value = assoc_dev_data->dev_stats.cli_LastDataUplinkRate; + } else if (STR_CMP(param_name, "Retransmissions")) { + *output_value = assoc_dev_data->dev_stats.cli_Retransmissions; + } else if (STR_CMP(param_name, "X_COMCAST-COM_DataFramesSentAck")) { + *output_value = assoc_dev_data->dev_stats.cli_DataFramesSentAck; + } else if (STR_CMP(param_name, "X_COMCAST-COM_DataFramesSentNoAck")) { + *output_value = assoc_dev_data->dev_stats.cli_DataFramesSentNoAck; + } else if (STR_CMP(param_name, "X_COMCAST-COM_BytesSent")) { + *output_value = assoc_dev_data->dev_stats.cli_BytesSent; + } else if (STR_CMP(param_name, "X_COMCAST-COM_BytesReceived")) { + *output_value = assoc_dev_data->dev_stats.cli_BytesReceived; + } else if (STR_CMP(param_name, "X_COMCAST-COM_Disassociations")) { + *output_value = assoc_dev_data->dev_stats.cli_Disassociations; + } else if( STR_CMP(param_name, "X_COMCAST-COM_AuthenticationFailures")) { + *output_value = assoc_dev_data->dev_stats.cli_AuthenticationFailures; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool associated_sta_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + assoc_dev_data_t *assoc_dev_data = (assoc_dev_data_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(assoc_dev_data, false); + + if (STR_CMP(param_name, "MACAddress")) { + char p_mac[18]; + snprintf(p_mac, 18, "%02x:%02x:%02x:%02x:%02x:%02x", assoc_dev_data->dev_stats.cli_MACAddress[0], assoc_dev_data->dev_stats.cli_MACAddress[1], assoc_dev_data->dev_stats.cli_MACAddress[2], + assoc_dev_data->dev_stats.cli_MACAddress[3], assoc_dev_data->dev_stats.cli_MACAddress[4], assoc_dev_data->dev_stats.cli_MACAddress[5]); + set_output_string(output_value, p_mac); + } else if (STR_CMP(param_name, "X_COMCAST-COM_OperatingStandard")) { + set_output_string(output_value, assoc_dev_data->dev_stats.cli_OperatingStandard); + } else if (STR_CMP(param_name, "X_COMCAST-COM_OperatingChannelBandwidth")) { + set_output_string(output_value, assoc_dev_data->dev_stats.cli_OperatingChannelBandwidth); + } else if (STR_CMP(param_name, "X_COMCAST-COM_InterferenceSources")) { + set_output_string(output_value, assoc_dev_data->dev_stats.cli_InterferenceSources); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ap_macfilter_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (isVapSTAMesh(pcfg->vap_index)) { + return true; + } + + if (STR_CMP(param_name, "Enable")) { + if (isVapHotspot(pcfg->vap_index)) { + *output_value = true; + } else { + *output_value = pcfg->u.bss_info.mac_filter_enable; + } + } else if (STR_CMP(param_name, "FilterAsBlackList")) { + if ((pcfg->u.bss_info.mac_filter_enable == true) && + (pcfg->u.bss_info.mac_filter_mode == wifi_mac_filter_mode_black_list)) { + *output_value = true; + } else { + *output_value = false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool ap_macfilter_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "Enable")) { + if (p_dm_vap_info->u.bss_info.mac_filter_enable != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d mac_filter_enable=%d Value=%d\n", __func__, + __LINE__, p_dm_vap_info->u.bss_info.mac_filter_enable, output_value); + p_dm_vap_info->u.bss_info.mac_filter_enable = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "FilterAsBlackList")) { + if (p_dm_vap_info->u.bss_info.mac_filter_mode != !output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d mac_filter_mode=%d Value=%d\n", __func__, + __LINE__, p_dm_vap_info->u.bss_info.mac_filter_mode, !output_value); + p_dm_vap_info->u.bss_info.mac_filter_mode = !output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wps_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "Enable")) { + *output_value = pcfg->u.bss_info.wps.enable; + } else if (STR_CMP(param_name, "X_CISCO_COM_ActivatePushButton")) { + *output_value = false; + } else if (STR_CMP(param_name, "X_CISCO_COM_CancelSession")) { + *output_value = false; + } else if (STR_CMP(param_name, "X_Comcast_com_Configured")) { + *output_value = false; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wps_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "X_CISCO_COM_WpsPushButton")) { + *output_value = pcfg->u.bss_info.wpsPushButton; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wps_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool wps_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + int vap_index = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name); + dml_vap_default *p_dm_vap_default = get_vap_default(vap_index); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "ConfigMethodsSupported")) { + char buff[128] = {0}; + + if (get_wifi_wps_method_string_from_int(p_dm_vap_default->wps_methods, buff) != 0) { + set_output_string(output_value, buff); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d wps method:%d str value not found\n", __func__, + __LINE__, p_dm_vap_default->wps_methods); + return false; + } + } else if (STR_CMP(param_name, "ConfigMethodsEnabled")) { + char buff[128] = {0}; + + if (get_wifi_wps_method_string_from_int(pcfg->u.bss_info.wps.methods, buff) != 0) { + set_output_string(output_value, buff); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d wps method:%d str value not found\n", __func__, + __LINE__, p_dm_vap_default->wps_methods); + return false; + } + } else if (STR_CMP(param_name, "X_CISCO_COM_Pin")) { + set_output_string(output_value, p_dm_vap_default->wps_pin); + } else if (STR_CMP(param_name, "X_CISCO_COM_ClientPin")) { + set_output_string(output_value, " "); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wps_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } else if (is_sec_mode_open_for_private_ap(pcfg->vap_index) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d [%s] does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return false; + } + + if (STR_CMP(param_name, "Enable")) { + if (p_dm_vap_info->u.bss_info.wps.enable != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:key=%d output_value=%d\n", __func__, + __LINE__, p_dm_vap_info->u.bss_info.wps.enable, output_value); + p_dm_vap_info->u.bss_info.wps.enable = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "X_CISCO_COM_ActivatePushButton")) { + dml_vap_default *p_dm_vap_default = get_vap_default(instance_number - 1); + + DM_CHECK_NULL_WITH_RC(p_dm_vap_default, false); + + if (p_dm_vap_info->u.bss_info.wpsPushButton != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:key=%d output_value=%d\n",__func__, + __LINE__, p_dm_vap_info->u.bss_info.wpsPushButton, output_value); + //WPS validation + if (output_value == true) { + if (p_dm_vap_info->u.bss_info.wps.enable == false) { + wifi_util_error_print(WIFI_DMCLI,"(%s) WPS is not enabled for vap %d\n", __func__, instance_number - 1); + p_dm_vap_info->u.bss_info.wpsPushButton = false; + return false; + } + + if ((p_dm_vap_default->wps_methods & WIFI_ONBOARDINGMETHODS_PUSHBUTTON) == 0) { + wifi_util_error_print(WIFI_DMCLI,"(%s) WPS PBC:%d is not configured for vap:%d\n", __func__, + p_dm_vap_default->wps_methods, instance_number - 1); + + p_dm_vap_info->u.bss_info.wpsPushButton = false; + return false; + } + } + p_dm_vap_info->u.bss_info.wpsPushButton = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + //WPS commit + if (output_value == true) { + int32_t temp_vap_index = instance_number - 1; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:Activate push button for vap %d\n", __func__, + __LINE__, temp_vap_index); + push_event_to_ctrl_queue(&temp_vap_index, sizeof(temp_vap_index), wifi_event_type_command, + wifi_event_type_command_wps, NULL); + p_dm_vap_info->u.bss_info.wpsPushButton = false; + } + } + } else if (STR_CMP(param_name, "X_CISCO_COM_CancelSession")) { + instance_number -= 1; + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d: WPS cancel for vap %d\n",__func__, __LINE__, instance_number); + push_event_to_ctrl_queue(&instance_number, sizeof(instance_number), wifi_event_type_command, wifi_event_type_command_wps_cancel, NULL); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wps_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } else if (is_sec_mode_open_for_private_ap(pcfg->vap_index) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d [%s] does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return false; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + if (STR_CMP(param_name, "X_CISCO_COM_WpsPushButton")) { + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wps_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } else if (is_sec_mode_open_for_private_ap(pcfg->vap_index) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d [%s] does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return false; + } + + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool wps_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } else if (is_sec_mode_open_for_private_ap(pcfg->vap_index) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d [%s] does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return false; + } + + if (STR_CMP(param_name, "ConfigMethodsEnabled")) { + wifi_onboarding_methods_t l_wps_method = 0; + + if (get_wifi_wps_method_int_from_string((char *)output_value->buff, &l_wps_method) != RETURN_OK) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: unsupported wps method:%s\n",__func__, + __LINE__, (char *)output_value->buff); + return false; + } + p_dm_vap_info->u.bss_info.wps.methods = l_wps_method; + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "X_CISCO_COM_ClientPin")) { + if ((strlen((char *)output_value->buff) >= 4) && (strlen((char *)output_value->buff) <= 8)) { + push_wps_pin_dml_to_ctrl_queue((instance_number - 1), (char *)output_value->buff); + } else { + return false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_serv_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_interworking_info = &vap_pcfg->u.bss_info.interworking; + + if (STR_CMP(param_name, "Parameters")) { + if (p_interworking_info->anqp.anqpParameters) { + set_output_string(output_value, (char *)p_interworking_info->anqp.anqpParameters); + } else { + set_output_string(output_value, " "); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool interworking_serv_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_dm_interworking_info = &p_dm_vap_info->u.bss_info.interworking; + + if (STR_CMP(param_name, "Parameters")) { + if (STR_CMP((char *)p_dm_interworking_info->anqp.anqpParameters, (char *)output_value->buff)) { + return true; + } else { + cJSON *p_root = cJSON_Parse((char *)output_value->buff); + if (p_root == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid json for vap %s\n", __func__, + __LINE__,pcfg->vap_name); + return false; + } + STR_COPY((char*)p_dm_interworking_info->anqp.anqpParameters, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + cJSON_Delete(p_root); + wifi_util_info_print(WIFI_DMCLI,"%s:%d: interwoking serv param set success\n",__func__, __LINE__); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool passpoint_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_interworking_info = &vap_pcfg->u.bss_info.interworking; + + if (STR_CMP(param_name, "Capability")) { + } else if (STR_CMP(param_name, "Enable")) { + *output_value = p_interworking_info->passpoint.enable; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool passpoint_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_interworking_info = &vap_pcfg->u.bss_info.interworking; + + if (STR_CMP(param_name, "Parameters")) { + if (p_interworking_info->passpoint.hs2Parameters) { + set_output_string(output_value, (char *)p_interworking_info->passpoint.hs2Parameters); + } else { + set_output_string(output_value, " "); + } + } else if (STR_CMP(param_name, "WANMetrics")) { + WiFi_GetWANMetrics((vap_pcfg->vap_index + 1), (char *)&p_interworking_info->passpoint.wanMetricsInfo, + sizeof(p_interworking_info->passpoint.wanMetricsInfo)); + set_output_string(output_value, (char *)&p_interworking_info->passpoint.wanMetricsInfo); + } else if (STR_CMP(param_name, "Stats")) { + WiFi_GetHS2Stats((vap_pcfg->vap_index + 1)); + set_output_string(output_value, (char *)p_interworking_info->anqp.passpointStats); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool passpoint_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_dm_interworking_info = &p_dm_vap_info->u.bss_info.interworking; + + if (STR_CMP(param_name, "Enable")) { + if (p_dm_interworking_info->interworking.interworkingEnabled == false) { + wifi_util_info_print(WIFI_DMCLI,"Cannot Enable Passpoint. Interworking Disabled\n"); + return false; + } else if (p_dm_interworking_info->passpoint.enable != output_value) { + p_dm_interworking_info->passpoint.enable = output_value; + set_dml_cache_vap_config_changed(instance_number - 1); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool passpoint_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if (isVapSTAMesh(pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, __LINE__, pcfg->vap_name); + return true; + } + + wifi_interworking_t *p_dm_interworking_info = &p_dm_vap_info->u.bss_info.interworking; + + if (STR_CMP(param_name, "Parameters")) { + if (STR_CMP((char *)p_dm_interworking_info->passpoint.hs2Parameters, (char *)output_value->buff)) { + return true; + } else { + cJSON *p_root = cJSON_Parse((char *)output_value->buff); + if (p_root == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Invalid json for vap %s\n", __func__, + __LINE__,pcfg->vap_name); + return false; + } + STR_COPY((char*)p_dm_interworking_info->passpoint.hs2Parameters, (char *)output_value->buff); + set_dml_cache_vap_config_changed(instance_number - 1); + cJSON_Delete(p_root); + wifi_util_info_print(WIFI_DMCLI,"%s:%d: passpoint param set success\n",__func__, __LINE__); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool conn_ctrl_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + if (STR_CMP(param_name, "ClientForceDisassociation")) { + set_output_string(output_value, vap_pcfg->u.bss_info.postassoc.client_force_disassoc_info); + } else if (STR_CMP(param_name, "ClientDenyAssociation")) { + set_output_string(output_value, vap_pcfg->u.bss_info.preassoc.client_deny_assoc_info); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool conn_ctrl_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + if (STR_CMP(param_name, "ClientForceDisassociation")) { + } else if (STR_CMP(param_name, "ClientDenyAssociation")) { + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool pre_conn_ctrl_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_preassoc_control_t *p_pre_assoc = &vap_pcfg->u.bss_info.preassoc; + + if (STR_CMP(param_name, "RssiUpThresholdSupported")) { + set_output_string(output_value, "disabled, 10 to 100"); + } else if (STR_CMP(param_name, "SnrThresholdSupported")) { + set_output_string(output_value, "disabled, 1 to 100"); + } else if (STR_CMP(param_name, "RssiUpThreshold")) { + set_output_string(output_value, p_pre_assoc->rssi_up_threshold); + } else if (STR_CMP(param_name, "SnrThreshold")) { + set_output_string(output_value, p_pre_assoc->snr_threshold); + } else if (STR_CMP(param_name, "CuThresholdSupported")) { + set_output_string(output_value, "disabled, 0 to 100 (%% in integer)"); + } else if (STR_CMP(param_name, "CuThreshold")) { + set_output_string(output_value, p_pre_assoc->cu_threshold); + } else if (STR_CMP(param_name, "BasicDataTransmitRates")) { + set_output_string(output_value, p_pre_assoc->basic_data_transmit_rates); + } else if (STR_CMP(param_name, "OperationalDataTransmitRates")) { + set_output_string(output_value, p_pre_assoc->operational_data_transmit_rates); + } else if (STR_CMP(param_name, "SupportedDataTransmitRates")) { + set_output_string(output_value, p_pre_assoc->supported_data_transmit_rates); + } else if (STR_CMP(param_name, "MinimumAdvertisedMCS")) { + set_output_string(output_value, p_pre_assoc->minimum_advertised_mcs); + } else if (STR_CMP(param_name, "6GOpInfoMinRate")) { + set_output_string(output_value, p_pre_assoc->sixGOpInfoMinRate); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool pre_conn_ctrl_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + int val, ret; + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, vap_pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if ((isVapSTAMesh(vap_pcfg->vap_index)) || + (!isVapHotspot(vap_pcfg->vap_index))) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_preassoc_control_t *p_dm_pre_assoc = &p_dm_vap_info->u.bss_info.preassoc; + char *p_input_str = (char *)output_value->buff; + + if (STR_CMP(param_name, "RssiUpThreshold")) { + if (STR_CMP(p_input_str, p_dm_pre_assoc->rssi_up_threshold)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_pre_assoc->rssi_up_threshold, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format. Example: -90 to -50\n", __func__, __LINE__); + return false; + } + + if (val > -50 || val < -95) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_pre_assoc->rssi_up_threshold, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SnrThreshold")) { + if (STR_CMP(p_input_str, p_dm_pre_assoc->snr_threshold)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_pre_assoc->snr_threshold, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format. Example: 10 to 100\n", __func__, __LINE__); + return false; + } + + if (val < 1 || val > 100) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_pre_assoc->snr_threshold, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else if (STR_CMP(param_name, "CuThreshold")) { + if (STR_CMP(p_input_str, p_dm_pre_assoc->cu_threshold)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_pre_assoc->cu_threshold, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format. Example: 10 to 100\n", __func__, __LINE__); + return false; + } + + if (val < 0 || val > 100) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_pre_assoc->cu_threshold, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else if (STR_CMP(param_name, "BasicDataTransmitRates")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s Rate to set for preassoc\n", __func__, __LINE__, p_input_str); + + if (STR_CMP(p_input_str, p_dm_pre_assoc->basic_data_transmit_rates)) { + return true; + } else if (strcmp(p_input_str, "disabled") == 0) { + STR_COPY(p_dm_pre_assoc->basic_data_transmit_rates, "disabled"); + } else if (is_valid_transmit_rate(p_input_str)) { + wifi_bitrate_t temp_bit_rate = 0; + + if (get_wifi_data_tx_rate_int_from_string(p_input_str, &temp_bit_rate) != RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Invalid value:%s:%d\n", __func__, + __LINE__, p_input_str, temp_bit_rate); + return false; + } + + STR_COPY(p_dm_pre_assoc->basic_data_transmit_rates, p_input_str); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s Not a valid format\n", __func__, __LINE__, p_input_str); + return false; + } + set_cac_cache_changed(instance_number - 1); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "OperationalDataTransmitRates")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s operational Rate to set for preassoc\n", __func__, __LINE__, p_input_str); + + if (STR_CMP(p_input_str, p_dm_pre_assoc->operational_data_transmit_rates)) { + return true; + } else if (strcmp(p_input_str, "disabled") == 0) { + STR_COPY(p_dm_pre_assoc->operational_data_transmit_rates, "disabled"); + } else if (is_valid_transmit_rate(p_input_str)) { + wifi_bitrate_t temp_bit_rate = 0; + + if (get_wifi_data_tx_rate_int_from_string(p_input_str, &temp_bit_rate) != RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Invalid value:%s:%d\n", __func__, + __LINE__, p_input_str, temp_bit_rate); + return false; + } + + STR_COPY(p_dm_pre_assoc->operational_data_transmit_rates, p_input_str); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s Not a valid format\n", __func__, __LINE__, p_input_str); + return false; + } + set_cac_cache_changed(instance_number - 1); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SupportedDataTransmitRates")) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d %s Supported Rate to set for preassoc\n", __func__, __LINE__, p_input_str); + + if (STR_CMP(p_input_str, p_dm_pre_assoc->supported_data_transmit_rates)) { + return true; + } else if (strcmp(p_input_str, "disabled") == 0) { + STR_COPY(p_dm_pre_assoc->supported_data_transmit_rates, "disabled"); + } else if (is_valid_transmit_rate(p_input_str)) { + wifi_bitrate_t temp_bit_rate = 0; + + if (get_wifi_data_tx_rate_int_from_string(p_input_str, &temp_bit_rate) != RETURN_OK) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Invalid value:%s:%d\n", __func__, + __LINE__, p_input_str, temp_bit_rate); + return false; + } + + STR_COPY(p_dm_pre_assoc->supported_data_transmit_rates, p_input_str); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s Not a valid format\n", __func__, __LINE__, p_input_str); + return false; + } + set_cac_cache_changed(instance_number - 1); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "MinimumAdvertisedMCS")) { + if (STR_CMP(p_input_str, p_dm_pre_assoc->minimum_advertised_mcs)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_pre_assoc->minimum_advertised_mcs, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format: value should be" + " single integer number between 0 to 7\n", __func__, __LINE__); + return false; + } + if (val < 0 || val > 7) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect value, value should be" + " within 0 to 7\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_pre_assoc->minimum_advertised_mcs, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + set_dml_cache_vap_config_changed(instance_number - 1); + } else if (STR_CMP(param_name, "6GOpInfoMinRate")) { + if (STR_CMP(p_input_str, p_dm_pre_assoc->sixGOpInfoMinRate)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_pre_assoc->sixGOpInfoMinRate, "disabled"); + } else { + STR_COPY(p_dm_pre_assoc->sixGOpInfoMinRate, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + set_dml_cache_vap_config_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool post_conn_ctrl_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + if (isVapSTAMesh(vap_pcfg->vap_index)) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_postassoc_control_t *p_post_assoc = &vap_pcfg->u.bss_info.postassoc; + + if (STR_CMP(param_name, "RssiUpThresholdSupported")) { + set_output_string(output_value, "disabled, -50 to -95"); + } else if (STR_CMP(param_name, "RssiUpThreshold")) { + set_output_string(output_value, p_post_assoc->rssi_up_threshold); + } else if (STR_CMP(param_name, "SamplingIntervalSupported")) { + set_output_string(output_value, "1 to 10"); + } else if (STR_CMP(param_name, "SamplingInterval")) { + set_output_string(output_value, p_post_assoc->sampling_interval); + } else if (STR_CMP(param_name, "SnrThresholdSupported")) { + set_output_string(output_value, "disabled, 1 to 100"); + } else if (STR_CMP(param_name, "SnrThreshold")) { + set_output_string(output_value, p_post_assoc->snr_threshold); + } else if (STR_CMP(param_name, "SamplingCountSupported")) { + set_output_string(output_value, "1 to 10"); + } else if (STR_CMP(param_name, "SamplingCount")) { + set_output_string(output_value, p_post_assoc->sampling_count); + } else if (STR_CMP(param_name, "CuThresholdSupported")) { + set_output_string(output_value, "disabled, 0 to 100"); + } else if (STR_CMP(param_name, "CuThreshold")) { + set_output_string(output_value, p_post_assoc->cu_threshold); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool post_conn_ctrl_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + int val, ret; + wifi_vap_info_t *vap_pcfg = (wifi_vap_info_t *)obj_ins_context; + + DM_CHECK_NULL_WITH_RC(vap_pcfg, false); + + wifi_platform_property_t *p_wifi_prop = &((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop; + uint32_t instance_number = convert_vap_name_to_index(p_wifi_prop, vap_pcfg->vap_name) + 1; + wifi_vap_info_t *p_dm_vap_info = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number - 1); + + if (p_dm_vap_info == NULL) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unable to get VAP info for instance_number:%d\n", __func__, __LINE__, instance_number); + return false; + } + + if ((isVapSTAMesh(vap_pcfg->vap_index)) || + (!isVapHotspot(vap_pcfg->vap_index))) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d %s does not support configuration\n", __func__, + __LINE__, vap_pcfg->vap_name); + return true; + } + + wifi_postassoc_control_t *p_dm_post_assoc = &p_dm_vap_info->u.bss_info.postassoc; + char *p_input_str = (char *)output_value->buff; + + if (STR_CMP(param_name, "RssiUpThreshold")) { + if (STR_CMP(p_input_str, p_dm_post_assoc->rssi_up_threshold)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_post_assoc->rssi_up_threshold, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format." + " Example: 10 to 100\n", __func__, __LINE__); + return false; + } + + if (val > -50 || val < -95) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_post_assoc->rssi_up_threshold, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SamplingInterval")) { + if (STR_CMP(p_input_str, p_dm_post_assoc->sampling_interval)) { + return true; + } else { + ret = sscanf(p_input_str, "%d", &val); + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format. Example: 10 to 100\n", __func__, __LINE__); + return false; + } + + if (val < 1 || val > 10) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_post_assoc->sampling_interval, p_input_str); + set_cac_cache_changed(instance_number - 1); + } + } else if (STR_CMP(param_name, "SnrThreshold")) { + if (STR_CMP(p_input_str, p_dm_post_assoc->snr_threshold)) { + return true; + } else if (strcmp(p_input_str, "disabled") == 0) { + STR_COPY(p_dm_post_assoc->snr_threshold, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format. Example: 10 to 100\n", __func__, + __LINE__); + return false; + } + + if (val < 1 || val > 100) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, + __LINE__); + return false; + } + + STR_COPY(p_dm_post_assoc->snr_threshold, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else if (STR_CMP(param_name, "SamplingCount")) { + if (STR_CMP(p_input_str, p_dm_post_assoc->sampling_count) == 0) { + return true; + } else { + ret = sscanf(p_input_str, "%d", &val); + + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format." + " Example: 10 to 100\n", __func__, __LINE__); + return false; + } + + if (val < 1 || val > 10) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of supported range\n", __func__, + __LINE__); + return false; + } + + STR_COPY(p_dm_post_assoc->sampling_count, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else if (STR_CMP(param_name, "CuThreshold")) { + if (STR_CMP(p_input_str, p_dm_post_assoc->cu_threshold)) { + return true; + } else if (STR_CMP(p_input_str, "disabled")) { + STR_COPY(p_dm_post_assoc->cu_threshold, "disabled"); + } else { + ret = sscanf(p_input_str, "%d", &val); + + /* String should be in format of range between two integers */ + if (ret != 1) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Incorrect format." + " Example: 10 to 100\n", __func__, __LINE__); + return false; + } + + if (val < 10 || val > 100) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Value is out of" + " supported range\n", __func__, __LINE__); + return false; + } + + STR_COPY(p_dm_post_assoc->cu_threshold, p_input_str); + } + set_cac_cache_changed(instance_number - 1); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_wifi_diag_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_config_t *p_global_wifi_config; + p_global_wifi_config = (wifi_global_config_t *) get_dml_cache_global_wifi_config(); + + DM_CHECK_NULL_WITH_RC(p_global_wifi_config, false); + + if (STR_CMP(param_name, "Enable")) { + *output_value = p_global_wifi_config->global_parameters.diagnostic_enable; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_wifi_diag_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool neig_wifi_diag_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_monitor_t *monitor_param = (wifi_monitor_t *)get_wifi_monitor(); + + if (STR_CMP(param_name, "ResultNumberOfEntries")) { + *output_value = (uint32_t)monitor_param->neighbor_scan_cfg.ResultCount; + wifi_util_info_print(WIFI_DMCLI,"%s:%d: neighbor_scan_cfg ResultCount:%d\n",__func__, + __LINE__, monitor_param->neighbor_scan_cfg.ResultCount); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_wifi_diag_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_monitor_t *monitor_param = (wifi_monitor_t *)get_wifi_monitor(); + + if (STR_CMP(param_name, "DiagnosticsState")) { + set_output_string(output_value, monitor_param->neighbor_scan_cfg.DiagnosticsState); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_wifi_diag_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_config_t *p_global_wifi_config; + p_global_wifi_config = (wifi_global_config_t *) get_dml_cache_global_wifi_config(); + + DM_CHECK_NULL_WITH_RC(p_global_wifi_config, false); + + if (STR_CMP(param_name, "Enable")) { + if (p_global_wifi_config->global_parameters.diagnostic_enable != output_value) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d:diagnostic_enable=%d Value:%d\n",__func__, + __LINE__, p_global_wifi_config->global_parameters.diagnostic_enable, output_value); + p_global_wifi_config->global_parameters.diagnostic_enable = output_value; + push_global_config_dml_cache_to_one_wifidb(); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_wifi_diag_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool neig_wifi_diag_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool neig_wifi_diag_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_config_t *p_global_wifi_config; + p_global_wifi_config = (wifi_global_config_t *) get_dml_cache_global_wifi_config(); + wifi_monitor_t *monitor_param = (wifi_monitor_t *)get_wifi_monitor(); + + DM_CHECK_NULL_WITH_RC(p_global_wifi_config, false); + + if (STR_CMP(param_name, "DiagnosticsState")) { + if ((STR_CMP((char *)output_value->buff, "Requested")) && + (p_global_wifi_config->global_parameters.diagnostic_enable)) { + if (STR_CMP(monitor_param->neighbor_scan_cfg.DiagnosticsState, "Requested")) { + return true; + } + + process_neighbor_scan_dml(); + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_diag_result_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_neighbor_ap2_t * p_neighbor_cfg = (wifi_neighbor_ap2_t *)obj_ins_context; + + if (STR_CMP(param_name, "SignalStrength")) { + *output_value = p_neighbor_cfg->ap_SignalStrength; + } else if (STR_CMP(param_name, "Noise")) { + *output_value = p_neighbor_cfg->ap_Noise; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_diag_result_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_neighbor_ap2_t * p_neighbor_cfg = (wifi_neighbor_ap2_t *)obj_ins_context; + + if (STR_CMP(param_name, "DTIMPeriod")) { + *output_value = p_neighbor_cfg->ap_DTIMPeriod; + } else if (STR_CMP(param_name, "X_COMCAST-COM_ChannelUtilization")) { + *output_value = p_neighbor_cfg->ap_ChannelUtilization; + } else if (STR_CMP(param_name, "Channel")) { + *output_value = p_neighbor_cfg->ap_Channel; + } else if (STR_CMP(param_name, "BeaconPeriod")) { + *output_value = p_neighbor_cfg->ap_BeaconPeriod; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool neig_diag_result_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_neighbor_ap2_t * p_neighbor_cfg = (wifi_neighbor_ap2_t *)obj_ins_context; + + if (STR_CMP(param_name, "Radio")) { + wifi_freq_bands_t l_freq_band; + + if (get_radio_band_int_from_string(p_neighbor_cfg->ap_OperatingFrequencyBand, &l_freq_band) != RETURN_ERR) { + return false; + } + + wifi_radio_operationParam_t *radio_oper_param = NULL; + char buff[32] = { 0 }; + + for (uint32_t index = 0; index < (uint32_t)get_num_radio_dml(); index++) { + radio_oper_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(index); + if (radio_oper_param != NULL && radio_oper_param->band == l_freq_band) { + snprintf(buff, sizeof(buff), "Device.WiFi.Radio.%u", index + 1); + set_output_string(output_value, buff); + return true; + } + } + return false; + } else if (STR_CMP(param_name, "EncryptionMode")) { + set_output_string(output_value, p_neighbor_cfg->ap_EncryptionMode); + } else if (STR_CMP(param_name, "Mode")) { + set_output_string(output_value, p_neighbor_cfg->ap_Mode); + } else if (STR_CMP(param_name, "SecurityModeEnabled")) { + set_output_string(output_value, p_neighbor_cfg->ap_SecurityModeEnabled); + } else if (STR_CMP(param_name, "BasicDataTransferRates")) { + set_output_string(output_value, p_neighbor_cfg->ap_BasicDataTransferRates); + } else if (STR_CMP(param_name, "SupportedDataTransferRates")) { + set_output_string(output_value, p_neighbor_cfg->ap_SupportedDataTransferRates); + } else if (STR_CMP(param_name, "OperatingChannelBandwidth")) { + set_output_string(output_value, p_neighbor_cfg->ap_OperatingChannelBandwidth); + } else if (STR_CMP(param_name, "OperatingStandards")) { + set_output_string(output_value, p_neighbor_cfg->ap_OperatingStandards); + } else if (STR_CMP(param_name, "SupportedStandards")) { + set_output_string(output_value, p_neighbor_cfg->ap_SupportedStandards); + } else if (STR_CMP(param_name, "BSSID")) { + set_output_string(output_value, p_neighbor_cfg->ap_BSSID); + } else if( STR_CMP(param_name, "SSID")) { + set_output_string(output_value, p_neighbor_cfg->ap_SSID); + } else if (STR_CMP(param_name, "OperatingFrequencyBand")) { + set_output_string(output_value, p_neighbor_cfg->ap_OperatingFrequencyBand); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_report_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "Enabled")) { + *output_value = pcfg->b_inst_client_enabled; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_report_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "ReportingPeriod")) { + *output_value = pcfg->u_inst_client_reporting_period; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_report_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "MacAddress")) { + set_output_string(output_value, pcfg->mac_address); + } else if (STR_CMP(param_name, "Schema")) { + set_output_string(output_value, "WifiSingleClient.avsc"); + } else if (STR_CMP(param_name, "SchemaID")) { + set_output_string(output_value, INST_SCHEMA_ID_BUFFER); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_report_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *p_dml_harvester = (instant_measurement_config_t *) get_dml_cache_harvester(); + + DM_CHECK_NULL_WITH_RC(p_dml_harvester, false); + + if (STR_CMP(param_name, "Enabled")) { + if ((output_value == true) && + (p_dml_harvester->u_inst_client_reporting_period > p_dml_harvester->u_inst_client_def_override_ttl)) { + wifi_util_error_print(WIFI_DMCLI,"Can not start report when PollingPeriod > TTL\n"); + return false; + } + + p_dml_harvester->b_inst_client_enabled = output_value; + push_harvester_dml_cache_to_one_wifidb(); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_report_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) obj_ins_context; + instant_measurement_config_t *p_dml_harvester = (instant_measurement_config_t *) get_dml_cache_harvester(); + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(p_dml_harvester, false); + + if (STR_CMP(param_name, "ReportingPeriod")) { + if (validate_def_reporting_period_value(output_value)) { + if (pcfg->b_inst_client_enabled && (output_value != 0) && + (output_value > p_dml_harvester->u_inst_client_def_override_ttl)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d Unsupported parameter value:%d" + " def override ttl value:%d\n", __func__, __LINE__, output_value, + p_dml_harvester->u_inst_client_def_override_ttl); + return false; + } else { + p_dml_harvester->u_inst_client_reporting_period = output_value; + push_harvester_dml_cache_to_one_wifidb(); + } + } else { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Unsupported parameter value:'%d'" + " for ReportingPeriod\n", __func__, __LINE__, output_value); + return false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_report_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *p_dml_harvester = (instant_measurement_config_t *) get_dml_cache_harvester(); + + DM_CHECK_NULL_WITH_RC(p_dml_harvester, false); + + if (STR_CMP(param_name, "MacAddress")) { + if (validate_inst_client_mac_value((char *)output_value->buff)){ + STR_COPY(p_dml_harvester->mac_address, (char *)output_value->buff); + push_harvester_dml_cache_to_one_wifidb(); + } else { + return false; + } + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_def_report_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) obj_ins_context; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "OverrideTTL")) { + *output_value = pcfg->u_inst_client_def_override_ttl; + } else if (STR_CMP(param_name, "ReportingPeriod")) { + *output_value = pcfg->u_inst_client_def_reporting_period; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_client_def_report_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + instant_measurement_config_t *pcfg = (instant_measurement_config_t *) obj_ins_context; + instant_measurement_config_t *p_dml_harvester = (instant_measurement_config_t *) get_dml_cache_harvester(); + + DM_CHECK_NULL_WITH_RC(pcfg, false); + DM_CHECK_NULL_WITH_RC(p_dml_harvester, false); + + if (STR_CMP(param_name, "OverrideTTL")) { + if (pcfg->b_inst_client_enabled && (output_value != 0) && + (output_value > p_dml_harvester->u_inst_client_reporting_period)) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Unsupported parameter value:'%d'" + " > inst client reporting period:%d\n", __func__, __LINE__, output_value, + p_dml_harvester->u_inst_client_reporting_period); + return false; + } else if (output_value > 900) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Unsupported parameter value:'%d'\n", __func__, + __LINE__, output_value); + return false; + } + p_dml_harvester->u_inst_client_def_override_ttl = output_value; + push_harvester_dml_cache_to_one_wifidb(); + } else if (STR_CMP(param_name, "ReportingPeriod")) { + if (validate_def_reporting_period_value(output_value) != true) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d: Unsupported parameter value:'%d'" + " for Defualt ReportingPeriod\n", __func__, __LINE__, output_value); + return false; + } + p_dml_harvester->u_inst_client_def_reporting_period = output_value; + push_harvester_dml_cache_to_one_wifidb(); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_region_code_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_param_t *pcfg = (wifi_global_param_t *)obj_ins_context; + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "Code")) { + set_output_string(output_value, pcfg->wifi_region_code); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool wifi_region_code_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + wifi_global_param_t *pcfg = (wifi_global_param_t *)obj_ins_context; + uint32_t radio_index = 0; + char partner_id[PARTNER_ID_LEN] = {0}; + char current_time[50] = { 0 }; + char requestor_str[16] = { 0 }; + char str_wifi_region_update_src[16] = { 0 }; + wifi_radio_operationParam_t *p_dm_wifi_radio_param; + wifi_global_config_t *p_dm_global_wifi_cfg; + p_dm_global_wifi_cfg = (wifi_global_config_t *) get_dml_cache_global_wifi_config(); + wifi_countrycode_type_t l_country_code; + wifi_operating_env_t l_oper_env; + + DM_CHECK_NULL_WITH_RC(pcfg, false); + + if (STR_CMP(param_name, "Code")) { + get_requestor_string(requestor_str); + get_wifi_region_update_source(str_wifi_region_update_src); + if (strcmp(requestor_str, BS_SOURCE_RFC_STR) == 0 && + strcmp(str_wifi_region_update_src, BS_SOURCE_WEBPA_STR) == 0) { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Do NOT allow override\n", __func__, __LINE__); + return false; + } + + for (radio_index = 0; radio_index < get_num_radio_dml(); radio_index++) { + p_dm_wifi_radio_param = (wifi_radio_operationParam_t *) get_dml_cache_radio_map(radio_index); + if (p_dm_wifi_radio_param == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to fetch Operating params for radio index:%d\n", __func__, + __LINE__, radio_index); + continue; + } + + if (get_reg_domain_int_from_string((char *)output_value->buff, &l_country_code, + &l_oper_env) == RETURN_OK) { + is_radio_config_changed = true; + p_dm_wifi_radio_param->countryCode = l_country_code; + p_dm_wifi_radio_param->operatingEnvironment = l_oper_env; + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d Unable to convert country code for radio_index %d\n", __func__, + __LINE__, radio_index); + return false; + } + } + + strcpy(p_dm_global_wifi_cfg->global_parameters.wifi_region_code, (char *)output_value->buff); + push_global_config_dml_cache_to_one_wifidb(); + push_radio_dml_cache_to_one_wifidb(); + last_radio_change = get_current_time_in_sec(); + + if((RETURN_OK == get_partner_id(partner_id) ) && (partner_id[ 0 ] != '\0') ) { + get_cur_time_str(current_time, sizeof(current_time)); + if (update_json_param("Device.WiFi.X_RDKCENTRAL-COM_Syndication.WiFiRegion.Code", partner_id, + (char *)output_value->buff, requestor_str, current_time) != RETURN_OK) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to update WifiRegion to Json file\n", __func__, __LINE__); + } + } + set_wifi_region_update_source(requestor_str); + } else { + wifi_util_info_print(WIFI_DMCLI,"%s:%d: unsupported param name:%s\n",__func__, __LINE__, param_name); + return false; + } + + return true; +} + +bool default_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_set_param_int_value(void *obj_ins_context, char *param_name, int output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} + +bool default_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value) +{ + wifi_util_info_print(WIFI_DMCLI,"%s:%d: param name:%s\n",__func__, __LINE__, param_name); + return true; +} diff --git a/source/platform/common/data_model/wifi_dml_cb.h b/source/platform/common/data_model/wifi_dml_cb.h new file mode 100644 index 00000000..98ece838 --- /dev/null +++ b/source/platform/common/data_model/wifi_dml_cb.h @@ -0,0 +1,163 @@ +#ifndef WIFI_DML_CB_H +#define WIFI_DML_CB_H + +#include +#include +#include +#include +#include +#include "wifi_data_model.h" + +#define SAE_PASSPHRASE_MIN_LENGTH 8 +#define SAE_PASSPHRASE_MAX_LENGTH 64 + +#define INST_SCHEMA_ID_BUFFER "8b27dafc-0c4d-40a1-b62c-f24a34074914/4388e585dd7c0d32ac47e71f634b579b" + +typedef struct mac_filter_set_param_arg { + acl_entry_t *acl_param; + wifi_vap_info_t *vap_info_param; +} mac_filter_set_param_arg_t; + +bool wifi_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool wifi_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool wifi_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool wifi_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool wifi_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool wifi_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool wifi_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool wifi_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool radio_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool radio_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool radio_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool radio_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool radio_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool radio_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool radio_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool radio_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool accesspoint_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool accesspoint_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool accesspoint_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool accesspoint_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool accesspoint_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool accesspoint_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool accesspoint_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool accesspoint_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool ssid_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool ssid_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool ssid_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool ssid_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool ssid_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool ssid_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool ssid_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool ssid_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool security_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool security_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool security_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool security_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool security_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool security_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool security_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool security_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool radius_sec_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool radius_sec_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool radius_sec_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool radius_sec_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); + +bool auth_sec_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool auth_sec_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); + +bool interworking_serv_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool interworking_serv_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool passpoint_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool passpoint_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool passpoint_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool passpoint_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool wps_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool wps_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool wps_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool wps_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool wps_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool wps_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool wps_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool wps_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool conn_ctrl_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool conn_ctrl_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool pre_conn_ctrl_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool pre_conn_ctrl_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool post_conn_ctrl_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool post_conn_ctrl_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +void *macfilter_tab_add_entry(void *obj_ins_context, uint32_t *p_ins_number); +int macfilter_tab_del_entry(void *obj_ins_context, void *p_instance); +bool macfilter_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool macfilter_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool macfilter_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool macfilter_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool macfilter_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool macfilter_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool macfilter_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool macfilter_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool associated_sta_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool associated_sta_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool associated_sta_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool associated_sta_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool interworking_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool interworking_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool interworking_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool interworking_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool interworking_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool interworking_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool interworking_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool interworking_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool ap_macfilter_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool ap_macfilter_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); + +bool neig_wifi_diag_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool neig_wifi_diag_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool neig_wifi_diag_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool neig_wifi_diag_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool neig_wifi_diag_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool neig_wifi_diag_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool neig_wifi_diag_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool neig_wifi_diag_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool neig_diag_result_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool neig_diag_result_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool neig_diag_result_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool wifi_client_report_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool wifi_client_report_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool wifi_client_report_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool wifi_client_report_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool wifi_client_report_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool wifi_client_report_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool wifi_client_def_report_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool wifi_client_def_report_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); + +bool wifi_region_code_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool wifi_region_code_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +bool default_get_param_bool_value(void *obj_ins_context, char *param_name, bool *output_value); +bool default_get_param_int_value(void *obj_ins_context, char *param_name, int *output_value); +bool default_get_param_uint_value(void *obj_ins_context, char *param_name, uint32_t *output_value); +bool default_get_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); +bool default_set_param_bool_value(void *obj_ins_context, char *param_name, bool output_value); +bool default_set_param_int_value(void *obj_ins_context, char *param_name, int output_value); +bool default_set_param_uint_value(void *obj_ins_context, char *param_name, uint32_t output_value); +bool default_set_param_string_value(void *obj_ins_context, char *param_name, scratch_data_buff_t *output_value); + +#endif //WIFI_DML_CB_H diff --git a/source/platform/common/misc_common.h b/source/platform/common/misc_common.h index f783a0a7..8154e827 100644 --- a/source/platform/common/misc_common.h +++ b/source/platform/common/misc_common.h @@ -33,6 +33,7 @@ typedef int (* initparodusTask_t) (); typedef int (* wifi_getRadioTrafficStats2_t) (int radioIndex, wifi_radioTrafficStats2_t *output_struct); typedef int (* WiFi_InitGasConfig_t) (); typedef void (* daemonize_t) (); +typedef void (* sendWebpaMsg_t) (char *serviceName, char *dest, char *trans_id, char *traceParent, char *traceState, char *contentType, char *payload, unsigned int payload_len); typedef struct { sysevent_open_t sysevent_open_fn; @@ -42,6 +43,7 @@ typedef struct { wifi_getRadioTrafficStats2_t wifi_getRadioTrafficStats2_fn; WiFi_InitGasConfig_t WiFi_InitGasConfig_fn; daemonize_t daemonize_fn; + sendWebpaMsg_t sendWebpaMsg_fn; } wifi_misc_desc_t; #ifdef __cplusplus diff --git a/source/platform/linux/bus.c b/source/platform/linux/bus.c index b726c538..55198899 100644 --- a/source/platform/linux/bus.c +++ b/source/platform/linux/bus.c @@ -320,6 +320,22 @@ bus_error_t bus_event_subscribe_ex_async(bus_handle_t *handle, bus_event_sub_t * return (bus_error_t)rc; } +static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, + uint32_t row_index, char const *alias) +{ + return bus_error_success; +} + +static bus_error_t bus_unreg_table_row(bus_handle_t *handle, char const *name) +{ + return bus_error_success; +} + +static bus_error_t bus_remove_table_row(bus_handle_t *handle, char const *name) +{ + return bus_error_success; +} + static void bus_desc_init(wifi_bus_desc_t *desc) { desc->bus_init_fn = bus_init; @@ -337,4 +353,7 @@ static void bus_desc_init(wifi_bus_desc_t *desc) desc->bus_event_subs_ex_async_fn = bus_event_subscribe_ex_async; desc->bus_method_invoke_fn = bus_method_invoke; desc->bus_get_trace_context_fn = bus_get_trace_context; + desc->bus_reg_table_row_fn = bus_reg_table_row; + desc->bus_unreg_table_row_fn = bus_unreg_table_row; + desc->bus_remove_table_row_fn = bus_remove_table_row; } diff --git a/source/platform/linux/misc.c b/source/platform/linux/misc.c index 5562a2fe..0b37d880 100644 --- a/source/platform/linux/misc.c +++ b/source/platform/linux/misc.c @@ -38,6 +38,11 @@ void linux_daemonize() return 0; } +void linux_sendWebpaMsg(char *serviceName, char *dest, char *trans_id, char *traceParent, char *traceState, char *contentType, char *payload, unsigned int payload_len) +{ + return; +} + void wifi_misc_init(wifi_misc_t *misc) { misc->desc.sysevent_open_fn = linux_sysevent_open; @@ -48,4 +53,5 @@ void wifi_misc_init(wifi_misc_t *misc) misc->desc.wifi_getRadioTrafficStats2_fn = linux_wifi_getRadioTrafficStats2; misc->desc.WiFi_InitGasConfig_fn = linux_WiFi_InitGasConfig; misc->desc.daemonize_fn = linux_daemonize; + misc->desc.sendWebpaMsg_fn = linux_sendWebpaMsg; } diff --git a/source/platform/openwrt/bus.c b/source/platform/openwrt/bus.c index fb310378..c02fc269 100644 --- a/source/platform/openwrt/bus.c +++ b/source/platform/openwrt/bus.c @@ -154,6 +154,22 @@ wifi_bus_desc_t *get_bus_descriptor(void) return &g_bus.desc; } +static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, + uint32_t row_index, char const *alias) +{ + return bus_error_success; +} + +static bus_error_t bus_unreg_table_row(bus_handle_t *handle, char const *name) +{ + return bus_error_success; +} + +static bus_error_t bus_remove_table_row(bus_handle_t *handle, char const *name) +{ + return bus_error_success; +} + void wifi_bus_init(void) { g_bus.desc.bus_init_fn = bus_init; @@ -175,4 +191,7 @@ void wifi_bus_init(void) g_bus.desc.bus_property_get_name_fn = bus_property_get_name; g_bus.desc.bus_method_invoke_fn = bus_method_invoke; g_bus.desc.bus_get_trace_context_fn = bus_get_trace_context; + g_bus.bus_reg_table_row_fn = bus_reg_table_row; + g_bus.bus_unreg_table_row_fn = bus_unreg_table_row; + g_bus.bus_remove_table_row_fn = bus_remove_table_row; } diff --git a/source/platform/rdkb/bus.c b/source/platform/rdkb/bus.c index 6eb57d2c..45db3b5e 100644 --- a/source/platform/rdkb/bus.c +++ b/source/platform/rdkb/bus.c @@ -465,8 +465,9 @@ rbusValueType_t convert_bus_to_rbus_data_type(bus_data_type_t bus_data_type) void free_raw_data_struct(raw_data_t *p_data) { - wifi_util_info_print(WIFI_BUS, "%s:%d free raw obj data type:%02x\r\n", __func__, __LINE__, p_data->data_type); if ((p_data->data_type == bus_data_type_string || p_data->data_type == bus_data_type_bytes) && p_data->raw_data.bytes != NULL) { + wifi_util_dbg_print(WIFI_BUS, "%s:%d free raw obj data type:%02x:%p\r\n", __func__, + __LINE__, p_data->data_type, p_data->raw_data.bytes); free(p_data->raw_data.bytes); p_data->raw_data.bytes = NULL; } @@ -501,6 +502,10 @@ bus_error_t get_rbus_property_data(char *event_name, rbusProperty_t property, ra bus_data->raw_data.u32 = rbusValue_GetUInt32(value); bus_data->raw_data_len = sizeof(uint32_t); break; + case RBUS_INT32: + bus_data->raw_data.i32 = rbusValue_GetInt32(value); + bus_data->raw_data_len = sizeof(int32_t); + break; case RBUS_BOOLEAN: bus_data->raw_data.b = rbusValue_GetBoolean(value); bus_data->raw_data_len = sizeof(bool); @@ -531,14 +536,21 @@ bus_error_t set_rbus_property_data(char *event_name, rbusProperty_t property, ra switch(bus_data->data_type) { case bus_data_type_string: // the encoded data is a string - rbusValue_SetString(value, (char *)bus_data->raw_data.bytes); + if (bus_data->raw_data.bytes != NULL) { + rbusValue_SetString(value, (char *)bus_data->raw_data.bytes); + } break; case bus_data_type_bytes: - rbusValue_SetBytes(value, (uint8_t *)bus_data->raw_data.bytes, bus_data->raw_data_len); + if (bus_data->raw_data.bytes != NULL) { + rbusValue_SetBytes(value, (uint8_t *)bus_data->raw_data.bytes, bus_data->raw_data_len); + } break; case bus_data_type_uint32: rbusValue_SetUInt32(value, bus_data->raw_data.u32); break; + case bus_data_type_int32: + rbusValue_SetInt32(value, bus_data->raw_data.i32); + break; case bus_data_type_boolean: rbusValue_SetBoolean(value, bus_data->raw_data.b); break; @@ -586,6 +598,10 @@ bus_error_t get_rbus_object_data(char *name, rbusObject_t inParams, raw_data_t * bus_data->raw_data.u32 = rbusValue_GetUInt32(value); bus_data->raw_data_len = sizeof(uint32_t); break; + case RBUS_INT32: + bus_data->raw_data.i32 = rbusValue_GetInt32(value); + bus_data->raw_data_len = sizeof(int32_t); + break; case RBUS_BOOLEAN: bus_data->raw_data.b = rbusValue_GetBoolean(value); bus_data->raw_data_len = sizeof(bool); @@ -648,6 +664,8 @@ rbusError_t rbus_get_handler(rbusHandle_t handle, rbusProperty_t property, rbusG if (event_name == NULL) { wifi_util_error_print(WIFI_BUS,"%s:%d rbus event name is NULL\n", __func__, __LINE__); return RBUS_ERROR_INVALID_INPUT; + } else if (options != NULL && options->requestingComponent != NULL) { + wifi_util_info_print(WIFI_BUS,"%s:%d rbus data get end comp:%s\n", __func__, __LINE__, options->requestingComponent); } wifi_util_info_print(WIFI_BUS,"%s:%d rbus cb triggered for %s\n", __func__, __LINE__, event_name); @@ -692,6 +710,8 @@ rbusError_t rbus_set_handler(rbusHandle_t handle, rbusProperty_t property, rbusS if (event_name == NULL) { wifi_util_error_print(WIFI_BUS,"%s:%d rbus event name is NULL\n", __func__, __LINE__); return RBUS_ERROR_INVALID_INPUT; + } else if (options != NULL && options->requestingComponent != NULL) { + wifi_util_info_print(WIFI_BUS,"%s:%d rbus data set end comp:%s\n", __func__, __LINE__, options->requestingComponent); } wifi_util_info_print(WIFI_BUS,"%s:%d rbus cb triggered for %s\n", __func__, __LINE__, event_name); @@ -704,6 +724,14 @@ rbusError_t rbus_set_handler(rbusHandle_t handle, rbusProperty_t property, rbusS if (user_cb->set_handler != NULL) { ret = get_rbus_property_data(event_name, property, &bus_data); if (ret == bus_error_success) { +#ifndef ONEWIFI_DML_SUPPORT + int ret_status = validate_dm_set_parameters(®_node_data->data_model_prop, &bus_data); + if (ret_status != RETURN_OK) { + wifi_util_error_print(WIFI_BUS,"%s:%d rbus event:%s, invalid data:%x operation\n", __func__, + __LINE__, event_name, bus_data.data_type); + return RBUS_ERROR_INVALID_OPERATION; + } +#endif ret = user_cb->set_handler(event_name, &bus_data); if (ret != bus_error_success) { wifi_util_error_print(WIFI_BUS,"%s:%d user cb processing failed:%d for %s\n", __func__, @@ -848,14 +876,11 @@ void rbus_sub_ex_async_handler(rbusHandle_t handle, rbusEventSubscription_t* sub } } -static void bus_cb_registration(bus_data_element_t *data_element, rbusCallbackTable_t *cb_table) +static bool map_bus_user_cb_with_rbus(bus_data_element_t *data_element, rbusCallbackTable_t *cb_table) { bool user_cb_set = false; - bus_name_string_t event_name = { 0 }; bus_callback_table_t *user_cb = &data_element->cb_table; - strncpy(event_name, data_element->full_name, strlen(data_element->full_name) + 1); - if (user_cb->get_handler != NULL) { cb_table->getHandler = rbus_get_handler; user_cb_set = true; @@ -886,7 +911,17 @@ static void bus_cb_registration(bus_data_element_t *data_element, rbusCallbackTa user_cb_set = true; } - wifi_util_info_print(WIFI_BUS,"%s:%d user_cb_set:%d event_name:%s\n", __func__, __LINE__, user_cb_set, event_name); + wifi_util_info_print(WIFI_BUS,"%s:%d user_cb_set:%d event_name:%s\n", __func__, + __LINE__, user_cb_set, data_element->full_name); + return user_cb_set; +} + +static void mux_bus_cb_registration(bus_data_element_t *data_element, bool user_cb_set) +{ + bus_name_string_t event_name = { 0 }; + + strncpy(event_name, data_element->full_name, strlen(data_element->full_name) + 1); + if (user_cb_set == true) { elem_node_map_t *reg_cb_mux_map = get_bus_mux_reg_cb_map(); bus_mux_reg_node_data_t reg_node_data; @@ -1036,6 +1071,9 @@ static bus_error_t bus_set(bus_handle_t *handle, char const *name, raw_data_t *d case bus_data_type_uint32: rbusValue_SetUInt32(value, data->raw_data.u32); break; + case bus_data_type_int32: + rbusValue_SetInt32(value, data->raw_data.i32); + break; case bus_data_type_bytes: rbusValue_SetBytes(value, (uint8_t *)data->raw_data.bytes, data->raw_data_len); break; @@ -1101,6 +1139,10 @@ static bus_error_t bus_data_get(bus_handle_t *handle, char const *name, raw_data data->raw_data.u32 = (uint32_t)rbusValue_GetUInt32(value); data->data_type = bus_data_type_uint32; break; + case RBUS_INT32: + data->raw_data.i32 = (int32_t)rbusValue_GetInt32(value); + data->data_type = bus_data_type_int32; + break; case RBUS_BYTES: ptr = (void *)rbusValue_GetBytes(value, &len); data->data_type = bus_data_type_bytes; @@ -1158,6 +1200,9 @@ static bus_error_t bus_event_publish(bus_handle_t *handle, char const *name, raw case bus_data_type_uint32: rbusValue_SetUInt32(value, data->raw_data.u32); break; + case bus_data_type_int32: + rbusValue_SetInt32(value, data->raw_data.i32); + break; case bus_data_type_bytes: rbusValue_SetBytes(value, (uint8_t *)data->raw_data.bytes, data->raw_data_len); break; @@ -1251,6 +1296,7 @@ bus_error_t bus_reg_data_elements(bus_handle_t *handle, bus_data_element_t *data rbusDataElement_t *rbus_dataElements; uint32_t index, table_index; char sub[] = ".{i}"; + bool user_cb_set; wifi_util_dbg_print(WIFI_BUS, "%s:%d bus: bus_reg_data_elements() hdl:%p, \ num_of_element:%d\n", __func__, __LINE__, p_rbus_handle, num_of_element); @@ -1271,17 +1317,14 @@ bus_error_t bus_reg_data_elements(bus_handle_t *handle, bus_data_element_t *data for (index = 0; index < num_of_element; index++) { rbus_dataElements[index].name = data_element[index].full_name; rbus_dataElements[index].type = convert_bus_to_rbus_elem_type(data_element[index].type); - bus_cb_registration(&data_element[index], &rbus_dataElements[index].cbTable); - } - - rc = rbus_regDataElements(p_rbus_handle, num_of_element, rbus_dataElements); - if (rc != RBUS_ERROR_SUCCESS) { - wifi_util_error_print(WIFI_BUS, "%s:%d: bus: rbus_regDataElements failed. \ - rc:%d.\n", __func__, __LINE__, rc); - rbus_unregDataElements(p_rbus_handle, num_of_element, rbus_dataElements); - rbus_close(p_rbus_handle); - free(rbus_dataElements); - return convert_rbus_to_bus_error_code(rc); + user_cb_set = map_bus_user_cb_with_rbus(&data_element[index], &rbus_dataElements[index].cbTable); + rc = rbus_regDataElements(p_rbus_handle, 1, &rbus_dataElements[index]); + if (rc != RBUS_ERROR_SUCCESS) { + wifi_util_error_print(WIFI_BUS, "%s:%d: bus: rbus_regDataElements failed. \ + rc:%d for %s\n", __func__, __LINE__, rc, data_element[index].full_name); + } else { + mux_bus_cb_registration(&data_element[index], user_cb_set); + } } wifi_util_info_print(WIFI_BUS, @@ -1370,6 +1413,10 @@ bus_error_t bus_method_invoke(bus_handle_t *handle, void *paramName, char *event output_data->raw_data.u32 = (uint32_t)rbusValue_GetUInt32(value); output_data->raw_data_len = sizeof(uint32_t); break; + case bus_data_type_int32: + output_data->raw_data.i32 = (int32_t)rbusValue_GetInt32(value); + output_data->raw_data_len = sizeof(int32_t); + break; case bus_data_type_bytes: output_data->raw_data.bytes = (void *)rbusValue_GetBytes(value, &len); output_data->raw_data_len = (unsigned int)len; @@ -1491,6 +1538,68 @@ bus_error_t bus_event_subscribe_ex_async(bus_handle_t *handle, bus_event_sub_t * return convert_rbus_to_bus_error_code(ret); } +static bus_error_t bus_reg_table_row(bus_handle_t *handle, char const *name, + uint32_t row_index, char const *alias) +{ + rbusError_t rc; + VERIFY_NULL_WITH_RC(name); + VERIFY_NULL_WITH_RC(handle); + + rbusHandle_t p_rbus_handle = handle->u.rbus_handle; + + rc = rbusTable_registerRow(p_rbus_handle, name, row_index, alias); + if (rc != RBUS_ERROR_SUCCESS) { + wifi_util_error_print(WIFI_BUS, "%s:%d bus: rbusTable_registerRow failed for" + " [%s] with error [%d] row_index:%d\n", __func__, __LINE__, name, rc, row_index); + } else { + if (bus_table_add_row(get_bus_mux_reg_cb_map(), (char *)name, row_index) != bus_error_success) { + wifi_util_error_print(WIFI_BUS, "%s:%d bus: mux table add failed for" + " [%s] row_index:%d\n", __func__, __LINE__, name, row_index); + } + } + + return convert_rbus_to_bus_error_code(rc); +} + +static bus_error_t bus_unreg_table_row(bus_handle_t *handle, char const *name) +{ + rbusError_t rc; + VERIFY_NULL_WITH_RC(name); + VERIFY_NULL_WITH_RC(handle); + + rbusHandle_t p_rbus_handle = handle->u.rbus_handle; + + rc = rbusTable_unregisterRow(p_rbus_handle, name); + if (rc != RBUS_ERROR_SUCCESS) { + wifi_util_error_print(WIFI_BUS, "%s:%d bus: rbusTable_unregisterRow failed for" + " [%s] with error [%d]\n", __func__, __LINE__, name, rc); + } else { + if (bus_table_remove_row(get_bus_mux_reg_cb_map(), (char *)name) != bus_error_success) { + wifi_util_error_print(WIFI_BUS, "%s:%d bus: mux table remove failed for" + " [%s]\n", __func__, __LINE__, name); + } + } + + return convert_rbus_to_bus_error_code(rc); +} + +static bus_error_t bus_remove_table_row(bus_handle_t *handle, char const *name) +{ + rbusError_t rc; + VERIFY_NULL_WITH_RC(name); + VERIFY_NULL_WITH_RC(handle); + + rbusHandle_t p_rbus_handle = handle->u.rbus_handle; + + rc = rbusTable_removeRow(p_rbus_handle, name); + if (rc != RBUS_ERROR_SUCCESS) { + wifi_util_error_print(WIFI_BUS, "%s:%d bus: rbusTable_removeRow failed for" + " [%s] with error [%d]\n", __func__, __LINE__, name, rc); + } + + return convert_rbus_to_bus_error_code(rc); +} + void rdkb_bus_desc_init(wifi_bus_desc_t *desc) { desc->bus_init_fn = bus_init; @@ -1508,4 +1617,7 @@ void rdkb_bus_desc_init(wifi_bus_desc_t *desc) desc->bus_event_subs_ex_async_fn = bus_event_subscribe_ex_async; desc->bus_method_invoke_fn = bus_method_invoke; desc->bus_get_trace_context_fn = bus_get_trace_context; + desc->bus_reg_table_row_fn = bus_reg_table_row; + desc->bus_unreg_table_row_fn = bus_unreg_table_row; + desc->bus_remove_table_row_fn = bus_remove_table_row; } diff --git a/source/platform/rdkb/misc.c b/source/platform/rdkb/misc.c index c49926ef..820742f1 100644 --- a/source/platform/rdkb/misc.c +++ b/source/platform/rdkb/misc.c @@ -60,7 +60,7 @@ void rdkb_daemonize() sem_unlink ("pSemCcspWifi"); /* unlink prevents the semaphore existing forever */ /* if a crash occurs during the execution */ - wifi_util_dbg_print(WIFI_MGR,"Semaphore initialization Done!!\n"); + wifi_util_info_print(WIFI_MGR,"Semaphore initialization Done!!:%p\n", sem); switch (fork()) { case 0: @@ -97,6 +97,11 @@ void rdkb_daemonize() } } +void rdkb_sendWebpaMsg(char *serviceName, char *dest, char *trans_id, char *traceParent, char *traceState, char *contentType, char *payload, unsigned int payload_len) +{ + sendWebpaMsg(serviceName, dest, trans_id, traceParent, traceState, contentType, payload, payload_len); +} + void wifi_misc_init(wifi_misc_t *misc) { misc->desc.sysevent_open_fn = rdkb_sysevent_open; @@ -107,4 +112,5 @@ void wifi_misc_init(wifi_misc_t *misc) misc->desc.wifi_getRadioTrafficStats2_fn = rdkb_wifi_getRadioTrafficStats2; misc->desc.WiFi_InitGasConfig_fn = rdkb_WiFi_InitGasConfig; misc->desc.daemonize_fn = rdkb_daemonize; + misc->desc.sendWebpaMsg_fn = rdkb_sendWebpaMsg; } diff --git a/source/stats/wifi_associated_devices_msmt.c b/source/stats/wifi_associated_devices_msmt.c index 41fd4338..a7e7766d 100644 --- a/source/stats/wifi_associated_devices_msmt.c +++ b/source/stats/wifi_associated_devices_msmt.c @@ -37,10 +37,10 @@ #include #include #include -#include "harvester.h" #include "wifi_stubs.h" #include "wifi_util.h" +#include "misc.h" // HASH - 7985cdc3a29f21c283fdcc0fcdcce550 // UUID - ec57a5b6-b167-4623-baff-399f063bd56a @@ -589,7 +589,7 @@ void upload_associated_devices_msmt_data(bssid_data_t *bssid_info, sta_data_t *s size += MAGIC_NUMBER_SIZE + SCHEMA_ID_LENGTH; #ifdef ONEWIFI_HARVESTER_APP_SUPPORT - sendWebpaMsg((char *)serviceName,(char *) dest, trans_id, NULL, NULL, (char *)contentType, buff, size);//ONE_WIFI + get_misc_descriptor()->sendWebpaMsg_fn((char *)serviceName,(char *) dest, trans_id, NULL, NULL, (char *)contentType, buff, size); #endif wifi_util_dbg_print(WIFI_MON, "Creating telemetry record successful\n"); } diff --git a/source/stats/wifi_monitor.c b/source/stats/wifi_monitor.c index c64da7bd..2079a6d2 100644 --- a/source/stats/wifi_monitor.c +++ b/source/stats/wifi_monitor.c @@ -16,7 +16,6 @@ See the License for the specific language governing permissions and limitations under the License. **************************************************************************/ -#include "harvester.h" #include "wifi_passpoint.h" #include #include diff --git a/source/utils/Makefile.am b/source/utils/Makefile.am index 886fbe7e..f7335c9c 100644 --- a/source/utils/Makefile.am +++ b/source/utils/Makefile.am @@ -43,8 +43,10 @@ AM_LDFLAGS += -lpthread AM_LDFLAGS += -ldl AM_LDFLAGS += -ljansson AM_LDFLAGS += -lrt +if ONEWIFI_DML_SUPPORT AM_LDFLAGS += -L$(top_builddir)/../CcspCommonLibrary/lib AM_LDFLAGS += -lccsp_common +endif AM_LDFLAGS += -lrdk_wifihal AM_CPPFLAGS = -Wall -Werror @@ -63,7 +65,10 @@ libwifi_utils_la_SOURCES += ext_blaster.pb-c.c libwifi_utils_la_LDFLAGS = -rdynamic -lwebconfig_framework -lsecure_wrapper $(SYSTEMD_LDFLAGS) -lsecure_wrapper -lmsgpackc -lcjson -lm -ljansson -static -libwifi_utils_la_LDFLAGS += -lccsp_common -lsyscfg -lprint_uptime -lsysevent -lrdk_wifihal +if ONEWIFI_DML_SUPPORT +libwifi_utils_la_LDFLAGS += -lccsp_common +endif +libwifi_utils_la_LDFLAGS += -lsyscfg -lprint_uptime -lsysevent -lrdk_wifihal if !HAL_IPC libwifi_utils_la_LDFLAGS += -lhal_wifi diff --git a/source/utils/wifi_util.c b/source/utils/wifi_util.c index f2012faa..f900dfa0 100644 --- a/source/utils/wifi_util.c +++ b/source/utils/wifi_util.c @@ -4338,3 +4338,40 @@ int update_radio_operating_classes(wifi_radio_operationParam_t *oper) return RETURN_OK; } + +int get_partner_id(char *partner_id) +{ + char buffer[64]; + FILE *file; + char *pos = NULL; + int ret = RETURN_ERR; + + if ((file = popen("syscfg get partner_id", "r")) != NULL) { + pos = fgets(buffer, sizeof(buffer), file); + pclose(file); + } + + if ((pos == NULL) && + ((file = popen("/lib/rdk/getpartner_id.sh Getpartner_id", "r")) != NULL)) { + pos = fgets(buffer, sizeof(buffer), file); + pclose(file); + } + + if (pos) { + size_t len = strlen (pos); + + if ((len > 0) && (pos[len - 1] == '\n')) { + len--; + } + + memcpy(partner_id, pos, len); + partner_id[len] = 0; + + ret = RETURN_OK; + } else { + wifi_util_error_print(WIFI_DMCLI,"%s : Error in opening File\n", __func__); + *partner_id = 0; + } + + return ret; +} diff --git a/source/utils/wifi_util.h b/source/utils/wifi_util.h index bc72e0b7..3314f15f 100644 --- a/source/utils/wifi_util.h +++ b/source/utils/wifi_util.h @@ -391,6 +391,7 @@ int scan_mode_type_conversion(wifi_neighborScanMode_t *scan_mode_enum, char *sca bool is_vap_param_config_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new, rdk_wifi_vap_info_t *rdk_old, rdk_wifi_vap_info_t *rdk_new, bool isSta); int update_radio_operating_classes(wifi_radio_operationParam_t *oper); +int get_partner_id(char *partner_id); #ifdef __cplusplus } #endif diff --git a/source/webconfig/Makefile.am b/source/webconfig/Makefile.am index 922782da..c1c2b25c 100644 --- a/source/webconfig/Makefile.am +++ b/source/webconfig/Makefile.am @@ -44,8 +44,11 @@ if !HAL_IPC AM_LDFLAGS += -lhal_wifi endif +if ONEWIFI_DML_SUPPORT AM_LDFLAGS += -L$(top_builddir)/../CcspCommonLibrary/lib AM_LDFLAGS += -lccsp_common +endif + AM_LDFLAGS += -lrdk_wifihal AM_CPPFLAGS = -Wall -Werror