-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
60 lines (45 loc) · 1.05 KB
/
main.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <cstdio>
using namespace std;
int data[9999];
int indx;
void printf_data(int nstart, int nend) {
printf("### ");
for (int tmpi = nstart; tmpi <= nend; tmpi++) {
printf("%d ", data[tmpi]);
}
printf("\n");
}
int main(int argc, char *argv[]) {
cout << "Hello World!" << endl;
FILE *fil = NULL;
if (argc > 1) fil = fopen(argv[1], "r");
indx = 0;
if (fil != NULL) {
while (!feof(fil)) {
fscanf(fil, "%x", &data[indx++]);
}
}
printf("length of data: %d \n", indx);
printf("source addr: ");
printf_data(0, 5); // source address
printf("dest addr: ");
printf_data(6, 11); // dest address
printf("IP type: ");
printf("%.2x %.2x", data[13], data[12]); // 13 12 ip type
printf("source IP addr: ");
printf_data(26, 29);
printf("dest IP addr: ");
printf_data(30, 33);
printf("max length: ");
printf_data(34, 35);
printf("head jiaoyanma");
printf_data(24, 25);
printf("source port");
printf_data(34, 35);
printf("dest port");
printf_data(36, 37);
printf("window size: ");
printf_data(48, 49);
return 0;
}