29 ast_assert(type != NULL);
34 static void message_destructor(
void *obj)
50 ast_log(LOG_ERROR,
"AEAP message %s: unable to create\n", type->
type_name);
64 ast_assert(type != NULL);
67 msg = message_create(type);
73 ast_log(LOG_ERROR,
"AEAP message %s: unable to construct1\n", type->
type_name);
82 const char *msg_type,
const char *name,
const char *
id,
const void *params)
86 ast_assert(type != NULL);
88 ast_assert(msg_type != NULL);
89 ast_assert(name != NULL);
91 msg = message_create(type);
96 if (type->
construct2(msg, msg_type, name,
id, params)) {
97 ast_log(LOG_ERROR,
"AEAP message %s: unable to construct2\n", type->
type_name);
106 const char *name,
const char *
id,
const void *params)
124 const char *name,
const char *
id,
const void *params)
130 const char *name,
const char *
id,
const char *error_msg)
148 const void *buf, intmax_t size)
152 ast_assert(type != NULL);
169 void **buf, intmax_t *size)
171 ast_assert(message != NULL);
172 ast_assert(message->
type != NULL);
179 const char *
id = NULL;
181 ast_assert(message != NULL);
182 ast_assert(message->
type != NULL);
185 id = message->
type->
id(message);
193 ast_assert(message != NULL);
194 ast_assert(message->
type != NULL);
201 char uuid_str[AST_UUID_STR_LEN];
204 if (strlen(uuid_str) != (AST_UUID_STR_LEN - 1)) {
205 ast_log(LOG_ERROR,
"AEAP message %s failed to generate UUID for message '%s'",
215 const char *name = NULL;
217 ast_assert(message != NULL);
218 ast_assert(message->
type != NULL);
221 name = message->
type->
name(message);
224 return name ? name :
"";
234 ast_assert(message != NULL);
235 ast_assert(message->
type != NULL);
242 ast_assert(message != NULL);
243 ast_assert(message->
type != NULL);
250 ast_assert(message != NULL);
251 ast_assert(message->
type != NULL);
258 ast_assert(message != NULL);
259 ast_assert(message->
type != NULL);
266 ast_assert(message != NULL);
267 ast_assert(message->
type != NULL);
enum AST_AEAP_DATA_TYPE ast_aeap_message_serial_type(const struct ast_aeap_message_type *type)
Retrieve the serial type a message type.
Asterisk External Application Protocol API.
Asterisk main include file. File version handling, generic pbx functions.
Asterisk External Application Protocol Message API.
int(* is_response)(const struct ast_aeap_message *self)
Retrieve whether or not this is a response message.
int ast_aeap_message_is_named(const struct ast_aeap_message *message, const char *name)
Check whether or not a message's name matches the given one.
void * ast_aeap_message_data(struct ast_aeap_message *message)
Retrieve the core message data/body.
int(* construct2)(struct ast_aeap_message *self, const char *msg_type, const char *name, const char *id, const void *params)
Construct/Initialize a message object.
int ast_aeap_message_error_msg_set(struct ast_aeap_message *message, const char *error_msg)
Set an error message.
void *(* data)(struct ast_aeap_message *self)
Retrieve the core message data/body.
Universally unique identifier support.
int(* construct1)(struct ast_aeap_message *self, const void *params)
Construct/Initialize a message object.
#define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg)
Allocate and initialize an object.
struct ast_aeap_message * ast_aeap_message_create1(const struct ast_aeap_message_type *type, const void *params)
Create an Asterisk external application message object.
const char * ast_aeap_message_id(const struct ast_aeap_message *message)
Retrieve a message id.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const char * ast_aeap_message_name(const struct ast_aeap_message *message)
Retrieve a message name.
int(* is_request)(const struct ast_aeap_message *self)
Retrieve whether or not this is a request message.
int ast_aeap_message_is_request(const struct ast_aeap_message *message)
Retrieve whether or not this is a request message.
int ast_aeap_message_serialize(const struct ast_aeap_message *message, void **buf, intmax_t *size)
Serialize the given message object into a byte/char buffer.
int ast_aeap_message_id_set(struct ast_aeap_message *message, const char *id)
Set a message id.
struct ast_aeap_message * ast_aeap_message_deserialize(const struct ast_aeap_message_type *type, const void *buf, intmax_t size)
Deserialize the given buffer into an Asterisk external application message object.
int(* error_msg_set)(struct ast_aeap_message *self, const char *error_msg)
Set an error message.
struct ast_aeap_message * ast_aeap_message_create_response(const struct ast_aeap_message_type *type, const char *name, const char *id, const void *params)
Create an Asterisk external application response object.
int(* deserialize)(struct ast_aeap_message *self, const void *buf, intmax_t size)
Deserialize the given buffer into a message object.
Asterisk external application base message.
enum AST_AEAP_DATA_TYPE serial_type
void(* destruct)(struct ast_aeap_message *self)
Destruct/Cleanup object resources.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
AST_AEAP_DATA_TYPE
Supported Asterisk external application data types.
Message type virtual method table.
struct ast_aeap_message * ast_aeap_message_create_error(const struct ast_aeap_message_type *type, const char *name, const char *id, const char *error_msg)
Create an Asterisk external application error response object.
const char *(* error_msg)(const struct ast_aeap_message *self)
Retrieve the error message if it has one.
const char *(* id)(const struct ast_aeap_message *self)
Retrieve a message id.
struct ast_aeap_message * ast_aeap_message_create2(const struct ast_aeap_message_type *type, const char *msg_type, const char *name, const char *id, const void *params)
Create an Asterisk external application message object.
const char * ast_aeap_message_id_generate(struct ast_aeap_message *message)
Generate an id, and set it for the message.
struct ast_aeap_message * ast_aeap_message_create_request(const struct ast_aeap_message_type *type, const char *name, const char *id, const void *params)
Create an Asterisk external application request object.
int(* id_set)(struct ast_aeap_message *self, const char *id)
Set a message id.
const struct ast_aeap_message_type * type
const char * ast_aeap_message_error_msg(const struct ast_aeap_message *message)
Retrieve the error message if it has one.
const char *(* name)(const struct ast_aeap_message *self)
Retrieve a message name.
int ast_aeap_message_is_response(const struct ast_aeap_message *message)
Retrieve whether or not this is a response message.
int(* serialize)(const struct ast_aeap_message *self, void **buf, intmax_t *size)
Serialize the message object into byte/char buffer.