mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-26 16:12:55 +00:00
Use macro to test netconn_type
Changes two IPv4 multicast socket options to use the LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE macro.
This commit is contained in:
parent
d96a90a5ec
commit
e27013aec3
@ -3080,21 +3080,13 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
|
|||||||
break;
|
break;
|
||||||
#if LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS && LWIP_UDP
|
#if LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS && LWIP_UDP
|
||||||
case IP_MULTICAST_TTL:
|
case IP_MULTICAST_TTL:
|
||||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, u8_t);
|
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, u8_t, NETCONN_UDP);
|
||||||
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) {
|
|
||||||
done_socket(sock);
|
|
||||||
return ENOPROTOOPT;
|
|
||||||
}
|
|
||||||
*(u8_t *)optval = udp_get_multicast_ttl(sock->conn->pcb.udp);
|
*(u8_t *)optval = udp_get_multicast_ttl(sock->conn->pcb.udp);
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_TTL) = %d\n",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_TTL) = %d\n",
|
||||||
s, *(int *)optval));
|
s, *(int *)optval));
|
||||||
break;
|
break;
|
||||||
case IP_MULTICAST_IF:
|
case IP_MULTICAST_IF:
|
||||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, struct in_addr);
|
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, *optlen, struct in_addr, NETCONN_UDP);
|
||||||
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) {
|
|
||||||
done_socket(sock);
|
|
||||||
return ENOPROTOOPT;
|
|
||||||
}
|
|
||||||
inet_addr_from_ip4addr((struct in_addr *)optval, udp_get_multicast_netif_addr(sock->conn->pcb.udp));
|
inet_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));
|
||||||
|
Loading…
Reference in New Issue
Block a user