6bdbb3da47b3aa8b64921b1ce2347b1c3d94203d
[libnl.git] / include / netlink / 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-2006 Thomas Graf <tgraf@suug.ch>
10  */
11
12 #ifndef NETLINK_H_
13 #define NETLINK_H_
14
15 #include <stdio.h>
16 #include <stdint.h>
17 #include <string.h>
18 #include <stdlib.h>
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <netlink/types.h>
22 #include <netlink/netlink-compat.h>
23 #include <netlink/netlink-kernel.h>
24 #include <netlink/rtnetlink-kernel.h>
25 #include <netlink/handlers.h>
26
27 extern int nl_debug;
28
29 struct nl_handle;
30
31 /* General */
32 extern struct nl_handle *       nl_handle_alloc(void);
33 extern struct nl_handle *       nl_handle_alloc_nondefault(enum nl_cb_kind);
34 extern void                     nl_handle_destroy(struct nl_handle *);
35 extern void                     nl_join_groups(struct nl_handle *, int);
36 extern void                     nl_disable_sequence_check(struct nl_handle *);
37
38 extern int                      nl_join_group(struct nl_handle *, int);
39 extern int                      nl_set_passcred(struct nl_handle *, int);
40
41 /* Access Functions */
42 extern pid_t                    nl_handle_get_pid(struct nl_handle *);
43 extern void                     nl_handle_set_pid(struct nl_handle *, pid_t);
44 extern pid_t                    nl_handle_get_peer_pid(struct nl_handle *);
45 extern void                     nl_handle_set_peer_pid(struct nl_handle *, pid_t);
46 extern int                      nl_handle_get_fd(struct nl_handle *);
47 extern struct sockaddr_nl *     nl_handle_get_local_addr(struct nl_handle *);
48 extern struct sockaddr_nl *     nl_handle_get_peer_addr(struct nl_handle *);
49 extern struct nl_cb *           nl_handle_get_cb(struct nl_handle *);
50
51 /* Connection Management */
52 extern int                      nl_connect(struct nl_handle *, int);
53 extern void                     nl_close(struct nl_handle *);
54
55 /* Send */
56 extern int                      nl_sendto(struct nl_handle *, void *, size_t);
57 extern int                      nl_sendmsg(struct nl_handle *, struct nl_msg *,
58                                            struct msghdr *);
59 extern int                      nl_send(struct nl_handle *, struct nl_msg *);
60 extern int                      nl_send_auto_complete(struct nl_handle *,
61                                                       struct nl_msg *);
62 extern int                      nl_send_simple(struct nl_handle *, int, int,
63                                                void *, size_t);
64
65 /* Receive */
66 extern int                      nl_recv(struct nl_handle *,
67                                         struct sockaddr_nl *, unsigned char **,
68                                         struct ucred **);
69
70 extern int                      nl_recvmsgs(struct nl_handle *, struct nl_cb *);
71 extern int                      nl_recvmsgs_def(struct nl_handle *);
72
73 extern int                      nl_wait_for_ack(struct nl_handle *);
74
75 /* Netlink Family Translations */
76 extern char *                   nl_nlfamily2str(int, char *, size_t);
77 extern int                      nl_str2nlfamily(const char *);
78
79 #endif