mme.h.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. mme.h
  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='memory.h.html' title=' memory.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='namedb.h.html' title=' namedb.h '>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. * mme.h -
  64. *
  65. * message header definitions and function declarations;
  66. *
  67. *. Qualcomm Atheros HomePlug AV Powerline Toolkit
  68. *: Copyright (c) 2009-2013 by Qualcomm Atheros Inc. ALL RIGHTS RESERVED;
  69. *; For demonstration and evaluation only; Not for production use.
  70. *
  71. * Contributor(s):
  72. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  73. * Matthieu Poullet &lt;m.poullet@avm.de&gt;
  74. *
  75. *--------------------------------------------------------------------*/
  76. #ifndef MME_HEADER
  77. #define MME_HEADER
  78. /*====================================================================*
  79. * system header files;
  80. *--------------------------------------------------------------------*/
  81. #include &lt;stdio.h&gt;
  82. #include &lt;stdint.h&gt;
  83. #include &lt;unistd.h&gt;
  84. /*====================================================================*
  85. * custom header files;
  86. *--------------------------------------------------------------------*/
  87. #include &quot;../ether/ether.h&quot;
  88. #include &quot;../ether/channel.h&quot;
  89. #include &quot;../mme/homeplug.h&quot;
  90. #include &quot;../mme/qualcomm.h&quot;
  91. /*====================================================================*
  92. * manage cross-platform structure packing;
  93. *--------------------------------------------------------------------*/
  94. #ifndef __packed
  95. #ifdef __GNUC__
  96. #define __packed __attribute__ ((packed))
  97. #else
  98. #define __packed
  99. #endif
  100. #endif
  101. /*====================================================================*
  102. * Ethernet, HomePlug and Qualcomm Frame headers;
  103. *--------------------------------------------------------------------*/
  104. #ifndef __GNUC__
  105. #pragma pack (push, 1)
  106. #endif
  107. typedef struct __packed ethernet_hdr
  108. {
  109. uint8_t ODA [ETHER_ADDR_LEN];
  110. uint8_t OSA [ETHER_ADDR_LEN];
  111. uint16_t MTYPE;
  112. }
  113. ethernet_hdr;
  114. typedef struct __packed homeplug_hdr
  115. {
  116. uint8_t MMV;
  117. uint16_t MMTYPE;
  118. }
  119. homeplug_hdr;
  120. typedef struct __packed homeplug_fmi
  121. {
  122. uint8_t MMV;
  123. uint16_t MMTYPE;
  124. uint8_t FMSN;
  125. uint8_t FMID;
  126. }
  127. homeplug_fmi;
  128. typedef struct __packed qualcomm_hdr
  129. {
  130. uint8_t MMV;
  131. uint16_t MMTYPE;
  132. uint8_t OUI [ETHER_ADDR_LEN &gt;&gt; 1];
  133. }
  134. qualcomm_hdr;
  135. typedef struct __packed qualcomm_fmi
  136. {
  137. uint8_t MMV;
  138. uint16_t MMTYPE;
  139. uint8_t FMSN;
  140. uint8_t FMID;
  141. uint8_t OUI [ETHER_ADDR_LEN &gt;&gt; 1];
  142. }
  143. qualcomm_fmi;
  144. #ifndef __GNUC__
  145. #pragma pack (pop)
  146. #endif
  147. /*====================================================================*
  148. * Composite message formats;
  149. *--------------------------------------------------------------------*/
  150. #ifndef __GNUC__
  151. #pragma pack (push, 1)
  152. #endif
  153. typedef struct __packed message
  154. {
  155. struct ethernet_hdr ethernet;
  156. uint8_t content [ETHERMTU];
  157. }
  158. MESSAGE;
  159. typedef struct __packed homeplug
  160. {
  161. struct ethernet_hdr ethernet;
  162. struct homeplug_fmi homeplug;
  163. uint8_t content [ETHERMTU - sizeof (struct homeplug_fmi)];
  164. }
  165. HOMEPLUG;
  166. typedef struct __packed qualcomm
  167. {
  168. struct ethernet_hdr ethernet;
  169. struct qualcomm_fmi qualcomm;
  170. uint8_t content [ETHERMTU - sizeof (struct qualcomm_fmi)];
  171. }
  172. QUALCOMM;
  173. #ifndef __GNUC__
  174. #pragma pack (pop)
  175. #endif
  176. /*====================================================================*
  177. * functions;
  178. *--------------------------------------------------------------------*/
  179. void MMEPeek (void const * memory, size_t extent, FILE * fp);
  180. void ARPCPeek (void const * memory, size_t extent, FILE * fp);
  181. void ARPCWrite (signed fd, void const * memory, size_t extent);
  182. void ARPCPrint (FILE * fp, void const * memory, size_t extent);
  183. /*====================================================================*
  184. * functions;
  185. *--------------------------------------------------------------------*/
  186. char const * MMEName (uint16_t MMTYPE);
  187. char const * MMEMode (uint16_t MMTYPE);
  188. char const * MMECode (uint16_t MMTYPE, uint8_t MSTATUS);
  189. /*====================================================================*
  190. * header encode functions;
  191. *--------------------------------------------------------------------*/
  192. signed EthernetHeader (void * memory, const uint8_t peer [], const uint8_t host [], uint16_t protocol);
  193. signed HomePlugHeader (struct homeplug_hdr *, uint8_t MMV, uint16_t MMTYPE);
  194. signed QualcommHeader (struct qualcomm_hdr *, uint8_t MMV, uint16_t MMTYPE);
  195. signed HomePlugHeader1 (struct homeplug_fmi *, uint8_t MMV, uint16_t MMTYPE);
  196. signed QualcommHeader1 (struct qualcomm_fmi *, uint8_t MMV, uint16_t MMTYPE);
  197. /*====================================================================*
  198. * header decode functions;
  199. *--------------------------------------------------------------------*/
  200. signed UnwantedMessage (void const * memory, size_t extent, uint8_t MMV, uint16_t MMTYPE);
  201. signed FirmwareMessage (void const * memory);
  202. /*====================================================================*
  203. * intermmediate level Ethernet send/receive functions;
  204. *--------------------------------------------------------------------*/
  205. ssize_t sendmessage (struct channel const *, struct message *, ssize_t length);
  206. ssize_t readmessage (struct channel const *, struct message *, uint8_t MMV, uint16_t MMTYPE);
  207. /*====================================================================*
  208. *
  209. *--------------------------------------------------------------------*/
  210. #endif
  211. </pre>
  212. <div class='footerlink'>
  213. [<a href='memory.h.html' title=' memory.h '>PREV</a>]
  214. [<a href='toolkit.html' title=' Index '>HOME</a>]
  215. [<a href='namedb.h.html' title=' namedb.h '>NEXT</a>]
  216. </div>
  217. </body>
  218. </html>