NetworkInfoStats.c.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. NetworkInfoStats.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='NetworkInformation.c.html' title=' NetworkInformation.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='NetworkTraffic1.c.html' title=' NetworkTraffic1.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  24. *
  25. * All rights reserved.
  26. *
  27. * Redistribution and use in source and binary forms, with or
  28. * without modification, are permitted (subject to the limitations
  29. * in the disclaimer below) provided that the following conditions
  30. * are met:
  31. *
  32. * * Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer.
  34. *
  35. * * Redistributions in binary form must reproduce the above
  36. * copyright notice, this list of conditions and the following
  37. * disclaimer in the documentation and/or other materials
  38. * provided with the distribution.
  39. *
  40. * * Neither the name of Qualcomm Atheros nor the names of
  41. * its contributors may be used to endorse or promote products
  42. * derived from this software without specific prior written
  43. * permission.
  44. *
  45. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  46. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
  47. * COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR
  48. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  50. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  51. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  52. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  53. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  54. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  56. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  57. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59. *
  60. *--------------------------------------------------------------------*/
  61. /*====================================================================*
  62. *
  63. * signed NetworkInfoStats (struct plc * plc);
  64. *
  65. * plc.h
  66. *
  67. * Request network membership information from the peer device using
  68. * the VS_NW_INFO_STATS message;
  69. *
  70. * This function is similar to function NetworkInformation() but the
  71. * output format is different;
  72. *
  73. *
  74. * Contributor(s):
  75. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  76. *
  77. *--------------------------------------------------------------------*/
  78. #ifndef NETWORKINFOSTATS_SOURCE
  79. #define NETWORKINFOSTATS_SOURCE
  80. #include &lt;stdint.h&gt;
  81. #include &lt;memory.h&gt;
  82. #include &quot;../plc/plc.h&quot;
  83. #include &quot;../tools/memory.h&quot;
  84. #include &quot;../tools/number.h&quot;
  85. #include &quot;../tools/error.h&quot;
  86. signed NetworkInfoStats (struct plc * plc)
  87. {
  88. extern char const * StationRole [STATIONROLES];
  89. struct channel * channel = (struct channel *)(plc-&gt;channel);
  90. struct message * message = (struct message *)(plc-&gt;message);
  91. #ifndef __GNUC__
  92. #pragma pack (push,1)
  93. #endif
  94. #if defined(INT6x00)
  95. struct __packed vs_ns_info_stats_request
  96. {
  97. struct ethernet_hdr ethernet;
  98. struct qualcomm_hdr qualcomm;
  99. uint8_t FIRST_TEI;
  100. }
  101. * request = (struct vs_ns_info_stats_request *)(message);
  102. struct __packed station
  103. {
  104. uint8_t MAC [ETHER_ADDR_LEN];
  105. uint8_t TEI;
  106. uint8_t BDA [ETHER_ADDR_LEN];
  107. uint8_t AVGTX;
  108. uint8_t AVGRX;
  109. }
  110. * station;
  111. struct __packed network
  112. {
  113. uint8_t NID [7];
  114. uint8_t SNID;
  115. uint8_t TEI;
  116. uint8_t ROLE;
  117. uint8_t CCO_MAC [ETHER_ADDR_LEN];
  118. uint8_t ACCESS uint8_t NEIGHBOR_NETWORKS;
  119. uint8_t CCO_TEI;
  120. uint8_t NUMSTAS;
  121. struct station stations [1];
  122. }
  123. * network;
  124. struct __packed vs_ns_info_stats_confirm
  125. {
  126. struct ethernet_hdr ethernet;
  127. struct qualcomm_hdr qualcomm;
  128. uint8_t FIRST_TEI;
  129. uint8_t IN_AVLN;
  130. struct network network;
  131. }
  132. * confirm = (struct vs_ns_info_stats_confirm *)(message);
  133. #elif defined (AR7x00)
  134. struct __packed vs_ns_info_stats_request
  135. {
  136. struct ethernet_hdr ethernet;
  137. struct qualcomm_fmi qualcomm;
  138. uint8_t MME_SUBVER;
  139. uint8_t RESERVED [3];
  140. uint8_t FIRST_TEI;
  141. UINT8_6 NUM_STAS;
  142. }
  143. * request = (struct vs_ns_info_stats_request *)(message);
  144. struct __packed station
  145. {
  146. uint8_t MAC [ETHER_ADDR_LEN];
  147. uint8_t TEI;
  148. uint8_t Reserved [3];
  149. uint8_t BDA [ETHER_ADDR_LEN];
  150. uint16_t AVGTX;
  151. uint8_t COUPLING;
  152. uint8_t Reserved3;
  153. uint16_t AVGRX;
  154. uint16_t Reserved4;
  155. }
  156. * station;
  157. struct __packed network
  158. {
  159. uint8_t NID [7];
  160. uint8_t Reserved1;
  161. uint8_t SNID;
  162. uint8_t TEI;
  163. uint8_t Reserved2 [2];
  164. uint8_t ROLE;
  165. uint8_t CCO_MAC [ETHER_ADDR_LEN];
  166. uint8_t ACCESS;
  167. uint8_t NEIGHBOR_NETWORKS;
  168. uint8_t CCO_TEI;
  169. uint8_t Reserved3 [7];
  170. uint8_t NUMSTAS;
  171. uint8_t Reserved4 [5];
  172. struct station stations [1];
  173. }
  174. * network;
  175. struct __packed vs_ns_info_stats_confirm
  176. {
  177. struct ethernet_hdr ethernet;
  178. struct qualcomm_fmi qualcomm;
  179. uint8_t SUB_VERSION;
  180. uint8_t Reserved;
  181. uint16_t DATA_LEN;
  182. uint8_t FIRST_TEI;
  183. uint8_t NUM_STAS;
  184. uin16_t Reserved;
  185. uint8_t IN_AVLN;
  186. struct network network;
  187. }
  188. * confirm = (struct vs_ns_info_stats_confirm *)(message);
  189. #else
  190. #error &quot;Unspecified Atheros chipset&quot;
  191. #endif
  192. #ifndef __GNUC__
  193. #pragma pack (pop)
  194. #endif
  195. Request (plc, &quot;Fetch Network Information&quot;);
  196. memset (message, 0, sizeof (* message));
  197. #if defined (INT6x00)
  198. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  199. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_NW_INFO_STATS | MMTYPE_REQ));
  200. #elif defined (AR7x00)
  201. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  202. QualcommHeader1 (&amp;request-&gt;qualcomm, 1, (VS_NW_INFO_STATS | MMTYPE_REQ));
  203. #else
  204. #error &quot;Unspecified Atheros chipset&quot;
  205. #endif
  206. plc-&gt;packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  207. if (SendMME (plc) &lt;= 0)
  208. {
  209. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  210. return (-1);
  211. }
  212. #if defined (INT6x00)
  213. while (ReadMME (plc, 0, (VS_NW_INFO_STATS | MMTYPE_CNF)) &gt; 0)
  214. #elif defined (AR7x00)
  215. while (ReadMME (plc, 1, (VS_NW_INFO_STATS | MMTYPE_CNF)) &gt; 0)
  216. #else
  217. #error &quot;Unspecified Atheros chipset&quot;
  218. #endif
  219. {
  220. char string [24];
  221. Confirm (plc, &quot;Found %d Network(s)\n&quot;, networks-&gt;NUMAVLNS);
  222. network = (struct network *)(&amp;networks-&gt;networks);
  223. while (networks-&gt;NUMAVLNS--)
  224. {
  225. printf (&quot;\tnetwork-&gt;NID = %s\n&quot;, hexstring (string, sizeof (string), network-&gt;NID, sizeof (network-&gt;NID)));
  226. printf (&quot;\tnetwork-&gt;SNID = %d\n&quot;, network-&gt;SNID);
  227. printf (&quot;\tnetwork-&gt;TEI = %d\n&quot;, network-&gt;TEI);
  228. printf (&quot;\tnetwork-&gt;ROLE = 0x%02X (%s)\n&quot;, network-&gt;ROLE, StationRole [network-&gt;ROLE]);
  229. printf (&quot;\tnetwork-&gt;CCO_DA = %s\n&quot;, hexstring (string, sizeof (string), network-&gt;CCO_MAC, sizeof (network-&gt;CCO_MAC)));
  230. printf (&quot;\tnetwork-&gt;CCO_TEI = %d\n&quot;, network-&gt;CCO_TEI);
  231. printf (&quot;\tnetwork-&gt;STATIONS = %d\n&quot;, network-&gt;NUMSTAS);
  232. printf (&quot;\n&quot;);
  233. station = (struct station *)(&amp;network-&gt;stations);
  234. while (network-&gt;NUMSTAS--)
  235. {
  236. char * TX = &quot;&quot;;
  237. char * RX = &quot;&quot;;
  238. printf (&quot;\t\tstation-&gt;MAC = %s\n&quot;, hexstring (string, sizeof (string), station-&gt;MAC, sizeof (station-&gt;MAC)));
  239. printf (&quot;\t\tstation-&gt;TEI = %d\n&quot;, station-&gt;TEI);
  240. printf (&quot;\t\tstation-&gt;BDA = %s\n&quot;, hexstring (string, sizeof (string), station-&gt;BDA, sizeof (station-&gt;BDA)));
  241. #if defined (AR7x00)
  242. station-&gt;AVGTX = LE16TOH (station-&gt;AVGTX);
  243. station-&gt;AVGRX = LE16TOH (station-&gt;AVGRX);
  244. TX = ((station-&gt;COUPLING &gt;&gt; 4) &amp; 0x0F)? &quot;Alternate&quot;: &quot;Primary&quot;;
  245. RX = ((station-&gt;COUPLING &gt;&gt; 0) &amp; 0x0F)? &quot;Alternate&quot;: &quot;Primary&quot;;
  246. #endif
  247. printf (&quot;\t\tstation-&gt;AvgPHYDR_TX = %03d mbps %s\n&quot;, station-&gt;AVGTX, TX);
  248. printf (&quot;\t\tstation-&gt;AvgPHYDR_RX = %03d mbps %s\n&quot;, station-&gt;AVGRX, RX);
  249. printf (&quot;\n&quot;);
  250. station++;
  251. }
  252. network = (struct network *)(station);
  253. }
  254. }
  255. return (0);
  256. }
  257. #endif
  258. </pre>
  259. <div class='footerlink'>
  260. [<a href='NetworkInformation.c.html' title=' NetworkInformation.c '>PREV</a>]
  261. [<a href='toolkit.html' title=' Index '>HOME</a>]
  262. [<a href='NetworkTraffic1.c.html' title=' NetworkTraffic1.c '>NEXT</a>]
  263. </div>
  264. </body>
  265. </html>