2 * Copyright (C) 2013 Martin Willi
3 * Copyright (C) 2013 revosec AG
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>.
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
17 * @defgroup stream_manager stream_manager
21 #ifndef STREAM_MANAGER_H_
22 #define STREAM_MANAGER_H_
24 typedef struct stream_manager_t stream_manager_t
;
27 #include <networking/streams/stream_service.h>
30 * Manages client-server connections and services using stream_t backends.
32 struct stream_manager_t
{
35 * Create a client-server connection to a service.
37 * @param uri URI of service to connect to
38 * @return stream instance, NULL on error
40 stream_t
* (*connect
)(stream_manager_t
*this, char *uri
);
43 * Create a new service under an URI to accept() client connections.
45 * @param uri URI of service to provide
46 * @param backlog size of the backlog queue, as passed to listen()
47 * @return service, NULL on error
49 stream_service_t
* (*create_service
)(stream_manager_t
*this, char *uri
,
53 * Register a stream backend to the manager.
55 * @param prefix prefix of URIs to use the backend for
56 * @param create constructor function for the stream
58 void (*add_stream
)(stream_manager_t
*this, char *prefix
,
59 stream_constructor_t create
);
62 * Unregister stream backends from the manager.
64 * @param create constructor function passed to add_stream()
66 void (*remove_stream
)(stream_manager_t
*this, stream_constructor_t create
);
69 * Register a stream service backend to the manager.
71 * @param prefix prefix of URIs to use the backend for
72 * @param create constructor function for the stream service
74 void (*add_service
)(stream_manager_t
*this, char *prefix
,
75 stream_service_constructor_t create
);
78 * Unregister stream service backends from the manager.
80 * @param create constructor function passed to add_service()
82 void (*remove_service
)(stream_manager_t
*this,
83 stream_service_constructor_t create
);
86 * Destroy a stream_manager_t.
88 void (*destroy
)(stream_manager_t
*this);
92 * Create a stream_manager instance.
94 stream_manager_t
*stream_manager_create();
96 #endif /** STREAM_MANAGER_H_ @}*/