Debian Codegraph @

agent/mibgroup/sctp-mib/sctpScalars_common.c

raw
1 #include <net-snmp/net-snmp-config.h>
2 #include <net-snmp/net-snmp-includes.h>
3 #include <net-snmp/agent/net-snmp-agent-includes.h>
4
5 #include "sctpScalars_common.h"
6
7 netsnmp_sctp_stats sctp_stats;
8 static netsnmp_sctp_stats prev_sctp_stats;
9
10 netsnmp_sctp_params sctp_params;
11
12 static int need_wrap_check = 1;
13
14 void
15 netsnmp_access_sctp_stats_init(void)
16 {
17 netsnmp_access_sctp_stats_arch_init();
18 }
19
20 int
21 netsnmp_access_sctp_stats_load(netsnmp_cache * cache, void *magic)
22 {
23 netsnmp_sctp_stats new_stats;
24 int ret;
25
26 DEBUGMSGTL(("sctp:scalars:stats:load", "called\n"));
27
28 ret = netsnmp_access_sctp_stats_arch_load(&new_stats);
29 if (ret < 0) {
30 DEBUGMSGTL(("sctp:scalars:stats:load", "arch load failed\n"));
31 return ret;
32 }
33
34 /*
35 * If we've determined that we have 64 bit counters, just copy them.
36 */
37 if (0 == need_wrap_check) {
38 memcpy(&sctp_stats, &new_stats, sizeof(new_stats));
39 return 0;
40 }
41
42 /*
43 * Update 32 bit counters
44 */
45 sctp_stats.curr_estab = new_stats.curr_estab;
46 sctp_stats.active_estabs = new_stats.active_estabs;
47 sctp_stats.passive_estabs = new_stats.passive_estabs;
48 sctp_stats.aborteds = new_stats.aborteds;
49 sctp_stats.shutdowns = new_stats.shutdowns;
50 sctp_stats.out_of_blues = new_stats.out_of_blues;
51 sctp_stats.checksum_errors = new_stats.checksum_errors;
52 sctp_stats.discontinuity_time = new_stats.discontinuity_time;
53
54 /*
55 * Update 64 bit counters
56 */
57 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.out_ctrl_chunks,
58 &new_stats.out_ctrl_chunks,
59 &prev_sctp_stats.out_ctrl_chunks,
60 &need_wrap_check))
61 NETSNMP_LOGONCE((LOG_ERR,
62 "SCTP: Error expanding sctpOutCtrlChunks to 64bits\n"));
63
64 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.out_order_chunks,
65 &new_stats.out_order_chunks,
66 &prev_sctp_stats.out_order_chunks,
67 &need_wrap_check))
68 NETSNMP_LOGONCE((LOG_ERR,
69 "SCTP: Error expanding sctpOutOrderChunks to 64bits\n"));
70
71 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.out_unorder_chunks,
72 &new_stats.out_unorder_chunks,
73 &prev_sctp_stats.out_unorder_chunks,
74 &need_wrap_check))
75 NETSNMP_LOGONCE((LOG_ERR,
76 "SCTP: Error expanding sctpOutUnorderChunks to 64bits\n"));
77
78 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.in_ctrl_chunks,
79 &new_stats.in_ctrl_chunks,
80 &prev_sctp_stats.in_ctrl_chunks,
81 &need_wrap_check))
82 NETSNMP_LOGONCE((LOG_ERR,
83 "SCTP: Error expanding sctpInCtrlChunks to 64bits\n"));
84
85 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.in_order_chunks,
86 &new_stats.in_order_chunks,
87 &prev_sctp_stats.in_order_chunks,
88 &need_wrap_check))
89 NETSNMP_LOGONCE((LOG_ERR,
90 "SCTP: Error expanding sctpInOrderChunks to 64bits\n"));
91
92 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.in_unorder_chunks,
93 &new_stats.in_unorder_chunks,
94 &prev_sctp_stats.in_unorder_chunks,
95 &need_wrap_check))
96 NETSNMP_LOGONCE((LOG_ERR,
97 "SCTP: Error expanding sctpInUnorderChunks to 64bits\n"));
98
99 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.frag_usr_msgs,
100 &new_stats.frag_usr_msgs,
101 &prev_sctp_stats.frag_usr_msgs,
102 &need_wrap_check))
103 NETSNMP_LOGONCE((LOG_ERR,
104 "SCTP: Error expanding sctpFragUsrMsgs to 64bits\n"));
105
106 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.reasm_usr_msgs,
107 &new_stats.reasm_usr_msgs,
108 &prev_sctp_stats.reasm_usr_msgs,
109 &need_wrap_check))
110 NETSNMP_LOGONCE((LOG_ERR,
111 "SCTP: Error expanding sctpReasmUsrMsgs to 64bits\n"));
112
113 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.out_sctp_packs,
114 &new_stats.out_sctp_packs,
115 &prev_sctp_stats.out_sctp_packs,
116 &need_wrap_check))
117 NETSNMP_LOGONCE((LOG_ERR,
118 "SCTP: Error expanding sctpOutSCTPPacks to 64bits\n"));
119
120 if (0 != netsnmp_c64_check32_and_update(&sctp_stats.in_sctp_packs,
121 &new_stats.in_sctp_packs,
122 &prev_sctp_stats.in_sctp_packs,
123 &need_wrap_check))
124 NETSNMP_LOGONCE((LOG_ERR,
125 "SCTP: Error expanding sctpInSCTPPacks to 64bits\n"));
126
127 /*
128 * Update prev_stats for next computation.
129 */
130 memcpy(&prev_sctp_stats, &new_stats, sizeof(new_stats));
131 return 0;
132 }
133
134 void
135 netsnmp_access_sctp_stats_free(netsnmp_cache * cache, void *magic)
136 {
137 /*
138 * Do nothing
139 */
140 }
141
142 void
143 netsnmp_access_sctp_params_init(void)
144 {
145 netsnmp_access_sctp_params_arch_init();
146 }
147
148 int
149 netsnmp_access_sctp_params_load(netsnmp_cache * cache, void *magic)
150 {
151 int ret;
152
153 DEBUGMSGTL(("sctp:scalars:params:load", "called\n"));
154
155 ret = netsnmp_access_sctp_params_arch_load(&sctp_params);
156 if (ret < 0) {
157 DEBUGMSGTL(("sctp:scalars:params:load", "arch load failed\n"));
158 return ret;
159 }
160 return 0;
161 }
162
163 void
164 netsnmp_access_sctp_params_free(netsnmp_cache * cache, void *magic)
165 {
166 /*
167 * Do nothing
168 */
169 }