fix backwards compatibility in capi20 library, small other changes

This commit is contained in:
kai 2000-11-12 16:06:41 +00:00
parent 61502341eb
commit 7551b31064
8 changed files with 68 additions and 17 deletions

View File

@ -10,7 +10,7 @@ lib_LTLIBRARIES = libcapi20.la
lib_LIBRARIES = libcapi20dyn.a
libcapi20_la_SOURCES = capi20.c capifunc.c convert.c
libcapi20_la_LDFLAGS = -version-info 2:5:0
libcapi20_la_LDFLAGS = -version-info 2:6:0
libcapi20dyn_a_SOURCES = capidyn.c
# libcapi20_la_LIBADD = $(LIBADD_DL)

View File

@ -81,7 +81,7 @@ lib_LTLIBRARIES = libcapi20.la
lib_LIBRARIES = libcapi20dyn.a
libcapi20_la_SOURCES = capi20.c capifunc.c convert.c
libcapi20_la_LDFLAGS = -version-info 2:5:0
libcapi20_la_LDFLAGS = -version-info 2:6:0
libcapi20dyn_a_SOURCES = capidyn.c
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4

View File

@ -1,7 +1,10 @@
/*
* $Id: capi20.c,v 1.17 2000/06/26 15:00:43 calle Exp $
* $Id: capi20.c,v 1.18 2000/11/12 16:06:41 kai Exp $
*
* $Log: capi20.c,v $
* Revision 1.18 2000/11/12 16:06:41 kai
* fix backwards compatibility in capi20 library, small other changes
*
* Revision 1.17 2000/06/26 15:00:43 calle
* - Will also compile with 2.0 Kernelheaders.
*
@ -180,8 +183,9 @@ capi20_register (unsigned MaxB3Connection,
if ((fd = open(capidevname, O_RDWR|O_NONBLOCK, 0666)) < 0 && errno == ENOENT)
fd = open(capidevnamenew, O_RDWR|O_NONBLOCK, 0666);
if (fd < 0)
return CapiRegOSResourceErr;
return CapiRegOSResourceErr;
ioctl_data.rparams.level3cnt = MaxB3Connection;
ioctl_data.rparams.datablkcnt = MaxB3Blks;
@ -189,14 +193,50 @@ capi20_register (unsigned MaxB3Connection,
if ((applid = ioctl(fd, CAPI_REGISTER, &ioctl_data)) < 0) {
if (errno == EIO) {
if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0)
if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) {
close (fd);
return CapiRegOSResourceErr;
}
close (fd);
return (unsigned)ioctl_data.errcode;
}
return CapiRegOSResourceErr;
} else if (errno == EINVAL) { // old kernel driver
close (fd);
fd = -1;
for (i=0; fd < 0; i++) {
/*----- open pseudo-clone device -----*/
sprintf(buf, "/dev/capi20.%02d", i);
if ((fd = open(buf, O_RDWR|O_NONBLOCK, 0666)) < 0) {
switch (errno) {
case EEXIST:
break;
default:
return CapiRegOSResourceErr;
}
}
}
if (fd < 0)
return CapiRegOSResourceErr;
ioctl_data.rparams.level3cnt = MaxB3Connection;
ioctl_data.rparams.datablkcnt = MaxB3Blks;
ioctl_data.rparams.datablklen = MaxSizeB3;
if ((applid = ioctl(fd, CAPI_REGISTER, &ioctl_data)) < 0) {
if (errno == EIO) {
if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) {
close(fd);
return CapiRegOSResourceErr;
}
close(fd);
return (unsigned)ioctl_data.errcode;
}
close(fd);
return CapiRegOSResourceErr;
}
applid = alloc_applid(fd);
} // end old driver compatibility
}
if (applid == 0) /* old driver */
applid = alloc_applid(fd);
if (remember_applid(applid, fd) < 0) {
close(fd);
return CapiRegOSResourceErr;
@ -301,6 +341,7 @@ capi20_get_message (unsigned ApplID, unsigned char **Buf)
*Buf = rcvbuf;
if ((rc = read(fd, rcvbuf, sizeof(rcvbuf))) > 0) {
CAPIMSG_SETAPPID(rcvbuf, ApplID); // workaround for old driver
if ( CAPIMSG_COMMAND(rcvbuf) == CAPI_DATA_B3
&& CAPIMSG_SUBCOMMAND(rcvbuf) == CAPI_IND) {
if (sizeof(void *) == 4) {

2
capi20/configure vendored
View File

@ -702,7 +702,7 @@ fi
PACKAGE=libcapi20
VERSION=2.0.5
VERSION=2.0.6
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }

View File

@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(capi20.c)
AM_INIT_AUTOMAKE(libcapi20,2.0.5)
AM_INIT_AUTOMAKE(libcapi20,2.0.6)
AC_PREFIX_DEFAULT(/usr)
dnl Checks for programs.

View File

@ -1,4 +1,4 @@
/* $Id: capiinfo.c,v 1.3 2000/06/12 08:51:04 kai Exp $
/* $Id: capiinfo.c,v 1.4 2000/11/12 16:06:42 kai Exp $
*
* A CAPI application to get infomation about installed controllers
*
@ -14,6 +14,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: capiinfo.c,v $
* Revision 1.4 2000/11/12 16:06:42 kai
* fix backwards compatibility in capi20 library, small other changes
*
* Revision 1.3 2000/06/12 08:51:04 kai
* show supported supplementary services
*
@ -204,7 +207,7 @@ int main(int argc, char **argv)
continue;
}
if (cmsg.Info != 0x0000) {
fprintf(stderr, "FAC GET - (Info)\n");
fprintf(stderr, "FAC GET - (Info %#x)\n", cmsg.Info);
continue;
}
if (cmsg.FacilityConfirmationParameter[0] != 0x09) {
@ -221,6 +224,7 @@ int main(int argc, char **argv)
printf("\nSupplementary services support: 0x%08x\n", SuppServices);
showbitvalues(SupportedServices, SuppServices);
printf("\n");
}
return 0;
}

View File

@ -25,7 +25,7 @@
* OR MODIFICATIONS.
*/
char ccp_rcsid[] = "$Id: ccp.c,v 1.14 1999/11/03 16:06:35 paul Exp $";
char ccp_rcsid[] = "$Id: ccp.c,v 1.15 2000/11/12 16:06:42 kai Exp $";
#include <string.h>
#include <syslog.h>
@ -215,6 +215,7 @@ static void ccp_init(int unit)
int ccp_getunit(int linkunit,int protocol)
{
int i;
char proto[64];
if(protocol != PPP_CCP && protocol != PPP_LINK_CCP)
return -1;
@ -227,7 +228,12 @@ int ccp_getunit(int linkunit,int protocol)
ccp_fsm[i].id = 0;
ccp_fsm[i].unit = linkunit;
ccp_fsm[i].protocol = protocol;
syslog(LOG_NOTICE,"CCP: got ccp-unit %d for link %d (protocol: %#x)",i,linkunit,protocol);
switch (protocol) {
case 0x80FD: strcpy(proto, "Compression Control Protocol"); break;
case 0x80FB: strcpy(proto, "Link Compression Control Protocol"); break;
default: sprintf(proto, "protocol: %#x", protocol);
}
syslog(LOG_NOTICE,"CCP: got ccp-unit %d for link %d (%s)",i,linkunit,proto);
return i;
}
}

View File

@ -23,7 +23,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
char lcp_rcsid[] = "$Id: lcp.c,v 1.11 2000/07/25 20:23:51 kai Exp $";
char lcp_rcsid[] = "$Id: lcp.c,v 1.12 2000/11/12 16:06:42 kai Exp $";
/*
* TODO:
@ -2048,7 +2048,7 @@ int lcp_printpkt(u_char *p,int plen,void (*printer)(void*,char*,...),void *arg)
case CI_MPMRRU:
p+=2;
GETSHORT(cishort,p);
printer(arg,"MPmrru 0x%x",cishort);
printer(arg,"MPmrru %d",cishort);
break;
case CI_MPSHORTSEQ:
p+=2;