Skip to content

Commit

Permalink
Added GetDesiredPhyList() function to WlanHelper.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed May 13, 2016
1 parent 4021abc commit b1cafbf
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 19 deletions.
70 changes: 53 additions & 17 deletions packetWin7/WlanHelper/WlanHelper/Tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
vector<tstring> g_strAdapterNames;
vector<tstring> g_strAdapterGUIDs;

vector<tstring> g_nstrPhyTypes;

tstring OperationMode2String(ULONG OperationMode)
{
if (OperationMode == DOT11_OPERATION_MODE_EXTENSIBLE_AP)
Expand Down Expand Up @@ -178,6 +180,14 @@ wstring ANSIToUnicode(const string& str)
return rt;
}

tstring itos(int i)
{
char buf[256];
_itoa_s(i, buf, 10);
tstring res = buf;
return res;
}

tstring executeCommand(TCHAR* cmd)
{
TCHAR buffer[128];
Expand Down Expand Up @@ -399,23 +409,6 @@ BOOL GetOperationModeCapability(tstring strGUID, tstring &strModes)
return bResult;
}

BOOL GetSupportedPhyTypes(tstring strGUID, vector<tstring> &nstrPhyTypes)
{
BOOL bResult;
DOT11_SUPPORTED_PHY_TYPES SupportedPhyTypes;

bResult = makeOIDRequest(strGUID, OID_DOT11_SUPPORTED_PHY_TYPES, FALSE, &SupportedPhyTypes, sizeof(DOT11_SUPPORTED_PHY_TYPES));
if (bResult)
{
for (size_t i = 0; i < SupportedPhyTypes.uNumOfEntries; i++)
{
nstrPhyTypes.push_back(PhyType2String(SupportedPhyTypes.dot11PHYType[i]));
}
}

return bResult;
}

BOOL GetCurrentChannel(tstring strGUID, ULONG &ulChannel)
{
BOOL bResult;
Expand Down Expand Up @@ -471,3 +464,46 @@ BOOL SetCurrentFrequency(tstring strGUID, ULONG ulFrequency)
bResult = makeOIDRequest(strGUID, OID_DOT11_CURRENT_FREQUENCY, TRUE, &CurrentFrequency, sizeof(ULONG));
return bResult;
}

BOOL GetSupportedPhyTypes(tstring strGUID, vector<tstring> &nstrPhyTypes)
{
BOOL bResult;
DOT11_SUPPORTED_PHY_TYPES SupportedPhyTypes;

bResult = makeOIDRequest(strGUID, OID_DOT11_SUPPORTED_PHY_TYPES, FALSE, &SupportedPhyTypes, sizeof(DOT11_SUPPORTED_PHY_TYPES));
if (bResult)
{
nstrPhyTypes.clear();
for (size_t i = 0; i < SupportedPhyTypes.uNumOfEntries; i++)
{
nstrPhyTypes.push_back(PhyType2String(SupportedPhyTypes.dot11PHYType[i]));
}
}

g_nstrPhyTypes = nstrPhyTypes;
return bResult;
}

BOOL GetDesiredPhyList(tstring strGUID, vector<tstring> &nstrPhyList)
{
BOOL bResult;
DOT11_PHY_ID_LIST DesiredPhyList;

if (g_nstrPhyTypes.size() == 0)
{
GetSupportedPhyTypes(strGUID, g_nstrPhyTypes);
}

bResult = makeOIDRequest(strGUID, OID_DOT11_DESIRED_PHY_LIST, FALSE, &DesiredPhyList, sizeof(DOT11_PHY_ID_LIST));
if (bResult)
{
nstrPhyList.clear();
for (size_t i = 0; i < DesiredPhyList.uNumOfEntries; i++)
{

nstrPhyList.push_back(itos(DesiredPhyList.dot11PhyId[i]));
}
}

return bResult;
}
7 changes: 5 additions & 2 deletions packetWin7/WlanHelper/WlanHelper/Tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ tstring PhyType2String(ULONG PhyType);

tstring printArray(vector<tstring> nstr);

tstring itos(int i);

tstring executeCommand(TCHAR* cmd);

void initAdapterList();
Expand All @@ -26,10 +28,11 @@ BOOL SetCurrentOperationMode(tstring strGUID, tstring strMode);

BOOL GetOperationModeCapability(tstring strGUID, tstring &strModes);

BOOL GetSupportedPhyTypes(tstring strGUID, vector<tstring> &strPhyTypes);

BOOL GetCurrentChannel(tstring strGUID, ULONG &ulChannel);
BOOL SetCurrentChannel(tstring strGUID, ULONG ulChannel);

BOOL GetCurrentFrequency(tstring strGUID, ULONG &ulFrequency);
BOOL SetCurrentFrequency(tstring strGUID, ULONG ulFrequency);

BOOL GetSupportedPhyTypes(tstring strGUID, vector<tstring> &strPhyTypes);
BOOL GetDesiredPhyList(tstring strGUID, vector<tstring> &nstrPhyList);
14 changes: 14 additions & 0 deletions packetWin7/WlanHelper/WlanHelper/WlanHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,20 @@ int _tmain(int argc, _TCHAR* argv[])
return -1;
}
}
else if (strArgs[2] == _T("modus2"))
{
vector<tstring> nstrPhyList;
if (GetDesiredPhyList(getGuidFromAdapterName_Wrapper(strArgs[1]), nstrPhyList))
{
_tprintf("%s\n", printArray(nstrPhyList).c_str());
return 0;
}
else
{
_tprintf(_T("Failure\n"));
return -1;
}
}
else
{
_tprintf(STR_INVALID_PARAMETER);
Expand Down

0 comments on commit b1cafbf

Please sign in to comment.