mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 15:19:53 -06:00
list adapters, display their info
This commit is contained in:
@ -25,6 +25,7 @@
|
|||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "../Config.h"
|
#include "../Config.h"
|
||||||
|
|
||||||
|
#include "LAN.h"
|
||||||
#include "DlgWifiSettings.h"
|
#include "DlgWifiSettings.h"
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +40,43 @@ uiWindow* win;
|
|||||||
|
|
||||||
uiCheckbox* cbBindAnyAddr;
|
uiCheckbox* cbBindAnyAddr;
|
||||||
|
|
||||||
|
uiCombobox* cmAdapterList;
|
||||||
|
uiCheckbox* cbDirectLAN;
|
||||||
|
|
||||||
|
uiLabel* lbAdapterMAC;
|
||||||
|
uiLabel* lbAdapterIP;
|
||||||
|
uiLabel* lbAdapterDNS0;
|
||||||
|
uiLabel* lbAdapterDNS1;
|
||||||
|
|
||||||
|
|
||||||
|
void UpdateAdapterInfo()
|
||||||
|
{
|
||||||
|
int sel = uiComboboxSelected(cmAdapterList);
|
||||||
|
if (sel < 0 || sel >= LAN::NumAdapters) return;
|
||||||
|
|
||||||
|
LAN::AdapterData* adapter = &LAN::Adapters[sel];
|
||||||
|
char tmp[64];
|
||||||
|
|
||||||
|
sprintf(tmp, "MAC: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||||
|
adapter->MAC[0], adapter->MAC[1], adapter->MAC[2],
|
||||||
|
adapter->MAC[3], adapter->MAC[4], adapter->MAC[5]);
|
||||||
|
uiLabelSetText(lbAdapterMAC, tmp);
|
||||||
|
|
||||||
|
sprintf(tmp, "IP: %d.%d.%d.%d",
|
||||||
|
adapter->IP_v4[0], adapter->IP_v4[1],
|
||||||
|
adapter->IP_v4[2], adapter->IP_v4[3]);
|
||||||
|
uiLabelSetText(lbAdapterIP, tmp);
|
||||||
|
|
||||||
|
sprintf(tmp, "Primary DNS: %d.%d.%d.%d",
|
||||||
|
adapter->DNS[0][0], adapter->DNS[0][1],
|
||||||
|
adapter->DNS[0][2], adapter->DNS[0][3]);
|
||||||
|
uiLabelSetText(lbAdapterDNS0, tmp);
|
||||||
|
|
||||||
|
sprintf(tmp, "Secondary DNS: %d.%d.%d.%d",
|
||||||
|
adapter->DNS[1][0], adapter->DNS[1][1],
|
||||||
|
adapter->DNS[1][2], adapter->DNS[1][3]);
|
||||||
|
uiLabelSetText(lbAdapterDNS1, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
int OnCloseWindow(uiWindow* window, void* blarg)
|
int OnCloseWindow(uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
@ -46,6 +84,11 @@ int OnCloseWindow(uiWindow* window, void* blarg)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnAdapterSelect(uiCombobox* c, void* blarg)
|
||||||
|
{
|
||||||
|
UpdateAdapterInfo();
|
||||||
|
}
|
||||||
|
|
||||||
void OnCancel(uiButton* btn, void* blarg)
|
void OnCancel(uiButton* btn, void* blarg)
|
||||||
{
|
{
|
||||||
uiControlDestroy(uiControl(win));
|
uiControlDestroy(uiControl(win));
|
||||||
@ -72,6 +115,8 @@ void Open()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LAN::Init();
|
||||||
|
|
||||||
opened = true;
|
opened = true;
|
||||||
win = uiNewWindow("Wifi settings - melonDS", 400, 100, 0, 0, 0);
|
win = uiNewWindow("Wifi settings - melonDS", 400, 100, 0, 0, 0);
|
||||||
uiWindowSetMargined(win, 1);
|
uiWindowSetMargined(win, 1);
|
||||||
@ -94,6 +139,8 @@ void Open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
uiLabel* lbl;
|
||||||
|
|
||||||
uiGroup* grp = uiNewGroup("Online");
|
uiGroup* grp = uiNewGroup("Online");
|
||||||
uiBoxAppend(top, uiControl(grp), 0);
|
uiBoxAppend(top, uiControl(grp), 0);
|
||||||
uiGroupSetMargined(grp, 1);
|
uiGroupSetMargined(grp, 1);
|
||||||
@ -101,8 +148,24 @@ void Open()
|
|||||||
uiBox* in_ctrl = uiNewVerticalBox();
|
uiBox* in_ctrl = uiNewVerticalBox();
|
||||||
uiGroupSetChild(grp, uiControl(in_ctrl));
|
uiGroupSetChild(grp, uiControl(in_ctrl));
|
||||||
|
|
||||||
uiLabel* dorp = uiNewLabel("placeholder");
|
lbl = uiNewLabel("Network adapter:");
|
||||||
uiBoxAppend(in_ctrl, uiControl(dorp), 0);
|
uiBoxAppend(in_ctrl, uiControl(lbl), 0);
|
||||||
|
|
||||||
|
cmAdapterList = uiNewCombobox();
|
||||||
|
uiComboboxOnSelected(cmAdapterList, OnAdapterSelect, NULL);
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(cmAdapterList), 0);
|
||||||
|
|
||||||
|
lbAdapterMAC = uiNewLabel("MAC");
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterMAC), 0);
|
||||||
|
lbAdapterIP = uiNewLabel("IP");
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterIP), 0);
|
||||||
|
lbAdapterDNS0 = uiNewLabel("DNS0");
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterDNS0), 0);
|
||||||
|
lbAdapterDNS1 = uiNewLabel("DNS1");
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(lbAdapterDNS1), 0);
|
||||||
|
|
||||||
|
cbDirectLAN = uiNewCheckbox("Direct mode (requires ethernet connection)");
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(cbDirectLAN), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -124,6 +187,17 @@ void Open()
|
|||||||
|
|
||||||
uiCheckboxSetChecked(cbBindAnyAddr, Config::SocketBindAnyAddr);
|
uiCheckboxSetChecked(cbBindAnyAddr, Config::SocketBindAnyAddr);
|
||||||
|
|
||||||
|
int sel = 0;
|
||||||
|
for (int i = 0; i < LAN::NumAdapters; i++)
|
||||||
|
{
|
||||||
|
LAN::AdapterData* adapter = &LAN::Adapters[i];
|
||||||
|
|
||||||
|
uiComboboxAppend(cmAdapterList, adapter->FriendlyName);
|
||||||
|
}
|
||||||
|
// TODO: select the right one!
|
||||||
|
uiComboboxSetSelected(cmAdapterList, sel);
|
||||||
|
UpdateAdapterInfo();
|
||||||
|
|
||||||
uiControlShow(uiControl(win));
|
uiControlShow(uiControl(win));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,9 @@ bool TryLoadPCap(void* lib)
|
|||||||
|
|
||||||
bool Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
|
// TODO: how to deal with cases where an adapter is unplugged or changes config??
|
||||||
|
if (PCapLib) return true;
|
||||||
|
|
||||||
PCapLib = NULL;
|
PCapLib = NULL;
|
||||||
PCapAdapter = NULL;
|
PCapAdapter = NULL;
|
||||||
PCapPacketLen = 0;
|
PCapPacketLen = 0;
|
||||||
|
@ -38,6 +38,10 @@ typedef struct
|
|||||||
} AdapterData;
|
} AdapterData;
|
||||||
|
|
||||||
|
|
||||||
|
extern AdapterData* Adapters;
|
||||||
|
extern int NumAdapters;
|
||||||
|
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
void DeInit();
|
void DeInit();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user