Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include "asterisk/utils.h"
#include "logger.h"
#include "transport.h"
#include "transport_websocket.h"
Go to the source code of this file.
Functions | |
int | aeap_transport_connect (struct aeap_transport *transport, const char *url, const char *protocol, int timeout) |
Connect a transport. More... | |
struct aeap_transport * | aeap_transport_create (const char *type) |
Create an Asterisk external application transport. More... | |
struct aeap_transport * | aeap_transport_create_and_connect (const char *type, const char *url, const char *protocol, int timeout) |
Create an Asterisk external application transport, and connect it. More... | |
void | aeap_transport_destroy (struct aeap_transport *transport) |
Destroy a transport. More... | |
int | aeap_transport_disconnect (struct aeap_transport *transport) |
Disconnect a transport. More... | |
int | aeap_transport_is_connected (struct aeap_transport *transport) |
Whether or not the transport is in a connected state. More... | |
intmax_t | aeap_transport_read (struct aeap_transport *transport, void *buf, intmax_t size, enum AST_AEAP_DATA_TYPE *rtype) |
Read data from the transport. More... | |
intmax_t | aeap_transport_write (struct aeap_transport *transport, const void *buf, intmax_t size, enum AST_AEAP_DATA_TYPE wtype) |
Write data to the transport. More... | |
int aeap_transport_connect | ( | struct aeap_transport * | transport, |
const char * | url, | ||
const char * | protocol, | ||
int | timeout | ||
) |
Connect a transport.
transport | The transport to connect |
url | The URL to connect to |
protocol | The connection protocol to use if applicable |
timeout | How long (in milliseconds) to attempt to connect (-1 equals infinite) |
Definition at line 48 of file transport.c.
References aeap_transport_is_connected(), aeap_transport_vtable::connect, aeap_transport::connected, aeap_transport::read_lock, SCOPED_MUTEX, url, aeap_transport::vtable, and aeap_transport::write_lock.
Referenced by aeap_transport_create_and_connect(), ast_aeap_connect(), and AST_TEST_DEFINE().
struct aeap_transport * aeap_transport_create | ( | const char * | type | ) |
Create an Asterisk external application transport.
type | The type of transport to create |
Definition at line 27 of file transport.c.
References aeap_transport_websocket_create(), ast_log, ast_mutex_init, aeap_transport::connected, LOG_ERROR, NULL, aeap_transport::read_lock, type, and aeap_transport::write_lock.
Referenced by aeap_transport_create_and_connect(), ast_aeap_create(), and AST_TEST_DEFINE().
struct aeap_transport * aeap_transport_create_and_connect | ( | const char * | type, |
const char * | url, | ||
const char * | protocol, | ||
int | timeout | ||
) |
Create an Asterisk external application transport, and connect it.
type | The type of transport to create |
url | The URL to connect to |
protocol | The connection protocol to use if applicable |
timeout | How long (in milliseconds) to attempt to connect (-1 equals infinite) |
Definition at line 68 of file transport.c.
References aeap_transport_connect(), aeap_transport_create(), aeap_transport_destroy(), NULL, type, and url.
Referenced by AST_TEST_DEFINE().
void aeap_transport_destroy | ( | struct aeap_transport * | transport | ) |
Destroy a transport.
transport | The transport to destroy |
Definition at line 117 of file transport.c.
References aeap_transport_disconnect(), ast_free, ast_mutex_destroy, aeap_transport_vtable::destroy, aeap_transport::read_lock, aeap_transport::vtable, and aeap_transport::write_lock.
Referenced by aeap_destructor(), aeap_transport_create_and_connect(), and AST_TEST_DEFINE().
int aeap_transport_disconnect | ( | struct aeap_transport * | transport | ) |
Disconnect a transport.
transport | The transport to disconnect |
Definition at line 94 of file transport.c.
References aeap_transport_is_connected(), ast_atomic_fetch_sub, aeap_transport::connected, aeap_transport_vtable::disconnect, aeap_transport::read_lock, SCOPED_MUTEX, aeap_transport::vtable, and aeap_transport::write_lock.
Referenced by aeap_transport_destroy(), ast_aeap_disconnect(), AST_TEST_DEFINE(), websocket_read(), and websocket_write().
int aeap_transport_is_connected | ( | struct aeap_transport * | transport | ) |
Whether or not the transport is in a connected state.
transport | The transport object |
Definition at line 85 of file transport.c.
References ast_atomic_fetch_add, and aeap_transport::connected.
Referenced by aeap_receive(), aeap_transport_connect(), aeap_transport_disconnect(), aeap_transport_read(), aeap_transport_write(), ast_aeap_connect(), and AST_TEST_DEFINE().
intmax_t aeap_transport_read | ( | struct aeap_transport * | transport, |
void * | buf, | ||
intmax_t | size, | ||
enum AST_AEAP_DATA_TYPE * | rtype | ||
) |
Read data from the transport.
This is a blocking read, and will not return until the transport implementation returns.
transport | The transport to read from |
buf | The buffer data is read into |
size | The size of data given data buffer |
rtype | [out] The type of data read |
Definition at line 134 of file transport.c.
References aeap_transport_is_connected(), buf, lock, aeap_transport_vtable::read, aeap_transport::read_lock, SCOPED_MUTEX, and aeap_transport::vtable.
Referenced by aeap_receive(), and AST_TEST_DEFINE().
intmax_t aeap_transport_write | ( | struct aeap_transport * | transport, |
const void * | buf, | ||
intmax_t | size, | ||
enum AST_AEAP_DATA_TYPE | wtype | ||
) |
Write data to the transport.
transport | The transport to write to |
buf | The data to write |
size | The size of data to write |
wtype | The type of data to write |
Definition at line 146 of file transport.c.
References aeap_transport_is_connected(), buf, lock, SCOPED_MUTEX, aeap_transport::vtable, aeap_transport_vtable::write, and aeap_transport::write_lock.
Referenced by aeap_send(), and AST_TEST_DEFINE().