Network Provider Filter Implemetation (#153)

This commit is contained in:
Saroj Kumar Patra 2019-06-25 17:53:30 +05:30 коммит произвёл GitHub
Родитель af73adfdb8
Коммит 980cd6122c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 48 добавлений и 7 удалений

Просмотреть файл

@ -23,7 +23,10 @@
#include "support/networkprovider.h"
#include "support/scxcimutils.h"
#include <sstream>
#include <scxcorelib/scxregex.h>
#include <scxcorelib/scxpatternfinder.h>
# define QLENGTH 1000
using namespace SCXSystemLib;
using namespace SCXCoreLib;
using namespace SCXCore;
@ -122,10 +125,45 @@ void SCX_LANEndpoint_Class_Provider::EnumerateInstances(
// Global lock for NetworkProvider class
SCXCoreLib::SCXThreadLock lock(SCXCoreLib::ThreadLockHandleGet(L"SCXCore::NetworkProvider::Lock"));
// Update network PAL instance. This is both update of number of interfaces and
// current statistics for each interfaces.
// Update network PAL instance. If filter parameter provided then "interfaceString" will be not blank.
// If "interfaceString" is blank this will update both number of interfaces and returns current statistics for
// each interfaces else update the instance for the interface given as parameter and return statistics of that interface.
SCXHandle<SCXCore::NetworkProviderDependencies> deps = SCXCore::g_NetworkProvider.getDependencies();
deps->UpdateIntf(false);
wstring interfaceString=L"";
if(filter) {
char* exprStr[QLENGTH]={'\0'};
char* qtypeStr[QLENGTH]={'\0'};
const MI_Char** expr=(const MI_Char**)&exprStr;
const MI_Char** qtype=(const MI_Char**)&qtypeStr;
MI_Filter_GetExpression(filter, qtype, expr);
SCX_LOGTRACE(log, SCXCoreLib::StrAppend(L"LANEndpoint Provider Filter Set with Expression: ",*expr));
std::wstring filterQuery(SCXCoreLib::StrFromUTF8(*expr));
SCXCoreLib::SCXPatternFinder::SCXPatternCookie s_patternID = 0, id=0;
SCXCoreLib::SCXPatternFinder::SCXPatternMatch param;
std::wstring s_pattern(L"select * from SCX_LANEndpoint where Name=%name");
SCXCoreLib::SCXPatternFinder patterenfinder;
patterenfinder.RegisterPattern(s_patternID, s_pattern);
bool status=patterenfinder.Match(filterQuery, id, param);
if ( !status )
throw SCXNotSupportedException(L"LANEndPoint Provider Query not on format: " + s_pattern, SCXSRCLOCATION);
if (id != s_patternID || param.end() == param.find(L"name"))
throw SCXInternalErrorException(L"Wrong pattern matched!", SCXSRCLOCATION);
interfaceString=param.find(L"name")->second;
SCX_LOGTRACE(log, SCXCoreLib::StrAppend(L"LANEndpoint Provider Enum Requested for Interface: ",interfaceString));
}
deps->UpdateIntf(false,interfaceString);
SCX_LOGTRACE(log, StrAppend(L"Number of interfaces = ", deps->IntfCount()));

Просмотреть файл

@ -46,9 +46,12 @@ void SCXCore::NetworkProviderDependencies::CleanUpIntf()
* Update interfaces`
* \param[in] updateInstances Update existing instances only
*/
void SCXCore::NetworkProviderDependencies::UpdateIntf(bool updateInstances)
void SCXCore::NetworkProviderDependencies::UpdateIntf(bool updateInstances, wstring interface)
{
m_interfaces->Update(updateInstances);
if(interface != L"")
m_interfaces->UpdateSpecific(interface);
else
m_interfaces->Update(updateInstances);
}
/*----------------------------------------------------b------------------------*/

Просмотреть файл

@ -33,7 +33,7 @@ namespace SCXCore
NetworkProviderDependencies() : m_interfaces(0) {}
virtual void InitIntf();
virtual void CleanUpIntf();
virtual void UpdateIntf(bool updateInstances=true);
virtual void UpdateIntf(bool updateInstances=true,wstring interface=L"");
virtual size_t IntfCount() const;
virtual SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> GetIntf(size_t pos) const;
virtual SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> GetIntf(const std::wstring& intfId) const;

Просмотреть файл

@ -36,7 +36,7 @@ public:
void CleanUpIntf() {
}
void UpdateIntf(bool) {
void UpdateIntf(bool,wstring interface=L"") {
}
size_t IntfCount() const {