mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-25 23:52:51 +00:00
inet.h: Consistently name some inet <-> ipaddr conversion macros
They operate on ip4_addr_t, not on ip_addr_t This should be clearly visible in their names
This commit is contained in:
parent
b99b7577fc
commit
ee7a2f346c
@ -382,7 +382,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
|||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
struct sockaddr_in *sa4 = (struct sockaddr_in*)sa;
|
struct sockaddr_in *sa4 = (struct sockaddr_in*)sa;
|
||||||
/* set up sockaddr */
|
/* set up sockaddr */
|
||||||
inet_addr_from_ipaddr(&sa4->sin_addr, ip_2_ip4(&addr));
|
inet4_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
|
||||||
sa4->sin_family = AF_INET;
|
sa4->sin_family = AF_INET;
|
||||||
sa4->sin_len = sizeof(struct sockaddr_in);
|
sa4->sin_len = sizeof(struct sockaddr_in);
|
||||||
sa4->sin_port = lwip_htons((u16_t)port_nr);
|
sa4->sin_port = lwip_htons((u16_t)port_nr);
|
||||||
|
@ -82,10 +82,10 @@
|
|||||||
(sin)->sin_len = sizeof(struct sockaddr_in); \
|
(sin)->sin_len = sizeof(struct sockaddr_in); \
|
||||||
(sin)->sin_family = AF_INET; \
|
(sin)->sin_family = AF_INET; \
|
||||||
(sin)->sin_port = lwip_htons((port)); \
|
(sin)->sin_port = lwip_htons((port)); \
|
||||||
inet_addr_from_ipaddr(&(sin)->sin_addr, ipaddr); \
|
inet4_addr_from_ip4addr(&(sin)->sin_addr, ipaddr); \
|
||||||
memset((sin)->sin_zero, 0, SIN_ZERO_LEN); }while(0)
|
memset((sin)->sin_zero, 0, SIN_ZERO_LEN); }while(0)
|
||||||
#define SOCKADDR4_TO_IP4ADDR_PORT(sin, ipaddr, port) do { \
|
#define SOCKADDR4_TO_IP4ADDR_PORT(sin, ipaddr, port) do { \
|
||||||
inet_addr_to_ipaddr(ip_2_ip4(ipaddr), &((sin)->sin_addr)); \
|
inet4_addr_to_ip4addr(ip_2_ip4(ipaddr), &((sin)->sin_addr)); \
|
||||||
(port) = lwip_ntohs((sin)->sin_port); }while(0)
|
(port) = lwip_ntohs((sin)->sin_port); }while(0)
|
||||||
#endif /* LWIP_IPV4 */
|
#endif /* LWIP_IPV4 */
|
||||||
|
|
||||||
@ -2001,7 +2001,7 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
|
|||||||
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) {
|
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) {
|
||||||
return ENOPROTOOPT;
|
return ENOPROTOOPT;
|
||||||
}
|
}
|
||||||
inet_addr_from_ipaddr((struct in_addr*)optval, udp_get_multicast_netif_addr(sock->conn->pcb.udp));
|
inet4_addr_from_ip4addr((struct in_addr*)optval, udp_get_multicast_netif_addr(sock->conn->pcb.udp));
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_IF) = 0x%"X32_F"\n",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_IF) = 0x%"X32_F"\n",
|
||||||
s, *(u32_t *)optval));
|
s, *(u32_t *)optval));
|
||||||
break;
|
break;
|
||||||
@ -2365,7 +2365,7 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
|||||||
{
|
{
|
||||||
ip4_addr_t if_addr;
|
ip4_addr_t if_addr;
|
||||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct in_addr, NETCONN_UDP);
|
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct in_addr, NETCONN_UDP);
|
||||||
inet_addr_to_ipaddr(&if_addr, (const struct in_addr*)optval);
|
inet4_addr_to_ip4addr(&if_addr, (const struct in_addr*)optval);
|
||||||
udp_set_multicast_netif_addr(sock->conn->pcb.udp, &if_addr);
|
udp_set_multicast_netif_addr(sock->conn->pcb.udp, &if_addr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2389,8 +2389,8 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
|||||||
ip4_addr_t if_addr;
|
ip4_addr_t if_addr;
|
||||||
ip4_addr_t multi_addr;
|
ip4_addr_t multi_addr;
|
||||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct ip_mreq, NETCONN_UDP);
|
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct ip_mreq, NETCONN_UDP);
|
||||||
inet_addr_to_ipaddr(&if_addr, &imr->imr_interface);
|
inet4_addr_to_ip4addr(&if_addr, &imr->imr_interface);
|
||||||
inet_addr_to_ipaddr(&multi_addr, &imr->imr_multiaddr);
|
inet4_addr_to_ip4addr(&multi_addr, &imr->imr_multiaddr);
|
||||||
if (optname == IP_ADD_MEMBERSHIP) {
|
if (optname == IP_ADD_MEMBERSHIP) {
|
||||||
if (!lwip_socket_register_membership(s, &if_addr, &multi_addr)) {
|
if (!lwip_socket_register_membership(s, &if_addr, &multi_addr)) {
|
||||||
/* cannot track membership (out of memory) */
|
/* cannot track membership (out of memory) */
|
||||||
|
@ -132,10 +132,10 @@ extern const struct in6_addr in6addr_any;
|
|||||||
|
|
||||||
#if LWIP_IPV4
|
#if LWIP_IPV4
|
||||||
|
|
||||||
#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
|
#define inet4_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
|
||||||
#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
|
#define inet4_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
|
||||||
/* ATTENTION: the next define only works because both s_addr and ip4_addr_t are an u32_t effectively! */
|
/* ATTENTION: the next define only works because both s_addr and ip4_addr_t are an u32_t effectively! */
|
||||||
#define inet_addr_to_ipaddr_p(target_ip4addr_p, source_inaddr) ((target_ip4addr_p) = (ip4_addr_t*)&((source_inaddr)->s_addr))
|
#define inet4_addr_to_ip4addr_p(target_ip4addr_p, source_inaddr) ((target_ip4addr_p) = (ip4_addr_t*)&((source_inaddr)->s_addr))
|
||||||
|
|
||||||
/* directly map this to the lwip internal functions */
|
/* directly map this to the lwip internal functions */
|
||||||
#define inet_addr(cp) ipaddr_addr(cp)
|
#define inet_addr(cp) ipaddr_addr(cp)
|
||||||
|
Loading…
Reference in New Issue
Block a user