I have this function is C++:
#include <windows.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <iostream>
#pragma comment(lib, "iphlpapi.lib")
void printInterfaces(){
ULONG buflen = sizeof(IP_ADAPTER_INFO);
IP_ADAPTER_INFO *pAdapterInfo = (IP_ADAPTER_INFO *)malloc(buflen);
if (GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) {
free(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *)malloc(buflen);
}
if (GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) {
for (IP_ADAPTER_INFO *pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) {
if (pAdapter -> IpAddressList.IpAddress.String != "0.0.0.0"){
std::cout << "IP: " <<
pAdapter->IpAddressList.IpAddress.String <<
" Description: " <<
pAdapter-> Description << std::endl;
}
}
}
if (pAdapterInfo) free(pAdapterInfo);
}
I am writing a sniffer with python and I want to get the names of interfaces on windows, so this c++ code prints the IP address and the Description, Is there a way to call this function from python and to make it return the interfaces as a list with tuples? and also I have a problem there when doing != "0.0.0.0"
it runs but doesn't filter the interfaces with ip "0.0.0.0". what is the correct way to do it? Also I am more familiar with C#, Is importing C# is easier then C++?