hi,
i configured and enabled bridging on host A (kernel 2.2.14). Every sec,
the bridge will transmit a config packet thru' eth0 (only 1 interface).
i run the code (attached) on host B (kernel 2.2.14). it is suppose to
read all sort of packets coming from all the interfaces of host B. host A
and B are connect directly using a cross-cable. however, the code could
not capture the config packets from the bridge, although it could capture
ping packets from host A. however, if i run tcpdump on another window in
host B, the code now is able to capture the bridge config packets as well!
i would like the code to be able to capture the bridge config packets
without the need to run tcpdump. did i miss out something in the code?
thanx.
Nelson
-------------------------------------------
"You will never walk alone"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if_packet.h>
#include <linux/supplicant.h>
#include<linux/if_ether.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/sockios.h>
#include <arpa/inet.h>
#include <errno.h>
unsigned char buf[10002]={128};
void print_head (void)
{
printf("HW-ADDR: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x -----> %.2x:%.2x:%.2x:%.2x:%.2x:%.2x
\n",
buf[6],buf[7],buf[8],buf[9],buf[10],buf[11],
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
}
main(int argc, char **argv)
{
int sockid;
int counter = 0;
if ( (sockid = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) ) < 0)
{
printf("%s: socket failed: %d\n", argv[0], errno);
exit(-1);
} else printf("sock is %d\n",sockid);
for(;;)
{
printf("i'm waiting...\n");
recv(sockid,buf,10000,0);
printf("message %d: ", counter);
print_head();
counter++;
printf("\n\n");
}
close(sockid);
}