diff --git a/CHANGELOG b/CHANGELOG index 151d49fc..31b25961 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,11 @@ HISTORY ++ New features: + 2015-02-22: chrysn, Simon Goldschmidt + * *.*: Changed nearly all functions taking 'ip(X)_addr_t' pointer to take + const pointers (changed user callbacks: raw_recv_fn, udp_recv_fn; changed + port callbacks: netif_output_fn, netif_igmp_mac_filter_fn) + 2015-02-19: Ivan Delamer * netif.h, dhcp.c: Removed unused netif flag for DHCP. The preferred way to evaluate if DHCP is active is through netif->dhcp field. diff --git a/src/api/api_lib.c b/src/api/api_lib.c index ce793f13..ecd2d912 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -196,7 +196,7 @@ netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) * @return ERR_OK if bound, any other err_t on failure */ err_t -netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port) +netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port) { API_MSG_VAR_DECLARE(msg); err_t err; @@ -228,7 +228,7 @@ netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port) * @return ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise */ err_t -netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port) +netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port) { API_MSG_VAR_DECLARE(msg); err_t err; @@ -626,7 +626,7 @@ netconn_recved(struct netconn *conn, u32_t length) * @return ERR_OK if data was sent, any other err_t on error */ err_t -netconn_sendto(struct netconn *conn, struct netbuf *buf, ip_addr_t *addr, u16_t port) +netconn_sendto(struct netconn *conn, struct netbuf *buf, const ip_addr_t *addr, u16_t port) { if (buf != NULL) { ipX_addr_set_ipaddr(PCB_ISIPV6(conn->pcb.ip), &buf->addr, addr); @@ -806,8 +806,8 @@ netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx) */ err_t netconn_join_leave_group(struct netconn *conn, - ip_addr_t *multiaddr, - ip_addr_t *netif_addr, + const ip_addr_t *multiaddr, + const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave) { API_MSG_VAR_DECLARE(msg); diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 3fe7673f..73bf782d 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -80,7 +80,7 @@ static err_t lwip_netconn_do_close_internal(struct netconn *conn); */ static u8_t recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, - ip_addr_t *addr) + const ip_addr_t *addr) { struct pbuf *q; struct netbuf *buf; @@ -146,7 +146,7 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, */ static void recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *addr, u16_t port) + const ip_addr_t *addr, u16_t port) { struct netbuf *buf; struct netconn *conn; diff --git a/src/core/dhcp.c b/src/core/dhcp.c index 8e676db0..05b55157 100644 --- a/src/core/dhcp.c +++ b/src/core/dhcp.c @@ -179,7 +179,7 @@ static err_t dhcp_reboot(struct netif *netif); static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state); /* receive, unfold, parse and free incoming messages */ -static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); +static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); /* set the DHCP timers */ static void dhcp_timeout(struct netif *netif); @@ -1581,7 +1581,7 @@ decode_next: * If an incoming DHCP message is in response to us, then trigger the state machine */ static void -dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) +dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) { struct netif *netif = (struct netif *)arg; struct dhcp *dhcp = netif->dhcp; diff --git a/src/core/dns.c b/src/core/dns.c index 45b416b4..44513c9a 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -277,7 +277,7 @@ static void dns_init_local(); /* forward declarations */ -static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); +static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); static void dns_check_entries(void); /*----------------------------------------------------------------------------- @@ -979,7 +979,7 @@ dns_check_entries(void) * @params see udp.h */ static void -dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) +dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) { u8_t i, entry_idx = DNS_TABLE_SIZE; u16_t txid; diff --git a/src/core/inet_chksum.c b/src/core/inet_chksum.c index 9f68e472..8124523e 100644 --- a/src/core/inet_chksum.c +++ b/src/core/inet_chksum.c @@ -340,7 +340,7 @@ inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, */ u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - ip6_addr_t *src, ip6_addr_t *dest) + const ip6_addr_t *src, const ip6_addr_t *dest) { u32_t acc = 0; u32_t addr; @@ -455,7 +455,7 @@ inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, */ u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest) + u16_t chksum_len, const ip6_addr_t *src, const ip6_addr_t *dest) { u32_t acc = 0; u32_t addr; diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index 3003c6b7..8fbae299 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -135,7 +135,7 @@ PACK_STRUCT_END #endif -static struct igmp_group *igmp_lookup_group(struct netif *ifp, ip_addr_t *addr); +static struct igmp_group *igmp_lookup_group(struct netif *ifp, const ip_addr_t *addr); static err_t igmp_remove_group(struct igmp_group *group); static void igmp_timeout( struct igmp_group *group); static void igmp_start_timer(struct igmp_group *group, u8_t max_time); @@ -287,7 +287,7 @@ igmp_report_groups(struct netif *netif) * NULL if the group wasn't found. */ struct igmp_group * -igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr) +igmp_lookfor_group(struct netif *ifp, const ip_addr_t *addr) { struct igmp_group *group = igmp_group_list; @@ -313,7 +313,7 @@ igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr) * NULL on memory error. */ struct igmp_group * -igmp_lookup_group(struct netif *ifp, ip_addr_t *addr) +igmp_lookup_group(struct netif *ifp, const ip_addr_t *addr) { struct igmp_group *group = igmp_group_list; @@ -386,7 +386,7 @@ igmp_remove_group(struct igmp_group *group) * @param dest destination ip address of the igmp packet */ void -igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) +igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest) { struct igmp_msg* igmp; struct igmp_group* group; @@ -510,7 +510,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) * @return ERR_OK if group was joined on the netif(s), an err_t otherwise */ err_t -igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) +igmp_joingroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr) { err_t err = ERR_VAL; /* no matching interface */ struct igmp_group *group; @@ -580,7 +580,7 @@ igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) * @return ERR_OK if group was left on the netif(s), an err_t otherwise */ err_t -igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) +igmp_leavegroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr) { err_t err = ERR_VAL; /* no matching interface */ struct igmp_group *group; diff --git a/src/core/ipv6/ethip6.c b/src/core/ipv6/ethip6.c index d9ac30f6..eedc1f9a 100644 --- a/src/core/ipv6/ethip6.c +++ b/src/core/ipv6/ethip6.c @@ -133,7 +133,7 @@ ethip6_send(struct netif *netif, struct pbuf *p, struct eth_addr *src, struct et * or the return type of either etharp_query() or etharp_send_ip(). */ err_t -ethip6_output(struct netif *netif, struct pbuf *q, ip6_addr_t *ip6addr) +ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr) { struct eth_addr dest; s8_t i; diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c index 85a61804..d934950f 100644 --- a/src/core/ipv6/ip6.c +++ b/src/core/ipv6/ip6.c @@ -78,7 +78,7 @@ * @return the netif on which to send to reach dest */ struct netif * -ip6_route(struct ip6_addr *src, struct ip6_addr *dest) +ip6_route(const struct ip6_addr *src, const struct ip6_addr *dest) { struct netif *netif; s8_t i; @@ -156,7 +156,7 @@ ip6_route(struct ip6_addr *src, struct ip6_addr *dest) * source address is found */ ip6_addr_t * -ip6_select_source_address(struct netif *netif, ip6_addr_t * dest) +ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest) { ip6_addr_t * src = NULL; u8_t i; @@ -744,11 +744,11 @@ ip6_input_cleanup: * returns errors returned by netif->output */ err_t -ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, +ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif) { - ip6_addr_t *src_used = src; + const ip6_addr_t *src_used = src; if (dest != IP_HDRINCL) { if (src != NULL && ip6_addr_isany(src)) { src = ip6_select_source_address(netif, dest); @@ -768,7 +768,7 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, * when it is 'any'. */ err_t -ip6_output_if_src(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, +ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif) { diff --git a/src/core/ipv6/mld6.c b/src/core/ipv6/mld6.c index 0771f5c8..0279b169 100644 --- a/src/core/ipv6/mld6.c +++ b/src/core/ipv6/mld6.c @@ -76,7 +76,7 @@ static struct mld_group* mld_group_list; /* Forward declarations. */ -static struct mld_group * mld6_new_group(struct netif *ifp, ip6_addr_t *addr); +static struct mld_group * mld6_new_group(struct netif *ifp, const ip6_addr_t *addr); static err_t mld6_free_group(struct mld_group *group); static void mld6_delayed_report(struct mld_group *group, u16_t maxresp); static void mld6_send(struct mld_group *group, u8_t type); @@ -150,7 +150,7 @@ mld6_report_groups(struct netif *netif) * NULL if the group wasn't found. */ struct mld_group * -mld6_lookfor_group(struct netif *ifp, ip6_addr_t *addr) +mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr) { struct mld_group *group = mld_group_list; @@ -174,7 +174,7 @@ mld6_lookfor_group(struct netif *ifp, ip6_addr_t *addr) * NULL on memory error. */ static struct mld_group * -mld6_new_group(struct netif *ifp, ip6_addr_t *addr) +mld6_new_group(struct netif *ifp, const ip6_addr_t *addr) { struct mld_group *group; @@ -324,7 +324,7 @@ mld6_input(struct pbuf *p, struct netif *inp) * @return ERR_OK if group was joined on the netif(s), an err_t otherwise */ err_t -mld6_joingroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr) +mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr) { err_t err = ERR_VAL; /* no matching interface */ struct mld_group *group; @@ -391,7 +391,7 @@ mld6_joingroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr) * @return ERR_OK if group was left on the netif(s), an err_t otherwise */ err_t -mld6_leavegroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr) +mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr) { err_t err = ERR_VAL; /* no matching interface */ struct mld_group *group; diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c index d3dc6ca8..a67f1b6a 100644 --- a/src/core/ipv6/nd6.c +++ b/src/core/ipv6/nd6.c @@ -82,21 +82,21 @@ static ip6_addr_t multicast_address; static u8_t nd6_ra_buffer[sizeof(struct prefix_option)]; /* Forward declarations. */ -static s8_t nd6_find_neighbor_cache_entry(ip6_addr_t * ip6addr); +static s8_t nd6_find_neighbor_cache_entry(const ip6_addr_t * ip6addr); static s8_t nd6_new_neighbor_cache_entry(void); static void nd6_free_neighbor_cache_entry(s8_t i); -static s8_t nd6_find_destination_cache_entry(ip6_addr_t * ip6addr); +static s8_t nd6_find_destination_cache_entry(const ip6_addr_t * ip6addr); static s8_t nd6_new_destination_cache_entry(void); -static s8_t nd6_is_prefix_in_netif(ip6_addr_t * ip6addr, struct netif * netif); -static s8_t nd6_get_router(ip6_addr_t * router_addr, struct netif * netif); -static s8_t nd6_new_router(ip6_addr_t * router_addr, struct netif * netif); +static s8_t nd6_is_prefix_in_netif(const ip6_addr_t * ip6addr, struct netif * netif); +static s8_t nd6_get_router(const ip6_addr_t * router_addr, struct netif * netif); +static s8_t nd6_new_router(const ip6_addr_t * router_addr, struct netif * netif); static s8_t nd6_get_onlink_prefix(ip6_addr_t * prefix, struct netif * netif); static s8_t nd6_new_onlink_prefix(ip6_addr_t * prefix, struct netif * netif); #define ND6_SEND_FLAG_MULTICAST_DEST 0x01 #define ND6_SEND_FLAG_ALLNODES_DEST 0x02 -static void nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags); -static void nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags); +static void nd6_send_ns(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags); +static void nd6_send_na(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags); #if LWIP_IPV6_SEND_ROUTER_SOLICIT static void nd6_send_rs(struct netif * netif); #endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ @@ -794,7 +794,7 @@ nd6_tmr(void) * @param flags one of ND6_SEND_FLAG_* */ static void -nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags) +nd6_send_ns(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags) { struct ns_header * ns_hdr; struct lladdr_option * lladdr_opt; @@ -859,13 +859,13 @@ nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags) * @param flags one of ND6_SEND_FLAG_* */ static void -nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags) +nd6_send_na(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags) { struct na_header * na_hdr; struct lladdr_option * lladdr_opt; struct pbuf * p; - ip6_addr_t * src_addr; - ip6_addr_t * dest_addr; + const ip6_addr_t * src_addr; + const ip6_addr_t * dest_addr; /* Use link-local address as source address. */ /* src_addr = &(netif->ip6_addr[0]); */ @@ -1003,7 +1003,7 @@ nd6_send_rs(struct netif * netif) * entry is found */ static s8_t -nd6_find_neighbor_cache_entry(ip6_addr_t * ip6addr) +nd6_find_neighbor_cache_entry(const ip6_addr_t * ip6addr) { s8_t i; for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { @@ -1158,7 +1158,7 @@ nd6_free_neighbor_cache_entry(s8_t i) * entry is found */ static s8_t -nd6_find_destination_cache_entry(ip6_addr_t * ip6addr) +nd6_find_destination_cache_entry(const ip6_addr_t * ip6addr) { s8_t i; for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { @@ -1208,7 +1208,7 @@ nd6_new_destination_cache_entry(void) * @return 1 if the address is on-link, 0 otherwise */ static s8_t -nd6_is_prefix_in_netif(ip6_addr_t * ip6addr, struct netif * netif) +nd6_is_prefix_in_netif(const ip6_addr_t * ip6addr, struct netif * netif) { s8_t i; for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) { @@ -1237,7 +1237,7 @@ nd6_is_prefix_in_netif(ip6_addr_t * ip6addr, struct netif * netif) * router is found */ s8_t -nd6_select_router(ip6_addr_t * ip6addr, struct netif * netif) +nd6_select_router(const ip6_addr_t * ip6addr, struct netif * netif) { s8_t i; /* last_router is used for round-robin router selection (as recommended @@ -1296,7 +1296,7 @@ nd6_select_router(ip6_addr_t * ip6addr, struct netif * netif) * @return the index of the router entry, or -1 if not found */ static s8_t -nd6_get_router(ip6_addr_t * router_addr, struct netif * netif) +nd6_get_router(const ip6_addr_t * router_addr, struct netif * netif) { s8_t i; @@ -1321,7 +1321,7 @@ nd6_get_router(ip6_addr_t * router_addr, struct netif * netif) * @return the index on the router table, or -1 if could not be created */ static s8_t -nd6_new_router(ip6_addr_t * router_addr, struct netif * netif) +nd6_new_router(const ip6_addr_t * router_addr, struct netif * netif) { s8_t router_index; s8_t neighbor_index; @@ -1427,7 +1427,7 @@ nd6_new_onlink_prefix(ip6_addr_t * prefix, struct netif * netif) * could be created */ s8_t -nd6_get_next_hop_entry(ip6_addr_t * ip6addr, struct netif * netif) +nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif) { s8_t i; @@ -1726,7 +1726,7 @@ nd6_send_q(s8_t i) * @return the Path MTU, if known, or the netif default MTU */ u16_t -nd6_get_destination_mtu(ip6_addr_t * ip6addr, struct netif * netif) +nd6_get_destination_mtu(const ip6_addr_t * ip6addr, struct netif * netif) { s8_t i; @@ -1756,7 +1756,7 @@ nd6_get_destination_mtu(ip6_addr_t * ip6addr, struct netif * netif) * by an upper layer protocol (TCP) */ void -nd6_reachability_hint(ip6_addr_t * ip6addr) +nd6_reachability_hint(const ip6_addr_t * ip6addr) { s8_t i; diff --git a/src/core/netif.c b/src/core/netif.c index 82442f3d..328694c4 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -85,7 +85,7 @@ struct netif *netif_default; static u8_t netif_num; #if LWIP_IPV6 -static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr); +static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr); #endif /* LWIP_IPV6 */ #if LWIP_IPV6 @@ -97,7 +97,7 @@ static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr #if LWIP_HAVE_LOOPIF static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip_addr_t* addr); #if LWIP_IPV6 -static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr); +static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t* addr); #endif @@ -771,7 +771,7 @@ netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip_addr_t* add #if LWIP_IPV6 static err_t -netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, ip6_addr_t* addr) +netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t* addr) { LWIP_UNUSED_ARG(addr); return netif_loop_output(netif, p); @@ -929,7 +929,7 @@ netif_create_ip6_linklocal_address(struct netif * netif, u8_t from_mac_48bit) } static err_t -netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) +netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr) { (void)netif; (void)p; diff --git a/src/core/snmp/msg_in.c b/src/core/snmp/msg_in.c index 08c5b346..57457b51 100644 --- a/src/core/snmp/msg_in.c +++ b/src/core/snmp/msg_in.c @@ -64,7 +64,7 @@ struct snmp_msg_pstat msg_input_list[SNMP_CONCURRENT_REQUESTS]; /* UDP Protocol Control Block */ struct udp_pcb *snmp1_pcb; -static void snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port); +static void snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port); static err_t snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat); static err_t snmp_pdu_dec_varbindlist(struct pbuf *p, u16_t ofs, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat); @@ -901,7 +901,7 @@ snmp_msg_event(u8_t request_id) /* lwIP UDP receive callback function */ static void -snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t port) +snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) { struct snmp_msg_pstat *msg_ps; u8_t req_idx; diff --git a/src/include/lwip/api.h b/src/include/lwip/api.h index c0145a66..4dde3e2e 100644 --- a/src/include/lwip/api.h +++ b/src/include/lwip/api.h @@ -263,8 +263,8 @@ LWIP_NETCONN_SCOPE err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr #define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) #define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) -LWIP_NETCONN_SCOPE err_t netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port); -LWIP_NETCONN_SCOPE err_t netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port); +LWIP_NETCONN_SCOPE err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port); +LWIP_NETCONN_SCOPE err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port); LWIP_NETCONN_SCOPE err_t netconn_disconnect (struct netconn *conn); LWIP_NETCONN_SCOPE err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); #define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) @@ -273,7 +273,7 @@ LWIP_NETCONN_SCOPE err_t netconn_recv(struct netconn *conn, struct netbuf **ne LWIP_NETCONN_SCOPE err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); LWIP_NETCONN_SCOPE void netconn_recved(struct netconn *conn, u32_t length); LWIP_NETCONN_SCOPE err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, - ip_addr_t *addr, u16_t port); + const ip_addr_t *addr, u16_t port); LWIP_NETCONN_SCOPE err_t netconn_send(struct netconn *conn, struct netbuf *buf); LWIP_NETCONN_SCOPE err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, u8_t apiflags, size_t *bytes_written); @@ -283,8 +283,8 @@ LWIP_NETCONN_SCOPE err_t netconn_close(struct netconn *conn); LWIP_NETCONN_SCOPE err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -LWIP_NETCONN_SCOPE err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr, - ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); +LWIP_NETCONN_SCOPE err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr, + const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ #if LWIP_DNS err_t netconn_gethostbyname(const char *name, ip_addr_t *addr); diff --git a/src/include/lwip/api_msg.h b/src/include/lwip/api_msg.h index e602a1af..7dcf01a4 100644 --- a/src/include/lwip/api_msg.h +++ b/src/include/lwip/api_msg.h @@ -56,9 +56,11 @@ extern "C" { #endif #if LWIP_MPU_COMPATIBLE -#define API_MSG_M_DEF(m) m +#define API_MSG_M_DEF(m) m +#define API_MSG_M_DEF_C(t, m) t m #else /* LWIP_MPU_COMPATIBLE */ -#define API_MSG_M_DEF(m) *m +#define API_MSG_M_DEF(m) *m +#define API_MSG_M_DEF_C(t, m) const t * m #endif /* LWIP_MPU_COMPATIBLE */ /* For the netconn API, these values are use as a bitmask! */ @@ -88,7 +90,7 @@ struct api_msg_msg { } n; /** used for lwip_netconn_do_bind and lwip_netconn_do_connect */ struct { - ip_addr_t API_MSG_M_DEF(ipaddr); + API_MSG_M_DEF_C(ip_addr_t, ipaddr); u16_t port; } bc; /** used for lwip_netconn_do_getaddr */ @@ -122,8 +124,8 @@ struct api_msg_msg { #if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) /** used for lwip_netconn_do_join_leave_group */ struct { - ipX_addr_t API_MSG_M_DEF(multiaddr); - ipX_addr_t API_MSG_M_DEF(netif_addr); + API_MSG_M_DEF_C(ipX_addr_t, multiaddr); + API_MSG_M_DEF_C(ipX_addr_t, netif_addr); enum netconn_igmp join_or_leave; } jl; #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ @@ -167,7 +169,7 @@ struct dns_api_msg { #else /* LWIP_MPU_COMPATIBLE */ const char *name; #endif /* LWIP_MPU_COMPATIBLE */ - /** Rhe resolved address is stored here */ + /** The resolved address is stored here */ ip_addr_t API_MSG_M_DEF(addr); /** This semaphore is posted when the name is resolved, the application thread should wait on it. */ diff --git a/src/include/lwip/ethip6.h b/src/include/lwip/ethip6.h index 31fed183..5e88dffd 100644 --- a/src/include/lwip/ethip6.h +++ b/src/include/lwip/ethip6.h @@ -57,7 +57,7 @@ extern "C" { #endif -err_t ethip6_output(struct netif *netif, struct pbuf *q, ip6_addr_t *ip6addr); +err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); #ifdef __cplusplus } diff --git a/src/include/lwip/igmp.h b/src/include/lwip/igmp.h index 4687b1fd..32e770ef 100644 --- a/src/include/lwip/igmp.h +++ b/src/include/lwip/igmp.h @@ -91,10 +91,10 @@ void igmp_init(void); err_t igmp_start(struct netif *netif); err_t igmp_stop(struct netif *netif); void igmp_report_groups(struct netif *netif); -struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); -void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); -err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); -err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); +struct igmp_group *igmp_lookfor_group(struct netif *ifp, const ip_addr_t *addr); +void igmp_input(struct pbuf *p, struct netif *inp, const ip_addr_t *dest); +err_t igmp_joingroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr); +err_t igmp_leavegroup(const ip_addr_t *ifaddr, const ip_addr_t *groupaddr); void igmp_tmr(void); #ifdef __cplusplus diff --git a/src/include/lwip/inet_chksum.h b/src/include/lwip/inet_chksum.h index e40f2169..4ae38ee1 100644 --- a/src/include/lwip/inet_chksum.h +++ b/src/include/lwip/inet_chksum.h @@ -82,9 +82,9 @@ u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); #if LWIP_IPV6 u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - ip6_addr_t *src, ip6_addr_t *dest); + const ip6_addr_t *src, const ip6_addr_t *dest); u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest); + u16_t chksum_len, const ip6_addr_t *src, const ip6_addr_t *dest); #define ipX_chksum_pseudo(isipv6, p, proto, proto_len, src, dest) \ ((isipv6) ? \ diff --git a/src/include/lwip/ip6.h b/src/include/lwip/ip6.h index a7b264f0..c650dbfe 100644 --- a/src/include/lwip/ip6.h +++ b/src/include/lwip/ip6.h @@ -162,17 +162,17 @@ PACK_STRUCT_END #define ip6_init() /* TODO should we init current addresses and header pointer? */ -struct netif *ip6_route(struct ip6_addr *src, struct ip6_addr *dest); -ip6_addr_t *ip6_select_source_address(struct netif *netif, ip6_addr_t * dest); +struct netif *ip6_route(const struct ip6_addr *src, const struct ip6_addr *dest); +ip6_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest); err_t ip6_input(struct pbuf *p, struct netif *inp); err_t ip6_output(struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, u8_t hl, u8_t tc, u8_t nexth); -err_t ip6_output_if(struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, +err_t ip6_output_if(struct pbuf *p, const struct ip6_addr *src, const struct ip6_addr *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); -err_t ip6_output_if_src(struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, +err_t ip6_output_if_src(struct pbuf *p, const struct ip6_addr *src, const struct ip6_addr *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); #if LWIP_NETIF_HWADDRHINT -err_t ip6_output_hinted(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, +err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint); #endif /* LWIP_NETIF_HWADDRHINT */ #if LWIP_IPV6_MLD diff --git a/src/include/lwip/mld6.h b/src/include/lwip/mld6.h index f629c3db..d5b515a0 100644 --- a/src/include/lwip/mld6.h +++ b/src/include/lwip/mld6.h @@ -103,10 +103,10 @@ PACK_STRUCT_END err_t mld6_stop(struct netif *netif); void mld6_report_groups(struct netif *netif); void mld6_tmr(void); -struct mld_group *mld6_lookfor_group(struct netif *ifp, ip6_addr_t *addr); +struct mld_group *mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr); void mld6_input(struct pbuf *p, struct netif *inp); -err_t mld6_joingroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr); -err_t mld6_leavegroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr); +err_t mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); +err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); #ifdef __cplusplus diff --git a/src/include/lwip/nd6.h b/src/include/lwip/nd6.h index 2a8401fc..5872ecae 100644 --- a/src/include/lwip/nd6.h +++ b/src/include/lwip/nd6.h @@ -345,12 +345,12 @@ extern u32_t retrans_timer; #define nd6_init() /* TODO should we init tables? */ void nd6_tmr(void); void nd6_input(struct pbuf *p, struct netif *inp); -s8_t nd6_get_next_hop_entry(ip6_addr_t * ip6addr, struct netif * netif); -s8_t nd6_select_router(ip6_addr_t * ip6addr, struct netif * netif); -u16_t nd6_get_destination_mtu(ip6_addr_t * ip6addr, struct netif * netif); +s8_t nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif); +s8_t nd6_select_router(const ip6_addr_t * ip6addr, struct netif * netif); +u16_t nd6_get_destination_mtu(const ip6_addr_t * ip6addr, struct netif * netif); err_t nd6_queue_packet(s8_t neighbor_index, struct pbuf * p); #if LWIP_ND6_TCP_REACHABILITY_HINTS -void nd6_reachability_hint(ip6_addr_t * ip6addr); +void nd6_reachability_hint(const ip6_addr_t * ip6addr); #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ #ifdef __cplusplus diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index 03a820e1..810ace43 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -134,7 +134,7 @@ typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, * @param ipaddr The IPv6 address to which the packet shall be sent */ typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p, - ip6_addr_t *ipaddr); + const ip6_addr_t *ipaddr); #endif /* LWIP_IPV6 */ /** Function prototype for netif->linkoutput functions. Only used for ethernet * netifs. This function is called by ARP when a packet shall be sent. @@ -151,7 +151,7 @@ typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, #if LWIP_IPV6 && LWIP_IPV6_MLD /** Function prototype for netif mld_mac_filter functions */ typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif, - ip6_addr_t *group, u8_t action); + const ip6_addr_t *group, u8_t action); #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ /** Generic data structure used for all lwIP network interfaces. diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h index be9579e8..24f84f4a 100644 --- a/src/include/lwip/udp.h +++ b/src/include/lwip/udp.h @@ -123,7 +123,7 @@ struct udp_pcb { #if LWIP_IGMP /** outgoing network interface for multicast packets */ - const ip_addr_t multicast_ip; + ip_addr_t multicast_ip; #endif /* LWIP_IGMP */ #if LWIP_UDPLITE diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 204abd8d..980c752c 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -180,9 +180,9 @@ const struct protent* const protocols[] = { /* Prototypes for procedures local to this file. */ static void ppp_do_open(void *arg); static err_t ppp_netif_init_cb(struct netif *netif); -static err_t ppp_netif_output_ip4(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr); +static err_t ppp_netif_output_ip4(struct netif *netif, struct pbuf *pb, const ip_addr_t *ipaddr); #if PPP_IPV6_SUPPORT -static err_t ppp_netif_output_ip6(struct netif *netif, struct pbuf *pb, ip6_addr_t *ipaddr); +static err_t ppp_netif_output_ip6(struct netif *netif, struct pbuf *pb, const ip6_addr_t *ipaddr); #endif /* PPP_IPV6_SUPPORT */ /***********************************/ @@ -453,7 +453,7 @@ static err_t ppp_netif_init_cb(struct netif *netif) { /* * Send an IPv4 packet on the given connection. */ -static err_t ppp_netif_output_ip4(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) { +static err_t ppp_netif_output_ip4(struct netif *netif, struct pbuf *pb, const ip_addr_t *ipaddr) { #if PPP_IPV4_SUPPORT ppp_pcb *pcb = (ppp_pcb*)netif->state; LWIP_UNUSED_ARG(ipaddr); @@ -480,7 +480,7 @@ static err_t ppp_netif_output_ip4(struct netif *netif, struct pbuf *pb, ip_addr_ /* * Send an IPv6 packet on the given connection. */ -static err_t ppp_netif_output_ip6(struct netif *netif, struct pbuf *pb, ip6_addr_t *ipaddr) { +static err_t ppp_netif_output_ip6(struct netif *netif, struct pbuf *pb, const ip6_addr_t *ipaddr) { ppp_pcb *pcb = (ppp_pcb*)netif->state; LWIP_UNUSED_ARG(ipaddr);