@@ -141,114 +141,3 @@ void process_redis_list(pibs_t* pibs)
141
141
}
142
142
}
143
143
}
144
-
145
-
146
- int main (int argc , char * argv [])
147
- {
148
-
149
- int opt ;
150
- pibs_t * pibs ;
151
-
152
- pibs = init ();
153
-
154
- fprintf (stderr , "[INFO] pid = %d\n" ,(int )getpid ());
155
-
156
- while ((opt = getopt (argc , argv , "r:dbsni:au:z:p:w:y:" )) != -1 ) {
157
- switch (opt ) {
158
- case 'r' :
159
- strncpy (pibs -> filename , optarg , FILENAME_MAX );
160
- break ;
161
- case 'd' :
162
- pibs -> should_dump_table = 1 ;
163
- break ;
164
- case 'b' :
165
- pibs -> show_backscatter = 1 ;
166
- break ;
167
- case 's' :
168
- pibs -> show_stats = 1 ;
169
- break ;
170
- case 'n' :
171
- pibs -> should_create_shm = 1 ;
172
- break ;
173
- case 'i' :
174
- strncpy (pibs -> shmid_file , optarg , FILENAME_MAX );
175
- break ;
176
- case 'a' :
177
- pibs -> should_attach = 1 ;
178
- break ;
179
- case 'u' :
180
- strncpy (pibs -> uuid , optarg , SZUUID );
181
- break ;
182
- case 'z' :
183
- strncpy (pibs -> server ,optarg , SZSERVER );
184
- break ;
185
- case 'p' :
186
- pibs -> port = atoi (optarg );
187
- break ;
188
- case 'w' :
189
- strncpy (pibs -> outputfile ,optarg , FILENAME_MAX );
190
- pibs -> should_writepcap = 1 ;
191
- break ;
192
- case 'y' :
193
- pibs -> redisdb = atoi (optarg );
194
- break ;
195
-
196
- default : /* '?' */
197
-
198
- fprintf (stderr , "[ERROR] Invalid command line was specified\n" );
199
- }
200
- }
201
- if (pibs -> should_create_shm ) {
202
- pibs_shmget (pibs );
203
- if (pibs -> shmid > 0 ){
204
- printf ("Create a new shared memory segment %d\n" , pibs -> shmid );
205
- } else {
206
- printf ("Failed to get shared memory segment. Cause = %s\n" ,
207
- strerror (pibs -> errno_copy ));
208
- }
209
- }
210
- if (pibs -> should_attach ) {
211
- if (pibs_shmat (pibs ) > 0 ) {
212
- printf ("Attached to shared memory segment %d\n" , pibs -> shmid );
213
- } else {
214
- printf ("Failed to attach to shared memory segment. System error:%s\n" ,
215
- strerror (pibs -> errno_copy ));
216
- return EXIT_FAILURE ;
217
- }
218
- }
219
- if (pibs -> uuid [0 ]) {
220
- if ((pibs -> server [0 ] == 0 ) || (pibs -> port == 0 )) {
221
- fprintf (stderr ,"Redis parameter server and port are incomplete. Use -z and -p options.\n" );
222
- return EXIT_FAILURE ;
223
- }
224
- process_redis_list (pibs );
225
- }
226
-
227
- //FIXME Add proper error handling for writecap
228
- if (pibs -> should_writepcap ) {
229
- pibs -> outcap = pcap_open_dead (DLT_EN10MB , 65535 );
230
- pibs -> dumper = pcap_dump_open (pibs -> outcap , pibs -> outputfile );
231
- if (pibs -> dumper == NULL ) {
232
- printf ("Failed to open outputfile. Reason=%s\n" , pcap_geterr (pibs -> outcap ));
233
- return EXIT_FAILURE ;
234
- }
235
- }
236
-
237
- if (pibs -> show_backscatter )
238
- printf ("#timestamp, source IP, TCP flags, source port\n" );
239
- if (pibs -> filename [0 ]) {
240
- process_file (pibs );
241
- }
242
- if (pibs -> should_dump_table ){
243
- pibs_dump_raw (pibs );
244
- pibs_dump_raw (pibs );
245
- }
246
- if (pibs -> show_stats ){
247
- pibs_dump_stats (pibs );
248
- }
249
- if (pibs -> should_writepcap ) {
250
- pcap_dump_close (pibs -> dumper );
251
- printf ("[INFO] Created pcap file %s\n" , pibs -> outputfile );
252
- }
253
- return EXIT_FAILURE ;
254
- }
0 commit comments