hi list,

i'm using kernel 2.2.14 and configured the bridge into the kernel.

i wrote a piece of code to detect any packets send out by the
bridge. every second, the bridge would send out a packet. however, my code
could not detect these packets. however, if i run tcpdump on the same
machine on which my code is ran, the code works fine. attached below is
the code. did i miss out anything?


#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);
}

Nelson
-------------------------------------------
"You will never walk alone"


-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to