int6klog.c.html 23 KB

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