Dennis Kellly
01/27/2009 9:39 AM
post20838
|
Did you try to bind the interface before the ioctl?
struct ifreq reader_if;
char if_name[128];
...
strcpy( if_name, "en0" );
// bind interface
strcpy( reader_if.ifr_name, if_name );
if ( ioctl( bpffd, BIOCSETIF, &reader_if ) )
{
printf( "error: bpf setif ioctl error %d\n", errno );
close( bpffd );
return -2;
}
if ( opt_promiscuous )
{
if ( ioctl( bpffd, BIOCPROMISC, NULL ) == -1 )
{
printf( "error: bpf promiscuous ioctl error %d\n", errno );
close( bpffd );
return -3;
}
}
|
|
|