blob: e7819393017feb61b2ebfab73202f9e14ee3bab2 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * 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 Dhavali7090c5f2015-11-02 17:55:19 -080020 *
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, Ganesh3f2d02c2016-09-13 12:23:47 +053037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038/**---------------------------------------------------------------
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 Johnson348973e2018-11-22 16:51:12 -080047 \param mac - mac global structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048 \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 ------------------------------------------------------------------*/
53void
Jeff Johnson9320c1e2018-12-02 13:09:20 -080054lim_get_session_info(struct mac_context *mac, uint8_t *pBuf, uint8_t *sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055 uint16_t *transactionId)
56{
57 if (!pBuf) {
Nishank Aggarwal51a803f2017-03-23 16:58:40 +053058 pe_err("NULL ptr received");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059 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, Ganesh3f2d02c2016-09-13 12:23:47 +053071
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 Johnson0301ecb2018-06-29 09:36:23 -070079 * return: QDF_STATUS_SUCCESS:Success Error value: Failure
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053080 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080081QDF_STATUS lim_send_disassoc_frm_req_ser_des(struct mac_context *mac_ctx,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053082 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 Johnson0301ecb2018-06-29 09:36:23 -070088 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053089
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, Ganesh3f2d02c2016-09-13 12:23:47 +053096 if (len < (A_INT16) sizeof(A_UINT32))
Jeff Johnson0301ecb2018-06-29 09:36:23 -070097 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053098
99 /* skip message header */
100 len -= sizeof(A_UINT32);
101 if (len < 0)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700102 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530103
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 Johnson0301ecb2018-06-29 09:36:23 -0700109 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530110
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 Johnson0301ecb2018-06-29 09:36:23 -0700117 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530118
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 Johnson0301ecb2018-06-29 09:36:23 -0700125 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530126
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 Johnson0301ecb2018-06-29 09:36:23 -0700133 return QDF_STATUS_E_FAILURE;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530134
135 disassoc_frm_req->wait_for_ack = *buf;
136 buf += sizeof(A_UINT8);
137 len -= sizeof(A_UINT8);
138
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700139 return QDF_STATUS_SUCCESS;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530140}