updated API doc for socket.h
[strongswan.git] / src / charon / plugins / kernel_netlink / kernel_netlink_shared.h
1 /*
2 * Copyright (C) 2008 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 #ifndef KERNEL_NETLINK_SHARED_H_
19 #define KERNEL_NETLINK_SHARED_H_
20
21 #include <library.h>
22
23 #define NETLINK_BUFFER_SIZE 1024
24
25 typedef struct netlink_socket_t netlink_socket_t;
26
27 /**
28 * Wrapper around a netlink socket.
29 */
30 struct netlink_socket_t {
31
32 /**
33 * Send a netlink message and wait for a reply.
34 *
35 * @param in netlink message to send
36 * @param out received netlink message
37 * @param out_len length of the received message
38 */
39 status_t (*send)(netlink_socket_t *this, struct nlmsghdr *in, struct nlmsghdr **out, size_t *out_len);
40
41 /**
42 * Send a netlink message and wait for its acknowledge.
43 *
44 * @param in netlink message to send
45 */
46 status_t (*send_ack)(netlink_socket_t *this, struct nlmsghdr *in);
47
48 /**
49 * Destroy the socket.
50 */
51 void (*destroy)(netlink_socket_t *this);
52 };
53
54 /**
55 * Create a netlink_socket_t object.
56 *
57 * @param protocol protocol type (e.g. NETLINK_XFRM or NETLINK_ROUTE)
58 */
59 netlink_socket_t *netlink_socket_create(int protocol);
60
61 /**
62 * Creates an rtattr and adds it to the given netlink message.
63 *
64 * @param hdr netlink message
65 * @param rta_type type of the rtattr
66 * @param data data to add to the rtattr
67 * @param buflen length of the netlink message buffer
68 */
69 void netlink_add_attribute(struct nlmsghdr *hdr, int rta_type, chunk_t data, size_t buflen);
70
71 #endif /* KERNEL_NETLINK_SHARED_H_ */