Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
fad04307
Commit
fad04307
authored
Jan 31, 2008
by
Browse files
Reverted previous "fix". Pebkac.
git-svn-id:
file:///home/svn/mapi/trunk@1373
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
810d25d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
applications/packetloss/packetloss.c
View file @
fad04307
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#define WITH_NCURSES 0 // set to 1 if you want ncurses, 0 otherwise
#define WITH_NCURSES 0 // set to 1 if you want ncurses, 0 otherwise
#define REFRESH_TIME 10 // 10 seconds base interval with which data will be fed into the RRD
#define REFRESH_TIME 10 // 10 seconds base interval with which data will be fed into the RRD
#define SHM_FLOWS_DEVICE_MAX 4999
9
// (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
sizeof(unsigned int)
) / sizeof(struct flow_data))
#define SHM_FLOWS_DEVICE_MAX 4999
8
// (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
cca24
) / sizeof(struct flow_data))
#define SHM_FLOWS_TOTAL_MAX 250000
#define SHM_FLOWS_TOTAL_MAX 250000
#define TIMESTAMP_TOLERANCE 430000000 // NTP 0.1
#define TIMESTAMP_TOLERANCE 430000000 // NTP 0.1
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
...
@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
...
@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
unsigned
int
*
results
;
// number of results/flowdata = (unsigned int *) ...
unsigned
int
*
results
;
// number of results/flowdata = (unsigned int *) ...
struct
flows_stat
*
flowsstats
;
struct
flows_stat
*
flowsstats
;
struct
flow_data
*
flowdata
;
// result/flowdata = (struct flow_data *)((char *) ... + sizeof(flows_stat)
+ sizeof(unsigned int))
;
struct
flow_data
*
flowdata
;
// result/flowdata = (struct flow_data *)((char *) ...
)
+ sizeof(flows_stat);
unsigned
long
long
pkloss
=
0
;
unsigned
long
long
pkloss
=
0
;
...
@@ -710,7 +710,7 @@ int main(int argc, char *argv[])
...
@@ -710,7 +710,7 @@ int main(int argc, char *argv[])
}
}
results
=
(
unsigned
int
*
)
host
[
h
].
results_dev
[
d
].
res
;
// number of results/flows at host h, dev d
results
=
(
unsigned
int
*
)
host
[
h
].
results_dev
[
d
].
res
;
// number of results/flows at host h, dev d
flowsstats
=
(
struct
flows_stat
*
)
host
[
h
].
results_dev
[
d
].
res
;
flowsstats
=
(
struct
flows_stat
*
)
host
[
h
].
results_dev
[
d
].
res
;
flowdata
=
(
struct
flow_data
*
)((
char
*
)
host
[
h
].
results_dev
[
d
].
res
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
);
// results/flows array
flowdata
=
(
struct
flow_data
*
)((
char
*
)
host
[
h
].
results_dev
[
d
].
res
+
sizeof
(
flows_stat
));
// results/flows array
fprintf
(
stdout
,
"packetloss: storing and matching results from %s:%d: %d
\n
"
,
host
[
h
].
name
,
d
,
*
results
);
fflush
(
stdout
);
fprintf
(
stdout
,
"packetloss: storing and matching results from %s:%d: %d
\n
"
,
host
[
h
].
name
,
d
,
*
results
);
fflush
(
stdout
);
// store flowstats_dev
// store flowstats_dev
...
@@ -763,7 +763,7 @@ int main(int argc, char *argv[])
...
@@ -763,7 +763,7 @@ int main(int argc, char *argv[])
// }}}
// }}}
results
=
(
unsigned
int
*
)
host
[
h
].
results_dev
[
d
].
res
;
// number of results/flows
results
=
(
unsigned
int
*
)
host
[
h
].
results_dev
[
d
].
res
;
// number of results/flows
flowdata
=
(
struct
flow_data
*
)
((
char
*
)
host
[
h
].
results_dev
[
d
].
res
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
);
// results/flows array
flowdata
=
(
struct
flow_data
*
)
((
char
*
)
host
[
h
].
results_dev
[
d
].
res
+
sizeof
(
flows_stat
));
// results/flows array
for
(
count
=
*
results
;
count
>
0
;
count
--
)
{
for
(
count
=
*
results
;
count
>
0
;
count
--
)
{
if
(
LOGFILE
)
{
if
(
LOGFILE
)
{
...
...
src/extraflib/expiredflowshash.h
View file @
fad04307
#define EXFL_HASH_SIZE 262144 //4
096
#define EXFL_HASH_SIZE 262144 //4
128
#include "protocols.h"
#include "protocols.h"
...
...
src/extraflib/exprflow.c
View file @
fad04307
...
@@ -35,7 +35,6 @@ pthread_t pthread;
...
@@ -35,7 +35,6 @@ pthread_t pthread;
typedef
struct
shm
{
typedef
struct
shm
{
unsigned
int
*
size
;
unsigned
int
*
size
;
unsigned
int
*
shm_flows
;
flow_data
*
Table
;
flow_data
*
Table
;
pthread_mutex_t
*
smmutex
;
pthread_mutex_t
*
smmutex
;
}
shm
;
}
shm
;
...
@@ -252,8 +251,8 @@ void poll_expired_flows(mapidflib_function_instance_t *instance) {
...
@@ -252,8 +251,8 @@ void poll_expired_flows(mapidflib_function_instance_t *instance) {
stats
=
(
flows_stat
*
)
instance
->
result
.
data
;
stats
=
(
flows_stat
*
)
instance
->
result
.
data
;
shm_struct
.
size
=
(
unsigned
int
*
)
instance
->
result
.
data
;
shm_struct
.
size
=
(
unsigned
int
*
)
instance
->
result
.
data
;
shm_struct
.
Table
=
(
flow_data
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
);
shm_struct
.
Table
=
(
flow_data
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
));
shm_struct
.
smmutex
=
(
pthread_mutex_t
*
)(((
char
*
)
instance
->
result
.
data
)
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
struct
flow_data
)
*
data
->
shm_flows
);
shm_struct
.
smmutex
=
(
pthread_mutex_t
*
)(((
char
*
)
instance
->
result
.
data
)
+
sizeof
(
flows_stat
)
+
sizeof
(
struct
flow_data
)
*
data
->
shm_flows
);
*
(
shm_struct
.
size
)
=
0
;
*
(
shm_struct
.
size
)
=
0
;
while
(
data
->
run
)
{
while
(
data
->
run
)
{
...
@@ -383,12 +382,12 @@ static int exprflow_instance(mapidflib_function_instance_t *instance,
...
@@ -383,12 +382,12 @@ static int exprflow_instance(mapidflib_function_instance_t *instance,
MAPI_UNUSED
int
fd
,
MAPI_UNUSED
int
fd
,
MAPI_UNUSED
mapidflib_flow_mod_t
*
flow_mod
)
{
MAPI_UNUSED
mapidflib_flow_mod_t
*
flow_mod
)
{
mapiFunctArg
*
fargs
;
mapiFunctArg
*
fargs
;
int
shm_flows
;
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
sizeof(unsigned int)
) / sizeof(struct flow_data))
int
shm_flows
;
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
cca24
) / sizeof(struct flow_data))
fargs
=
instance
->
args
;
fargs
=
instance
->
args
;
shm_flows
=
getargint
(
&
fargs
);
shm_flows
=
getargint
(
&
fargs
);
instance
->
def
->
shm_size
=
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
+
sizeof
(
unsigned
int
)
+
sizeof
(
pthread_mutex_t
);
instance
->
def
->
shm_size
=
sizeof
(
flows_stat
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
+
sizeof
(
pthread_mutex_t
);
return
0
;
return
0
;
}
}
...
@@ -424,23 +423,21 @@ static int exprflow_init(mapidflib_function_instance_t *instance, MAPI_UNUSED in
...
@@ -424,23 +423,21 @@ static int exprflow_init(mapidflib_function_instance_t *instance, MAPI_UNUSED in
data
->
epoch
=
0
;
data
->
epoch
=
0
;
// function arguments
// function arguments
data
->
shm_flows
=
getargint
(
&
fargs
);
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
sizeof(unsigned int)
) / sizeof(struct flow_data))
data
->
shm_flows
=
getargint
(
&
fargs
);
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
cca24
) / sizeof(struct flow_data))
data
->
expired_flows_list_size_max
=
getargint
(
&
fargs
);
data
->
expired_flows_list_size_max
=
getargint
(
&
fargs
);
data
->
packets_count_min
=
getargint
(
&
fargs
);
data
->
packets_count_min
=
getargint
(
&
fargs
);
// Shared Memory Initialization
// Shared Memory Initialization
stats
=
(
flows_stat
*
)
instance
->
result
.
data
;
stats
=
(
flows_stat
*
)
instance
->
result
.
data
;
shm_struct
.
size
=
(
unsigned
int
*
)
instance
->
result
.
data
;
shm_struct
.
size
=
(
unsigned
int
*
)
instance
->
result
.
data
;
shm_struct
.
shm_flows
=
(
unsigned
int
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
));
shm_struct
.
Table
=
(
flow_data
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
));
shm_struct
.
Table
=
(
flow_data
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
));
shm_struct
.
smmutex
=
(
pthread_mutex_t
*
)(((
char
*
)
instance
->
result
.
data
)
+
sizeof
(
flows_stat
)
+
sizeof
(
struct
flow_data
)
*
data
->
shm_flows
);
shm_struct
.
smmutex
=
(
pthread_mutex_t
*
)(((
char
*
)
instance
->
result
.
data
)
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
struct
flow_data
)
*
data
->
shm_flows
);
stats
->
received
=
0
;
stats
->
received
=
0
;
stats
->
expired
=
0
;
stats
->
expired
=
0
;
*
(
shm_struct
.
size
)
=
0
;
//stats->sent = 0;
*
(
shm_struct
.
size
)
=
0
;
//stats->sent = 0;
stats
->
ignored
=
0
;
stats
->
ignored
=
0
;
stats
->
dropped
=
0
;
stats
->
dropped
=
0
;
*
(
shm_struct
.
shm_flows
)
=
data
->
shm_flows
;
//mutex initialization
//mutex initialization
*
(
shm_struct
.
smmutex
)
=
tmpmutex
;
*
(
shm_struct
.
smmutex
)
=
tmpmutex
;
...
@@ -609,27 +606,22 @@ void print_flow(eflow_data *data) {
...
@@ -609,27 +606,22 @@ void print_flow(eflow_data *data) {
}
}
static
int
exprflow_client_read_result
(
mapidflib_function_instance_t
*
instance
,
mapi_result_t
*
res
)
{
static
int
exprflow_client_read_result
(
mapidflib_function_instance_t
*
instance
,
mapi_result_t
*
res
)
{
unsigned
int
size
;
shm
shm_struct
;
shm
shm_struct
;
eflow_data
*
data
;
flows_stat
*
stats
;
flows_stat
*
stats
;
mapiFunctArg
*
fargs
;
mapiFunctArg
*
fargs
;
int
shm_flows
;
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
sizeof(unsigned int)
) / sizeof(struct flow_data))
int
shm_flows
;
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
cca24
) / sizeof(struct flow_data))
fargs
=
instance
->
args
;
fargs
=
instance
->
args
;
shm_flows
=
getargint
(
&
fargs
);
shm_flows
=
getargint
(
&
fargs
);
stats
=
(
flows_stat
*
)
instance
->
result
.
data
;
stats
=
(
flows_stat
*
)
instance
->
result
.
data
;
shm_struct
.
size
=
(
unsigned
int
*
)
instance
->
result
.
data
;
shm_struct
.
size
=
(
unsigned
int
*
)
instance
->
result
.
data
;
shm_struct
.
shm_flows
=
(
unsigned
int
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
));
shm_struct
.
Table
=
(
flow_data
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
));
shm_struct
.
Table
=
(
flow_data
*
)((
char
*
)
instance
->
result
.
data
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
));
shm_struct
.
smmutex
=
(
pthread_mutex_t
*
)(((
char
*
)
instance
->
result
.
data
)
+
sizeof
(
flows_stat
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
);
fprintf
(
stdout
,
"shm_flows: %u"
,
*
(
shm_struct
.
shm_flows
));
fflush
(
stdout
);
shm_struct
.
smmutex
=
(
pthread_mutex_t
*
)(((
char
*
)
instance
->
result
.
data
)
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
struct
flow_data
)
*
(
*
shm_struct
.
shm_flows
));
res
->
res
=
instance
->
internal_data
;
res
->
res
=
instance
->
internal_data
;
res
->
size
=
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
flow_data
)
*
(
*
(
shm_struct
.
size
));
res
->
size
=
sizeof
(
flows_stat
)
+
sizeof
(
flow_data
)
*
(
*
(
shm_struct
.
size
));
size
=
*
shm_struct
.
size
;
pthread_mutex_lock
(
shm_struct
.
smmutex
);
pthread_mutex_lock
(
shm_struct
.
smmutex
);
memcpy
(
instance
->
internal_data
,
instance
->
result
.
data
,
res
->
size
);
memcpy
(
instance
->
internal_data
,
instance
->
result
.
data
,
res
->
size
);
...
@@ -640,25 +632,24 @@ fprintf(stdout, "shm_flows: %u", *(shm_struct.shm_flows)); fflush(stdout);
...
@@ -640,25 +632,24 @@ fprintf(stdout, "shm_flows: %u", *(shm_struct.shm_flows)); fflush(stdout);
stats
->
dropped
=
0
;
stats
->
dropped
=
0
;
pthread_mutex_unlock
(
shm_struct
.
smmutex
);
pthread_mutex_unlock
(
shm_struct
.
smmutex
);
data
=
(
flow_data
*
)((
char
*
)
instance
->
internal_data
+
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
));
return
(
0
);
return
(
0
);
}
}
static
int
exprflow_client_init
(
mapidflib_function_instance_t
*
instance
,
void
*
data
)
{
static
int
exprflow_client_init
(
mapidflib_function_instance_t
*
instance
,
void
*
data
)
{
mapiFunctArg
*
fargs
;
mapiFunctArg
*
fargs
;
int
shm_flows
;
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
sizeof(unsigned int)
) / sizeof(struct flow_data))
int
shm_flows
;
// max: (DIMAPI_DATA_SIZE - sizeof(flows_stat) -
cca24
) / sizeof(struct flow_data))
fargs
=
instance
->
args
;
fargs
=
instance
->
args
;
shm_flows
=
getargint
(
&
fargs
);
shm_flows
=
getargint
(
&
fargs
);
if
(
shm_flows
>
(
DIMAPI_DATA_SIZE
-
sizeof
(
flows_stat
)
-
sizeof
(
unsigned
int
)
)
/
sizeof
(
struct
flow_data
))
{
if
(
shm_flows
>
(
DIMAPI_DATA_SIZE
-
sizeof
(
flows_stat
)
-
24
)
/
sizeof
(
struct
flow_data
))
{
printf
(
"Cannot process %d flows. Maximum is %d.
\n
"
,
shm_flows
,
(
DIMAPI_DATA_SIZE
-
sizeof
(
flows_stat
))
/
sizeof
(
struct
flow_data
));
printf
(
"Cannot process %d flows. Maximum is %d.
\n
"
,
shm_flows
,
(
DIMAPI_DATA_SIZE
-
sizeof
(
flows_stat
)
-
24
)
/
sizeof
(
struct
flow_data
));
return
(
-
1
);
return
(
-
1
);
}
}
if
((
instance
->
internal_data
=
malloc
(
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
))
==
NULL
)
{
if
((
instance
->
internal_data
=
malloc
(
sizeof
(
flows_stat
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
))
==
NULL
)
{
printf
(
"Malloc failed for size %d [%s:%d]
\n
"
,
sizeof
(
flows_stat
)
+
sizeof
(
unsigned
int
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
,
__FILE__
,
__LINE__
);
printf
(
"Malloc failed for size %d [%s:%d]
\n
"
,
sizeof
(
flows_stat
)
+
sizeof
(
struct
flow_data
)
*
shm_flows
,
__FILE__
,
__LINE__
);
return
(
-
1
);
return
(
-
1
);
}
}
data
=
instance
->
internal_data
;
data
=
instance
->
internal_data
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment