libnl  3.4.0
netlink.h
1 /*
2  * netlink/netlink.h Netlink Interface
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 #ifndef NETLINK_NETLINK_H_
13 #define NETLINK_NETLINK_H_
14 
15 #include <stdio.h>
16 #include <stdint.h>
17 #include <string.h>
18 #include <stdlib.h>
19 #include <poll.h>
20 #include <sys/socket.h>
21 #include <sys/types.h>
22 #include <sys/time.h>
23 #include <netdb.h>
24 #include <netlink/netlink-compat.h>
25 #include <linux/netlink.h>
26 #include <linux/rtnetlink.h>
27 #include <linux/genetlink.h>
28 #include <linux/netfilter/nfnetlink.h>
29 #include <netinet/tcp.h>
30 #include <netlink/version.h>
31 #include <netlink/errno.h>
32 #include <netlink/types.h>
33 #include <netlink/handlers.h>
34 #include <netlink/socket.h>
35 #include <netlink/object.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 struct nlmsghdr;
42 struct ucred;
43 struct nl_cache_ops;
44 struct nl_parser_param;
45 struct nl_object;
46 struct nl_sock;
47 
48 extern int nl_debug;
49 extern struct nl_dump_params nl_debug_dp;
50 
51 /* Connection Management */
52 extern int nl_connect(struct nl_sock *, int);
53 extern void nl_close(struct nl_sock *);
54 
55 /* Send */
56 extern int nl_sendto(struct nl_sock *, void *, size_t);
57 extern int nl_sendmsg(struct nl_sock *, struct nl_msg *,
58  struct msghdr *);
59 extern int nl_send(struct nl_sock *, struct nl_msg *);
60 extern int nl_send_iovec(struct nl_sock *, struct nl_msg *,
61  struct iovec *, unsigned);
62 extern void nl_complete_msg(struct nl_sock *,
63  struct nl_msg *);
64 extern void nl_auto_complete(struct nl_sock *,
65  struct nl_msg *);
66 extern int nl_send_auto(struct nl_sock *, struct nl_msg *);
67 extern int nl_send_auto_complete(struct nl_sock *,
68  struct nl_msg *);
69 extern int nl_send_sync(struct nl_sock *, struct nl_msg *);
70 extern int nl_send_simple(struct nl_sock *, int, int,
71  void *, size_t);
72 
73 /* Receive */
74 extern int nl_recv(struct nl_sock *,
75  struct sockaddr_nl *, unsigned char **,
76  struct ucred **);
77 
78 extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *);
79 extern int nl_recvmsgs_report(struct nl_sock *, struct nl_cb *);
80 
81 extern int nl_recvmsgs_default(struct nl_sock *);
82 
83 extern int nl_wait_for_ack(struct nl_sock *);
84 
85 extern int nl_pickup(struct nl_sock *,
86  int (*parser)(struct nl_cache_ops *,
87  struct sockaddr_nl *,
88  struct nlmsghdr *,
89  struct nl_parser_param *),
90  struct nl_object **);
91 extern int nl_pickup_keep_syserr(struct nl_sock *sk,
92  int (*parser)(struct nl_cache_ops *, struct sockaddr_nl *,
93  struct nlmsghdr *, struct nl_parser_param *),
94  struct nl_object **result,
95  int *syserror);
96 /* Netlink Family Translations */
97 extern char * nl_nlfamily2str(int, char *, size_t);
98 extern int nl_str2nlfamily(const char *);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif
int nl_send_auto_complete(struct nl_sock *, struct nl_msg *)
Definition: nl.c:1247
void nl_complete_msg(struct nl_sock *, struct nl_msg *)
Finalize Netlink message.
Definition: nl.c:481
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:548
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:1178
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:1195
int nl_recvmsgs(struct nl_sock *, struct nl_cb *)
Receive a set of messages from a netlink socket.
Definition: nl.c:1077
int nl_connect(struct nl_sock *, int)
Create file descriptor and bind socket.
Definition: nl.c:103
int nl_send_iovec(struct nl_sock *, struct nl_msg *, struct iovec *, unsigned)
Transmit Netlink message (taking IO vector)
Definition: nl.c:373
int nl_recvmsgs_default(struct nl_sock *)
Receive a set of message from a netlink socket using handlers in nl_sock.
Definition: nl.c:1093
int nl_send(struct nl_sock *, struct nl_msg *)
Transmit Netlink message.
Definition: nl.c:447
int nl_send_simple(struct nl_sock *, int, int, void *, size_t)
Construct and transmit a Netlink message.
Definition: nl.c:580
int nl_wait_for_ack(struct nl_sock *)
Wait for ACK.
Definition: nl.c:1112
void nl_close(struct nl_sock *)
Close Netlink socket.
Definition: nl.c:230
void nl_auto_complete(struct nl_sock *, struct nl_msg *)
Definition: nl.c:1239
Dumping parameters.
Definition: types.h:33
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:1052
int nl_sendto(struct nl_sock *, void *, size_t)
Transmit raw data over Netlink socket.
Definition: nl.c:270
int nl_send_auto(struct nl_sock *, struct nl_msg *)
Finalize and transmit Netlink message.
Definition: nl.c:516
int nl_recv(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **)
Receive data from netlink socket.
Definition: nl.c:658
int nl_debug
Global variable indicating the desired level of debugging output.
Definition: utils.c:53
int nl_sendmsg(struct nl_sock *, struct nl_msg *, struct msghdr *)
Transmit Netlink message using sendmsg()
Definition: nl.c:327