Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lwip_snmp_mib2_tcp.c Source File

lwip_snmp_mib2_tcp.c

Go to the documentation of this file.
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       u16_t tcpcurrestab = 0;
00098       struct tcp_pcb *pcb = tcp_active_pcbs;
00099       while (pcb != NULL) {
00100         if ((pcb->state == ESTABLISHED) ||
00101             (pcb->state == CLOSE_WAIT)) {
00102           tcpcurrestab++;
00103         }
00104         pcb = pcb->next;
00105       }
00106       *uint_ptr = tcpcurrestab;
00107     }
00108     return sizeof(*uint_ptr);
00109     case 10: /* tcpInSegs */
00110       *uint_ptr = STATS_GET(mib2.tcpinsegs);
00111       return sizeof(*uint_ptr);
00112     case 11: /* tcpOutSegs */
00113       *uint_ptr = STATS_GET(mib2.tcpoutsegs);
00114       return sizeof(*uint_ptr);
00115     case 12: /* tcpRetransSegs */
00116       *uint_ptr = STATS_GET(mib2.tcpretranssegs);
00117       return sizeof(*uint_ptr);
00118     case 14: /* tcpInErrs */
00119       *uint_ptr = STATS_GET(mib2.tcpinerrs);
00120       return sizeof(*uint_ptr);
00121     case 15: /* tcpOutRsts */
00122       *uint_ptr = STATS_GET(mib2.tcpoutrsts);
00123       return sizeof(*uint_ptr);
00124 #if LWIP_HAVE_INT64
00125     case 17: { /* tcpHCInSegs */
00126       /* use the 32 bit counter for now... */
00127       u64_t val64 = STATS_GET(mib2.tcpinsegs);
00128       *((u64_t *)value) = val64;
00129     }
00130     return sizeof(u64_t);
00131     case 18: { /* tcpHCOutSegs */
00132       /* use the 32 bit counter for now... */
00133       u64_t val64 = STATS_GET(mib2.tcpoutsegs);
00134       *((u64_t *)value) = val64;
00135     }
00136     return sizeof(u64_t);
00137 #endif
00138     default:
00139       LWIP_DEBUGF(SNMP_MIB_DEBUG, ("tcp_get_value(): unknown id: %"S32_F"\n", instance->node->oid));
00140       break;
00141   }
00142 
00143   return 0;
00144 }
00145 
00146 /* --- tcpConnTable --- */
00147 
00148 #if LWIP_IPV4
00149 
00150 /* list of allowed value ranges for incoming OID */
00151 static const struct snmp_oid_range tcp_ConnTable_oid_ranges[] = {
00152   { 0, 0xff   }, /* IP A */
00153   { 0, 0xff   }, /* IP B */
00154   { 0, 0xff   }, /* IP C */
00155   { 0, 0xff   }, /* IP D */
00156   { 0, 0xffff }, /* Port */
00157   { 0, 0xff   }, /* IP A */
00158   { 0, 0xff   }, /* IP B */
00159   { 0, 0xff   }, /* IP C */
00160   { 0, 0xff   }, /* IP D */
00161   { 0, 0xffff }  /* Port */
00162 };
00163 
00164 static snmp_err_t
00165 tcp_ConnTable_get_cell_value_core(struct tcp_pcb *pcb, const u32_t *column, union snmp_variant_value *value, u32_t *value_len)
00166 {
00167   LWIP_UNUSED_ARG(value_len);
00168 
00169   /* value */
00170   switch (*column) {
00171     case 1: /* tcpConnState */
00172       value->u32 = pcb->state + 1;
00173       break;
00174     case 2: /* tcpConnLocalAddress */
00175       value->u32 = ip_2_ip4(&pcb->local_ip)->addr;
00176       break;
00177     case 3: /* tcpConnLocalPort */
00178       value->u32 = pcb->local_port;
00179       break;
00180     case 4: /* tcpConnRemAddress */
00181       if (pcb->state == LISTEN) {
00182         value->u32 = IP4_ADDR_ANY4->addr;
00183       } else {
00184         value->u32 = ip_2_ip4(&pcb->remote_ip)->addr;
00185       }
00186       break;
00187     case 5: /* tcpConnRemPort */
00188       if (pcb->state == LISTEN) {
00189         value->u32 = 0;
00190       } else {
00191         value->u32 = pcb->remote_port;
00192       }
00193       break;
00194     default:
00195       LWIP_ASSERT("invalid id", 0);
00196       return SNMP_ERR_NOSUCHINSTANCE;
00197   }
00198 
00199   return SNMP_ERR_NOERROR;
00200 }
00201 
00202 static snmp_err_t
00203 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)
00204 {
00205   u8_t i;
00206   ip4_addr_t local_ip;
00207   ip4_addr_t remote_ip;
00208   u16_t local_port;
00209   u16_t remote_port;
00210   struct tcp_pcb *pcb;
00211 
00212   /* check if incoming OID length and if values are in plausible range */
00213   if (!snmp_oid_in_range(row_oid, row_oid_len, tcp_ConnTable_oid_ranges, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges))) {
00214     return SNMP_ERR_NOSUCHINSTANCE;
00215   }
00216 
00217   /* get IPs and ports from incoming OID */
00218   snmp_oid_to_ip4(&row_oid[0], &local_ip); /* we know it succeeds because of oid_in_range check above */
00219   local_port = (u16_t)row_oid[4];
00220   snmp_oid_to_ip4(&row_oid[5], &remote_ip); /* we know it succeeds because of oid_in_range check above */
00221   remote_port = (u16_t)row_oid[9];
00222 
00223   /* find tcp_pcb with requested ips and ports */
00224   for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_lists); i++) {
00225     pcb = *tcp_pcb_lists[i];
00226 
00227     while (pcb != NULL) {
00228       /* do local IP and local port match? */
00229       if (IP_IS_V4_VAL(pcb->local_ip) &&
00230           ip4_addr_cmp(&local_ip, ip_2_ip4(&pcb->local_ip)) && (local_port == pcb->local_port)) {
00231 
00232         /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */
00233         if (pcb->state == LISTEN) {
00234           if (ip4_addr_cmp(&remote_ip, IP4_ADDR_ANY4) && (remote_port == 0)) {
00235             /* fill in object properties */
00236             return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len);
00237           }
00238         } else {
00239           if (IP_IS_V4_VAL(pcb->remote_ip) &&
00240               ip4_addr_cmp(&remote_ip, ip_2_ip4(&pcb->remote_ip)) && (remote_port == pcb->remote_port)) {
00241             /* fill in object properties */
00242             return tcp_ConnTable_get_cell_value_core(pcb, column, value, value_len);
00243           }
00244         }
00245       }
00246 
00247       pcb = pcb->next;
00248     }
00249   }
00250 
00251   /* not found */
00252   return SNMP_ERR_NOSUCHINSTANCE;
00253 }
00254 
00255 static snmp_err_t
00256 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)
00257 {
00258   u8_t i;
00259   struct tcp_pcb *pcb;
00260   struct snmp_next_oid_state state;
00261   u32_t result_temp[LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges)];
00262 
00263   /* init struct to search next oid */
00264   snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges));
00265 
00266   /* iterate over all possible OIDs to find the next one */
00267   for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_lists); i++) {
00268     pcb = *tcp_pcb_lists[i];
00269     while (pcb != NULL) {
00270       u32_t test_oid[LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges)];
00271 
00272       if (IP_IS_V4_VAL(pcb->local_ip)) {
00273         snmp_ip4_to_oid(ip_2_ip4(&pcb->local_ip), &test_oid[0]);
00274         test_oid[4] = pcb->local_port;
00275 
00276         /* PCBs in state LISTEN are not connected and have no remote_ip or remote_port */
00277         if (pcb->state == LISTEN) {
00278           snmp_ip4_to_oid(IP4_ADDR_ANY4, &test_oid[5]);
00279           test_oid[9] = 0;
00280         } else {
00281           if (IP_IS_V6_VAL(pcb->remote_ip)) { /* should never happen */
00282             continue;
00283           }
00284           snmp_ip4_to_oid(ip_2_ip4(&pcb->remote_ip), &test_oid[5]);
00285           test_oid[9] = pcb->remote_port;
00286         }
00287 
00288         /* check generated OID: is it a candidate for the next one? */
00289         snmp_next_oid_check(&state, test_oid, LWIP_ARRAYSIZE(tcp_ConnTable_oid_ranges), pcb);
00290       }
00291 
00292       pcb = pcb->next;
00293     }
00294   }
00295 
00296   /* did we find a next one? */
00297   if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
00298     snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
00299     /* fill in object properties */
00300     return tcp_ConnTable_get_cell_value_core((struct tcp_pcb *)state.reference, column, value, value_len);
00301   }
00302 
00303   /* not found */
00304   return SNMP_ERR_NOSUCHINSTANCE;
00305 }
00306 
00307 #endif /* LWIP_IPV4 */
00308 
00309 /* --- tcpConnectionTable --- */
00310 
00311 static snmp_err_t
00312 tcp_ConnectionTable_get_cell_value_core(const u32_t *column, struct tcp_pcb *pcb, union snmp_variant_value *value)
00313 {
00314   /* all items except tcpConnectionState and tcpConnectionProcess are declared as not-accessible */
00315   switch (*column) {
00316     case 7: /* tcpConnectionState */
00317       value->u32 = pcb->state + 1;
00318       break;
00319     case 8: /* tcpConnectionProcess */
00320       value->u32 = 0; /* not supported */
00321       break;
00322     default:
00323       return SNMP_ERR_NOSUCHINSTANCE;
00324   }
00325 
00326   return SNMP_ERR_NOERROR;
00327 }
00328 
00329 static snmp_err_t
00330 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)
00331 {
00332   ip_addr_t local_ip, remote_ip;
00333   u16_t local_port, remote_port;
00334   struct tcp_pcb *pcb;
00335   u8_t idx = 0;
00336   u8_t i;
00337   struct tcp_pcb **const tcp_pcb_nonlisten_lists[] = {&tcp_bound_pcbs, &tcp_active_pcbs, &tcp_tw_pcbs};
00338 
00339   LWIP_UNUSED_ARG(value_len);
00340 
00341   /* tcpConnectionLocalAddressType + tcpConnectionLocalAddress + tcpConnectionLocalPort */
00342   idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len - idx, &local_ip, &local_port);
00343   if (idx == 0) {
00344     return SNMP_ERR_NOSUCHINSTANCE;
00345   }
00346 
00347   /* tcpConnectionRemAddressType + tcpConnectionRemAddress + tcpConnectionRemPort */
00348   idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len - idx, &remote_ip, &remote_port);
00349   if (idx == 0) {
00350     return SNMP_ERR_NOSUCHINSTANCE;
00351   }
00352 
00353   /* find tcp_pcb with requested ip and port*/
00354   for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_nonlisten_lists); i++) {
00355     pcb = *tcp_pcb_nonlisten_lists[i];
00356 
00357     while (pcb != NULL) {
00358       if (ip_addr_cmp(&local_ip, &pcb->local_ip) &&
00359           (local_port == pcb->local_port) &&
00360           ip_addr_cmp(&remote_ip, &pcb->remote_ip) &&
00361           (remote_port == pcb->remote_port)) {
00362         /* fill in object properties */
00363         return tcp_ConnectionTable_get_cell_value_core(column, pcb, value);
00364       }
00365       pcb = pcb->next;
00366     }
00367   }
00368 
00369   /* not found */
00370   return SNMP_ERR_NOSUCHINSTANCE;
00371 }
00372 
00373 static snmp_err_t
00374 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)
00375 {
00376   struct tcp_pcb *pcb;
00377   struct snmp_next_oid_state state;
00378   /* 1x tcpConnectionLocalAddressType + 1x OID len + 16x tcpConnectionLocalAddress  + 1x tcpConnectionLocalPort
00379    * 1x tcpConnectionRemAddressType   + 1x OID len + 16x tcpConnectionRemAddress    + 1x tcpConnectionRemPort */
00380   u32_t  result_temp[38];
00381   u8_t i;
00382   struct tcp_pcb **const tcp_pcb_nonlisten_lists[] = {&tcp_bound_pcbs, &tcp_active_pcbs, &tcp_tw_pcbs};
00383 
00384   LWIP_UNUSED_ARG(value_len);
00385 
00386   /* init struct to search next oid */
00387   snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(result_temp));
00388 
00389   /* iterate over all possible OIDs to find the next one */
00390   for (i = 0; i < LWIP_ARRAYSIZE(tcp_pcb_nonlisten_lists); i++) {
00391     pcb = *tcp_pcb_nonlisten_lists[i];
00392 
00393     while (pcb != NULL) {
00394       u8_t idx = 0;
00395       u32_t test_oid[LWIP_ARRAYSIZE(result_temp)];
00396 
00397       /* tcpConnectionLocalAddressType + tcpConnectionLocalAddress + tcpConnectionLocalPort */
00398       idx += snmp_ip_port_to_oid(&pcb->local_ip, pcb->local_port, &test_oid[idx]);
00399 
00400       /* tcpConnectionRemAddressType + tcpConnectionRemAddress + tcpConnectionRemPort */
00401       idx += snmp_ip_port_to_oid(&pcb->remote_ip, pcb->remote_port, &test_oid[idx]);
00402 
00403       /* check generated OID: is it a candidate for the next one? */
00404       snmp_next_oid_check(&state, test_oid, idx, pcb);
00405 
00406       pcb = pcb->next;
00407     }
00408   }
00409 
00410   /* did we find a next one? */
00411   if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
00412     snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
00413     /* fill in object properties */
00414     return tcp_ConnectionTable_get_cell_value_core(column, (struct tcp_pcb *)state.reference, value);
00415   } else {
00416     /* not found */
00417     return SNMP_ERR_NOSUCHINSTANCE;
00418   }
00419 }
00420 
00421 /* --- tcpListenerTable --- */
00422 
00423 static snmp_err_t
00424 tcp_ListenerTable_get_cell_value_core(const u32_t *column, union snmp_variant_value *value)
00425 {
00426   /* all items except tcpListenerProcess are declared as not-accessible */
00427   switch (*column) {
00428     case 4: /* tcpListenerProcess */
00429       value->u32 = 0; /* not supported */
00430       break;
00431     default:
00432       return SNMP_ERR_NOSUCHINSTANCE;
00433   }
00434 
00435   return SNMP_ERR_NOERROR;
00436 }
00437 
00438 static snmp_err_t
00439 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)
00440 {
00441   ip_addr_t local_ip;
00442   u16_t local_port;
00443   struct tcp_pcb_listen *pcb;
00444   u8_t idx = 0;
00445 
00446   LWIP_UNUSED_ARG(value_len);
00447 
00448   /* tcpListenerLocalAddressType + tcpListenerLocalAddress + tcpListenerLocalPort */
00449   idx += snmp_oid_to_ip_port(&row_oid[idx], row_oid_len - idx, &local_ip, &local_port);
00450   if (idx == 0) {
00451     return SNMP_ERR_NOSUCHINSTANCE;
00452   }
00453 
00454   /* find tcp_pcb with requested ip and port*/
00455   pcb = tcp_listen_pcbs.listen_pcbs;
00456   while (pcb != NULL) {
00457     if (ip_addr_cmp(&local_ip, &pcb->local_ip) &&
00458         (local_port == pcb->local_port)) {
00459       /* fill in object properties */
00460       return tcp_ListenerTable_get_cell_value_core(column, value);
00461     }
00462     pcb = pcb->next;
00463   }
00464 
00465   /* not found */
00466   return SNMP_ERR_NOSUCHINSTANCE;
00467 }
00468 
00469 static snmp_err_t
00470 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)
00471 {
00472   struct tcp_pcb_listen *pcb;
00473   struct snmp_next_oid_state state;
00474   /* 1x tcpListenerLocalAddressType + 1x OID len + 16x tcpListenerLocalAddress  + 1x tcpListenerLocalPort */
00475   u32_t  result_temp[19];
00476 
00477   LWIP_UNUSED_ARG(value_len);
00478 
00479   /* init struct to search next oid */
00480   snmp_next_oid_init(&state, row_oid->id, row_oid->len, result_temp, LWIP_ARRAYSIZE(result_temp));
00481 
00482   /* iterate over all possible OIDs to find the next one */
00483   pcb = tcp_listen_pcbs.listen_pcbs;
00484   while (pcb != NULL) {
00485     u8_t idx = 0;
00486     u32_t test_oid[LWIP_ARRAYSIZE(result_temp)];
00487 
00488     /* tcpListenerLocalAddressType + tcpListenerLocalAddress + tcpListenerLocalPort */
00489     idx += snmp_ip_port_to_oid(&pcb->local_ip, pcb->local_port, &test_oid[idx]);
00490 
00491     /* check generated OID: is it a candidate for the next one? */
00492     snmp_next_oid_check(&state, test_oid, idx, NULL);
00493 
00494     pcb = pcb->next;
00495   }
00496 
00497   /* did we find a next one? */
00498   if (state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {
00499     snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);
00500     /* fill in object properties */
00501     return tcp_ListenerTable_get_cell_value_core(column, value);
00502   } else {
00503     /* not found */
00504     return SNMP_ERR_NOSUCHINSTANCE;
00505   }
00506 }
00507 
00508 static const struct snmp_scalar_node tcp_RtoAlgorithm  = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, tcp_get_value);
00509 static const struct snmp_scalar_node tcp_RtoMin        = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, tcp_get_value);
00510 static const struct snmp_scalar_node tcp_RtoMax        = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, tcp_get_value);
00511 static const struct snmp_scalar_node tcp_MaxConn       = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, tcp_get_value);
00512 static const struct snmp_scalar_node tcp_ActiveOpens   = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00513 static const struct snmp_scalar_node tcp_PassiveOpens  = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00514 static const struct snmp_scalar_node tcp_AttemptFails  = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00515 static const struct snmp_scalar_node tcp_EstabResets   = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00516 static const struct snmp_scalar_node tcp_CurrEstab     = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_GAUGE, tcp_get_value);
00517 static const struct snmp_scalar_node tcp_InSegs        = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00518 static const struct snmp_scalar_node tcp_OutSegs       = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00519 static const struct snmp_scalar_node tcp_RetransSegs   = SNMP_SCALAR_CREATE_NODE_READONLY(12, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00520 static const struct snmp_scalar_node tcp_InErrs        = SNMP_SCALAR_CREATE_NODE_READONLY(14, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00521 static const struct snmp_scalar_node tcp_OutRsts       = SNMP_SCALAR_CREATE_NODE_READONLY(15, SNMP_ASN1_TYPE_COUNTER, tcp_get_value);
00522 #if LWIP_HAVE_INT64
00523 static const struct snmp_scalar_node tcp_HCInSegs      = SNMP_SCALAR_CREATE_NODE_READONLY(17, SNMP_ASN1_TYPE_COUNTER64, tcp_get_value);
00524 static const struct snmp_scalar_node tcp_HCOutSegs     = SNMP_SCALAR_CREATE_NODE_READONLY(18, SNMP_ASN1_TYPE_COUNTER64, tcp_get_value);
00525 #endif
00526 
00527 #if LWIP_IPV4
00528 static const struct snmp_table_simple_col_def tcp_ConnTable_columns[] = {
00529   {  1, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnState */
00530   {  2, SNMP_ASN1_TYPE_IPADDR,  SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnLocalAddress */
00531   {  3, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnLocalPort */
00532   {  4, SNMP_ASN1_TYPE_IPADDR,  SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnRemAddress */
00533   {  5, SNMP_ASN1_TYPE_INTEGER, SNMP_VARIANT_VALUE_TYPE_U32 }  /* tcpConnRemPort */
00534 };
00535 
00536 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);
00537 #endif /* LWIP_IPV4 */
00538 
00539 static const struct snmp_table_simple_col_def tcp_ConnectionTable_columns[] = {
00540   /* all items except tcpConnectionState and tcpConnectionProcess are declared as not-accessible */
00541   { 7, SNMP_ASN1_TYPE_INTEGER,    SNMP_VARIANT_VALUE_TYPE_U32 }, /* tcpConnectionState */
00542   { 8, SNMP_ASN1_TYPE_UNSIGNED32, SNMP_VARIANT_VALUE_TYPE_U32 }  /* tcpConnectionProcess */
00543 };
00544 
00545 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);
00546 
00547 
00548 static const struct snmp_table_simple_col_def tcp_ListenerTable_columns[] = {
00549   /* all items except tcpListenerProcess are declared as not-accessible */
00550   { 4, SNMP_ASN1_TYPE_UNSIGNED32, SNMP_VARIANT_VALUE_TYPE_U32 }  /* tcpListenerProcess */
00551 };
00552 
00553 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);
00554 
00555 /* the following nodes access variables in LWIP stack from SNMP worker thread and must therefore be synced to LWIP (TCPIP) thread */
00556 CREATE_LWIP_SYNC_NODE( 1, tcp_RtoAlgorithm)
00557 CREATE_LWIP_SYNC_NODE( 2, tcp_RtoMin)
00558 CREATE_LWIP_SYNC_NODE( 3, tcp_RtoMax)
00559 CREATE_LWIP_SYNC_NODE( 4, tcp_MaxConn)
00560 CREATE_LWIP_SYNC_NODE( 5, tcp_ActiveOpens)
00561 CREATE_LWIP_SYNC_NODE( 6, tcp_PassiveOpens)
00562 CREATE_LWIP_SYNC_NODE( 7, tcp_AttemptFails)
00563 CREATE_LWIP_SYNC_NODE( 8, tcp_EstabResets)
00564 CREATE_LWIP_SYNC_NODE( 9, tcp_CurrEstab)
00565 CREATE_LWIP_SYNC_NODE(10, tcp_InSegs)
00566 CREATE_LWIP_SYNC_NODE(11, tcp_OutSegs)
00567 CREATE_LWIP_SYNC_NODE(12, tcp_RetransSegs)
00568 #if LWIP_IPV4
00569 CREATE_LWIP_SYNC_NODE(13, tcp_ConnTable)
00570 #endif /* LWIP_IPV4 */
00571 CREATE_LWIP_SYNC_NODE(14, tcp_InErrs)
00572 CREATE_LWIP_SYNC_NODE(15, tcp_OutRsts)
00573 #if LWIP_HAVE_INT64
00574 CREATE_LWIP_SYNC_NODE(17, tcp_HCInSegs)
00575 CREATE_LWIP_SYNC_NODE(18, tcp_HCOutSegs)
00576 #endif
00577 CREATE_LWIP_SYNC_NODE(19, tcp_ConnectionTable)
00578 CREATE_LWIP_SYNC_NODE(20, tcp_ListenerTable)
00579 
00580 static const struct snmp_node *const tcp_nodes[] = {
00581   &SYNC_NODE_NAME(tcp_RtoAlgorithm).node.node,
00582   &SYNC_NODE_NAME(tcp_RtoMin).node.node,
00583   &SYNC_NODE_NAME(tcp_RtoMax).node.node,
00584   &SYNC_NODE_NAME(tcp_MaxConn).node.node,
00585   &SYNC_NODE_NAME(tcp_ActiveOpens).node.node,
00586   &SYNC_NODE_NAME(tcp_PassiveOpens).node.node,
00587   &SYNC_NODE_NAME(tcp_AttemptFails).node.node,
00588   &SYNC_NODE_NAME(tcp_EstabResets).node.node,
00589   &SYNC_NODE_NAME(tcp_CurrEstab).node.node,
00590   &SYNC_NODE_NAME(tcp_InSegs).node.node,
00591   &SYNC_NODE_NAME(tcp_OutSegs).node.node,
00592   &SYNC_NODE_NAME(tcp_RetransSegs).node.node,
00593 #if LWIP_IPV4
00594   &SYNC_NODE_NAME(tcp_ConnTable).node.node,
00595 #endif /* LWIP_IPV4 */
00596   &SYNC_NODE_NAME(tcp_InErrs).node.node,
00597   &SYNC_NODE_NAME(tcp_OutRsts).node.node,
00598   &SYNC_NODE_NAME(tcp_HCInSegs).node.node,
00599 #if LWIP_HAVE_INT64
00600   &SYNC_NODE_NAME(tcp_HCOutSegs).node.node,
00601   &SYNC_NODE_NAME(tcp_ConnectionTable).node.node,
00602 #endif
00603   &SYNC_NODE_NAME(tcp_ListenerTable).node.node
00604 };
00605 
00606 const struct snmp_tree_node snmp_mib2_tcp_root = SNMP_CREATE_TREE_NODE(6, tcp_nodes);
00607 #endif /* LWIP_SNMP && SNMP_LWIP_MIB2 && LWIP_TCP */