mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-15 14:05:22 +08:00
89afe6ef89
mnlu_gen_socket_open opens a socket and configures it for use with a generic netlink family. As part of this process it sends a CTRL_CMD_GETFAMILY to get the ID for the family name requested. In addition to the family id, this command reports a few other useful values including the maximum attribute. The maximum attribute is useful in order to know whether a given attribute is supported and for knowing the necessary size to allocate for other operations such as policy dumping. Since we already have to issue a CTRL_CMD_GETFAMILY to get the id, we can also store the maximum attribute as well. Modify the callback functions to parse the maximum attribute NLA and store it in the mnlu_gen_socket structure. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: David Ahern <dsahern@kernel.org>
35 lines
1.2 KiB
C
35 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __MNL_UTILS_H__
|
|
#define __MNL_UTILS_H__ 1
|
|
|
|
struct mnlu_gen_socket {
|
|
struct mnl_socket *nl;
|
|
char *buf;
|
|
uint32_t family;
|
|
uint32_t maxattr;
|
|
unsigned int seq;
|
|
uint8_t version;
|
|
};
|
|
|
|
int mnlu_gen_socket_open(struct mnlu_gen_socket *nlg, const char *family_name,
|
|
uint8_t version);
|
|
void mnlu_gen_socket_close(struct mnlu_gen_socket *nlg);
|
|
struct nlmsghdr *
|
|
_mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
|
|
uint8_t cmd, uint16_t flags,
|
|
uint32_t id, uint8_t version);
|
|
struct nlmsghdr *mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
|
|
uint8_t cmd, uint16_t flags);
|
|
int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh,
|
|
mnl_cb_t data_cb, void *data);
|
|
|
|
struct mnl_socket *mnlu_socket_open(int bus);
|
|
struct nlmsghdr *mnlu_msg_prepare(void *buf, uint32_t nlmsg_type, uint16_t flags,
|
|
void *extra_header, size_t extra_header_size);
|
|
int mnlu_socket_recv_run(struct mnl_socket *nl, unsigned int seq, void *buf, size_t buf_size,
|
|
mnl_cb_t cb, void *data);
|
|
int mnlu_gen_socket_recv_run(struct mnlu_gen_socket *nlg, mnl_cb_t cb,
|
|
void *data);
|
|
|
|
#endif /* __MNL_UTILS_H__ */
|