61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include "cap_utils.h"
|
||
|
#include "net_tools.h"
|
||
|
|
||
|
int main(int argc, char** argv) {
|
||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||
|
printf("~ capreplay ~\n");
|
||
|
|
||
|
int opt, verbose = 0, is_active = 0;
|
||
|
char *outf, *inf;
|
||
|
while ((opt = getopt(argc, argv, "r:s:m:v")) != -1) {
|
||
|
switch(opt) {
|
||
|
case 'v':
|
||
|
verbose++;
|
||
|
break;
|
||
|
case 'r':
|
||
|
inf = optarg;
|
||
|
break;
|
||
|
case 's':
|
||
|
outf = optarg;
|
||
|
break;
|
||
|
case 'm':
|
||
|
is_active = strcmp(optarg, "active") == 0;
|
||
|
break;
|
||
|
default:
|
||
|
goto usage;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
struct cap_file cf;
|
||
|
cap_load(&cf, inf);
|
||
|
|
||
|
size_t nbp = cap_count_bp (&cf);
|
||
|
if (nbp < 1) {
|
||
|
fprintf(stderr, "No buffer packet to read\n");
|
||
|
exit(EXIT_FAILURE);
|
||
|
}
|
||
|
|
||
|
struct timespec started;
|
||
|
struct buffer_packet bp;
|
||
|
cap_peek_bp (&cf, &bp);
|
||
|
started = bp.seen;
|
||
|
|
||
|
int fd = create_udp_client ("127.0.0.1", "5000");
|
||
|
|
||
|
for (int c = 0; c < nbp; c++) {
|
||
|
cap_next_bp (&cf, &bp);
|
||
|
//sleep(bp.seen);
|
||
|
// send on UDP to 127.13.3.7
|
||
|
// sleep for given time
|
||
|
//sendto(fd, bp.ip.ap.fmt.content.clear.payload);
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
|
||
|
usage:
|
||
|
fprintf(stderr, "Usage: %s -r FILE.0 -s FILE.1 -m [active|passive] [-v]\n", argv[0]);
|
||
|
return 1;
|
||
|
}
|