Function riot_sys::sock_ip_create

source ·
pub unsafe extern "C" fn sock_ip_create(
    sock: *mut sock_ip_t,
    local: *const sock_ip_ep_t,
    remote: *const sock_ip_ep_t,
    proto: u8,
    flags: u16
) -> c_int
Expand description

@brief Creates a new raw IPv4/IPv6 sock object

@pre (sock != NULL)

@param[out] sock The resulting sock object. @param[in] local Local end point for the sock object. May be NULL. sock_ip_ep_t::netif must either be @ref SOCK_ADDR_ANY_NETIF or equal to sock_ip_ep_t::netif of @p remote if remote != NULL. If NULL @ref sock_ip_send() may bind implicitly. @param[in] remote Remote end point for the sock object. May be NULL but then the remote parameter of @ref sock_ip_send() may not be NULL or it will always error with return value -ENOTCONN. sock_ip_ep_t::port may not be 0 if remote != NULL. sock_ip_ep_t::netif must either be @ref SOCK_ADDR_ANY_NETIF or equal to sock_ip_ep_t::netif of @p local if local != NULL. @param[in] proto Protocol to use in the raw IPv4/IPv6 sock object (the protocol header field in IPv4 and the next_header field in IPv6). @param[in] flags Flags for the sock object. See also sock flags. May be 0.

@return 0 on success. @return -EADDRINUSE, if local != NULL and @p local is already used elsewhere @return -EAFNOSUPPORT, if local != NULL or remote != NULL and sock_ip_ep_t::family of @p local or @p remote is not supported. @return -EINVAL, if sock_ip_ep_t::addr of @p remote is an invalid address. @return -EINVAL, if sock_ip_ep_t::netif of @p local or @p remote are not valid interfaces or contradict each other (i.e. (local->netif != remote->netif) && ((local->netif != SOCK_ADDR_ANY_NETIF) || (remote->netif != SOCK_ADDR_ANY_NETIF)) if neither is NULL). @return -ENOMEM, if not enough resources can be provided for sock to be created. @return -EPROTONOSUPPORT, if local != NULL or remote != NULL and proto is not supported by sock_ip_ep_t::family of @p local or @p remote.