Fixed mbcico ISDN modem aftercall function

This commit is contained in:
Michiel Broek 2002-07-02 20:00:49 +00:00
parent f5132ca7a0
commit 2a01693438
6 changed files with 453 additions and 447 deletions

View File

@ -33,6 +33,8 @@ v0.35.02 22-Jun-2002
mbcico: mbcico:
Implemented nodes special outbound boxes. Implemented nodes special outbound boxes.
Corrected a problem with getting modem aftercall info for ISDN
modems.
mbout: mbout:
Implemented nodes special outbound boxes. Implemented nodes special outbound boxes.

View File

@ -94,7 +94,7 @@ int portopen(faddr *addr)
} }
} }
WriteError("No call method available"); WriteError("No call method available, maybe missing parameters");
return ST_PORTERR; return ST_PORTERR;
} }
@ -270,10 +270,17 @@ int call(faddr *addr)
closetcp(); closetcp();
} else { } else {
hangup(); hangup();
if (rc == 0)
aftercall();
localport(); localport();
closeport(); closeport();
if (strlen(modem.info)) {
/*
* If mode info string defined, open port again to get
* the aftercall information. Mostly used with ISDN.
*/
portopen(addr);
aftercall();
closeport();
}
} }
} else { } else {
IsDoing("NoCall"); IsDoing("NoCall");

View File

@ -44,8 +44,7 @@
char *tranphone(char *Phone) char *tranphone(char *Phone)
{ {
static char trp[21]; static char trp[21];
char buf[21]; char buf[21], *p;
char *p;
int ln, i, j; int ln, i, j;
if (Phone == NULL) if (Phone == NULL)
@ -150,14 +149,10 @@ void almhdl(int sig)
int expect_str(int, char *); int expect_str(int, int, char *);
int expect_str(int timeout, char *Phone) int expect_str(int timeout, int aftermode, char *Phone)
{ {
int matched = FALSE; int matched = FALSE, smatch = FALSE, ematch = FALSE, ioerror = FALSE, i, rc;
int smatch = FALSE;
int ematch = FALSE;
int ioerror = FALSE;
int i, rc;
char inbuf[256]; char inbuf[256];
unsigned char ch = '\0'; unsigned char ch = '\0';
int eol = FALSE; int eol = FALSE;
@ -190,6 +185,9 @@ int expect_str(int timeout, char *Phone)
} }
inbuf[i] = '\0'; inbuf[i] = '\0';
if (aftermode && strcmp(inbuf, (char *)"OK\r") && strcmp(inbuf, (char *)"\r"))
Syslog('+', "chat: rcv \"%s\"", printable(inbuf, 0));
else
Syslog('c', "chat: rcv \"%s\"", printable(inbuf, 0)); Syslog('c', "chat: rcv \"%s\"", printable(inbuf, 0));
for (i = 0; (i < 10) && !matched; i++) for (i = 0; (i < 10) && !matched; i++)
@ -241,12 +239,12 @@ int expect_str(int timeout, char *Phone)
* The phone number must be full international notation unless the \D * The phone number must be full international notation unless the \D
* macro is in the dial command. * macro is in the dial command.
*/ */
int chat(char *Send, int timeout, char *Phone) int chat(char *Send, int timeout, int aftermode, char *Phone)
{ {
int rc; int rc;
if ((rc = send_str(Send, Phone)) == 0) if ((rc = send_str(Send, Phone)) == 0)
rc = expect_str(timeout, Phone); rc = expect_str(timeout, aftermode, Phone);
return rc; return rc;
} }

View File

@ -1,8 +1,10 @@
#ifndef _CHAT_H #ifndef _CHAT_H
#define _CHAT_H #define _CHAT_H
/* $Id$ */
char *tranphone(char *); char *tranphone(char *);
int chat(char *, int, char *); int chat(char *, int, int, char *);
#endif #endif

View File

@ -60,7 +60,7 @@ int initmodem(void)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (strlen(modem.init[i])) if (strlen(modem.init[i]))
if (chat(modem.init[i], CFG.timeoutreset, NULL)) { if (chat(modem.init[i], CFG.timeoutreset, FALSE, NULL)) {
WriteError("dial: could not reset the modem"); WriteError("dial: could not reset the modem");
return 1; return 1;
} }
@ -82,20 +82,20 @@ int dialphone(char *Phone)
rc = 0; rc = 0;
if (strlen(nodes.phone[0])) { if (strlen(nodes.phone[0])) {
if (strlen(nodes.dial)) if (strlen(nodes.dial))
rc = chat(nodes.dial, CFG.timeoutconnect, nodes.phone[0]); rc = chat(nodes.dial, CFG.timeoutconnect, FALSE, nodes.phone[0]);
else else
rc = chat(modem.dial, CFG.timeoutconnect, nodes.phone[0]); rc = chat(modem.dial, CFG.timeoutconnect, FALSE, nodes.phone[0]);
if ((rc == 0) && strlen(nodes.phone[1])) { if ((rc == 0) && strlen(nodes.phone[1])) {
if (strlen(nodes.dial)) if (strlen(nodes.dial))
rc = chat(nodes.dial, CFG.timeoutconnect, nodes.phone[1]); rc = chat(nodes.dial, CFG.timeoutconnect, FALSE, nodes.phone[1]);
else else
rc = chat(modem.dial, CFG.timeoutconnect, nodes.phone[1]); rc = chat(modem.dial, CFG.timeoutconnect, FALSE, nodes.phone[1]);
} }
} else { } else {
if (strlen(nodes.dial)) if (strlen(nodes.dial))
rc = chat(nodes.dial, CFG.timeoutconnect, Phone); rc = chat(nodes.dial, CFG.timeoutconnect, FALSE, Phone);
else else
rc = chat(modem.dial, CFG.timeoutconnect, Phone); rc = chat(modem.dial, CFG.timeoutconnect, FALSE, Phone);
} }
if (rc) { if (rc) {
@ -118,7 +118,7 @@ int hangup()
FLUSHIN(); FLUSHIN();
FLUSHOUT(); FLUSHOUT();
if (strlen(modem.hangup)) if (strlen(modem.hangup))
chat(modem.hangup, CFG.timeoutreset, NULL); chat(modem.hangup, CFG.timeoutreset, FALSE, NULL);
if (carrier) { if (carrier) {
c_end = time(NULL); c_end = time(NULL);
@ -152,15 +152,12 @@ int hangup()
int aftercall() void aftercall()
{ {
if (strlen(modem.info)) {
Syslog('d', "Reading link stat (aftercall)"); Syslog('d', "Reading link stat (aftercall)");
FLUSHIN(); FLUSHIN();
FLUSHOUT(); FLUSHOUT();
chat(modem.info, CFG.timeoutreset, NULL); chat(modem.info, CFG.timeoutreset, TRUE, NULL);
}
return 0;
} }

View File

@ -1,11 +1,11 @@
#ifndef _DIAL_H #ifndef _DIAL_H
#define _DIAL_H #define _DIAL_H
/* $Id$ */
int dialphone(char *); int dialphone(char *);
int hangup(void); int hangup(void);
int aftercall(void); void aftercall(void);
#endif #endif