int set_monitor( char *interface, int fd_raw ) { int pid, status; struct iwreq wrq; if( strcmp(interface,"prism0") == 0 ) { if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); chdir( "/" ); execlp( "wl", "wl", "monitor", "1", NULL); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) return( WEXITSTATUS(status) ); return( 1 ); } else { if( G.is_wlanng ) { if( ( pid = fork() ) == 0 ) { close( 0 ); close( 1 ); close( 2 ); chdir( "/" ); execlp( "wlanctl-ng", "wlanctl-ng", interface, "lnxreq_wlansniff", "enable=true", "prismheader=true", "wlanheader=false", "stripfcs=true", "keepwepflags=true", NULL ); exit( 1 ); } waitpid( pid, &status, 0 ); if( WIFEXITED(status) ) return( WEXITSTATUS(status) ); return( 1 ); } memset( &wrq, 0, sizeof( struct iwreq ) ); strncpy( wrq.ifr_name, interface, IFNAMSIZ ); wrq.u.mode = IW_MODE_MONITOR; if( ioctl( fd_raw, SIOCSIWMODE, &wrq ) < 0 ) { perror( "ioctl(SIOCSIWMODE) failed" ); return( 1 ); } } /* Check later if it's really usefull to set channel here */ set_channel( interface, fd_raw, (G.channel == 0 ) ? 10 : G.channel); return( 0 ); }