rules.h.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. rules.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='qualcomm.h.html' title=' qualcomm.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='sdram.h.html' title=' sdram.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. * rules.h - Classification Rules Definitions and Declarations;
  64. *
  65. *. Qualcomm Atheros HomePlug AV Powerline Toolkit;
  66. *: Copyright (c) 2006-2010 by Intellon Corporation; ALL RIGHTS RESERVED;
  67. *; For demonstration and evaluation only; Not for production use.
  68. *
  69. * Contributor(s):
  70. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  71. * Nathaniel Houghton &lt;nathaniel.houghton@qca.qualcomm.com&gt;
  72. *
  73. *--------------------------------------------------------------------*/
  74. #ifndef RULES_HEADER
  75. #define RULES_HEADER
  76. /*====================================================================*
  77. * system header files;
  78. *--------------------------------------------------------------------*/
  79. #include &lt;stdint.h&gt;
  80. /*====================================================================*
  81. * custom header files;
  82. *--------------------------------------------------------------------*/
  83. #include &quot;../plc/plc.h&quot;
  84. #include &quot;../tools/symbol.h&quot;
  85. /*====================================================================*
  86. * constants;
  87. *--------------------------------------------------------------------*/
  88. #define CLASSIFIER_STRING 64
  89. #define CLASSIFIER_CONTROLS 3
  90. #define CLASSIFIER_VOLATILITIES 2
  91. #define CLASSIFIER_ACTIONS 13
  92. #define CLASSIFIER_OPERANDS 3
  93. #define CLASSIFIER_OPERATORS 2
  94. #define CLASSIFIER_STATES 8
  95. #define CLASSIFIER_FIELDS 22
  96. #define CLASSIFIER_CONTROL_NAME &quot;control&quot;
  97. #define CLASSIFIER_VOLATILITY_NAME &quot;volatility&quot;
  98. #define CLASSIFIER_ACTION_NAME &quot;action&quot;
  99. #define CLASSIFIER_OPERAND_NAME &quot;operand&quot;
  100. #define CLASSIFIER_OPERATOR_NAME &quot;operator&quot;
  101. #define CLASSIFIER_STATE_NAME &quot;state&quot;
  102. #define CLASSIFIER_FIELD_NAME &quot;field&quot;
  103. #define CONTROL_ADD 0x00
  104. #define CONTROL_REM 0x01
  105. #define CONTROL_READ 0x02
  106. #define CONTROL_REMOVE CONTROL_REM
  107. #define VOLATILITY_TEMP 0x00
  108. #define VOLATILITY_PERM 0x01
  109. #define ACTION_CAP0 0x00
  110. #define ACTION_CAP1 0x01
  111. #define ACTION_CAP2 0x02
  112. #define ACTION_CAP3 0x03
  113. #define ACTION_DROP 0x04
  114. #define ACTION_DROPTX ACTION_DROP
  115. #define ACTION_BOOST 0x05
  116. #define ACTION_DROPRX 0x06
  117. #define ACTION_AUTOCONNECT 0x06
  118. #define ACTION_STRIPTX 0x20
  119. #define ACTION_STRIPRX 0x21
  120. #define ACTION_TAGTX 0x22
  121. #define ACTION_TAGRX 0x23
  122. #define OPERAND_ALL 0x00
  123. #define OPERAND_ANY 0x01
  124. #define OPERAND_ALWAYS 0x02
  125. #define OPERATOR_IS 0x00
  126. #define OPERATOR_NOT 0x01
  127. #define FIELD_ETH_DA 0x00
  128. #define FIELD_ETH_SA 0x01
  129. #define FIELD_VLAN_UP 0x02
  130. #define FIELD_VLAN_ID 0x03
  131. #define FIELD_IPV4_TOS 0x04
  132. #define FIELD_IPV4_PROT 0x05
  133. #define FIELD_IPV4_SA 0x06
  134. #define FIELD_IPV4_DA 0x07
  135. #define FIELD_IPV6_TC 0x08
  136. #define FIELD_IPV6_FL 0x09
  137. #define FIELD_IPV6_SA 0x0A
  138. #define FIELD_IPV6_DA 0x0B
  139. #define FIELD_TCP_SP 0x0C
  140. #define FIELD_TCP_DP 0x0D
  141. #define FIELD_UDP_SP 0x0E
  142. #define FIELD_UDP_DP 0x0F
  143. #define FIELD_IP_SP 0xE0
  144. #define FIELD_IP_DP 0xE1
  145. #define FIELD_HPAV_MME 0xE2
  146. #define FIELD_ETH_TYPE 0xE3
  147. #define FIELD_TCP_ACK 0xE4
  148. #define FIELD_VLAN_TAG 0xE5
  149. #define RULE_MAX_AUTOCONN 16
  150. #define RULE_MAX_PRIORITY_MAPS 8
  151. #define RULE_MAX_CLASSIFIERS 3
  152. /*====================================================================*
  153. * variables;
  154. *--------------------------------------------------------------------*/
  155. extern struct _code_ const controls [CLASSIFIER_CONTROLS];
  156. extern struct _code_ const volatilities [CLASSIFIER_VOLATILITIES];
  157. extern struct _code_ const actions [CLASSIFIER_ACTIONS];
  158. extern struct _code_ const operands [CLASSIFIER_OPERANDS];
  159. extern struct _code_ const fields [CLASSIFIER_FIELDS];
  160. extern struct _code_ const operators [CLASSIFIER_OPERATORS];
  161. extern struct _code_ const states [CLASSIFIER_STATES];
  162. #ifndef __GNUC__
  163. #pragma pack (push,1)
  164. #endif
  165. /*
  166. * MME and PIB Classifier Rules are similar but differ in size
  167. * and so we declare structures for each use; observe that
  168. * function ParseRule uses the compact MMERule structure;
  169. */
  170. typedef struct __packed cspec
  171. {
  172. uint16_t CSPEC_VERSION;
  173. uint32_t VLAN_TAG;
  174. uint32_t RSVD;
  175. }
  176. cspec;
  177. typedef struct __packed MMEClassifier
  178. {
  179. uint8_t CR_PID;
  180. uint8_t CR_OPERAND;
  181. uint8_t CR_VALUE [16];
  182. }
  183. MMEClassifier;
  184. typedef struct __packed PIBClassifier
  185. {
  186. uint32_t CR_PID;
  187. uint32_t CR_OPERAND;
  188. uint8_t CR_VALUE [16];
  189. }
  190. PIBClassifier;
  191. typedef struct __packed MMERule
  192. {
  193. uint8_t MCONTROL;
  194. uint8_t MVOLATILITY;
  195. uint8_t MACTION;
  196. uint8_t MOPERAND;
  197. uint8_t NUM_CLASSIFIERS;
  198. struct MMEClassifier CLASSIFIER [RULE_MAX_CLASSIFIERS];
  199. struct cspec cspec;
  200. }
  201. MMERule;
  202. typedef struct __packed PIBRule
  203. {
  204. uint8_t MCONTROL;
  205. uint8_t MVOLATILITY;
  206. uint8_t MACTION;
  207. uint8_t MOPERAND;
  208. uint32_t NUM_CLASSIFIERS;
  209. struct PIBClassifier CLASSIFIER [RULE_MAX_CLASSIFIERS];
  210. struct cspec cspec;
  211. }
  212. PIBRule;
  213. typedef struct __packed classifier_priority_map
  214. {
  215. uint32_t Priority;
  216. struct PIBClassifier CLASSIFIER;
  217. }
  218. classifier_priority_map;
  219. typedef struct __packed auto_connection
  220. {
  221. uint8_t MACTION;
  222. uint8_t MOPERAND;
  223. uint16_t NUM_CLASSIFIERS;
  224. struct PIBClassifier CLASSIFIER [RULE_MAX_CLASSIFIERS];
  225. struct cspec cspec;
  226. uint8_t RSVD [14];
  227. }
  228. auto_connection;
  229. typedef struct __packed PIBClassifiers
  230. {
  231. uint32_t priority_count;
  232. uint32_t autoconn_count;
  233. struct classifier_priority_map classifier_priority_map [RULE_MAX_PRIORITY_MAPS];
  234. struct auto_connection auto_connection [RULE_MAX_AUTOCONN];
  235. }
  236. PIBClassifiers;
  237. #ifndef __GNUC__
  238. #pragma pack (pop)
  239. #endif
  240. /*====================================================================*
  241. * functions;
  242. *--------------------------------------------------------------------*/
  243. signed MakeRule (struct plc * plc, struct MMERule * rule);
  244. signed ParseRule (int * argcp, char const ** argvp [], struct MMERule *, struct cspec *);
  245. signed PrintRule (uint32_t CR_PID, uint32_t CR_OPERAND, uint8_t CR_VALUE []);
  246. signed ReadRules (struct plc * plc);
  247. void cspec_dump (struct cspec *);
  248. void classifier_priority_map_dump (struct classifier_priority_map *);
  249. void auto_connection_dump (struct auto_connection *);
  250. void PIBClassifiersDump (struct PIBClassifiers *);
  251. void PIBClassifierDump (struct PIBClassifier *);
  252. void MMEClassifierDump (struct MMEClassifier *);
  253. void PIBRuleDump (struct PIBRule *);
  254. void MMERuleDump (struct MMERule *);
  255. /*====================================================================*
  256. *
  257. *--------------------------------------------------------------------*/
  258. #endif
  259. </pre>
  260. <div class='footerlink'>
  261. [<a href='qualcomm.h.html' title=' qualcomm.h '>PREV</a>]
  262. [<a href='toolkit.html' title=' Index '>HOME</a>]
  263. [<a href='sdram.h.html' title=' sdram.h '>NEXT</a>]
  264. </div>
  265. </body>
  266. </html>