Discussion:
(fwd) mgetty patch for caller-id functionality 2010
(too old to reply)
Paul Fox
2010-09-01 03:21:13 UTC
Permalink
is there any chance of getting alex's caller-id patch into mgetty?
Date: Thu, 04 Mar 2010 12:54:11 PST
Subject: mgetty patch for caller-id functionality 2010
Hi Gert, how are you?
It would be nice to see mgetty-1.1.37 come out this year, including
my caller-id patch, for which people have expressed interest in.
I'm sure you'll have other fixes/improvements to rollout since almost 2 years
passed since the last version came out.
By the way, the filenames you use, for example mgetty1.1.36-Jun15.tar.gz
should include the year in the filename. In the case of the above filename
which is the latest version, the year it came out was 2007.
The previous version, mgetty1.1.35-Feb22.tar.gz came out in 2006.
Anyway, I have added comments to my patch in changelog format, to make
things easier for you. The patch has by now undergone years of successful
testing, and includes good, complete documentation.
Thanks,
Alex
=---------------------
paul fox, ***@foxharp.boston.ma.us (arlington, ma, where it's 76.3 degrees)

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Matthias Urlichs
2010-09-01 07:53:11 UTC
Permalink
Hi,
By the way, the filenames you use, for example
mgetty1.1.36-Jun15.tar.gz
should include the year in the filename.
IMHO it'd make much more sense to not include the date in the first
place. Nobody else does that, and having more than one release with a
given number (but different dates) is a big no-no in any case.
--
-- Matthias Urlichs
Dan Smith
2010-09-01 18:09:55 UTC
Permalink
I'd love to get that patch to build but I'm getting an error running make
test, running ubuntu lucid, trying to patch ubuntu's mgetty 1.1.36-1.5
source.
If I remove setup_environment line from cnd.c it compiles fine but I haven't
bothered installing it since I'm assuming that line is needed. I'd fix it if
I knew how to do more than apply patches.

make[1]: Entering directory `/home/mrplow/mgetty-cnd/tmp/mgetty-1.1.36/t'
gcc -o t_ring t_ring.o ../ring.o ../cnd.o
../cnd.o: In function `cnd_call':
cnd.c:(.text+0x106): undefined reference to `setup_environment'
collect2: ld returned 1 exit status
make[1]: *** [t_ring] Error 1
make[1]: Leaving directory `/home/mrplow/mgetty-cnd/tmp/mgetty-1.1.36/t'
make: *** [test] Error 2
Post by Paul Fox
is there any chance of getting alex's caller-id patch into mgetty?
Date: Thu, 04 Mar 2010 12:54:11 PST
Subject: mgetty patch for caller-id functionality 2010
Hi Gert, how are you?
It would be nice to see mgetty-1.1.37 come out this year, including
my caller-id patch, for which people have expressed interest in.
I'm sure you'll have other fixes/improvements to rollout since almost 2
years
passed since the last version came out.
By the way, the filenames you use, for example mgetty1.1.36-Jun15.tar.gz
should include the year in the filename. In the case of the above
filename
which is the latest version, the year it came out was 2007.
The previous version, mgetty1.1.35-Feb22.tar.gz came out in 2006.
Anyway, I have added comments to my patch in changelog format, to make
things easier for you. The patch has by now undergone years of
successful
testing, and includes good, complete documentation.
Thanks,
Alex
=---------------------
Gert Doering
2010-09-01 20:46:20 UTC
Permalink
Hi,
Post by Dan Smith
make[1]: Entering directory `/home/mrplow/mgetty-cnd/tmp/mgetty-1.1.36/t'
gcc -o t_ring t_ring.o ../ring.o ../cnd.o
cnd.c:(.text+0x106): undefined reference to `setup_environment'
collect2: ld returned 1 exit status
Well, that's just one of the test programs. So failure there is
harmless (in this case) regarding the function of mgetty itself.

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
mattias
2010-09-01 21:07:37 UTC
Permalink
How to unsubscribe?

-----Original Message-----
From: Gert Doering [mailto:***@greenie.muc.de]
Sent: Wednesday, September 01, 2010 10:46 PM
To: Dan Smith
Cc: ***@muc.de; Paul Fox; Alexandros Manoussakis
Subject: Re: (fwd) mgetty patch for caller-id functionality 2010


Hi,
Post by Dan Smith
make[1]: Entering directory
`/home/mrplow/mgetty-cnd/tmp/mgetty-1.1.36/t'
gcc -o t_ring t_ring.o ../ring.o ../cnd.o
cnd.c:(.text+0x106): undefined reference to `setup_environment'
collect2: ld returned 1 exit status
Well, that's just one of the test programs. So failure there is
harmless (in this case) regarding the function of mgetty itself.

gert
--
USENET is *not* the non-clickable part of WWW!

//www.muc.de/~gert/
Gert Doering - Munich, Germany
***@greenie.muc.de
fax: +49-89-35655025
***@net.informatik.tu-muenchen.de
Gert Doering
2010-09-02 07:07:50 UTC
Permalink
Hi,
Post by mattias
How to unsubscribe?
Same way you got on the list :-) - send mail to mgetty-***@muc.de
and follow the instructions.

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Alexandros Manoussakis
2010-09-02 05:23:12 UTC
Permalink
I have 2 ways to solve the problem. One is to move set_env_var and
setup_environment to cnd.c

The other is to add a define to a header file that is not used by the test
suite, and hide the setup_environment call from cnd.c if it's being linked
by the test suite.

I think the first way is better. In any case, I am sending 2 patches, one
for each solution. Gert please let me know which one you prefer, and I can
send a new overall patch against 1.1.37 with the caller-id functionality
which will include the test suite fix. Both patches pass "make test".

Thanks,
Alex
Post by Gert Doering
Hi,
Post by Dan Smith
make[1]: Entering directory `/home/mrplow/mgetty-cnd/tmp/mgetty-1.1.36/t'
gcc -o t_ring t_ring.o ../ring.o ../cnd.o
cnd.c:(.text+0x106): undefined reference to `setup_environment'
collect2: ld returned 1 exit status
Well, that's just one of the test programs. So failure there is
harmless (in this case) regarding the function of mgetty itself.
gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
a***@juniper.net
2010-09-03 04:00:37 UTC
Permalink
Sending caller-id patch (against mgetty-1.1.37) with updates so that
the test suite works properly. Gert, if you can merge it into the
mainline it would be really great ! It's pretty much complete,
with documentation, changelog, etc.

Changelog:
The purpose of this patch is to allow mgetty to function as a caller-id box
and report caller-id information by invoking a user-specified program, as
soon as the callerid information becomes available. The invoked program is
specified by the new cid-program option, which is similar to the cnd-program
that already exists (used to invoke a program only when mgetty actually picks
up the phone).

* cnd.c:
(cndfind) (process_rockwell_mesg): Upgraded message reporting caller
to L_NOISE, since it's a rather noteworthy event.

(cnd_call): Call the setup_environment function, so that CID information
will be available to the cnd-program/cid-program scripts as environment
variables.

(set_env_var): Moved this function here from logname.c as it makes
sense to have set_env_var and setup_environment in the same file
and allows cnd.o to be linked by the test suite.

(setup_environment): Moved this function here from login.c
and added new environment variables CALL_DATE and CALL_TIME,
useful to pass to programs run by cnd-program/cid-program.

* conf_mg.c (conf_mg.c): Added the new cid-program configuration option, which
is used to execute a program as soon as caller id information comes in.

* conf_mg.h: Added cid_program member to the conf_data_mgetty struct.

* mgetty.texi-in: Added documentation about the new cid-program option, and
added information about the new CALL_DATE and CALL_TIME environment
variables, and about the existing CALL_DEVICE environment variable.

* login.c (setup_environment): Added new environment variables CALL_DATE and
CALL_TIME, useful to pass to programs run by cnd-program/cid-program.

* logname.c (set_env_var): Moved this function to cnd.c

* mgetty.c (main): Added logic to run cid-program as soon as caller-id
information comes in (and only run it once per call).

* mgetty.h: Added extern reference to the CallDate pointer, since it is now
used by more than one file.

* t/t_ring.c: Initialize Device to a dummy value for cnd.c to use for the test.

diff -upr mgetty-1.1.37-orig/cnd.c mgetty-1.1.37/cnd.c
--- mgetty-1.1.37-orig/cnd.c 2005-04-17 04:55:43.000000000 -0700
+++ mgetty-1.1.37/cnd.c 2010-09-01 21:52:05.000000000 -0700
@@ -11,6 +11,8 @@
#include "mgetty.h"
#include "config.h"

+extern char * Device; /* mgetty.c */
+
char *Connect = "";
char *CallerId = "none";
char *CallTime = "";
@@ -170,7 +172,7 @@ cndfind _P1((str), char *str)
p++;
}
}
- lprintf(L_JUNK, "CND: found: %s", *(cp->variable));
+ lprintf(L_NOISE, "CND: found: %s", *(cp->variable));
return;
}
}
@@ -221,7 +223,7 @@ void process_rockwell_mesg _P0 (void)
}
*p = 0;

- lprintf(L_JUNK, "CND: caller ID: %s", CallerId);
+ lprintf(L_NOISE, "CND: caller ID: %s", CallerId);
}

/* lookup Caller ID in CNDFILE, decide upon answering or not */
@@ -287,6 +289,7 @@ int cnd_call _P3((name, tty, dist_ring),
tty, CallerId, CallName, dist_ring, CalledNr, CONSOLE );
lprintf( L_NOISE, "CND: program \"%s\"", program );

+ setup_environment();
rc = system(program);

if ( rc < 0 )
@@ -297,3 +300,38 @@ int cnd_call _P3((name, tty, dist_ring),

return rc>>8;
}
+
+/* set_env_var( var, string )
+ *
+ * create an environment entry "VAR=string"
+ */
+void set_env_var _P2( (var,string), char * var, char * string )
+{
+ char * v;
+ v = malloc( strlen(var) + strlen(string) + 2 );
+ if ( v == NULL )
+ lprintf( L_ERROR, "set_env_var: cannot malloc" );
+ else
+ {
+ sprintf( v, "%s=%s", var, string );
+ lprintf( L_NOISE, "setenv: '%s'", v );
+ if ( putenv( v ) != 0 )
+ lprintf( L_ERROR, "putenv failed" );
+ }
+}
+
+void setup_environment _P0(void)
+{
+ if ( *CallerId )
+ set_env_var( "CALLER_ID", CallerId );
+ if ( *CallDate )
+ set_env_var( "CALL_DATE", CallDate );
+ if ( *CallTime )
+ set_env_var( "CALL_TIME", CallTime );
+ if ( *CallName )
+ set_env_var( "CALLER_NAME", CallName );
+ if ( *CalledNr )
+ set_env_var( "CALLED_ID", CalledNr );
+ set_env_var( "CONNECT", Connect );
+ set_env_var( "DEVICE", Device );
+}
diff -upr mgetty-1.1.37-orig/conf_mg.c mgetty-1.1.37/conf_mg.c
--- mgetty-1.1.37-orig/conf_mg.c 2009-03-19 08:13:53.000000000 -0700
+++ mgetty-1.1.37/conf_mg.c 2010-09-01 21:45:14.000000000 -0700
@@ -85,6 +85,7 @@ struct conf_data_mgetty c = {
{ "rings", {1}, CT_INT, C_PRESET },
{ "msn-list", {(p_int) NULL}, CT_CHAT, C_EMPTY },
{ "get-cnd-chat", {0}, CT_CHAT, C_EMPTY },
+ { "cid-program", {(p_int) NULL}, CT_STRING, C_EMPTY },
{ "cnd-program", {(p_int) NULL}, CT_STRING, C_EMPTY },
{ "answer-chat", {0}, CT_CHAT, C_EMPTY },
{ "answer-chat-timeout", {80}, CT_INT, C_PRESET },
diff -upr mgetty-1.1.37-orig/conf_mg.h mgetty-1.1.37/conf_mg.h
--- mgetty-1.1.37-orig/conf_mg.h 2005-11-24 08:57:58.000000000 -0800
+++ mgetty-1.1.37/conf_mg.h 2010-09-01 21:45:14.000000000 -0700
@@ -33,6 +33,7 @@ extern struct conf_data_mgetty {
rings_wanted, /* number of RINGs */
msn_list, /* ISDN MSNs (dist.ring) */
getcnd_chat, /* get caller ID (for ELINK)*/
+ cid_program, /* notify about caller ID */
cnd_program, /* accept caller? */
answer_chat, /* ATA...CONNECT...""...\n */
answer_chat_timeout, /* longer as S7! */
diff -upr mgetty-1.1.37-orig/doc/mgetty.texi-in mgetty-1.1.37/doc/mgetty.texi-in
--- mgetty-1.1.37-orig/doc/mgetty.texi-in 2008-01-31 08:30:12.000000000 -0800
+++ mgetty-1.1.37/doc/mgetty.texi-in 2010-09-01 21:45:14.000000000 -0700
@@ -638,12 +638,20 @@ Some telephone companies provide a servi
your phone is ringing. Not all providers support it, and you'll have to
ask for it.

-If your modem is able to retrieve callerid information, and @code{mgetty}
+Right now, Caller ID in @code{mgetty} works for most modem variants out there,
+ZyXEL, Rockwell, ELSA and isdn4linux among them.
+
+If your modem is able to retrieve callerid information, @code{mgetty} can
+report that information by passing it as arguments to the @code{cid-program}
+statement in @file{mgetty.config}. You may point @code{cid-program} to a
+script that writes to a logfile, displays a popup on your terminal, etc.
+@code{cid-program} takes the same arguments as @code{cnd-program} (see below)
+but its exit code is ignored.
+
+In addition to the ability of reporting callerid information, if @code{mgetty}
is compiled with @code{CNDFILE} defined in @file{policy.h}, @code{mgetty}
-can check the caller's number before answering the phone. (Right now, it
-works for most variants out there, ZyXEL, Rockwell, ELSA and isdn4linux
-among them). If @code{CNDFILE} is undefined, or if the
-file specified does not exist, all calls will be allowed.
+can check the caller's number before answering the phone. If @code{CNDFILE} is
+undefined, or if the file specified does not exist, all calls will be allowed.

One important thing: for most analog modems, you @strong{must} set the
number of RINGs to wait for to two (2) or higher (set @samp{rings 2} in
@@ -1042,6 +1050,13 @@ if the static Caller ID selection in CND
or if you want to use the Caller ID data for other purposes (displaying,
for example). @xref{Caller-ID}.

+@item @code{cid-program} @var{pathname}
+
+Specify a program to be run as soon as Caller ID information comes in
+(typically between 1st and 2nd ring). If Caller ID info is not available by
+the 3rd ring, still run the program (to report the time that the phone rang).
+This allows mgetty to behave like a caller-id box. @xref{Caller-ID}.
+
@item @code{answer-chat} @var{chat sequence}

This is the command sequence that is used to answer a phone call. Usually
@@ -1489,11 +1504,11 @@ A sample command line might look like th
@BINDIR@/new_fax 0 "+49 89 3243328" 1 @FAX_SPOOL@/ff-01.a123
@end example

-In addition, some environment variables are provide: @code{CALLER_ID},
+In addition, some environment variables are provided: @code{CALLER_ID},
@code{CALLER_NAME}, @code{CALLED_ID} (Caller ID and destination ISDN MSN,
-if available and supported by your modem), and @code{DEVICE} (the full
-name of the tty device, if you want to process faxes differently
-depending on the line they came in).
+if available and supported by your modem), @code{CALL_DATE}, @code{CALL_TIME},
+and @code{DEVICE} (the full name of the tty device, if you want to process
+faxes differently depending on the line they came in).

Such a ``notify program'' could print out the fax, convert it into a MIME
metamail and send it away, display it in an X window (this a little bit
diff -upr mgetty-1.1.37-orig/login.c mgetty-1.1.37/login.c
--- mgetty-1.1.37-orig/login.c 2003-12-05 14:28:58.000000000 -0800
+++ mgetty-1.1.37/login.c 2010-09-01 21:48:16.000000000 -0700
@@ -369,14 +369,3 @@ fallthrough:
exit(FAIL);
}

-void setup_environment _P0(void)
-{
- if ( *CallerId )
- set_env_var( "CALLER_ID", CallerId );
- if ( *CallName )
- set_env_var( "CALLER_NAME", CallName );
- if ( *CalledNr )
- set_env_var( "CALLED_ID", CalledNr );
- set_env_var( "CONNECT", Connect );
- set_env_var( "DEVICE", Device );
-}
diff -upr mgetty-1.1.37-orig/logname.c mgetty-1.1.37/logname.c
--- mgetty-1.1.37-orig/logname.c 2005-11-24 08:58:32.000000000 -0800
+++ mgetty-1.1.37/logname.c 2010-09-01 21:51:57.000000000 -0700
@@ -230,25 +230,6 @@ boolean ln_all_upper _P1( (string), char
#endif


-/* set_env_var( var, string )
- *
- * create an environment entry "VAR=string"
- */
-void set_env_var _P2( (var,string), char * var, char * string )
-{
- char * v;
- v = malloc( strlen(var) + strlen(string) + 2 );
- if ( v == NULL )
- lprintf( L_ERROR, "set_env_var: cannot malloc" );
- else
- {
- sprintf( v, "%s=%s", var, string );
- lprintf( L_NOISE, "setenv: '%s'", v );
- if ( putenv( v ) != 0 )
- lprintf( L_ERROR, "putenv failed" );
- }
-}
-
static int timeouts = 0;
static RETSIGTYPE getlog_timeout(SIG_HDLR_ARGS)
{
diff -upr mgetty-1.1.37-orig/mgetty.c mgetty-1.1.37/mgetty.c
--- mgetty-1.1.37-orig/mgetty.c 2009-03-19 08:14:28.000000000 -0700
+++ mgetty-1.1.37/mgetty.c 2010-09-01 21:45:14.000000000 -0700
@@ -279,6 +279,7 @@ int main _P2((argc, argv), int argc, cha
int rings_wanted;
int rings = 0;
int dist_ring = 0; /* type of RING detected */
+ boolean cid_program_ran = FALSE;/* Only run cid_program once per call */

#if defined(_3B1_) || defined(MEIBE) || defined(sysV68)
extern struct passwd *getpwuid(), *getpwnam();
@@ -548,6 +549,7 @@ int main _P2((argc, argv), int argc, cha
*/
CallTime = CallName = CalledNr = ""; /* dirty */
CallerId = "none";
+ cid_program_ran = FALSE;
clean_line( STDIN, 3); /* let line settle */
rmlocks();
mgetty_state = St_waiting;
@@ -738,14 +740,26 @@ int main _P2((argc, argv), int argc, cha

while ( rings < rings_wanted )
{
- if ( wait_for_ring( STDIN, c_chat(msn_list),
- ( c_bool(ringback) && rings == 0 )
- ? c_int(ringback_time) : ring_chat_timeout,
- ring_chat_actions, &what_action,
- &dist_ring ) == FAIL)
+ int w;
+
+ w = wait_for_ring( STDIN, c_chat(msn_list),
+ ( c_bool(ringback) && rings == 0 )
+ ? c_int(ringback_time) : ring_chat_timeout,
+ ring_chat_actions, &what_action,
+ &dist_ring );
+
+ /* Inform about Caller ID. If we haven't gotten the info by 3rd
+ * ring, it's hopeless; just report that the phone rang. */
+ if ( c_isset(cid_program) && !cid_program_ran
+ && (rings >= 2 || *CallName || strcmp(CallerId, "none")) )
{
- break; /* ringing stopped, or "action" */
+ cnd_call( c_string(cid_program), Device, dist_ring );
+ cid_program_ran = TRUE;
}
+
+ if ( w == FAIL )
+ break; /* ringing stopped, or "action" */
+
rings++;
}

diff -upr mgetty-1.1.37-orig/mgetty.h mgetty-1.1.37/mgetty.h
--- mgetty-1.1.37-orig/mgetty.h 2006-01-01 09:13:18.000000000 -0800
+++ mgetty-1.1.37/mgetty.h 2010-09-01 21:45:14.000000000 -0700
@@ -296,6 +296,7 @@ void setup_environment _PROTO(( void ));

extern char *Connect;
extern char *CallerId;
+extern char *CallDate;
extern char *CallTime;
extern char *CallName;
extern char *CalledNr;
diff -upr mgetty-1.1.37-orig/t/t_ring.c mgetty-1.1.37/t/t_ring.c
--- mgetty-1.1.37-orig/t/t_ring.c 2005-03-23 01:56:21.000000000 -0800
+++ mgetty-1.1.37/t/t_ring.c 2010-09-01 21:53:16.000000000 -0700
@@ -30,6 +30,8 @@
# include <stdarg.h>
#endif

+
+char *Device = "/dev/null"; /* device to use */
char *msnlist[] = {"9999", "35655023", "35655024", "35655025", "4023", NULL};

struct t_ring_tests { char * input;

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Dan Smith
2010-09-03 17:07:05 UTC
Permalink
please include this patch for 1.1.37 release, I guess its too late to
get 1.1.37 out for inclusion in Ubuntu 10.10 though
Resending caller-id patch for 1.1.37 as attachment which should better
preserve tabs/spaces/etc.
Alex
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Gert Doering
2010-09-03 17:54:54 UTC
Permalink
Hi,
Post by Dan Smith
please include this patch for 1.1.37 release, I guess its too late to
get 1.1.37 out for inclusion in Ubuntu 10.10 though
I'll do what I can. Right now, I need to divide my time between
"4 month old daughter", "paying customers", "make OpenVPN work right
with IPv6" and "get some sleep".

I have seen your mails and heard you, but will need to take a close
look at the patch (coding conventions, side effects, unexpected
behaviour change, ...) - and that needs "have an hour of quietness
and enough brains".

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Dan Smith
2010-09-03 18:02:38 UTC
Permalink
thanks, I'm done prodding now ;)
Post by Gert Doering
Hi,
Post by Dan Smith
please include this patch for 1.1.37 release, I guess its too late to
get 1.1.37 out for inclusion in Ubuntu 10.10 though
I'll do what I can. Right now, I need to divide my time between
"4 month old daughter", "paying customers", "make OpenVPN work right
with IPv6" and "get some sleep".
I have seen your mails and heard you, but will need to take a close
look at the patch (coding conventions, side effects, unexpected
behaviour change, ...) - and that needs "have an hour of quietness
and enough brains".
gert
--
USENET is *not* the non-clickable part of WWW!
//
www.muc.de/~gert/ <http://www.muc.de/%7Egert/>
Gert Doering - Munich, Germany
fax: +49-89-35655025
Loading...