ruledump.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or
  8. * without modification, are permitted (subject to the limitations
  9. * in the disclaimer below) provided that the following conditions
  10. * are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * * Redistributions in binary form must reproduce the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer in the documentation and/or other materials
  18. * provided with the distribution.
  19. *
  20. * * Neither the name of Qualcomm Atheros nor the names of
  21. * its contributors may be used to endorse or promote products
  22. * derived from this software without specific prior written
  23. * permission.
  24. *
  25. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  26. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
  27. * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  28. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  31. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  33. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  34. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  36. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  37. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. *--------------------------------------------------------------------*/
  41. /*====================================================================*
  42. *
  43. * void ruledump (struct rule * rule, FILE * fp);
  44. *
  45. *
  46. *--------------------------------------------------------------------*/
  47. #ifndef RULEDUMP_SOURCE
  48. #define RULEDUMP_SOURCE
  49. #include <stdio.h>
  50. #include "../tools/memory.h"
  51. #include "../plc/rules.h"
  52. /*====================================================================*
  53. *
  54. * cspec_dump (struct cspec * cspec);
  55. *
  56. *
  57. *--------------------------------------------------------------------*/
  58. void cspec_dump (struct cspec * cspec)
  59. {
  60. printf ("cspec->CSPEC_VERSION=%d\n", LE16TOH (cspec->CSPEC_VERSION));
  61. printf ("cspec->VLAN_TAG=%d\n", LE16TOH (cspec->VLAN_TAG));
  62. return;
  63. }
  64. /*====================================================================*
  65. *
  66. * MMEClassifierDump (struct MMEClassifier * classifier);
  67. *
  68. *
  69. *--------------------------------------------------------------------*/
  70. void MMEClassifierDump (struct MMEClassifier * classifier)
  71. {
  72. char string [48];
  73. printf ("classifier->CR_PID=0x%02X\n", (unsigned)(classifier->CR_PID));
  74. printf ("classifier->CR_OPERAND=0x%02X\n", classifier->CR_OPERAND);
  75. hexdecode (classifier->CR_VALUE, sizeof (classifier->CR_VALUE), string, sizeof (string));
  76. printf ("classifier->CR_VALUE=%s\n", string);
  77. return;
  78. }
  79. /*====================================================================*
  80. *
  81. * PIBClassifierDump (struct PIBClassifier * classifier);
  82. *
  83. *
  84. *--------------------------------------------------------------------*/
  85. void PIBClassifierDump (struct PIBClassifier * classifier)
  86. {
  87. char string [48];
  88. printf ("classifier->CR_PID=0x%08X\n", LE32TOH (classifier->CR_PID));
  89. printf ("classifier->CR_OPERAND=0x%08X\n", LE32TOH (classifier->CR_OPERAND));
  90. hexdecode (classifier->CR_VALUE, sizeof (classifier->CR_VALUE), string, sizeof (string));
  91. printf ("classifier->CR_VALUE=%s\n", string);
  92. return;
  93. }
  94. /*====================================================================*
  95. *
  96. * MMERuleDump (struct MMERule * rule);
  97. *
  98. *
  99. *--------------------------------------------------------------------*/
  100. void MMERuleDump (struct MMERule * rule)
  101. {
  102. unsigned count;
  103. printf ("rule->MCONTROL=%d\n", rule->MCONTROL);
  104. printf ("rule->MVOLATILITY=%d\n", rule->MVOLATILITY);
  105. printf ("rule->MACTION=%d\n", rule->MACTION);
  106. printf ("rule->MOPERAND=%d\n", rule->MOPERAND);
  107. printf ("rule->NUM_CLASSIFIERS=%d\n", rule->NUM_CLASSIFIERS);
  108. for (count = 0; count < rule->NUM_CLASSIFIERS; count++)
  109. {
  110. MMEClassifierDump (&rule->CLASSIFIER [count]);
  111. }
  112. cspec_dump (&rule->cspec);
  113. printf ("\n");
  114. return;
  115. }
  116. /*====================================================================*
  117. *
  118. * PIBRuleDump (struct PIBRule * rule);
  119. *
  120. *
  121. *--------------------------------------------------------------------*/
  122. void PIBRuleDump (struct PIBRule * rule)
  123. {
  124. unsigned count;
  125. printf ("rule->MCONTROL=%d\n", rule->MCONTROL);
  126. printf ("rule->MVOLATILITY=%d\n", rule->MVOLATILITY);
  127. printf ("rule->MACTION=%d\n", rule->MACTION);
  128. printf ("rule->MOPERAND=%d\n", rule->MOPERAND);
  129. printf ("rule->NUM_CLASSIFIERS=%d\n", LE32TOH (rule->NUM_CLASSIFIERS));
  130. for (count = 0; count < LE32TOH (rule->NUM_CLASSIFIERS); count++)
  131. {
  132. PIBClassifierDump (&rule->CLASSIFIER [count]);
  133. }
  134. cspec_dump (&rule->cspec);
  135. printf ("\n");
  136. return;
  137. }
  138. /*====================================================================*
  139. *
  140. * classifier_priority_map_dump (struct classifier_priority_map * classifier_priority_map);
  141. *
  142. *
  143. *--------------------------------------------------------------------*/
  144. void classifier_priority_map_dump (struct classifier_priority_map * classifier_priority_map)
  145. {
  146. printf ("classifier_priority_map->Priority=%d\n", LE32TOH (classifier_priority_map->Priority));
  147. PIBClassifierDump (&classifier_priority_map->CLASSIFIER);
  148. return;
  149. }
  150. /*====================================================================*
  151. *
  152. * auto_connection_dump (struct auto_connection * auto_connection);
  153. *
  154. *
  155. *--------------------------------------------------------------------*/
  156. void auto_connection_dump (struct auto_connection * auto_connection)
  157. {
  158. unsigned count;
  159. printf ("auto_connection->MACTION=%d\n", auto_connection->MACTION);
  160. printf ("auto_connection->MOPERAND=%d\n", auto_connection->MOPERAND);
  161. printf ("auto_connection->NUM_CLASSIFIERS=%d\n", LE16TOH (auto_connection->NUM_CLASSIFIERS));
  162. for (count = 0; count < LE16TOH (auto_connection->NUM_CLASSIFIERS); count++)
  163. {
  164. PIBClassifierDump (&auto_connection->CLASSIFIER [count]);
  165. }
  166. cspec_dump (&auto_connection->cspec);
  167. return;
  168. }
  169. /*====================================================================*
  170. *
  171. * PIBClassifiersDump (struct PIBClassifiers * classifiers);
  172. *
  173. *
  174. *--------------------------------------------------------------------*/
  175. void PIBClassifiersDump (struct PIBClassifiers * classifiers)
  176. {
  177. unsigned count;
  178. printf ("classifiers->priority_count=%d\n", LE32TOH (classifiers->priority_count));
  179. printf ("classifiers->autoconn_count=%d\n", LE32TOH (classifiers->autoconn_count));
  180. printf ("\n");
  181. printf ("-------- PRIORITY MAPS --------\n\n");
  182. for (count = 0; count < LE32TOH (classifiers->priority_count); count++)
  183. {
  184. classifier_priority_map_dump (&classifiers->classifier_priority_map [count]);
  185. }
  186. printf ("\n");
  187. printf ("-------- AUTO CONNECTIONS --------\n\n");
  188. for (count = 0; count < LE32TOH (classifiers->autoconn_count); count++)
  189. {
  190. auto_connection_dump (&classifiers->auto_connection [count]);
  191. }
  192. printf ("\n");
  193. return;
  194. }
  195. /*====================================================================*
  196. *
  197. *--------------------------------------------------------------------*/
  198. #endif