Blob Blame History Raw
diff -up mgetty-1.1.36/callback/callback.c.caller_name mgetty-1.1.36/callback/callback.c
--- mgetty-1.1.36/callback/callback.c.caller_name	2009-01-30 08:47:53.000000000 +0100
+++ mgetty-1.1.36/callback/callback.c	2009-01-30 08:49:15.000000000 +0100
@@ -396,7 +396,7 @@ char * r;
 /* provide some "dummy" things for do_chat(), otherwise callback won't link */
 /*!!! FIXME - we don't really want this */
 int virtual_ring = FALSE;
-void cndfind _P1( (p), char * p ) { /* DUMMY */ }
+int cndfind _P1( (p), char * p ) { /* DUMMY */ }
 
 int main _P2((argc, argv), int argc, char ** argv)
 {
diff -up mgetty-1.1.36/cnd.c.caller_name mgetty-1.1.36/cnd.c
--- mgetty-1.1.36/cnd.c.caller_name	2009-01-30 08:48:07.000000000 +0100
+++ mgetty-1.1.36/cnd.c	2009-01-30 09:09:36.000000000 +0100
@@ -104,7 +104,7 @@ struct cndtable cndtable[] =
 };
     
 
-void
+int
 cndfind _P1((str), char *str)
 {
     struct cndtable *cp;
@@ -124,56 +124,82 @@ cndfind _P1((str), char *str)
        asked for it with AT\O. The CID will simply get sent on a single
        line consisting only of digits. So, if we get a line starting
        with a digit, let's assume that it's the CID...
+       The USRobotics can send unformatted caller id data. Allow for that as well.
      */
     if ( isdigit(*str) )
     {
-	CallerId = p = strdup(str);
-	while( isdigit(*p) ) p++;
-	*p = 0;
-	lprintf( L_NOISE, "CND: ELink caller ID: '%s'", CallerId );
-	return;
+			int CheckSum=0; // to validate possible unformatted display
+ 			int digit;
+			CallerId = p = strdup(str);
+			while( isxdigit(*p) ) p++;
+			*p = 0;
+ 			// Check for an unformatted display of caller id. Calculate FSK checksum...
+			p = CallerId;
+	 		while (*p)
+			{
+	 			if (isdigit(*p))
+					digit = (*p - '0');
+ 				else digit = 10 + (tolower(*p) - 'a');
+ 				CheckSum += (digit << 4);
+		 		p++;
+ 				if (!*p)
+					break; // odd number of characters, not proper hex, cannot be FSK
+	 			if (isdigit(*p))
+					digit = (*p - '0');
+	 			else digit = 10 + (tolower(*p) - 'a');
+ 				CheckSum += digit;
+				CheckSum &= 255;
+ 				p++;
+		 	}
+			if (CheckSum == 0)
+			{
+				lprintf( L_NOISE, "CND: ELink caller ID: '%s'", CallerId );
+				return 4;
+			}
+			return 1;
     }
 
     for (cp = cndtable; cp->string; cp++)
     {
-	len = strlen(cp->string);
-	if (strncmp(cp->string, str, len) == 0)
-	{
-	    if (!cp->variable)
-		return;
-
-	    /* special case: Rockwell sends *two* MESG=... lines */
-	    if (cp->variable == &CallMsg1 && CallMsg1[0] != 0)
-		continue;
-
-	    /* special case for CONNECT on Rockwell-Based modems */
-	    if ( ( cnd_carrier[0] != 0 || cnd_protocol[0] != 0 ) &&
-		 strncmp( str, "CONNECT ", 8 ) == 0 )
-	    {
-		*(cp->variable) = malloc( strlen(str) - len +
-		                  strlen( cnd_carrier ) +
-				  strlen( cnd_protocol ) + 5 );
-		sprintf( *(cp->variable), "%s/%s %s",
-			 str+len, cnd_carrier, cnd_protocol );
-	    }
-	    else	/* normal case */
-	    {
-		*(cp->variable) = p = malloc(strlen(str) - len + 1);
-		(void) strcpy(*(cp->variable), str+len);
-
-		/* nuke quotes and non-printable characters (some of this 
-		 * stuff is passed to shell commands and environment vars)
-		 */
-		while( *p != '\0' )
-		{ 
-		    if ( *p == '\'' || *p == '\"' || !isprint(*p) ) *p = ' ';
-		    p++;
-		}
-	    }
-	    lprintf(L_JUNK, "CND: found: %s", *(cp->variable));
-	    return;
-	}
+			len = strlen(cp->string);
+			if (strncmp(cp->string, str, len) == 0)
+			{
+	  	  if (!cp->variable)
+					return 0;
+
+	    	/* special case: Rockwell sends *two* MESG=... lines */
+		    if (cp->variable == &CallMsg1 && CallMsg1[0] != 0)
+					continue;
+
+		    /* special case for CONNECT on Rockwell-Based modems */
+		    if ( ( cnd_carrier[0] != 0 || cnd_protocol[0] != 0 ) &&
+						 strncmp( str, "CONNECT ", 8 ) == 0 )
+		    {
+					*(cp->variable) = malloc( strlen(str) - len +
+		      	strlen( cnd_carrier ) +
+					  strlen( cnd_protocol ) + 5 );
+					sprintf( *(cp->variable), "%s/%s %s",
+						str+len, cnd_carrier, cnd_protocol );
+		    }
+		    else	/* normal case */
+	  	  {
+					*(cp->variable) = p = malloc(strlen(str) - len + 1);
+					(void) strcpy(*(cp->variable), str+len);
+
+					/* nuke quotes and non-printable characters (some of this 
+					 * stuff is passed to shell commands and environment vars)
+					 */
+					while( *p != '\0' )
+					{ 
+				    if ( *p == '\'' || *p == '\"' || !isprint(*p) ) *p = ' ';
+				    p++;
+					}
+		    }
+		    lprintf(L_JUNK, "CND: found: %s", *(cp->variable));
+	  	  return 1;
+			}
     }
+	return 0;
 }
 
 /* process Rockwell-style caller ID. Weird */
diff -up mgetty-1.1.36/mgetty.h.caller_name mgetty-1.1.36/mgetty.h
--- mgetty-1.1.36/mgetty.h.caller_name	2009-01-30 08:48:28.000000000 +0100
+++ mgetty-1.1.36/mgetty.h	2009-01-30 09:39:28.000000000 +0100
@@ -300,7 +300,7 @@ extern char *CallTime;
 extern char *CallName;
 extern char *CalledNr;
 
-void cndfind _PROTO((char *str));
+int cndfind _PROTO((char *str));
 int cndlookup _PROTO((void));
 int cnd_call _PROTO((char *name, char *tty, int dist_ring ));
 
diff -up mgetty-1.1.36/ring.c.caller_name mgetty-1.1.36/ring.c
--- mgetty-1.1.36/ring.c.caller_name	2009-01-30 08:48:17.000000000 +0100
+++ mgetty-1.1.36/ring.c	2009-01-30 09:47:03.000000000 +0100
@@ -219,6 +219,7 @@ int wait_for_ring _P6((fd, msn_list, tim
 char	buf[BUFSIZE], ch, *p;
 int	i, w, r;
 int	rc = SUCCESS;
+int need_cnd_items = 4;
 boolean	got_dle;		/* for <DLE><char> events (voice mode) */
 
     lprintf( L_MESG, "wfr: waiting for ``RING''" );
@@ -311,7 +312,7 @@ boolean	got_dle;		/* for <DLE><char> eve
 	/* got a full line */
 	if ( w == 0 ) { continue; }		/* ignore empty lines */
 	buf[w] = '\0';
-	cndfind( buf );				/* grab caller ID */
+  need_cnd_items -= cndfind( buf );	/* grab caller ID, adjust count of needed data items for cnd-program */
 
 	/* ZyXEL CallerID/MSN display? */
 	if ( strncmp( buf, "FM:", 3 ) == 0 ||
@@ -323,7 +324,8 @@ boolean	got_dle;		/* for <DLE><char> eve
 	 * instead of waiting for the next "real" RING
 	 * (but don't do this for V253 DRON/DROF modems!)
 	 */
-	if ( strncmp( buf, "NMBR", 4 ) == 0 && drox_count == 0 ) { break; }
+	//if ( strncmp( buf, "NMBR", 4 ) == 0 && drox_count == 0 ) { break; }
+  if ( (need_cnd_items <= 0) && (drox_count == 0) ) { break; }
 
 	/* V.253 ring cadences */
 	if ( strncmp( buf, "DRON", 4 ) == 0 ||