[asterisk-commits] jpeeler: branch jpeeler/asterisk-sigwork-trunk r205977 - /team/jpeeler/asteri...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 10 15:28:44 CDT 2009
Author: jpeeler
Date: Fri Jul 10 15:28:39 2009
New Revision: 205977
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=205977
Log:
Finish readding *0 support. Doing so required adding yet another callback, so I
consolidated about 7 or so existing callbacks into one with easy further
expansion. Will fully utilize the new generic callback next.
Modified:
team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h
Modified: team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c?view=diff&rev=205977&r1=205976&r2=205977
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c Fri Jul 10 15:28:39 2009
@@ -1525,6 +1525,30 @@
return index;
}
+static int analog_ioctl_to_dahdi_ioctl(enum analog_ioctl_operation op)
+{
+ switch (op) {
+ case ANALOG_ONHOOK:
+ return DAHDI_ONHOOK;
+ case ANALOG_OFFHOOK:
+ return DAHDI_OFFHOOK;
+ case ANALOG_WINK:
+ return DAHDI_WINK;
+ case ANALOG_FLASH:
+ return DAHDI_FLASH;
+ case ANALOG_START:
+ return DAHDI_START;
+ case ANALOG_RING:
+ return DAHDI_RING;
+ case ANALOG_GETEVENT:
+ return DAHDI_GETEVENT;
+ case ANALOG_DIALING:
+ return DAHDI_DIALING;
+ }
+
+ return -1;
+}
+
static enum analog_event dahdievent_to_analogevent(int event);
static int bump_gains(struct dahdi_pvt *p);
static int dahdi_setlinear(int dfd, int linear);
@@ -1863,14 +1887,10 @@
}
static int dahdi_wink(struct dahdi_pvt *p, int index);
-
static int my_wink(void *pvt, enum analog_sub sub)
{
struct dahdi_pvt *p = pvt;
int index = analogsub_to_dahdisub(sub);
- if (index != SUB_REAL) {
- ast_log(LOG_ERROR, "We used a sub other than SUB_REAL (incorrect assumption sir)\n");
- }
return dahdi_wink(p, index);
}
@@ -1980,6 +2000,49 @@
return p->sig_pvt;
else
return NULL;
+}
+
+static inline int dahdi_set_hook(int fd, int hs);
+static int dahdi_ring_phone(struct dahdi_pvt *p);
+
+static int my_ioctl_operation(void *pvt, enum analog_sub sub, enum analog_ioctl_operation op)
+{
+ int x;
+ struct dahdi_pvt *p = pvt;
+ int dahdi_sub = analogsub_to_dahdisub(sub);
+ int dahdi_op = analog_ioctl_to_dahdi_ioctl(op);
+
+ switch (dahdi_op) {
+ case DAHDI_ONHOOK:
+ return dahdi_set_hook(p->subs[dahdi_sub].dfd, DAHDI_ONHOOK);
+ case DAHDI_OFFHOOK:
+ return dahdi_set_hook(p->subs[dahdi_sub].dfd, DAHDI_OFFHOOK);
+ case DAHDI_WINK:
+ return dahdi_wink(p, dahdi_sub);
+ case DAHDI_FLASH:
+ x = DAHDI_FLASH;
+ return ioctl(p->subs[dahdi_sub].dfd, DAHDI_HOOK, &x);
+ case DAHDI_START:
+ x = DAHDI_START;
+ return ioctl(p->subs[dahdi_sub].dfd, DAHDI_HOOK, &x);
+ case DAHDI_RING:
+ return dahdi_ring_phone(p);
+ case DAHDI_GETEVENT:
+ if (p->fake_event) {
+ x = p->fake_event;
+ p->fake_event = 0;
+ } else
+ x = dahdi_get_event(p->subs[dahdi_sub].dfd);
+ return dahdievent_to_analogevent(x);
+ case DAHDI_DIALING:
+ if (ioctl(p->subs[dahdi_sub].dfd, DAHDI_DIALING, &x)) {
+ ast_log(LOG_DEBUG, "DAHDI_DIALING ioctl failed!\n");
+ return -1;
+ }
+ return x;
+ }
+
+ return -1;
}
static void my_increase_ss_count(void)
@@ -2342,16 +2405,12 @@
return 0;
}
-static int dahdi_ring_phone(struct dahdi_pvt *p);
-
static int my_ring(void *pvt)
{
struct dahdi_pvt *p = pvt;
return dahdi_ring_phone(p);
}
-
-static inline int dahdi_set_hook(int fd, int hs);
static int my_off_hook(void *pvt)
{
@@ -2626,6 +2685,7 @@
.set_linear_mode = my_set_linear_mode,
.get_and_handle_alarms = my_get_and_handle_alarms,
.get_sigpvt_bridged_channel = my_get_sigpvt_bridged_channel,
+ .ioctl_operation = my_ioctl_operation,
};
static struct dahdi_pvt *round_robin[32];
@@ -8125,6 +8185,9 @@
static int dahdi_wink(struct dahdi_pvt *p, int idx)
{
int j;
+ if (idx != SUB_REAL) {
+ ast_log(LOG_ERROR, "We used a sub other than SUB_REAL (incorrect assumption sir)\n");
+ }
dahdi_set_hook(p->subs[idx].dfd, DAHDI_WINK);
for (;;)
{
@@ -11034,6 +11097,7 @@
analog_p->usedistinctiveringdetection = conf->chan.usedistinctiveringdetection;
analog_p->ringt = conf->chan.ringt;
analog_p->ringt_base = ringt_base;
+ analog_p->chan_tech = &dahdi_tech;
ast_copy_string(analog_p->mohsuggest, conf->chan.mohsuggest, sizeof(analog_p->mohsuggest));
ast_copy_string(analog_p->cid_num, conf->chan.cid_num, sizeof(analog_p->cid_num));
Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c?view=diff&rev=205977&r1=205976&r2=205977
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c Fri Jul 10 15:28:39 2009
@@ -89,8 +89,8 @@
* way to do this in the dialplan now. */
};
-#define ISTRUNK(p) ((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \
- (p->sig == SIG_FXSGS))
+#define ISTRUNK(p) ((p->sig == ANALOG_SIG_FXSLS) || (p->sig == ANALOG_SIG_FXSKS) || \
+ (p->sig == ANALOG_SIG_FXSGS))
enum analog_sigtype analog_str_to_sigtype(const char *name)
{
@@ -1278,7 +1278,6 @@
return p->calls->get_and_handle_alarms(p->chan_pvt);
}
-#if 0
static void *analog_get_bridged_channel(struct analog_pvt *p, struct ast_channel *chan)
{
if (p->calls->get_sigpvt_bridged_channel)
@@ -1286,7 +1285,14 @@
else
return NULL;
}
-#endif
+
+static int analog_ioctl_operation(struct analog_pvt *p, enum analog_sub sub, enum analog_ioctl_operation op)
+{
+ if (p->calls->ioctl_operation)
+ return p->calls->ioctl_operation(p->chan_pvt, sub, op);
+ else
+ return -1;
+}
#define ANALOG_NEED_MFDETECT(p) (((p)->sig == ANALOG_SIG_FEATDMF) || ((p)->sig == ANALOG_SIG_FEATDMF_TA) || ((p)->sig == ANALOG_SIG_E911) || ((p)->sig == ANALOG_SIG_FGC_CAMA) || ((p)->sig == ANALOG_SIG_FGC_CAMAMF) || ((p)->sig == ANALOG_SIG_FEATB))
@@ -1808,21 +1814,19 @@
memset(exten, 0, sizeof(exten));
timeout = analog_firstdigittimeout;
} else if (!strcmp(exten, "*0")) {
-#if 0
struct ast_channel *nbridge = p->subs[ANALOG_SUB_THREEWAY].owner;
struct analog_pvt *pbridge = NULL;
/* set up the private struct of the bridged one, if any */
if (nbridge && ast_bridged_channel(nbridge))
pbridge = analog_get_bridged_channel(p, nbridge);
if (nbridge && pbridge &&
- (nbridge->tech == chan_tech) &&
- (ast_bridged_channel(nbridge)->tech == chan_tech) &&
+ (nbridge->tech == p->chan_tech) &&
+ (ast_bridged_channel(nbridge)->tech == p->chan_tech) &&
ISTRUNK(pbridge)) {
- int func = DAHDI_FLASH;
/* Clear out the dial buffer */
p->dop.dialstr[0] = '\0';
/* flash hookswitch */
- if ((ioctl(pbridge->subs[ANALOG_SUB_REAL].dfd,DAHDI_HOOK,&func) == -1) && (errno != EINPROGRESS)) {
+ if ((analog_ioctl_operation(pbridge, ANALOG_SUB_REAL, ANALOG_FLASH) == -1) && (errno != EINPROGRESS)) {
ast_log(LOG_WARNING, "Unable to flash external trunk on channel %s: %s\n",
nbridge->name, strerror(errno));
}
@@ -1843,7 +1847,6 @@
ast_hangup(chan);
goto quit;
}
-#endif
} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
((exten[0] != '*') || (strlen(exten) > 2))) {
ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h?view=diff&rev=205977&r1=205976&r2=205977
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h Fri Jul 10 15:28:39 2009
@@ -105,6 +105,18 @@
ANALOG_DIAL_OP_REPLACE = 2,
};
+/* list of "simple" operations on a dahdi fd for use with analog_ioctl_operation,
+ all operations here map directly to the defines found in DAHDI (user.h) */
+enum analog_ioctl_operation {
+ ANALOG_ONHOOK,
+ ANALOG_OFFHOOK,
+ ANALOG_WINK,
+ ANALOG_FLASH,
+ ANALOG_START,
+ ANALOG_RING,
+ ANALOG_GETEVENT,
+ ANALOG_DIALING,
+};
struct analog_dialoperation {
enum dialop op;
@@ -190,6 +202,7 @@
int (* const set_linear_mode)(void *pvt, int idx, int linear_mode);
void (* const get_and_handle_alarms)(void *pvt);
void * (* const get_sigpvt_bridged_channel)(struct ast_channel *chan);
+ int (* const ioctl_operation)(void *pvt, enum analog_sub sub, enum analog_ioctl_operation op);
};
@@ -233,6 +246,7 @@
unsigned int transfer:1;
unsigned int transfertobusy:1; /*!< allow flash-transfers to busy channels */
unsigned int use_callerid:1; /*!< Whether or not to use caller id on this channel */
+ const struct ast_channel_tech *chan_tech;
/*!
* \brief TRUE if distinctive rings are to be detected.
* \note For FXO lines
More information about the asterisk-commits
mailing list