Skip to content

Commit

Permalink
Adding NetworkManager plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Gururaaja E S R authored and Gururaaja E S R committed Mar 27, 2024
1 parent eae6e79 commit 72c2cd7
Show file tree
Hide file tree
Showing 35 changed files with 10,101 additions and 0 deletions.
25 changes: 25 additions & 0 deletions NetworkManager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.3)

project(NetworkManager)
find_package(WPEFramework)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)

add_compile_definitions(NETWORKMANAGER_MAJOR_VERSION=${VERSION_MAJOR})
add_compile_definitions(NETWORKMANAGER_MINOR_VERSION=${VERSION_MINOR})
add_compile_definitions(NETWORKMANAGER_PATCH_VERSION=${VERSION_PATCH})

set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})


include(CmakeHelperFunctions)

string(TOLOWER ${NAMESPACE} STORAGE_DIRECTORY)
get_directory_property(SEVICES_DEFINES COMPILE_DEFINITIONS)

add_subdirectory(interface)
add_subdirectory(service)

1 change: 1 addition & 0 deletions NetworkManager/cmake
48 changes: 48 additions & 0 deletions NetworkManager/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
project(NetworkManagerInterface)
find_package(WPEFramework REQUIRED)
find_package(${NAMESPACE}Core REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)
find_package(ProxyStubGenerator REQUIRED)

set(ProxyStubGenerator_DIR ${CMAKE_SYSROOT}${CMAKE_INSTALL_PREFIX}/tools/cmake ${ProxyStubGenerator_DIR})

if(NOT GENERATOR_SEARCH_PATH)
set(GENERATOR_SEARCH_PATH ${CMAKE_SYSROOT}${CMAKE_INSTALL_PREFIX}/include/${NAMESPACE})
endif()

ProxyStubGenerator(INPUT "${CMAKE_CURRENT_SOURCE_DIR}" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated" INCLUDE_PATH ${GENERATOR_SEARCH_PATH})

file(GLOB INTERFACES_HEADERS I*.h)
list(APPEND INTERFACES_HEADERS Module.h)

file(GLOB PROXY_STUB_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/generated/ProxyStubs*.cpp")

set(TARGET ${NAMESPACE}NetworkManagerInterface)
string(TOLOWER ${NAMESPACE} NAMESPACE_LIB)

add_library(${TARGET} SHARED ${PROXY_STUB_SOURCES} Module.cpp)

target_include_directories( ${TARGET} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_link_libraries(${TARGET} PRIVATE ${NAMESPACE}Core::${NAMESPACE}Core)
target_link_libraries(${TARGET} PRIVATE CompileSettingsDebug::CompileSettingsDebug)

set_target_properties(${TargetMarshalling} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
FRAMEWORK FALSE
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)

install(
TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies
ARCHIVE DESTINATION lib/${NAMESPACE_LIB}/proxystubs COMPONENT libs # static lib
LIBRARY DESTINATION lib/${NAMESPACE_LIB}/proxystubs COMPONENT libs # shared lib
RUNTIME DESTINATION bin COMPONENT libs # binaries
FRAMEWORK DESTINATION bin/${NAMESPACE_LIB}/proxystubs COMPONENT libs # for mac
PUBLIC_HEADER DESTINATION include/${NAMESPACE}/proxystubs COMPONENT devel # headers for mac (note the different component -> different package)
INCLUDES DESTINATION include/${NAMESPACE}/proxystubs # headers
)

InstallCMakeConfig(TARGETS ${TARGET})
296 changes: 296 additions & 0 deletions NetworkManager/interface/INetworkManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2023 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#pragma once
#include "Module.h"

// @stubgen:include <com/IIteratorType.h>

namespace WPEFramework
{
namespace Exchange
{
enum myNetwork_ids {
ID_NETWORKMANAGER = 0x800004E0,
ID_NETWORKMANAGER_NOTIFICATION = ID_NETWORKMANAGER + 1,
ID_NETWORKMANAGER_INTERFACE_DETAILS_ITERATOR = ID_NETWORKMANAGER + 2,
ID_NETWORKMANAGER_WIFI_SECURITY_MODE_ITERATOR = ID_NETWORKMANAGER + 3
};

/* @json */
struct EXTERNAL INetworkManager: virtual public Core::IUnknown
{
// All interfaces require a unique ID, defined in Ids.h
enum { ID = ID_NETWORKMANAGER };

// Define the RPC methods
enum InterfaceType : uint8_t
{
INTERFACE_TYPE_ETHERNET,
INTERFACE_TYPE_WIFI,
INTERFACE_TYPE_P2P,
};

struct EXTERNAL InterfaceDetails {
string m_type;
string m_name;
string m_mac;
bool m_isEnabled;
bool m_isConnected;
};

enum IPAddressType : uint8_t
{
IP_ADDRESS_V4,
IP_ADDRESS_V6,
IP_ADDRESS_BOTH
};

struct EXTERNAL IPAddressInfo {
string m_ipAddrType;
bool m_autoConfig;
string m_dhcpServer;
string m_v6LinkLocal;
string m_ipAddress;
uint32_t m_prefix;
string m_gateway;
string m_primaryDns;
string m_secondaryDns;
};

// Define the RPC methods
enum InternetStatus : uint8_t
{
INTERNET_NOT_AVAILABLE,
INTERNET_LIMITED,
INTERNET_CAPTIVE_PORTAL,
INTERNET_FULLY_CONNECTED,
INTERNET_UNKNOWN,
};

enum WiFiFrequency : uint8_t
{
WIFI_FREQUENCY_WHATEVER,
WIFI_FREQUENCY_2_4_GHZ,
WIFI_FREQUENCY_5_GHZ,
WIFI_FREQUENCY_6_GHZ
};

enum WiFiWPS : uint8_t
{
WIFI_WPS_PBC,
WIFI_WPS_PIN,
WIFI_WPS_SERIALIZED_PIN
};

enum WIFISecurityMode : uint8_t
{
WIFI_SECURITY_NONE,
WIFI_SECURITY_WEP_64,
WIFI_SECURITY_WEP_128,
WIFI_SECURITY_WPA_PSK_TKIP,
WIFI_SECURITY_WPA_PSK_AES,
WIFI_SECURITY_WPA2_PSK_TKIP,
WIFI_SECURITY_WPA2_PSK_AES,
WIFI_SECURITY_WPA_ENTERPRISE_TKIP,
WIFI_SECURITY_WPA_ENTERPRISE_AES,
WIFI_SECURITY_WPA2_ENTERPRISE_TKIP,
WIFI_SECURITY_WPA2_ENTERPRISE_AES,
WIFI_SECURITY_WPA_WPA2_PSK,
WIFI_SECURITY_WPA_WPA2_ENTERPRISE,
WIFI_SECURITY_WPA3_PSK_AES,
WIFI_SECURITY_WPA3_SAE
};

struct EXTERNAL WiFiScanResults {
string m_ssid;
WIFISecurityMode m_securityMode;
string m_signalStrength;
WiFiFrequency m_frequency;
};

struct EXTERNAL WiFiConnectTo {
string m_ssid;
string m_passphrase;
WIFISecurityMode m_securityMode;
};

struct EXTERNAL WiFiSSIDInfo {
string m_ssid;
string m_bssid;
WIFISecurityMode m_securityMode;
string m_signalStrength;
WiFiFrequency m_frequency;
string m_rate;
string m_noise;
};

struct EXTERNAL WIFISecurityModeInfo {
WIFISecurityMode m_securityMode;
string m_securityModeText;
};

enum WiFiSignalQuality : uint8_t
{
WIFI_SIGNAL_DISCONNECTED,
WIFI_SIGNAL_WEAK,
WIFI_SIGNAL_FAIR,
WIFI_SIGNAL_GOOD,
WIFI_SIGNAL_EXCELLENT
};

enum NMLogging : uint8_t
{
LOG_LEVEL_FATAL,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_VERBOSE,
LOG_LEVEL_TRACE
};

// The state of the interface
enum InterfaceState : uint8_t
{
INTERFACE_ADDED,
INTERFACE_LINK_UP,
INTERFACE_LINK_DOWN,
INTERFACE_ACQUIRING_IP,
INTERFACE_REMOVED,
INTERFACE_DISABLED
};

enum WiFiState : uint8_t
{
WIFI_STATE_UNINSTALLED,
WIFI_STATE_DISABLED,
WIFI_STATE_DISCONNECTED,
WIFI_STATE_PAIRING,
WIFI_STATE_CONNECTING,
WIFI_STATE_CONNECTED,
WIFI_STATE_SSID_NOT_FOUND,
WIFI_STATE_SSID_CHANGED,
WIFI_STATE_CONNECTION_LOST,
WIFI_STATE_CONNECTION_FAILED,
WIFI_STATE_CONNECTION_INTERRUPTED,
WIFI_STATE_INVALID_CREDENTIALS,
WIFI_STATE_AUTHENTICATION_FAILED,
WIFI_STATE_ERROR
};

using IInterfaceDetailsIterator = RPC::IIteratorType<InterfaceDetails, ID_NETWORKMANAGER_INTERFACE_DETAILS_ITERATOR>;
using ISecurityModeIterator = RPC::IIteratorType<WIFISecurityModeInfo, ID_NETWORKMANAGER_WIFI_SECURITY_MODE_ITERATOR>;
using IStringIterator = RPC::IIteratorType<string, RPC::ID_STRINGITERATOR>;

/* @brief Get all the Available Interfaces */
virtual uint32_t GetAvailableInterfaces (IInterfaceDetailsIterator*& interfaces/* @out */) = 0;

/* @brief Get the Primary Interface used for external world communication */
virtual uint32_t GetPrimaryInterface (string& interface /* @out */) = 0;
/* @brief Set the Primary Interface used for external world communication */
virtual uint32_t SetPrimaryInterface (const string& interface/* @in */) = 0;

/* @brief Enable the active Interface used for external world communication */
virtual uint32_t EnableInterface (const string& interface/* @in */) = 0;
/* @brief Disable the Interface passed */
virtual uint32_t DisableInterface (const string& interface/* @in */) = 0;

/* @brief Get IP Address Of the Interface */
virtual uint32_t GetIPSettings(const string& interface /* @in */, const string &ipversion /* @in */, IPAddressInfo& result /* @out */) = 0;
/* @brief Set IP Address Of the Interface */
virtual uint32_t SetIPSettings(const string& interface /* @in */, const string &ipversion /* @in */, const IPAddressInfo& address /* @in */) = 0;

/* @brief Get STUN Endpoint to be used for identifying Public IP */
virtual uint32_t GetStunEndpoint (string &endPoint /* @out */, uint32_t &port /* @out */, uint32_t &bindTimeout /* @out */, uint32_t &cacheTimeout /* @out */) const = 0;
/* @brief Set STUN Endpoint to be used to identify Public IP */
virtual uint32_t SetStunEndpoint (string const endPoint /* @in */, const uint32_t port /* @in */, const uint32_t bindTimeout /* @in */, const uint32_t cacheTimeout /* @in */) = 0;

/* @brief Get ConnectivityTest Endpoints */
virtual uint32_t GetConnectivityTestEndpoints(IStringIterator*& endPoints/* @out */) const = 0;
/* @brief Set ConnectivityTest Endpoints */
virtual uint32_t SetConnectivityTestEndpoints(IStringIterator* const endPoints /* @in */) = 0;

/* @brief Get Internet Connectivty Status */
virtual uint32_t IsConnectedToInternet(const string &ipversion /* @in */, InternetStatus &result /* @out */) = 0;
/* @brief Get Authentication URL if the device is behind Captive Portal */
virtual uint32_t GetCaptivePortalURI(string &endPoints/* @out */) const = 0;

/* @brief Start The Internet Connectivity Monitoring */
virtual uint32_t StartConnectivityMonitoring(const uint32_t interval /* @in */) = 0;
/* @brief Stop The Internet Connectivity Monitoring */
virtual uint32_t StopConnectivityMonitoring(void) const = 0;

/* @brief Get the Public IP used for external world communication */
virtual uint32_t GetPublicIP (const string &ipversion /* @in */, string& ipAddress /* @out */) = 0;

/* @brief Request for ping and get the response in as event. The GUID used in the request will be returned in the event. */
virtual uint32_t Ping (const string ipversion /* @in */, const string endpoint /* @in */, const uint32_t noOfRequest /* @in */, const uint16_t timeOutInSeconds /* @in */, const string guid /* @in */, string& response /* @out */) = 0;

/* @brief Request for trace get the response in as event. The GUID used in the request will be returned in the event. */
virtual uint32_t Trace (const string ipversion /* @in */, const string endpoint /* @in */, const uint32_t noOfRequest /* @in */, const string guid /* @in */, string& response /* @out */) = 0;


// WiFi Specific Methods
/* @brief Initiate a WIFI Scan; This is Async method and returns the scan results as Event */
virtual uint32_t StartWiFiScan(const WiFiFrequency frequency /* @in */) = 0;
virtual uint32_t StopWiFiScan(void) = 0;

virtual uint32_t GetKnownSSIDs(IStringIterator*& ssids /* @out */) = 0;
virtual uint32_t AddToKnownSSIDs(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t RemoveKnownSSID(const string& ssid /* @in */) = 0;

virtual uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t WiFiDisconnect(void) = 0;
virtual uint32_t GetConnectedSSID(WiFiSSIDInfo& ssidInfo /* @out */) = 0;

virtual uint32_t StartWPS(const WiFiWPS& method /* @in */, const string& wps_pin /* @in */) = 0;
virtual uint32_t StopWPS(void) = 0;
virtual uint32_t GetWifiState(WiFiState &state /* @out */) = 0;
virtual uint32_t GetWiFiSignalStrength(string& ssid /* @out */, string& signalStrength /* @out */, WiFiSignalQuality& quality /* @out */) = 0;
virtual uint32_t GetSupportedSecurityModes(ISecurityModeIterator*& securityModes /* @out */) const = 0;

/* @brief Set the network manager plugin log level */
virtual uint32_t SetLogLevel(const NMLogging& logLevel /* @in */) = 0;

/* @brief configure network manager plugin */
virtual uint32_t Configure(const string& configLine /* @in */, NMLogging& logLevel /* @out */) = 0;

/* @event */
struct EXTERNAL INotification : virtual public Core::IUnknown
{
enum { ID = ID_NETWORKMANAGER_NOTIFICATION };

// Network Notifications that other processes can subscribe to
virtual void onInterfaceStateChange(const InterfaceState event /* @in */, const string interface /* @in */) = 0;
virtual void onActiveInterfaceChange(const string prevActiveInterface /* @in */, const string currentActiveinterface /* @in */) = 0;
virtual void onIPAddressChange(const string interface /* @in */, const bool isAcquired /* @in */, const bool isIPv6 /* @in */, const string ipAddress /* @in */) = 0;
virtual void onInternetStatusChange(const InternetStatus oldState /* @in */, const InternetStatus newstate /* @in */) = 0;

// WiFi Notifications that other processes can subscribe to
virtual void onAvailableSSIDs(const string jsonOfWiFiScanResults /* @in */) = 0;
virtual void onWiFiStateChange(const WiFiState state /* @in */) = 0;
virtual void onWiFiSignalStrengthChange(const string ssid /* @in */, const string signalLevel /* @in */, const WiFiSignalQuality signalQuality /* @in */) = 0;
};

// Allow other processes to register/unregister from our notifications
virtual uint32_t Register(INetworkManager::INotification* notification) = 0;
virtual uint32_t Unregister(INetworkManager::INotification* notification) = 0;
};
}
}
3 changes: 3 additions & 0 deletions NetworkManager/interface/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "Module.h"

MODULE_NAME_DECLARATION(BUILD_REFERENCE)
8 changes: 8 additions & 0 deletions NetworkManager/interface/Module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#ifndef MODULE_NAME
#define MODULE_NAME INetworkManager
#endif

#include <core/core.h>
#include <com/com.h>
Loading

0 comments on commit 72c2cd7

Please sign in to comment.