From 3fb559b60ac45aecccb91352ab2837723191538c Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 5 May 2005 10:39:07 +0000 Subject: [PATCH] corrected data link receive of large packets that were reporting a actual PDU length but not loading the PDU. --- bacnet-stack/Makefile | 4 ++-- bacnet-stack/ports/linux/ethernet.c | 4 ++++ bacnet-stack/ports/linux/main.c | 4 ++-- bacnet-stack/ports/rtos32/bip.c | 2 ++ bacnet-stack/ports/rtos32/ethernet.c | 4 ++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bacnet-stack/Makefile b/bacnet-stack/Makefile index 96e04bee..e6f366be 100644 --- a/bacnet-stack/Makefile +++ b/bacnet-stack/Makefile @@ -6,8 +6,8 @@ BASEDIR = . #CFLAGS = -Wall -I. -O2 -g # Note: you can strip out symbols using the strip command # to get an idea of how big the compile really is. -#CFLAGS = -Wall -I. -g -DBACDL_ETHERNET=1 -CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_BIP=1 +CFLAGS = -Wall -I. -g -DBACDL_ETHERNET=1 +#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_BIP=1 SRCS = ports/linux/main.c \ ports/linux/ethernet.c \ diff --git a/bacnet-stack/ports/linux/ethernet.c b/bacnet-stack/ports/linux/ethernet.c index 1e6a0a5b..71a277f0 100644 --- a/bacnet-stack/ports/linux/ethernet.c +++ b/bacnet-stack/ports/linux/ethernet.c @@ -357,6 +357,10 @@ uint16_t ethernet_receive( // copy the buffer into the PDU if (pdu_len < max_pdu) memmove(&pdu[0],&buf[17],pdu_len); + // ignore packets that are too large + else + pdu_len = 0; + return pdu_len; } diff --git a/bacnet-stack/ports/linux/main.c b/bacnet-stack/ports/linux/main.c index 9a11ec03..fbf4fcea 100644 --- a/bacnet-stack/ports/linux/main.c +++ b/bacnet-stack/ports/linux/main.c @@ -46,6 +46,7 @@ // buffers used for receiving static uint8_t Rx_Buf[MAX_MPDU] = {0}; +#ifdef BACDL_BIP static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request) { int fd; @@ -106,12 +107,11 @@ static void Init_Network(char *ifname) /* setup local address */ get_local_address_ioctl(ifname, &local_address, SIOCGIFADDR); decode_network_address(&local_address, &octet1, &octet2, &octet3, &octet4); - #ifdef BACDL_BIP bip_set_address(octet1, octet2, octet3, octet4); - #endif fprintf(stderr,"IP Address: %d.%d.%d.%d\n", (int)octet1, (int)octet2, (int)octet3, (int)octet4); } +#endif static void Init_Device_Parameters(void) { diff --git a/bacnet-stack/ports/rtos32/bip.c b/bacnet-stack/ports/rtos32/bip.c index b600ac2c..e2a1dceb 100644 --- a/bacnet-stack/ports/rtos32/bip.c +++ b/bacnet-stack/ports/rtos32/bip.c @@ -284,6 +284,8 @@ uint16_t bip_receive( pdu_len -= 4; /* BVLC header */ if (pdu_len < max_pdu) memmove(&pdu[0],&buf[4],pdu_len); + // ignore packets that are too large + // clients should check my max-apdu first else pdu_len = 0; } diff --git a/bacnet-stack/ports/rtos32/ethernet.c b/bacnet-stack/ports/rtos32/ethernet.c index 668c99e9..2302a7aa 100644 --- a/bacnet-stack/ports/rtos32/ethernet.c +++ b/bacnet-stack/ports/rtos32/ethernet.c @@ -257,6 +257,10 @@ uint16_t ethernet_receive( // copy the buffer into the PDU if (pdu_len < max_pdu) memmove(&pdu[0],&buf[17],pdu_len); + // ignore packets that are too large + // client should check my max apdu first + else + pdu_len = 0; return pdu_len; }