- Timestamp:
- 03/07/07 19:12:47 (22 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 modified
-
Makefile.in (modified) (1 diff)
-
iwcontrol.c (modified) (1 diff)
-
iwcontrol.h (modified) (1 diff)
-
rt2500inject.c (modified) (4 diffs)
-
rt2500inject.h (modified) (1 diff)
-
rt2570inject.c (modified) (1 diff)
-
rt73inject.c (added)
-
rt73inject.h (added)
-
tx80211.c (modified) (3 diffs)
-
tx80211.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r102 r106 31 31 ajinject.lo p54inject.lo wginject.lo \ 32 32 hapinject.lo rt2500inject.lo rtlinject.lo \ 33 rt2570inject.lo tx80211.lo \33 rt2570inject.lo rt73inject.lo tx80211.lo \ 34 34 packet_assembly.lo lorcon_forge.lo 35 35 LIBOUT = liborcon.la -
trunk/iwcontrol.c
r105 r106 460 460 } 461 461 462 /* 463 * Set a character-based private ioctl 464 */ 465 int 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 462 594 int iwconfig_get_levels(const char *in_dev, char *in_err, int *level, 463 595 int *noise) -
trunk/iwcontrol.h
r105 r106 78 78 int *val, char *errstr); 79 79 80 int iwconfig_set_charpriv(const char *in_dev, const char *privcmd, 81 char *val, char *errstr); 82 80 83 // Fetch levels 81 84 int iwconfig_get_levels(const char *in_dev, char *in_err, int *level, -
trunk/rt2500inject.c
r90 r106 26 26 #include "wtinject.h" 27 27 28 int rt2500_open(struct tx80211 *in_tx); 29 int rt2500_close(struct tx80211 *in_tx); 30 28 31 int tx80211_rt2500_init(struct tx80211 *in_tx) 29 32 { 30 33 31 34 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; 34 37 in_tx->setmode_callthrough = &wtinj_setmode; 35 38 in_tx->getmode_callthrough = &wtinj_getmode; … … 48 51 TX80211_CAP_FRAG | TX80211_CAP_CTRL | 49 52 TX80211_CAP_DURID | TX80211_CAP_SNIFFACK | 50 TX80211_CAP_DSSSTX | TX80211_CAP_OFDMTX);53 TX80211_CAP_DSSSTX); 51 54 /* TODO: Test SELFACK */ 52 55 return (0); … … 60 63 61 64 /* 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) { 63 66 fprintf(stderr, "Error enabling rfmontx private ioctl: %s\n", 64 67 errstr); … … 75 78 76 79 /* 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) { 78 81 fprintf(stderr, "Error disabling rfmontx private ioctl: %s\n", 79 82 errstr); -
trunk/rt2500inject.h
r90 r106 56 56 int tx80211_rt2500_capabilities(); 57 57 58 int rt2500_open(struct tx80211 *in_tx); 59 int rt2500_close(struct tx80211 *in_tx); 60 58 61 #endif /* linux */ 59 62 -
trunk/rt2570inject.c
r90 r106 58 58 59 59 /* 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) { 61 61 fprintf(stderr, "Error enabling rfmontx private ioctl: %s\n", 62 62 errstr); -
trunk/tx80211.c
r103 r106 127 127 ret->capabilities[ret->num_cards] = tx80211_rt2500_capabilities(); 128 128 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++; 129 134 #endif 130 135 … … 183 188 if (!strcasecmp(in_str, "rt2570") || !strcasecmp(in_str, "rtl2570")) 184 189 return INJ_RT2570; 190 191 if (!strcasecmp(in_str, "rt73") || !strcasecmp(in_str, "rtl73")) 192 return INJ_RT73; 185 193 #endif 186 194 … … 232 240 case INJ_RT2570: 233 241 tx80211_rt2570_init(in_tx); 242 break; 243 244 case INJ_RT73: 245 tx80211_rt73_init(in_tx); 234 246 break; 235 247 -
trunk/tx80211.h
r104 r106 208 208 #define INJ_RT2500 8 209 209 #define INJ_RT2570 9 210 #define INJ_MAX 10 210 #define INJ_RT73 10 211 #define INJ_MAX 11 211 212 212 213 /* Generic endian flopping macros */
