libnl  3.6.0
netlink.h
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
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
int nl_send_iovec(struct nl_sock *, struct nl_msg *, struct iovec *, unsigned)
Transmit Netlink message (taking IO vector)
Definition: nl.c:367
int nl_send(struct nl_sock *, struct nl_msg *)
Transmit Netlink message.
Definition: nl.c:441
int nl_recv(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **)
Receive data from netlink socket.
Definition: nl.c:652
int nl_recvmsgs_default(struct nl_sock *)
Receive a set of message from a netlink socket using handlers in nl_sock.
Definition: nl.c:1087
int nl_send_auto(struct nl_sock *, struct nl_msg *)
Finalize and transmit Netlink message.
Definition: nl.c:510
void nl_complete_msg(struct nl_sock *, struct nl_msg *)
Finalize Netlink message.
Definition: nl.c:475
int nl_send_sync(struct nl_sock *, struct nl_msg *)
Finalize and transmit Netlink message and wait for ACK or error message.
Definition: nl.c:542
void nl_auto_complete(struct nl_sock *, struct nl_msg *)
Definition: nl.c:1233
int nl_connect(struct nl_sock *, int)
Create file descriptor and bind socket.
Definition: nl.c:97
int nl_recvmsgs_report(struct nl_sock *, struct nl_cb *)
Receive a set of messages from a netlink socket and report parsed messages.
Definition: nl.c:1046
int nl_pickup_keep_syserr(struct nl_sock *sk, int(*parser)(struct nl_cache_ops *, struct sockaddr_nl *, struct nlmsghdr *, struct nl_parser_param *), struct nl_object **result, int *syserror)
Pickup netlink answer, parse is and return object with preserving system error.
Definition: nl.c:1189
int nl_send_auto_complete(struct nl_sock *, struct nl_msg *)
Definition: nl.c:1241
int nl_recvmsgs(struct nl_sock *, struct nl_cb *)
Receive a set of messages from a netlink socket.
Definition: nl.c:1071
int nl_pickup(struct nl_sock *, int(*parser)(struct nl_cache_ops *, struct sockaddr_nl *, struct nlmsghdr *, struct nl_parser_param *), struct nl_object **)
Pickup netlink answer, parse is and return object.
Definition: nl.c:1172
void nl_close(struct nl_sock *)
Close Netlink socket.
Definition: nl.c:224
int nl_sendmsg(struct nl_sock *, struct nl_msg *, struct msghdr *)
Transmit Netlink message using sendmsg()
Definition: nl.c:321
int nl_sendto(struct nl_sock *, void *, size_t)
Transmit raw data over Netlink socket.
Definition: nl.c:264
int nl_wait_for_ack(struct nl_sock *)
Wait for ACK.
Definition: nl.c:1106
int nl_send_simple(struct nl_sock *, int, int, void *, size_t)
Construct and transmit a Netlink message.
Definition: nl.c:574
int nl_debug
Global variable indicating the desired level of debugging output.
Definition: utils.c:47
Dumping parameters.
Definition: types.h:28