-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
38 lines (34 loc) · 1.06 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <string.h>
#include "iping.h"
#include "genframe.h"
int main(int argc, char *argv[]) {
frame_op* options = init_frame_op();
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i],"--help") == 0) {
printf("\nHelp Message!\n");
}
if (strcmp(argv[i],"--l3") == 0) {
if (strcmp(argv[i+1], "ipv4") == 0) {
options->typeL4 = IPV4;
options->frame_length += 20;
}
else if (strcmp(argv[i+1], "ipv6") == 0) {
options->typeL4 = IPV4;
options->frame_length += 40;
}
}
if (strcmp(argv[i],"--l4") == 0) {
if (strcmp(argv[i+1], "tcp") == 0) {genframe(options);
options->typeL3 = TCP;
options->frame_length += 20;
}
else if (strcmp(argv[i+1], "udp")==0) {
options->typeL4 = UDP;
options->frame_length += 8;
}
}
}
genframe(options);
return 0;
}