Luis R. Rodriguez | 4bd43f5 | 2008-10-27 22:44:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2007-2008 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | /* */ |
| 17 | /* Module Name : wrap_sec.c */ |
| 18 | /* */ |
| 19 | /* Abstract */ |
| 20 | /* This module contains wrapper functions for CENC. */ |
| 21 | /* */ |
| 22 | /* NOTES */ |
| 23 | /* Platform dependent. */ |
| 24 | /* */ |
| 25 | /************************************************************************/ |
| 26 | |
| 27 | #include "oal_dt.h" |
| 28 | #include "usbdrv.h" |
| 29 | |
| 30 | #include <linux/netlink.h> |
| 31 | |
| 32 | #if WIRELESS_EXT > 12 |
| 33 | #include <net/iw_handler.h> |
| 34 | #endif |
| 35 | |
| 36 | #ifdef ZM_ENABLE_CENC |
| 37 | extern int zfLnxCencSendMsg(struct sock *netlink_sk, u_int8_t *msg, int len); |
| 38 | |
| 39 | u16_t zfLnxCencAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u16_t port) |
| 40 | { |
| 41 | struct usbdrv_private *macp = (struct usbdrv_private *)dev->priv; |
| 42 | struct zydas_cenc_sta_info cenc_info; |
| 43 | //struct sock *netlink_sk; |
| 44 | u8_t ie_len; |
| 45 | int ii; |
| 46 | |
| 47 | /* Create NETLINK socket */ |
| 48 | //netlink_sk = netlink_kernel_create(NETLINK_USERSOCK, NULL); |
| 49 | |
| 50 | if (macp->netlink_sk == NULL) |
| 51 | { |
| 52 | printk(KERN_ERR "NETLINK Socket is NULL\n"); |
| 53 | return -1; |
| 54 | } |
| 55 | |
| 56 | memset(&cenc_info, 0, sizeof(cenc_info)); |
| 57 | |
| 58 | //memcpy(cenc_info.gsn, vap->iv_cencmsk_keys.wk_txiv, ZM_CENC_IV_LEN); |
| 59 | zfiWlanQueryGSN(dev, cenc_info.gsn, port); |
| 60 | cenc_info.datalen += ZM_CENC_IV_LEN; |
| 61 | ie_len = body[1] + 2; |
| 62 | memcpy(cenc_info.wie, body, ie_len); |
| 63 | cenc_info.datalen += ie_len; |
| 64 | |
| 65 | memcpy(cenc_info.sta_mac, macAddr, 6); |
| 66 | cenc_info.msg_type = ZM_CENC_WAI_REQUEST; |
| 67 | cenc_info.datalen += 6 + 2; |
| 68 | |
| 69 | printk(KERN_ERR "===== zfwCencSendMsg, bodySize: %d =====\n", bodySize); |
| 70 | |
| 71 | for(ii = 0; ii < bodySize; ii++) |
| 72 | { |
| 73 | printk(KERN_ERR "%02x ", body[ii]); |
| 74 | |
| 75 | if ((ii & 0xf) == 0xf) |
| 76 | { |
| 77 | printk(KERN_ERR "\n"); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | zfLnxCencSendMsg(macp->netlink_sk, (u8_t *)&cenc_info, cenc_info.datalen+4); |
| 82 | |
| 83 | /* Close NETLINK socket */ |
| 84 | //sock_release(netlink_sk); |
| 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | #endif //ZM_ENABLE_CENC |
| 89 | |
| 90 | u8_t zfwCencHandleBeaconProbrespon(zdev_t* dev, u8_t *pWIEc, |
| 91 | u8_t *pPeerSSIDc, u8_t *pPeerAddrc) |
| 92 | { |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | u8_t zfwGetPktEncExemptionActionType(zdev_t* dev, zbuf_t* buf) |
| 97 | { |
| 98 | return ZM_ENCRYPTION_EXEMPT_NO_EXEMPTION; |
| 99 | } |
| 100 | |
| 101 | void copyToIntTxBuffer(zdev_t* dev, zbuf_t* buf, u8_t* src, |
| 102 | u16_t offset, u16_t length) |
| 103 | { |
| 104 | u16_t i; |
| 105 | |
| 106 | for(i=0; i<length;i++) |
| 107 | { |
| 108 | //zmw_tx_buf_writeb(dev, buf, offset+i, src[i]); |
| 109 | *(u8_t*)((u8_t*)buf->data+offset+i) = src[i]; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | u16_t zfwStaAddIeWpaRsn(zdev_t* dev, zbuf_t* buf, u16_t offset, u8_t frameType) |
| 114 | { |
Greg Kroah-Hartman | da3e890 | 2009-01-05 13:44:36 -0800 | [diff] [blame] | 115 | struct usbdrv_private *macp = dev->ml_priv; |
Luis R. Rodriguez | 4bd43f5 | 2008-10-27 22:44:22 -0700 | [diff] [blame] | 116 | //zm_msg1_mm(ZM_LV_0, "CWY - add wpaie content Length : ", macp->supIe[1]); |
| 117 | if (macp->supIe[1] != 0) |
| 118 | { |
| 119 | copyToIntTxBuffer(dev, buf, macp->supIe, offset, macp->supIe[1]+2); |
| 120 | //memcpy(buf->data[offset], macp->supIe, macp->supIe[1]+2); |
| 121 | offset += (macp->supIe[1]+2); |
| 122 | } |
| 123 | |
| 124 | return offset; |
| 125 | } |
| 126 | |
| 127 | /* Leave an empty line below to remove warning message on some compiler */ |