| 1 | /* |
|---|
| 2 | This file is part of lorcon |
|---|
| 3 | |
|---|
| 4 | lorcon is free software; you can redistribute it and/or modify |
|---|
| 5 | it under the terms of the GNU General Public License as published by |
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | (at your option) any later version. |
|---|
| 8 | |
|---|
| 9 | lorcon is distributed in the hope that it will be useful, |
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | GNU General Public License for more details. |
|---|
| 13 | |
|---|
| 14 | You should have received a copy of the GNU General Public License |
|---|
| 15 | along with lorcon; if not, write to the Free Software |
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 | |
|---|
| 18 | Copyright (c) 2005 dragorn and Joshua Wright |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifdef HAVE_CONFIG_H |
|---|
| 22 | #include "config.h" |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | #ifdef SYS_LINUX |
|---|
| 26 | |
|---|
| 27 | #include "rt73inject.h" |
|---|
| 28 | #include "wtinject.h" |
|---|
| 29 | |
|---|
| 30 | int tx80211_rt73_init(struct tx80211 *in_tx) |
|---|
| 31 | { |
|---|
| 32 | |
|---|
| 33 | in_tx->capabilities = tx80211_rt73_capabilities(); |
|---|
| 34 | in_tx->open_callthrough = &rt73_open; |
|---|
| 35 | in_tx->close_callthrough = &rt73_close; |
|---|
| 36 | in_tx->setmode_callthrough = &wtinj_setmode; |
|---|
| 37 | in_tx->getmode_callthrough = &wtinj_getmode; |
|---|
| 38 | in_tx->getchan_callthrough = &wtinj_getchannel; |
|---|
| 39 | in_tx->setchan_callthrough = &wtinj_setchannel; |
|---|
| 40 | in_tx->txpacket_callthrough = &wtinj_send; |
|---|
| 41 | in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; |
|---|
| 42 | |
|---|
| 43 | return 0; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | int tx80211_rt73_capabilities() |
|---|
| 47 | { |
|---|
| 48 | return (TX80211_CAP_SNIFF | TX80211_CAP_TRANSMIT | |
|---|
| 49 | TX80211_CAP_SEQ | TX80211_CAP_BSSTIME | |
|---|
| 50 | TX80211_CAP_FRAG | TX80211_CAP_CTRL | |
|---|
| 51 | TX80211_CAP_DURID | TX80211_CAP_SNIFFACK | |
|---|
| 52 | TX80211_CAP_DSSSTX | TX80211_CAP_OFDMTX); |
|---|
| 53 | /* TODO: Test SELFACK */ |
|---|
| 54 | return (0); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | int rt73_open(struct tx80211 *in_tx) |
|---|
| 59 | { |
|---|
| 60 | char errstr[TX80211_STATUS_MAX]; |
|---|
| 61 | |
|---|
| 62 | /* Call private ioctl "rfmontx" to enable raw TX */ |
|---|
| 63 | if (iwconfig_set_intpriv(in_tx->ifname, "rfmontx", 1, 0, errstr) != 0) { |
|---|
| 64 | if (iwconfig_set_charpriv(in_tx->ifname, "rfmontx", "1", errstr) != 0) { |
|---|
| 65 | snprintf(in_tx->errstr, TX80211_STATUS_MAX, |
|---|
| 66 | "Error enabling rfmontx private ioctl: %s\n", |
|---|
| 67 | errstr); |
|---|
| 68 | return -1; |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | return(wtinj_open(in_tx)); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | int rt73_close(struct tx80211 *in_tx) |
|---|
| 76 | { |
|---|
| 77 | |
|---|
| 78 | char errstr[TX80211_STATUS_MAX]; |
|---|
| 79 | |
|---|
| 80 | /* Call private ioctl "rfmontx" to disable raw TX */ |
|---|
| 81 | if (iwconfig_set_charpriv(in_tx->ifname, "rfmontx", "0", errstr) != 0) { |
|---|
| 82 | snprintf(in_tx->errstr, TX80211_STATUS_MAX, |
|---|
| 83 | "Error disabling rfmontx private ioctl: %s\n", |
|---|
| 84 | errstr); |
|---|
| 85 | return -1; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | return(wtinj_close(in_tx)); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | #endif /* linux */ |
|---|