C/ajinject.c
/* aj_recvframe accepts an 8-byte character array of data, with a length of the
   packet to transmit with the socket in the airjack_data struct.  aj_recvframe
   will test to see if we are currently blocking on the interface.  If we are
   blocking, we simply wait until the packet is received with recv().  If we are
   in nonblock mode, we select on the socket using a fixed timeout parameter,
   and if we don't get any data within that time, we return 1.  An error will
   return -1, success returns 0.
   TODO: Add a timeval struct to the ifname struct for use in the select() on
   the socket for receiving data, instead of a fixed timeout duration. 
   TODO: Write this function. */
aj_recvframe accepts an 8-byte character array of data, with a length of the
packet to transmit with the socket in the airjack_data struct.  aj_recvframe
will test to see if we are currently blocking on the interface.  If we are
blocking, we simply wait until the packet is received with recv().  If we are
in nonblock mode, we select on the socket using a fixed timeout parameter,
and if we don't get any data within that time, we return 1.  An error will
return -1, success returns 0.
TODO: Add a timeval struct to the ifname struct for use in the select() on
the socket for receiving data, instead of a fixed timeout duration.
TODO: Write this function.
aj_recvframe accepts an 8 - byte character array of data with a length of the packet to transmit with the socket in the airjack_data struct . aj_recvframe will test to see if we are currently blocking on the interface . If we are blocking we simply wait until the packet is received with recv () . If we are in nonblock mode we select on the socket using a fixed timeout parameter and if we don ' t get any data within that time we return 1 . An error will return - 1 success returns 0 . TODO : Add a timeval struct to the ifname struct for use in the select () on the socket for receiving data instead of a fixed timeout duration . TODO : Write this function .
int aj_ifupdown(char *ifname, int devup) {
    struct ifreq ifr;
    int    sock;
    if((sock = aj_getsocket(ifname)) < 0) {
        perror("aj_getsocket");
        close(sock);
        return(-1);
    }
    memset(&ifr, 0, sizeof(ifr));
    strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
    if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
        perror("ioctl[SIOCGIFFLAGS]");
        close(sock);
        return(1);
    }
    if (devup) {
        ifr.ifr_flags |= IFF_UP;
    } else {
        ifr.ifr_flags &= ~IFF_UP;
    }
    if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
        perror("ioctl[SIOCSIFFLAGS]");
        close(sock);
        return(1);
    }
    return(0);
}
int aj_ifupdown ( char * ifname , int devup ) { struct ifreq ifr ; int sock ; if ( ( sock = aj_getsocket ( ifname ) ) < 0 ) { perror ( " " ) ; close ( sock ) ; return ( -1 ) ; } memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_name , ifname , sizeof ( ifr . ifr_name ) ) ; if ( ioctl ( sock , SIOCGIFFLAGS , & ifr ) != 0 ) { perror ( " " ) ; close ( sock ) ; return ( 1 ) ; } if ( devup ) { ifr . ifr_flags |= IFF_UP ; } else { ifr . ifr_flags &= ~ IFF_UP ; } if ( ioctl ( sock , SIOCSIFFLAGS , & ifr ) != 0 ) { perror ( " " ) ; close ( sock ) ; return ( 1 ) ; } return ( 0 ) ; }
aj_recvframe accepts an 8-byte character array of data, with a length of the
packet to transmit with the socket in the airjack_data struct.
aj_recvframe accepts an 8 - byte character array of data with a length of the packet to transmit with the socket in the airjack_data struct .
/* Populate the ifr struct with the airjack interface name */ /* Get current flag information from the interface */ /* Set the flag information */