FirmwareMessage.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * signed FirmwareMessage (void const * memory);
  11. *
  12. * mme.h
  13. *
  14. * intercept and print Qualcomm Atheros vendor-specific VS_ARPC
  15. * messages on stdout; this message type is used for diagnostic
  16. * reporting and should not appear in released firmware;
  17. *
  18. * Contributor(s):
  19. * Charles Maier <cmaier@qca.qualcomm.com>
  20. *
  21. *--------------------------------------------------------------------*/
  22. #ifndef FIRMWAREMESSAGE_SOURCE
  23. #define FIRMWAREMESSAGE_SOURCE
  24. #include <stdint.h>
  25. #include <memory.h>
  26. #include "../plc/plc.h"
  27. #include "../tools/memory.h"
  28. #include "../tools/endian.h"
  29. #include "../mme/mme.h"
  30. signed FirmwareMessage (void const * memory)
  31. {
  32. const struct message * message = (const struct message *) (memory);
  33. #ifndef __GNUC__
  34. #pragma pack (push,1)
  35. #endif
  36. static struct qualcomm_hdr header_arpc =
  37. {
  38. 0,
  39. 0,
  40. {
  41. 0x00,
  42. 0xB0,
  43. 0x52
  44. }
  45. };
  46. struct __packed vs_arpc_indicate
  47. {
  48. struct ethernet_hdr ethernet;
  49. struct qualcomm_hdr qualcomm;
  50. uint16_t RDATALENGTH;
  51. uint8_t RDATAOFFSET;
  52. uint8_t RDATA [1];
  53. }
  54. * indicate = (struct vs_arpc_indicate *) (message);
  55. #ifndef __GNUC__
  56. #pragma pack (pop)
  57. #endif
  58. header_arpc.MMTYPE = HTOLE16 (VS_ARPC | MMTYPE_IND);
  59. if (! memcmp (& indicate->qualcomm, & header_arpc, sizeof (header_arpc)))
  60. {
  61. ARPCPrint (stderr, & indicate->RDATA [indicate->RDATAOFFSET], LE16TOH (indicate->RDATALENGTH) - indicate->RDATAOFFSET);
  62. return (- 1);
  63. }
  64. return (0);
  65. }
  66. #endif