Newer
Older
* Asterisk -- An open source telephony toolkit.
* Copyright (C) 1999 - 2006, Digium, Inc.
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
*
* \brief Core PBX routines.
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
Kevin P. Fleming
committed
#include "asterisk/lock.h"
#include "asterisk/cli.h"
#include "asterisk/pbx.h"
#include "asterisk/channel.h"
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/file.h"
#include "asterisk/callerid.h"
#include "asterisk/cdr.h"
#include "asterisk/config.h"
#include "asterisk/term.h"
#include "asterisk/manager.h"
#include "asterisk/ast_expr.h"
#include "asterisk/linkedlists.h"
#define SAY_STUBS /* generate declarations and stubs for say methods */
Kevin P. Fleming
committed
#include "asterisk/say.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/musiconhold.h"
#include "asterisk/app.h"
Kevin P. Fleming
committed
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
*
* The speed of extension handling will likely be among the most important
* aspects of this PBX. The switching scheme as it exists right now isn't
* terribly bad (it's O(N+M), where N is the # of extensions and M is the avg #
* of priorities, but a constant search time here would be great ;-)
#ifdef LOW_MEMORY
#define EXT_DATA_SIZE 256
#else
#define EXT_DATA_SIZE 8192
#endif
#define SWITCH_DATA_LENGTH 256
#define VAR_NORMAL 1
#define VAR_SOFTTRAN 2
#define VAR_HARDTRAN 3
Mark Spencer
committed
#define BACKGROUND_SKIP (1 << 0)
#define BACKGROUND_NOANSWER (1 << 1)
Kevin P. Fleming
committed
#define BACKGROUND_MATCHEXTEN (1 << 2)
#define BACKGROUND_PLAYBACK (1 << 3)
Mark Spencer
committed
AST_APP_OPTIONS(background_opts, {
AST_APP_OPTION('s', BACKGROUND_SKIP),
AST_APP_OPTION('n', BACKGROUND_NOANSWER),
AST_APP_OPTION('m', BACKGROUND_MATCHEXTEN),
AST_APP_OPTION('p', BACKGROUND_PLAYBACK),
Mark Spencer
committed
});
#define WAITEXTEN_MOH (1 << 0)
AST_APP_OPTIONS(waitexten_opts, {
AST_APP_OPTION_ARG('m', WAITEXTEN_MOH, 1),
Mark Spencer
committed
});
The dialplan is saved as a linked list with each context
having it's own linked list of extensions - one item per
priority.
*/
char *exten; /*!< Extension name */
int matchcid; /*!< Match caller id ? */
Russell Bryant
committed
const char *cidmatch; /*!< Caller id to match for this extension */
Russell Bryant
committed
const char *label; /*!< Label */
struct ast_context *parent; /*!< The context this extension belongs to */
Russell Bryant
committed
const char *app; /*!< Application to execute */
void *data; /*!< Data to use (arguments) */
void (*datad)(void *); /*!< Data destructor */
struct ast_exten *peer; /*!< Next higher priority with our extension */
const char *registrar; /*!< Registrar */
struct ast_exten *next; /*!< Extension with a greater ID */
/*! \brief ast_include: include= support in extensions.conf */
Russell Bryant
committed
const char *rname; /*!< Context to include */
const char *registrar; /*!< Registrar */
int hastime; /*!< If time construct exists */
struct ast_timing timing; /*!< time construct */
struct ast_include *next; /*!< Link them together */
/*! \brief ast_sw: Switch statement in extensions.conf */
const char *registrar; /*!< Registrar */
char *data; /*!< Data load */
int eval;
AST_LIST_ENTRY(ast_sw) list;
char *tmpdata;
/*! \brief ast_ignorepat: Ignore patterns in dial plan */
const char *registrar;
Russell Bryant
committed
const char pattern[0];
/*! \brief ast_context: An extension context */
ast_mutex_t lock; /*!< A lock to prevent multiple threads from clobbering the context */
struct ast_exten *root; /*!< The root of the list of extensions */
struct ast_context *next; /*!< Link them together */
struct ast_include *includes; /*!< Include other contexts */
struct ast_ignorepat *ignorepats; /*!< Patterns for which to continue playing dialtone */
const char *registrar; /*!< Registrar */
AST_LIST_HEAD_NOLOCK(, ast_sw) alts; /*!< Alternative switches */
char name[0]; /*!< Name of the context */
/*! \brief ast_app: A registered application */
struct ast_app {
int (*execute)(struct ast_channel *chan, void *data);
const char *synopsis; /*!< Synopsis text for 'show applications' */
const char *description; /*!< Description (help text) for 'show application <name>' */
AST_LIST_ENTRY(ast_app) list; /*!< Next app in list */
struct module *module; /*!< Module this app belongs to */
/*! \brief ast_state_cb: An extension state notify register item */
struct ast_state_cb {
int id;
void *data;
ast_state_cb_type callback;
struct ast_state_cb *next;
/*! \brief Structure for dial plan hints
Hints are pointers from an extension in the dialplan to one or
more devices (tech/name) */
struct ast_hint {
struct ast_exten *exten; /*!< Extension */
int laststate; /*!< Last known state */
struct ast_state_cb *callbacks; /*!< Callback list for this extension */
Russell Bryant
committed
AST_LIST_ENTRY(ast_hint) list; /*!< Pointer to next hint in list */
Loading
Loading full blame...