43 #include <sys/socket.h>
46 #include <netinet/in.h>
47 #include <arpa/inet.h>
48 #include <sys/signal.h>
203 static const char tdesc[] =
"Call Agent Proxy Channel";
204 static const char config[] =
"agents.conf";
206 static const char app[] =
"AgentLogin";
207 static const char app3[] =
"AgentMonitorOutgoing";
209 static char moh[80] =
"default";
211 #define AST_MAX_AGENT 80
212 #define AST_MAX_BUF 256
213 #define AST_MAX_FILENAME_LEN 256
216 #define PA_MAX_LEN 2048
218 #define DEFAULT_ACCEPTDTMF '#'
219 #define DEFAULT_ENDDTMF '*'
241 #define GETAGENTBYCALLERID "AGENTBYCALLERID"
282 #define DATA_EXPORT_AGENT(MEMBER) \
283 MEMBER(agent_pvt, autologoff, AST_DATA_INTEGER) \
284 MEMBER(agent_pvt, ackcall, AST_DATA_BOOLEAN) \
285 MEMBER(agent_pvt, deferlogoff, AST_DATA_BOOLEAN) \
286 MEMBER(agent_pvt, wrapuptime, AST_DATA_MILLISECONDS) \
287 MEMBER(agent_pvt, acknowledged, AST_DATA_BOOLEAN) \
288 MEMBER(agent_pvt, name, AST_DATA_STRING) \
289 MEMBER(agent_pvt, password, AST_DATA_PASSWORD) \
290 MEMBER(agent_pvt, acceptdtmf, AST_DATA_CHARACTER)
296 #define CHECK_FORMATS(ast, p) do { \
298 if (ast->nativeformats != p->chan->nativeformats) { \
299 char tmp1[256], tmp2[256]; \
300 ast_debug(1, "Native formats changing from '%s' to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast->nativeformats), ast_getformatname_multiple(tmp2, sizeof(tmp2), p->chan->nativeformats)); \
302 ast->nativeformats = p->chan->nativeformats; \
303 ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast->readformat), ast_getformatname_multiple(tmp2, sizeof(tmp2), ast->writeformat));\
304 ast_set_read_format(ast, ast->readformat); \
305 ast_set_write_format(ast, ast->writeformat); \
307 if (p->chan->readformat != ast->rawreadformat && !p->chan->generator) \
308 ast_set_read_format(p->chan, ast->rawreadformat); \
309 if (p->chan->writeformat != ast->rawwriteformat && !p->chan->generator) \
310 ast_set_write_format(p->chan, ast->rawwriteformat); \
318 #define CLEANUP(ast, p) do { \
321 for (x=0;x<AST_MAX_FDS;x++) {\
322 if (x != AST_TIMING_FD) \
323 ast_channel_set_fd(ast, x, p->chan->fds[x]); \
325 ast_channel_set_fd(ast, AST_AGENT_FD, p->chan->fds[AST_TIMING_FD]); \
351 .description =
tdesc,
400 if (owner != pvt->
owner) {
463 password =
args.password;
464 while (*password && *password < 33) password++;
468 while (*name && *name < 33) name++;
474 if (!strcmp(p->
agent, agt)) {
519 if (p->
lastdisc.tv_sec > (now.tv_sec + wrapuptime/1000)) {
520 p->
lastdisc.tv_sec = now.tv_sec + wrapuptime/1000;
582 snprintf(filename,
sizeof(filename),
"agent-%s-%s",p->
agent, ast->
uniqueid);
584 if ((pointer = strchr(filename,
'.')))
586 snprintf(tmp,
sizeof(tmp),
"%s%s", savecallsin, filename);
589 snprintf(tmp2,
sizeof(tmp2),
"%s%s.%s", urlprefix, filename, recordformatext);
612 int cur_time = time(NULL);
637 int howlong = cur_time - p->
start;
640 if (owner || p->
chan) {
721 if (recordagentcalls && f == &answer_frame)
762 ast_debug(1,
"Dropping one incompatible %s frame on '%s' to '%s'\n",
777 if (p->
owner != oldchan) {
852 ast_debug(3,
"Played beep, result '%d'\n", res);
855 ast_debug(3,
"Waited for stream, result '%d'\n", res);
862 ast_debug(3,
"Set read format, result '%d'\n", res);
869 ast_debug(3,
"Set write format, result '%d'\n", res);
879 if (recordagentcalls)
899 ast_log(
LOG_ERROR,
"whoa, you need a channel (0x%ld) with a tech_pvt (0x%ld) to get a base channel.\n", (
long)chan, (chan)?(
long)chan->
tech_pvt:(
long)NULL);
958 }
else if (p->
dead) {
993 ast_debug(5,
"agent_cont_sleep() returning %d\n", res);
1052 if (chan == p->
chan)
1054 else if (chan == bridge->
_bridge)
1058 ast_debug(1,
"Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->
name, bridge->
name, ret ? ret->
name :
"<none>");
1073 tmp =
ast_channel_alloc(0, state, 0, 0,
"", p->
chan ? p->
chan->
exten:
"", p->
chan ? p->
chan->
context:
"", linkedid, 0,
"Agent/P%s-%d", p->
agent, (
int)
ast_random() & 0xffff);
1075 tmp =
ast_channel_alloc(0, state, 0, 0,
"", p->
chan ? p->
chan->
exten:
"", p->
chan ? p->
chan->
context:
"", linkedid, 0,
"Agent/%s", p->
agent);
1118 const char *catname;
1119 const char *hasagent;
1130 ast_log(
LOG_NOTICE,
"No agent configuration found -- agent support disabled\n");
1151 strcpy(moh,
"default");
1153 recordagentcalls = 0;
1154 strcpy(recordformat,
"wav");
1155 strcpy(recordformatext,
"wav");
1156 urlprefix[0] =
'\0';
1157 savecallsin[0] =
'\0';
1163 if (!strcasecmp(v->
name,
"agent")) {
1165 }
else if (!strcasecmp(v->
name,
"group")) {
1167 }
else if (!strcasecmp(v->
name,
"autologoff")) {
1168 autologoff = atoi(v->
value);
1171 }
else if (!strcasecmp(v->
name,
"ackcall")) {
1175 }
else if (!strcasecmp(v->
name,
"endcall")) {
1177 }
else if (!strcasecmp(v->
name,
"acceptdtmf")) {
1178 acceptdtmf = *(v->
value);
1180 }
else if (!strcasecmp(v->
name,
"enddtmf")) {
1181 enddtmf = *(v->
value);
1182 }
else if (!strcasecmp(v->
name,
"wrapuptime")) {
1183 wrapuptime = atoi(v->
value);
1187 maxlogintries = atoi(v->
value);
1188 if (maxlogintries < 0)
1191 strcpy(agentgoodbye,v->
value);
1192 }
else if (!strcasecmp(v->
name,
"musiconhold")) {
1194 }
else if (!strcasecmp(v->
name,
"updatecdr")) {
1199 }
else if (!strcasecmp(v->
name,
"autologoffunavail")) {
1201 autologoffunavail = 1;
1203 autologoffunavail = 0;
1204 }
else if (!strcasecmp(v->
name,
"recordagentcalls")) {
1206 }
else if (!strcasecmp(v->
name,
"recordformat")) {
1208 if (!strcasecmp(v->
value,
"wav49"))
1209 strcpy(recordformatext,
"WAV");
1212 }
else if (!strcasecmp(v->
name,
"urlprefix")) {
1214 if (urlprefix[strlen(urlprefix) - 1] !=
'/')
1215 strncat(urlprefix,
"/",
sizeof(urlprefix) - strlen(urlprefix) - 1);
1216 }
else if (!strcasecmp(v->
name,
"savecallsin")) {
1217 if (v->
value[0] ==
'/')
1220 snprintf(savecallsin,
sizeof(savecallsin) - 2,
"/%s", v->
value);
1221 if (savecallsin[strlen(savecallsin) - 1] !=
'/')
1222 strncat(savecallsin,
"/",
sizeof(savecallsin) - strlen(savecallsin) - 1);
1223 }
else if (!strcasecmp(v->
name,
"custom_beep")) {
1232 if (strcasecmp(catname,
"general")) {
1234 if (
ast_true(hasagent) || (!hasagent && genhasagent)) {
1242 snprintf(tmp,
sizeof(tmp),
"%s,%s,%s", catname, secret,fullname);
1276 ast_debug(1,
"Checking availability of '%s'\n", newlyavailable->
agent);
1280 if (p == newlyavailable) {
1297 if (parent && chan) {
1298 if (newlyavailable->
ackcall) {
1304 ast_debug(3,
"Played beep, result '%d'\n", res);
1307 ast_debug(1,
"Waited for stream, result '%d'\n", res);
1322 ast_debug(1,
"Sneaky, parent disappeared in the mean time...\n");
1326 ast_debug(1,
"Ugh... Agent hung up at exactly the wrong time\n");
1338 ast_debug(1,
"Checking beep availability of '%s'\n", newlyavailable->
agent);
1342 if (p == newlyavailable) {
1347 ast_debug(1,
"Call '%s' looks like a would-be winner for agent '%s'\n", p->
owner->
name, newlyavailable->
agent);
1359 ast_debug(1,
"Played beep, result '%d'\n", res);
1362 ast_debug(1,
"Waited for stream, result '%d'\n", res);
1382 if ((s[0] ==
'@') && (sscanf(s + 1,
"%30d", &groupoff) == 1)) {
1383 groupmatch = (1 << groupoff);
1384 }
else if ((s[0] ==
':') && (sscanf(s + 1,
"%30d", &groupoff) == 1)) {
1385 groupmatch = (1 << groupoff);
1394 if (!p->
pending && ((groupmatch && (p->
group & groupmatch)) || !strcmp(data, p->
agent))) {
1416 if (!chan && waitforagent) {
1420 ast_debug(1,
"Creating place holder for '%s'\n", s);
1423 p->
group = groupmatch;
1431 ast_debug(1,
"Not creating place holder for '%s' since nobody logged in\n", s);
1445 ast_debug(1,
"Agent disconnected before we could connect the call\n");
1460 ast_debug(1,
"Agent disconnected while we were connecting the call\n");
1497 char idText[256] =
"";
1499 char *username = NULL;
1500 char *loginChan = NULL;
1501 char *talkingto = NULL;
1502 char *talkingtoChan = NULL;
1507 snprintf(idText,
sizeof(idText) ,
"ActionID: %s\r\n",
id);
1524 status =
"AGENT_UNKNOWN";
1528 if (owner && owner->
_bridge) {
1534 talkingtoChan =
"n/a";
1536 status =
"AGENT_ONCALL";
1539 talkingtoChan =
"n/a";
1540 status =
"AGENT_IDLE";
1545 talkingtoChan =
"n/a";
1546 status =
"AGENT_LOGGEDOFF";
1558 "LoggedInChan: %s\r\n"
1559 "LoggedInTime: %d\r\n"
1561 "TalkingToChan: %s\r\n"
1564 p->
agent, username, status, loginChan, (
int)p->
loginstart, talkingto, talkingtoChan, idText);
1581 if (!strcasecmp(p->
agent, agent)) {
1624 "Usage: agent logoff <channel> [soft]\n"
1625 " Sets an agent as no longer logged in.\n"
1626 " If 'soft' is specified, do not hangup existing calls.\n";
1634 if (a->
argc == 4 && strcasecmp(a->
argv[3],
"soft"))
1637 agent = a->
argv[2] + 6;
1640 ast_cli(a->
fd,
"Logging out %s\n", agent);
1682 int which = 0,
len = strlen(word);
1686 snprintf(name,
sizeof(name),
"Agent/%s", p->
agent);
1687 if (!strncasecmp(word, name,
len) && p->
loginstart && ++which > state) {
1693 }
else if (pos == 3 && state == 0)
1710 int online_agents = 0;
1711 int offline_agents = 0;
1717 "Usage: agent show\n"
1718 " Provides summary information on agents.\n";
1739 snprintf(username,
sizeof(username),
"(%s) ", p->
name);
1743 snprintf(location,
sizeof(location),
"logged in on %s", p->
chan->
name);
1747 strcpy(talkingto,
" is idle");
1751 strcpy(location,
"not logged in");
1752 talkingto[0] =
'\0';
1756 snprintf(music,
sizeof(music),
" (musiconhold is '%s')", p->
moh);
1758 username, location, talkingto, music);
1769 if ( !count_agents )
1770 ast_cli(a->
fd,
"No Agents are configured in %s\n",config);
1772 ast_cli(a->
fd,
"%d agents configured [%d online , %d offline]\n",count_agents, online_agents, offline_agents);
1787 int online_agents = 0;
1788 int agent_status = 0;
1792 e->
command =
"agent show online";
1794 "Usage: agent show online\n"
1795 " Provides a list of all online agents.\n";
1813 snprintf(username,
sizeof(username),
"(%s) ", p->
name);
1817 snprintf(location,
sizeof(location),
"logged in on %s", p->
chan->
name);
1821 strcpy(talkingto,
" is idle");
1833 snprintf(music,
sizeof(music),
" (musiconhold is '%s')", p->
moh);
1835 ast_cli(a->
fd,
"%-12.12s %s%s%s%s\n", p->
agent, username, location, talkingto, music);
1841 ast_cli(a->
fd,
"No Agents are configured in %s\n", config);
1843 ast_cli(a->
fd,
"%d agents online\n", online_agents);
1849 "Usage: agent logoff <channel> [soft]\n"
1850 " Sets an agent as no longer logged in.\n"
1851 " If 'soft' is specified, do not hangup existing calls.\n";
1885 const char *tmpoptions = NULL;
1886 int play_announcement = 1;
1903 if (max_login_tries < 0)
1904 max_login_tries = 0;
1906 ast_verb(3,
"Saw variable AGENTMAXLOGINTRIES=%s, setting max_login_tries to: %d on Channel '%s'.\n",tmpoptions,max_login_tries,chan->
name);
1914 ast_verb(3,
"Saw variable AGENTUPDATECDR=%s, setting update_cdr to: %d on Channel '%s'.\n",tmpoptions,update_cdr,chan->
name);
1919 ast_verb(3,
"Saw variable AGENTGOODBYE=%s, setting agent_goodbye to: %s on Channel '%s'.\n",tmpoptions,agent_goodbye,chan->
name);
1925 if (strchr(
args.options,
's')) {
1926 play_announcement = 0;
1938 while (!res && (max_login_tries==0 || tries < max_login_tries)) {
1953 errmsg =
"agent-incorrect";
1962 int unlock_channel = 1;
1966 if (!strcmp(p->
agent, user) &&
1977 ast_verb(3,
"Saw variable AGENTACKCALL=%s, setting ackcall to: %d for Agent '%s'.\n", tmpoptions, p->
ackcall, p->
agent);
1987 ast_verb(3,
"Saw variable AGENTAUTOLOGOFF=%s, setting autologff to: %d for Agent '%s'.\n", tmpoptions, p->
autologoff, p->
agent);
1997 ast_verb(3,
"Saw variable AGENTWRAPUPTIME=%s, setting wrapuptime to: %d for Agent '%s'.\n", tmpoptions, p->
wrapuptime, p->
agent);
2005 ast_verb(3,
"Saw variable AGENTACCEPTDTMF=%s, setting acceptdtmf to: %c for Agent '%s'.\n", tmpoptions, p->
acceptdtmf, p->
agent);
2011 ast_verb(3,
"Saw variable AGENTENDDTMF=%s, setting enddtmf to: %c for Agent '%s'.\n", tmpoptions, p->
enddtmf, p->
agent);
2034 if (!res && play_announcement == 1) {
2049 snprintf(agent,
sizeof(agent),
"Agent/%s", p->
agent);
2065 if (update_cdr && chan->
cdr)
2068 ast_verb(2,
"Agent '%s' logged in (format %s/%s)\n", p->
agent,
2088 ast_debug(1,
"Wrapup time for %s expired!\n", agent);
2150 "Logintime: %ld\r\n"
2170 errmsg =
"agent-alreadyon";
2175 if (unlock_channel) {
2181 if (!res && (max_login_tries==0 || tries < max_login_tries))
2201 int exitifnoagentid = 0;
2203 int changeoutgoing = 0;
2208 if (strchr(data,
'd'))
2209 exitifnoagentid = 1;
2210 if (strchr(data,
'n'))
2212 if (strchr(data,
'c'))
2226 if (!strcasecmp(p->
agent, tmp)) {
2237 ast_log(
LOG_WARNING,
"Couldn't find the global variable %s, so I can't figure out which agent (if it's an agent) is placing outgoing call.\n", agentvar);
2242 ast_log(
LOG_WARNING,
"There is no callerid on that call, so I can't figure out which agent (if it's an agent) is placing outgoing call.\n");
2245 if (exitifnoagentid)
2255 const char *device = data;
2258 if (device[0] ==
'@' || device[0] ==
':') {
2270 }
else if (p->
chan) {
2297 if (!strcmp(cur->
agent, agentid))
2325 args.item =
"status";
2335 if (!strcasecmp(
args.item,
"status")) {
2336 char *
status =
"LOGGEDOUT";
2338 status =
"LOGGEDIN";
2341 }
else if (!strcasecmp(
args.item,
"password"))
2343 else if (!strcasecmp(
args.item,
"name"))
2345 else if (!strcasecmp(
args.item,
"mohclass"))
2347 else if (!strcasecmp(
args.item,
"channel")) {
2352 tmp = strrchr(buf,
'-');
2356 }
else if (!strcasecmp(
args.item,
"fullchannel")) {
2362 }
else if (!strcasecmp(
args.item,
"exten")) {
2387 struct ast_data *data_agent, *data_channel, *data_talkingto;
2408 if (!data_channel) {
2420 if (!data_talkingto) {
2540 .nonoptreq =
"res_monitor,chan_local",
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
unsigned long long ast_group_t
union ast_frame_subclass subclass
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
static int agentmonitoroutgoing_exec(struct ast_channel *chan, const char *data)
Called by the AgentMonitorOutgoing application (from the dial plan).
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
char password[AST_MAX_AGENT]
#define AST_CLI_DEFINE(fn, txt,...)
static int read_agent_config(int reload)
char * str
Subscriber phone number (Malloced)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk locking-related definitions:
void astman_append(struct mansession *s, const char *fmt,...)
static int check_beep(struct agent_pvt *newlyavailable, int needlock)
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
The data tree to be returned by the callbacks and managed by functions local to this file...
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
struct ast_frame ast_null_frame
struct ast_party_caller caller
Channel Caller ID information.
static int agents_data_provider_get(const struct ast_data_search *search, struct ast_data *data_root)
const ast_string_field uniqueid
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
Weird function made for call transfers.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_test_flag(p, flag)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
char context[AST_MAX_CONTEXT]
static char * agent_logoff_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
#define ast_set_flag(p, flag)
#define DEADLOCK_AVOIDANCE(lock)
descriptor for a cli entry.
static struct ast_channel * agent_get_base_channel(struct ast_channel *chan)
return the channel or base channel if one exists. This function assumes the channel it is called on i...
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
#define DEFAULT_ACCEPTDTMF
void ast_verbose(const char *fmt,...)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
static int function_agent(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
This entries are for multiple registers.
Structure for variables, used for configurations and for channel variables.
static struct ast_custom_function agent_function
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static char recordformatext[AST_MAX_BUF]
static int agent_digit_begin(struct ast_channel *ast, char digit)
#define DATA_EXPORT_AGENT(MEMBER)
Configuration File Parser.
static char recordformat[AST_MAX_BUF]
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
static int agent_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
struct ast_data * ast_data_add_bool(struct ast_data *root, const char *childname, unsigned int boolean)
Add a boolean node type.
static struct agent_pvt * add_agent(const char *agent, int pending)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
#define ast_mutex_lock(a)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
#define ast_copy_flags(dest, src, flagz)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
I/O Management (derived from Cheops-NG)
ast_cond_t login_wait_cond
void ast_cli(int fd, const char *fmt,...)
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
void ast_monitor_setjoinfiles(struct ast_channel *chan, int turnon)
const ast_string_field linkedid
#define AST_DATA_ENTRY(__path, __handler)
int ast_unregister_application(const char *app)
Unregister an application.
#define GETAGENTBYCALLERID
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define ast_cond_signal(cond)
static int recordagentcalls
#define ast_verb(level,...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
static char urlprefix[AST_MAX_BUF]
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static struct ast_channel * agent_lock_owner(struct agent_pvt *pvt)
Locks the owning channel for a LOCKED pvt while obeying locking order. The pvt must enter this functi...
static int agent_hangup(struct ast_channel *ast)
static int __agent_start_monitoring(struct ast_channel *ast, struct agent_pvt *p, int needlock)
String fields in structures.
#define AST_MAX_FILENAME_LEN
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
pthread_cond_t ast_cond_t
struct ast_channel * chan
int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield)
Set CDR user field for channel (stored in CDR)
static char beep[AST_MAX_BUF]
struct ast_party_id id
Caller party ID.
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged)
Insert into an astdata tree, the channel structure.
#define AST_DATA_HANDLER_VERSION
The Data API structures version.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
static int load_module(void)
Initialize the Agents module. This function is being called by Asterisk when loading the module...
#define CHECK_FORMATS(ast, p)
General Asterisk PBX channel definitions.
#define ast_config_load(filename, flags)
Load a config file.
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
static struct ast_data_entry agents_data_providers[]
Data structure associated with a custom dialplan function.
Access Control of various sorts.
static int agent_sendtext(struct ast_channel *ast, const char *text)
struct ast_data * ast_data_add_node(struct ast_data *root, const char *childname)
Add a container child.
Scheduler Routines (derived from cheops)
#define ast_data_unregister(path)
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
long int ast_random(void)
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
static struct ast_channel * agent_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Part of the Asterisk PBX interface.
static int login_exec(struct ast_channel *chan, const char *data)
Log in agent application.
static char language[MAX_LANGUAGE]
int ast_monitor_start(struct ast_channel *chan, const char *format_spec, const char *fname_base, int need_lock, int stream_action)
Start monitoring a channel.
char channel[AST_MAX_EXTENSION]
struct ast_channel * _bridge
ast_group_t ast_get_group(const char *s)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
static const char config[]
#define ast_data_register_multiple(data_entries, entries)
ast_cond_t app_complete_cond
Structure to describe a channel "technology", ie a channel driver See for examples: ...
static char * complete_agent_logoff_cmd(const char *line, const char *word, int pos, int state)
Core PBX routines and definitions.
static char agentgoodbye[AST_MAX_FILENAME_LEN]
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
struct ast_channel * owner
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
static int agent_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
#define ast_data_add_structure(structure_name, root, structure)
The list of nodes with their search requirement.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
static int agent_logoff(const char *agent, int soft)
static const char pa_family[]
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_strdupa(s)
duplicate a string in memory from the stack
static int check_availability(struct agent_pvt *newlyavailable, int needlock)
static int action_agents(struct mansession *s, const struct message *m)
char * ast_getformatname(format_t format)
Get the name of a format.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
#define CLEANUP(ast, p)
Cleanup moves all the relevant FD's from the 2nd to the first, but retains things properly for a timi...
static int agent_devicestate(void *data)
Part of PBX channel interface.
Structure representing an agent.
void ast_data_remove_node(struct ast_data *root, struct ast_data *child)
Remove a node that was added using ast_data_add_.
char agent[AST_MAX_AGENT]
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
struct agent_pvt::@78 list
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_channel_state _state
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
static char * agents_show_online(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const ast_string_field name
static int agent_start_monitoring(struct ast_channel *ast, int needlock)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static char savecallsin[AST_MAX_BUF]
#define ast_cond_destroy(cond)
static struct ast_cli_entry cli_agents[]
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
struct ast_bridge * bridge
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static int autologoffunavail
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
#define AST_CAUSE_UNREGISTERED
static char * agents_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int agent_call(struct ast_channel *ast, char *dest, int timeout)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
static int agent_answer(struct ast_channel *ast)
structure to hold users read from users.conf
Structure used to handle boolean flags.
static int agent_cleanup(struct agent_pvt *p)
static int agent_cont_sleep(void *data)
static int agent_ack_sleep(struct agent_pvt *p)
static int agent_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
#define AST_FORMAT_SLINEAR
#define ast_channel_ref(c)
Increase channel reference count.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Standard Command Line Interface.
static int agent_write(struct ast_channel *ast, struct ast_frame *f)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static const char agent_logoff_usage[]
Data structure associated with a single frame of data.
#define AST_DATA_STRUCTURE(__struct, __name)
Internal Asterisk hangup causes.
static struct ast_channel * agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
static long count_agents(const char *const caller, const int core_id_exception)
#define AST_APP_ARG(name)
Define an application argument.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
struct ast_variable * next
int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int(*cond)(void *), void *data)
Wait for a specified amount of time, looking for hangups and a condition argument.
#define ast_mutex_init(pmutex)
#define ast_channel_trylock(chan)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define CONFIG_STATUS_FILEINVALID
static struct ast_channel * agent_new(struct agent_pvt *p, int state, const char *linkedid)
Create new agent channel.
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
struct ast_channel_monitor * monitor
#define ast_mutex_destroy(a)
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static force_inline int powerof(unsigned int d)
#define ASTERISK_GPL_KEY
The text the key() function should return.
static void agent_pvt_destroy(struct agent_pvt *doomed)
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
struct ast_data * ast_data_add_str(struct ast_data *root, const char *childname, const char *string)
Add a string node type.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
static struct agent_pvt * find_agent(char *agentid)
static snd_pcm_format_t format
union ast_frame::@172 data
static struct ast_frame * agent_read(struct ast_channel *ast)
struct ast_channel_tech * tech
Persistant data storage (akin to *doze registry)
static struct ast_data_handler agents_data_provider
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
unsigned char valid
TRUE if the number information is valid/present.
int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data)
Check the current generated node to know if it matches the search condition.
#define ast_custom_function_register(acf)
Register a custom function.
const ast_string_field language
uint32_t version
Structure version.
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
char exten[AST_MAX_EXTENSION]
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static int action_agent_logoff(struct mansession *s, const struct message *m)
Structure for mutex and tracking information.
static int unload_module(void)
The structure of the node handler.
static const char tdesc[]
int ast_manager_unregister(char *action)
Unregister a registered manager command.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static int update_cdr
queues.conf [general] option
#define CONFIG_STATUS_FILEUNCHANGED
#define ast_mutex_unlock(a)
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
struct ast_party_number number
Subscriber phone number.
static struct ast_channel_tech agent_tech
Channel interface description for PBX integration.