1 /* 2 * nlsock.h - netlink socket 3 * 4 * Declarations of netlink socket structure and related functions. 5 */ 6 7 #ifndef ETHTOOL_NETLINK_NLSOCK_H__ 8 #define ETHTOOL_NETLINK_NLSOCK_H__ 9 10 #include <libmnl/libmnl.h> 11 #include <linux/netlink.h> 12 #include <linux/genetlink.h> 13 #include <linux/ethtool_netlink.h> 14 #include "msgbuff.h" 15 16 struct nl_context; 17 18 /** 19 * struct nl_socket - netlink socket abstraction 20 * @nlctx: netlink context 21 * @sk: libmnl socket handle 22 * @msgbuff: embedded message buffer used by default 23 * @port: port number for netlink header 24 * @seq: autoincremented sequence number for netlink header 25 * @nl_fam: netlink family (e.g. NETLINK_GENERIC or NETLINK_ROUTE) 26 */ 27 struct nl_socket { 28 struct nl_context *nlctx; 29 struct mnl_socket *sk; 30 struct nl_msg_buff msgbuff; 31 unsigned int port; 32 unsigned int seq; 33 int nl_fam; 34 }; 35 36 int nlsock_init(struct nl_context *nlctx, struct nl_socket **__nlsk, 37 int nl_fam); 38 void nlsock_done(struct nl_socket *nlsk); 39 int nlsock_prep_get_request(struct nl_socket *nlsk, unsigned int nlcmd, 40 uint16_t hdr_attrtype, u32 flags); 41 ssize_t nlsock_sendmsg(struct nl_socket *nlsk, struct nl_msg_buff *__msgbuff); 42 int nlsock_send_get_request(struct nl_socket *nlsk, mnl_cb_t cb); 43 int nlsock_process_reply(struct nl_socket *nlsk, mnl_cb_t reply_cb, void *data); 44 45 #endif /* ETHTOOL_NETLINK_NLSOCK_H__ */ 46