mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-10-12 08:23:42 +00:00
Enabled LWIP_SNMP for development in the 'minimal' example.
This commit is contained in:
parent
a40ebbcac3
commit
922405d4e9
@ -59,11 +59,16 @@ CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \
|
||||
$(LWIPDIR)/core/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c \
|
||||
$(LWIPDIR)/core/ipv4/ip_frag.c
|
||||
|
||||
# SNMPFILES: Extra SNMPv1 agent
|
||||
SNMPFILES=$(LWIPDIR)/core/snmp/asn1_dec.c $(LWIPDIR)/core/snmp/asn1_enc.c \
|
||||
$(LWIPDIR)/core/snmp/mib2.c $(LWIPDIR)/core/snmp/mib_structs.c \
|
||||
$(LWIPDIR)/core/snmp/msg_in.c $(LWIPDIR)/core/snmp/msg_out.c
|
||||
|
||||
# NETIFFILES: Files implementing various generic network interface functions.'
|
||||
NETIFFILES=$(LWIPDIR)/netif/etharp.c mintapif.c
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES)
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(SNMPFILES) $(NETIFFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
This is an example of a very minimal lwIP project. It runs in a single
|
||||
thread and runs a single example application - an echo server. The
|
||||
echo application is implemented using the raw API.
|
||||
echo application is implemented using the raw API. Additionally this
|
||||
raw API example hosts the SNMPv1 agent for development purposes.
|
||||
|
@ -149,6 +149,17 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
(recommended). */
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
|
||||
/* ---------- SNMP options ---------- */
|
||||
/** @todo SNMP isn't functional yet.
|
||||
@note UDP must be available for SNMP transport */
|
||||
#ifndef LWIP_SNMP
|
||||
#define LWIP_SNMP 1
|
||||
#endif
|
||||
|
||||
#ifndef SNMP_PRIVATE_MIB
|
||||
#define SNMP_PRIVATE_MIB 0
|
||||
#endif
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip_frag.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/snmp_msg.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "mintapif.h"
|
||||
@ -71,6 +72,7 @@ main(int argc, char **argv)
|
||||
netif_init();
|
||||
ip_init();
|
||||
udp_init();
|
||||
snmp_init();
|
||||
tcp_init();
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
||||
#endif
|
||||
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
@ -149,6 +150,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
||||
struct pbuf *q;
|
||||
char buf[1514];
|
||||
char *bufptr;
|
||||
int written;
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
@ -166,9 +168,14 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
||||
}
|
||||
|
||||
/* signal that packet should be sent(); */
|
||||
if (write(mintapif->fd, buf, p->tot_len) == -1) {
|
||||
written = write(mintapif->fd, buf, p->tot_len);
|
||||
if (written == -1) {
|
||||
snmp_inc_ifoutdiscards(netif);
|
||||
perror("tapif: write");
|
||||
}
|
||||
else {
|
||||
snmp_add_ifoutoctets(netif, written);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@ -181,23 +188,26 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct pbuf *
|
||||
low_level_input(struct mintapif *mintapif)
|
||||
low_level_input(struct netif *netif)
|
||||
{
|
||||
struct pbuf *p, *q;
|
||||
u16_t len;
|
||||
char buf[1514];
|
||||
char *bufptr;
|
||||
struct mintapif *mintapif;
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
/* Obtain the size of the packet and put it into the "len"
|
||||
variable. */
|
||||
len = read(mintapif->fd, buf, sizeof(buf));
|
||||
snmp_add_ifinoctets(netif,len);
|
||||
|
||||
/* if (((double)rand()/(double)RAND_MAX) < 0.1) {
|
||||
printf("drop\n");
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
|
||||
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
|
||||
|
||||
@ -216,6 +226,7 @@ low_level_input(struct mintapif *mintapif)
|
||||
/* acknowledge that packet has been read(); */
|
||||
} else {
|
||||
/* drop packet(); */
|
||||
snmp_inc_ifindiscards(netif);
|
||||
printf("Could not allocate pbufs\n");
|
||||
}
|
||||
|
||||
@ -258,7 +269,7 @@ mintapif_input(struct netif *netif)
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
p = low_level_input(mintapif);
|
||||
p = low_level_input(netif);
|
||||
|
||||
if (p != NULL) {
|
||||
|
||||
@ -304,7 +315,29 @@ mintapif_init(struct netif *netif)
|
||||
struct mintapif *mintapif;
|
||||
|
||||
mintapif = mem_malloc(sizeof(struct mintapif));
|
||||
if (mintapif == NULL)
|
||||
{
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_init: out of memory for mintapif\n"));
|
||||
return ERR_MEM;
|
||||
}
|
||||
netif->state = mintapif;
|
||||
#if LWIP_SNMP
|
||||
/* ifType is other(1), there doesn't seem
|
||||
to be a proper type for the tunnel if */
|
||||
netif->link_type = 1;
|
||||
/* @todo get this from struct tunif? */
|
||||
netif->link_speed = 0;
|
||||
netif->ts = 0;
|
||||
netif->ifinoctets = 0;
|
||||
netif->ifinucastpkts = 0;
|
||||
netif->ifinnucastpkts = 0;
|
||||
netif->ifindiscards = 0;
|
||||
netif->ifoutoctets = 0;
|
||||
netif->ifoutucastpkts = 0;
|
||||
netif->ifoutnucastpkts = 0;
|
||||
netif->ifoutdiscards = 0;
|
||||
#endif
|
||||
|
||||
netif->hwaddr_len = 6;
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include "timer.h"
|
||||
#include "lwip/snmp.h"
|
||||
|
||||
static struct itimerval tmr;
|
||||
|
||||
@ -136,6 +137,8 @@ sigalarm_handler(int sig)
|
||||
unsigned char i;
|
||||
struct itmr *tp;
|
||||
|
||||
snmp_inc_sysuptime();
|
||||
|
||||
tp = &timers[TIMER_NUM-1];
|
||||
for(i = TIMER_NUM; i > 0; i--)
|
||||
{
|
||||
|
@ -57,6 +57,10 @@ COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
|
||||
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c $(LWIPDIR)/core/dhcp.c
|
||||
CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/inet.c
|
||||
|
||||
# SNMPFILES: Extra SNMPv1 agent
|
||||
SNMPFILES=$(LWIPDIR)/core/snmp/asn1_dec.c $(LWIPDIR)/core/snmp/asn1_enc.c \
|
||||
$(LWIPDIR)/core/snmp/mib2.c $(LWIPDIR)/core/snmp/mib_structs.c \
|
||||
$(LWIPDIR)/core/snmp/msg_in.c $(LWIPDIR)/core/snmp/msg_out.c
|
||||
|
||||
# APIFILES: The files which implement the sequential and socket APIs.
|
||||
APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
|
||||
@ -84,7 +88,7 @@ APPFILES=apps/fs.c apps/httpd.c \
|
||||
apps/shell.c
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(SNMPFILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
|
@ -195,6 +195,17 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
(recommended). */
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
|
||||
/* ---------- SNMP options ---------- */
|
||||
/** @todo SNMP is experimental for now
|
||||
@note UDP must be available for SNMP transport */
|
||||
#ifndef LWIP_SNMP
|
||||
#define LWIP_SNMP 0
|
||||
#endif
|
||||
|
||||
#ifndef SNMP_PRIVATE_MIB
|
||||
#define SNMP_PRIVATE_MIB 0
|
||||
#endif
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
|
Loading…
Reference in New Issue
Block a user