1 /* SPDX-License-Identifier: LGPL-2.1-only */ 2 /* 3 * Copyright (c) 2003-2013 Thomas Graf <[email protected]> 4 */ 5 6 #ifndef NETLINK_NETLINK_H_ 7 #define NETLINK_NETLINK_H_ 8 9 #include <stdio.h> 10 #include <stdint.h> 11 #include <string.h> 12 #include <stdlib.h> 13 #include <poll.h> 14 #include <sys/socket.h> 15 #include <sys/types.h> 16 #include <sys/time.h> 17 #include <netdb.h> 18 #include <netlink/netlink-compat.h> 19 #include <linux/netlink.h> 20 #include <linux/rtnetlink.h> 21 #include <linux/genetlink.h> 22 #include <linux/netfilter/nfnetlink.h> 23 #include <netinet/tcp.h> 24 #include <netlink/version.h> 25 #include <netlink/errno.h> 26 #include <netlink/types.h> 27 #include <netlink/handlers.h> 28 #include <netlink/socket.h> 29 #include <netlink/object.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 struct nlmsghdr; 36 struct ucred; 37 struct nl_cache_ops; 38 struct nl_parser_param; 39 struct nl_object; 40 struct nl_sock; 41 42 extern int nl_debug; 43 extern struct nl_dump_params nl_debug_dp; 44 45 /* Connection Management */ 46 extern int nl_connect(struct nl_sock *, int); 47 extern void nl_close(struct nl_sock *); 48 49 /* Send */ 50 extern int nl_sendto(struct nl_sock *, void *, size_t); 51 extern int nl_sendmsg(struct nl_sock *, struct nl_msg *, 52 struct msghdr *); 53 extern int nl_send(struct nl_sock *, struct nl_msg *); 54 extern int nl_send_iovec(struct nl_sock *, struct nl_msg *, 55 struct iovec *, unsigned); 56 extern void nl_complete_msg(struct nl_sock *, 57 struct nl_msg *); 58 extern void nl_auto_complete(struct nl_sock *, 59 struct nl_msg *); 60 extern int nl_send_auto(struct nl_sock *, struct nl_msg *); 61 extern int nl_send_auto_complete(struct nl_sock *, 62 struct nl_msg *); 63 extern int nl_send_sync(struct nl_sock *, struct nl_msg *); 64 extern int nl_send_simple(struct nl_sock *, int, int, 65 void *, size_t); 66 67 /* Receive */ 68 extern int nl_recv(struct nl_sock *, 69 struct sockaddr_nl *, unsigned char **, 70 struct ucred **); 71 72 extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *); 73 extern int nl_recvmsgs_report(struct nl_sock *, struct nl_cb *); 74 75 extern int nl_recvmsgs_default(struct nl_sock *); 76 77 extern int nl_wait_for_ack(struct nl_sock *); 78 79 extern int nl_pickup(struct nl_sock *, 80 int (*parser)(struct nl_cache_ops *, 81 struct sockaddr_nl *, 82 struct nlmsghdr *, 83 struct nl_parser_param *), 84 struct nl_object **); 85 extern int nl_pickup_keep_syserr(struct nl_sock *sk, 86 int (*parser)(struct nl_cache_ops *, struct sockaddr_nl *, 87 struct nlmsghdr *, struct nl_parser_param *), 88 struct nl_object **result, 89 int *syserror); 90 /* Netlink Family Translations */ 91 extern char * nl_nlfamily2str(int, char *, size_t); 92 extern int nl_str2nlfamily(const char *); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif 99