mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 12:35:26 +00:00
Add DHCP ports to iana.h
This commit is contained in:
parent
0eb8d19e82
commit
1c91118f4a
@ -238,8 +238,8 @@ dhcp_inc_pcb_refcount(void)
|
|||||||
ip_set_option(dhcp_pcb, SOF_BROADCAST);
|
ip_set_option(dhcp_pcb, SOF_BROADCAST);
|
||||||
|
|
||||||
/* set up local and remote port for the pcb -> listen on all interfaces on all src/dest IPs */
|
/* set up local and remote port for the pcb -> listen on all interfaces on all src/dest IPs */
|
||||||
udp_bind(dhcp_pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT);
|
udp_bind(dhcp_pcb, IP4_ADDR_ANY, LWIP_IANA_PORT_DHCP_CLIENT);
|
||||||
udp_connect(dhcp_pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT);
|
udp_connect(dhcp_pcb, IP4_ADDR_ANY, LWIP_IANA_PORT_DHCP_SERVER);
|
||||||
udp_recv(dhcp_pcb, dhcp_recv, NULL);
|
udp_recv(dhcp_pcb, dhcp_recv, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ dhcp_select(struct netif *netif)
|
|||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
/* send broadcast to any DHCP server */
|
/* send broadcast to any DHCP server */
|
||||||
result = udp_sendto_if_src(dhcp_pcb, p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP4_ADDR_ANY);
|
result = udp_sendto_if_src(dhcp_pcb, p_out, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER, netif, IP4_ADDR_ANY);
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_select: REQUESTING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_select: REQUESTING\n"));
|
||||||
} else {
|
} else {
|
||||||
@ -838,7 +838,7 @@ dhcp_inform(struct netif *netif)
|
|||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_inform: INFORMING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_inform: INFORMING\n"));
|
||||||
|
|
||||||
udp_sendto_if(dhcp_pcb, p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif);
|
udp_sendto_if(dhcp_pcb, p_out, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER, netif);
|
||||||
|
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
} else {
|
} else {
|
||||||
@ -952,7 +952,7 @@ dhcp_decline(struct netif *netif)
|
|||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
/* per section 4.4.4, broadcast DECLINE messages */
|
/* per section 4.4.4, broadcast DECLINE messages */
|
||||||
result = udp_sendto_if_src(dhcp_pcb, p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP4_ADDR_ANY);
|
result = udp_sendto_if_src(dhcp_pcb, p_out, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER, netif, IP4_ADDR_ANY);
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
|
||||||
} else {
|
} else {
|
||||||
@ -1006,8 +1006,8 @@ dhcp_discover(struct netif *netif)
|
|||||||
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, DHCP_STATE_SELECTING, msg_out, DHCP_DISCOVER, &options_out_len);
|
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, DHCP_STATE_SELECTING, msg_out, DHCP_DISCOVER, &options_out_len);
|
||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER)\n"));
|
||||||
udp_sendto_if_src(dhcp_pcb, p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif, IP4_ADDR_ANY);
|
udp_sendto_if_src(dhcp_pcb, p_out, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER, netif, IP4_ADDR_ANY);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: deleting()ing\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_discover: deleting()ing\n"));
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover: SELECTING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover: SELECTING\n"));
|
||||||
@ -1177,7 +1177,7 @@ dhcp_renew(struct netif *netif)
|
|||||||
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, DHCP_STATE_RENEWING, msg_out, DHCP_REQUEST, &options_out_len);
|
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, DHCP_STATE_RENEWING, msg_out, DHCP_REQUEST, &options_out_len);
|
||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
result = udp_sendto_if(dhcp_pcb, p_out, &dhcp->server_ip_addr, DHCP_SERVER_PORT, netif);
|
result = udp_sendto_if(dhcp_pcb, p_out, &dhcp->server_ip_addr, LWIP_IANA_PORT_DHCP_SERVER, netif);
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew: RENEWING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_renew: RENEWING\n"));
|
||||||
@ -1233,7 +1233,7 @@ dhcp_rebind(struct netif *netif)
|
|||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
/* broadcast to server */
|
/* broadcast to server */
|
||||||
result = udp_sendto_if(dhcp_pcb, p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif);
|
result = udp_sendto_if(dhcp_pcb, p_out, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER, netif);
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind: REBINDING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_rebind: REBINDING\n"));
|
||||||
} else {
|
} else {
|
||||||
@ -1285,7 +1285,7 @@ dhcp_reboot(struct netif *netif)
|
|||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
/* broadcast to server */
|
/* broadcast to server */
|
||||||
result = udp_sendto_if(dhcp_pcb, p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT, netif);
|
result = udp_sendto_if(dhcp_pcb, p_out, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER, netif);
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot: REBOOTING\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_reboot: REBOOTING\n"));
|
||||||
} else {
|
} else {
|
||||||
@ -1350,7 +1350,7 @@ dhcp_release_and_stop(struct netif *netif)
|
|||||||
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, dhcp->state, msg_out, DHCP_RELEASE, &options_out_len);
|
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, dhcp->state, msg_out, DHCP_RELEASE, &options_out_len);
|
||||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||||
|
|
||||||
udp_sendto_if(dhcp_pcb, p_out, &server_ip_addr, DHCP_SERVER_PORT, netif);
|
udp_sendto_if(dhcp_pcb, p_out, &server_ip_addr, LWIP_IANA_PORT_DHCP_SERVER, netif);
|
||||||
pbuf_free(p_out);
|
pbuf_free(p_out);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release: RELEASED, DHCP_STATE_OFF\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_release: RELEASED, DHCP_STATE_OFF\n"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include "lwip/autoip.h"
|
#include "lwip/autoip.h"
|
||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "lwip/prot/dhcp.h"
|
#include "lwip/prot/dhcp.h"
|
||||||
|
#include "lwip/prot/iana.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -89,14 +90,14 @@
|
|||||||
*/
|
*/
|
||||||
#if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT)
|
#if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT)
|
||||||
/* accept DHCP client port and custom port */
|
/* accept DHCP client port and custom port */
|
||||||
#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (((port) == PP_NTOHS(DHCP_CLIENT_PORT)) \
|
#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (((port) == PP_NTOHS(LWIP_IANA_PORT_DHCP_CLIENT)) \
|
||||||
|| (LWIP_IP_ACCEPT_UDP_PORT(port)))
|
|| (LWIP_IP_ACCEPT_UDP_PORT(port)))
|
||||||
#elif defined(LWIP_IP_ACCEPT_UDP_PORT) /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */
|
#elif defined(LWIP_IP_ACCEPT_UDP_PORT) /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */
|
||||||
/* accept custom port only */
|
/* accept custom port only */
|
||||||
#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (LWIP_IP_ACCEPT_UDP_PORT(port))
|
#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (LWIP_IP_ACCEPT_UDP_PORT(port))
|
||||||
#else /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */
|
#else /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */
|
||||||
/* accept DHCP client port only */
|
/* accept DHCP client port only */
|
||||||
#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) ((port) == PP_NTOHS(DHCP_CLIENT_PORT))
|
#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) ((port) == PP_NTOHS(LWIP_IANA_PORT_DHCP_CLIENT))
|
||||||
#endif /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */
|
#endif /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */
|
||||||
|
|
||||||
#else /* LWIP_DHCP */
|
#else /* LWIP_DHCP */
|
||||||
|
@ -44,10 +44,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DHCP_CLIENT_PORT 68
|
|
||||||
#define DHCP_SERVER_PORT 67
|
|
||||||
|
|
||||||
|
|
||||||
/* DHCP message item offsets and length */
|
/* DHCP message item offsets and length */
|
||||||
#define DHCP_CHADDR_LEN 16U
|
#define DHCP_CHADDR_LEN 16U
|
||||||
#define DHCP_SNAME_OFS 44U
|
#define DHCP_SNAME_OFS 44U
|
||||||
|
@ -38,15 +38,13 @@
|
|||||||
#ifndef LWIP_HDR_PROT_IANA_H
|
#ifndef LWIP_HDR_PROT_IANA_H
|
||||||
#define LWIP_HDR_PROT_IANA_H
|
#define LWIP_HDR_PROT_IANA_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
/* Hardware types */
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Hardware types */
|
|
||||||
#define LWIP_IANA_HWTYPE_ETHERNET 1
|
#define LWIP_IANA_HWTYPE_ETHERNET 1
|
||||||
|
|
||||||
/** Port numbers */
|
/* Port numbers (https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt) */
|
||||||
#define LWIP_IANA_PORT_SMTP 25
|
#define LWIP_IANA_PORT_SMTP 25
|
||||||
|
#define LWIP_IANA_PORT_DHCP_SERVER 67
|
||||||
|
#define LWIP_IANA_PORT_DHCP_CLIENT 68
|
||||||
#define LWIP_IANA_PORT_TFTP 69
|
#define LWIP_IANA_PORT_TFTP 69
|
||||||
#define LWIP_IANA_PORT_HTTP 80
|
#define LWIP_IANA_PORT_HTTP 80
|
||||||
#define LWIP_IANA_PORT_SNTP 123
|
#define LWIP_IANA_PORT_SNTP 123
|
||||||
@ -59,8 +57,4 @@ extern "C" {
|
|||||||
#define LWIP_IANA_PORT_MDNS 5353
|
#define LWIP_IANA_PORT_MDNS 5353
|
||||||
#define LWIP_IANA_PORT_SEQURE_MQTT 8883
|
#define LWIP_IANA_PORT_SEQURE_MQTT 8883
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* LWIP_HDR_PROT_IANA_H */
|
#endif /* LWIP_HDR_PROT_IANA_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user