Pacified GCC warnings.

This commit is contained in:
christiaans 2006-08-21 11:50:03 +00:00
parent cdb7557d88
commit c3f82acf7a
6 changed files with 150 additions and 21 deletions

View File

@ -35,9 +35,10 @@
*/ */
#include "lwip/opt.h" #include "lwip/opt.h"
#include "lwip/snmp_asn1.h"
#if LWIP_SNMP #if LWIP_SNMP
#include "lwip/snmp_asn1.h"
/** /**
* Retrieves type field from incoming pbuf chain. * Retrieves type field from incoming pbuf chain.
* *
@ -644,4 +645,5 @@ snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw
} }
} }
#endif /* LWIP_SNMP */ #endif /* LWIP_SNMP */

View File

@ -35,9 +35,10 @@
*/ */
#include "lwip/opt.h" #include "lwip/opt.h"
#include "lwip/snmp_asn1.h"
#if LWIP_SNMP #if LWIP_SNMP
#include "lwip/snmp_asn1.h"
/** /**
* Returns octet count for length. * Returns octet count for length.
* *
@ -482,6 +483,7 @@ snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident)
} }
else else
{ {
/* @bug: allow empty varbinds for symmetry (we must decode them for getnext), allow partial compression?? */
/* ident_len <= 1, at least we need zeroDotZero (0.0) (ident_len == 2) */ /* ident_len <= 1, at least we need zeroDotZero (0.0) (ident_len == 2) */
return ERR_ARG; return ERR_ARG;
} }

View File

@ -34,17 +34,17 @@
#include "arch/cc.h" #include "arch/cc.h"
#include "lwip/opt.h" #include "lwip/opt.h"
#if LWIP_SNMP
#include "lwip/snmp.h" #include "lwip/snmp.h"
#include "lwip/netif.h" #include "lwip/netif.h"
#include "netif/etharp.h" #include "netif/etharp.h"
#include "lwip/ip.h" #include "lwip/ip.h"
#include "lwip/ip_frag.h" #include "lwip/ip_frag.h"
#include "lwip/tcp.h"
#include "lwip/udp.h" #include "lwip/udp.h"
#include "lwip/snmp_asn1.h" #include "lwip/snmp_asn1.h"
#include "lwip/snmp_structs.h" #include "lwip/snmp_structs.h"
#if LWIP_SNMP
/** /**
* IANA assigned enterprise ID for lwIP is 26381 * IANA assigned enterprise ID for lwIP is 26381
* @see http://www.iana.org/assignments/enterprise-numbers * @see http://www.iana.org/assignments/enterprise-numbers
@ -66,6 +66,18 @@
#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
#endif #endif
/**
* @todo
* table entry availability test in struct mib_node {},
* also we need to be able to expand entry from a partial index
* ifTable, use netif_cnt
* atTable, use ?
* ipAddrTable, use ?
* ipRouteTable, use ?
* ipNetToMediaTable, use ?
* tcpConnTable, use ?
* udpTable, use ?
*/
static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
static void system_get_value(struct obj_def *od, u16_t len, void *value); static void system_get_value(struct obj_def *od, u16_t len, void *value);
@ -559,7 +571,6 @@ static u32_t tcpactiveopens = 0,
tcppassiveopens = 0, tcppassiveopens = 0,
tcpattemptfails = 0, tcpattemptfails = 0,
tcpestabresets = 0, tcpestabresets = 0,
tcpcurrestab = 0,
tcpinsegs = 0, tcpinsegs = 0,
tcpoutsegs = 0, tcpoutsegs = 0,
tcpretranssegs = 0, tcpretranssegs = 0,
@ -1001,11 +1012,6 @@ void snmp_inc_tcpattemptfails(void)
void snmp_inc_tcpestabresets(void) void snmp_inc_tcpestabresets(void)
{ {
tcpestabresets++; tcpestabresets++;
}
void snmp_inc_tcpcurrestab(void)
{
tcpcurrestab++;
} }
void snmp_inc_tcpinsegs(void) void snmp_inc_tcpinsegs(void)
@ -2604,11 +2610,129 @@ icmp_get_value(struct obj_def *od, u16_t len, void *value)
static void static void
tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od) tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{ {
u8_t id;
if ((ident_len == 2) && (ident[1] == 0))
{
od->id_inst_len = ident_len;
od->id_inst_ptr = ident;
id = ident[0];
LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0",(u16_t)id));
switch (id)
{
case 1: /* tcpRtoAlgorithm */
case 2: /* tcpRtoMin */
case 3: /* tcpRtoMax */
case 4: /* tcpMaxConn */
od->instance = MIB_OBJECT_SCALAR;
od->access = MIB_OBJECT_READ_ONLY;
od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
od->v_len = sizeof(s32_t);
break;
case 5: /* tcpActiveOpens */
case 6: /* tcpPassiveOpens */
case 7: /* tcpAttemptFails */
case 8: /* tcpEstabResets */
case 10: /* tcpInSegs */
case 11: /* tcpOutSegs */
case 12: /* tcpRetransSegs */
case 14: /* tcpInErrs */
case 15: /* tcpOutRsts */
od->instance = MIB_OBJECT_SCALAR;
od->access = MIB_OBJECT_READ_ONLY;
od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
od->v_len = sizeof(u32_t);
break;
case 9: /* tcpCurrEstab */
od->instance = MIB_OBJECT_TAB;
od->access = MIB_OBJECT_READ_ONLY;
od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
od->v_len = sizeof(u32_t);
break;
default:
LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no such object"));
od->instance = MIB_OBJECT_NONE;
break;
};
}
else
{
LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no scalar"));
od->instance = MIB_OBJECT_NONE;
}
} }
static void static void
tcp_get_value(struct obj_def *od, u16_t len, void *value) tcp_get_value(struct obj_def *od, u16_t len, void *value)
{ {
u32_t *uint_ptr = value;
s32_t *sint_ptr = value;
u8_t id;
if (len){}
id = od->id_inst_ptr[0];
switch (id)
{
case 1: /* tcpRtoAlgorithm, vanj(4) */
*sint_ptr = 4;
break;
case 2: /* tcpRtoMin */
/* @todo need value */
*sint_ptr = 0;
break;
case 3: /* tcpRtoMax */
/* @todo need value */
*sint_ptr = 0;
break;
case 4: /* tcpMaxConn */
*sint_ptr = MEMP_NUM_TCP_PCB_LISTEN;
break;
case 5: /* tcpActiveOpens */
*uint_ptr = tcpactiveopens;
break;
case 6: /* tcpPassiveOpens */
*uint_ptr = tcppassiveopens;
break;
case 7: /* tcpAttemptFails */
*uint_ptr = tcpattemptfails;
break;
case 8: /* tcpEstabResets */
*uint_ptr = tcpestabresets;
break;
case 9: /* tcpCurrEstab */
{
u16_t tcpcurrestab = 0;
struct tcp_pcb *pcb = tcp_active_pcbs;
while (pcb != NULL)
{
if ((pcb->state == ESTABLISHED) ||
(pcb->state == CLOSE_WAIT))
{
tcpcurrestab++;
}
pcb = pcb->next;
}
*uint_ptr = tcpcurrestab;
}
break;
case 10: /* tcpInSegs */
*uint_ptr = tcpinsegs;
break;
case 11: /* tcpOutSegs */
*uint_ptr = tcpoutsegs;
break;
case 12: /* tcpRetransSegs */
*uint_ptr = tcpretranssegs;
break;
case 14: /* tcpInErrs */
*uint_ptr = tcpinerrs;
break;
case 15: /* tcpOutRsts */
*uint_ptr = tcpoutrsts;
break;
}
} }
static void static void
@ -2923,4 +3047,4 @@ snmp_get_value(struct obj_def *od, u16_t len, void *value)
}; };
} }
#endif /* LWIP_SNMP */ #endif /* LWIP_SNMP */

View File

@ -42,8 +42,10 @@
* Author: Christiaan Simons <christiaan.simons@axon.tv> * Author: Christiaan Simons <christiaan.simons@axon.tv>
*/ */
#include "arch/cc.h"
#include "lwip/opt.h" #include "lwip/opt.h"
#if LWIP_SNMP
#include "arch/cc.h"
#include "lwip/udp.h" #include "lwip/udp.h"
#include "lwip/netif.h" #include "lwip/netif.h"
@ -51,8 +53,6 @@
#include "lwip/snmp_asn1.h" #include "lwip/snmp_asn1.h"
#include "lwip/snmp_msg.h" #include "lwip/snmp_msg.h"
#if LWIP_SNMP
/** /**
* TRAP message structure * TRAP message structure
* @todo turn this into an arg to snmp_create_trap ? * @todo turn this into an arg to snmp_create_trap ?
@ -616,4 +616,4 @@ snmp_varbind_list_enc(struct snmp_varbind_root *root, struct pbuf *p, u16_t ofs)
return ofs; return ofs;
} }
#endif /* LWIP_SNMP */ #endif /* LWIP_SNMP */

View File

@ -120,7 +120,6 @@ void snmp_inc_tcpactiveopens(void);
void snmp_inc_tcppassiveopens(void); void snmp_inc_tcppassiveopens(void);
void snmp_inc_tcpattemptfails(void); void snmp_inc_tcpattemptfails(void);
void snmp_inc_tcpestabresets(void); void snmp_inc_tcpestabresets(void);
void snmp_inc_tcpcurrestab(void);
void snmp_inc_tcpinsegs(void); void snmp_inc_tcpinsegs(void);
void snmp_inc_tcpoutsegs(void); void snmp_inc_tcpoutsegs(void);
void snmp_inc_tcpretranssegs(void); void snmp_inc_tcpretranssegs(void);
@ -236,7 +235,6 @@ void snmp_set_snmpenableauthentraps(u8_t *value);
#define snmp_inc_tcppassiveopens() #define snmp_inc_tcppassiveopens()
#define snmp_inc_tcpattemptfails() #define snmp_inc_tcpattemptfails()
#define snmp_inc_tcpestabresets() #define snmp_inc_tcpestabresets()
#define snmp_inc_tcpcurrestab()
#define snmp_inc_tcpinsegs() #define snmp_inc_tcpinsegs()
#define snmp_inc_tcpoutsegs() #define snmp_inc_tcpoutsegs()
#define snmp_inc_tcpretranssegs() #define snmp_inc_tcpretranssegs()

View File

@ -38,6 +38,8 @@
#define __LWIP_SNMP_STRUCTS_H__ #define __LWIP_SNMP_STRUCTS_H__
#include "lwip/opt.h" #include "lwip/opt.h"
#if LWIP_SNMP
#include "arch/cc.h" #include "arch/cc.h"
#include "lwip/snmp.h" #include "lwip/snmp.h"
@ -104,8 +106,8 @@ struct mib_node
struct mib_array_node struct mib_array_node
{ {
/* inherited "base class" */ /* inherited "base class" */
const void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); void (* const get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
const void (*get_value)(struct obj_def *od, u16_t len, void *value); void (* const get_value)(struct obj_def *od, u16_t len, void *value);
const u8_t node_type; const u8_t node_type;
const u16_t maxlength; const u16_t maxlength;
@ -189,4 +191,5 @@ struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *
u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident); u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
#endif /* LWIP_SNMP */
#endif #endif