vs_host_action_response.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*====================================================================*
  2. Copyright (c) 2013,2021 Qualcomm Technologies, Inc.
  3. All Rights Reserved.
  4. Confidential and Proprietary - Qualcomm Technologies, Inc.
  5. ******************************************************************
  6. 2013 Qualcomm Atheros, Inc.
  7. *--------------------------------------------------------------------*/
  8. /*====================================================================*
  9. *
  10. * int vs_host_action_response (struct plc * plc);
  11. *
  12. * slac.h
  13. *
  14. *--------------------------------------------------------------------*/
  15. #include <stdint.h>
  16. #include <memory.h>
  17. #include "../plc/plc.h"
  18. #include "../tools/error.h"
  19. #include "../tools/memory.h"
  20. signed vs_host_action_response(struct plc * plc)
  21. {
  22. struct channel * channel = (struct channel *) (plc->channel);
  23. struct message * message = (struct message *) (plc->message);
  24. #ifndef __GNUC__
  25. #pragma pack (push,1)
  26. #endif
  27. struct __packed vs_host_action_ind
  28. {
  29. struct ethernet_hdr ethernet;
  30. struct qualcomm_hdr qualcomm;
  31. uint8_t MACTION;
  32. uint8_t MAJOR_VERSION;
  33. uint8_t MINOR_VERSION;
  34. uint8_t session_id;
  35. uint16_t outstanding_retries;
  36. uint16_t retrytimer_in10ms;
  37. };
  38. struct __packed vs_host_action_rsp
  39. {
  40. struct ethernet_hdr ethernet;
  41. struct qualcomm_hdr qualcomm;
  42. uint8_t MSTATUS;
  43. uint8_t MAJOR_VERSION;
  44. uint8_t MINOR_VERSION;
  45. uint8_t MACTION;
  46. uint8_t session_id;
  47. uint16_t outstanding_retries;
  48. }
  49. * response = (struct vs_host_action_rsp *) (message);
  50. #ifndef __GNUC__
  51. #pragma pack (pop)
  52. #endif
  53. struct vs_host_action_ind indication;
  54. memcpy(&indication, message, sizeof(struct vs_host_action_ind));
  55. memset (message, 0, sizeof (* message));
  56. memcpy(channel->peer, indication.ethernet.OSA, sizeof(channel->peer));
  57. response->MAJOR_VERSION = indication.MAJOR_VERSION;
  58. response->MINOR_VERSION = indication.MINOR_VERSION;
  59. response->MACTION = indication.MACTION;
  60. response->session_id = indication.session_id;
  61. response->outstanding_retries = indication.outstanding_retries;
  62. EthernetHeader (& response->ethernet, channel->peer, channel->host, channel->type);
  63. QualcommHeader (& response->qualcomm, 0, (VS_HOST_ACTION | MMTYPE_RSP));
  64. plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  65. if (SendMME (plc) <= 0)
  66. {
  67. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  68. return (-1);
  69. }
  70. return (0);
  71. }