Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
lwip_snmp_mib2_tcp.c
00001 /** 00002 * @file 00003 * Management Information Base II (RFC1213) TCP objects and functions. 00004 */ 00005 00006 /* 00007 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * Author: Dirk Ziegelmeier <dziegel@gmx.de> 00033 * Christiaan Simons <christiaan.simons@axon.tv> 00034 */ 00035 00036 #include "lwip/snmp.h" 00037 #include "lwip/apps/snmp.h" 00038 #include "lwip/apps/snmp_core.h" 00039 #include "lwip/apps/snmp_mib2.h" 00040 #include "lwip/apps/snmp_table.h" 00041 #include "lwip/apps/snmp_scalar.h" 00042 #include "lwip/tcp.h" 00043 #include "lwip/priv/tcp_priv.h" 00044 #include "lwip/stats.h" 00045 00046 #include <string.h> 00047 00048 #if LWIP_SNMP && SNMP_LWIP_MIB2 && LWIP_TCP 00049 00050 #if SNMP_USE_NETCONN 00051 #define SYNC_NODE_NAME(node_name) node_name ## _synced 00052 #define CREATE_LWIP_SYNC_NODE(oid, node_name) \ 00053 static const struct snmp_threadsync_node node_name ## _synced = SNMP_CREATE_THREAD_SYNC_NODE(oid, &node_name.node, &snmp_mib2_lwip_locks); 00054 #else 00055 #define SYNC_NODE_NAME(node_name) node_name 00056 #define CREATE_LWIP_SYNC_NODE(oid, node_name) 00057 #endif 00058 00059 /* --- tcp .1.3.6.1.2.1.6 ----------------------------------------------------- */ 00060 00061 static s16_t 00062 tcp_get_value(struct snmp_node_instance* instance, void* value) 00063 { 00064 u32_t *uint_ptr = (u32_t*)value; 00065 s32_t *sint_ptr = (s32_t*)value; 00066 00067 switch (instance->node->oid) { 00068 case 1: /* tcpRtoAlgorithm, vanj(4) */ 00069 *sint_ptr = 4; 00070 return sizeof(*sint_ptr); 00071 case 2: /* tcpRtoMin */ 00072 /* @todo not the actual value, a guess, 00073 needs to be calculated */ 00074 *sint_ptr = 1000; 00075 return sizeof(*sint_ptr); 00076 case 3: /* tcpRtoMax */ 00077 /* @todo not the actual value, a guess, 00078 needs to be calculated */ 00079 *sint_ptr = 60000; 00080 return sizeof(*sint_ptr); 00081 case 4: /* tcpMaxConn */ 00082 *sint_ptr = MEMP_NUM_TCP_PCB; 00083 return sizeof(*sint_ptr); 00084 case 5: /* tcpActiveOpens */ 00085 *uint_ptr = STATS_GET(mib2.tcpactiveopens); 00086 return sizeof(*uint_ptr); 00087 case 6: /* tcpPassiveOpens */ 00088 *uint_ptr = STATS_GET(mib2.tcppassiveopens); 00089 return sizeof(*uint_ptr); 00090 case 7: /* tcpAttemptFails */ 00091 *uint_ptr = STATS_GET(mib2.tcpattemptfails); 00092 return sizeof(*uint_ptr); 00093 case 8: /* tcpEstabResets */ 00094 *uint_ptr = STATS_GET(mib2.tcpestabresets); 00095 return sizeof(*uint_ptr); 00096 case 9: /* tcpCurrEstab */ 00097 { 00098 u16_t tcpcurrestab = 0; 00099 struct tcp_pcb *pcb = tcp_active_pcbs; 00100 while (pcb != NULL) { 00101 if ((pcb->state == ESTABLISHED) || 00102 (pcb->state == CLOSE_WAIT)) { 00103 tcpcurrestab++; 00104 } 00105 pcb = pcb->next; 00106 } 00107 *uint_ptr = tcpcurrestab; 00108 } 00109 return sizeof(*uint_ptr); 00110 case 10: /* tcpInSegs */ 00111 *uint_ptr = STATS_GET(mib2.tcpinsegs); 00112 return sizeof(*uint_ptr); 00113 case 11: /* tcpOutSegs */ 00114 *uint_ptr = STATS_GET(mib2.tcpoutsegs); 00115 return sizeof(*uint_ptr); 00116 case 12: /* tcpRetransSegs */ 00117 *uint_ptr = STATS_GET(mib2.tcpretranssegs); 00118 return sizeof(*uint_ptr); 00119 case 14: /* tcpInErrs */ 00120 *uint_ptr = STATS_GET(mib2.tcpinerrs); 00121 return sizeof(*uint_ptr); 00122 case 15: /* tcpOutRsts */ 00123 *uint_ptr = STATS_GET(mib2.tcpoutrsts); 00124 return sizeof(*uint_ptr); 00125 case 17: /* tcpHCInSegs */ 00126 memset(value, 0, 2*sizeof(u32_t)); /* not supported */ 00127 return 2*sizeof(u32_t); 00128 case 18: /* tcpHCOutSegs */ 00129 memset(value, 0, 2*sizeof(u32_t)); /* not supported */ 00130 return 2*sizeof(u32_t); 00131 default: 00132 LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_value(): unknown id: %"S32_F"\n", instance->node->oid)); 00133 break; 00134 } 00135 00136 return 0; 00137 } 00138 00139 /* --- tcpConnTable --- */ 00140 00141 #if LWIP_IPV4 00142 00143 /* list of allowed value ranges for incoming OID */ 00144 static const struct snmp_oid_range tcp_ConnTable_oid_ranges[] = { 00145 { 0, 0xff }, /* IP A */ 00146 { 0, 0xff }, /* IP B */ 00147 { 0, 0xff }, /* IP C */ 00148 { 0, 0xff }, /* IP D */ 00149 { 0, 0xffff }, /* Port */ 00150 { 0, 0xff }, /* IP A */ 00151 { 0, 0xff }, /* IP B */ 00152 { 0, 0xff }, /* IP C */ 00153 { 0, 0xff }, /* IP D */ 00154 { 0, 0xffff } /* Port */ 00155 }; 00156 00157 static snmp_err_t 00158 tcp_ConnTable_get_cell_value_core(struct tcp_pcb *pcb, const u32_t* column, union snmp_variant_value* value, u32_t* value_len) 00159 { 00160 LWIP_UNUSED_ARG(value_len); 00161 00162 /* value */ 00163 switch (*column) { 00164 case 1: /* tcpConnState */ 00165 value->u32 = pcb->state + 1; 00166 break; 00167 case 2: /* tcpConnLocalAddress */ 00168 value->u32 = ip_2_ip4(&pcb->local_ip)->addr; 00169 break; 00170 case 3: /* tcpConnLocalPort */ 00171 value->u32 = pcb->local_port; 00172 break; 00173 case 4: /* tcpConnRemAddress */ 00174 if (pcb->state == LISTEN) { 00175 value->u32 = IP4_ADDR_ANY4->addr; 00176 } else { 00177 value->u32 = ip_2_ip4(&pcb->remote_ip)->addr; 00178 } 00179 break; 00180 case 5: /* tcpConnRemPort */ 00181 if (pcb->state == LISTEN) { 00182 value->u32 = 0; 00183 } else { 00184 value->u32 = pcb->remote_port; 00185 } 00186 break; 00187 default: 00188 LWIP_ASSERT("invalid id", 0); 00189 return SNMP_ERR_NOSUCHINSTANCE; 00190 } 00191 00192 return SNMP_ERR_NOERROR; 00193 } 00194 00195 static snmp_err_t 00196 tcp_ConnTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len) 00197 { 00198 u8_t i; 00199 ip4_addr_t local_ip; 00200 ip4_addr_t remote_ip; 00201 u16_t local_port; 00202 u16_t remote_port; 00203 struct tcp_pcb *pcb; 00204 00205 /* check if incoming OID length and if values are in plausible range */ 00206 if (!snmp_oid_in_range(row_oid, row_oid_len, tcp_ConnTable_oid_ranges, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges))) { 00207 return SNMP_ERR_NOSUCHINSTANCE; 00208 } 00209 00210 /* get IPs and ports from incoming OID */ 00211 snmp_oid_to_ip4(&row_oid[0], &local_ip); /* we know it succeeds because of oid_in_range check above */ 00212 local_port = (u16_t)row_oid[4]; 00213 snmp_oid_to_ip4(&row_oid[5], &remote_ip); /* we know it succeeds because of oid_in_range check above */ 00214 remote_port = (u16_t)row_oid[9]; 00215 00216 /* find tcp_pcb with requested ips and ports */ 00217 for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_lists); i++) { 00218 pcb = *tcp_pcb_lists[i]; 00219 00220 while (pcb != NULL) { 00221 /* do local IP and local port match? */ 00222 if (IP_IS_V4_VAL(pcb->local_ip) && 00223 ip4_addr_cmp(&local_ip, ip_2_ip4(&pcb->local_ip)) && (local_port == pcb->local_port)) { 00224 00225 /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */ 00226 if (pcb->state == LISTEN) { 00227 if (ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY4) && (remote_port == 0)) { 00228 /* fill in object properties */ 00229 return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len); 00230 } 00231 } else { 00232 if (IP_IS_V4_VAL(pcb->remote_ip) && 00233 ip4_addr_cmp(&remote_ip, ip_2_ip4(&pcb->remote_ip)) && (remote_port == pcb->remote_port)) { 00234 /* fill in object properties */ 00235 return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len); 00236 } 00237 } 00238 } 00239 00240 pcb = pcb->next; 00241 } 00242 } 00243 00244 /* not found */ 00245 return SNMP_ERR_NOSUCHINSTANCE; 00246 } 00247 00248 static snmp_err_t 00249 tcp_ConnTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len) 00250 { 00251 u8_t i; 00252 struct tcp_pcb *pcb; 00253 struct snmp_next_oid_state state; 00254 u32_t result_temp[LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges)]; 00255 00256 /* init struct to search next oid */ 00257 snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges)); 00258 00259 /* iterate over all possible OIDs to find the next one */ 00260 for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_lists); i++) { 00261 pcb = *tcp_pcb_lists[i]; 00262 while (pcb != NULL) { 00263 u32_t test_oid[LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges)]; 00264 00265 if (IP_IS_V4_VAL(pcb->local_ip)) { 00266 snmp_ip4_to_oid(ip_2_ip4(&pcb->local_ip), &test_oid[0]); 00267 test_oid[4] = pcb->local_port; 00268 00269 /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */ 00270 if (pcb->state == LISTEN) { 00271 snmp_ip4_to_oid(IP4_ADDR_ANY4, &test_oid[5]); 00272 test_oid[9] = 0; 00273 } else { 00274 if (IP_IS_V6_VAL(pcb->remote_ip)) { /* should never happen */ 00275 continue; 00276 } 00277 snmp_ip4_to_oid(ip_2_ip4(&pcb->remote_ip), &test_oid[5]); 00278 test_oid[9] = pcb->remote_port; 00279 } 00280 00281 /* check generated OID: is it a candidate for the next one? */ 00282 snmp_next_oid_check(&state, test_oid, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges), pcb); 00283 } 00284 00285 pcb = pcb->next; 00286 } 00287 } 00288 00289 /* did we find a next one? */ 00290 if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) { 00291 snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len); 00292 /* fill in object properties */ 00293 return tcp_ConnTable_get_cell_value_core((struct tcp_pcb*)state.reference, column, value, value_len); 00294 } 00295 00296 /* not found */ 00297 return SNMP_ERR_NOSUCHINSTANCE; 00298 } 00299 00300 #endif /* LWIP_IPV4 */ 00301 00302 /* --- tcpConnectionTable --- */ 00303 00304 static snmp_err_t 00305 tcp_ConnectionTable_get_cell_value_core(const u32_t* column, struct tcp_pcb *pcb, union snmp_variant_value* value) 00306 { 00307 /* all items except tcpConnectionState and tcpConnectionProcess are declared as not-accessible */ 00308 switch (*column) { 00309 case 7: /* tcpConnectionState */ 00310 value->u32 = pcb->state + 1; 00311 break; 00312 case 8: /* tcpConnectionProcess */ 00313 value->u32 = 0; /* not supported */ 00314 break; 00315 default: 00316 return SNMP_ERR_NOSUCHINSTANCE; 00317 } 00318 00319 return SNMP_ERR_NOERROR; 00320 } 00321 00322 static snmp_err_t 00323 tcp_ConnectionTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len) 00324 { 00325 ip_addr_t local_ip, remote_ip; 00326 u16_t local_port, remote_port; 00327 struct tcp_pcb *pcb; 00328 u8_t idx = 0; 00329 u8_t i; 00330 struct tcp_pcb ** const tcp_pcb_nonlisten_lists[] = {&tcp_bound_pcbs, &tcp_active_pcbs, &tcp_tw_pcbs}; 00331 00332 LWIP_UNUSED_ARG(value_len); 00333 00334 /* tcpConnectionLocalAddressType + tcpConnectionLocalAddress + tcpConnectionLocalPort */ 00335 idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &local_ip, &local_port); 00336 if (idx == 0) { 00337 return SNMP_ERR_NOSUCHINSTANCE; 00338 } 00339 00340 /* tcpConnectionRemAddressType + tcpConnectionRemAddress + tcpConnectionRemPort */ 00341 idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &remote_ip, &remote_port); 00342 if (idx == 0) { 00343 return SNMP_ERR_NOSUCHINSTANCE; 00344 } 00345 00346 /* find tcp_pcb with requested ip and port*/ 00347 for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_nonlisten_lists); i++) { 00348 pcb = *tcp_pcb_nonlisten_lists[i]; 00349 00350 while (pcb != NULL) { 00351 if (ip_addr_cmp(&local_ip, &pcb->local_ip) && 00352 (local_port == pcb->local_port) && 00353 ip_addr_cmp(&remote_ip, &pcb->remote_ip) && 00354 (remote_port == pcb->remote_port)) { 00355 /* fill in object properties */ 00356 return tcp_ConnectionTable_get_cell_value_core(column, pcb, value); 00357 } 00358 pcb = pcb->next; 00359 } 00360 } 00361 00362 /* not found */ 00363 return SNMP_ERR_NOSUCHINSTANCE; 00364 } 00365 00366 static snmp_err_t 00367 tcp_ConnectionTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len) 00368 { 00369 struct tcp_pcb *pcb; 00370 struct snmp_next_oid_state state; 00371 /* 1x tcpConnectionLocalAddressType + 1x OID len + 16x tcpConnectionLocalAddress + 1x tcpConnectionLocalPort 00372 * 1x tcpConnectionRemAddressType + 1x OID len + 16x tcpConnectionRemAddress + 1x tcpConnectionRemPort */ 00373 u32_t result_temp[38]; 00374 u8_t i; 00375 struct tcp_pcb ** const tcp_pcb_nonlisten_lists[] = {&tcp_bound_pcbs, &tcp_active_pcbs, &tcp_tw_pcbs}; 00376 00377 LWIP_UNUSED_ARG(value_len); 00378 00379 /* init struct to search next oid */ 00380 snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(result_temp)); 00381 00382 /* iterate over all possible OIDs to find the next one */ 00383 for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_nonlisten_lists); i++) { 00384 pcb = *tcp_pcb_nonlisten_lists[i]; 00385 00386 while (pcb != NULL) { 00387 u8_t idx = 0; 00388 u32_t test_oid[LWIP_ARRAYSIZE(result_temp)]; 00389 00390 /* tcpConnectionLocalAddressType + tcpConnectionLocalAddress + tcpConnectionLocalPort */ 00391 idx += snmp_ip_port_to_oid(&pcb->local_ip, pcb->local_port, &test_oid[idx]); 00392 00393 /* tcpConnectionRemAddressType + tcpConnectionRemAddress + tcpConnectionRemPort */ 00394 idx += snmp_ip_port_to_oid(&pcb->remote_ip, pcb->remote_port, &test_oid[idx]); 00395 00396 /* check generated OID: is it a candidate for the next one? */ 00397 snmp_next_oid_check(&state, test_oid, idx, pcb); 00398 00399 pcb = pcb->next; 00400 } 00401 } 00402 00403 /* did we find a next one? */ 00404 if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) { 00405 snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len); 00406 /* fill in object properties */ 00407 return tcp_ConnectionTable_get_cell_value_core(column, (struct tcp_pcb*)state.reference, value); 00408 } else { 00409 /* not found */ 00410 return SNMP_ERR_NOSUCHINSTANCE; 00411 } 00412 } 00413 00414 /* --- tcpListenerTable --- */ 00415 00416 static snmp_err_t 00417 tcp_ListenerTable_get_cell_value_core(const u32_t* column, union snmp_variant_value* value) 00418 { 00419 /* all items except tcpListenerProcess are declared as not-accessible */ 00420 switch (*column) { 00421 case 4: /* tcpListenerProcess */ 00422 value->u32 = 0; /* not supported */ 00423 break; 00424 default: 00425 return SNMP_ERR_NOSUCHINSTANCE; 00426 } 00427 00428 return SNMP_ERR_NOERROR; 00429 } 00430 00431 static snmp_err_t 00432 tcp_ListenerTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len) 00433 { 00434 ip_addr_t local_ip; 00435 u16_t local_port; 00436 struct tcp_pcb_listen *pcb; 00437 u8_t idx = 0; 00438 00439 LWIP_UNUSED_ARG(value_len); 00440 00441 /* tcpListenerLocalAddressType + tcpListenerLocalAddress + tcpListenerLocalPort */ 00442 idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len-idx, &local_ip, &local_port); 00443 if (idx == 0) { 00444 return SNMP_ERR_NOSUCHINSTANCE; 00445 } 00446 00447 /* find tcp_pcb with requested ip and port*/ 00448 pcb = tcp_listen_pcbs.listen_pcbs; 00449 while (pcb != NULL) { 00450 if (ip_addr_cmp(&local_ip, &pcb->local_ip) && 00451 (local_port == pcb->local_port)) { 00452 /* fill in object properties */ 00453 return tcp_ListenerTable_get_cell_value_core(column, value); 00454 } 00455 pcb = pcb->next; 00456 } 00457 00458 /* not found */ 00459 return SNMP_ERR_NOSUCHINSTANCE; 00460 } 00461 00462 static snmp_err_t 00463 tcp_ListenerTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len) 00464 { 00465 struct tcp_pcb_listen *pcb; 00466 struct snmp_next_oid_state state; 00467 /* 1x tcpListenerLocalAddressType + 1x OID len + 16x tcpListenerLocalAddress + 1x tcpListenerLocalPort */ 00468 u32_t result_temp[19]; 00469 00470 LWIP_UNUSED_ARG(value_len); 00471 00472 /* init struct to search next oid */ 00473 snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(result_temp)); 00474 00475 /* iterate over all possible OIDs to find the next one */ 00476 pcb = tcp_listen_pcbs.listen_pcbs; 00477 while (pcb != NULL) { 00478 u8_t idx = 0; 00479 u32_t test_oid[LWIP_ARRAYSIZE(result_temp)]; 00480 00481 /* tcpListenerLocalAddressType + tcpListenerLocalAddress + tcpListenerLocalPort */ 00482 idx += snmp_ip_port_to_oid(&pcb->local_ip, pcb->local_port, &test_oid[idx]); 00483 00484 /* check generated OID: is it a candidate for the next one? */ 00485 snmp_next_oid_check(&state, test_oid, idx, NULL); 00486 00487 pcb = pcb->next; 00488 } 00489 00490 /* did we find a next one? */ 00491 if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) { 00492 snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len); 00493 /* fill in object properties */ 00494 return tcp_ListenerTable_get_cell_value_core(column, value); 00495 } else { 00496 /* not found */ 00497 return SNMP_ERR_NOSUCHINSTANCE; 00498 } 00499 } 00500 00501 static const struct snmp_scalar_node tcp_RtoAlgorithm = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, tcp_get_value); 00502 static const struct snmp_scalar_node tcp_RtoMin = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, tcp_get_value); 00503 static const struct snmp_scalar_node tcp_RtoMax = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, tcp_get_value); 00504 static const struct snmp_scalar_node tcp_MaxConn = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, tcp_get_value); 00505 static const struct snmp_scalar_node tcp_ActiveOpens = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00506 static const struct snmp_scalar_node tcp_PassiveOpens = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00507 static const struct snmp_scalar_node tcp_AttemptFails = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00508 static const struct snmp_scalar_node tcp_EstabResets = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00509 static const struct snmp_scalar_node tcp_CurrEstab = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_GAUGE, tcp_get_value); 00510 static const struct snmp_scalar_node tcp_InSegs = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00511 static const struct snmp_scalar_node tcp_OutSegs = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00512 static const struct snmp_scalar_node tcp_RetransSegs = SNMP_SCALAR_CREATE_NODE_READONLY(12, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00513 static const struct snmp_scalar_node tcp_InErrs = SNMP_SCALAR_CREATE_NODE_READONLY(14, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00514 static const struct snmp_scalar_node tcp_OutRsts = SNMP_SCALAR_CREATE_NODE_READONLY(15, SNMP_ASN1_TYPE_COUNTER, tcp_get_value); 00515 static const struct snmp_scalar_node tcp_HCInSegs = SNMP_SCALAR_CREATE_NODE_READONLY(17, SNMP_ASN1_TYPE_COUNTER64, tcp_get_value); 00516 static const struct snmp_scalar_node tcp_HCOutSegs = SNMP_SCALAR_CREATE_NODE_READONLY(18, SNMP_ASN1_TYPE_COUNTER64, tcp_get_value); 00517 00518 #if LWIP_IPV4 00519 static const struct snmp_table_simple_col_def tcp_ConnTable_columns[] = { 00520 { 1, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnState */ 00521 { 2, SNMP_ASN1_TYPE_IPADDR, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnLocalAddress */ 00522 { 3, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnLocalPort */ 00523 { 4, SNMP_ASN1_TYPE_IPADDR, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnRemAddress */ 00524 { 5, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 } /* tcpConnRemPort */ 00525 }; 00526 00527 static const struct snmp_table_simple_node tcp_ConnTable = SNMP_TABLE_CREATE_SIMPLE(13, tcp_ConnTable_columns, tcp_ConnTable_get_cell_value, tcp_ConnTable_get_next_cell_instance_and_value); 00528 #endif /* LWIP_IPV4 */ 00529 00530 static const struct snmp_table_simple_col_def tcp_ConnectionTable_columns[] = { 00531 /* all items except tcpConnectionState and tcpConnectionProcess are declared as not-accessible */ 00532 { 7, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnectionState */ 00533 { 8, SNMP_ASN1_TYPE_UNSIGNED32, SNMP_VARIANT_VALUE_TYPE_U32 } /* tcpConnectionProcess */ 00534 }; 00535 00536 static const struct snmp_table_simple_node tcp_ConnectionTable = SNMP_TABLE_CREATE_SIMPLE(19, tcp_ConnectionTable_columns, tcp_ConnectionTable_get_cell_value, tcp_ConnectionTable_get_next_cell_instance_and_value); 00537 00538 00539 static const struct snmp_table_simple_col_def tcp_ListenerTable_columns[] = { 00540 /* all items except tcpListenerProcess are declared as not-accessible */ 00541 { 4, SNMP_ASN1_TYPE_UNSIGNED32, SNMP_VARIANT_VALUE_TYPE_U32 } /* tcpListenerProcess */ 00542 }; 00543 00544 static const struct snmp_table_simple_node tcp_ListenerTable = SNMP_TABLE_CREATE_SIMPLE(20, tcp_ListenerTable_columns, tcp_ListenerTable_get_cell_value, tcp_ListenerTable_get_next_cell_instance_and_value); 00545 00546 /* the following nodes access variables in LWIP stack from SNMP worker thread and must therefore be synced to LWIP (TCPIP) thread */ 00547 CREATE_LWIP_SYNC_NODE( 1, tcp_RtoAlgorithm) 00548 CREATE_LWIP_SYNC_NODE( 2, tcp_RtoMin) 00549 CREATE_LWIP_SYNC_NODE( 3, tcp_RtoMax) 00550 CREATE_LWIP_SYNC_NODE( 4, tcp_MaxConn) 00551 CREATE_LWIP_SYNC_NODE( 5, tcp_ActiveOpens) 00552 CREATE_LWIP_SYNC_NODE( 6, tcp_PassiveOpens) 00553 CREATE_LWIP_SYNC_NODE( 7, tcp_AttemptFails) 00554 CREATE_LWIP_SYNC_NODE( 8, tcp_EstabResets) 00555 CREATE_LWIP_SYNC_NODE( 9, tcp_CurrEstab) 00556 CREATE_LWIP_SYNC_NODE(10, tcp_InSegs) 00557 CREATE_LWIP_SYNC_NODE(11, tcp_OutSegs) 00558 CREATE_LWIP_SYNC_NODE(12, tcp_RetransSegs) 00559 #if LWIP_IPV4 00560 CREATE_LWIP_SYNC_NODE(13, tcp_ConnTable) 00561 #endif /* LWIP_IPV4 */ 00562 CREATE_LWIP_SYNC_NODE(14, tcp_InErrs) 00563 CREATE_LWIP_SYNC_NODE(15, tcp_OutRsts) 00564 CREATE_LWIP_SYNC_NODE(17, tcp_HCInSegs) 00565 CREATE_LWIP_SYNC_NODE(18, tcp_HCOutSegs) 00566 CREATE_LWIP_SYNC_NODE(19, tcp_ConnectionTable) 00567 CREATE_LWIP_SYNC_NODE(20, tcp_ListenerTable) 00568 00569 static const struct snmp_node* const tcp_nodes[] = { 00570 &SYNC_NODE_NAME(tcp_RtoAlgorithm).node.node, 00571 &SYNC_NODE_NAME(tcp_RtoMin).node.node, 00572 &SYNC_NODE_NAME(tcp_RtoMax).node.node, 00573 &SYNC_NODE_NAME(tcp_MaxConn).node.node, 00574 &SYNC_NODE_NAME(tcp_ActiveOpens).node.node, 00575 &SYNC_NODE_NAME(tcp_PassiveOpens).node.node, 00576 &SYNC_NODE_NAME(tcp_AttemptFails).node.node, 00577 &SYNC_NODE_NAME(tcp_EstabResets).node.node, 00578 &SYNC_NODE_NAME(tcp_CurrEstab).node.node, 00579 &SYNC_NODE_NAME(tcp_InSegs).node.node, 00580 &SYNC_NODE_NAME(tcp_OutSegs).node.node, 00581 &SYNC_NODE_NAME(tcp_RetransSegs).node.node, 00582 #if LWIP_IPV4 00583 &SYNC_NODE_NAME(tcp_ConnTable).node.node, 00584 #endif /* LWIP_IPV4 */ 00585 &SYNC_NODE_NAME(tcp_InErrs).node.node, 00586 &SYNC_NODE_NAME(tcp_OutRsts).node.node, 00587 &SYNC_NODE_NAME(tcp_HCInSegs).node.node, 00588 &SYNC_NODE_NAME(tcp_HCOutSegs).node.node, 00589 &SYNC_NODE_NAME(tcp_ConnectionTable).node.node, 00590 &SYNC_NODE_NAME(tcp_ListenerTable).node.node 00591 }; 00592 00593 const struct snmp_tree_node snmp_mib2_tcp_root = SNMP_CREATE_TREE_NODE(6, tcp_nodes); 00594 #endif /* LWIP_SNMP && SNMP_LWIP_MIB2 && LWIP_TCP */
Generated on Fri Jul 22 2022 04:53:53 by
1.7.2
