mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 17:59:04 +00:00
eth_get_pcap_devname as a wrapper. In addition to the hardware address check, add a check of the textual interface descriptions in order better to distinguish interfaces. It appears to me that the pcap description (pdev->description) is the same as what is returned by a call to PacketRequest with an OID of OID_GEN_FRIENDLY_NAME, so that's what I'm comparing. That differs from OID_GEN_VENDOR_NAME, which is what you get in ifrow.bDescr from GetIfTable. We've found that simply comparing hardware addresses is not enough when using Windows "teamed" (link-aggregated) interfaces. In a simple example, two NICs are teamed together, leading to three interfaces visible to libdnet: the two physical NICs and the virtual teamed interface. All three of these have the same MAC address. What was happening was the eth0 interface was being assigned to one of the physical NICs, packets were sent over it, but the replies were not necessarily coming back to the same physical NIC.
70 lines
2.2 KiB
C
70 lines
2.2 KiB
C
/*
|
|
* intf.c
|
|
*
|
|
* Network interface operations.
|
|
*
|
|
* Copyright (c) 2000 Dug Song <dugsong@monkey.org>
|
|
*
|
|
* $Id: intf.h 478 2004-01-13 07:41:09Z dugsong $
|
|
*/
|
|
|
|
#ifndef DNET_INTF_H
|
|
#define DNET_INTF_H
|
|
|
|
/*
|
|
* Interface entry
|
|
*/
|
|
#define INTF_NAME_LEN 16
|
|
|
|
struct intf_entry {
|
|
u_int intf_len; /* length of entry */
|
|
char intf_name[INTF_NAME_LEN]; /* interface name */
|
|
u_short intf_type; /* interface type (r/o) */
|
|
u_short intf_flags; /* interface flags */
|
|
u_int intf_mtu; /* interface MTU */
|
|
struct addr intf_addr; /* interface address */
|
|
struct addr intf_dst_addr; /* point-to-point dst */
|
|
struct addr intf_link_addr; /* link-layer address */
|
|
u_int intf_alias_num; /* number of aliases */
|
|
struct addr intf_alias_addrs __flexarr; /* array of aliases */
|
|
};
|
|
|
|
/*
|
|
* MIB-II interface types - http://www.iana.org/assignments/ianaiftype-mib
|
|
*/
|
|
#define INTF_TYPE_OTHER 1 /* other */
|
|
#define INTF_TYPE_ETH 6 /* Ethernet */
|
|
#define INTF_TYPE_TOKENRING 9 /* Token Ring */
|
|
#define INTF_TYPE_FDDI 15 /* FDDI */
|
|
#define INTF_TYPE_PPP 23 /* Point-to-Point Protocol */
|
|
#define INTF_TYPE_LOOPBACK 24 /* software loopback */
|
|
#define INTF_TYPE_SLIP 28 /* Serial Line Interface Protocol */
|
|
#define INTF_TYPE_TUN 53 /* proprietary virtual/internal */
|
|
|
|
/*
|
|
* Interface flags
|
|
*/
|
|
#define INTF_FLAG_UP 0x01 /* enable interface */
|
|
#define INTF_FLAG_LOOPBACK 0x02 /* is a loopback net (r/o) */
|
|
#define INTF_FLAG_POINTOPOINT 0x04 /* point-to-point link (r/o) */
|
|
#define INTF_FLAG_NOARP 0x08 /* disable ARP */
|
|
#define INTF_FLAG_BROADCAST 0x10 /* supports broadcast (r/o) */
|
|
#define INTF_FLAG_MULTICAST 0x20 /* supports multicast (r/o) */
|
|
|
|
typedef struct intf_handle intf_t;
|
|
|
|
typedef int (*intf_handler)(const struct intf_entry *entry, void *arg);
|
|
|
|
__BEGIN_DECLS
|
|
intf_t *intf_open(void);
|
|
int intf_get(intf_t *i, struct intf_entry *entry);
|
|
int intf_get_src(intf_t *i, struct intf_entry *entry, struct addr *src);
|
|
int intf_get_dst(intf_t *i, struct intf_entry *entry, struct addr *dst);
|
|
int intf_get_pcap_devname(const char *intf_name, char *pcapdev, int pcapdevlen);
|
|
int intf_set(intf_t *i, const struct intf_entry *entry);
|
|
int intf_loop(intf_t *i, intf_handler callback, void *arg);
|
|
intf_t *intf_close(intf_t *i);
|
|
__END_DECLS
|
|
|
|
#endif /* DNET_INTF_H */
|