C/ajinject.c
/* aj_setmode sets the operating mode for  AirJack interfaces */
aj_setmode sets the operating mode for  AirJack interfaces
aj_setmode sets the operating mode for AirJack interfaces
int aj_setmode(char *ifname, int mode) {
    struct aj_config ajconf;
    struct ifreq req;
    int    sock;
    if((sock = aj_getsocket(ifname)) < 0) {
        perror("aj_getsocket");
        close(sock);
        return(-1);
    }
    req.ifr_data = (char *)&ajconf;
    strncpy(req.ifr_name, ifname, sizeof(req.ifr_name));
    if (ioctl(sock, SIOCAJGMODE, &req) < 0) {
        close(sock); 
        return(-1);
    }
    ajconf.mode = mode;
    if (ioctl(sock, SIOCAJSMODE, &req) < 0) {
        close(sock); 
        return(-1);
    }
    close(sock); 
    return(0);
}
int aj_setmode ( char * ifname , int mode ) { struct aj_config ajconf ; struct ifreq req ; int sock ; if ( ( sock = aj_getsocket ( ifname ) ) < 0 ) { perror ( " " ) ; close ( sock ) ; return ( -1 ) ; } req . ifr_data = ( char * ) & ajconf ; strncpy ( req . ifr_name , ifname , sizeof ( req . ifr_name ) ) ; if ( ioctl ( sock , SIOCAJGMODE , & req ) < 0 ) { close ( sock ) ; return ( -1 ) ; } ajconf . mode = mode ; if ( ioctl ( sock , SIOCAJSMODE , & req ) < 0 ) { close ( sock ) ; return ( -1 ) ; } close ( sock ) ; return ( 0 ) ; }
aj_setmode sets the operating mode for  AirJack interfaces
aj_setmode sets the operating mode for AirJack interfaces
/* populate the structure */