2018-08-03 21:22:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/netlink/netlink.h
|
|
|
|
*
|
2024-09-11 14:39:39 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2018-08-03 21:22:36 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-08-03 21:22:36 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2018-08-03 21:22:36 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __NET_NETLINK_NETLINK_H
|
|
|
|
#define __NET_NETLINK_NETLINK_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2019-11-28 04:30:01 +01:00
|
|
|
#include <poll.h>
|
2018-08-03 21:22:36 +02:00
|
|
|
|
2019-11-03 20:59:42 +01:00
|
|
|
#include <netpacket/netlink.h>
|
2022-09-25 17:08:38 +02:00
|
|
|
#include <nuttx/queue.h>
|
2024-04-19 10:47:34 +02:00
|
|
|
#include <nuttx/net/icmpv6.h>
|
2019-11-19 04:12:50 +01:00
|
|
|
#include <nuttx/net/netlink.h>
|
2020-02-01 08:17:32 +01:00
|
|
|
#include <nuttx/semaphore.h>
|
2021-07-01 12:49:03 +02:00
|
|
|
#include <nuttx/wqueue.h>
|
2019-11-03 20:59:42 +01:00
|
|
|
|
2018-08-03 21:22:36 +02:00
|
|
|
#include "devif/devif.h"
|
|
|
|
#include "socket/socket.h"
|
|
|
|
|
2020-04-13 10:10:30 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_NETLINK_ROUTE
|
2023-01-30 09:50:11 +01:00
|
|
|
# define netlink_device_notify(dev)
|
2023-10-19 09:04:23 +02:00
|
|
|
# define netlink_device_notify_ipaddr(dev, type, domain, addr, preflen)
|
2024-04-09 15:07:57 +02:00
|
|
|
# define netlink_route_notify(route, type, domain)
|
2024-04-16 11:19:33 +02:00
|
|
|
# define netlink_neigh_notify(neigh, type, domain)
|
2024-04-19 10:47:34 +02:00
|
|
|
# define netlink_ipv6_prefix_notify(dev, type, pinfo)
|
2020-04-13 10:10:30 +02:00
|
|
|
#endif
|
|
|
|
|
2018-08-03 21:22:36 +02:00
|
|
|
#ifdef CONFIG_NET_NETLINK
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nla_for_each_attr - iterate over a stream of attributes
|
|
|
|
* pos: loop counter, set to current attribute
|
|
|
|
* head: head of attribute stream
|
|
|
|
* len: length of attribute stream
|
|
|
|
* rem: initialized to len, holds bytes currently remaining in stream
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nla_for_each_attr(pos, head, len, rem) \
|
|
|
|
for (pos = head, rem = len; nla_ok(pos, rem); \
|
|
|
|
pos = nla_next(pos, &(rem)))
|
|
|
|
|
|
|
|
/* Always use this macro, this allows later putting the
|
|
|
|
* message into a separate section or such for things
|
|
|
|
* like translation or listing all possible messages.
|
|
|
|
* Currently string formatting is not supported (due
|
|
|
|
* to the lack of an output buffer.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define nl_set_err_msg_attr(extack, attr, msg) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
static const char __msg[] = (msg); \
|
|
|
|
FAR struct netlink_ext_ack *__extack = (extack); \
|
|
|
|
if (__extack) \
|
|
|
|
{ \
|
|
|
|
__extack->_msg = __msg; \
|
|
|
|
__extack->bad_attr = (attr); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nla_data - head of payload
|
|
|
|
* nla: netlink attribute
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nla_data(nla) ((FAR void *)((FAR char *)(nla) + NLA_HDRLEN))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nla_len - length of payload
|
|
|
|
* nla: netlink attribute
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nla_len(nla) ((nla)->nla_len - NLA_HDRLEN)
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nla_type - attribute type
|
|
|
|
* nla: netlink attribute
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nla_type(nla) ((nla)->nla_type & NLA_TYPE_MASK)
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nla_ok - check if the netlink attribute fits into the remaining bytes
|
|
|
|
* nla: netlink attribute
|
|
|
|
* remaining: number of bytes remaining in attribute stream
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nla_ok(nla, remaining) \
|
|
|
|
((remaining) >= sizeof(*(nla)) && \
|
|
|
|
(nla)->nla_len >= sizeof(*(nla)) && \
|
|
|
|
(nla)->nla_len <= (remaining))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nlmsg_msg_size - length of netlink message not including padding
|
|
|
|
* payload: length of message payload
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nlmsg_msg_size(payload) (NLMSG_HDRLEN + (payload))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nlmsg_len - length of message payload
|
|
|
|
* nlh: netlink message header
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nlmsg_len(nlh) ((nlh)->nlmsg_len - NLMSG_HDRLEN)
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nlmsg_attrlen - length of attributes data
|
|
|
|
* nlh: netlink message header
|
|
|
|
* hdrlen: length of family specific header
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nlmsg_attrlen(nlh, hdrlen) (nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nlmsg_data - head of message payload
|
|
|
|
* nlh: netlink message header
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nlmsg_data(nlh) ((FAR void *)((FAR char *)(nlh) + NLMSG_HDRLEN))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nla_get_in_addr - return payload of IPv4 address attribute
|
|
|
|
* nla: IPv4 address netlink attribute
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nla_get_in_addr(nla) (*(FAR uint32_t *)nla_data(nla))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nlmsg_attrdata - head of attributes data
|
|
|
|
* nlh: netlink message header
|
|
|
|
* hdrlen: length of family specific header
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define nlmsg_attrdata(nlh, hdrlen) \
|
|
|
|
((FAR struct nlattr *)((FAR char *)nlmsg_data(nlh) + NLMSG_ALIGN(hdrlen)))
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* nlmsg_parse - parse attributes of a netlink message
|
|
|
|
* nlh: netlink message header
|
|
|
|
* hdrlen: length of family specific header
|
|
|
|
* tb: destination array with maxtype+1 elements
|
|
|
|
* maxtype: maximum attribute type to be expected
|
|
|
|
* policy: validation policy
|
|
|
|
* extack: extended ACK report struct
|
2023-01-30 09:50:11 +01:00
|
|
|
*
|
|
|
|
* See nla_parse()
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define nlmsg_parse(nlh, hdrlen, tb, maxtype, policy, extack) \
|
|
|
|
((nlh)->nlmsg_len < nlmsg_msg_size(hdrlen) ? -EINVAL : \
|
|
|
|
nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen), \
|
|
|
|
nlmsg_attrlen(nlh, hdrlen), policy, extack))
|
|
|
|
|
|
|
|
/* this can be increased when necessary - don't expose to userland */
|
|
|
|
|
|
|
|
#define NETLINK_MAX_COOKIE_LEN 20
|
|
|
|
|
2018-08-03 21:22:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-04-10 15:03:34 +02:00
|
|
|
/* This connection structure describes the underlying state of the socket. */
|
2019-11-03 20:59:42 +01:00
|
|
|
|
2018-08-03 21:22:36 +02:00
|
|
|
struct netlink_conn_s
|
|
|
|
{
|
2019-09-01 16:47:01 +02:00
|
|
|
/* Common prologue of all connection structures. */
|
|
|
|
|
2022-02-07 04:17:44 +01:00
|
|
|
struct socket_conn_s sconn;
|
2018-08-03 21:22:36 +02:00
|
|
|
|
2019-11-04 21:06:07 +01:00
|
|
|
/* NetLink-specific content follows */
|
2018-08-03 21:22:36 +02:00
|
|
|
|
2019-11-03 20:59:42 +01:00
|
|
|
uint32_t pid; /* Port ID (if bound) */
|
|
|
|
uint32_t groups; /* Multicast groups mask (if bound) */
|
2020-04-07 20:31:57 +02:00
|
|
|
uint32_t dst_pid; /* Destination port ID */
|
|
|
|
uint32_t dst_groups; /* Destination multicast groups mask */
|
2019-09-01 16:47:01 +02:00
|
|
|
uint8_t crefs; /* Reference counts on this instance */
|
2019-11-03 20:59:42 +01:00
|
|
|
|
2019-11-28 04:30:01 +01:00
|
|
|
/* poll() support */
|
|
|
|
|
2019-11-28 21:20:40 +01:00
|
|
|
int key; /* used to cancel notifications */
|
2022-09-19 05:08:57 +02:00
|
|
|
FAR struct pollfd *fds; /* Used to wakeup poll() */
|
2019-11-18 16:48:14 +01:00
|
|
|
|
|
|
|
/* Queued response data */
|
2019-11-03 20:59:42 +01:00
|
|
|
|
2020-04-07 19:44:23 +02:00
|
|
|
sq_queue_t resplist; /* Singly linked list of responses */
|
2018-08-03 21:22:36 +02:00
|
|
|
};
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* Standard attribute types to specify validation policy */
|
2023-01-30 09:50:11 +01:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NLA_UNSPEC,
|
|
|
|
NLA_U8,
|
|
|
|
NLA_U16,
|
|
|
|
NLA_U32,
|
|
|
|
NLA_U64,
|
|
|
|
NLA_STRING,
|
|
|
|
NLA_FLAG,
|
|
|
|
NLA_MSECS,
|
|
|
|
NLA_NESTED,
|
|
|
|
NLA_NESTED_COMPAT,
|
|
|
|
NLA_NUL_STRING,
|
|
|
|
NLA_BINARY,
|
|
|
|
NLA_S8,
|
|
|
|
NLA_S16,
|
|
|
|
NLA_S32,
|
|
|
|
NLA_S64,
|
|
|
|
NLA_BITFIELD32,
|
|
|
|
NLA_TYPE_MAX = NLA_BITFIELD32,
|
|
|
|
};
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* struct netlink_ext_ack - netlink extended ACK report struct
|
|
|
|
* _msg: message string to report - don't access directly, use
|
|
|
|
* nl_set_err_msg_attr
|
|
|
|
* bad_attr: attribute with error
|
|
|
|
* cookie: cookie data to return to userspace (for success)
|
|
|
|
* cookie_len: actual cookie data length
|
2023-01-30 09:50:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct netlink_ext_ack
|
|
|
|
{
|
|
|
|
FAR const char *_msg;
|
|
|
|
FAR const struct nlattr *bad_attr;
|
|
|
|
uint8_t cookie[NETLINK_MAX_COOKIE_LEN];
|
|
|
|
uint8_t cookie_len;
|
|
|
|
};
|
|
|
|
|
2023-12-10 03:53:03 +01:00
|
|
|
/* struct nla_policy - attribute validation policy
|
|
|
|
* type: Type of attribute or NLA_UNSPEC
|
|
|
|
* len: Type specific length of payload
|
2023-01-30 09:50:11 +01:00
|
|
|
*
|
|
|
|
* Policies are defined as arrays of this struct, the array must be
|
|
|
|
* accessible by attribute type up to the highest identifier to be expected.
|
|
|
|
*
|
|
|
|
* Meaning of `len' field:
|
|
|
|
* NLA_STRING Maximum length of string
|
|
|
|
* NLA_NUL_STRING Maximum length of string (excluding NUL)
|
|
|
|
* NLA_FLAG Unused
|
|
|
|
* NLA_BINARY Maximum length of attribute payload
|
|
|
|
* NLA_NESTED Don't use `len' field -- length verification is
|
|
|
|
* done by checking len of nested header (or empty)
|
|
|
|
* NLA_NESTED_COMPAT Minimum length of structure payload
|
|
|
|
* NLA_U8, NLA_U16,
|
|
|
|
* NLA_U32, NLA_U64,
|
|
|
|
* NLA_S8, NLA_S16,
|
|
|
|
* NLA_S32, NLA_S64,
|
|
|
|
* NLA_MSECS Leaving the length field zero will verify the
|
|
|
|
* given type fits, using it verifies minimum length
|
|
|
|
* just like "All other"
|
|
|
|
* NLA_BITFIELD32 A 32-bit bitmap/bitselector attribute
|
|
|
|
* All other Minimum length of attribute payload
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* static const struct nla_policy my_policy[ATTR_MAX + 1] = {
|
|
|
|
* [ATTR_FOO] = { .type = NLA_U16 },
|
|
|
|
* [ATTR_BAR] = { .type = NLA_STRING, .len = BARSIZ },
|
|
|
|
* [ATTR_BAZ] = { .len = sizeof(struct mystruct) },
|
|
|
|
* [ATTR_GOO] = { .type = NLA_BITFIELD32, .validation_data =
|
|
|
|
* &myvalidflags },
|
|
|
|
* };
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct nla_policy
|
|
|
|
{
|
|
|
|
uint16_t type;
|
|
|
|
uint16_t len;
|
|
|
|
FAR void *validation_data;
|
|
|
|
};
|
|
|
|
|
2018-08-03 21:22:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
# define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
# define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXTERN const struct sock_intf_s g_netlink_sockif;
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_initialize()
|
|
|
|
*
|
|
|
|
* Description:
|
2018-10-31 21:10:19 +01:00
|
|
|
* Initialize the NetLink connection structures. Called once and only
|
2018-08-03 21:22:36 +02:00
|
|
|
* from the networking layer.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void netlink_initialize(void);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_alloc()
|
|
|
|
*
|
|
|
|
* Description:
|
2019-11-04 21:06:07 +01:00
|
|
|
* Allocate a new, uninitialized NetLink connection structure. This is
|
2018-08-03 21:22:36 +02:00
|
|
|
* normally something done by the implementation of the socket() API
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct netlink_conn_s *netlink_alloc(void);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_free()
|
|
|
|
*
|
|
|
|
* Description:
|
2020-04-10 15:03:34 +02:00
|
|
|
* Free a NetLink connection structure that is no longer in use. This
|
|
|
|
* should be done by the implementation of close().
|
2018-08-03 21:22:36 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void netlink_free(FAR struct netlink_conn_s *conn);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_nextconn()
|
|
|
|
*
|
|
|
|
* Description:
|
2019-11-04 21:06:07 +01:00
|
|
|
* Traverse the list of allocated NetLink connections
|
2018-08-03 21:22:36 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2019-11-04 21:06:07 +01:00
|
|
|
* This function is called from NetLink device logic.
|
2018-08-03 21:22:36 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct netlink_conn_s *netlink_nextconn(FAR struct netlink_conn_s *conn);
|
|
|
|
|
2019-11-28 21:20:40 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_notifier_setup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set up to perform a callback to the worker function the Netlink
|
|
|
|
* response data is received. The worker function will execute on the low
|
|
|
|
* priority worker thread.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* worker - The worker function to execute on the low priority work
|
|
|
|
* queue when Netlink response data is available.
|
|
|
|
* conn - The Netlink connection where the response is expected.
|
|
|
|
* arg - A user-defined argument that will be available to the worker
|
|
|
|
* function when it runs.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned if the notification was successfully set up.
|
|
|
|
* A negated error value is returned if an unexpected error occurred
|
|
|
|
* and no notification will occur.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int netlink_notifier_setup(worker_t worker, FAR struct netlink_conn_s *conn,
|
|
|
|
FAR void *arg);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_notifier_teardown
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Eliminate a Netlink response notification previously setup by
|
|
|
|
* netlink_notifier_setup(). This function should only be called if the
|
|
|
|
* notification should be aborted prior to the notification. The
|
|
|
|
* notification will automatically be torn down after the notification.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - Teardown the notification for this Netlink connection.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-05-13 12:24:38 +02:00
|
|
|
void netlink_notifier_teardown(FAR struct netlink_conn_s *conn);
|
2019-11-28 21:20:40 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_notifier_signal
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* New Netlink response data is available. Execute worker thread
|
|
|
|
* functions for all threads that wait for response data.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* conn - The Netlink connection where the response was just buffered.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void netlink_notifier_signal(FAR struct netlink_conn_s *conn);
|
|
|
|
|
2024-03-21 05:14:29 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_add_terminator
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add one NLMSG_DONE response to handle.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* handle - The handle previously provided to the sendto() implementation
|
|
|
|
* for the protocol. This is an opaque reference to the Netlink
|
|
|
|
* socket state structure.
|
|
|
|
* req - The request message header.
|
|
|
|
* group - The broadcast group index, 0 for normal response.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned if the terminator was successfully added to the
|
|
|
|
* response list.
|
|
|
|
* A negated error value is returned if an unexpected error occurred.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int netlink_add_terminator(NETLINK_HANDLE handle,
|
|
|
|
FAR const struct nlmsghdr *req, int group);
|
|
|
|
|
2019-11-18 16:48:14 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_tryget_response
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return the next response from the head of the pending response list.
|
|
|
|
* Responses are returned one-at-a-time in FIFO order.
|
|
|
|
*
|
|
|
|
* Note: The network will be momentarily locked to support exclusive
|
|
|
|
* access to the pending response list.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* The next response from the head of the pending response list is
|
|
|
|
* returned. NULL will be returned if the pending response list is
|
|
|
|
* empty
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct netlink_response_s *
|
2020-04-13 14:49:52 +02:00
|
|
|
netlink_tryget_response(FAR struct netlink_conn_s *conn);
|
2019-11-18 16:48:14 +01:00
|
|
|
|
2019-11-03 20:59:42 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_get_response
|
|
|
|
*
|
|
|
|
* Description:
|
2019-11-04 16:02:14 +01:00
|
|
|
* Return the next response from the head of the pending response list.
|
|
|
|
* Responses are returned one-at-a-time in FIFO order.
|
2019-11-03 20:59:42 +01:00
|
|
|
*
|
2019-11-18 16:48:14 +01:00
|
|
|
* Note: The network will be momentarily locked to support exclusive
|
|
|
|
* access to the pending response list.
|
|
|
|
*
|
2023-12-19 11:38:44 +01:00
|
|
|
* Input Parameters:
|
|
|
|
* conn - The Netlink connection
|
|
|
|
* response - The next response from the head of the pending response list
|
|
|
|
* is returned. This function will block until a response is
|
|
|
|
* received if the pending response list is empty. NULL will be
|
|
|
|
* returned only in the event of a failure.
|
|
|
|
*
|
2019-11-18 16:48:14 +01:00
|
|
|
* Returned Value:
|
2023-12-19 11:38:44 +01:00
|
|
|
* Zero (OK) is returned if the notification was successfully set up.
|
|
|
|
* A negated error value is returned if an unexpected error occurred
|
2019-11-03 20:59:42 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-12-19 11:38:44 +01:00
|
|
|
int netlink_get_response(FAR struct netlink_conn_s *conn,
|
|
|
|
FAR struct netlink_response_s **response);
|
2019-11-03 20:59:42 +01:00
|
|
|
|
2019-11-27 01:52:22 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_check_response
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return true is a response is pending now.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* True: A response is available; False; No response is available.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-04-13 14:49:52 +02:00
|
|
|
bool netlink_check_response(FAR struct netlink_conn_s *conn);
|
2019-11-27 01:52:22 +01:00
|
|
|
|
2019-11-03 20:59:42 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_route_sendto()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the sendto() operation for the NETLINK_ROUTE protocol.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NETLINK_ROUTE
|
2020-04-13 14:49:52 +02:00
|
|
|
ssize_t netlink_route_sendto(NETLINK_HANDLE handle,
|
2019-11-03 20:59:42 +01:00
|
|
|
FAR const struct nlmsghdr *nlmsg,
|
|
|
|
size_t len, int flags,
|
|
|
|
FAR const struct sockaddr_nl *to,
|
|
|
|
socklen_t tolen);
|
2020-04-13 10:10:30 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_device_notify()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the route broadcast for the NETLINK_ROUTE protocol.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void netlink_device_notify(FAR struct net_driver_s *dev);
|
2023-01-30 09:50:11 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_device_notify_ipaddr()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the route broadcast for the NETLINK_ROUTE protocol.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void netlink_device_notify_ipaddr(FAR struct net_driver_s *dev,
|
2023-10-19 09:04:23 +02:00
|
|
|
int type, int domain,
|
|
|
|
FAR const void *addr, uint8_t preflen);
|
2023-01-30 09:50:11 +01:00
|
|
|
|
2024-04-09 15:07:57 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_route_notify
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the route broadcast for the NETLINK_NETFILTER protocol.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* route - The route entry
|
|
|
|
* type - The type of the message, RTM_*ROUTE
|
|
|
|
* domain - The domain of the message
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined CONFIG_NETLINK_DISABLE_GETROUTE
|
|
|
|
# define netlink_route_notify(route, type, domain)
|
|
|
|
#else
|
|
|
|
void netlink_route_notify(FAR const void *route, int type, int domain);
|
|
|
|
#endif
|
|
|
|
|
2024-04-16 11:19:33 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_neigh_notify()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the neigh broadcast for the NETLINK_ROUTE protocol.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* neigh - The ARP entry or neighbour entry
|
|
|
|
* type - The type of the message, RTM_*NEIGH
|
|
|
|
* domain - The domain of the message
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_NETLINK_DISABLE_GETNEIGH)
|
|
|
|
# define netlink_neigh_notify(neigh, type, domain)
|
|
|
|
#else
|
|
|
|
void netlink_neigh_notify(FAR const void *neigh, int type, int domain);
|
|
|
|
#endif
|
|
|
|
|
2024-04-19 10:47:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_ipv6_prefix_notify()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the RA prefix for the NETLINK_ROUTE protocol.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2024-05-21 05:30:27 +02:00
|
|
|
#if defined(CONFIG_NETLINK_DISABLE_NEWPREFIX) || !defined(CONFIG_NET_IPv6)
|
2024-04-19 10:47:34 +02:00
|
|
|
# define netlink_ipv6_prefix_notify(dev, type, pinfo)
|
|
|
|
#else
|
|
|
|
void netlink_ipv6_prefix_notify(FAR struct net_driver_s *dev, int type,
|
|
|
|
FAR const struct icmpv6_prefixinfo_s *pinfo);
|
|
|
|
#endif
|
|
|
|
|
2023-01-30 09:50:11 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: nla_next
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Next netlink attribute in attribute stream.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* nla - netlink attribute.
|
|
|
|
* remaining - number of bytes remaining in attribute stream.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Returns the next netlink attribute in the attribute stream and
|
|
|
|
* decrements remaining by the size of the current attribute.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct nlattr *nla_next(FAR const struct nlattr *nla,
|
|
|
|
FAR int *remaining);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nla_parse
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Parse the nested netlink attribute.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int nla_parse(FAR struct nlattr **tb, int maxtype,
|
|
|
|
FAR const struct nlattr *head,
|
|
|
|
int len, FAR const struct nla_policy *policy,
|
|
|
|
FAR struct netlink_ext_ack *extack);
|
2024-03-20 04:22:24 +01:00
|
|
|
#endif /* CONFIG_NETLINK_ROUTE */
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_netfilter_sendto
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the sendto() operation for the NETLINK_NETFILTER protocol.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NETLINK_NETFILTER
|
|
|
|
ssize_t netlink_netfilter_sendto(NETLINK_HANDLE handle,
|
|
|
|
FAR const struct nlmsghdr *nlmsg,
|
|
|
|
size_t len, int flags,
|
|
|
|
FAR const struct sockaddr_nl *to,
|
|
|
|
socklen_t tolen);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netlink_conntrack_notify
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform the conntrack broadcast for the NETLINK_NETFILTER protocol.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* type - The type of the message, IPCTNL_MSG_CT_*
|
|
|
|
* domain - The domain of the message
|
|
|
|
* nat_entry - The NAT entry
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void netlink_conntrack_notify(uint8_t type, uint8_t domain,
|
|
|
|
FAR const void *nat_entry);
|
|
|
|
|
|
|
|
#endif /* CONFIG_NETLINK_NETFILTER */
|
2019-11-03 20:59:42 +01:00
|
|
|
|
2018-08-03 21:22:36 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET_NETLINK */
|
|
|
|
#endif /* __NET_NETLINK_NETLINK_H */
|