Enable UDP for DHCP in uIP

This commit is contained in:
logicog
2026-01-18 07:50:38 +01:00
parent 4269745521
commit 34cebe5971
3 changed files with 16 additions and 13 deletions
+3 -2
View File
@@ -129,14 +129,14 @@ typedef unsigned short uip_stats_t;
* *
* \hideinitializer * \hideinitializer
*/ */
#define UIP_CONF_UDP 0 #define UIP_CONF_UDP 1
/** /**
* UDP checksums on or off * UDP checksums on or off
* *
* \hideinitializer * \hideinitializer
*/ */
#define UIP_CONF_UDP_CHECKSUMS 1 #define UIP_CONF_UDP_CHECKSUMS 0
/** /**
* uIP statistics on or off * uIP statistics on or off
@@ -149,6 +149,7 @@ typedef unsigned short uip_stats_t;
our project. */ our project. */
/*#include "smtp.h"*/ /*#include "smtp.h"*/
#include "httpd.h" #include "httpd.h"
#include "dhcp.h"
/*#include "telnetd.h"*/ /*#include "telnetd.h"*/
/*#include "webserver.h" */ /*#include "webserver.h" */
/*#include "dhcpc.h"*/ /*#include "dhcpc.h"*/
+7 -5
View File
@@ -85,6 +85,7 @@
#include "uip.h" #include "uip.h"
#include "uipopt.h" #include "uipopt.h"
#include "uip_arch.h" #include "uip_arch.h"
#include <stddef.h>
#pragma codeseg BANK1 #pragma codeseg BANK1
#pragma constseg BANK1 #pragma constseg BANK1
@@ -168,8 +169,8 @@ __xdata u16_t uip_listenports[UIP_LISTENPORTS];
/* The uip_listenports list all currently /* The uip_listenports list all currently
listning ports. */ listning ports. */
#if UIP_UDP #if UIP_UDP
struct uip_udp_conn *uip_udp_conn; __xdata struct uip_udp_conn *uip_udp_conn;
struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; __xdata struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
#endif /* UIP_UDP */ #endif /* UIP_UDP */
__xdata static u16_t ipid; /* Ths ipid variable is an increasing __xdata static u16_t ipid; /* Ths ipid variable is an increasing
@@ -469,7 +470,7 @@ uip_connect(register __xdata uip_ipaddr_t *ripaddr, __xdata u16_t rport) __banke
struct uip_udp_conn * struct uip_udp_conn *
uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport) __banked uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport) __banked
{ {
register struct uip_udp_conn *conn; __xdata struct uip_udp_conn *conn;
/* Find an unused local port. */ /* Find an unused local port. */
again: again:
@@ -721,7 +722,6 @@ uip_process(u8_t flag) __banked
/* Reset the length variables. */ /* Reset the length variables. */
uip_len = 0; uip_len = 0;
uip_slen = 0; uip_slen = 0;
/* Check if the connection is in a state in which we simply wait /* Check if the connection is in a state in which we simply wait
for the connection to time out. If so, we increase the for the connection to time out. If so, we increase the
connection's timer and remove the connection if it times connection's timer and remove the connection if it times
@@ -919,12 +919,14 @@ uip_process(u8_t flag) __banked
} }
#endif /* UIP_BROADCAST */ #endif /* UIP_BROADCAST */
/* Check if the packet is destined for our IP address. */ /* Check if we have a DHCP packet, otherwise check if the packet is destined for our IP address. */
#if !UIP_CONF_IPV6 #if !UIP_CONF_IPV6
if(!(BUF->proto == UIP_PROTO_UDP && UDPBUF->destport == HTONS(DHCPC_CLIENT_PORT))) {
if(!uip_ipaddr_cmpx(BUF->destipaddr, uip_hostaddr)) { if(!uip_ipaddr_cmpx(BUF->destipaddr, uip_hostaddr)) {
UIP_STAT(++uip_stat.ip.drop); UIP_STAT(++uip_stat.ip.drop);
goto drop; goto drop;
} }
}
#else /* UIP_CONF_IPV6 */ #else /* UIP_CONF_IPV6 */
/* For IPv6, packet reception is a little trickier as we need to /* For IPv6, packet reception is a little trickier as we need to
make sure that we listen to certain multicast addresses (all make sure that we listen to certain multicast addresses (all
+2 -2
View File
@@ -1224,8 +1224,8 @@ struct uip_udp_conn {
/** /**
* The current UDP connection. * The current UDP connection.
*/ */
extern struct uip_udp_conn *uip_udp_conn; extern __xdata struct uip_udp_conn *uip_udp_conn;
extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; extern __xdata struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
#endif /* UIP_UDP */ #endif /* UIP_UDP */
/** /**