mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

815 lines
25 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/powerpc/linux24benh/port-orinoco-monitor-0.13e.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. --- orinoco-0.13e/drivers/net/wireless/hermes.c 2003-05-11 23:22:27.000000000 -0700
  20. +++ orinoco-0.13e-patched/drivers/net/wireless/hermes.c 2003-08-07 04:16:04.000000000 -0700
  21. @@ -183,6 +183,10 @@
  22. if (err)
  23. return err;
  24. + for ( k = 0; k < HERMES_NUMPORTS_MAX; k++) {
  25. + hw->port_enabled[k] = 0;
  26. + }
  27. +
  28. reg = hermes_read_regn(hw, EVSTAT);
  29. k = CMD_INIT_TIMEOUT;
  30. while ( (! (reg & HERMES_EV_CMD)) && k) {
  31. diff -aur orinoco-0.13e/hermes.h orinoco-0.13e-patched/hermes.h
  32. --- orinoco-0.13e/drivers/net/wireless/hermes.h 2003-05-11 23:22:27.000000000 -0700
  33. +++ orinoco-0.13e-patched/drivers/net/wireless/hermes.h 2003-08-07 04:16:04.000000000 -0700
  34. @@ -33,6 +33,10 @@
  35. #include <linux/if_ether.h>
  36. #include <asm/byteorder.h>
  37. +#define HFA384x_PORTTYPE_IBSS ((uint16_t)3)
  38. +#define HFA384x_WEPFLAGS_DISABLE_TXCRYPT (0x10)
  39. +#define HFA384x_WEPFLAGS_DISABLE_RXCRYPT (0x80)
  40. +
  41. /*
  42. * Limits and constants
  43. */
  44. @@ -149,6 +153,38 @@
  45. #define HERMES_MONITOR_DISABLE (0x000f)
  46. /*
  47. + * Configuration RIDs
  48. + */
  49. +
  50. +#define HERMES_RID_CNF_PORTTYPE (0xfc00)
  51. +#define HERMES_RID_CNF_CHANNEL (0xfc03)
  52. +#define HERMES_RID_CNF_PRISM2_WEP_ON (0xfc28)
  53. +
  54. +/*-- Status Fields --*/
  55. +#define HERMES_RXSTATUS_MSGTYPE (0xE000)
  56. +#define HERMES_RXSTATUS_MACPORT (0x0700)
  57. +#define HERMES_RXSTATUS_UNDECR (0x0002)
  58. +#define HERMES_RXSTATUS_FCSERR (0x0001)
  59. +
  60. +/*--------------------------------------------------------------------
  61. +Communication Frames: Test/Get/Set Field Values for Receive Frames
  62. +--------------------------------------------------------------------*/
  63. +#define HERMES_RXSTATUS_MSGTYPE_GET(value) (((value) & HERMES_RXSTATUS_MSGTYPE) >> 13)
  64. +#define HERMES_RXSTATUS_MSGTYPE_SET(value) ((value) << 13)
  65. +#define HERMES_RXSTATUS_MACPORT_GET(value) (((value) & HERMES_RXSTATUS_MACPORT) >> 8)
  66. +#define HERMES_RXSTATUS_MACPORT_SET(value) ((value) << 8)
  67. +#define HERMES_RXSTATUS_ISUNDECR(value) ((value) & HERMES_RXSTATUS_UNDECR)
  68. +#define HERMES_RXSTATUS_ISFCSERR(value) ((value) & HERMES_RXSTATUS_FCSERR)
  69. +
  70. +/*--------------------------------------------------------------------
  71. +Communication Frames: Field Masks for Receive Frames
  72. +--------------------------------------------------------------------*/
  73. +/*-- Offsets --------*/
  74. +#define HERMES_RX_DATA_LEN_OFF (44)
  75. +#define HERMES_RX_80211HDR_OFF (14)
  76. +#define HERMES_RX_DATA_OFF (60)
  77. +
  78. +/*
  79. * Frame structures and constants
  80. */
  81. @@ -286,6 +322,7 @@
  82. #define HERMES_32BIT_REGSPACING 1
  83. u16 inten; /* Which interrupts should be enabled? */
  84. + uint8_t port_enabled[HERMES_NUMPORTS_MAX];
  85. #ifdef HERMES_DEBUG_BUFFER
  86. struct hermes_debug_entry dbuf[HERMES_DEBUG_BUFSIZE];
  87. @@ -339,12 +376,14 @@
  88. static inline int hermes_enable_port(hermes_t *hw, int port)
  89. {
  90. + hw->port_enabled[port] = 1;
  91. return hermes_docmd_wait(hw, HERMES_CMD_ENABLE | (port << 8),
  92. 0, NULL);
  93. }
  94. static inline int hermes_disable_port(hermes_t *hw, int port)
  95. {
  96. + hw->port_enabled[port] = 0;
  97. return hermes_docmd_wait(hw, HERMES_CMD_DISABLE | (port << 8),
  98. 0, NULL);
  99. }
  100. diff -aur orinoco-0.13e/orinoco.c orinoco-0.13e-patched/orinoco.c
  101. --- orinoco-0.13e/drivers/net/wireless/orinoco.c 2003-05-11 23:22:27.000000000 -0700
  102. +++ orinoco-0.13e-patched/drivers/net/wireless/orinoco.c 2003-08-07 04:16:04.000000000 -0700
  103. @@ -1673,6 +1673,7 @@
  104. struct header_struct hdr;
  105. struct ethhdr *eh;
  106. int err;
  107. + struct ieee802_11_hdr hdr80211;
  108. rxfid = hermes_read_regn(hw, RXFID);
  109. @@ -1689,6 +1690,7 @@
  110. if (status & HERMES_RXSTAT_ERR) {
  111. if (status & HERMES_RXSTAT_UNDECRYPTABLE) {
  112. + if (dev->type != ARPHRD_ETHER) goto sniffing;
  113. wstats->discard.code++;
  114. DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n",
  115. dev->name);
  116. @@ -1699,7 +1701,7 @@
  117. stats->rx_errors++;
  118. goto drop;
  119. }
  120. -
  121. +sniffing:
  122. /* For now we ignore the 802.11 header completely, assuming
  123. that the card's firmware has handled anything vital */
  124. @@ -1730,6 +1732,11 @@
  125. goto drop;
  126. }
  127. + /* Now handle frame based on port# */
  128. + switch( HERMES_RXSTATUS_MACPORT_GET(status) )
  129. + {
  130. + case 0:
  131. +
  132. /* We need space for the packet data itself, plus an ethernet
  133. header, plus 2 bytes so we can align the IP header on a
  134. 32bit boundary, plus 1 byte so we can read in odd length
  135. @@ -1804,6 +1811,26 @@
  136. return;
  137. + case 7:
  138. + if ( ! HERMES_RXSTATUS_ISFCSERR(status) ) {
  139. + if (hermes_bap_pread(hw, IRQ_BAP, &hdr80211, sizeof(hdr80211),
  140. + rxfid, HERMES_RX_80211HDR_OFF)) {
  141. + stats->rx_errors++;
  142. + }
  143. + else {
  144. + /* Copy to wlansnif skb */
  145. + orinoco_int_rxmonitor( priv, rxfid, length, &desc, &hdr80211);
  146. + }
  147. + } else {
  148. + printk("Received monitor frame: FCSerr set\n");
  149. + }
  150. + break;
  151. + default:
  152. + printk("Received frame on unsupported port=%d\n",
  153. + HERMES_RXSTATUS_MACPORT_GET(status) );
  154. + break;
  155. + }
  156. +
  157. drop:
  158. stats->rx_dropped++;
  159. @@ -2446,6 +2473,24 @@
  160. return err;
  161. }
  162. +//#define SET_MAC_ADDRESS
  163. +#ifdef SET_MAC_ADDRESS
  164. +static int
  165. +orinoco_set_mac_address(struct net_device *dev, void *addr)
  166. +{
  167. + struct orinoco_private *priv = dev->priv;
  168. + struct sockaddr *mac = addr;
  169. +
  170. + /* Copy the address */
  171. + memcpy(dev->dev_addr, mac->sa_data, WLAN_ADDR_LEN);
  172. +
  173. + /* Reconfig the beast */
  174. + orinoco_reset(priv);
  175. +
  176. + return 0;
  177. +}
  178. +#endif /* SET_MAC_ADDRESS */
  179. +
  180. static void
  181. orinoco_tx_timeout(struct net_device *dev)
  182. {
  183. @@ -3598,6 +3643,173 @@
  184. return 0;
  185. }
  186. +/*----------------------------------------------------------------
  187. +* orinoco_wlansniff
  188. +*
  189. +* Start or stop sniffing.
  190. +*
  191. +* Arguments:
  192. +* wlandev wlan device structure
  193. +* msgp ptr to msg buffer
  194. +*
  195. +* Returns:
  196. +* 0 success and done
  197. +* <0 success, but we're waiting for something to finish.
  198. +* >0 an error occurred while handling the message.
  199. +* Side effects:
  200. +*
  201. +* Call context:
  202. +* process thread (usually)
  203. +* interrupt
  204. +----------------------------------------------------------------*/
  205. +static int orinoco_wlansniff(struct net_device *dev, struct iwreq *wrq)
  206. +{
  207. + struct orinoco_private *priv = dev->priv;
  208. +
  209. + hermes_t *hw = &(priv->hw);
  210. + hermes_response_t resp;
  211. + int result = 0;
  212. + uint16_t word;
  213. +
  214. + int *parms = (int *) wrq->u.name;
  215. + int enable = parms[0] > 0;
  216. + unsigned long flags;
  217. +
  218. + orinoco_lock(priv, &flags);
  219. +
  220. + switch (enable)
  221. + {
  222. + case P80211ENUM_truth_false:
  223. + /* Confirm that we're in monitor mode */
  224. + if ( dev->type == ARPHRD_ETHER ) {
  225. + result = -EFAULT;
  226. + }
  227. + /* Disable monitor mode */
  228. + word = HERMES_CMD_MONITOR | (HERMES_MONITOR_DISABLE << 8);
  229. + result = hermes_docmd_wait(hw, word, 0, &resp);
  230. +
  231. + if ( result ) break;
  232. +
  233. + /* Disable port 0 */
  234. + result = hermes_disable_port(hw, 0);
  235. + if ( result ) break;
  236. +
  237. + /* Clear the driver state */
  238. + dev->type = ARPHRD_ETHER;
  239. +
  240. + /* Restore the wepflags */ //Orinoco doesn't like this
  241. +/*
  242. + result = hermes_write_wordrec(hw, USER_BAP,
  243. + HERMES_RID_CNF_PRISM2_WEP_ON,
  244. + priv->presniff_wepflags);
  245. + if ( result ) break;
  246. +
  247. +*/
  248. + /* Set the port to its prior type and enable (if necessary) */
  249. + if (priv->presniff_port_type != 0 ) {
  250. + word = priv->presniff_port_type;
  251. + result = hermes_write_wordrec(hw, USER_BAP,
  252. + HERMES_RID_CNF_PORTTYPE, word);
  253. + if ( result ) break;
  254. +
  255. + /* Enable the port */
  256. + result = hermes_enable_port(hw, 0);
  257. + if ( result ) break;
  258. +
  259. + }
  260. +
  261. + break;
  262. + case P80211ENUM_truth_true:
  263. + /* Re-initialize the card before changing channel as advised at
  264. + * http://lists.samba.org/pipermail/wireless/2002-June/004491.html
  265. + * by Ian Goldberg. Implementation by Pat Swieskowski.
  266. + */
  267. +// __orinoco_down(dev);
  268. + hermes_set_irqmask(hw, 0);
  269. + hermes_init(hw);
  270. +// _orinoco_up(dev);
  271. + hermes_set_irqmask(hw, ORINOCO_INTEN);
  272. +/*
  273. + __orinoco_stop_irqs(priv);
  274. + hermes_reset(hw);
  275. + __orinoco_start_irqs(priv, HERMES_EV_RX | HERMES_EV_ALLOC |
  276. + HERMES_EV_TX | HERMES_EV_TXEXC |
  277. + HERMES_EV_WTERR | HERMES_EV_INFO |
  278. + HERMES_EV_INFDROP);
  279. +*/
  280. + /* Disable the port (if enabled), only check Port 0 */
  281. + if ( hw->port_enabled[0] ) {
  282. + /* Save macport 0 state */
  283. + result = hermes_read_wordrec(hw, USER_BAP,
  284. + HERMES_RID_CNF_PORTTYPE,
  285. + &(priv->presniff_port_type));
  286. + if ( result ) break;
  287. +
  288. + /* Save the wepflags state */
  289. + result = hermes_read_wordrec(hw, USER_BAP,
  290. + HERMES_RID_CNF_PRISM2_WEP_ON,
  291. + &(priv->presniff_wepflags));
  292. + if ( result ) break;
  293. + result = hermes_disable_port(hw, 0);
  294. + if ( result ) break;
  295. + }
  296. + else {
  297. + priv->presniff_port_type = 0;
  298. + }
  299. +
  300. + /* Set the channel we wish to sniff */
  301. + if (parms[1] > 0 && parms[1] < 15) {
  302. + word = parms[1];
  303. + result = hermes_write_wordrec(hw, USER_BAP,
  304. + HERMES_RID_CNF_CHANNEL, word);
  305. + } else {
  306. + result = -EFAULT;
  307. + }
  308. +
  309. + if ( result ) break;
  310. +
  311. + /* Set the port type to pIbss */
  312. + word = HFA384x_PORTTYPE_IBSS;
  313. + result = hermes_write_wordrec(hw, USER_BAP,
  314. + HERMES_RID_CNF_PORTTYPE, word);
  315. + if ( result ) break;
  316. +
  317. +/*
  318. + if ( (msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) &&
  319. + (msg->keepwepflags.data != P80211ENUM_truth_true)) {
  320. + // Set the wepflags for no decryption //Orinoco doesn't like this
  321. + word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT |
  322. + HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
  323. + result = hermes_write_wordrec(hw, USER_BAP,
  324. + HERMES_RID_CNF_PRISM2_WEP_ON, word); //won't work with the bits above
  325. + }
  326. + if ( result ) break;
  327. +
  328. +*/
  329. + /* Enable the port */
  330. + result = hermes_enable_port(hw, 0);
  331. + if ( result ) break;
  332. +
  333. + /* Enable monitor mode */
  334. + word = HERMES_CMD_MONITOR | (HERMES_MONITOR_ENABLE << 8);
  335. + result = hermes_docmd_wait(hw, word, 0, &resp);
  336. + if ( result ) break;
  337. +
  338. + /* Set the driver state */
  339. + /* Do we want the prism2 header? */
  340. + if (parms[0] == 1)
  341. + dev->type = ARPHRD_IEEE80211_PRISM;
  342. + else
  343. + dev->type = ARPHRD_IEEE80211;
  344. + break;
  345. + default:
  346. + result = -EFAULT;
  347. + break;
  348. + }
  349. + orinoco_unlock(priv, &flags);
  350. + return result;
  351. +}
  352. +
  353. static int
  354. orinoco_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  355. {
  356. @@ -3830,6 +4042,9 @@
  357. { SIOCIWFIRSTPRIV + 0x7, 0,
  358. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  359. "get_ibssport" },
  360. + { SIOCIWFIRSTPRIV + 0x8,
  361. + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
  362. + 0, "monitor" },
  363. { SIOCIWLASTPRIV, 0, 0, "dump_recs" },
  364. };
  365. @@ -3924,6 +4139,16 @@
  366. err = orinoco_ioctl_getibssport(dev, wrq);
  367. break;
  368. + case SIOCIWFIRSTPRIV + 0x8: /* set sniff (monitor) mode */
  369. + DEBUG(1, "%s: SIOCIWFIRSTPRIV + 0x8 (monitor)\n",
  370. + dev->name);
  371. + if (! capable(CAP_NET_ADMIN)) {
  372. + err = -EPERM;
  373. + break;
  374. + }
  375. + err = orinoco_wlansniff(dev, wrq);
  376. + break;
  377. +
  378. case SIOCIWLASTPRIV:
  379. err = orinoco_debug_dump_recs(dev);
  380. if (err)
  381. @@ -4146,6 +4371,9 @@
  382. dev->tx_timeout = orinoco_tx_timeout;
  383. dev->watchdog_timeo = HZ; /* 1 second timeout */
  384. dev->get_stats = orinoco_get_stats;
  385. +#ifdef SET_MAC_ADDRESS
  386. + dev->set_mac_address = orinoco_set_mac_address;
  387. +#endif /* SET_MAC_ADDRESS */
  388. dev->get_wireless_stats = orinoco_get_wireless_stats;
  389. dev->do_ioctl = orinoco_ioctl;
  390. dev->change_mtu = orinoco_change_mtu;
  391. @@ -4171,6 +4399,197 @@
  392. }
  393. +/*----------------------------------------------------------------
  394. +* orinoco_int_rxmonitor
  395. +*
  396. +* Helper function for int_rx. Handles monitor frames.
  397. +* Note that this function allocates space for the FCS and sets it
  398. +* to 0xffffffff. The hfa384x doesn't give us the FCS value but the
  399. +* higher layers expect it. 0xffffffff is used as a flag to indicate
  400. +* the FCS is bogus.
  401. +*
  402. +* Arguments:
  403. +* dev wlan device structure
  404. +* rxfid received FID
  405. +* rxdesc rx descriptor read from card in int_rx
  406. +*
  407. +* Returns:
  408. +* nothing
  409. +*
  410. +* Side effects:
  411. +* Allocates an skb and passes it up via the PF_PACKET interface.
  412. +* Call context:
  413. +* interrupt
  414. +----------------------------------------------------------------*/
  415. +void orinoco_int_rxmonitor( struct orinoco_private *dev, uint16_t rxfid, int len,
  416. + struct hermes_rx_descriptor *rxdesc, struct ieee802_11_hdr *hdr)
  417. +{
  418. + hermes_t *hw = &(dev->hw);
  419. + uint32_t hdrlen = 0;
  420. + uint32_t datalen = 0;
  421. + uint32_t skblen = 0;
  422. + p80211msg_lnxind_wlansniffrm_t *msg;
  423. + struct net_device_stats *stats = &dev->stats;
  424. +
  425. +
  426. + uint8_t *datap;
  427. + uint16_t fc;
  428. + struct sk_buff *skb;
  429. +
  430. + /* Don't forget the status, time, and data_len fields are in host order */
  431. + /* Figure out how big the frame is */
  432. + fc = le16_to_cpu(hdr->frame_ctl);
  433. + switch ( WLAN_GET_FC_FTYPE(fc) )
  434. + {
  435. + case WLAN_FTYPE_DATA:
  436. + if ( WLAN_GET_FC_TODS(fc) && WLAN_GET_FC_FROMDS(fc) ) {
  437. + hdrlen = WLAN_HDR_A4_LEN;
  438. + } else {
  439. + hdrlen = WLAN_HDR_A3_LEN;
  440. + }
  441. + datalen = len;
  442. + break;
  443. + case WLAN_FTYPE_MGMT:
  444. + hdrlen = WLAN_HDR_A3_LEN;
  445. + datalen = len;
  446. + break;
  447. + case WLAN_FTYPE_CTL:
  448. + switch ( WLAN_GET_FC_FSTYPE(fc) )
  449. + {
  450. + case WLAN_FSTYPE_PSPOLL:
  451. + case WLAN_FSTYPE_RTS:
  452. + case WLAN_FSTYPE_CFEND:
  453. + case WLAN_FSTYPE_CFENDCFACK:
  454. + hdrlen = 16;
  455. + break;
  456. + case WLAN_FSTYPE_CTS:
  457. + case WLAN_FSTYPE_ACK:
  458. + hdrlen = 10;
  459. + break;
  460. + }
  461. + datalen = 0;
  462. + break;
  463. + default:
  464. + printk("unknown frm: fc=0x%04x\n", fc);
  465. + return;
  466. + }
  467. +
  468. + /* Allocate an ind message+framesize skb */
  469. + skblen = sizeof(p80211msg_lnxind_wlansniffrm_t) +
  470. + hdrlen + datalen;
  471. +
  472. + /* sanity check the length */
  473. + if ( skblen >
  474. + (sizeof(p80211msg_lnxind_wlansniffrm_t) +
  475. + WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN) ) {
  476. + printk("overlen frm: len=%d\n",
  477. + skblen - sizeof(p80211msg_lnxind_wlansniffrm_t));
  478. + }
  479. +
  480. + if ( (skb = dev_alloc_skb(skblen)) == NULL ) {
  481. + printk("alloc_skb failed trying to allocate %d bytes\n", skblen);
  482. + return;
  483. + }
  484. +
  485. + /* only prepend the prism header if in the right mode */
  486. + if (dev->ndev->type != ARPHRD_IEEE80211_PRISM) {
  487. + skb_put(skb, skblen - sizeof(p80211msg_lnxind_wlansniffrm_t));
  488. + datap = skb->data;
  489. + } else {
  490. + skb_put(skb, skblen);
  491. + datap = skb->data + sizeof(p80211msg_lnxind_wlansniffrm_t);
  492. + msg = (p80211msg_lnxind_wlansniffrm_t*)skb->data;
  493. +
  494. + /* Initialize the message members */
  495. + msg->msgcode = DIDmsg_lnxind_wlansniffrm;
  496. + msg->msglen = sizeof(p80211msg_lnxind_wlansniffrm_t);
  497. + strcpy(msg->devname, dev->ndev->name);
  498. +
  499. + msg->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
  500. + msg->hosttime.status = 0;
  501. + msg->hosttime.len = 4;
  502. + msg->hosttime.data = jiffies;
  503. +
  504. + msg->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
  505. + msg->mactime.status = 0;
  506. + msg->mactime.len = 4;
  507. + msg->mactime.data = rxdesc->time;
  508. +
  509. + msg->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
  510. + msg->channel.status = P80211ENUM_msgitem_status_no_value;
  511. + msg->channel.len = 4;
  512. + msg->channel.data = 0;
  513. +
  514. + msg->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
  515. + msg->rssi.status = P80211ENUM_msgitem_status_no_value;
  516. + msg->rssi.len = 4;
  517. + msg->rssi.data = 0;
  518. +
  519. + msg->sq.did = DIDmsg_lnxind_wlansniffrm_sq;
  520. + msg->sq.status = P80211ENUM_msgitem_status_no_value;
  521. + msg->sq.len = 4;
  522. + msg->sq.data = 0;
  523. +
  524. + msg->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
  525. + msg->signal.status = 0;
  526. + msg->signal.len = 4;
  527. + msg->signal.data = rxdesc->signal;
  528. +
  529. + msg->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
  530. + msg->noise.status = 0;
  531. + msg->noise.len = 4;
  532. + msg->noise.data = rxdesc->silence;
  533. +
  534. + msg->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
  535. + msg->rate.status = 0;
  536. + msg->rate.len = 4;
  537. + msg->rate.data = rxdesc->rate / 5; /* set to 802.11 units */
  538. +
  539. + msg->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
  540. + msg->istx.status = 0;
  541. + msg->istx.len = 4;
  542. + msg->istx.data = P80211ENUM_truth_false;
  543. +
  544. + msg->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
  545. + msg->frmlen.status = 0;
  546. + msg->frmlen.len = 4;
  547. + msg->frmlen.data = hdrlen + datalen;
  548. + }
  549. +
  550. + /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */
  551. + memcpy( datap, &(hdr->frame_ctl), hdrlen);
  552. +
  553. + /* If any, copy the data from the card to the skb */
  554. + if ( datalen > 0 )
  555. + {
  556. + hermes_bap_pread(hw, IRQ_BAP, datap + hdrlen, (datalen+1)&~1,
  557. + rxfid, HERMES_RX_DATA_OFF);
  558. +
  559. + /* check for unencrypted stuff if WEP bit set. */
  560. + if (*(datap+1) & 0x40) // wep set
  561. + if ((*(datap+hdrlen) == 0xaa) && (*(datap+hdrlen+1) == 0xaa))
  562. + *(datap+1) &= 0xbf; // clear wep; it's the 802.2 header!
  563. + }
  564. +
  565. + /* pass it up via the PF_PACKET interface */
  566. + {
  567. + skb->dev = dev->ndev;
  568. + skb->dev->last_rx = jiffies;
  569. +
  570. + skb->mac.raw = skb->data ;
  571. + skb->ip_summed = CHECKSUM_NONE;
  572. + skb->pkt_type = PACKET_OTHERHOST;
  573. + skb->protocol = htons(ETH_P_80211_RAW); /* XXX ETH_P_802_2? */
  574. +
  575. + stats->rx_packets++;
  576. + stats->rx_bytes += skb->len;
  577. +
  578. + netif_rx(skb);
  579. + }
  580. +
  581. + return;
  582. +}
  583. +
  584. /********************************************************************/
  585. /* Module initialization */
  586. /********************************************************************/
  587. diff -aur orinoco-0.13e/orinoco.h orinoco-0.13e-patched/orinoco.h
  588. --- orinoco-0.13e/drivers/net/wireless/orinoco.h 2003-05-11 23:22:27.000000000 -0700
  589. +++ orinoco-0.13e-patched/drivers/net/wireless/orinoco.h 2003-08-07 04:16:04.000000000 -0700
  590. @@ -37,6 +37,20 @@
  591. /* To enable debug messages */
  592. //#define ORINOCO_DEBUG 3
  593. +#ifndef ETH_P_ECONET
  594. +#define ETH_P_ECONET 0x0018 /* needed for 2.2.x kernels */
  595. +#endif
  596. +
  597. +#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  598. +
  599. +#ifndef ARPHRD_IEEE80211
  600. +#define ARPHRD_IEEE80211 801 /* kernel 2.4.6 */
  601. +#endif
  602. +
  603. +#ifndef ARPHRD_IEEE80211_PRISM /* kernel 2.4.18 */
  604. +#define ARPHRD_IEEE80211_PRISM 802
  605. +#endif
  606. +
  607. #if (! defined (WIRELESS_EXT)) || (WIRELESS_EXT < 10)
  608. #error "orinoco driver requires Wireless extensions v10 or later."
  609. #endif /* (! defined (WIRELESS_EXT)) || (WIRELESS_EXT < 10) */
  610. @@ -54,6 +68,158 @@
  611. HERMES_EV_TXEXC | HERMES_EV_WTERR | HERMES_EV_INFO | \
  612. HERMES_EV_INFDROP )
  613. +#define WLAN_DEVNAMELEN_MAX 16
  614. +
  615. +/* message data item for INT, BOUNDEDINT, ENUMINT */
  616. +typedef struct p80211item_uint32
  617. +{
  618. + uint32_t did __attribute__ ((packed));
  619. + uint16_t status __attribute__ ((packed));
  620. + uint16_t len __attribute__ ((packed));
  621. + uint32_t data __attribute__ ((packed));
  622. +} __attribute__ ((packed)) p80211item_uint32_t;
  623. +
  624. +typedef struct p80211msg
  625. +{
  626. + uint32_t msgcode __attribute__ ((packed));
  627. + uint32_t msglen __attribute__ ((packed));
  628. + uint8_t devname[WLAN_DEVNAMELEN_MAX] __attribute__ ((packed));
  629. +} __attribute__ ((packed)) p80211msg_t;
  630. +
  631. +#define DIDmsg_lnxind_wlansniffrm 0x0041
  632. +#define DIDmsg_lnxind_wlansniffrm_hosttime 0x1041
  633. +#define DIDmsg_lnxind_wlansniffrm_mactime 0x2041
  634. +#define DIDmsg_lnxind_wlansniffrm_channel 0x3041
  635. +#define DIDmsg_lnxind_wlansniffrm_rssi 0x4041
  636. +#define DIDmsg_lnxind_wlansniffrm_sq 0x5041
  637. +#define DIDmsg_lnxind_wlansniffrm_signal 0x6041
  638. +#define DIDmsg_lnxind_wlansniffrm_noise 0x7041
  639. +#define DIDmsg_lnxind_wlansniffrm_rate 0x8041
  640. +#define DIDmsg_lnxind_wlansniffrm_istx 0x9041
  641. +#define DIDmsg_lnxind_wlansniffrm_frmlen 0xA041
  642. +
  643. +typedef struct p80211msg_lnxind_wlansniffrm
  644. +{
  645. + uint32_t msgcode;
  646. + uint32_t msglen;
  647. + uint8_t devname[WLAN_DEVNAMELEN_MAX];
  648. + p80211item_uint32_t hosttime;
  649. + p80211item_uint32_t mactime;
  650. + p80211item_uint32_t channel;
  651. + p80211item_uint32_t rssi;
  652. + p80211item_uint32_t sq;
  653. + p80211item_uint32_t signal;
  654. + p80211item_uint32_t noise;
  655. + p80211item_uint32_t rate;
  656. + p80211item_uint32_t istx;
  657. + p80211item_uint32_t frmlen;
  658. +} __attribute__ ((packed)) p80211msg_lnxind_wlansniffrm_t;
  659. +
  660. +#define P80211ENUM_truth_false 0
  661. +#define P80211ENUM_truth_true 1
  662. +#define P80211ENUM_resultcode_success 1
  663. +#define P80211ENUM_resultcode_invalid_parameters 2
  664. +#define P80211ENUM_resultcode_not_supported 3
  665. +#define P80211ENUM_resultcode_timeout 4
  666. +#define P80211ENUM_resultcode_too_many_req 5
  667. +#define P80211ENUM_resultcode_refused 6
  668. +#define P80211ENUM_resultcode_bss_already 7
  669. +#define P80211ENUM_resultcode_invalid_access 8
  670. +#define P80211ENUM_resultcode_invalid_mibattribute 9
  671. +#define P80211ENUM_resultcode_cant_set_readonly_mib 10
  672. +#define P80211ENUM_resultcode_implementation_failure 11
  673. +#define P80211ENUM_resultcode_cant_get_writeonly_mib 12
  674. +#define P80211ENUM_msgitem_status_data_ok 0
  675. +#define P80211ENUM_msgitem_status_no_value 1
  676. +#define P80211ENUM_msgitem_status_invalid_itemname 2
  677. +#define P80211ENUM_msgitem_status_invalid_itemdata 3
  678. +#define P80211ENUM_msgitem_status_missing_itemdata 4
  679. +#define P80211ENUM_msgitem_status_incomplete_itemdata 5
  680. +#define P80211ENUM_msgitem_status_invalid_msg_did 6
  681. +#define P80211ENUM_msgitem_status_invalid_mib_did 7
  682. +#define P80211ENUM_msgitem_status_missing_conv_func 8
  683. +#define P80211ENUM_msgitem_status_string_too_long 9
  684. +#define P80211ENUM_msgitem_status_data_out_of_range 10
  685. +#define P80211ENUM_msgitem_status_string_too_short 11
  686. +#define P80211ENUM_msgitem_status_missing_valid_func 12
  687. +#define P80211ENUM_msgitem_status_unknown 13
  688. +#define P80211ENUM_msgitem_status_invalid_did 14
  689. +#define P80211ENUM_msgitem_status_missing_print_func 15
  690. +
  691. +#define WLAN_GET_FC_FTYPE(n) (((n) & 0x0C) >> 2)
  692. +#define WLAN_GET_FC_FSTYPE(n) (((n) & 0xF0) >> 4)
  693. +#define WLAN_GET_FC_TODS(n) (((n) & 0x0100) >> 8)
  694. +#define WLAN_GET_FC_FROMDS(n) (((n) & 0x0200) >> 9)
  695. +
  696. +/*--- Sizes -----------------------------------------------*/
  697. +#define WLAN_ADDR_LEN 6
  698. +#define WLAN_CRC_LEN 4
  699. +#define WLAN_BSSID_LEN 6
  700. +#define WLAN_BSS_TS_LEN 8
  701. +#define WLAN_HDR_A3_LEN 24
  702. +#define WLAN_HDR_A4_LEN 30
  703. +#define WLAN_SSID_MAXLEN 32
  704. +#define WLAN_DATA_MAXLEN 2312
  705. +
  706. +/*--- Frame Control Field -------------------------------------*/
  707. +/* Frame Types */
  708. +#define WLAN_FTYPE_MGMT 0x00
  709. +#define WLAN_FTYPE_CTL 0x01
  710. +#define WLAN_FTYPE_DATA 0x02
  711. +
  712. +/* Frame subtypes */
  713. +/* Management */
  714. +#define WLAN_FSTYPE_ASSOCREQ 0x00
  715. +#define WLAN_FSTYPE_ASSOCRESP 0x01
  716. +#define WLAN_FSTYPE_REASSOCREQ 0x02
  717. +#define WLAN_FSTYPE_REASSOCRESP 0x03
  718. +#define WLAN_FSTYPE_PROBEREQ 0x04
  719. +#define WLAN_FSTYPE_PROBERESP 0x05
  720. +#define WLAN_FSTYPE_BEACON 0x08
  721. +#define WLAN_FSTYPE_ATIM 0x09
  722. +#define WLAN_FSTYPE_DISASSOC 0x0a
  723. +#define WLAN_FSTYPE_AUTHEN 0x0b
  724. +#define WLAN_FSTYPE_DEAUTHEN 0x0c
  725. +
  726. +/* Control */
  727. +#define WLAN_FSTYPE_PSPOLL 0x0a
  728. +#define WLAN_FSTYPE_RTS 0x0b
  729. +#define WLAN_FSTYPE_CTS 0x0c
  730. +#define WLAN_FSTYPE_ACK 0x0d
  731. +#define WLAN_FSTYPE_CFEND 0x0e
  732. +#define WLAN_FSTYPE_CFENDCFACK 0x0f
  733. +
  734. +/* Data */
  735. +#define WLAN_FSTYPE_DATAONLY 0x00
  736. +#define WLAN_FSTYPE_DATA_CFACK 0x01
  737. +#define WLAN_FSTYPE_DATA_CFPOLL 0x02
  738. +#define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
  739. +#define WLAN_FSTYPE_NULL 0x04
  740. +#define WLAN_FSTYPE_CFACK 0x05
  741. +#define WLAN_FSTYPE_CFPOLL 0x06
  742. +#define WLAN_FSTYPE_CFACK_CFPOLL 0x07
  743. +
  744. +/*----------------------------------------------------------------*/
  745. +/* Magic number, a quick test to see we're getting the desired struct */
  746. +
  747. +#define P80211_IOCTL_MAGIC (0x4a2d464dUL)
  748. +
  749. +/*================================================================*/
  750. +/* Types */
  751. +
  752. +/*----------------------------------------------------------------*/
  753. +/* A ptr to the following structure type is passed as the third */
  754. +/* argument to the ioctl system call when issuing a request to */
  755. +/* the p80211 module. */
  756. +
  757. +typedef struct p80211ioctl_req
  758. +{
  759. + char name[WLAN_DEVNAMELEN_MAX] __attribute__ ((packed));
  760. + void *data __attribute__ ((packed));
  761. + uint32_t magic __attribute__ ((packed));
  762. + uint16_t len __attribute__ ((packed));
  763. + uint32_t result __attribute__ ((packed));
  764. +} __attribute__ ((packed)) p80211ioctl_req_t;
  765. struct orinoco_private {
  766. void *card; /* Pointer to card dependent structure */
  767. @@ -116,6 +282,9 @@
  768. /* Configuration dependent variables */
  769. int port_type, createibss;
  770. int promiscuous, mc_count;
  771. +
  772. + uint16_t presniff_port_type;
  773. + uint16_t presniff_wepflags;
  774. };
  775. #ifdef ORINOCO_DEBUG
  776. @@ -163,4 +332,12 @@
  777. spin_unlock_irqrestore(&priv->lock, *flags);
  778. }
  779. +/*================================================================*/
  780. +/* Function Declarations */
  781. +
  782. +struct ieee802_11_hdr;
  783. +
  784. +void orinoco_int_rxmonitor( struct orinoco_private *dev, uint16_t rxfid, int len,
  785. + struct hermes_rx_descriptor *rxdesc, struct ieee802_11_hdr *hdr);
  786. +
  787. #endif /* _ORINOCO_H */