task #12722 (improve IPv4/v6 address handling): renamed ip_addr_t to ip4_addr_t, renamed ipX_addr_t to ip_addr_t and added IP version;

ip_addr_t is used for all generic IP addresses for the API, ip(4/6)_addr_t are only used internally or when initializing netifs or when calling version-related functions
This commit is contained in:
sg
2015-04-09 22:21:15 +02:00
parent 4ff1eb1890
commit ce7e31cd04
74 changed files with 1709 additions and 1395 deletions

View File

@@ -107,6 +107,24 @@ PACK_STRUCT_END
#endif /* ETHARP_SUPPORT_VLAN */
/* A list of often ethtypes (although lwIP does not use all of them): */
#define ETHTYPE_IP 0x0800U /* Internet protocol v4 */
#define ETHTYPE_ARP 0x0806U /* Address resolution protocol */
#define ETHTYPE_WOL 0x0842U /* Wake on lan */
#define ETHTYPE_VLAN 0x8100U /* Virtual local area network */
#define ETHTYPE_IPV6 0x86DDU /* Internet protocol v6 */
#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */
#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */
#define ETHTYPE_JUMBO 0x8870U /* Jumbo Frames */
#define ETHTYPE_PROFINET 0x8892U /* Process field network */
#define ETHTYPE_ETHERCAT 0x88A4U /* Ethernet for control automation technology */
#define ETHTYPE_LLDP 0x88CCU /* Link layer discovery protocol */
#define ETHTYPE_SERCOS 0x88CDU /* Serial real-time communication system */
#define ETHTYPE_PTP 0x88F7U /* Precision time protocol */
#define ETHTYPE_QINQ 0x9100U /* Q-in-Q, 802.1ad */
#if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
@@ -119,9 +137,9 @@ struct etharp_hdr {
PACK_STRUCT_FLD_8(u8_t protolen);
PACK_STRUCT_FIELD(u16_t opcode);
PACK_STRUCT_FLD_S(struct eth_addr shwaddr);
PACK_STRUCT_FLD_S(struct ip_addr2 sipaddr);
PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr);
PACK_STRUCT_FLD_S(struct eth_addr dhwaddr);
PACK_STRUCT_FLD_S(struct ip_addr2 dipaddr);
PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
@@ -140,22 +158,6 @@ PACK_STRUCT_END
/** 1 seconds period */
#define ARP_TMR_INTERVAL 1000
/* A list of often ethtypes (although lwIP does not use all of them): */
#define ETHTYPE_IP 0x0800U /* Internet protocol v4 */
#define ETHTYPE_ARP 0x0806U /* Address resolution protocol */
#define ETHTYPE_WOL 0x0842U /* Wake on lan */
#define ETHTYPE_VLAN 0x8100U /* Virtual local area network */
#define ETHTYPE_IPV6 0x86DDU /* Internet protocol v6 */
#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */
#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */
#define ETHTYPE_JUMBO 0x8870U /* Jumbo Frames */
#define ETHTYPE_PROFINET 0x8892U /* Process field network */
#define ETHTYPE_ETHERCAT 0x88A4U /* Ethernet for control automation technology */
#define ETHTYPE_LLDP 0x88CCU /* Link layer discovery protocol */
#define ETHTYPE_SERCOS 0x88CDU /* Serial real-time communication system */
#define ETHTYPE_PTP 0x88F7U /* Precision time protocol */
#define ETHTYPE_QINQ 0x9100U /* Q-in-Q, 802.1ad */
/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
* or known to be 32-bit aligned within the protocol header. */
#ifndef ETHADDR32_COPY
@@ -168,8 +170,6 @@ PACK_STRUCT_END
#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETHARP_HWADDR_LEN)
#endif
#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
/** ARP message types (opcodes) */
#define ARP_REQUEST 1
#define ARP_REPLY 2
@@ -196,11 +196,11 @@ struct etharp_q_entry {
#define etharp_init() /* Compatibility define, no init needed. */
void etharp_tmr(void);
s8_t etharp_find_addr(struct netif *netif, const ip_addr_t *ipaddr,
struct eth_addr **eth_ret, const ip_addr_t **ip_ret);
err_t etharp_output(struct netif *netif, struct pbuf *q, const ip_addr_t *ipaddr);
err_t etharp_query(struct netif *netif, const ip_addr_t *ipaddr, struct pbuf *q);
err_t etharp_request(struct netif *netif, const ip_addr_t *ipaddr);
s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
struct eth_addr **eth_ret, const ip4_addr_t **ip_ret);
err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q);
err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr);
/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
* this is an ARP packet sent by a node in order to spontaneously cause other
* nodes to update an entry in their ARP cache.
@@ -209,19 +209,19 @@ err_t etharp_request(struct netif *netif, const ip_addr_t *ipaddr);
void etharp_cleanup_netif(struct netif *netif);
#if ETHARP_SUPPORT_STATIC_ENTRIES
err_t etharp_add_static_entry(const ip_addr_t *ipaddr, struct eth_addr *ethaddr);
err_t etharp_remove_static_entry(const ip_addr_t *ipaddr);
err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr);
err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr);
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
#if LWIP_AUTOIP
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
const struct eth_addr *ethdst_addr,
const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr,
const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr,
const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr,
const struct eth_addr *hwdst_addr, const ip4_addr_t *ipdst_addr,
const u16_t opcode);
#endif /* LWIP_AUTOIP */
#endif /* LWIP_ARP */
#endif /* LWIP_IPV4 && LWIP_ARP */
err_t ethernet_input(struct pbuf *p, struct netif *netif);

View File

@@ -299,9 +299,9 @@ typedef struct ppp_settings_s {
#if PPP_SERVER
struct ppp_addrs {
#if PPP_IPV4_SUPPORT
ip_addr_t our_ipaddr, his_ipaddr, netmask;
ip4_addr_t our_ipaddr, his_ipaddr, netmask;
#if LWIP_DNS
ip_addr_t dns1, dns2;
ip4_addr_t dns1, dns2;
#endif /* LWIP_DNS */
#endif /* PPP_IPV4_SUPPORT */
#if PPP_IPV6_SUPPORT

View File

@@ -166,7 +166,7 @@ struct pppol2tp_pcb_s {
u8_t phase; /* L2TP phase */
struct udp_pcb *udp; /* UDP L2TP Socket */
struct netif *netif; /* Output interface, used as a default route */
ipX_addr_t remote_ip; /* LNS IP Address */
ip_addr_t remote_ip; /* LNS IP Address */
u16_t remote_port; /* LNS port */
#if PPPOL2TP_AUTH_SUPPORT
u8_t *secret; /* Secret string */
@@ -193,7 +193,7 @@ struct pppol2tp_pcb_s {
/* Create a new L2TP session over IPv4. */
ppp_pcb *pppol2tp_create(struct netif *pppif,
struct netif *netif, ip_addr_t *ipaddr, u16_t port,
struct netif *netif, ip4_addr_t *ipaddr, u16_t port,
u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);