Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
| 19 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20 | * |
| 21 | * This file lim_ser_des_utils.cc contains the serializer/deserializer |
| 22 | * utility functions LIM uses while communicating with upper layer |
| 23 | * software entities |
| 24 | * Author: Chandra Modumudi |
| 25 | * Date: 10/20/02 |
| 26 | * History:- |
| 27 | * Date Modified by Modification Information |
| 28 | * -------------------------------------------------------------------- |
| 29 | */ |
| 30 | |
| 31 | #include "ani_system_defs.h" |
| 32 | #include "utils_api.h" |
| 33 | #include "lim_types.h" |
| 34 | #include "lim_utils.h" |
| 35 | #include "lim_ser_des_utils.h" |
| 36 | |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 37 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | /**--------------------------------------------------------------- |
| 39 | \fn lim_get_session_info |
| 40 | \brief This function returns the sessionId and transactionId |
| 41 | \ of a message. This assumes that the message structure |
| 42 | \ is of format: |
| 43 | \ uint16_t messageType |
| 44 | \ uint16_t messageLength |
| 45 | \ uint8_t sessionId |
| 46 | \ uint16_t transactionId |
Jeff Johnson | 348973e | 2018-11-22 16:51:12 -0800 | [diff] [blame] | 47 | \param mac - mac global structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 48 | \param *pBuf - pointer to the message buffer |
| 49 | \param sessionId - returned session id value |
| 50 | \param transactionId - returned transaction ID value |
| 51 | \return None |
| 52 | ------------------------------------------------------------------*/ |
| 53 | void |
Jeff Johnson | 9320c1e | 2018-12-02 13:09:20 -0800 | [diff] [blame^] | 54 | lim_get_session_info(struct mac_context *mac, uint8_t *pBuf, uint8_t *sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 55 | uint16_t *transactionId) |
| 56 | { |
| 57 | if (!pBuf) { |
Nishank Aggarwal | 51a803f | 2017-03-23 16:58:40 +0530 | [diff] [blame] | 58 | pe_err("NULL ptr received"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 59 | return; |
| 60 | } |
| 61 | |
| 62 | pBuf += sizeof(uint16_t); /* skip message type */ |
| 63 | pBuf += sizeof(uint16_t); /* skip message length */ |
| 64 | |
| 65 | *sessionId = *pBuf; /* get sessionId */ |
| 66 | pBuf++; |
| 67 | *transactionId = lim_get_u16(pBuf); /* get transactionId */ |
| 68 | |
| 69 | return; |
| 70 | } |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * lim_send_disassoc_frm_req_ser_des - called on receiving SME_DISASSOC_REQ |
| 74 | * @mac_ctx: pointer to mac context |
| 75 | * @disassoc_frm_req: pointer to structure sme_send_disassoc_frm_req |
| 76 | * |
| 77 | * function send's disassoc frame request on receiving SME_DISASSOC_REQ |
| 78 | * |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 79 | * return: QDF_STATUS_SUCCESS:Success Error value: Failure |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 80 | */ |
Jeff Johnson | 9320c1e | 2018-12-02 13:09:20 -0800 | [diff] [blame^] | 81 | QDF_STATUS lim_send_disassoc_frm_req_ser_des(struct mac_context *mac_ctx, |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 82 | struct sme_send_disassoc_frm_req *disassoc_frm_req, |
| 83 | uint8_t *buf) |
| 84 | { |
| 85 | A_INT16 len = 0; |
| 86 | |
| 87 | if (!disassoc_frm_req || !buf) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 88 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 89 | |
| 90 | disassoc_frm_req->msg_type = lim_get_u16(buf); |
| 91 | buf += sizeof(A_UINT16); |
| 92 | |
| 93 | len = disassoc_frm_req->length = lim_get_u16(buf); |
| 94 | buf += sizeof(A_UINT16); |
| 95 | |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 96 | if (len < (A_INT16) sizeof(A_UINT32)) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 97 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 98 | |
| 99 | /* skip message header */ |
| 100 | len -= sizeof(A_UINT32); |
| 101 | if (len < 0) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 102 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 103 | |
| 104 | /* Extract sessionID */ |
| 105 | disassoc_frm_req->session_id = *buf; |
| 106 | buf += sizeof(A_UINT8); |
| 107 | len -= sizeof(A_UINT8); |
| 108 | if (len < 0) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 109 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 110 | |
| 111 | /* Extract transactionid */ |
| 112 | disassoc_frm_req->trans_id = lim_get_u16(buf); |
| 113 | buf += sizeof(A_UINT16); |
| 114 | len -= sizeof(A_UINT16); |
| 115 | |
| 116 | if (len < 0) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 117 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 118 | |
| 119 | /* Extract peerMacAddr */ |
| 120 | qdf_mem_copy(disassoc_frm_req->peer_mac, buf, sizeof(tSirMacAddr)); |
| 121 | buf += sizeof(tSirMacAddr); |
| 122 | len -= sizeof(tSirMacAddr); |
| 123 | |
| 124 | if (len < 0) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 125 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 126 | |
| 127 | /* Extract reasonCode */ |
| 128 | disassoc_frm_req->reason = lim_get_u16(buf); |
| 129 | buf += sizeof(A_UINT16); |
| 130 | len -= sizeof(A_UINT16); |
| 131 | |
| 132 | if (len < 0) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 133 | return QDF_STATUS_E_FAILURE; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 134 | |
| 135 | disassoc_frm_req->wait_for_ack = *buf; |
| 136 | buf += sizeof(A_UINT8); |
| 137 | len -= sizeof(A_UINT8); |
| 138 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 139 | return QDF_STATUS_SUCCESS; |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 140 | } |