libnl 3.7.0
socket.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
4 */
5
6#ifndef NETLINK_SOCKET_H_
7#define NETLINK_SOCKET_H_
8
9#include <netlink/types.h>
10#include <netlink/handlers.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16extern struct nl_sock * nl_socket_alloc(void);
17extern struct nl_sock * nl_socket_alloc_cb(struct nl_cb *);
18extern void nl_socket_free(struct nl_sock *);
19
20extern uint32_t nl_socket_get_local_port(const struct nl_sock *);
21extern void nl_socket_set_local_port(struct nl_sock *, uint32_t);
22
23extern int nl_socket_add_memberships(struct nl_sock *, int, ...);
24extern int nl_socket_add_membership(struct nl_sock *, int);
25extern int nl_socket_drop_memberships(struct nl_sock *, int, ...);
26extern int nl_socket_drop_membership(struct nl_sock *,
27 int);
28extern void nl_join_groups(struct nl_sock *, int);
29
30
31extern uint32_t nl_socket_get_peer_port(const struct nl_sock *);
32extern void nl_socket_set_peer_port(struct nl_sock *,
33 uint32_t);
34extern uint32_t nl_socket_get_peer_groups(const struct nl_sock *sk);
35extern void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups);
36extern struct nl_cb * nl_socket_get_cb(const struct nl_sock *);
37extern void nl_socket_set_cb(struct nl_sock *,
38 struct nl_cb *);
39extern int nl_socket_modify_cb(struct nl_sock *, enum nl_cb_type,
40 enum nl_cb_kind,
41 nl_recvmsg_msg_cb_t, void *);
42extern int nl_socket_modify_err_cb(struct nl_sock *, enum nl_cb_kind,
43 nl_recvmsg_err_cb_t, void *);
44
45extern int nl_socket_set_buffer_size(struct nl_sock *, int, int);
46extern int nl_socket_set_msg_buf_size(struct nl_sock *, size_t);
47extern size_t nl_socket_get_msg_buf_size(struct nl_sock *);
48extern int nl_socket_set_passcred(struct nl_sock *, int);
49extern int nl_socket_recv_pktinfo(struct nl_sock *, int);
50
51extern void nl_socket_disable_seq_check(struct nl_sock *);
52extern unsigned int nl_socket_use_seq(struct nl_sock *);
53extern void nl_socket_disable_auto_ack(struct nl_sock *);
54extern void nl_socket_enable_auto_ack(struct nl_sock *);
55
56extern int nl_socket_get_fd(const struct nl_sock *);
57extern int nl_socket_set_fd(struct nl_sock *sk, int protocol, int fd);
58extern int nl_socket_set_nonblocking(const struct nl_sock *);
59extern void nl_socket_enable_msg_peek(struct nl_sock *);
60extern void nl_socket_disable_msg_peek(struct nl_sock *);
61
62#ifdef __cplusplus
63}
64#endif
65
66#endif
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:47
nl_cb_type
Callback types.
Definition: handlers.h:87
int(* nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg)
nl_recvmsgs() callback for message processing customization
Definition: handlers.h:38
nl_cb_kind
Callback kinds.
Definition: handlers.h:69
int nl_socket_get_fd(const struct nl_sock *)
Return the file descriptor of the backing socket.
Definition: socket.c:578
void nl_socket_set_local_port(struct nl_sock *, uint32_t)
Set local port of socket.
Definition: socket.c:398
void nl_socket_disable_auto_ack(struct nl_sock *)
Disable automatic request for ACK.
Definition: socket.c:309
size_t nl_socket_get_msg_buf_size(struct nl_sock *)
Get default message buffer size of netlink socket.
Definition: socket.c:877
int nl_socket_recv_pktinfo(struct nl_sock *, int)
Enable/disable receival of additional packet information.
Definition: socket.c:919
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:781
void nl_join_groups(struct nl_sock *, int)
Join multicast groups (deprecated)
Definition: socket.c:527
int nl_socket_set_passcred(struct nl_sock *, int)
Enable/disable credential passing on netlink socket.
Definition: socket.c:889
int nl_socket_add_memberships(struct nl_sock *, int,...)
Join groups.
Definition: socket.c:429
void nl_socket_disable_msg_peek(struct nl_sock *)
Disable use of MSG_PEEK when reading from socket.
Definition: socket.c:728
struct nl_sock * nl_socket_alloc(void)
Allocate new netlink socket.
Definition: socket.c:200
int nl_socket_set_msg_buf_size(struct nl_sock *, size_t)
Set default message buffer size of netlink socket.
Definition: socket.c:864
struct nl_sock * nl_socket_alloc_cb(struct nl_cb *)
Allocate new socket with custom callbacks.
Definition: socket.c:226
int nl_socket_set_nonblocking(const struct nl_sock *)
Set file descriptor of socket to non-blocking state.
Definition: socket.c:697
void nl_socket_enable_auto_ack(struct nl_sock *)
Enable automatic request for ACK (default)
Definition: socket.c:319
void nl_socket_enable_msg_peek(struct nl_sock *)
Enable use of MSG_PEEK when reading from socket.
Definition: socket.c:717
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:610
unsigned int nl_socket_use_seq(struct nl_sock *)
Use next sequence number.
Definition: socket.c:292
void nl_socket_disable_seq_check(struct nl_sock *)
Disable sequence number checking.
Definition: socket.c:277
int nl_socket_set_buffer_size(struct nl_sock *, int, int)
Set socket buffer size of netlink socket.
Definition: socket.c:807
void nl_socket_free(struct nl_sock *)
Free a netlink socket.
Definition: socket.c:238
int nl_socket_drop_memberships(struct nl_sock *, int,...)
Leave groups.
Definition: socket.c:479
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:765