4
* An implementation of Common ISDN API 2.0 for Asterisk
8
* Copyright (C) 2002, Junghanns.NET GmbH
10
* Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
12
* This program is free software and may be modified and
13
* distributed under the terms of the GNU Public License.
16
#include <asterisk/file.h>
17
#include <asterisk/logger.h>
18
#include <asterisk/channel.h>
19
#include <asterisk/channel_pvt.h>
20
#include <asterisk/pbx.h>
21
#include <asterisk/module.h>
28
#include <linux/capi.h>
30
#include "chan_capi_pvt.h"
31
#include "chan_capi_app.h"
35
static char *tdesc = "(CAPI*) RETRIEVE";
36
static char *app = "capiRETRIEVE";
37
static char *synopsis = "retrieve the call that is on hold";
43
static int capiRETRIEVE_exec(struct ast_channel *chan, void *data)
45
struct ast_capi_pvt *i = chan->pvt->pvt;
46
MESSAGE_EXCHANGE_ERROR Info;
47
_cmsg CMSG/*,*CMSG2*/;
53
/* Do our thing here */
55
// if ((i->state != CAPI_STATE_ONHOLD) || (i->onholdPLCI <= 0)) {
56
if (i->onholdPLCI <= 0) {
57
ast_log(LOG_WARNING, "no call on hold to retrieve!\n");
62
fac[1] = 0x03; // retrieve
66
FACILITY_REQ_HEADER(&CMSG,ast_capi_ApplID,ast_capi_MessageNumber++,0);
67
FACILITY_REQ_PLCI(&CMSG) = i->onholdPLCI;
68
FACILITY_REQ_FACILITYSELECTOR(&CMSG) = 0x0003; // sservices
69
FACILITY_REQ_FACILITYREQUESTPARAMETER(&CMSG) = (char *)&fac;
71
if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
72
ast_log(LOG_ERROR,"Error sending FACILITY_REQ\n");
75
i->state = CAPI_STATE_RETRIEVING;
76
ast_log(LOG_NOTICE,"sent FACILITY_REQ PLCI = %#x\n",i->onholdPLCI);
79
while (i->state == CAPI_STATE_RETRIEVING) {
84
// send a CONNECT_B3_REQ
85
memset(&CMSG,0,sizeof(_cmsg));
86
CONNECT_B3_REQ_HEADER(&CMSG, ast_capi_ApplID, ast_capi_MessageNumber++,0);
87
CONNECT_B3_REQ_PLCI(&CMSG) = i->PLCI;
88
if ((Info = _capi_put_cmsg(&CMSG)) != 0) {
89
ast_log(LOG_ERROR,"error sending CONNECT_B3_REQ (error=%#x)\n",Info);
91
ast_log(LOG_NOTICE,"sent CONNECT_B3_REQ (PLCI=%#x)\n",i->PLCI);
94
while (i->state == CAPI_STATE_CONNECTED) {
97
ast_log(LOG_NOTICE,"retrieved PLCI = %#x\n",i->PLCI);
103
int unload_module(void)
105
STANDARD_HANGUP_LOCALUSERS;
106
return ast_unregister_application(app);
109
int load_module(void)
111
return ast_register_application(app, capiRETRIEVE_exec,synopsis,tdesc);
114
char *description(void)
122
STANDARD_USECOUNT(res);
128
return ASTERISK_GPL_KEY;