Annotation of embedaddon/strongswan/src/libcharon/plugins/vici/vici_socket.h, revision 1.1.1.2
1.1 misho 1: /*
2: * Copyright (C) 2014 Martin Willi
3: * Copyright (C) 2014 revosec AG
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:
16: /**
17: * @defgroup vici_socket vici_socket
18: * @{ @ingroup vici
19: */
20:
21: #ifndef VICI_SOCKET_H_
22: #define VICI_SOCKET_H_
23:
24: #include <library.h>
25:
26: /**
27: * Maximum size of a single message exchanged.
28: */
1.1.1.2 ! misho 29: #ifndef VICI_MESSAGE_SIZE_MAX
1.1 misho 30: #define VICI_MESSAGE_SIZE_MAX (512 * 1024)
1.1.1.2 ! misho 31: #endif
1.1 misho 32:
33: typedef struct vici_socket_t vici_socket_t;
34:
35: /**
36: * Callback function for dispatching inbound client messages.
37: *
38: * @param user user data, as passed during registration
39: * @param id unique client connection identifier
40: * @param data incoming message data
41: */
42: typedef void (*vici_inbound_cb_t)(void *user, u_int id, chunk_t data);
43:
44: /**
45: * Callback function invoked when new clients connect
46: *
47: * @param user user data, as passed during registration
48: * @param id unique client connection identifier
49: * @return client connection context
50: */
51: typedef void (*vici_connect_cb_t)(void *user, u_int id);
52:
53: /**
54: * Callback function invoked when connected clients disconnect
55: *
56: * @param user user data, as passed during registration
57: * @param id unique client connection identifier
58: */
59: typedef void (*vici_disconnect_cb_t)(void *user, u_int id);
60:
61: /**
62: * Vici socket, low level socket input/output handling.
63: *
64: * On the socket, we pass raw chunks having a 2 byte network order length
65: * prefix. The length field does not count the length header itself, and
66: * is not included in the data passed over this interface.
67: */
68: struct vici_socket_t {
69:
70: /**
71: * Send a message to a client identified by connection identifier.
72: *
73: * @param id unique client connection identifier
74: * @param data data to send to client, gets owned
75: */
76: void (*send)(vici_socket_t *this, u_int id, chunk_t data);
77:
78: /**
79: * Destroy socket.
80: */
81: void (*destroy)(vici_socket_t *this);
82: };
83:
84: /**
85: * Create a vici_socket instance.
86: *
87: * @param uri socket URI to listen on
88: * @param inbound inbound message callback
89: * @param connect connect callback
90: * @param disconnect disconnect callback
91: * @param user user data to pass to callbacks
92: */
93: vici_socket_t *vici_socket_create(char *uri, vici_inbound_cb_t inbound,
94: vici_connect_cb_t connect,
95: vici_disconnect_cb_t disconnect, void *user);
96:
97: #endif /** VICI_SOCKET_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>