- Timestamp:
- 11/01/06 19:00:10 (2 years ago)
- Location:
- trunk
- Files:
-
- 15 modified
- 2 moved
-
Makefile.in (modified) (1 diff)
-
ajinject.c (modified) (1 diff)
-
hapinject.c (modified) (1 diff)
-
ifcontrol_linux.c (moved) (moved from trunk/ifcontrol.c) (1 diff)
-
ifcontrol_linux.h (moved) (moved from trunk/ifcontrol.h)
-
lorcon.3 (modified) (11 diffs)
-
mwnginject.c (modified) (1 diff)
-
mwoldinject.c (modified) (1 diff)
-
p54inject.c (modified) (1 diff)
-
rt2500inject.c (modified) (1 diff)
-
rt2570inject.c (modified) (1 diff)
-
rtlinject.c (modified) (1 diff)
-
tx80211.c (modified) (7 diffs)
-
tx80211.h (modified) (3 diffs)
-
wginject.c (modified) (1 diff)
-
wtinject.c (modified) (8 diffs)
-
wtinject.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r83 r86 25 25 DEPEND = .depend 26 26 27 LIBOBJ = ifcontrol .lo iwcontrol.lo \27 LIBOBJ = ifcontrol_linux.lo iwcontrol.lo \ 28 28 wtinject.lo mwoldinject.lo mwnginject.lo \ 29 29 ajinject.lo p54inject.lo wginject.lo \ -
trunk/ajinject.c
r73 r86 50 50 in_tx->setchan_callthrough = &ajinj_setchannel; 51 51 in_tx->txpacket_callthrough = &ajinj_send; 52 in_tx->setfuncmode_callthrough = NULL; 52 53 53 54 return 0; -
trunk/hapinject.c
r69 r86 33 33 in_tx->setchan_callthrough = &wtinj_setchannel; 34 34 in_tx->txpacket_callthrough = &wtinj_send; 35 in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; 35 36 36 37 return 0; -
trunk/ifcontrol_linux.c
r68 r86 20 20 21 21 #include "config.h" 22 #include "ifcontrol .h"22 #include "ifcontrol_linux.h" 23 23 #include "tx80211.h" 24 24 -
trunk/lorcon.3
r85 r86 1 1 .\" $Id: $ 2 .TH LORCON 3 " 22 November 2005"2 .TH LORCON 3 "01 November 2006" 3 3 .SH NAME 4 4 LORCON \- 802.11 Wireless Packet Injection Library … … 21 21 .LP 22 22 .ft B 23 int tx80211_getcapabilities(struct tx80211 *in_tx)24 .ft25 .LP26 .ft B27 23 int tx80211_init(struct tx80211 *in_tx, const char *in_ifname, 28 24 .ti +8 … … 31 27 .LP 32 28 .ft B 29 int tx80211_geterrstr(struct tx80211 *in_tx) 30 .ft 31 .LP 32 .ft B 33 int tx80211_getcapabilities(struct tx80211 *in_tx) 34 .ft 35 .LP 36 .ft B 33 37 int tx80211_open(struct tx80211 *in_tx) 34 38 .ft … … 36 40 .ft B 37 41 int tx80211_setmode(struct tx80211 *in_tx, int in_mode) 38 int tx80211_getmode(struct tx80211 *in_tx) 42 int tx80211_getmode(struct tx80211 *in_tx) /* deprecated */ 43 int tx80211_setfunctionalmode(struct tx80211 *in_tx, int in_fmode) 39 44 .ft 40 45 .LP … … 184 189 185 190 .PP 191 .BR tx80211_geterrstr() 192 fetches the error string of the last failed operation, contained in the 193 .I in_tx 194 structure. 195 .B tx80211_geterrstr() 196 should only be called when an error is returned. Calling it extraneously may return 197 older error data which is not relevant. 198 199 .PP 186 200 .BR tx80211_getcapabilities() 187 201 is used to resolve the capability information for the driver in use. Different … … 322 336 .B tx80211_init 323 337 function. 338 339 .I This function is deprecated. It has been superseded by the 340 .B tx80211_setfunctionalmode 341 .I function. 342 324 343 .I in_mode 325 344 is the desired operating mode for the wireless card, as defined in the … … 367 386 operating mode is the preferred operating mechanism. 368 387 388 .PP 389 .BR tx80211_setfunctionalmode() 390 is used to set the operating mode of the wireless card. 391 .I in_tx 392 is the structure populated by the 393 .B tx80211_init 394 function. 395 .I in_fmode 396 is the desired functional operating mode for the wireless card: 397 398 .RS 399 .TP 400 .B 401 TX80211_FUNCMODE_RFMON 402 Configures the card to forward all frames to userspace regardless of destination 403 or BSSID address. 404 .TP 405 .B 406 TX80211_FUNCMODE_INJECT 407 Configures the card for injection mode. While this may imply other modes, the only 408 guaranteed functionality is injection. 409 .TP 410 .B 411 TX80211_FUNCMODE_INJMON 412 Configures the card for dual functionality, injection and rfmon. If the device 413 supports it, this allows sniffing and injection simultaneously. 414 415 .RE 416 .B tx80211_setfunctionalmode() 417 returns 0 on success, < 0 on error. 418 419 .B NOTE: 420 For most packet injection uses, the 421 .B TX80211_FUNCMODE_INJMON 422 operating mode is the preferred operating mechanism. 423 424 .B NOTE 2: It's possible that on some cards one mode can perform multiple tasks (IE 425 injection still works while in monitor mode) however this is not recommended as it 426 will not operate on all cards. The caller should always set the desired functional 427 mode. 369 428 370 429 .PP … … 506 565 507 566 /* Place the card in monitor mode */ 508 if (tx80211_setmode(&in_tx, IW_MODE_MONITOR) != 0) { 509 fprintf(stderr, "Error setting monitor mode.\\n"); 567 if (tx80211_setfunctionalmode(&in_tx, TX80211_FUNCMODE_INJMON) != 0) { 568 fprintf(stderr, "Error setting monitor/inject mode: %s.\\n", 569 tx80211_geterrstr(in_tx)); 510 570 return 1; 511 571 } … … 513 573 /* Switch to the specified channel */ 514 574 if (tx80211_setchannel(&in_tx, CHANNEL) < 0) { 515 fprintf(stderr, "Error setting channel.\\n"); 575 fprintf(stderr, "Error setting channel: %s.\\n", 576 tx80211_geterrstr(in_tx)); 516 577 return 1; 517 578 } … … 519 580 /* Open the interface */ 520 581 if (tx80211_open(&in_tx) < 0) { 521 fprintf(stderr, "Unable to open interface %s .\\n",522 in_tx.ifname );582 fprintf(stderr, "Unable to open interface %s: %s.\\n", 583 in_tx.ifname, tx80211_geterrstr(in_tx)); 523 584 return 1; 524 585 } … … 531 592 /* Transmit the packet */ 532 593 if (tx80211_txpacket(&in_tx, &in_packet) < 0) { 533 fprintf(stderr, "Unable to transmit packet.\\n"); 594 fprintf(stderr, "Unable to transmit packet: %s.\\n", 595 tx80211_geterrstr(in_tx)); 534 596 return 1; 535 597 } -
trunk/mwnginject.c
r83 r86 33 33 in_tx->setchan_callthrough = &wtinj_setchannel; 34 34 in_tx->txpacket_callthrough = &madwifing_send; 35 in_tx->setfuncmode_callthrough = NULL; 35 36 36 37 return 0; -
trunk/mwoldinject.c
r73 r86 36 36 in_tx->setchan_callthrough = &wtinj_setchannel; 37 37 in_tx->txpacket_callthrough = &wtinj_send; 38 in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; 38 39 39 40 return 0; -
trunk/p54inject.c
r69 r86 33 33 in_tx->setchan_callthrough = &wtinj_setchannel; 34 34 in_tx->txpacket_callthrough = &wtinj_send; 35 in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; 35 36 36 37 return 0; -
trunk/rt2500inject.c
r70 r86 33 33 in_tx->setchan_callthrough = &wtinj_setchannel; 34 34 in_tx->txpacket_callthrough = &wtinj_send; 35 in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; 35 36 36 37 return 0; -
trunk/rt2570inject.c
r85 r86 33 33 in_tx->setchan_callthrough = &wtinj_setchannel; 34 34 in_tx->txpacket_callthrough = &rt2570_send; 35 in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; 35 36 36 37 return 0; -
trunk/rtlinject.c
r68 r86 33 33 in_tx->setchan_callthrough = &wtinj_setchannel; 34 34 in_tx->txpacket_callthrough = &wtinj_send; 35 in_tx->setfuncmode_callthrough = &wtinj_setfuncmode; 35 36 36 37 return 0; -
trunk/tx80211.c
r73 r86 180 180 } 181 181 182 char *tx80211_geterrstr(struct tx80211 *in_tx) 183 { 184 return in_tx->errstr; 185 } 186 182 187 int tx80211_init(struct tx80211 *in_tx, const char *in_ifname, int in_injector) 183 188 { … … 248 253 int tx80211_close(struct tx80211 *in_tx) 249 254 { 250 if (in_tx->close_callthrough == NULL) 251 return TX80211_ENOHANDLER; 255 if (in_tx->close_callthrough == NULL) 256 { 257 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 258 "Close callthrough handler not implemented"); 259 return TX80211_ENOHANDLER; 260 } 252 261 253 262 return (in_tx->close_callthrough) (in_tx); … … 256 265 int tx80211_setmode(struct tx80211 *in_tx, int in_mode) 257 266 { 258 if (in_tx->setmode_callthrough == NULL) 259 return TX80211_ENOHANDLER; 267 fprintf(stderr, "LORCON - tx80211_setmode(...) is deprecated, please use " 268 "tx80211_setfunctionalmode(...) instead\n"); 269 270 if (in_tx->setmode_callthrough == NULL) 271 { 272 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 273 "Setmode callthrough handler not implemented"); 274 return TX80211_ENOHANDLER; 275 } 260 276 261 277 return (in_tx->setmode_callthrough) (in_tx, in_mode); … … 265 281 { 266 282 if (in_tx->getmode_callthrough == NULL) 267 return TX80211_ENOHANDLER; 283 { 284 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 285 "Getmode callthrough handler not implemented"); 286 return TX80211_ENOHANDLER; 287 } 268 288 269 289 return (in_tx->getmode_callthrough) (in_tx); … … 272 292 int tx80211_setfunctionalmode(struct tx80211 *in_tx, int in_fmode) 273 293 { 274 if (in_tx->setfuncmode_callthrough == NULL) 275 return TX80211_ENOHANDLER; 294 if (in_tx->setfuncmode_callthrough == NULL) 295 { 296 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 297 "Setfunctionalmode callthrough handler not implemented"); 298 return TX80211_ENOHANDLER; 299 } 276 300 277 301 return (in_tx->setfuncmode_callthrough) (in_tx, in_fmode); … … 281 305 { 282 306 if (in_tx->setchan_callthrough == NULL) 283 return TX80211_ENOHANDLER; 307 { 308 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 309 "Setchannel callthrough handler not implemented"); 310 return TX80211_ENOHANDLER; 311 } 284 312 285 313 return (in_tx->setchan_callthrough) (in_tx, in_chan); 286 314 } 287 315 288 int tx80211_getchan (struct tx80211 *in_tx)316 int tx80211_getchannel(struct tx80211 *in_tx) 289 317 { 290 318 if (in_tx->getchan_callthrough == NULL) 291 return TX80211_ENOHANDLER; 319 { 320 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 321 "Getchannel callthrough handler not implemented"); 322 return TX80211_ENOHANDLER; 323 } 292 324 293 325 return (in_tx->getchan_callthrough) (in_tx); … … 296 328 int tx80211_txpacket(struct tx80211 *in_tx, struct tx80211_packet *in_packet) 297 329 { 298 if (in_tx->txpacket_callthrough == NULL) 299 return TX80211_ENOHANDLER; 330 if (in_tx->txpacket_callthrough == NULL) 331 { 332 snprintf(in_tx->errstr, TX80211_STATUS_MAX, 333 "txpacket callthrough handler not implemented"); 334 return TX80211_ENOHANDLER; 335 } 300 336 301 337 return (in_tx->txpacket_callthrough) (in_tx, in_packet); 302 338 } 339 -
trunk/tx80211.h
r85 r86 55 55 int rate; 56 56 57 /* Error buffer */ 58 char errstr[TX80211_STATUS_MAX]; 59 57 60 /* Extra space for use by the driver code */ 58 61 void *extra; … … 84 87 /* Functional modes (you should probably be using these to set the mode 85 88 * instead of calling SetMode() directly. These modes can be combined 86 * if the card supports them, and the actual modes set will be */ 87 #define TX80211_FUNCMODE_ 89 * if the card supports them, and the actual modes set will be. It's 90 * possible that one mode will be able to perform other tasks (ie, some cards 91 * may support inject in monitor mode w/ no special tricks) but it's a wise 92 * idea to use the proper mode, INJMON, for that) */ 93 #define TX80211_FUNCMODE_RFMON 0 94 #define TX80211_FUNCMODE_INJECT 1 95 #define TX80211_FUNCMODE_INJMON 2 88 96 89 97 /* tx80211 device capabilities */ … … 253 261 int tx80211_resolvecard(const char *in_str); 254 262 263 /* Get the error string */ 264 char *tx80211_geterrstr(struct tx80211 *in_tx); 265 255 266 /* Create and assign a tx80211 system */ 256 267 int tx80211_init(struct tx80211 *in_tx, const char *in_ifname, int in_injector); -
trunk/wginject.c
r69 r86 49 49 in_tx->setchan_callthrough = &wginj_setchannel; 50 50 in_tx->txpacket_callthrough = &wginj_send; 51 in_tx->setfuncmode_callthrough = NULL; 51 52 52 53 return 0; -
trunk/wtinject.c
r68 r86 23 23 24 24 #include "wtinject.h" 25 #include "tx80211.h" 26 #include "tx80211_errno.h" 25 27 26 28 int wtinj_send(struct tx80211 *wtinj, struct tx80211_packet *in_pkt) … … 52 54 wtinj->raw_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); 53 55 54 if (wtinj->raw_fd < 0) 56 if (wtinj->raw_fd < 0) { 57 snprintf(wtinj->errstr, TX80211_STATUS_MAX, "no socket fd in tx descriptor"); 55 58 return -1; 59 } 56 60 57 61 memset(&if_req, 0, sizeof if_req); … … 60 64 err = ioctl(wtinj->raw_fd, SIOCGIFINDEX, &if_req); 61 65 if (err < 0) { 66 snprintf(wtinj->errstr, TX80211_STATUS_MAX, "SIOCGIFINDEX ioctl failed, %s", 67 strerror(errno)); 62 68 close(wtinj->raw_fd); 63 69 return -2; … … 70 76 err = bind(wtinj->raw_fd, (struct sockaddr *)&sa_ll, sizeof sa_ll); 71 77 if (err != 0) { 78 snprintf(wtinj->errstr, TX80211_STATUS_MAX, "bind() failed, %s", 79 strerror(errno)); 72 80 close(wtinj->raw_fd); 73 81 return -3; … … 85 93 { 86 94 /* wrapper for iwconfig_set_channel */ 87 char errstr[TX80211_STATUS_MAX]; /* Not used for now */ 88 return (iwconfig_set_channel(wtinj->ifname, errstr, channel)); 95 return (iwconfig_set_channel(wtinj->ifname, wtinj->errstr, channel)); 89 96 90 97 } … … 93 100 { 94 101 /* wrapper for iwconfig_get_channel */ 95 char errstr[TX80211_STATUS_MAX]; /* Not used for now */ 96 return (iwconfig_get_channel(wtinj->ifname, errstr)); 102 return (iwconfig_get_channel(wtinj->ifname, wtinj->errstr)); 97 103 98 104 } … … 101 107 { 102 108 /* wrapper for iwconfig_set_mode */ 103 char errstr[TX80211_STATUS_MAX]; /* Not used for now */ 104 return (iwconfig_set_mode(wtinj->ifname, errstr, mode)); 105 109 return (iwconfig_set_mode(wtinj->ifname, wtinj->errstr, mode)); 106 110 } 107 111 … … 109 113 { 110 114 /* wrapper for iwconfig_get_mode */ 111 char errstr[TX80211_STATUS_MAX]; /* Not used for now */ 112 return (iwconfig_get_mode(wtinj->ifname, errstr)); 115 return (iwconfig_get_mode(wtinj->ifname, wtinj->errstr)); 113 116 114 117 } 118 119 int wtinj_setfuncmode(struct tx80211 *wtinj, int funcmode) 120 { 121 /* All the iw* drivers use rfmon mode for injection so we just set it 122 * here the same */ 123 if (funcmode == TX80211_FUNCMODE_RFMON || 124 funcmode == TX80211_FUNCMODE_INJECT || 125 funcmode == TX80211_FUNCMODE_INJMON) { 126 return (iwconfig_set_mode(wtinj->ifname, wtinj->errstr, IW_MODE_MONITOR)); 127 } 128 129 /* Otherwise we don't have a handler */ 130 return TX80211_ENOHANDLER; 131 } 132 -
trunk/wtinject.h
r48 r86 62 62 int wtinj_setmode(struct tx80211 *wtinj, int mode); 63 63 int wtinj_getmode(struct tx80211 *wtinj); 64 int wtinj_setfuncmode(struct tx80211 *wtinj, int funcmode); 64 65 65 66 #endif
