#include "iface-windows.h"
#include "iface.h"
+#include <stdlib.h> // wcstombs
#include <catta/malloc.h>
#include <catta/log.h>
#include <iphlpapi.h>
{
CattaIfIndex idx;
CattaHwInterface *hw;
+ size_t n;
// look up the interface index by LUID
if((idx = find_ifindex(m, p->Luid)) < 0) {
// fill the CattaHwInterface struct with data
hw->flags_ok =
- (p->OperStatus & IfOperStatusUp) &&
- !(p->IfType & IF_TYPE_SOFTWARE_LOOPBACK) &&
+ (p->OperStatus == IfOperStatusUp) &&
+ !(p->IfType == IF_TYPE_SOFTWARE_LOOPBACK) &&
!(p->Flags & IP_ADAPTER_NO_MULTICAST) &&
- (m->server->config.allow_point_to_point || !(p->IfType & IF_TYPE_PPP));
+ (m->server->config.allow_point_to_point || !(p->IfType == IF_TYPE_PPP));
// XXX what about IF_TYPE_TUNNEL?
+ n = wcstombs(NULL, p->FriendlyName, 0) + 1;
catta_free(hw->name);
- hw->name = catta_strdup(p->AdapterName);
+ hw->name = catta_new(char, n);
+ wcstombs(hw->name, p->FriendlyName, n);
hw->mtu = p->Mtu;
hw->mac_address_size = p->PhysicalAddressLength;
- if (hw->mac_address_size > CATTA_MAC_ADDRESS_MAX)
- hw->mac_address_size = CATTA_MAC_ADDRESS_MAX;
+ if(hw->mac_address_size > CATTA_MAC_ADDRESS_MAX)
+ hw->mac_address_size = CATTA_MAC_ADDRESS_MAX;
memcpy(hw->mac_address, p->PhysicalAddress, hw->mac_address_size);
// XXX process addresses
// XXX debugging, remove
{
char mac[256];
- catta_log_debug("======\n name: %s\n index:%d\n mtu:%d\n mac:%s\n flags_ok:%d\n======",
+ catta_log_debug("======\n name: %s\n index:%d\n mtu:%d\n mac:%s\n type:%u\n status:%u\n multicast:%d\n flags:0x%.4x\n flags_ok:%d\n======",
hw->name, hw->index,
hw->mtu,
catta_format_mac_address(mac, sizeof(mac), hw->mac_address, hw->mac_address_size),
- hw->flags_ok);
+ (unsigned int)p->IfType,
+ (unsigned int)p->OperStatus,
+ !(p->Flags & IP_ADAPTER_NO_MULTICAST),
+ (unsigned int)p->Flags,
+ hw->flags_ok);
}
}