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