plclog.c.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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. plclog.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='plclist.c.html' title=' plclist.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='plcmdio16.c.html' title=' plcmdio16.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. * plclog.c - Atheros INT6x00 Log Retrieval Utility;
  64. *
  65. *
  66. * Contributor(s):
  67. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  68. * Nathaniel Houghton &lt;nhoughto@qca.qualcomm.com&gt;
  69. *
  70. *--------------------------------------------------------------------*/
  71. /*====================================================================*&quot;
  72. * system header files;
  73. *--------------------------------------------------------------------*/
  74. #include &lt;unistd.h&gt;
  75. #include &lt;stdint.h&gt;
  76. #include &lt;stdlib.h&gt;
  77. #include &lt;ctype.h&gt;
  78. /*====================================================================*
  79. * custom header files;
  80. *--------------------------------------------------------------------*/
  81. #include &quot;../tools/getoptv.h&quot;
  82. #include &quot;../tools/putoptv.h&quot;
  83. #include &quot;../tools/memory.h&quot;
  84. #include &quot;../tools/number.h&quot;
  85. #include &quot;../tools/symbol.h&quot;
  86. #include &quot;../tools/format.h&quot;
  87. #include &quot;../tools/base64.h&quot;
  88. #include &quot;../tools/types.h&quot;
  89. #include &quot;../tools/flags.h&quot;
  90. #include &quot;../tools/files.h&quot;
  91. #include &quot;../tools/error.h&quot;
  92. #include &quot;../ether/channel.h&quot;
  93. #include &quot;../plc/plc.h&quot;
  94. /*====================================================================*
  95. * custom source files;
  96. *--------------------------------------------------------------------*/
  97. #ifndef MAKEFILE
  98. #include &quot;../plc/Devices.c&quot;
  99. #include &quot;../plc/Failure.c&quot;
  100. #include &quot;../plc/SendMME.c&quot;
  101. #include &quot;../plc/ReadMME.c&quot;
  102. #include &quot;../mme/EthernetHeader.c&quot;
  103. #include &quot;../mme/QualcommHeader.c&quot;
  104. #include &quot;../mme/UnwantedMessage.c&quot;
  105. #endif
  106. #ifndef MAKEFILE
  107. #include &quot;../tools/error.c&quot;
  108. #include &quot;../tools/getoptv.c&quot;
  109. #include &quot;../tools/putoptv.c&quot;
  110. #include &quot;../tools/version.c&quot;
  111. #include &quot;../tools/uintspec.c&quot;
  112. #include &quot;../tools/hexdump.c&quot;
  113. #include &quot;../tools/hexencode.c&quot;
  114. #include &quot;../tools/hexdecode.c&quot;
  115. #include &quot;../tools/hexstring.c&quot;
  116. #include &quot;../tools/todigit.c&quot;
  117. #include &quot;../tools/strfbits.c&quot;
  118. #include &quot;../tools/synonym.c&quot;
  119. #include &quot;../tools/b64dump.c&quot;
  120. #endif
  121. #ifndef MAKEFILE
  122. #include &quot;../ether/openchannel.c&quot;
  123. #include &quot;../ether/closechannel.c&quot;
  124. #include &quot;../ether/readpacket.c&quot;
  125. #include &quot;../ether/sendpacket.c&quot;
  126. #include &quot;../ether/channel.c&quot;
  127. #endif
  128. #ifndef MAKEFILE
  129. #include &quot;../mme/MMECode.c&quot;
  130. #endif
  131. /*====================================================================*
  132. * constants
  133. *--------------------------------------------------------------------*/
  134. #define MSTATUS_STATUS (7 &lt;&lt; 0)
  135. #define MSTATUS_MAJORVERSION (1 &lt;&lt; 3)
  136. #define MSTATUS_BUFFERISLOCKED (1 &lt;&lt; 4)
  137. #define MSTATUS_AUTOLOCKONRESET (1 &lt;&lt; 5)
  138. #define MSTATUS_UNSOLICITEDUPDATES (1 &lt;&lt; 6)
  139. #define MSTATUS_UNSOLICITED (1 &lt;&lt; 7)
  140. #define WD_SESSION_ID 0xFEFE
  141. #define WD_ACTION_READ (1 &lt;&lt; 0)
  142. #define WD_ACTION_CLEAR (1 &lt;&lt; 1)
  143. #define WD_ACTION_CUSTOM (1 &lt;&lt; 2)
  144. /*====================================================================*
  145. *
  146. * static signed PrintRawWatchdogReport (struct plc * plc);
  147. *
  148. * Read the watchdog report using VS_WD_RPT and write to file in
  149. * binary or XML format; this file can be sent to Atheros Support
  150. * for analysis;
  151. *
  152. * The XML version rquires additional information and so VS_SW_VER
  153. * is used to collect it;
  154. *
  155. * This VW_WD_RPT message protocol returns an indication message,
  156. * not a confirm message;
  157. *
  158. *
  159. * Contributor(s):
  160. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  161. *
  162. *--------------------------------------------------------------------*/
  163. static signed PrintRawWatchdogReport (struct plc * plc)
  164. {
  165. struct channel * channel = (struct channel *)(plc-&gt;channel);
  166. struct message * message = (struct message *)(plc-&gt;message);
  167. #ifndef __GNUC__
  168. #pragma pack (push,1)
  169. #endif
  170. struct __packed vs_wd_rpt_request
  171. {
  172. struct ethernet_hdr ethernet;
  173. struct qualcomm_hdr qualcomm;
  174. uint16_t SESSIONID;
  175. uint8_t CLR;
  176. }
  177. * request = (struct vs_wd_rpt_request *) (message);
  178. struct __packed vs_wd_rpt_ind
  179. {
  180. struct ethernet_hdr ethernet;
  181. struct qualcomm_hdr qualcomm;
  182. uint8_t MSTATUS;
  183. uint16_t SESSIONID;
  184. uint8_t NUMPARTS;
  185. uint8_t CURPART;
  186. uint16_t RDATALENGTH;
  187. uint8_t RDATAOFFSET;
  188. uint8_t RDATA [1];
  189. }
  190. * indicate = (struct vs_wd_rpt_ind *) (message);
  191. #ifndef __GNUC__
  192. #pragma pack (pop)
  193. #endif
  194. memset (message, 0, sizeof (* message));
  195. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  196. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_WD_RPT | MMTYPE_REQ));
  197. plc-&gt;packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  198. request-&gt;SESSIONID = HTOLE16 (WD_SESSION_ID);
  199. request-&gt;CLR = plc-&gt;readaction;
  200. if (SendMME (plc) &lt;= 0)
  201. {
  202. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  203. return (-1);
  204. }
  205. do
  206. {
  207. if (ReadMME (plc, 0, (VS_WD_RPT | MMTYPE_IND)) &lt;= 0)
  208. {
  209. error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
  210. return (-1);
  211. }
  212. if (indicate-&gt;MSTATUS)
  213. {
  214. Failure (plc, PLC_WONTDOIT);
  215. return (-1);
  216. }
  217. write (STDOUT_FILENO, indicate-&gt;RDATA + indicate-&gt;RDATAOFFSET, LE16TOH (indicate-&gt;RDATALENGTH) - indicate-&gt;RDATAOFFSET);
  218. }
  219. while (indicate-&gt;CURPART &lt; indicate-&gt;NUMPARTS);
  220. return (0);
  221. }
  222. /*====================================================================*
  223. *
  224. * static signed PrintWatchdogReport (struct plc * plc, char const * version);
  225. *
  226. * Read the watchdog report using VS_WD_RPT and write to file in
  227. * XML format; this file may be sent to QCA for analysis;
  228. *
  229. * The XML version rquires additional information and so VS_SW_VER
  230. * is used to collect it;
  231. *
  232. * This VW_WD_RPT message protocol returns an indication message,
  233. * not a confirm message;
  234. *
  235. *
  236. * Contributor(s):
  237. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  238. *
  239. *--------------------------------------------------------------------*/
  240. static signed PrintWatchdogReport (struct plc * plc, char const * version)
  241. {
  242. struct channel * channel = (struct channel *)(plc-&gt;channel);
  243. struct message * message = (struct message *)(plc-&gt;message);
  244. #ifndef __GNUC__
  245. #pragma pack (push,1)
  246. #endif
  247. struct __packed vs_wd_rpt_request
  248. {
  249. struct ethernet_hdr ethernet;
  250. struct qualcomm_hdr qualcomm;
  251. uint16_t SESSIONID;
  252. uint8_t CLR;
  253. }
  254. * request = (struct vs_wd_rpt_request *) (message);
  255. struct __packed vs_wd_rpt_ind
  256. {
  257. struct ethernet_hdr ethernet;
  258. struct qualcomm_hdr qualcomm;
  259. uint8_t MSTATUS;
  260. uint16_t SESSIONID;
  261. uint8_t NUMPARTS;
  262. uint8_t CURPART;
  263. uint16_t RDATALENGTH;
  264. uint8_t RDATAOFFSET;
  265. uint8_t RDATA [1];
  266. }
  267. * indicate = (struct vs_wd_rpt_ind *) (message);
  268. #ifndef __GNUC__
  269. #pragma pack (pop)
  270. #endif
  271. memset (message, 0, sizeof (* message));
  272. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  273. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_WD_RPT | MMTYPE_REQ));
  274. plc-&gt;packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  275. request-&gt;SESSIONID = HTOLE16 (WD_SESSION_ID);
  276. request-&gt;CLR = plc-&gt;readaction;
  277. if (SendMME (plc) &lt;= 0)
  278. {
  279. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  280. return (-1);
  281. }
  282. printf (&quot;&lt;WatchdogReport&gt;&quot;);
  283. do
  284. {
  285. if (ReadMME (plc, 0, (VS_WD_RPT | MMTYPE_IND)) &lt;= 0)
  286. {
  287. printf (&quot;&lt;/WatchdogReport&gt;&quot;);
  288. error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
  289. return (-1);
  290. }
  291. if (indicate-&gt;MSTATUS)
  292. {
  293. printf (&quot;&lt;/WatchdogReport&gt;&quot;);
  294. Failure (plc, PLC_WONTDOIT);
  295. return (-1);
  296. }
  297. printf (&quot;&lt;Packet&gt;&quot;);
  298. printf (&quot;&lt;Version&gt;%s&lt;/Version&gt;&quot;, version);
  299. printf (&quot;&lt;OUI&gt;%s&lt;/OUI&gt;&quot;, &quot;00B052&quot;);
  300. printf (&quot;&lt;Status&gt;0&lt;/Status&gt;&quot;);
  301. printf (&quot;&lt;SessionId&gt;0&lt;/SessionId&gt;&quot;);
  302. printf (&quot;&lt;NumParts&gt;%d&lt;/NumParts&gt;&quot;, indicate-&gt;NUMPARTS);
  303. printf (&quot;&lt;CurPart&gt;%d&lt;/CurPart&gt;&quot;, indicate-&gt;CURPART);
  304. printf (&quot;&lt;DataLength&gt;%d&lt;/DataLength&gt;&quot;, LE16TOH (indicate-&gt;RDATALENGTH));
  305. printf (&quot;&lt;DataOffset&gt;%d&lt;/DataOffset&gt;&quot;, indicate-&gt;RDATAOFFSET);
  306. printf (&quot;&lt;Data&gt;&quot;);
  307. b64dump (indicate-&gt;RDATA, LE16TOH (indicate-&gt;RDATALENGTH), 0, stdout);
  308. printf (&quot;&lt;/Data&gt;&quot;);
  309. printf (&quot;&lt;/Packet&gt;&quot;);
  310. }
  311. while (indicate-&gt;CURPART &lt; indicate-&gt;NUMPARTS);
  312. printf (&quot;&lt;/WatchdogReport&gt;&quot;);
  313. return (0);
  314. }
  315. /*====================================================================*
  316. *
  317. * static signed PrintCheckpointReport (struct plc * plc, char const * version);
  318. *
  319. * Read the watchdog reqport using VS_CP_RPT and write to file in
  320. * binary or XML format; this file can be sent to Atheros Support
  321. * for analysis;
  322. *
  323. * The XML version rquires additional information and so VS_SW_VER
  324. * is used to collect it;
  325. *
  326. * This VW_WD_RPT message protocol returns an indication message,
  327. * not a confirm message;
  328. *
  329. *
  330. * Contributor(s):
  331. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  332. * Nathaniel Houghton &lt;nhoughto@qca.qualcomm.com&gt;
  333. *
  334. *--------------------------------------------------------------------*/
  335. static signed PrintCheckpointReport (struct plc * plc, char const * version)
  336. {
  337. struct channel * channel = (struct channel *)(plc-&gt;channel);
  338. struct message * message = (struct message *)(plc-&gt;message);
  339. #ifndef __GNUC__
  340. #pragma pack (push,1)
  341. #endif
  342. struct __packed vs_cp_rpt_request
  343. {
  344. struct ethernet_hdr ethernet;
  345. struct qualcomm_hdr qualcomm;
  346. uint16_t SESSIONID;
  347. uint8_t CLR;
  348. }
  349. * request = (struct vs_cp_rpt_request *) (message);
  350. struct __packed vs_cp_rpt_ind
  351. {
  352. struct ethernet_hdr ethernet;
  353. struct qualcomm_hdr qualcomm;
  354. uint8_t MSTATUS;
  355. uint8_t MAJORVERSION;
  356. uint8_t MINORVERSION;
  357. uint8_t RESERVED [14];
  358. uint16_t SESSIONID;
  359. uint32_t TOTALBUFFERSIZE;
  360. uint32_t BLOCKOFFSET;
  361. uint32_t BYTEINDEXOFNEXTPOSITION;
  362. uint8_t NUMPARTS;
  363. uint8_t CURPART;
  364. uint16_t RDATALENGTH;
  365. uint8_t RDATAOFFSET;
  366. uint8_t RDATA [1];
  367. }
  368. * indicate = (struct vs_cp_rpt_ind *) (message);
  369. #ifndef __GNUC__
  370. #pragma pack (pop)
  371. #endif
  372. memset (message, 0, sizeof (* message));
  373. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  374. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_CP_RPT | MMTYPE_REQ));
  375. plc-&gt;packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  376. request-&gt;SESSIONID = HTOLE16 (WD_SESSION_ID);
  377. request-&gt;CLR = plc-&gt;readaction;
  378. if (SendMME (plc) &lt;= 0)
  379. {
  380. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  381. return (-1);
  382. }
  383. printf (&quot;&lt;CheckpointReport&gt;&quot;);
  384. do
  385. {
  386. if (ReadMME (plc, 0, (VS_CP_RPT | MMTYPE_IND)) &lt;= 0)
  387. {
  388. printf (&quot;&lt;/CheckpointReport&gt;&quot;);
  389. error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
  390. return (-1);
  391. }
  392. if (_anyset (indicate-&gt;MSTATUS, MSTATUS_STATUS))
  393. {
  394. printf (&quot;&lt;/CheckpointReport&gt;&quot;);
  395. Failure (plc, PLC_WONTDOIT);
  396. return (-1);
  397. }
  398. printf (&quot;&lt;Packet&gt;&quot;);
  399. printf (&quot;&lt;Version&gt;%s&lt;/Version&gt;&quot;, version);
  400. printf (&quot;&lt;Status&gt;0&lt;/Status&gt;&quot;);
  401. printf (&quot;&lt;MajorVersionBit&gt;%d&lt;/MajorVersionBit&gt;&quot;, indicate-&gt;MSTATUS &amp; MSTATUS_MAJORVERSION? 1:0);
  402. printf (&quot;&lt;BufferIsLocked&gt;%d&lt;/BufferIsLocked&gt;&quot;, indicate-&gt;MSTATUS &amp; MSTATUS_BUFFERISLOCKED? 1:0);
  403. printf (&quot;&lt;AutoLockOnResetIsOn&gt;%d&lt;/AutoLockOnResetIsOn&gt;&quot;, indicate-&gt;MSTATUS &amp; MSTATUS_AUTOLOCKONRESET? 1:0);
  404. printf (&quot;&lt;UnsolicitedUpdatesIsOn&gt;%d&lt;/UnsolicitedUpdatesIsOn&gt;&quot;, indicate-&gt;MSTATUS &amp; MSTATUS_UNSOLICITEDUPDATES? 1:0);
  405. printf (&quot;&lt;Unsolicited&gt;%d&lt;/Unsolicited&gt;&quot;, indicate-&gt;MSTATUS &amp; MSTATUS_UNSOLICITED? 1:0);
  406. printf (&quot;&lt;MajorVersion&gt;%d&lt;/MajorVersion&gt;&quot;, indicate-&gt;MAJORVERSION);
  407. printf (&quot;&lt;MinorVersion&gt;%d&lt;/MinorVersion&gt;&quot;, indicate-&gt;MINORVERSION);
  408. printf (&quot;&lt;Reserved1&gt;0&lt;/Reserved1&gt;&quot;);
  409. printf (&quot;&lt;Reserved2&gt;0&lt;/Reserved2&gt;&quot;);
  410. printf (&quot;&lt;Reserved3&gt;0&lt;/Reserved3&gt;&quot;);
  411. printf (&quot;&lt;Reserved4&gt;0&lt;/Reserved4&gt;&quot;);
  412. printf (&quot;&lt;SessionId&gt;1&lt;/SessionId&gt;&quot;);
  413. printf (&quot;&lt;TotalBufferSize&gt;%d&lt;/TotalBufferSize&gt;&quot;, LE32TOH (indicate-&gt;TOTALBUFFERSIZE));
  414. printf (&quot;&lt;BlockOffset&gt;%d&lt;/BlockOffset&gt;&quot;, LE32TOH (indicate-&gt;BLOCKOFFSET));
  415. printf (&quot;&lt;ByteIndexOfNextPos&gt;%d&lt;/ByteIndexOfNextPos&gt;&quot;, LE32TOH (indicate-&gt;BYTEINDEXOFNEXTPOSITION));
  416. printf (&quot;&lt;NumParts&gt;%d&lt;/NumParts&gt;&quot;, indicate-&gt;NUMPARTS);
  417. printf (&quot;&lt;CurPart&gt;%d&lt;/CurPart&gt;&quot;, indicate-&gt;CURPART);
  418. printf (&quot;&lt;RDataLength&gt;%d&lt;/RDataLength&gt;&quot;, LE16TOH (indicate-&gt;RDATALENGTH));
  419. printf (&quot;&lt;RDataOffset&gt;%d&lt;/RDataOffset&gt;&quot;, indicate-&gt;RDATAOFFSET);
  420. printf (&quot;&lt;RData&gt;&quot;);
  421. b64dump (indicate-&gt;RDATA, LE16TOH (indicate-&gt;RDATALENGTH), 0, stdout);
  422. printf (&quot;&lt;/RData&gt;&quot;);
  423. printf (&quot;&lt;/Packet&gt;&quot;);
  424. }
  425. while (indicate-&gt;CURPART &lt; indicate-&gt;NUMPARTS);
  426. printf (&quot;&lt;/CheckpointReport&gt;&quot;);
  427. return (0);
  428. }
  429. /*====================================================================*
  430. *
  431. * static signed Diagnostics (struct plc * plc)
  432. *
  433. * read the firmware version string from a device before reading
  434. * and writing the watchdog and checkpoint reports in XML format;
  435. *
  436. *
  437. *--------------------------------------------------------------------*/
  438. static signed Diagnostics (struct plc * plc)
  439. {
  440. char version [PLC_VERSION_STRING];
  441. struct channel * channel = (struct channel *)(plc-&gt;channel);
  442. struct message * message = (struct message *)(plc-&gt;message);
  443. #ifndef __GNUC__
  444. #pragma pack (push,1)
  445. #endif
  446. struct __packed vs_sw_ver_request
  447. {
  448. struct ethernet_hdr ethernet;
  449. struct qualcomm_hdr qualcomm;
  450. uint8_t MSTATUS;
  451. uint8_t MDEVICEID;
  452. uint8_t MVERLENGTH;
  453. char MVERSION [PLC_VERSION_STRING];
  454. }
  455. * request = (struct vs_sw_ver_request *) (message);
  456. struct __packed vs_sw_ver_confirm
  457. {
  458. struct ethernet_hdr ethernet;
  459. struct qualcomm_hdr qualcomm;
  460. uint8_t MSTATUS;
  461. uint8_t MDEVICEID;
  462. uint8_t MVERLENGTH;
  463. char MVERSION [PLC_VERSION_STRING];
  464. }
  465. * confirm = (struct vs_sw_ver_confirm *) (message);
  466. #ifndef __GNUC__
  467. #pragma pack (pop)
  468. #endif
  469. memset (message, 0, sizeof (* message));
  470. EthernetHeader (&amp;request-&gt;ethernet, channel-&gt;peer, channel-&gt;host, channel-&gt;type);
  471. QualcommHeader (&amp;request-&gt;qualcomm, 0, (VS_SW_VER | MMTYPE_REQ));
  472. plc-&gt;packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN);
  473. if (SendMME (plc) &lt;= 0)
  474. {
  475. error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND);
  476. return (-1);
  477. }
  478. if (ReadMME (plc, 0, (VS_SW_VER | MMTYPE_CNF)) &lt;= 0)
  479. {
  480. error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
  481. return (-1);
  482. }
  483. if (confirm-&gt;MSTATUS)
  484. {
  485. Failure (plc, PLC_WONTDOIT);
  486. return (-1);
  487. }
  488. memcpy (version, confirm-&gt;MVERSION, sizeof (version));
  489. if (_anyset (plc-&gt;flags, PLC_XML_FORMAT))
  490. {
  491. printf (&quot;&lt;?xml version='1.0' encoding='utf-8' standalone='yes'?&gt;&quot;);
  492. printf (&quot;&lt;Diagnostics&gt;&quot;);
  493. PrintWatchdogReport (plc, version);
  494. PrintCheckpointReport (plc, version);
  495. printf (&quot;&lt;/Diagnostics&gt;\n&quot;);
  496. return (0);
  497. }
  498. PrintRawWatchdogReport (plc);
  499. return (0);
  500. }
  501. /*====================================================================*
  502. *
  503. * int main (int argc, char const * argv[]);
  504. *
  505. * parse command line, populate plc structure and perform selected
  506. * operations; show help summary if asked; see getoptv and putoptv
  507. * to understand command line parsing and help summary display; see
  508. * plc.h for the definition of struct plc;
  509. *
  510. * the command line accepts multiple MAC addresses and the program
  511. * performs the specified operations on each address, in turn; the
  512. * address order is significant but the option order is not; the
  513. * default address is a local broadcast that causes all devices on
  514. * the local H1 interface to respond but not those at the remote
  515. * end of the powerline;
  516. *
  517. * the default address is 00:B0:52:00:00:01; omitting the address
  518. * will automatically address the local device; some options will
  519. * cancel themselves if this makes no sense;
  520. *
  521. * the default interface is eth1 because most people use eth0 as
  522. * their principle network connection; you can specify another
  523. * interface with -i or define environment string PLC to make
  524. * that the default interface and save typing;
  525. *
  526. *
  527. *--------------------------------------------------------------------*/
  528. int main (int argc, char const * argv [])
  529. {
  530. extern struct channel channel;
  531. static char const * optv [] =
  532. {
  533. &quot;cCei:qvx&quot;,
  534. &quot;device [device] [...] [&gt; stdout]&quot;,
  535. &quot;Qualcomm Atheros INT6x00 Log Retrieval Utility&quot;,
  536. &quot;c\tcustom report&quot;,
  537. &quot;C\tclear report&quot;,
  538. &quot;e\tredirect stderr to stdout&quot;,
  539. #if defined (WINPCAP) || defined (LIBPCAP)
  540. &quot;i n\thost interface is (n) [&quot; LITERAL (CHANNEL_ETHNUMBER) &quot;]&quot;,
  541. #else
  542. &quot;i s\thost interface is (s) [&quot; LITERAL (CHANNEL_ETHDEVICE) &quot;]&quot;,
  543. #endif
  544. &quot;q\tquiet mode&quot;,
  545. &quot;v\tverbose mode&quot;,
  546. &quot;x\tprint watchdog report in XML format&quot;,
  547. (char const *) (0)
  548. };
  549. #include &quot;../plc/plc.c&quot;
  550. signed c;
  551. if (getenv (PLCDEVICE))
  552. {
  553. #if defined (WINPCAP) || defined (LIBPCAP)
  554. channel.ifindex = atoi (getenv (PLCDEVICE));
  555. #else
  556. channel.ifname = strdup (getenv (PLCDEVICE));
  557. #endif
  558. }
  559. optind = 1;
  560. plc.readaction = WD_ACTION_READ;
  561. while ((c = getoptv (argc, argv, optv)) != -1)
  562. {
  563. switch (c)
  564. {
  565. case 'C':
  566. plc.readaction |= WD_ACTION_CLEAR;
  567. break;
  568. case 'c':
  569. plc.readaction |= WD_ACTION_CUSTOM;
  570. break;
  571. case 'e':
  572. dup2 (STDOUT_FILENO, STDERR_FILENO);
  573. break;
  574. case 'x':
  575. _setbits (plc.flags, PLC_XML_FORMAT);
  576. break;
  577. case 'i':
  578. #if defined (WINPCAP) || defined (LIBPCAP)
  579. channel.ifindex = atoi (optarg);
  580. #else
  581. channel.ifname = optarg;
  582. #endif
  583. break;
  584. case 'q':
  585. _setbits (channel.flags, CHANNEL_SILENCE);
  586. _setbits (plc.flags, PLC_SILENCE);
  587. break;
  588. case 'v':
  589. _setbits (channel.flags, CHANNEL_VERBOSE);
  590. _setbits (plc.flags, PLC_VERBOSE);
  591. break;
  592. default:
  593. break;
  594. }
  595. }
  596. argc -= optind;
  597. argv += optind;
  598. if (argc != 1)
  599. {
  600. if (plc.rpt.file != -1)
  601. {
  602. error (1, ECANCELED, PLC_NODEVICE);
  603. }
  604. }
  605. openchannel (&amp;channel);
  606. if (!(plc.message = malloc (sizeof (* plc.message))))
  607. {
  608. error (1, errno, PLC_NOMEMORY);
  609. }
  610. #if defined (WIN32)
  611. if (format == INT6KLOG_FMT_RAW)
  612. {
  613. setmode (STDOUT_FILENO, O_BINARY);
  614. }
  615. #endif
  616. if (!argc)
  617. {
  618. Diagnostics (&amp;plc);
  619. }
  620. while ((argc) &amp;&amp; (* argv))
  621. {
  622. if (!hexencode (channel.peer, sizeof (channel.peer), synonym (* argv, devices, SIZEOF (devices))))
  623. {
  624. error (1, errno, PLC_BAD_MAC, * argv);
  625. }
  626. Diagnostics (&amp;plc);
  627. argc--;
  628. argv++;
  629. }
  630. free (plc.message);
  631. closechannel (&amp;channel);
  632. exit (0);
  633. }
  634. </pre>
  635. <div class='footerlink'>
  636. [<a href='plclist.c.html' title=' plclist.c '>PREV</a>]
  637. [<a href='toolkit.html' title=' Index '>HOME</a>]
  638. [<a href='plcmdio16.c.html' title=' plcmdio16.c '>NEXT</a>]
  639. </div>
  640. </body>
  641. </html>