C/ajinject.c
/* aj_getsocket accepts the AirJack interface char * and 
   return a socket, or -1 on error.  This is cribbed right from essid_jack.c,
   thanks Abaddon. */
aj_getsocket accepts the AirJack interface char * and
return a socket, or -1 on error.  This is cribbed right from essid_jack.c,
thanks Abaddon.
aj_getsocket accepts the AirJack interface char * and return a socket or - 1 on error . This is cribbed right from essid_jack . c thanks Abaddon .
int aj_getsocket(char *ifname) {
    struct sockaddr_ll	addr;
    struct ifreq	req;
    struct aj_config	aj_conf;
    int    sock;
    if((sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) {
        return(-1);
    }
    memset(&req, 0, sizeof(struct ifreq));
    memset(&aj_conf, 0, sizeof(struct aj_config));
    strcpy(req.ifr_name, ifname);
    if(ioctl(sock, SIOCGIFINDEX, &req) < 0) {
        close(sock);
        return(-1);
    }
    memset(&addr, 0, sizeof(struct sockaddr_ll));
    addr.sll_ifindex = req.ifr_ifindex;
    addr.sll_protocol = htons(ETH_P_ALL);
    addr.sll_family = AF_PACKET;
    if(bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_ll)) < 0) {
        close(sock);
        return(-1);
    }
    return(sock);
}
int aj_getsocket ( char * ifname ) { struct sockaddr_ll addr ; struct ifreq req ; struct aj_config aj_conf ; int sock ; if ( ( sock = socket ( PF_PACKET , SOCK_RAW , htons ( ETH_P_ALL ) ) ) < 0 ) { return ( -1 ) ; } memset ( & req , 0 , sizeof ( struct ifreq ) ) ; memset ( & aj_conf , 0 , sizeof ( struct aj_config ) ) ; strcpy ( req . ifr_name , ifname ) ; if ( ioctl ( sock , SIOCGIFINDEX , & req ) < 0 ) { close ( sock ) ; return ( -1 ) ; } memset ( & addr , 0 , sizeof ( struct sockaddr_ll ) ) ; addr . sll_ifindex = req . ifr_ifindex ; addr . sll_protocol = htons ( ETH_P_ALL ) ; addr . sll_family = AF_PACKET ; if ( bind ( sock , ( struct sockaddr * ) & addr , sizeof ( struct sockaddr_ll ) ) < 0 ) { close ( sock ) ; return ( -1 ) ; } return ( sock ) ; }
aj_getsocket accepts the AirJack interface char * and
return a socket, or -1 on error.
aj_getsocket accepts the AirJack interface char * and return a socket or - 1 on error .
/* open the link layer socket */ /* get the interface index */ /* bind the socket to the interface */