@@ -163,14 +163,6 @@ static struct semaphore SemHandlePktResp;
static tstrConfigPktInfo gstrConfigPktInfo;
-static u8 g_seqno;
-
-static s16 g_wid_num = -1;
-
-static u16 Res_Len;
-
-static u8 g_oper_mode = SET_CFG;
-
/* WID Switches */
static tstrWID gastrWIDs[] = {
{WID_FIRMWARE_VERSION, WID_STR},
@@ -307,160 +299,6 @@ u16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID));
/*****************************************************************************/
/* Functions */
/*****************************************************************************/
-INLINE u8 ascii_hex_to_dec(u8 num)
-{
- if ((num >= '0') && (num <= '9'))
- return (num - '0');
- else if ((num >= 'A') && (num <= 'F'))
- return (10 + (num - 'A'));
- else if ((num >= 'a') && (num <= 'f'))
- return (10 + (num - 'a'));
-
- return INVALID;
-}
-
-INLINE u8 get_hex_char(u8 inp)
-{
- u8 *d2htab = "0123456789ABCDEF";
-
- return d2htab[inp & 0xF];
-}
-
-/* This function extracts the MAC address held in a string in standard format */
-/* into another buffer as integers. */
-INLINE u16 extract_mac_addr(char *str, u8 *buff)
-{
- *buff = 0;
- while (*str != '\0') {
- if ((*str == ':') || (*str == '-'))
- *(++buff) = 0;
- else
- *buff = (*buff << 4) + ascii_hex_to_dec(*str);
-
- str++;
- }
-
- return MAC_ADDR_LEN;
-}
-
-/* This function creates MAC address in standard format from a buffer of */
-/* integers. */
-INLINE void create_mac_addr(u8 *str, u8 *buff)
-{
- u32 i = 0;
- u32 j = 0;
-
- for (i = 0; i < MAC_ADDR_LEN; i++) {
- str[j++] = get_hex_char((u8)((buff[i] >> 4) & 0x0F));
- str[j++] = get_hex_char((u8)(buff[i] & 0x0F));
- str[j++] = ':';
- }
- str[--j] = '\0';
-}
-
-/* This function converts the IP address string in dotted decimal format to */
-/* unsigned integer. This functionality is similar to the library function */
-/* inet_addr() but is reimplemented here since I could not confirm that */
-/* inet_addr is platform independent. */
-/* ips=>IP Address String in dotted decimal format */
-/* ipn=>Pointer to IP Address in integer format */
-INLINE u8 conv_ip_to_int(u8 *ips, u32 *ipn)
-{
- u8 i = 0;
- u8 ipb = 0;
- *ipn = 0;
- /* Integer to string for each component */
- while (ips[i] != '\0') {
- if (ips[i] == '.') {
- *ipn = ((*ipn) << 8) | ipb;
- ipb = 0;
- } else {
- ipb = ipb * 10 + ascii_hex_to_dec(ips[i]);
- }
-
- i++;
- }
-
- /* The last byte of the IP address is read in here */
- *ipn = ((*ipn) << 8) | ipb;
-
- return 0;
-}
-
-/* This function converts the IP address from integer format to dotted */
-/* decimal string format. Alternative to std library fn inet_ntoa(). */
-/* ips=>Buffer to hold IP Address String dotted decimal format (Min 17B) */
-/* ipn=>IP Address in integer format */
-INLINE u8 conv_int_to_ip(u8 *ips, u32 ipn)
-{
- u8 i = 0;
- u8 ipb = 0;
- u8 cnt = 0;
- u8 ipbsize = 0;
-
- for (cnt = 4; cnt > 0; cnt--) {
- ipb = (ipn >> (8 * (cnt - 1))) & 0xFF;
-
- if (ipb >= 100)
- ipbsize = 2;
- else if (ipb >= 10)
- ipbsize = 1;
- else
- ipbsize = 0;
-
- switch (ipbsize) {
- case 2:
- ips[i++] = get_hex_char(ipb / 100);
- ipb %= 100;
-
- case 1:
- ips[i++] = get_hex_char(ipb / 10);
- ipb %= 10;
-
- default:
- ips[i++] = get_hex_char(ipb);
- }
-
- if (cnt > 1)
- ips[i++] = '.';
- }
-
- ips[i] = '\0';
-
- return i;
-}
-
-INLINE tenuWIDtype get_wid_type(u32 wid_num)
-{
- /* Check for iconfig specific WID types first */
- if ((wid_num == WID_BSSID) ||
- (wid_num == WID_MAC_ADDR) ||
- (wid_num == WID_IP_ADDRESS) ||
- (wid_num == WID_HUT_DEST_ADDR)) {
- return WID_ADR;
- }
-
- if ((WID_1X_SERV_ADDR == wid_num) ||
- (WID_STACK_IP_ADDR == wid_num) ||
- (WID_STACK_NETMASK_ADDR == wid_num)) {
- return WID_IP;
- }
-
- /* Next check for standard WID types */
- if (wid_num < 0x1000)
- return WID_CHAR;
- else if (wid_num < 0x2000)
- return WID_SHORT;
- else if (wid_num < 0x3000)
- return WID_INT;
- else if (wid_num < 0x4000)
- return WID_STR;
- else if (wid_num < 0x5000)
- return WID_BIN_DATA;
-
- return WID_UNDEF;
-}
-
/* This function extracts the beacon period field from the beacon or probe */
/* response frame. */
@@ -500,14 +338,6 @@ INLINE u32 get_beacon_timestamp_hi(u8 *data)
return time_stamp;
}
-/* This function extracts the 'frame type' bits from the MAC header of the */
-/* input frame. */
-/* Returns the value in the LSB of the returned value. */
-INLINE tenuBasicFrmType get_type(u8 *header)
-{
- return ((tenuBasicFrmType)(header[0] & 0x0C));
-}
-
/* This function extracts the 'frame type and sub type' bits from the MAC */
/* header of the input frame. */
/* Returns the value in the LSB of the returned value. */
@@ -1058,887 +888,6 @@ s32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults)
}
#endif
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessCharWid */
-/* */
-/* Description : This function processes a WID of type WID_CHAR and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Value to set */
-/* */
-/* Globals : */
-/* */
-/* Processing : */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessCharWid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, s8 *ps8WidVal)
-{
- u8 *pu8val = (u8 *)ps8WidVal;
- u8 u8val = 0;
- s32 s32PktLen = *ps32PktLen;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set CHAR val 0x%x ,NULL structure\n", u8val);
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid >> 8) & 0xFF;
- if (g_oper_mode == SET_CFG) {
- u8val = *pu8val;
-
- /* Length */
- pcPacket[s32PktLen++] = sizeof(u8);
-
-
- /* Value */
- pcPacket[s32PktLen++] = u8val;
- }
- *ps32PktLen = s32PktLen;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessShortWid */
-/* */
-/* Description : This function processes a WID of type WID_SHORT and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Value to set */
-/* */
-/* Globals : */
-/* */
-/* Processing : */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessShortWid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, s8 *ps8WidVal)
-{
- u16 *pu16val = (u16 *)ps8WidVal;
- u16 u16val = 0;
- s32 s32PktLen = *ps32PktLen;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set SHORT val 0x%x ,NULL structure\n", u16val);
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
-
- if (g_oper_mode == SET_CFG) {
- u16val = *pu16val;
-
- /* Length */
- pcPacket[s32PktLen++] = sizeof(u16);
-
- /* Value */
- pcPacket[s32PktLen++] = (u8)(u16val & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u16val >> 8) & 0xFF);
- }
- *ps32PktLen = s32PktLen;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessIntWid */
-/* */
-/* Description : This function processes a WID of type WID_INT and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Value to set */
-/* */
-/* Globals : */
-/* */
-/* Processing : */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessIntWid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, s8 *ps8WidVal)
-{
- u32 *pu32val = (u32 *)ps8WidVal;
- u32 u32val = 0;
- s32 s32PktLen = *ps32PktLen;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set INT val 0x%x , NULL structure\n", u32val);
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
-
- if (g_oper_mode == SET_CFG) {
- u32val = *pu32val;
-
- /* Length */
- pcPacket[s32PktLen++] = sizeof(u32);
-
- /* Value */
- pcPacket[s32PktLen++] = (u8)(u32val & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u32val >> 8) & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u32val >> 16) & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u32val >> 24) & 0xFF);
- }
- *ps32PktLen = s32PktLen;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessIPwid */
-/* */
-/* Description : This function processes a WID of type WID_IP and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Value to set */
-/* */
-/* Globals : */
-/* */
-/* */
-/* Processing : */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessIPwid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, u8 *pu8ip)
-{
- u32 u32val = 0;
- s32 s32PktLen = *ps32PktLen;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set IP Addr , NULL structure\n");
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
-
- if (g_oper_mode == SET_CFG) {
- /* Length */
- pcPacket[s32PktLen++] = sizeof(u32);
-
- /* Convert the IP Address String to Integer */
- conv_ip_to_int(pu8ip, &u32val);
-
- /* Value */
- pcPacket[s32PktLen++] = (u8)(u32val & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u32val >> 8) & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u32val >> 16) & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u32val >> 24) & 0xFF);
- }
- *ps32PktLen = s32PktLen;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessStrWid */
-/* */
-/* Description : This function processes a WID of type WID_STR and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Value to set */
-/* */
-/* Globals : */
-/* */
-/* Processing : */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessStrWid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, u8 *pu8val, s32 s32ValueSize)
-{
- u16 u16MsgLen = 0;
- u16 idx = 0;
- s32 s32PktLen = *ps32PktLen;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set STR val, NULL structure\n");
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
-
- if (g_oper_mode == SET_CFG) {
- /* Message Length */
- u16MsgLen = (u16)s32ValueSize;
-
- /* Length */
- pcPacket[s32PktLen++] = (u8)u16MsgLen;
-
- /* Value */
- for (idx = 0; idx < u16MsgLen; idx++)
- pcPacket[s32PktLen++] = pu8val[idx];
- }
- *ps32PktLen = s32PktLen;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessAdrWid */
-/* */
-/* Description : This function processes a WID of type WID_ADR and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Value to set */
-/* */
-/* Globals : */
-/* */
-/* Processing : */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessAdrWid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, u8 *pu8val)
-{
- u16 u16MsgLen = 0;
- s32 s32PktLen = *ps32PktLen;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set Addr WID, NULL structure\n");
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
-
- if (g_oper_mode == SET_CFG) {
- /* Message Length */
- u16MsgLen = MAC_ADDR_LEN;
-
- /* Length */
- pcPacket[s32PktLen++] = (u8)u16MsgLen;
-
- /* Value */
- extract_mac_addr(pu8val, pcPacket + s32PktLen);
- s32PktLen += u16MsgLen;
- }
- *ps32PktLen = s32PktLen;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ProcessBinWid */
-/* */
-/* Description : This function processes a WID of type WID_BIN_DATA and */
-/* updates the cfg packet with the supplied value. */
-/* */
-/* Inputs : 1) Pointer to WID cfg structure */
-/* 2) Name of file containing the binary data in text mode */
-/* */
-/* Globals : */
-/* */
-/* Processing : The binary data is expected to be supplied through a */
-/* file in text mode. This file is expected to be in the */
-/* finject format. It is parsed, converted to binary format */
-/* and copied into g_cfg_pkt for further processing. This */
-/* is obviously a round-about way of processing involving */
-/* multiple (re)conversions between bin & ascii formats. */
-/* But it is done nevertheless to retain uniformity and for */
-/* ease of debugging. */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : None */
-/* */
-
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-void ProcessBinWid(char *pcPacket, s32 *ps32PktLen,
- tstrWID *pstrWID, u8 *pu8val, s32 s32ValueSize)
-{
- u16 u16MsgLen = 0;
- u16 idx = 0;
- s32 s32PktLen = *ps32PktLen;
- u8 u8checksum = 0;
-
- if (pstrWID == NULL) {
- PRINT_WRN(CORECONFIG_DBG, "Can't set BIN val, NULL structure\n");
- return;
- }
-
- /* WID */
- pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
- pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
-
- if (g_oper_mode == SET_CFG) {
- /* Message Length */
- u16MsgLen = (u16)s32ValueSize;
-
- /* Length */
- /* pcPacket[s32PktLen++] = (u8)u16MsgLen; */
- pcPacket[s32PktLen++] = (u8)(u16MsgLen & 0xFF);
- pcPacket[s32PktLen++] = (u8)((u16MsgLen >> 8) & 0xFF);
-
- /* Value */
- for (idx = 0; idx < u16MsgLen; idx++)
- pcPacket[s32PktLen++] = pu8val[idx];
-
- /* checksum */
- for (idx = 0; idx < u16MsgLen; idx++)
- u8checksum += pcPacket[MSG_HEADER_LEN + idx + 4];
-
- pcPacket[s32PktLen++] = u8checksum;
- }
- *ps32PktLen = s32PktLen;
-}
-
-
-/*****************************************************************************/
-/* */
-/* Function Name : further_process_response */
-/* */
-/* Description : This function parses the response frame got from the */
-/* device. */
-/* */
-/* Inputs : 1) The received response frame */
-/* 2) WID */
-/* 3) WID Length */
-/* 4) Output file handle */
-/* 5) Process Wid Number(i.e wid from --widn switch) */
-/* 6) Index the array in the Global Wid Structure. */
-/* */
-/* Globals : g_wid_num, gastrWIDs */
-/* */
-/* Processing : This function parses the response of the device depending*/
-/* WID type and writes it to the output file in Hex or */
-/* decimal notation depending on the --getx or --get switch.*/
-/* */
-/* Outputs : None */
-/* */
-/* Returns : 0 on Success & -2 on Failure */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2009 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-s32 further_process_response(u8 *resp,
- u16 u16WIDid,
- u16 cfg_len,
- bool process_wid_num,
- u32 cnt,
- tstrWID *pstrWIDresult)
-{
- u32 retval = 0;
- u32 idx = 0;
- u8 cfg_chr = 0;
- u16 cfg_sht = 0;
- u32 cfg_int = 0;
- u8 cfg_str[256] = {0};
- tenuWIDtype enuWIDtype = WID_UNDEF;
-
- if (process_wid_num)
- enuWIDtype = get_wid_type(g_wid_num);
- else
- enuWIDtype = gastrWIDs[cnt].enuWIDtype;
-
-
- switch (enuWIDtype) {
- case WID_CHAR:
- cfg_chr = resp[idx];
- /*Set local copy of WID*/
- *(pstrWIDresult->ps8WidVal) = cfg_chr;
- break;
-
- case WID_SHORT:
- {
- u16 *pu16val = (u16 *)(pstrWIDresult->ps8WidVal);
-
- cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]);
- /*Set local copy of WID*/
- /* pstrWIDresult->ps8WidVal = (s8*)(s32)cfg_sht; */
- *pu16val = cfg_sht;
- break;
- }
-
- case WID_INT:
- {
- u32 *pu32val = (u32 *)(pstrWIDresult->ps8WidVal);
-
- cfg_int = MAKE_WORD32(
- MAKE_WORD16(resp[idx], resp[idx + 1]),
- MAKE_WORD16(resp[idx + 2], resp[idx + 3])
- );
- /*Set local copy of WID*/
- /* pstrWIDresult->ps8WidVal = (s8*)cfg_int; */
- *pu32val = cfg_int;
- break;
- }
-
- case WID_STR:
- memcpy(cfg_str, resp + idx, cfg_len);
- /* cfg_str[cfg_len] = '\0'; //mostafa: no need currently for NULL termination */
- if (pstrWIDresult->s32ValueSize >= cfg_len) {
- memcpy(pstrWIDresult->ps8WidVal, cfg_str, cfg_len); /* mostafa: no need currently for the extra NULL byte */
- pstrWIDresult->s32ValueSize = cfg_len;
- } else {
- PRINT_ER("allocated WID buffer length is smaller than the received WID Length\n");
- retval = -2;
- }
-
- break;
-
- case WID_ADR:
- create_mac_addr(cfg_str, resp + idx);
-
- strncpy(pstrWIDresult->ps8WidVal, cfg_str, strlen(cfg_str));
- pstrWIDresult->ps8WidVal[strlen(cfg_str)] = '\0';
- break;
-
- case WID_IP:
- cfg_int = MAKE_WORD32(
- MAKE_WORD16(resp[idx], resp[idx + 1]),
- MAKE_WORD16(resp[idx + 2], resp[idx + 3])
- );
- conv_int_to_ip(cfg_str, cfg_int);
- break;
-
- case WID_BIN_DATA:
- if (pstrWIDresult->s32ValueSize >= cfg_len) {
- memcpy(pstrWIDresult->ps8WidVal, resp + idx, cfg_len);
- pstrWIDresult->s32ValueSize = cfg_len;
- } else {
- PRINT_ER("Allocated WID buffer length is smaller than the received WID Length Err(%d)\n", retval);
- retval = -2;
- }
- break;
-
- default:
- PRINT_ER("ERROR: Check config database: Error(%d)\n", retval);
- retval = -2;
- break;
- }
-
- return retval;
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ParseResponse */
-/* */
-/* Description : This function parses the command-line options and */
-/* creates the config packets which can be sent to the WLAN */
-/* station. */
-/* */
-/* Inputs : 1) The received response frame */
-/* */
-/* Globals : g_opt_list, gastrWIDs */
-/* */
-/* Processing : This function parses the options and creates different */
-/* types of packets depending upon the WID-type */
-/* corresponding to the option. */
-/* */
-/* Outputs : None */
-/* */
-/* Returns : 0 on Success & -1 on Failure */
-/* */
-/* Issues : None */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 08 01 2008 Ittiam Draft */
-/* */
-/*****************************************************************************/
-
-s32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult)
-{
- u16 u16RespLen = 0;
- u16 u16WIDid = 0;
- u16 cfg_len = 0;
- tenuWIDtype enuWIDtype = WID_UNDEF;
- bool num_wid_processed = false;
- u32 cnt = 0;
- u32 idx = 0;
- u32 ResCnt = 0;
- /* Check whether the received frame is a valid response */
- if (RESP_MSG_TYPE != resp[0]) {
- PRINT_INFO(CORECONFIG_DBG, "Received Message format incorrect.\n");
- return -1;
- }
-
- /* Extract Response Length */
- u16RespLen = MAKE_WORD16(resp[2], resp[3]);
- Res_Len = u16RespLen;
-
- for (idx = MSG_HEADER_LEN; idx < u16RespLen; ) {
- u16WIDid = MAKE_WORD16(resp[idx], resp[idx + 1]);
- cfg_len = resp[idx + 2];
- /* Incase of Bin Type Wid, the length is given by two byte field */
- enuWIDtype = get_wid_type(u16WIDid);
- if (WID_BIN_DATA == enuWIDtype) {
- cfg_len |= ((u16)resp[idx + 3] << 8) & 0xFF00;
- idx++;
- }
- idx += 3;
- if ((u16WIDid == g_wid_num) && (!num_wid_processed)) {
- num_wid_processed = true;
-
- if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, true, 0, &pstrWIDcfgResult[ResCnt])) {
- return -2;
- }
- ResCnt++;
- } else {
- for (cnt = 0; cnt < g_num_total_switches; cnt++) {
- if (gastrWIDs[cnt].u16WIDid == u16WIDid) {
- if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, false, cnt,
- &pstrWIDcfgResult[ResCnt])) {
- return -2;
- }
- ResCnt++;
- }
- }
- }
- idx += cfg_len;
- /* In case if BIN type Wid, The last byte of the Cfg packet is the */
- /* Checksum. The WID Length field does not accounts for the checksum. */
- /* The Checksum is discarded. */
- if (WID_BIN_DATA == enuWIDtype) {
- idx++;
- }
- }
-
- return 0;
-}
-
-/**
- * @brief parses the write response [just detects its status: success or failure]
- * @details
- * @param[in] pu8RespBuffer The Response to be parsed
- * @return Error code indicating Write Operation status:
- * WRITE_RESP_SUCCESS (1) => Write Success.
- * WILC_FAIL (-100) => Write Failure.
- * @note
- * @author Ittiam
- * @date 11 Aug 2009
- * @version 1.0
- */
-
-s32 ParseWriteResponse(u8 *pu8RespBuffer)
-{
- s32 s32Error = WILC_FAIL;
- u16 u16WIDtype = (u16)WID_NIL;
-
- /* Check whether the received frame is a valid response */
- if (RESP_MSG_TYPE != pu8RespBuffer[0]) {
- PRINT_ER("Received Message format incorrect.\n");
- return WILC_FAIL;
- }
-
- u16WIDtype = MAKE_WORD16(pu8RespBuffer[4], pu8RespBuffer[5]);
-
- /* Check for WID_STATUS ID and then check the length and status value */
- if ((u16WIDtype == WID_STATUS) &&
- (pu8RespBuffer[6] == 1) &&
- (pu8RespBuffer[7] == WRITE_RESP_SUCCESS)) {
- s32Error = WRITE_RESP_SUCCESS;
- return s32Error;
- }
-
- /* If the length or status are not as expected return failure */
- s32Error = WILC_FAIL;
- return s32Error;
-
-}
-
-/**
- * @brief creates the header of the Configuration Packet
- * @details
- * @param[in,out] pcpacket The Configuration Packet
- * @param[in,out] ps32PacketLength Length of the Configuration Packet
- * @return Error code indicating success/failure
- * @note
- * @author aismail
- * @date 18 Feb 2012
- * @version 1.0
- */
-
-s32 CreatePacketHeader(char *pcpacket, s32 *ps32PacketLength)
-{
- s32 s32Error = WILC_SUCCESS;
- u16 u16MsgLen = (u16)(*ps32PacketLength);
- u16 u16MsgInd = 0;
-
- /* The format of the message is: */
- /* +-------------------------------------------------------------------+ */
- /* | Message Type | Message ID | Message Length |Message body | */
- /* +-------------------------------------------------------------------+ */
- /* | 1 Byte | 1 Byte | 2 Bytes | Message Length - 4 | */
- /* +-------------------------------------------------------------------+ */
-
- /* The format of a message body of a message type 'W' is: */
- /* +-------------------------------------------------------------------+ */
- /* | WID0 | WID0 Length | WID0 Value | ......................... | */
- /* +-------------------------------------------------------------------+ */
- /* | 2 Bytes | 1 Byte | WID0 Length | ......................... | */
- /* +-------------------------------------------------------------------+ */
-
-
-
- /* Message Type */
- if (g_oper_mode == SET_CFG)
- pcpacket[u16MsgInd++] = WRITE_MSG_TYPE;
- else
- pcpacket[u16MsgInd++] = QUERY_MSG_TYPE;
-
- /* Sequence Number */
- pcpacket[u16MsgInd++] = g_seqno++;
-
- /* Message Length */
- pcpacket[u16MsgInd++] = (u8)(u16MsgLen & 0xFF);
- pcpacket[u16MsgInd++] = (u8)((u16MsgLen >> 8) & 0xFF);
-
- *ps32PacketLength = u16MsgLen;
-
- return s32Error;
-}
-
-/**
- * @brief creates Configuration packet based on the Input WIDs
- * @details
- * @param[in] pstrWIDs WIDs to be sent in the configuration packet
- * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet
- * @param[out] ps8packet The created Configuration Packet
- * @param[out] ps32PacketLength Length of the created Configuration Packet
- * @return Error code indicating success/failure
- * @note
- * @author
- * @date 1 Mar 2012
- * @version 1.0
- */
-
-s32 CreateConfigPacket(s8 *ps8packet, s32 *ps32PacketLength,
- tstrWID *pstrWIDs, u32 u32WIDsCount)
-{
- s32 s32Error = WILC_SUCCESS;
- u32 u32idx = 0;
- *ps32PacketLength = MSG_HEADER_LEN;
- for (u32idx = 0; u32idx < u32WIDsCount; u32idx++) {
- switch (pstrWIDs[u32idx].enuWIDtype) {
- case WID_CHAR:
- ProcessCharWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
- pstrWIDs[u32idx].ps8WidVal);
- break;
-
- case WID_SHORT:
- ProcessShortWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
- pstrWIDs[u32idx].ps8WidVal);
- break;
-
- case WID_INT:
- ProcessIntWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
- pstrWIDs[u32idx].ps8WidVal);
- break;
-
- case WID_STR:
- ProcessStrWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
- pstrWIDs[u32idx].ps8WidVal, pstrWIDs[u32idx].s32ValueSize);
- break;
-
- case WID_IP:
- ProcessIPwid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
- pstrWIDs[u32idx].ps8WidVal);
- break;
-
- case WID_BIN_DATA:
- ProcessBinWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
- pstrWIDs[u32idx].ps8WidVal, pstrWIDs[u32idx].s32ValueSize);
- break;
-
- default:
- PRINT_ER("ERROR: Check Config database\n");
- }
- }
-
- CreatePacketHeader(ps8packet, ps32PacketLength);
-
- return s32Error;
-}
-
-s32 ConfigWaitResponse(char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32BytesRead,
- bool bRespRequired)
-{
- s32 s32Error = WILC_SUCCESS;
- /*bug 3878*/
- /*removed to caller function*/
- /*gstrConfigPktInfo.pcRespBuffer = pcRespBuffer;
- * gstrConfigPktInfo.s32MaxRespBuffLen = s32MaxRespBuffLen;
- * gstrConfigPktInfo.bRespRequired = bRespRequired;*/
-
-
- if (gstrConfigPktInfo.bRespRequired) {
- down(&SemHandlePktResp);
-
- *ps32BytesRead = gstrConfigPktInfo.s32BytesRead;
- }
-
- memset((void *)(&gstrConfigPktInfo), 0, sizeof(tstrConfigPktInfo));
-
- return s32Error;
-}
-
-s32 ConfigProvideResponse(char *pcRespBuffer, s32 s32RespLen)
-{
- s32 s32Error = WILC_SUCCESS;
-
- if (gstrConfigPktInfo.bRespRequired) {
- if (s32RespLen <= gstrConfigPktInfo.s32MaxRespBuffLen) {
- memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, s32RespLen);
- gstrConfigPktInfo.s32BytesRead = s32RespLen;
- } else {
- memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, gstrConfigPktInfo.s32MaxRespBuffLen);
- gstrConfigPktInfo.s32BytesRead = gstrConfigPktInfo.s32MaxRespBuffLen;
- PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size\n");
- }
-
- up(&SemHandlePktResp);
- }
-
- return s32Error;
-}
-
-/**
- * @brief writes the received packet pu8RxPacket in the global Rx FIFO buffer
- * @details
- * @param[in] pu8RxPacket The received packet
- * @param[in] s32RxPacketLen Length of the received packet
- * @return Error code indicating success/failure
- * @note
- *
- * @author mabubakr
- * @date 1 Mar 2012
- * @version 1.0
- */
-
-s32 ConfigPktReceived(u8 *pu8RxPacket, s32 s32RxPacketLen)
-{
- s32 s32Error = WILC_SUCCESS;
- u8 u8MsgType = 0;
-
- u8MsgType = pu8RxPacket[0];
-
- switch (u8MsgType) {
- case 'R':
- ConfigProvideResponse(pu8RxPacket, s32RxPacketLen);
-
- break;
-
- case 'N':
- PRINT_INFO(CORECONFIG_DBG, "NetworkInfo packet received\n");
- NetworkInfoReceived(pu8RxPacket, s32RxPacketLen);
- break;
-
- case 'I':
- GnrlAsyncInfoReceived(pu8RxPacket, s32RxPacketLen);
- break;
-
- case 'S':
- host_int_ScanCompleteReceived(pu8RxPacket, s32RxPacketLen);
- break;
-
- default:
- PRINT_ER("ConfigPktReceived(): invalid received msg type at the Core Configurator\n");
- break;
- }
-
- return s32Error;
-}
-
/**
* @brief Deinitializes the Core Configurator
* @details