185 if (!parkee_snapshot) {
198 const char *lot_name = pu->
lot->
name;
203 if (!parkee_snapshot) {
208 duration = now.tv_sec - pu->
start.tv_sec;
226 if (!parkee_string) {
233 if (!retriever_string) {
242 "ParkerDialString: %s\r\n" 244 "ParkingSpace: %u\r\n" 245 "ParkingTimeout: %lu\r\n" 246 "ParkingDuration: %lu\r\n",
286 if (!parked_call_string) {
319 if (!lot_container) {
320 ast_log(
LOG_ERROR,
"Failed to obtain parking lot list. Action canceled.\n");
343 if (!parked_call_string) {
380 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
429 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
433 if (!lot_container) {
434 ast_log(
LOG_ERROR,
"Failed to obtain parking lot list. Action canceled.\n");
456 chan, parkinglot,
NULL, 0, 0, timeout_override, 1);
458 if (!parking_bridge) {
480 if (timeout_override != -1) {
481 if (
ast_asprintf(&app_data,
"%s,t(%d)", parkinglot, timeout_override) == -1) {
496 if (!bridge_channel) {
527 int timeout_override = -1;
538 if (sscanf(timeout,
"%30d", &timeout_override) != 1 || timeout_override < 0) {
543 if (timeout_override) {
545 timeout_override =
MAX(1, timeout_override / 1000);
550 snprintf(buf,
sizeof(buf),
"Channel does not exist: %s", channel);
562 if (!parker_chan || strcmp(
ast_channel_name(parker_chan), timeout_channel)) {
565 if (!announce_channel) {
578 if (!
ast_strlen_zero(announce_channel) && strcmp(announce_channel, timeout_channel)) {
582 if (!announce_channel) {
641 char *event_type =
"";
646 event_type =
"ParkedCall";
649 event_type =
"ParkedCallTimeOut";
652 event_type =
"ParkedCallGiveUp";
655 event_type =
"UnParkedCall";
658 event_type =
"ParkedCallSwap";
666 if (!parked_call_string) {
667 ast_log(
LOG_ERROR,
"Failed to issue an AMI event of '%s' in response to a stasis message.\n", event_type);
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
static int manager_park(struct mansession *s, const struct message *m)
void astman_append(struct mansession *s, const char *fmt,...)
int load_parking_manager(void)
Register manager actions and setup subscriptions for stasis events.
Asterisk main include file. File version handling, generic pbx functions.
static char parkinglot[AST_MAX_CONTEXT]
static void parking_manager_enable_stasis(void)
static struct ast_parked_call_payload * parked_call_payload_from_failure(struct ast_channel *chan)
struct ast_parked_call_payload * ast_parked_call_payload_create(enum ast_parked_call_event_type event_type, struct ast_channel_snapshot *parkee_snapshot, const char *parker_dial_string, struct ast_channel_snapshot *retriever_snapshot, const char *parkinglot, unsigned int parkingspace, unsigned long int timeout, unsigned long int duration)
Constructor for parked_call_payload objects.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
static int manager_parking_status(struct mansession *s, const struct message *m)
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
struct ao2_container * parked_users
int ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
Have a bridge channel park a channel in the bridge.
static int manager_parking_lot_list(struct mansession *s, const struct message *m)
Structure representing a snapshot of channel state.
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
A parked call message payload.
enum ast_parked_call_event_type event_type
void publish_parked_call(struct parked_user *pu, enum ast_parked_call_event_type event_type)
Publish a stasis parked call message for a given parked user.
long unsigned int duration
struct ast_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate...
struct ao2_container * get_parking_lot_container(void)
Get a pointer to the parking lot container for purposes such as iteration.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
void publish_parked_call_failure(struct ast_channel *parkee)
Publish a stasis parked call message for the channel indicating failure to park.
static void manager_parking_status_single_lot(struct mansession *s, const struct message *m, const char *id_text, const char *lot_name)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Configuration File Parser.
struct ast_channel_snapshot * parkee
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
char * parker_dial_string
#define ast_channel_cleanup(c)
Cleanup a channel reference.
#define ao2_ref(o, delta)
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
static int manager_append_event_parking_lot_data_cb(void *obj, void *arg, void *data, int flags)
static void manager_park_bridged(struct mansession *s, const struct message *m, struct ast_channel *chan, struct ast_channel *parker_chan, const char *parkinglot, int timeout_override)
#define stasis_subscribe(topic, callback, data)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
Configuration option-handling.
Structure that contains information about a bridge.
static void parking_event_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features, int play_tone, const char *xfersound)
Add an arbitrary channel to a bridge.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static struct ast_str * manager_build_parked_call_string(const struct ast_parked_call_payload *payload)
Builds a manager string based on the contents of a parked call payload.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
unsigned int parkingspace
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
long unsigned int timeout
#define ao2_callback_data(container, flags, cb_fn, arg, data)
#define ao2_iterator_next(iter)
static struct ast_parked_call_payload * parked_call_payload_from_parked_user(struct parked_user *pu, enum ast_parked_call_event_type event_type)
#define ast_channel_unlock(chan)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
ast_parked_call_event_type
Defines the type of parked call message being published.
static void manager_park_unbridged(struct mansession *s, const struct message *m, struct ast_channel *chan, const char *parkinglot, int timeout_override)
void unload_parking_manager(void)
Unregister manager actions and remove subscriptions for stasis events.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
void ast_bridge_set_transfer_variables(struct ast_channel *chan, const char *value, int is_attended)
Set the relevant transfer variables for a single channel.
const ast_string_field name
const ast_string_field parkinglot
static struct stasis_subscription * parking_sub
subscription to the parking lot topic
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
struct stasis_topic * ast_parking_topic(void)
accessor for the parking stasis topic
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
const char * ast_channel_name(const struct ast_channel *chan)
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
struct stasis_forward * sub
const ast_string_field parker_dial_string
static void parking_manager_disable_stasis(void)
struct parking_lot * parking_lot_find_by_name(const char *lot_name)
Find a parking lot based on its name.
Call Parking Resource Internal API.
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
struct ast_channel_snapshot * retriever
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
static void manager_parking_status_all_lots(struct mansession *s, const struct message *m, const char *id_text)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
struct ast_channel_snapshot * retriever
struct ast_channel * chan
static void parked_call_message_response(struct ast_parked_call_payload *parked_call)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
struct ast_bridge * park_common_setup(struct ast_channel *parkee, struct ast_channel *parker, const char *lot_name, const char *comeback_override, int use_ringing, int randomize, int time_limit, int silence_announcements)
Setup a parked call on a parking bridge without needing to parse appdata.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int create_parked_subscription(struct ast_channel *chan, const char *parkee_uuid, int hangup_after)
Create a parking announcement subscription.
struct parking_lot_cfg * cfg
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.