summaryrefslogtreecommitdiffstats
path: root/lib/socket.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@redhat.com>2012-10-09 14:15:08 (GMT)
committerThomas Graf <tgraf@redhat.com>2012-10-09 14:16:54 (GMT)
commite4192ff97f3fccbe8347e88139aca9ba49af29ab (patch)
tree0d68cae2f3ba9c72f94ed7c2e0f404c80b247d66 /lib/socket.c
parent72c2cb9e299b0510ae76e90b0b4fcc040ab485c7 (diff)
downloadlibnl-e4192ff97f3fccbe8347e88139aca9ba49af29ab.zip
libnl-e4192ff97f3fccbe8347e88139aca9ba49af29ab.tar.gz
libnl-e4192ff97f3fccbe8347e88139aca9ba49af29ab.tar.bz2
nl: Provide API to specify the default buffer size when receiving netlink messages
New functions: nl_socket_set_msg_buf_size(sk, size) nl_socket_get_msg_buf_size(sk) Default remains getpagesize() Signed-off-by: Thomas Graf <tgraf@redhat.com>
Diffstat (limited to 'lib/socket.c')
-rw-r--r--lib/socket.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/socket.c b/lib/socket.c
index 7e3ebf6..d53a714 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -587,6 +587,36 @@ int nl_socket_set_buffer_size(struct nl_sock *sk, int rxbuf, int txbuf)
}
/**
+ * Set default message buffer size of netlink socket.
+ * @arg sk Netlink socket.
+ * @arg bufsize Default message buffer size in bytes.
+ *
+ * Sets the default message buffer size to the specified length in bytes.
+ * The default message buffer size limits the maximum message size the
+ * socket will be able to receive. It is generally recommneded to specify
+ * a buffer size no less than the size of a memory page.
+ *
+ * @return 0 on success or a negative error code.
+ */
+int nl_socket_set_msg_buf_size(struct nl_sock *sk, size_t bufsize)
+{
+ sk->s_bufsize = bufsize;
+
+ return 0;
+}
+
+/**
+ * Get default message buffer size of netlink socket.
+ * @arg sk Netlink socket.
+ *
+ * @return Size of default message buffer.
+ */
+size_t nl_socket_get_msg_buf_size(struct nl_sock *sk)
+{
+ return sk->s_bufsize;
+}
+
+/**
* Enable/disable credential passing on netlink socket.
* @arg sk Netlink socket.
* @arg state New state (0 - disabled, 1 - enabled)