85c6a759322fc66ea828bb9507ef0e247fa3e5d5
[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
35 #ifndef TEST_PMAC_PM_H_
36 #define TEST_PMAC_PM_H_
37
38 /**
39  * PATTERNS
40  */
41
42 /*
43  * clean ASCII patterns
44  */
45 #define MAX_PATTERN_LEN 256
46 const char clean_patterns[][MAX_PATTERN_LEN] = {
47                 "Command completed",
48                 "Bad command or filename",
49                 "1 file(s) copied",
50                 "Invalid URL",
51                 "Index of /cgi-bin/",
52                 "HTTP/1.1 403",
53                 "subject=FrEaK+SERVER",
54                 "friend_nickname=",
55                 "/scripts/WWPMsg.dll",
56                 "body=JJ+BackDoor+-+v",
57
58                 "subject=Insurrection+Page",
59                 "backtrust.com",
60                 "User-Agent:",
61                 "fromemail=y3k",
62                 "www.kornputers.com",
63                 "# Nova CGI Notification Script",
64                 /* test NOT converting to binary */
65                 "|23|",
66                 /* test adding same pattern twice - should result in two matches */
67                 "fromemail=y3k",
68 };
69
70 /*
71  * mixed ASCII-binary patterns
72  */
73 const char mixed_patterns[][MAX_PATTERN_LEN] = {
74                 "1 file|28|s|29| copied",
75                 "User-Agent|3A|",
76                 "|23|",                         /* gives # */
77                 "|7C 32 33 7C 00|",     /* gives |23| */
78                 /* test converter not converting stuff erroneously */
79                 "www.kornputers.com",
80 };
81
82 /*
83  * P1 patterns
84  * (P1 is used when having only one pattern)
85  */
86 const char P1_patterns[][MAX_PATTERN_LEN] = {
87                 "1111aA111111",
88 };
89
90
91
92 /**
93  * BUFFERS TO LOOK PATTERNS IN
94  */
95 #define MAX_MATCH_COUNT 3
96
97 struct pm_test_buffer {
98         /* test string */
99         const char string[MAX_PATTERN_LEN];
100         /* strings that should be found marching.
101          * for our test we allow no more than 3 matches.
102          * the number is completely arbitrary */
103         const char * matched_str[MAX_MATCH_COUNT];
104         /* number of matches with and without case sensitivity */
105         uint8_t n_matches;
106         uint8_t n_matches_with_case_sense;
107 };
108
109 struct pm_test_buffer clean_buffers[] = {
110                 {"abcCommand completedcde",
111                                 {clean_patterns[0], NULL, NULL},
112                                 1,      1},
113                 {"jsljelkwlefwe|23|igu5o0",
114                                 {clean_patterns[16], NULL, NULL},
115                                 1,      1},
116                 {"Invalid URLwww.kOrnpUterS.comfRiEnD_niCKname=",
117                                 {clean_patterns[3], clean_patterns[14], clean_patterns[7]},
118                                 3,      1},
119                 {"HTTP/1.1 404",
120                                 {NULL, NULL, NULL},
121                                 0,      0},
122                 {"abcfrOmemail=y3kcde",
123                                 {clean_patterns[13], clean_patterns[17], NULL},
124                                 2,      0},
125                 {"FANOUTsubject=FrEaK+SERVERFANOUT",
126                                 {clean_patterns[6], NULL, NULL},
127                                 1,      1},
128                 {"Bad command or filenam",
129                                 {NULL, NULL, NULL},
130                                 0,      0},
131                 {"Bad command or filename",
132                                 {clean_patterns[1], NULL, NULL},
133                                 1,      1},
134                 {"845hyut8hji51 FILE(S) COPIED934ui45",
135                                 {clean_patterns[2], NULL, NULL},
136                                 1,      0},
137                 {"HTTP/1.1 403IndEx of /cgi-bin/",
138                                 {clean_patterns[5], clean_patterns[4], NULL},
139                                 2,      1},
140                 {"mail.php?subject=Mail&body=JJ+BackDoor+-+v&id=2357874",
141                                 {clean_patterns[9], NULL, NULL},
142                                 1,      1},
143                 {"/var/www/site/scripts/WWPMsg.dll",
144                                 {clean_patterns[8], NULL, NULL},
145                                 1,      1},
146                 {"backtrust.com/mail.cgi?subject=Insurrection+Page&body=JJ+BackDoor+-+v",
147                                 {clean_patterns[11], clean_patterns[10], clean_patterns[9]},
148                                 3,      3},
149                 {"User-Agent: Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1)",
150                                 {clean_patterns[12], NULL, NULL},
151                                 1,      1},
152                 {"User-agent: Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1)",
153                                 {clean_patterns[12], NULL, NULL},
154                                 1,      0},
155                 {"http://www.kornputers.com/index.php",
156                                 {clean_patterns[14], NULL, NULL},
157                                 1,      1},
158                 {"\r\n# Nova CGI Notification Script",
159                                 {clean_patterns[15], NULL, NULL},
160                                 1,      1},
161                 {"\r\n# Nova CGI Notification Scrupt",
162                                 {NULL, NULL, NULL},
163                                 0,      0},
164                 {"User Agent: Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1)",
165                                 {NULL, NULL, NULL},
166                                 0,      0},
167                 {"abcfromemail=y3dcde",
168                                 {NULL, NULL, NULL},
169                                 0,      0},
170 };
171
172 struct pm_test_buffer mixed_buffers[] = {
173                 {"jsljelkwlefwe|23|igu5o0",
174                                 {mixed_patterns[3], NULL, NULL},
175                                 1,      1},
176                 {"User-Agent:",
177                                 {mixed_patterns[1], NULL, NULL},
178                                 1,      1},
179                 {"User-Agent#",
180                                 {mixed_patterns[2], NULL, NULL},
181                                 1,      1},
182                 {"User-agEnt:",
183                                 {mixed_patterns[1], NULL, NULL},
184                                 1,      0},
185                 {"www.kornputers.com",
186                                 {mixed_patterns[4], NULL, NULL},
187                                 1,      1},
188                 {"1 file(s) copied from www.kornputers.com ",
189                                 {mixed_patterns[0], mixed_patterns[4], NULL},
190                                 2,      2},
191                 {"www.kornputers.com: 1 File(s) Copied",
192                                 {mixed_patterns[4], mixed_patterns[0], NULL},
193                                 2,      1},
194                 {"1 file(s) copied",
195                                 {mixed_patterns[0], NULL, NULL},
196                                 1,      1},
197                 {"1 file(s) copie",
198                                 {NULL, NULL, NULL},
199                                 0,      0},
200                 {"1 file(s) copieD",
201                                 {mixed_patterns[0], NULL, NULL},
202                                 1,      0},
203                 {"iwrhf34890yuhh *Y89#9ireirgf",
204                                 {mixed_patterns[2], NULL, NULL},
205                                 1,      1},
206 };
207
208 struct pm_test_buffer P1_buffers[] = {
209                 {"1111aA111111",
210                                 {P1_patterns[0], NULL, NULL},
211                                 1,      1},
212                 {"1111Aa111111",
213                                 {P1_patterns[0], NULL, NULL},
214                                 1,      0},
215                 {"1111aA11111",
216                                 {NULL, NULL, NULL},
217                                 0,      0},
218                 {"1111aB11111",
219                                 {NULL, NULL, NULL},
220                                 0,      0},
221                 {"1111aA11112",
222                                 {NULL, NULL, NULL},
223                                 0,      0},
224                 {"1111aA1111111111aA111111",
225                                 {P1_patterns[0], P1_patterns[0], NULL},
226                                 2,      2},
227 };
228
229
230 #endif /* TEST_PMAC_PM_H_ */