aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorberat <beratiz@gmail.com>2017-05-01 14:37:12 +0200
committerberat <beratiz@gmail.com>2017-05-01 14:37:12 +0200
commit32d02836f01c2c2938750e608c64e0c98775649b (patch)
tree84ef677847e37f40309613f3418c79c67162db66 /example
parent4030b52ecb5c7a98eeb3eadc362eab60521fb565 (diff)
fixed syntax for gcc compiler
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 63e33d783..8fa1b10ce 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -832,6 +832,7 @@ void freeIpTree(addr_node *root) {
void updateTopIpAddress(u_int32_t addr, int count, struct info_pair top[], int size){
int update = 0;
+ int i;
int min_i = 0;
int min = count;
@@ -842,7 +843,7 @@ void updateTopIpAddress(u_int32_t addr, int count, struct info_pair top[], int s
/* if the same ip with a bigger
count just update it */
- for(int i=0; i<size; i++) {
+ for(i=0; i<size; i++) {
if (top[i].addr == addr) {
top[i].count = count;
return;
@@ -851,7 +852,7 @@ void updateTopIpAddress(u_int32_t addr, int count, struct info_pair top[], int s
/* if array is not full yet
add it to the first empty place */
- for(int i=0; i<size; i++) {
+ for(i=0; i<size; i++) {
if (top[i].addr != addr && top[i].count == 0) {
top[i] = pair;
return;
@@ -859,7 +860,7 @@ void updateTopIpAddress(u_int32_t addr, int count, struct info_pair top[], int s
}
/* if bigger than the smallest one, replace it */
- for(int i=0; i<size; i++) {
+ for(i=0; i<size; i++) {
if(top[i].count < count && top[i].count < min){
min = top[i].count;
min_i = i;
@@ -1199,6 +1200,7 @@ void printPortStats(struct port_stats *stats) {
struct port_stats *s, *tmp;
char ip_name[48];
int i = 0;
+ int j = 0;
int first = 1;
@@ -1208,16 +1210,18 @@ void printPortStats(struct port_stats *stats) {
qsort(&s->top_ip_addrs[0], MAX_NUM_IP_ADDRESS, sizeof(struct info_pair), info_pair_cmp);
- for(int i=0;i<MAX_NUM_IP_ADDRESS;i++) {
- if (s->top_ip_addrs[i].count != 0) {
- inet_ntop(AF_INET, &s->top_ip_addrs[i].addr, ip_name, sizeof(ip_name));
+ for(j=0; j<MAX_NUM_IP_ADDRESS; j++) {
+ if (s->top_ip_addrs[j].count != 0) {
+ inet_ntop(AF_INET, &s->top_ip_addrs[j].addr, ip_name, sizeof(ip_name));
printf("\t\t\t\t%s\t%s ~ %.2f%%\n", (first) ? "Top IP Stats:" : "\t",
- ip_name, ((s->top_ip_addrs[i].count) * 100.0) / s->cumulative_addr);
+ ip_name, ((s->top_ip_addrs[j].count) * 100.0) / s->cumulative_addr);
first = 0;
}
}
+
printf("\n");
first = 1;
+
if(i >= 10) break;
}
}