On Mon, May 02, 2005 at 01:55:18AM +0300, Martins Dzelde wrote:
The FreeBSD box is configured to work as bridge,
That'll be it. When iftop starts up, does it say "Cannot obtain MAC address on this platform"? (you should be able to see this message after you quit).
If so, then the problem is that it can't get the hardware address, and because it's a bridge, the interfaces don't have an IP address, so it can't determine which way the packets are actually moving.
Either we need to figure out how to get the hardware address on FreeBSD, or add an option to specify the hardware address.
Paul
Hmm, well, i was using iftop all the time on the bridge, and one of the interfaces do have an ip address. Iftop was working fine on the bridge until i switched to the media type for the interface to 10baseT/UTP..
Martins.
On Mon, 02 May 2005 12:40:53 +0300, Paul Warren pdw@ex-parrot.com wrote:
On Mon, May 02, 2005 at 01:55:18AM +0300, Martins Dzelde wrote:
The FreeBSD box is configured to work as bridge,
That'll be it. When iftop starts up, does it say "Cannot obtain MAC address on this platform"? (you should be able to see this message after you quit).
If so, then the problem is that it can't get the hardware address, and because it's a bridge, the interfaces don't have an IP address, so it can't determine which way the packets are actually moving.
Either we need to figure out how to get the hardware address on FreeBSD, or add an option to specify the hardware address.
Paul
iftop-users mailing list iftop-users@lists.beasts.org http://lists.beasts.org/mailman/listinfo/iftop-users
On Mon, May 02, 2005 at 12:55:47PM +0300, Martins Dzelde wrote:
Hmm, well, i was using iftop all the time on the bridge, and one of the interfaces do have an ip address.
Yes, but presumably if it's acting as a bridge, most of the traffic is going straight across rather than going to/from the IP address of the bridge (iftop uses the IP address as a fall back in the event that it can't get the hardware address, but for this reason h/ware address is preferred).
Iftop was working fine on the bridge until i switched to the media type for the interface to 10baseT/UTP..
Hmm. Can you tell me what iftop says about the hardware address for the interface? My guess is that for some reason it can determine h/ware address for 10baseT/UTP.
Paul
On Mon, 02 May 2005 12:40:53 +0300, Paul Warren pdw@ex-parrot.com wrote:
On Mon, May 02, 2005 at 01:55:18AM +0300, Martins Dzelde wrote:
The FreeBSD box is configured to work as bridge,
That'll be it. When iftop starts up, does it say "Cannot obtain MAC address on this platform"? (you should be able to see this message after you quit).
If so, then the problem is that it can't get the hardware address, and because it's a bridge, the interfaces don't have an IP address, so it can't determine which way the packets are actually moving.
Either we need to figure out how to get the hardware address on FreeBSD, or add an option to specify the hardware address.
Paul
iftop-users mailing list iftop-users@lists.beasts.org http://lists.beasts.org/mailman/listinfo/iftop-users
iftop-users mailing list iftop-users@lists.beasts.org http://lists.beasts.org/mailman/listinfo/iftop-users
Paul Warren(pdw@ex-parrot.com)@2005.05.02 10:40:53 +0100 wrote:
we need to figure out how to get the hardware address on FreeBSD,
Hi,
Here is a patch which uses sysctl to get the hardware address. I tried it on FreeBSD 5.3 and OpenBSD 3.5. Note that I don't know how this code work on an non-ethernet interface (tried on some pseudo-interface and get an all-0 address, but...).
I left the code in the get_addrs_ioctl fct despite the fact it uses sysctl because it was simpler.
Oh yes, I used gotos, I found them more readable in this case than deeply imbricated ifs.
Best Regards, Nicolas
Hi Nicolas,
Thanks for this - I've now applied this to the version in CVS.
Paul
On Tue, May 03, 2005 at 12:17:08PM +0200, Nicolas Bernard wrote:
Paul Warren(pdw@ex-parrot.com)@2005.05.02 10:40:53 +0100 wrote:
we need to figure out how to get the hardware address on FreeBSD,
Hi,
Here is a patch which uses sysctl to get the hardware address. I tried it on FreeBSD 5.3 and OpenBSD 3.5. Note that I don't know how this code work on an non-ethernet interface (tried on some pseudo-interface and get an all-0 address, but...).
I left the code in the get_addrs_ioctl fct despite the fact it uses sysctl because it was simpler.
Oh yes, I used gotos, I found them more readable in this case than deeply imbricated ifs.
Best Regards, Nicolas
diff -u -r iftop-0.17pre1/addrs_ioctl.c iftop-0.17pre1-bsdmac/addrs_ioctl.c --- iftop-0.17pre1/addrs_ioctl.c Tue Jul 27 10:44:13 2004 +++ iftop-0.17pre1-bsdmac/addrs_ioctl.c Tue May 3 11:46:49 2005 @@ -18,6 +18,12 @@ #include <net/if.h> #include <netinet/in.h>
+#if defined __FreeBSD__ || defined __OpenBSD__ +#include <sys/param.h> +#include <sys/sysctl.h> +#include <net/if_dl.h> +#endif
#include "iftop.h"
/* @@ -65,7 +71,41 @@ got_hw_addr = 1; } #else +#if defined __FreeBSD__ || defined __OpenBSD__
- {
- int sysctlparam[6] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
- int needed = 0;
- char *buf = NULL;
- struct if_msghdr *msghdr = NULL;
- sysctlparam[5] = if_nametoindex(interface);
- if (sysctlparam[5] == 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
- }
- if (sysctl(sysctlparam, 6, NULL, &needed, NULL, 0) < 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
- }
- if ((buf = malloc(needed)) == NULL) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
- }
- if (sysctl(sysctlparam, 6, buf, &needed, NULL, 0) < 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
free(buf);
goto ENDHWADDR;
- }
- msghdr = (struct if_msghdr *) buf;
- memcpy(if_hw_addr, LLADDR((struct sockaddr_dl *)(buf + sizeof(struct if_msghdr) - sizeof(struct if_data) + sizeof(struct if_data))), 6);
- free(buf);
- got_hw_addr = 1;
- ENDHWADDR:
- 1; /* compiler whines if there is a label at the end of a block...*/
- }
+#else fprintf(stderr, "Cannot obtain hardware address on this platform\n"); +#endif #endif
/* Get the IP address of the interface */