-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support using the device MAC address #3
Comments
Why not use |
I am hesitant to add platform-specific functionality to this tool. I think there are many Linux-specific tools, e.g.: https://github.com/saravana815/dhtest |
I would love to something added such as --clientmac that would allow using the client mac without having to look it up first on windows or remember that string on linux. Having a random mac is great for some networks but others that are slightly locked down using the clients is a lot more reliable. |
dhtest and other linux-specific tools are also great tools on testing DHCP functionality. However, dhcptest is more handy becuase it dumps all DHCP options. I may try to implement the Windows corresponding part if I have time. After all, still many thanks to the information! |
Here is some Windows code: struct NetworkInterface
{
string name;
ubyte[] mac;
string[] ips;
}
NetworkInterface[] getInterfaces()
{
version (Windows)
{
// For this functionality, the Windows bindings are required:
// $ git clone https://github.com/CS-svnmirror/dsource-bindings-win32 win32
version(HAVE_WIN32)
{
import win32.windef;
import win32.iphlpapi;
import win32.iptypes;
import std.windows.syserror;
DWORD dwBufLen = 0;
GetAdaptersInfo(null, &dwBufLen);
PIP_ADAPTER_INFO adapterInfo = cast(PIP_ADAPTER_INFO)new ubyte[dwBufLen];
GetAdaptersInfo(adapterInfo, &dwBufLen).wenforce("GetAdaptersInfo");
NetworkInterface[] result;
for (; adapterInfo; adapterInfo = adapterInfo.Next)
{
NetworkInterface iface;
iface.name = adapterInfo.AdapterName.to!string();
iface.mac = adapterInfo.Address[0..adapterInfo.AddressLength];
for (auto addr = &adapterInfo.IpAddressList; addr; addr = addr.Next)
iface.ips ~= addr.IpAddress.String.to!string();
}
return result;
}
}
version (linux)
{
// ...
}
assert(false, "This functionality is not available in this version or on this platform");
} Windows interface names are long and don't make much sense, so it would be good to also allow using the interface IP address, using the same syntax. |
I would like to use device MAC address in the --mac option. For example, on Linux, a possible usage may be:
I have an implementation at https://github.com/yan12125/dhcptest, however, I'm not familiar with D and the implementation is naive. Could you add the support?
The text was updated successfully, but these errors were encountered: