(api break) qualify ip_addr_t as const where feasible

this changes the callback signatures of the ip_output and the
{udp,raw}_recv functions.

changes were made by going through all header files, searching for
occurrences of ip_addr_t, qualifying them as const and if required
modifying the corresponding c files, looking for other uses of ip_addr_t
that would be required.

the following header files were not treated as i'm not using them and
wouldn't see them compiled: api.h api_msg.h dhcp.h dns.h igmp.h
netifapi.h pppapi.h snmp.h snmp_msg.h snmp_structs.h ppp.h pppol2tp.h
test/*

no modifications were done on ip6_addr_t.
This commit is contained in:
chrysn
2015-01-24 01:25:18 +01:00
committed by sg
parent df3f05e824
commit 9f065c0ea5
18 changed files with 96 additions and 95 deletions

View File

@@ -309,7 +309,7 @@ inet_cksum_pseudo_base(struct pbuf *p, u8_t proto, u16_t proto_len, u32_t acc)
*/
u16_t
inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len,
ip_addr_t *src, ip_addr_t *dest)
const ip_addr_t *src, const ip_addr_t *dest)
{
u32_t acc;
u32_t addr;
@@ -421,7 +421,7 @@ inet_cksum_pseudo_partial_base(struct pbuf *p, u8_t proto, u16_t proto_len,
*/
u16_t
inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len,
u16_t chksum_len, ip_addr_t *src, ip_addr_t *dest)
u16_t chksum_len, const ip_addr_t *src, const ip_addr_t *dest)
{
u32_t acc;
u32_t addr;

View File

@@ -108,7 +108,7 @@ static u16_t ip_id;
* @return the netif on which to send to reach dest
*/
struct netif *
ip_route(ip_addr_t *dest)
ip_route(const ip_addr_t *dest)
{
struct netif *netif;
@@ -649,7 +649,7 @@ ip_input(struct pbuf *p, struct netif *inp)
* unique identifiers independent of destination"
*/
err_t
ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
ip_output_if(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
u8_t ttl, u8_t tos,
u8_t proto, struct netif *netif)
{
@@ -663,12 +663,12 @@ ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
* @ param ip_options pointer to the IP options, copied into the IP header
* @ param optlen length of ip_options
*/
err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
err_t ip_output_if_opt(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
u16_t optlen)
{
#endif /* IP_OPTIONS_SEND */
ip_addr_t *src_used = src;
const ip_addr_t *src_used = src;
if (dest != IP_HDRINCL) {
if (ip_addr_isany(src)) {
src_used = &netif->ip_addr;
@@ -688,7 +688,7 @@ err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
* when it is 'any'.
*/
err_t
ip_output_if_src(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
ip_output_if_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
u8_t ttl, u8_t tos,
u8_t proto, struct netif *netif)
{
@@ -700,7 +700,7 @@ ip_output_if_src(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
* Same as ip_output_if_opt() but 'src' address is not replaced by netif address
* when it is 'any'.
*/
err_t ip_output_if_opt_src(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
err_t ip_output_if_opt_src(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
u16_t optlen)
{
@@ -861,7 +861,7 @@ err_t ip_output_if_opt_src(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
* see ip_output_if() for more return values
*/
err_t
ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
ip_output(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
u8_t ttl, u8_t tos, u8_t proto)
{
struct netif *netif;
@@ -898,7 +898,7 @@ ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
* see ip_output_if() for more return values
*/
err_t
ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
ip_output_hinted(struct pbuf *p, const ip_addr_t *src, const ip_addr_t *dest,
u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint)
{
struct netif *netif;

View File

@@ -677,7 +677,7 @@ ipfrag_free_pbuf_custom(struct pbuf *p)
* @return ERR_OK if sent successfully, err_t otherwise
*/
err_t
ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)
ip_frag(struct pbuf *p, struct netif *netif, const ip_addr_t *dest)
{
struct pbuf *rambuf;
#if IP_FRAG_USES_STATIC_BUF

View File

@@ -95,7 +95,7 @@ static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr
#endif
#if LWIP_HAVE_LOOPIF
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr);
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);
#endif
@@ -171,8 +171,8 @@ netif_init(void)
* @return netif, or NULL if failed.
*/
struct netif *
netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)
netif_add(struct netif *netif, const ip_addr_t *ipaddr, const ip_addr_t *netmask,
const ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)
{
#if LWIP_IPV6
u32_t i;
@@ -277,8 +277,8 @@ netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
* @param gw the new default gateway
*/
void
netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
ip_addr_t *gw)
netif_set_addr(struct netif *netif, const ip_addr_t *ipaddr, const ip_addr_t *netmask,
const ip_addr_t *gw)
{
netif_set_ipaddr(netif, ipaddr);
netif_set_netmask(netif, netmask);
@@ -383,7 +383,7 @@ netif_find(char *name)
* default gateway
*/
void
netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)
netif_set_ipaddr(struct netif *netif, const ip_addr_t *ipaddr)
{
/* TODO: Handling of obsolete pcbs */
/* See: http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */
@@ -448,7 +448,7 @@ netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)
* @note call netif_set_addr() if you also want to change ip address and netmask
*/
void
netif_set_gw(struct netif *netif, ip_addr_t *gw)
netif_set_gw(struct netif *netif, const ip_addr_t *gw)
{
ip_addr_set(&(netif->gw), gw);
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
@@ -469,7 +469,7 @@ netif_set_gw(struct netif *netif, ip_addr_t *gw)
* default gateway
*/
void
netif_set_netmask(struct netif *netif, ip_addr_t *netmask)
netif_set_netmask(struct netif *netif, const ip_addr_t *netmask)
{
snmp_delete_iprteidx_tree(0, netif);
/* set new netmask to netif */
@@ -763,7 +763,7 @@ netif_loop_output(struct netif *netif, struct pbuf *p)
}
static err_t
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, ip_addr_t* addr)
netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip_addr_t* addr)
{
LWIP_UNUSED_ARG(addr);
return netif_loop_output(netif, p);

View File

@@ -170,7 +170,7 @@ raw_input(struct pbuf *p, struct netif *inp)
* @see raw_disconnect()
*/
err_t
raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr)
raw_bind(struct raw_pcb *pcb, const ip_addr_t *ipaddr)
{
ipX_addr_set_ipaddr(PCB_ISIPV6(pcb), &pcb->local_ip, ipaddr);
return ERR_OK;
@@ -190,7 +190,7 @@ raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr)
* @see raw_disconnect() and raw_sendto()
*/
err_t
raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr)
raw_connect(struct raw_pcb *pcb, const ip_addr_t *ipaddr)
{
ipX_addr_set_ipaddr(PCB_ISIPV6(pcb), &pcb->remote_ip, ipaddr);
return ERR_OK;
@@ -231,14 +231,14 @@ raw_recv(struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)
*
*/
err_t
raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr)
{
err_t err;
struct netif *netif;
ipX_addr_t *src_ip;
struct pbuf *q; /* q will be sent down the stack */
s16_t header_size;
ipX_addr_t *dst_ip = ip_2_ipX(ipaddr);
const ipX_addr_t *dst_ip = ip_2_ipX(ipaddr);
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n"));

View File

@@ -436,7 +436,7 @@ tcp_abort(struct tcp_pcb *pcb)
* ERR_OK if bound
*/
err_t
tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
{
int i;
int max_pcb_list = NUM_TCP_PCB_LISTS;
@@ -726,7 +726,7 @@ again:
* other err_t values if connect request couldn't be sent
*/
err_t
tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port,
tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
tcp_connected_fn connected)
{
err_t ret;

View File

@@ -540,7 +540,7 @@ udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p,
*/
err_t
udp_sendto(struct udp_pcb *pcb, struct pbuf *p,
ip_addr_t *dst_ip, u16_t dst_port)
const ip_addr_t *dst_ip, u16_t dst_port)
{
#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
return udp_sendto_chksum(pcb, p, dst_ip, dst_port, 0, 0);
@@ -548,12 +548,12 @@ udp_sendto(struct udp_pcb *pcb, struct pbuf *p,
/** Same as udp_sendto(), but with checksum */
err_t
udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
u16_t dst_port, u8_t have_chksum, u16_t chksum)
{
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
struct netif *netif;
ipX_addr_t *dst_ip_route = ip_2_ipX(dst_ip);
const ipX_addr_t *dst_ip_route = ip_2_ipX(dst_ip);
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n"));
@@ -612,7 +612,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
*/
err_t
udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p,
ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif)
const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif)
{
#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0);
@@ -620,12 +620,12 @@ udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p,
/** Same as udp_sendto_if(), but with checksum */
err_t
udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
u16_t dst_port, struct netif *netif, u8_t have_chksum,
u16_t chksum)
{
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
ip_addr_t *src_ip;
const ip_addr_t *src_ip;
/* PCB local address is IP_ANY_ADDR? */
#if LWIP_IPV6
@@ -670,7 +670,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
/** Same as udp_sendto_if(), but with source address */
err_t
udp_sendto_if_src(struct udp_pcb *pcb, struct pbuf *p,
ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif, ip_addr_t *src_ip)
const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif, const ip_addr_t *src_ip)
{
#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0, src_ip);
@@ -678,9 +678,9 @@ udp_sendto_if_src(struct udp_pcb *pcb, struct pbuf *p,
/** Same as udp_sendto_if_src(), but with checksum */
err_t
udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
u16_t dst_port, struct netif *netif, u8_t have_chksum,
u16_t chksum, ip_addr_t *src_ip)
u16_t chksum, const ip_addr_t *src_ip)
{
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
struct udp_hdr *udphdr;
@@ -883,7 +883,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip,
* @see udp_disconnect()
*/
err_t
udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
{
struct udp_pcb *ipcb;
u8_t rebind;
@@ -969,7 +969,7 @@ udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
* @see udp_disconnect()
*/
err_t
udp_connect(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port)
udp_connect(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
{
struct udp_pcb *ipcb;