mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
net/sock/udp: add sock_udp_ep_is_multicast()
This commit is contained in:
parent
777857ae4c
commit
15fd7a9a1c
@ -268,6 +268,7 @@
|
||||
#ifndef NET_SOCK_UDP_H
|
||||
#define NET_SOCK_UDP_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -280,7 +281,10 @@
|
||||
# pragma clang diagnostic ignored "-Wtypedef-redefinition"
|
||||
#endif
|
||||
|
||||
#include "net/af.h"
|
||||
#include "net/sock.h"
|
||||
#include "net/ipv4/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -785,6 +789,31 @@ static inline ssize_t sock_udp_sendv(sock_udp_t *sock,
|
||||
return sock_udp_sendv_aux(sock, snips, remote, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the IP address of an endpoint is multicast
|
||||
*
|
||||
* @param[in] ep end point to check
|
||||
*
|
||||
* @returns true if end point is multicast
|
||||
*/
|
||||
static inline bool sock_udp_ep_is_multicast(const sock_udp_ep_t *ep)
|
||||
{
|
||||
switch (ep->family) {
|
||||
#ifdef SOCK_HAS_IPV6
|
||||
case AF_INET6:
|
||||
return ipv6_addr_is_multicast((const ipv6_addr_t *)&ep->addr.ipv6);
|
||||
#endif
|
||||
#ifdef SOCK_HAS_IPV4
|
||||
case AF_INET:
|
||||
return ipv4_addr_is_multicast((const ipv4_addr_t *)&ep->addr.ipv4);
|
||||
#endif
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "sock_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user