HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-users] CID and DAD recognize for Eicon Diva



Hi All!

     I try to setup Ecoin Diva 4 BRI ISDN card under Linux for Hylafax.
Diva card give nice CID and DAD numbers in the RING string via /dev/ttydsXX
inteface:
RING CID: 5300 DAD: 5777
Unfortunately hylafax do not recognize this format.
Howto get these two parameters to bin/faxrecvq ?
I write simple hack against hylafax-4.1.8 , which one relace CIDNumber and
CIDName with Diva CID and DAD. You can read and applay patch bellow.
To activate feature add line in Your etc/config.ttydsXX file
ModemResetCmds:          "AT#CID=7"
CIDNumber:          "CID: [0-9]+"
CIDName:       "DAD: [0-9]+"

where CIDNumber, CIDName is regular expressions.
After Your bin/faxrecvq have two parameters more "CID: 5300" "DAD: 5777"
Both parameters are very usable for fax dispatching.
My Diva have empty MSN field and so i can receive calls to multiple
numbers, how many local PBX administrator allow.
I can setup more incoming fax numbers as Diva card line count, which is
main idea to develop this.

     I hope in future Hylafax developers add CID and DAD number
recognize for Diva and another ISDN cards.

Aivils Stoss

diff -Nurp hylafax-4.1.8/faxd/ClassModem.c++
hylafax-4.1.8-chg/faxd/ClassModem.c++
--- hylafax-4.1.8/faxd/ClassModem.c++    2003-04-19 00:03:40.000000000
+0300
+++ hylafax-4.1.8-chg/faxd/ClassModem.c++     2004-03-03 16:35:53.000000000
+0200
@@ -750,7 +750,7 @@ ClassModem::atResponse(char* buf, long m
          lastResponse = AT_OFFHOOK;
         break;
     case 'R':
-        if (streq(buf, "RING"))         // NB: avoid match of RINGING
+        if (strneq(buf, "RING", 4))          // NB: avoid match of RINGING
          lastResponse = AT_RING;
         break;
     case '\020':
@@ -1220,8 +1220,10 @@ ClassModem::waitForRings(u_int n, CallTy
              // to hear DTMF tones which are DID data, and we configure
              // RingExtended to be FAXCNG to then trigger ATA.
              atCmd(conf.ringResponse);
-         else
+         else {
              n--;
+             conf.parseCID(rbuf, cid);
+         }
          break;
         case AT_NOANSWER:
         case AT_NOCARRIER:
diff -Nurp hylafax-4.1.8/faxd/ModemConfig.c++
hylafax-4.1.8-chg/faxd/ModemConfig.c++
--- hylafax-4.1.8/faxd/ModemConfig.c++   2003-03-26 06:41:55.000000000
+0200
+++ hylafax-4.1.8-chg/faxd/ModemConfig.c++    2004-03-04 12:59:48.000000000
+0200
@@ -521,10 +521,59 @@ ModemConfig::getRTNHandling(const char*
 void
 ModemConfig::parseCID(const char* rbuf, CallerID& cid) const
 {
-    if (strneq(rbuf, cidName, cidName.length()))
-    cid.name = cid.name | rbuf+cidName.length();
-    if (strneq(rbuf, cidNumber, cidNumber.length()))
-    cid.number = cid.number | rbuf+cidNumber.length();
+    int ret;
+    regmatch_t   matchp[1];
+    static char errbuf[256];
+    static char cidname[256];
+    static char cidnumber[256];
+
+    cidname[0] = '\0';
+    cidnumber[0] = '\0';
+    cid.name = cidname;
+    cid.number = cidnumber;
+
+    ret = regexec( &cidNameReg, rbuf, 1, matchp, REG_EXTENDED);
+    if (ret && ret != REG_NOMATCH) {
+    regerror( ret, &cidNameReg, errbuf, 256 );
+    cid.name = errbuf;
+    }
+    else if (matchp[0].rm_so > 0) {
+    strncpy(cidname, rbuf + matchp[0].rm_so, matchp[0].rm_eo -
matchp[0].rm_so);
+    *(cidname + matchp[0].rm_eo - matchp[0].rm_so + 1) = '\0';
+    }
+
+    ret = regexec( &cidNumberReg, rbuf, 1, matchp, REG_EXTENDED);
+    if (ret && ret != REG_NOMATCH) {
+        regerror( ret, &cidNumberReg, errbuf, 256 );
+        cid.number = errbuf;
+    }
+    else if (matchp[0].rm_so > 0) {
+        strncpy(cidnumber, rbuf + matchp[0].rm_so, matchp[0].rm_eo \
+            - matchp[0].rm_so);
+        *(cidnumber + matchp[0].rm_eo - matchp[0].rm_so + 1) = '\0';
+    }
+    cid.name = cidname;
+    cid.number = cidnumber;
+
+//    if (strneq(rbuf, cidName, cidName.length()))
+//  cid.name = cid.name | rbuf+cidName.length();
+//    if (strneq(rbuf, cidNumber, cidNumber.length()))
+//  cid.number = cid.number | rbuf+cidNumber.length();
+}
+
+void
+ModemConfig::setRegex(regex_t *Reg, const char *value)
+{
+    int ret;
+    char errbuf[256];
+    regfree(Reg);
+    ret = regcomp(Reg, value, REG_EXTENDED);
+    if (ret) {
+    regerror(ret, Reg, errbuf, 256);
+    configError("Unable copile regular expresion \"%s\", error: \"%s\"",\
+             value, errbuf);
+    regfree(Reg);
+    }
 }

 bool
@@ -533,8 +582,15 @@ ModemConfig::setConfigItem(const char* t
     u_int ix;
     if (findTag(tag, (const tags*)atcmds, N(atcmds), ix))
     (*this).*atcmds[ix].p = parseATCmd(value);
-    else if (findTag(tag, (const tags*)strcmds, N(strcmds), ix))
+    else if (findTag(tag, (const tags*)strcmds, N(strcmds), ix)) {
     (*this).*strcmds[ix].p = value;
+    if (streq(tag, "cidname")) {
+        setRegex(&cidNameReg, value);
+    }
+    else if (streq(tag, "cidnumber")) {
+        setRegex(&cidNumberReg, value);
+        }
+    }
     else if (findTag(tag, (const tags*)fillorders, N(fillorders), ix))
     (*this).*fillorders[ix].p = getFill(value);
     else if (findTag(tag, (const tags*)numbers, N(numbers), ix))
diff -Nurp hylafax-4.1.8/faxd/ModemConfig.h
hylafax-4.1.8-chg/faxd/ModemConfig.h
--- hylafax-4.1.8/faxd/ModemConfig.h     2003-02-09 04:03:13.000000000
+0200
+++ hylafax-4.1.8-chg/faxd/ModemConfig.h      2004-03-04 12:19:30.000000000
+0200
@@ -30,6 +30,7 @@
  */
 #include "FaxConfig.h"
 #include "FaxModem.h"
+#include "regex.h"

 struct ModemConfig : public FaxConfig {
 private:
@@ -102,6 +103,8 @@ public:
     fxStr     cidNumber;          // pattern for number info
     u_int     cidNameAnswerLength;      // answer when CID received
     u_int     cidNumberAnswerLength;    // answer when CID received
+    regex_t     cidNameReg;
+    regex_t     cidNumberReg;

                         // protocol timers
     u_int     t1Timer;       // T.30 T1 timer (ms)
@@ -194,5 +197,6 @@ public:

     void parseCID(const char*, CallerID&) const;
     const fxStr& getFlowCmd(FlowControl) const;
+    void setRegex(regex_t *, const char *);
 };
 #endif /* _ModemConfig_ */


____________________ HylaFAX(tm) Users Mailing List _______________________
  To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
 On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
  *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxxxxx*




Project hosted by iFAX Solutions