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.

796 lines
24 KiB

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