PageRenderTime 343ms CodeModel.GetById 43ms RepoModel.GetById 0ms app.codeStats 0ms

/recipes/mamona/cx3110x-diablo-2.0.15/cx3110x.patch

https://github.com/crystalfontz/openembedded
Patch | 492 lines | 484 code | 8 blank | 0 comment | 0 complexity | 1ae4966f081fbf9e2063f746f8466798 MD5 | raw file
  1. diff -ru cx3110x-module-src-2.0.14.orig/src/sm_drv_ioctl_umac.c cx3110x-module-src-2.0.14/src/sm_drv_ioctl_umac.c
  2. --- cx3110x-module-src-2.0.14.orig/src/sm_drv_ioctl_umac.c 2007-09-25 13:02:17.000000000 -0300
  3. +++ cx3110x-module-src-2.0.14/src/sm_drv_ioctl_umac.c 2007-10-09 15:32:30.000000000 -0300
  4. @@ -88,8 +88,8 @@
  5. kfree(wrqu.data.pointer);
  6. }
  7. -void send_wpa_ie_event(struct net_device *dev, char * bss_addr,
  8. - char * wpa_ie, size_t wpa_ie_len, uint32_t event)
  9. +void send_wpa_ie_event(struct net_device *dev, char * wpa_ie,
  10. + size_t wpa_ie_len, uint32_t event)
  11. {
  12. union iwreq_data wrqu;
  13. uint32_t we_event;
  14. @@ -111,15 +111,12 @@
  15. return;
  16. }
  17. - wrqu.data.pointer = kzalloc(ETH_ALEN + 1 + wpa_ie_len, GFP_ATOMIC);
  18. + wrqu.data.pointer = kzalloc(wpa_ie_len, GFP_ATOMIC);
  19. if (!wrqu.data.pointer)
  20. return;
  21. - memcpy(wrqu.data.pointer, bss_addr, ETH_ALEN);
  22. - *((char *)(wrqu.data.pointer + ETH_ALEN)) = ':';
  23. - memcpy(wrqu.data.pointer + ETH_ALEN + 1, wpa_ie, wpa_ie_len);
  24. -
  25. - wrqu.data.length = ETH_ALEN + 1 + wpa_ie_len;
  26. + memcpy(wrqu.data.pointer, wpa_ie, wpa_ie_len);
  27. + wrqu.data.length = wpa_ie_len;
  28. wireless_send_event(dev, we_event, &wrqu, wrqu.data.pointer);
  29. kfree(wrqu.data.pointer);
  30. @@ -478,7 +475,7 @@
  31. if ((lp->link_state == DOT11_STATE_ASSOCING
  32. || lp->link_state == DOT11_STATE_ASSOC)
  33. && event)
  34. - send_wpa_ie_event(dev, bssid, wpa_ie, wpa_ie_len, event);
  35. + send_wpa_ie_event(dev, wpa_ie, wpa_ie_len, event);
  36. /* try to use existing entry */
  37. list_for_each_entry_safe(bss, safe, &lp->bss_wpa_list, list) {
  38. @@ -1928,6 +1925,435 @@
  39. (void *)&key, sizeof(struct obj_stakey));
  40. }
  41. +static int sm_drv_set_auth(struct net_device *dev,
  42. + struct iw_request_info *info,
  43. + union iwreq_data *wrqu, char *extra)
  44. +{
  45. + struct net_local *priv = netdev_priv(dev);
  46. + struct iw_param *param = &wrqu->param;
  47. + u32 authen = 0, dot1x = 0;
  48. + u32 exunencrypt = 0, privinvoked = 0, wpa = 0;
  49. + u32 old_wpa;
  50. + int ret = 0;
  51. +
  52. + DEBUG(DBG_IOCTL, "SET AUTH\n");
  53. +
  54. + /* first get the flags */
  55. + down(&priv->wpa_sem);
  56. + wpa = old_wpa = priv->wpa;
  57. + up(&priv->wpa_sem);
  58. + ret = sm_drv_oid_get(dev, DOT11_OID_AUTHENABLE,
  59. + (void *)&authen, sizeof(uint32_t));
  60. + ret |= sm_drv_oid_get(dev, DOT11_OID_PRIVACYINVOKED,
  61. + (void *)&privinvoked, sizeof(uint32_t));
  62. + ret |= sm_drv_oid_get(dev, DOT11_OID_EXUNENCRYPTED,
  63. + (void *)&exunencrypt, sizeof(uint32_t));
  64. + ret |= sm_drv_oid_get(dev, DOT11_OID_DOT1XENABLE,
  65. + (void *)&dot1x, sizeof(uint32_t));
  66. +
  67. + if (ret < 0)
  68. + goto out;
  69. +
  70. + switch (param->flags & IW_AUTH_INDEX) {
  71. + case IW_AUTH_CIPHER_PAIRWISE:
  72. + case IW_AUTH_CIPHER_GROUP:
  73. + case IW_AUTH_KEY_MGMT:
  74. + break;
  75. +
  76. + case IW_AUTH_WPA_ENABLED:
  77. + /* Do the same thing as IW_AUTH_WPA_VERSION */
  78. + if (param->value) {
  79. + wpa = DOT11_PRIV_INV_TKIP;
  80. + privinvoked = 1; /* For privacy invoked */
  81. + exunencrypt = 1; /* Filter out all unencrypted frames */
  82. + dot1x = 0x01; /* To enable eap filter */
  83. + authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
  84. + } else {
  85. + wpa = DOT11_PRIV_INV_NONE;
  86. + privinvoked = 0;
  87. + exunencrypt = 0; /* Do not filter un-encrypted data */
  88. + dot1x = 0;
  89. + }
  90. + break;
  91. +
  92. + case IW_AUTH_WPA_VERSION:
  93. + if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
  94. + wpa = DOT11_PRIV_INV_NONE;
  95. + privinvoked = 0;
  96. + exunencrypt = 0; /* Do not filter un-encrypted data */
  97. + dot1x = 0;
  98. + } else {
  99. + if (param->value & IW_AUTH_WPA_VERSION_WPA)
  100. + wpa = DOT11_PRIV_INV_TKIP;
  101. + else if (param->value & IW_AUTH_WPA_VERSION_WPA2)
  102. + wpa = DOT11_PRIV_INV_AES_CCMP;
  103. + privinvoked = 1; /* For privacy invoked */
  104. + exunencrypt = 1; /* Filter out all unencrypted frames */
  105. + dot1x = 0x01; /* To enable eap filter */
  106. + authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
  107. + }
  108. + break;
  109. +
  110. + case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  111. + /* dot1x should be the opposite of RX_UNENCRYPTED_EAPOL;
  112. + * turn off dot1x when allowing receipt of unencrypted EAPOL
  113. + * frames, turn on dot1x when receipt should be disallowed
  114. + */
  115. + dot1x = param->value ? 0 : 0x01;
  116. + break;
  117. +
  118. + case IW_AUTH_PRIVACY_INVOKED:
  119. + privinvoked = param->value ? 1 : 0;
  120. + break;
  121. +
  122. + case IW_AUTH_DROP_UNENCRYPTED:
  123. + exunencrypt = param->value ? 1 : 0;
  124. + break;
  125. +
  126. + case IW_AUTH_80211_AUTH_ALG:
  127. + if (param->value & IW_AUTH_ALG_SHARED_KEY) {
  128. + /* Only WEP uses _SK and _BOTH */
  129. + if (wpa > 0) {
  130. + ret = -EINVAL;
  131. + goto out;
  132. + }
  133. + authen = DOT11_AUTH_SK;
  134. + } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
  135. + authen = DOT11_AUTH_OS;
  136. + } else {
  137. + ret = -EINVAL;
  138. + goto out;
  139. + }
  140. + break;
  141. +
  142. + default:
  143. + return -EOPNOTSUPP;
  144. + }
  145. +
  146. + /* Set all the values */
  147. + down(&priv->wpa_sem);
  148. + priv->wpa = wpa;
  149. + up(&priv->wpa_sem);
  150. +
  151. + sm_drv_oid_set(dev, DOT11_OID_AUTHENABLE,
  152. + (void *)&authen, sizeof(uint32_t));
  153. + sm_drv_oid_set(dev, DOT11_OID_PRIVACYINVOKED,
  154. + (void *)&privinvoked, sizeof(uint32_t));
  155. + sm_drv_oid_set(dev, DOT11_OID_EXUNENCRYPTED,
  156. + (void *)&exunencrypt, sizeof(uint32_t));
  157. + sm_drv_oid_set(dev, DOT11_OID_DOT1XENABLE,
  158. + (void *)&dot1x, sizeof(uint32_t));
  159. +
  160. + out:
  161. + return ret;
  162. +}
  163. +
  164. +static int sm_drv_get_auth(struct net_device *dev,
  165. + struct iw_request_info *info,
  166. + union iwreq_data *wrqu, char *extra)
  167. +{
  168. + struct net_local *priv = netdev_priv(dev);
  169. + struct iw_param *param = &wrqu->param;
  170. + u32 authen = 0, dot1x = 0;
  171. + u32 exunencrypt = 0, privinvoked = 0, wpa = 0;
  172. + int ret = 0;
  173. +
  174. + DEBUG(DBG_IOCTL, "GET AUTH\n");
  175. +
  176. + /* first get the flags */
  177. + down(&priv->wpa_sem);
  178. + wpa = priv->wpa;
  179. + up(&priv->wpa_sem);
  180. +
  181. + switch (param->flags & IW_AUTH_INDEX) {
  182. + case IW_AUTH_CIPHER_PAIRWISE:
  183. + case IW_AUTH_CIPHER_GROUP:
  184. + case IW_AUTH_KEY_MGMT:
  185. + /*
  186. + * wpa_supplicant will control these internally
  187. + */
  188. + ret = -EOPNOTSUPP;
  189. + break;
  190. +
  191. + case IW_AUTH_WPA_VERSION:
  192. + switch (wpa) {
  193. + case DOT11_PRIV_INV_TKIP:
  194. + param->value = IW_AUTH_WPA_VERSION_WPA;
  195. + break;
  196. + case DOT11_PRIV_INV_AES_CCMP:
  197. + param->value = IW_AUTH_WPA_VERSION_WPA2;
  198. + break;
  199. + default:
  200. + param->value = IW_AUTH_WPA_VERSION_DISABLED;
  201. + break;
  202. + }
  203. + break;
  204. +
  205. + case IW_AUTH_DROP_UNENCRYPTED:
  206. + ret = sm_drv_oid_get(dev, DOT11_OID_EXUNENCRYPTED,
  207. + (void *)&exunencrypt, sizeof(uint32_t));
  208. + if (ret >= 0)
  209. + param->value = exunencrypt > 0 ? 1 : 0;
  210. + break;
  211. +
  212. + case IW_AUTH_80211_AUTH_ALG:
  213. + ret = sm_drv_oid_get(dev, DOT11_OID_AUTHENABLE,
  214. + (void *)&authen, sizeof(uint32_t));
  215. + if (ret >= 0) {
  216. + switch (authen) {
  217. + case DOT11_AUTH_OS:
  218. + param->value = IW_AUTH_ALG_OPEN_SYSTEM;
  219. + break;
  220. + case DOT11_AUTH_BOTH:
  221. + case DOT11_AUTH_SK:
  222. + param->value = IW_AUTH_ALG_SHARED_KEY;
  223. + case DOT11_AUTH_NONE:
  224. + default:
  225. + param->value = 0;
  226. + break;
  227. + }
  228. + }
  229. + break;
  230. +
  231. + case IW_AUTH_WPA_ENABLED:
  232. + param->value = wpa > 0 ? 1 : 0;
  233. + break;
  234. +
  235. + case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  236. + ret = sm_drv_oid_get(dev, DOT11_OID_DOT1XENABLE,
  237. + (void *)&dot1x, sizeof(uint32_t));
  238. + if (ret >= 0)
  239. + param->value = dot1x > 0 ? 1 : 0;
  240. + break;
  241. +
  242. + case IW_AUTH_PRIVACY_INVOKED:
  243. + ret = sm_drv_oid_get(dev, DOT11_OID_PRIVACYINVOKED,
  244. + (void *)&privinvoked, sizeof(uint32_t));
  245. + if (ret >= 0)
  246. + param->value = privinvoked > 0 ? 1 : 0;
  247. + break;
  248. +
  249. + default:
  250. + return -EOPNOTSUPP;
  251. + }
  252. + return ret;
  253. +}
  254. +
  255. +#define KEY_SIZE_WEP104 13 /* 104/128-bit WEP keys */
  256. +#define KEY_SIZE_WEP40 5 /* 40/64-bit WEP keys */
  257. +#define KEY_SIZE_TKIP 32 /* TKIP keys */
  258. +
  259. +static int sm_drv_set_encodeext(struct net_device *dev,
  260. + struct iw_request_info *info,
  261. + union iwreq_data *wrqu,
  262. + char *extra)
  263. +{
  264. + struct iw_point *encoding = &wrqu->encoding;
  265. + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  266. + int idx, alg = ext->alg, set_key = 1;
  267. + int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
  268. + int ret = 0;
  269. +
  270. + DEBUG(DBG_IOCTL, "SET ENCODEEXT\n");
  271. +
  272. + /* Determine and validate the key index */
  273. + idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
  274. + if (idx) {
  275. + if (idx < 0 || idx > 3)
  276. + return -EINVAL;
  277. + } else {
  278. + ret = sm_drv_oid_get(dev, DOT11_OID_DEFKEYID,
  279. + (void *)&idx, sizeof(uint32_t));
  280. + if (ret < 0)
  281. + goto out;
  282. + }
  283. +
  284. + if (encoding->flags & IW_ENCODE_DISABLED)
  285. + alg = IW_ENCODE_ALG_NONE;
  286. +
  287. + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
  288. + /* Only set transmit key index here, actual
  289. + * key is set below if needed.
  290. + */
  291. + ret = sm_drv_oid_set(dev, DOT11_OID_DEFKEYID,
  292. + (void *)&idx, sizeof(uint32_t));
  293. + set_key = ext->key_len > 0 ? 1 : 0;
  294. + }
  295. +
  296. + if (set_key) {
  297. + switch (alg) {
  298. + case IW_ENCODE_ALG_NONE:
  299. + break;
  300. + case IW_ENCODE_ALG_WEP: {
  301. + struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
  302. + memset(key.key, 0, sizeof(key.key));
  303. + if (ext->key_len > KEY_SIZE_WEP104) {
  304. + ret = -EINVAL;
  305. + goto out;
  306. + }
  307. + if (ext->key_len > KEY_SIZE_WEP40)
  308. + key.length = KEY_SIZE_WEP104;
  309. + else
  310. + key.length = KEY_SIZE_WEP40;
  311. + memcpy(key.key, ext->key, ext->key_len);
  312. + ret = sm_drv_oid_set(dev, DOT11_OID_DEFKEYID + idx + 1,
  313. + (void *)&key,
  314. + sizeof(struct obj_key));
  315. + break;
  316. + }
  317. + case IW_ENCODE_ALG_TKIP:
  318. + case IW_ENCODE_ALG_CCMP: {
  319. + struct obj_stakey key;
  320. + memset(key.key, 0, sizeof(key.key));
  321. + if (alg == IW_ENCODE_ALG_TKIP)
  322. + key.type = DOT11_PRIV_TKIP;
  323. + else
  324. + key.type = DOT11_PRIV_AES_CCMP;
  325. + memcpy(key.address, ext->addr.sa_data, ETH_ALEN);
  326. + key.length = ext->key_len;
  327. + key.keyid = idx;
  328. + key.ext = 0;
  329. + memcpy(key.key, ext->key, ext->key_len);
  330. + ret = sm_drv_oid_set(dev, DOT11_OID_STAKEY,
  331. + (void *)&key,
  332. + sizeof(struct obj_stakey));
  333. + break;
  334. + }
  335. + default:
  336. + return -EINVAL;
  337. + }
  338. +
  339. + if (ret < 0)
  340. + goto out;
  341. +
  342. + }
  343. +
  344. + /* Read the flags */
  345. + if (encoding->flags & IW_ENCODE_DISABLED) {
  346. + /* Encoding disabled,
  347. + * authen = DOT11_AUTH_OS;
  348. + * invoke = 0;
  349. + * exunencrypt = 0; */
  350. + }
  351. + if (encoding->flags & IW_ENCODE_OPEN) {
  352. + /* Encode but accept non-encoded packets. No auth */
  353. + invoke = 1;
  354. + }
  355. + if (encoding->flags & IW_ENCODE_RESTRICTED) {
  356. + /* Refuse non-encoded packets. Auth */
  357. + authen = DOT11_AUTH_BOTH;
  358. + invoke = 1;
  359. + exunencrypt = 1;
  360. + }
  361. +
  362. + /* do the change if requested */
  363. + if (encoding->flags & IW_ENCODE_MODE) {
  364. + sm_drv_oid_set(dev, DOT11_OID_AUTHENABLE,
  365. + (void *)&authen, sizeof(uint32_t));
  366. + sm_drv_oid_set(dev, DOT11_OID_PRIVACYINVOKED,
  367. + (void *)&invoke, sizeof(uint32_t));
  368. + sm_drv_oid_set(dev, DOT11_OID_EXUNENCRYPTED,
  369. + (void *)&exunencrypt, sizeof(uint32_t));
  370. + }
  371. +
  372. + out:
  373. + return ret;
  374. +}
  375. +
  376. +
  377. +static int sm_drv_get_encodeext(struct net_device *dev,
  378. + struct iw_request_info *info,
  379. + union iwreq_data *wrqu,
  380. + char *extra)
  381. +{
  382. + struct net_local *priv = netdev_priv(dev);
  383. + struct iw_point *encoding = &wrqu->encoding;
  384. + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  385. + int idx, max_key_len;
  386. + int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0, wpa = 0;
  387. + int ret = 0;
  388. +
  389. + DEBUG(DBG_IOCTL, "GET ENCODEEXT\n");
  390. +
  391. + /* first get the flags */
  392. + ret = sm_drv_oid_get(dev, DOT11_OID_AUTHENABLE,
  393. + (void *)&authen, sizeof(uint32_t));
  394. + ret |= sm_drv_oid_get(dev, DOT11_OID_PRIVACYINVOKED,
  395. + (void *)&invoke, sizeof(uint32_t));
  396. + ret |= sm_drv_oid_get(dev, DOT11_OID_EXUNENCRYPTED,
  397. + (void *)&exunencrypt, sizeof(uint32_t));
  398. + if (ret < 0)
  399. + goto out;
  400. +
  401. + max_key_len = encoding->length - sizeof(*ext);
  402. + if (max_key_len < 0)
  403. + return -EINVAL;
  404. +
  405. + idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
  406. + if (idx) {
  407. + if (idx < 0 || idx > 3)
  408. + return -EINVAL;
  409. + } else {
  410. + ret = sm_drv_oid_get(dev, DOT11_OID_DEFKEYID,
  411. + (void *)&idx, sizeof(uint32_t));
  412. + if (ret < 0)
  413. + goto out;
  414. + }
  415. +
  416. + encoding->flags = idx + 1;
  417. + memset(ext, 0, sizeof(*ext));
  418. +
  419. + switch (authen) {
  420. + case DOT11_AUTH_BOTH:
  421. + case DOT11_AUTH_SK:
  422. + wrqu->encoding.flags |= IW_ENCODE_RESTRICTED;
  423. + case DOT11_AUTH_OS:
  424. + default:
  425. + wrqu->encoding.flags |= IW_ENCODE_OPEN;
  426. + break;
  427. + }
  428. +
  429. + down(&priv->wpa_sem);
  430. + wpa = priv->wpa;
  431. + up(&priv->wpa_sem);
  432. +
  433. + if (authen == DOT11_AUTH_OS && !exunencrypt && !invoke && !wpa) {
  434. + /* No encryption */
  435. + ext->alg = IW_ENCODE_ALG_NONE;
  436. + ext->key_len = 0;
  437. + wrqu->encoding.flags |= IW_ENCODE_DISABLED;
  438. + } else {
  439. + struct obj_key *key;
  440. +
  441. + ret = sm_drv_oid_get(dev, DOT11_OID_DEFKEYID + idx + 1,
  442. + (void *)&key, sizeof(struct obj_key));
  443. + if (ret < 0)
  444. + goto out;
  445. + if (max_key_len < key->length) {
  446. + ret = -E2BIG;
  447. + goto out;
  448. + }
  449. + memcpy(ext->key, key->key, key->length);
  450. + ext->key_len = key->length;
  451. +
  452. + switch (key->type) {
  453. + case DOT11_PRIV_TKIP:
  454. + ext->alg = IW_ENCODE_ALG_TKIP;
  455. + break;
  456. + case DOT11_PRIV_AES_CCMP:
  457. + ext->alg = IW_ENCODE_ALG_CCMP;
  458. + break;
  459. + default:
  460. + case DOT11_PRIV_WEP:
  461. + ext->alg = IW_ENCODE_ALG_WEP;
  462. + break;
  463. + }
  464. + wrqu->encoding.flags |= IW_ENCODE_ENABLED;
  465. + }
  466. +
  467. + out:
  468. + return ret;
  469. +}
  470. /* Private handlers */
  471. @@ -2473,10 +2899,10 @@
  472. (iw_handler) NULL, /* -- hole -- */
  473. (iw_handler) sm_drv_set_genie, /* SIOCSIWGENIE*/
  474. (iw_handler) NULL, /* SIOCGIWGENIE */
  475. - (iw_handler) NULL, /* SIOCSIWAUTH */
  476. - (iw_handler) NULL, /* SIOCGIWAUTH */
  477. - (iw_handler) NULL, /* SIOCSIWENCODEEXT */
  478. - (iw_handler) NULL, /* SIOCGIWENCODEEXT */
  479. + (iw_handler) sm_drv_set_auth, /* SIOCSIWAUTH */
  480. + (iw_handler) sm_drv_get_auth, /* SIOCGIWAUTH */
  481. + (iw_handler) sm_drv_set_encodeext, /* SIOCSIWENCODEEXT */
  482. + (iw_handler) sm_drv_get_encodeext, /* SIOCGIWENCODEEXT */
  483. (iw_handler) sm_drv_set_pmk, /* SIOCSIWPMKSA */
  484. };