- Timestamp:
- 03/19/07 20:32:50 (22 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
madwifing_control.c (modified) (6 diffs)
-
madwifing_control.h (modified) (2 diffs)
-
mwnginject.c (modified) (5 diffs)
-
mwnginject.h (modified) (2 diffs)
-
rt2570inject.c (modified) (1 diff)
-
tx80211.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/madwifing_control.c
r117 r126 42 42 #include <errno.h> 43 43 44 #include "tx80211.h" 44 45 #include "ifcontrol_linux.h" 45 46 … … 54 55 55 56 if ((devdir = opendir(dirpath)) == NULL) { 56 snprintf(errstr, 1024, "madwifing sys directory open failed: %s %s",57 snprintf(errstr, TX80211_STATUS_MAX, "madwifing sys directory open failed: %s %s", 57 58 dirpath, strerror(errno)); 58 59 return NULL; … … 101 102 102 103 if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 103 snprintf(errstr, 1024, "Failed to create socket to madwifi: %s",104 snprintf(errstr, TX80211_STATUS_MAX, "Failed to create socket to madwifi: %s", 104 105 strerror(errno)); 105 106 return -1; … … 109 110 strncpy(ifr.ifr_name, ifname, IFNAMSIZ); 110 111 if (ioctl(sock, SIOC80211IFDESTROY, &ifr) < 0) { 111 snprintf(errstr, 1024, "Failed to destroy VAP: %s", strerror(errno));112 snprintf(errstr, TX80211_STATUS_MAX, "Failed to destroy VAP: %s", strerror(errno)); 112 113 close(sock); 113 114 return -1; … … 170 171 } 171 172 173 if (madwifing_setdevtype(ifr.ifr_name, ARPHDR_RADIOTAP, errstr) < 0) { 174 return -1; 175 } 176 172 177 strncpy(retvapname, ifr.ifr_name, IFNAMSIZ); 173 178 close(sock); … … 176 181 } 177 182 183 /* 184 * Set the device link type for the named interface by changing the dev_type 185 * file in the sys filesystem. 186 */ 187 int madwifing_setdevtype(const char *ifname, char *devtype, char *errstr) 188 { 189 FILE *fp; 190 char athdevpath[64]; 191 int ret; 192 193 snprintf(athdevpath, 64, "/proc/sys/net/%s/dev_type", ifname); 194 195 fp = fopen(athdevpath, "w"); 196 if (!fp) { 197 snprintf(errstr, TX80211_STATUS_MAX, "Error setting madwifi-ng " 198 "capture header type, unable to open proc device \"%s\"", 199 athdevpath); 200 return -1; 201 } 202 203 ret = fprintf(fp, "%s\n", devtype); 204 if (ret < 0) { 205 snprintf(errstr, TX80211_STATUS_MAX, "Error setting madwifi-ng " 206 "capture header type, unable to write to proc device \"%s\"", 207 athdevpath); 208 return ret; 209 } 210 211 fclose(fp); 212 return 0; 213 } 214 178 215 #endif /* linux */ 179 216 -
trunk/madwifing_control.h
r116 r126 37 37 #define IEEE80211_M_MONITOR 8 38 38 39 #define ARPHDR_RADIOTAP "803" 40 39 41 struct madwifi_vaps { 40 42 char **vaplist; … … 55 57 char *retvapname, int vapmode, int vapflags); 56 58 59 /* Set the device type for a VAP */ 60 int madwifing_setdevtype(const char *ifname, char *devtype, char *errstr); 61 57 62 #endif 58 63 #endif -
trunk/mwnginject.c
r125 r126 89 89 } 90 90 91 int madwifing_devtype(struct tx80211 *in_tx, char *devtype)92 {93 FILE *fp;94 char athdevpath[64];95 int ret;96 97 snprintf(athdevpath, 64, "/proc/sys/net/%s/dev_type", in_tx->ifname);98 99 fp = fopen(athdevpath, "w");100 if (!fp) {101 snprintf(in_tx->errstr, TX80211_STATUS_MAX, "Error setting madwifi-ng "102 "capture header type, unable to open proc device \"%s\"",103 athdevpath);104 return -1;105 }106 107 ret = fprintf(fp, "%s\n", devtype);108 if (ret < 0) {109 snprintf(in_tx->errstr, TX80211_STATUS_MAX, "Error setting madwifi-ng "110 "capture header type, unable to write to proc device \"%s\"",111 athdevpath);112 return ret;113 }114 115 fclose(fp);116 return 0;117 }118 119 91 int madwifing_setfuncmode(struct tx80211 *wtinj, int funcmode) 120 92 { … … 126 98 funcmode == TX80211_FUNCMODE_INJMON) { 127 99 128 /* If we weren't passed a rfmon vap already... */ 129 if (madwifing_devtype(wtinj, ARPHDR_RADIOTAP) != 0) { 100 /* 101 * If we weren't passed a rfmon vap already... This will faile 102 * for the master interface it doesn't get a /sys entry i 103 */ 104 if (madwifing_setdevtype(wtinj->ifname, ARPHDR_RADIOTAP, 105 wtinj->errstr) != 0) { 130 106 if (wtinj->extra != NULL) { 131 107 /* If we've got a cached controller name, swap to it */ … … 159 135 160 136 } 137 161 138 162 139 if (wtinj_open(wtinj) != 0) { … … 242 219 mwng_pkt.plen = len; 243 220 244 if ( 245 sendcount = wtinj_send(in_tx, &mwng_pkt) != mwng_pkt.plen); 221 sendcount = wtinj_send(in_tx, &mwng_pkt); 246 222 free(pkt); 247 223 … … 249 225 return TX80211_ENOTX; 250 226 } else if (sendcount != mwng_pkt.plen) { 227 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 228 "Error sending packet data, partial write."); 251 229 return TX80211_EPARTTX; 252 230 } else { -
trunk/mwnginject.h
r113 r126 54 54 #include "wtinject.h" 55 55 56 #define ARPHDR_RADIOTAP "803"57 58 56 enum mwng_ieee80211_phymode { 59 57 MWNG_IEEE80211_MODE_AUTO = 0, /* autoselect */ … … 70 68 int tx80211_madwifing_capabilities(); 71 69 int madwifing_open(struct tx80211 *in_tx); 72 int madwifing_devtype(struct tx80211 *in_tx, char *devtype);73 70 int madwifing_send(struct tx80211 *in_tx, struct tx80211_packet *in_pkt); 74 71 int madwifing_setfuncmode(struct tx80211 *in_tx, int funcmode); -
trunk/rt2570inject.c
r113 r126 60 60 61 61 /* Call private ioctl "rfmontx" to enable raw TX */ 62 if (iwconfig_set_ charpriv(in_tx->ifname, "rfmontx", "1", errstr) != 0) {62 if (iwconfig_set_intpriv(in_tx->ifname, "rfmontx", 1, 0, errstr) != 0) { 63 63 fprintf(stderr, "Error enabling rfmontx private ioctl: %s\n", 64 64 errstr); -
trunk/tx80211.c
r123 r126 29 29 #include <unistd.h> 30 30 #include <string.h> 31 #include <stdlib.h> 31 32 32 33 #include "tx80211.h"
