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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
Description: s_addr may be a macro
Index: knot/src/knot/stat/stat.c
===================================================================
--- knot.orig/src/knot/stat/stat.c 2014-05-24 14:03:58.252864051 +0400
+++ knot/src/knot/stat/stat.c 2014-05-24 14:33:01.893720770 +0400
@@ -69,19 +69,19 @@
* \brief Calculates very simple hash from IPv4 address and returns index to
* array.
*
- * \param s_addr Socket address structure.
+ * \param sa Socket address structure.
* \param protocol Used protocol.
*
* \return uint Calculated index.
*/
-static uint return_index(struct sockaddr_in *s_addr , protocol_t protocol)
+static uint return_index(struct sockaddr_in *sa , protocol_t protocol)
{
/* TODO IPv6 */
/* This is the first "hash" I could think of quickly. */
uint ret = 0;
char str[24];
- inet_ntop(AF_INET, &s_addr->sin_addr, str, 24);
+ inet_ntop(AF_INET, &sa->sin_addr, str, 24);
for (int i = 0; i < strlen(str); i++) {
if (str[i] != '.') {
@@ -90,7 +90,7 @@
}
}
- ret += s_addr->sin_port * 7;
+ ret += sa->sin_port * 7;
if (protocol == stat_UDP) {
ret *= 3;
} else {
@@ -113,10 +113,10 @@
static int stat_gatherer_add_data(stat_t *stat)
{
/* TODO IPv6*/
- uint index = return_index(stat->s_addr, stat->protocol);
+ uint index = return_index(stat->sa, stat->protocol);
if (!local_gath->freq_array[index]) {
char addr[24];
- inet_ntop(AF_INET, &stat->s_addr->sin_addr, addr, 24);
+ inet_ntop(AF_INET, &stat->sa->sin_addr, addr, 24);
flow_data_t *tmp;
tmp = malloc(sizeof(flow_data_t));
if (tmp == NULL) {
@@ -130,7 +130,7 @@
return -1;
}
strcpy(tmp->addr, addr);
- tmp->port = stat->s_addr->sin_port;
+ tmp->port = stat->sa->sin_port;
tmp->protocol = stat->protocol;
local_gath->flow_array[index] = tmp;
}
@@ -231,12 +231,12 @@
stat->protocol = protocol;
}
-void stat_get_first(stat_t *stat , struct sockaddr_in *s_addr)
+void stat_get_first(stat_t *stat , struct sockaddr_in *sa)
{
/* CLEANUP */
// gettimeofday(&stat->t2, NULL);
- stat->s_addr = s_addr;
-// check if s_addr does not get overwritten
+ stat->sa = sa;
+// check if sa does not get overwritten
}
void stat_get_second(stat_t *stat)
Index: knot/src/knot/stat/stat.h
===================================================================
--- knot.orig/src/knot/stat/stat.h 2014-05-24 14:03:58.253187794 +0400
+++ knot/src/knot/stat/stat.h 2014-05-24 14:31:46.374073829 +0400
@@ -58,7 +58,7 @@
struct stat_stat {
// struct timespec t1, t2; /* Currently disabled */
protocol_t protocol; /*!< Flags. */
- struct sockaddr_in *s_addr;
+ struct sockaddr_in *sa;
// gatherer_t *gatherer; / * not needed when using static gatherer. */
};
@@ -94,13 +94,13 @@
* \brief Gets the time from a processing function.
*
* \param stat Current instance of stat_t.
- * \param s_addr Sockaddr structure to be used later for statistics.
+ * \param sa Sockaddr structure to be used later for statistics.
*/
#ifdef STAT_COMPILE
#warning "stat fixme: pass sockaddr* for generic _in and _in6 support"
-void stat_get_first(stat_t *stat, struct sockaddr_in *s_addr);
+void stat_get_first(stat_t *stat, struct sockaddr_in *sa);
#else
-static inline void stat_get_first(stat_t *stat, struct sockaddr *s_addr) {}
+static inline void stat_get_first(stat_t *stat, struct sockaddr *sa) {}
#endif /* STAT_COMPILE */
/*!
|