Mercurial > hg > freeDiameter
annotate libfdcore/fifo_stats.c @ 1562:6219359a36a9 default tip
Merge latest changes from proposed branch
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Mon, 21 Jun 2021 19:08:18 +0800 |
parents | 018a573b05f0 |
children |
rev | line source |
---|---|
1071
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
4 * * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
5 * Copyright (c) 2013, WIDE Project and NICT * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
6 * All rights reserved. * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
7 * * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
10 * * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
13 * following disclaimer. * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
14 * * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
19 * * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
24 * NICT. * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
25 * * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
35 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
36 #include "fdcore-internal.h" |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
37 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
38 /* See include/freeDiameter/libfdcore.h for more information */ |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
39 int fd_stat_getstats(enum fd_stat_type stat, struct peer_hdr * peer, |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
40 int * current_count, int * limit_count, int * highest_count, long long * total_count, |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
41 struct timespec * total, struct timespec * blocking, struct timespec * last) |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
42 { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
43 struct fd_peer * p = (struct fd_peer *)peer; |
1074
018a573b05f0
Forgot to include the new file in the build
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1071
diff
changeset
|
44 TRACE_ENTRY( "%d %p %p %p %p %p %p %p %p", stat, peer, current_count, limit_count, highest_count, total_count, total, blocking, last); |
1071
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
45 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
46 switch (stat) { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
47 case STAT_G_LOCAL: { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
48 CHECK_FCT( fd_fifo_getstats(fd_g_local, current_count, limit_count, highest_count, total_count, total, blocking, last) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
49 } |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
50 break; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
51 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
52 case STAT_G_INCOMING: { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
53 CHECK_FCT( fd_fifo_getstats(fd_g_incoming, current_count, limit_count, highest_count, total_count, total, blocking, last) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
54 } |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
55 break; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
56 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
57 case STAT_G_OUTGOING: { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
58 CHECK_FCT( fd_fifo_getstats(fd_g_outgoing, current_count, limit_count, highest_count, total_count, total, blocking, last) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
59 } |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
60 break; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
61 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
62 case STAT_P_PSM: { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
63 CHECK_PARAMS( CHECK_PEER( peer ) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
64 CHECK_FCT( fd_fifo_getstats(p->p_events, current_count, limit_count, highest_count, total_count, total, blocking, last) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
65 } |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
66 break; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
67 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
68 case STAT_P_TOSEND: { |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
69 CHECK_PARAMS( CHECK_PEER( peer ) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
70 CHECK_FCT( fd_fifo_getstats(p->p_tosend, current_count, limit_count, highest_count, total_count, total, blocking, last) ); |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
71 } |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
72 break; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
73 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
74 default: |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
75 return EINVAL; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
76 } |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
77 |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
78 return 0; |
6ca6cadf209c
Implement the fd_stat_getstats function; changed prototype of fd_fifo_length.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff
changeset
|
79 } |