doc: whitespace changes in licenses
[dpdk.git] / app / test / test_pmac_pm.h
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  * 
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  * 
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  * 
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef TEST_PMAC_PM_H_
35 #define TEST_PMAC_PM_H_
36
37 /**
38  * PATTERNS
39  */
40
41 /*
42  * clean ASCII patterns
43  */
44 #define MAX_PATTERN_LEN 256
45 const char clean_patterns[][MAX_PATTERN_LEN] = {
46                 "Command completed",
47                 "Bad command or filename",
48                 "1 file(s) copied",
49                 "Invalid URL",
50                 "Index of /cgi-bin/",
51                 "HTTP/1.1 403",
52                 "subject=FrEaK+SERVER",
53                 "friend_nickname=",
54                 "/scripts/WWPMsg.dll",
55                 "body=JJ+BackDoor+-+v",
56
57                 "subject=Insurrection+Page",
58                 "backtrust.com",
59                 "User-Agent:",
60                 "fromemail=y3k",
61                 "www.kornputers.com",
62                 "# Nova CGI Notification Script",
63                 /* test NOT converting to binary */
64                 "|23|",
65                 /* test adding same pattern twice - should result in two matches */
66                 "fromemail=y3k",
67 };
68
69 /*
70  * mixed ASCII-binary patterns
71  */
72 const char mixed_patterns[][MAX_PATTERN_LEN] = {
73                 "1 file|28|s|29| copied",
74                 "User-Agent|3A|",
75                 "|23|",                         /* gives # */
76                 "|7C 32 33 7C 00|",     /* gives |23| */
77                 /* test converter not converting stuff erroneously */
78                 "www.kornputers.com",
79 };
80
81 /*
82  * P1 patterns
83  * (P1 is used when having only one pattern)
84  */
85 const char P1_patterns[][MAX_PATTERN_LEN] = {
86                 "1111aA111111",
87 };
88
89
90
91 /**
92  * BUFFERS TO LOOK PATTERNS IN
93  */
94 #define MAX_MATCH_COUNT 3
95
96 struct pm_test_buffer {
97         /* test string */
98         const char string[MAX_PATTERN_LEN];
99         /* strings that should be found marching.
100          * for our test we allow no more than 3 matches.
101          * the number is completely arbitrary */
102         const char * matched_str[MAX_MATCH_COUNT];
103         /* number of matches with and without case sensitivity */
104         uint8_t n_matches;
105         uint8_t n_matches_with_case_sense;
106 };
107
108 struct pm_test_buffer clean_buffers[] = {
109                 {"abcCommand completedcde",
110                                 {clean_patterns[0], NULL, NULL},
111                                 1,      1},
112                 {"jsljelkwlefwe|23|igu5o0",
113                                 {clean_patterns[16], NULL, NULL},
114                                 1,      1},
115                 {"Invalid URLwww.kOrnpUterS.comfRiEnD_niCKname=",
116                                 {clean_patterns[3], clean_patterns[14], clean_patterns[7]},
117                                 3,      1},
118                 {"HTTP/1.1 404",
119                                 {NULL, NULL, NULL},
120                                 0,      0},
121                 {"abcfrOmemail=y3kcde",
122                                 {clean_patterns[13], clean_patterns[17], NULL},
123                                 2,      0},
124                 {"FANOUTsubject=FrEaK+SERVERFANOUT",
125                                 {clean_patterns[6], NULL, NULL},
126                                 1,      1},
127                 {"Bad command or filenam",
128                                 {NULL, NULL, NULL},
129                                 0,      0},
130                 {"Bad command or filename",
131                                 {clean_patterns[1], NULL, NULL},
132                                 1,      1},
133                 {"845hyut8hji51 FILE(S) COPIED934ui45",
134                                 {clean_patterns[2], NULL, NULL},
135                                 1,      0},
136                 {"HTTP/1.1 403IndEx of /cgi-bin/",
137                                 {clean_patterns[5], clean_patterns[4], NULL},
138                                 2,      1},
139                 {"mail.php?subject=Mail&body=JJ+BackDoor+-+v&id=2357874",
140                                 {clean_patterns[9], NULL, NULL},
141                                 1,      1},
142                 {"/var/www/site/scripts/WWPMsg.dll",
143                                 {clean_patterns[8], NULL, NULL},
144                                 1,      1},
145                 {"backtrust.com/mail.cgi?subject=Insurrection+Page&body=JJ+BackDoor+-+v",
146                                 {clean_patterns[11], clean_patterns[10], clean_patterns[9]},
147                                 3,      3},
148                 {"User-Agent: Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1)",
149                                 {clean_patterns[12], NULL, NULL},
150                                 1,      1},
151                 {"User-agent: Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1)",
152                                 {clean_patterns[12], NULL, NULL},
153                                 1,      0},
154                 {"http://www.kornputers.com/index.php",
155                                 {clean_patterns[14], NULL, NULL},
156                                 1,      1},
157                 {"\r\n# Nova CGI Notification Script",
158                                 {clean_patterns[15], NULL, NULL},
159                                 1,      1},
160                 {"\r\n# Nova CGI Notification Scrupt",
161                                 {NULL, NULL, NULL},
162                                 0,      0},
163                 {"User Agent: Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1)",
164                                 {NULL, NULL, NULL},
165                                 0,      0},
166                 {"abcfromemail=y3dcde",
167                                 {NULL, NULL, NULL},
168                                 0,      0},
169 };
170
171 struct pm_test_buffer mixed_buffers[] = {
172                 {"jsljelkwlefwe|23|igu5o0",
173                                 {mixed_patterns[3], NULL, NULL},
174                                 1,      1},
175                 {"User-Agent:",
176                                 {mixed_patterns[1], NULL, NULL},
177                                 1,      1},
178                 {"User-Agent#",
179                                 {mixed_patterns[2], NULL, NULL},
180                                 1,      1},
181                 {"User-agEnt:",
182                                 {mixed_patterns[1], NULL, NULL},
183                                 1,      0},
184                 {"www.kornputers.com",
185                                 {mixed_patterns[4], NULL, NULL},
186                                 1,      1},
187                 {"1 file(s) copied from www.kornputers.com ",
188                                 {mixed_patterns[0], mixed_patterns[4], NULL},
189                                 2,      2},
190                 {"www.kornputers.com: 1 File(s) Copied",
191                                 {mixed_patterns[4], mixed_patterns[0], NULL},
192                                 2,      1},
193                 {"1 file(s) copied",
194                                 {mixed_patterns[0], NULL, NULL},
195                                 1,      1},
196                 {"1 file(s) copie",
197                                 {NULL, NULL, NULL},
198                                 0,      0},
199                 {"1 file(s) copieD",
200                                 {mixed_patterns[0], NULL, NULL},
201                                 1,      0},
202                 {"iwrhf34890yuhh *Y89#9ireirgf",
203                                 {mixed_patterns[2], NULL, NULL},
204                                 1,      1},
205 };
206
207 struct pm_test_buffer P1_buffers[] = {
208                 {"1111aA111111",
209                                 {P1_patterns[0], NULL, NULL},
210                                 1,      1},
211                 {"1111Aa111111",
212                                 {P1_patterns[0], NULL, NULL},
213                                 1,      0},
214                 {"1111aA11111",
215                                 {NULL, NULL, NULL},
216                                 0,      0},
217                 {"1111aB11111",
218                                 {NULL, NULL, NULL},
219                                 0,      0},
220                 {"1111aA11112",
221                                 {NULL, NULL, NULL},
222                                 0,      0},
223                 {"1111aA1111111111aA111111",
224                                 {P1_patterns[0], P1_patterns[0], NULL},
225                                 2,      2},
226 };
227
228
229 #endif /* TEST_PMAC_PM_H_ */