Changeset 106 for trunk

Show
Ignore:
Timestamp:
03/07/07 19:12:47 (22 months ago)
Author:
dragorn
Message:

Added rt73 USB injectors
Added char* iwpriv controls
Fixed rt2500 to not report OFDMTX
Fixed rt2500 to use char* iwpriv
Fixed rt2500 to use rt2500 open/close callbacks
Fixed rt2570 to use char* iwpriv

Location:
trunk
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.in

    r102 r106  
    3131                 ajinject.lo p54inject.lo wginject.lo \ 
    3232                 hapinject.lo rt2500inject.lo rtlinject.lo \ 
    33                  rt2570inject.lo tx80211.lo \ 
     33                 rt2570inject.lo rt73inject.lo tx80211.lo \ 
    3434                 packet_assembly.lo lorcon_forge.lo 
    3535LIBOUT = liborcon.la 
  • trunk/iwcontrol.c

    r105 r106  
    460460} 
    461461 
     462/*  
     463 * Set a character-based private ioctl 
     464 */ 
     465int iwconfig_set_charpriv(const char *in_dev, const char *privcmd, 
     466                         char *val, char *errstr) 
     467{ 
     468        struct iwreq wrq; 
     469        int skfd; 
     470        struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 
     471        int subcmd = 0; 
     472        int offset = 0; 
     473 
     474        memset(priv, 0, sizeof(priv)); 
     475 
     476        if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 
     477                snprintf(errstr, TX80211_STATUS_MAX, 
     478                         "Failed to create socket to set private ioctl " 
     479                         "on %s: %s", in_dev, strerror(errno)); 
     480                return -1; 
     481        } 
     482 
     483        memset(&wrq, 0, sizeof(struct iwreq)); 
     484        strncpy(wrq.ifr_name, in_dev, IFNAMSIZ); 
     485 
     486        wrq.u.data.pointer = (caddr_t) priv; 
     487        wrq.u.data.length = IW_MAX_PRIV_DEF; 
     488        wrq.u.data.flags = 0; 
     489 
     490        if (ioctl(skfd, SIOCGIWPRIV, &wrq) < 0) { 
     491                snprintf(errstr, TX80211_STATUS_MAX, 
     492                         "Failed to retrieve list of private ioctls on %s: %s", 
     493                         in_dev, strerror(errno)); 
     494                close(skfd); 
     495                return -1; 
     496        } 
     497 
     498        int pn = -1; 
     499        while ((++pn < wrq.u.data.length) && strcmp(priv[pn].name, privcmd)) ; 
     500 
     501        if (pn == wrq.u.data.length) { 
     502                snprintf(errstr, TX80211_STATUS_MAX, 
     503                         "Unable to find private ioctl '%s' on %s",  
     504                         privcmd, in_dev); 
     505                close(skfd); 
     506                return -2; 
     507        } 
     508 
     509        /* Find subcmds, as if this isn't ugly enough already */ 
     510        if (priv[pn].cmd < SIOCDEVPRIVATE) { 
     511                int j = -1; 
     512 
     513                while ((++j < wrq.u.data.length) 
     514                       && ((priv[j].name[0] != '\0') 
     515                           || (priv[j].set_args != priv[pn].set_args) 
     516                           || (priv[j].get_args != priv[pn].get_args))) ; 
     517 
     518                if (j == wrq.u.data.length) { 
     519                        snprintf(errstr, TX80211_STATUS_MAX, 
     520                                 "Unable to find subioctl '%s' on %s",  
     521                                 privcmd, in_dev); 
     522                        close(skfd); 
     523                        return -2; 
     524                } 
     525 
     526                subcmd = priv[pn].cmd; 
     527                offset = sizeof(uint32_t); 
     528                pn = j; 
     529        } 
     530 
     531        /* Make sure its an iwpriv we can set */ 
     532        if ((priv[pn].set_args & IW_PRIV_TYPE_MASK) == 0 || 
     533            (priv[pn].set_args & IW_PRIV_SIZE_MASK) == 0) { 
     534                snprintf(errstr, TX80211_STATUS_MAX, 
     535                         "Unable to set values for private ioctl '%s' on %s", 
     536                         privcmd, in_dev); 
     537                close(skfd); 
     538                return -1; 
     539        } 
     540 
     541        if ((priv[pn].set_args & IW_PRIV_TYPE_MASK) != IW_PRIV_TYPE_CHAR) { 
     542                snprintf(errstr, TX80211_STATUS_MAX, 
     543                         "'%s' on %s does not accept char parameters.", 
     544                         privcmd, in_dev); 
     545                close(skfd); 
     546                return -1; 
     547        } 
     548 
     549        /* Find out how many arguments it takes and die if we can't handle it */ 
     550#if 0 
     551        int nargs = (priv[pn].set_args & IW_PRIV_SIZE_MASK); 
     552        if (nargs > 1) { 
     553                snprintf(errstr, TX80211_STATUS_MAX, 
     554                         "Private ioctl '%s' on %s expects more than 1 arguments.", privcmd, in_dev); 
     555                close(skfd); 
     556                return -1; 
     557        } 
     558#endif 
     559 
     560        /* Build the set request */ 
     561        memset(&wrq, 0, sizeof(struct iwreq)); 
     562        strncpy(wrq.ifr_name, in_dev, IFNAMSIZ); 
     563 
     564        /* Assign the arguments */ 
     565        wrq.u.data.length = strlen(val) + 1; 
     566 
     567        /* This is terrible!  
     568         * This is also simplified from what iwpriv.c does, because we don't 
     569         * need to worry about get-no-set ioctls 
     570         */ 
     571        if ((priv[pn].set_args & IW_PRIV_SIZE_FIXED) && 
     572            ((sizeof(char) * strlen(val) + 1) + offset <= IFNAMSIZ)) { 
     573                if (offset) 
     574                        wrq.u.mode = subcmd; 
     575                memcpy(wrq.u.name + offset, val, IFNAMSIZ - offset); 
     576        } else { 
     577                wrq.u.data.pointer = (caddr_t) val; 
     578                wrq.u.data.flags = 0; 
     579        } 
     580 
     581        /* Actually do it. */ 
     582        if (ioctl(skfd, priv[pn].cmd, &wrq) < 0) { 
     583                snprintf(errstr, TX80211_STATUS_MAX, 
     584                         "Failed to set private ioctl '%s' on %s: %s", privcmd, 
     585                         in_dev, strerror(errno)); 
     586                close(skfd); 
     587                return -1; 
     588        } 
     589 
     590        close(skfd); 
     591        return 0; 
     592} 
     593 
    462594int iwconfig_get_levels(const char *in_dev, char *in_err, int *level, 
    463595                        int *noise) 
  • trunk/iwcontrol.h

    r105 r106  
    7878                         int *val, char *errstr); 
    7979 
     80int iwconfig_set_charpriv(const char *in_dev, const char *privcmd, 
     81                         char *val, char *errstr); 
     82 
    8083// Fetch levels 
    8184int iwconfig_get_levels(const char *in_dev, char *in_err, int *level, 
  • trunk/rt2500inject.c

    r90 r106  
    2626#include "wtinject.h" 
    2727 
     28int rt2500_open(struct tx80211 *in_tx); 
     29int rt2500_close(struct tx80211 *in_tx); 
     30 
    2831int tx80211_rt2500_init(struct tx80211 *in_tx) 
    2932{ 
    3033 
    3134        in_tx->capabilities = tx80211_rt2500_capabilities(); 
    32         in_tx->open_callthrough = &wtinj_open; 
    33         in_tx->close_callthrough = &wtinj_close; 
     35        in_tx->open_callthrough = &rt2500_open; 
     36        in_tx->close_callthrough = &rt2500_close; 
    3437        in_tx->setmode_callthrough = &wtinj_setmode; 
    3538        in_tx->getmode_callthrough = &wtinj_getmode; 
     
    4851                TX80211_CAP_FRAG | TX80211_CAP_CTRL | 
    4952                TX80211_CAP_DURID | TX80211_CAP_SNIFFACK | 
    50                 TX80211_CAP_DSSSTX | TX80211_CAP_OFDMTX); 
     53                TX80211_CAP_DSSSTX); 
    5154        /* TODO: Test SELFACK */ 
    5255        return (0); 
     
    6063 
    6164        /* Call private ioctl "rfmontx" to enable raw TX */ 
    62         if (iwconfig_set_intpriv(in_tx->ifname, "rfmontx", 1, 0, errstr) != 0) { 
     65        if (iwconfig_set_charpriv(in_tx->ifname, "rfmontx", "1", errstr) != 0) { 
    6366                fprintf(stderr, "Error enabling rfmontx private ioctl: %s\n", 
    6467                        errstr); 
     
    7578 
    7679        /* Call private ioctl "rfmontx" to disable raw TX */ 
    77         if (iwconfig_set_intpriv(in_tx->ifname, "rfmontx", 0, 0, errstr) != 0) { 
     80        if (iwconfig_set_charpriv(in_tx->ifname, "rfmontx", "0", errstr) != 0) { 
    7881                fprintf(stderr, "Error disabling rfmontx private ioctl: %s\n", 
    7982                        errstr); 
  • trunk/rt2500inject.h

    r90 r106  
    5656int tx80211_rt2500_capabilities(); 
    5757 
     58int rt2500_open(struct tx80211 *in_tx); 
     59int rt2500_close(struct tx80211 *in_tx); 
     60 
    5861#endif /* linux */ 
    5962 
  • trunk/rt2570inject.c

    r90 r106  
    5858 
    5959        /* Call private ioctl "rfmontx" to enable raw TX */ 
    60         if (iwconfig_set_intpriv(in_tx->ifname, "rfmontx", 1, 0, errstr) != 0) { 
     60        if (iwconfig_set_charpriv(in_tx->ifname, "rfmontx", "1", errstr) != 0) { 
    6161                fprintf(stderr, "Error enabling rfmontx private ioctl: %s\n", 
    6262                                errstr); 
  • trunk/tx80211.c

    r103 r106  
    127127        ret->capabilities[ret->num_cards] = tx80211_rt2500_capabilities(); 
    128128        ret->num_cards++; 
     129 
     130        ret->cardnames[ret->num_cards] = strdup("rt73"); 
     131        ret->descriptions[ret->num_cards] = strdup("Raylink 73 802.11g USB"); 
     132        ret->capabilities[ret->num_cards] = tx80211_rt73_capabilities(); 
     133        ret->num_cards++; 
    129134#endif 
    130135 
     
    183188        if (!strcasecmp(in_str, "rt2570") || !strcasecmp(in_str, "rtl2570")) 
    184189                return INJ_RT2570; 
     190 
     191        if (!strcasecmp(in_str, "rt73") || !strcasecmp(in_str, "rtl73")) 
     192                return INJ_RT73; 
    185193#endif 
    186194 
     
    232240        case INJ_RT2570: 
    233241                tx80211_rt2570_init(in_tx); 
     242                break; 
     243 
     244        case INJ_RT73: 
     245                tx80211_rt73_init(in_tx); 
    234246                break; 
    235247 
  • trunk/tx80211.h

    r104 r106  
    208208#define INJ_RT2500      8 
    209209#define INJ_RT2570      9 
    210 #define INJ_MAX         10 
     210#define INJ_RT73        10 
     211#define INJ_MAX         11 
    211212 
    212213/* Generic endian flopping macros */