libnl 3.5.0

socket.h
1 /*
2 * netlink/socket.h Netlink Socket
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-2008 Thomas Graf <tgraf@suug.ch>
10 */
11
12 #ifndef NETLINK_SOCKET_H_
13 #define NETLINK_SOCKET_H_
14
15 #include <netlink/types.h>
16 #include <netlink/handlers.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 extern struct nl_sock * nl_socket_alloc(void);
23 extern struct nl_sock * nl_socket_alloc_cb(struct nl_cb *);
24 extern void nl_socket_free(struct nl_sock *);
25
26 extern uint32_t nl_socket_get_local_port(const struct nl_sock *);
27 extern void nl_socket_set_local_port(struct nl_sock *, uint32_t);
28
29 extern int nl_socket_add_memberships(struct nl_sock *, int, ...);
30 extern int nl_socket_add_membership(struct nl_sock *, int);
31 extern int nl_socket_drop_memberships(struct nl_sock *, int, ...);
32 extern int nl_socket_drop_membership(struct nl_sock *,
33 int);
34 extern void nl_join_groups(struct nl_sock *, int);
35
36
37 extern uint32_t nl_socket_get_peer_port(const struct nl_sock *);
38 extern void nl_socket_set_peer_port(struct nl_sock *,
39 uint32_t);
40 extern uint32_t nl_socket_get_peer_groups(const struct nl_sock *sk);
41 extern void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups);
42 extern struct nl_cb * nl_socket_get_cb(const struct nl_sock *);
43 extern void nl_socket_set_cb(struct nl_sock *,
44 struct nl_cb *);
45 extern int nl_socket_modify_cb(struct nl_sock *, enum nl_cb_type,
46 enum nl_cb_kind,
47 nl_recvmsg_msg_cb_t, void *);
48 extern int nl_socket_modify_err_cb(struct nl_sock *, enum nl_cb_kind,
49 nl_recvmsg_err_cb_t, void *);
50
51 extern int nl_socket_set_buffer_size(struct nl_sock *, int, int);
52 extern int nl_socket_set_msg_buf_size(struct nl_sock *, size_t);
53 extern size_t nl_socket_get_msg_buf_size(struct nl_sock *);
54 extern int nl_socket_set_passcred(struct nl_sock *, int);
55 extern int nl_socket_recv_pktinfo(struct nl_sock *, int);
56
57 extern void nl_socket_disable_seq_check(struct nl_sock *);
58 extern unsigned int nl_socket_use_seq(struct nl_sock *);
59 extern void nl_socket_disable_auto_ack(struct nl_sock *);
60 extern void nl_socket_enable_auto_ack(struct nl_sock *);
61
62 extern int nl_socket_get_fd(const struct nl_sock *);
63 extern int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd);
64 extern int nl_socket_set_nonblocking(const struct nl_sock *);
65 extern void nl_socket_enable_msg_peek(struct nl_sock *);
66 extern void nl_socket_disable_msg_peek(struct nl_sock *);
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif
nl_socket_enable_auto_ack
void nl_socket_enable_auto_ack(struct nl_sock *)
Enable automatic request for ACK (default)
Definition: socket.c:325
nl_socket_set_passcred
int nl_socket_set_passcred(struct nl_sock *, int)
Enable/disable credential passing on netlink socket.
Definition: socket.c:895
nl_socket_drop_memberships
int nl_socket_drop_memberships(struct nl_sock *, int,...)
Leave groups.
Definition: socket.c:485
nl_socket_get_fd
int nl_socket_get_fd(const struct nl_sock *)
Return the file descriptor of the backing socket.
Definition: socket.c:584
nl_socket_disable_auto_ack
void nl_socket_disable_auto_ack(struct nl_sock *)
Disable automatic request for ACK.
Definition: socket.c:315
nl_socket_enable_msg_peek
void nl_socket_enable_msg_peek(struct nl_sock *)
Enable use of MSG_PEEK when reading from socket.
Definition: socket.c:723
nl_socket_set_local_port
void nl_socket_set_local_port(struct nl_sock *, uint32_t)
Set local port of socket.
Definition: socket.c:404
nl_socket_modify_err_cb
int nl_socket_modify_err_cb(struct nl_sock *, enum nl_cb_kind, nl_recvmsg_err_cb_t, void *)
Modify the error callback handler associated with the socket.
Definition: socket.c:787
nl_cb_kind
nl_cb_kind
Callback kinds.
Definition: handlers.h:75
nl_socket_alloc
struct nl_sock * nl_socket_alloc(void)
Allocate new netlink socket.
Definition: socket.c:206
nl_socket_modify_cb
int nl_socket_modify_cb(struct nl_sock *, enum nl_cb_type, enum nl_cb_kind, nl_recvmsg_msg_cb_t, void *)
Modify the callback handler associated with the socket.
Definition: socket.c:771
nl_socket_alloc_cb
struct nl_sock * nl_socket_alloc_cb(struct nl_cb *)
Allocate new socket with custom callbacks.
Definition: socket.c:232
nl_socket_disable_seq_check
void nl_socket_disable_seq_check(struct nl_sock *)
Disable sequence number checking.
Definition: socket.c:283
nl_socket_set_nonblocking
int nl_socket_set_nonblocking(const struct nl_sock *)
Set file descriptor of socket to non-blocking state.
Definition: socket.c:703
nl_recvmsg_err_cb_t
int(* nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla, struct nlmsgerr *nlerr, void *arg)
nl_recvmsgs() callback for error message processing customization
Definition: handlers.h:53
nl_socket_free
void nl_socket_free(struct nl_sock *)
Free a netlink socket.
Definition: socket.c:244
nl_socket_use_seq
unsigned int nl_socket_use_seq(struct nl_sock *)
Use next sequence number.
Definition: socket.c:298
nl_socket_disable_msg_peek
void nl_socket_disable_msg_peek(struct nl_sock *)
Disable use of MSG_PEEK when reading from socket.
Definition: socket.c:734
nl_recvmsg_msg_cb_t
int(* nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg)
nl_recvmsgs() callback for message processing customization
Definition: handlers.h:44
nl_socket_set_fd
int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd)
Set the socket file descriptor externally which initializes the socket similar to nl_connect().
Definition: socket.c:616
nl_socket_set_msg_buf_size
int nl_socket_set_msg_buf_size(struct nl_sock *, size_t)
Set default message buffer size of netlink socket.
Definition: socket.c:870
nl_cb_type
nl_cb_type
Callback types.
Definition: handlers.h:93
nl_socket_set_buffer_size
int nl_socket_set_buffer_size(struct nl_sock *, int, int)
Set socket buffer size of netlink socket.
Definition: socket.c:813
nl_join_groups
void nl_join_groups(struct nl_sock *, int)
Join multicast groups (deprecated)
Definition: socket.c:533
nl_socket_add_memberships
int nl_socket_add_memberships(struct nl_sock *, int,...)
Join groups.
Definition: socket.c:435
nl_socket_recv_pktinfo
int nl_socket_recv_pktinfo(struct nl_sock *, int)
Enable/disable receival of additional packet information.
Definition: socket.c:925
nl_socket_get_msg_buf_size
size_t nl_socket_get_msg_buf_size(struct nl_sock *)
Get default message buffer size of netlink socket.
Definition: socket.c:883