RxRates1.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * signed RxRates1 (struct plc * plc);
  11. *
  12. * An INT6x00 only version;
  13. *
  14. * Contributor(s):
  15. * Charles Maier <cmaier@qca.qualcomm.com>
  16. *
  17. *--------------------------------------------------------------------*/
  18. #ifndef RXRATES1_SOURCE
  19. #define RXRATES1_SOURCE
  20. #include <unistd.h>
  21. #include <stdlib.h>
  22. #include <stdint.h>
  23. #include <limits.h>
  24. #include "../tools/types.h"
  25. #include "../tools/flags.h"
  26. #include "../tools/error.h"
  27. #include "../plc/plc.h"
  28. signed RxRates1 (struct plc * plc)
  29. {
  30. extern const byte broadcast [ETHER_ADDR_LEN];
  31. struct channel * channel = (struct channel *) (plc->channel);
  32. struct message * message = (struct message *) (plc->message);
  33. #ifndef __GNUC__
  34. #pragma pack (push,1)
  35. #endif
  36. struct __packed vs_nw_info_request
  37. {
  38. struct ethernet_hdr ethernet;
  39. struct qualcomm_hdr qualcomm;
  40. }
  41. * request = (struct vs_nw_info_request *) (message);
  42. struct __packed vs_nw_info_confirm
  43. {
  44. struct ethernet_hdr ethernet;
  45. struct qualcomm_hdr qualcomm;
  46. uint8_t data [1];
  47. }
  48. * confirm = (struct vs_nw_info_confirm *) (message);
  49. struct __packed station
  50. {
  51. uint8_t MAC [ETHER_ADDR_LEN];
  52. uint8_t TEI;
  53. uint8_t BDA [ETHER_ADDR_LEN];
  54. uint8_t AVGTX;
  55. uint8_t AVGRX;
  56. }
  57. * station;
  58. struct __packed network
  59. {
  60. uint8_t NID [7];
  61. uint8_t SNID;
  62. uint8_t TEI;
  63. uint8_t ROLE;
  64. uint8_t CCO_MAC [ETHER_ADDR_LEN];
  65. uint8_t CCO_TEI;
  66. uint8_t NUMSTAS;
  67. struct station stations [1];
  68. }
  69. * network;
  70. struct __packed networks
  71. {
  72. uint8_t NUMAVLNS;
  73. struct network networks [1];
  74. }
  75. * networks = (struct networks *) (confirm->data);
  76. #ifndef __GNUC__
  77. #pragma pack (pop)
  78. #endif
  79. memset (message, 0, sizeof (* message));
  80. EthernetHeader (& request->ethernet, channel->peer, channel->host, channel->type);
  81. QualcommHeader (& request->qualcomm, 0, (VS_NW_INFO | MMTYPE_REQ));
  82. plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  83. if (SendMME (plc) <= 0)
  84. {
  85. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  86. return (-1);
  87. }
  88. while (ReadMME (plc, 0, (VS_NW_INFO | MMTYPE_CNF)) > 0)
  89. {
  90. network = (struct network *) (& networks->networks);
  91. while (networks->NUMAVLNS--)
  92. {
  93. station = (struct station *) (& network->stations);
  94. while (network->NUMSTAS--)
  95. {
  96. if (memcmp (station->MAC, broadcast, sizeof (broadcast)))
  97. {
  98. if (_anyset (plc->flags, PLC_UNCODED_RATES))
  99. {
  100. station->AVGTX = ((station->AVGTX * 21) >> 4);
  101. station->AVGRX = ((station->AVGRX * 21) >> 4);
  102. }
  103. printf ("%d", _anyset (plc->flags, PLC_TXONLY)? station->AVGTX: station->AVGRX);
  104. if (network->NUMSTAS)
  105. {
  106. printf (", ");
  107. }
  108. }
  109. station++;
  110. }
  111. printf ("\n");
  112. network = (struct network *) (station);
  113. }
  114. fflush (stdout);
  115. }
  116. return (0);
  117. }
  118. #endif