summaryrefslogtreecommitdiffstats
path: root/src/isode/compat
diff options
context:
space:
mode:
Diffstat (limited to 'src/isode/compat')
-rw-r--r--src/isode/compat/Makefile.in217
-rw-r--r--src/isode/compat/asprintf.c112
-rw-r--r--src/isode/compat/baduser.c88
-rw-r--r--src/isode/compat/bridge.c434
-rw-r--r--src/isode/compat/camtec.c268
-rw-r--r--src/isode/compat/chkpassword.c101
-rw-r--r--src/isode/compat/chrcnv.c82
-rw-r--r--src/isode/compat/cmd_srch.c58
-rw-r--r--src/isode/compat/configure.in2
-rw-r--r--src/isode/compat/dgram.c805
-rw-r--r--src/isode/compat/explode.c69
-rw-r--r--src/isode/compat/general.c162
-rw-r--r--src/isode/compat/getpassword.c144
-rw-r--r--src/isode/compat/hpuxx25.c922
-rw-r--r--src/isode/compat/implode.c80
-rw-r--r--src/isode/compat/inst-man.sh167
-rw-r--r--src/isode/compat/internet.c700
-rw-r--r--src/isode/compat/isoaddrs.c1234
-rw-r--r--src/isode/compat/isofiles.c64
-rw-r--r--src/isode/compat/isohost.c94
-rw-r--r--src/isode/compat/isologs.sh36
-rw-r--r--src/isode/compat/isoman.rf8
-rw-r--r--src/isode/compat/isoservent.c144
-rw-r--r--src/isode/compat/lexequ.c68
-rw-r--r--src/isode/compat/lexnequ.c73
-rw-r--r--src/isode/compat/libicompat.335
-rw-r--r--src/isode/compat/log_tai.c146
-rw-r--r--src/isode/compat/logger.c622
-rw-r--r--src/isode/compat/na2norm.c163
-rw-r--r--src/isode/compat/na2str.c62
-rw-r--r--src/isode/compat/nochrcnv.c81
-rw-r--r--src/isode/compat/norm2na.c287
-rw-r--r--src/isode/compat/pa2str.c107
-rw-r--r--src/isode/compat/putenv.c116
-rw-r--r--src/isode/compat/rcmd_srch.c53
-rw-r--r--src/isode/compat/saddr2str.c59
-rw-r--r--src/isode/compat/sel2str.c98
-rw-r--r--src/isode/compat/select.c389
-rw-r--r--src/isode/compat/serror.c61
-rw-r--r--src/isode/compat/servbyname.c76
-rw-r--r--src/isode/compat/servbyport.c79
-rw-r--r--src/isode/compat/servbysel.c80
-rw-r--r--src/isode/compat/signals.c151
-rw-r--r--src/isode/compat/smalloc.c60
-rw-r--r--src/isode/compat/sprintb.c77
-rw-r--r--src/isode/compat/sstr2arg.c164
-rw-r--r--src/isode/compat/str2elem.c71
-rw-r--r--src/isode/compat/str2saddr.c56
-rw-r--r--src/isode/compat/str2sel.c135
-rw-r--r--src/isode/compat/str2taddr.c56
-rw-r--r--src/isode/compat/str2vec.c105
-rw-r--r--src/isode/compat/strdup.c69
-rw-r--r--src/isode/compat/sunlink.c683
-rw-r--r--src/isode/compat/taddr2str.c59
-rw-r--r--src/isode/compat/tailor.c962
-rw-r--r--src/isode/compat/ubcx25.c320
-rw-r--r--src/isode/compat/ultrix25.c773
-rw-r--r--src/isode/compat/version.major1
-rw-r--r--src/isode/compat/version.minor1
-rw-r--r--src/isode/compat/x25addr.c1476
60 files changed, 13865 insertions, 0 deletions
diff --git a/src/isode/compat/Makefile.in b/src/isode/compat/Makefile.in
new file mode 100644
index 000000000..65a90c74a
--- /dev/null
+++ b/src/isode/compat/Makefile.in
@@ -0,0 +1,217 @@
+###############################################################################
+# Instructions to Make, for compilation of UNIX compatibility library
+###############################################################################
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+BUILDTOP = ../../
+TOPDIR = $(BUILDTOP)
+
+OPTIONS = -I. -I$(HDIR) $(PEPYPATH) $(KRBOPT)
+CFLAGS = $(OPTIONS) $(LOPTIONS)
+
+HDIR = $(TOPDIR)isode/h/
+UTILDIR = $(TOPDIR)isode/util/
+INCDIRM = $(HDIR)
+INCDIR = $(INCDIRM)/
+PEPSYDIRM= $(INCDIR)pepsy
+PEPSYDIR= $(PEPSYDIRM)/
+LIBISODE= $(TOPDIR)libisode.a
+LIBDSAP = $(TOPDIR)libdsap.a
+
+LIBES = libcompat.a
+LLIBS =
+HFILES = $(HDIR)manifest.h $(HDIR)general.h $(HDIR)config.h
+LN = ln
+
+
+##################################################################
+# Here it is...
+##################################################################
+
+all: libcompat
+inst-all: inst-isologs # inst-libcompat manuals
+install: inst-all clean
+lint: l-libcompat
+
+
+################################################################
+# libcompat
+################################################################
+
+CFILES = general.c logger.c select.c signals.c \
+ asprintf.c explode.c implode.c isofiles.c isohost.c sel2str.c \
+ serror.c sprintb.c str2elem.c str2sel.c str2vec.c \
+ tailor.c \
+ baduser.c chkpassword.c getpassword.c putenv.c \
+ chrcnv.c cmd_srch.c lexequ.c lexnequ.c log_tai.c nochrcnv.c \
+ rcmd_srch.c smalloc.c sstr2arg.c strdup.c \
+ isoservent.c servbyname.c servbyport.c servbysel.c \
+ isoaddrs.c str2saddr.c str2taddr.c saddr2str.c taddr2str.c\
+ na2norm.c norm2na.c na2str.c pa2str.c \
+ internet.c \
+ dgram.c \
+ bridge.c camtec.c sunlink.c ubcx25.c \
+ hpuxx25.c ultrix25.c x25addr.c
+OFILES = general.o logger.o select.o signals.o \
+ asprintf.o explode.o implode.o isofiles.o isohost.o sel2str.o \
+ serror.o sprintb.o str2elem.o str2sel.o str2vec.o \
+ tailor.o \
+ baduser.o chkpassword.o getpassword.o putenv.o \
+ chrcnv.o cmd_srch.o lexequ.o lexnequ.o log_tai.o nochrcnv.o \
+ rcmd_srch.o smalloc.o sstr2arg.o strdup.o \
+ isoservent.o servbyname.o servbyport.o servbysel.o \
+ isoaddrs.o str2saddr.o str2taddr.o saddr2str.o taddr2str.o \
+ na2norm.o norm2na.o na2str.o pa2str.o \
+ internet.o \
+ dgram.o \
+ bridge.o camtec.o sunlink.o ubcx25.o \
+ hpuxx25.o ultrix25.o x25addr.o \
+ $(OSTRINGS)
+
+inst-libcompat: $(LIBDIR)libicompat.a $(LINTDIR)llib-licompat
+
+$(LIBDIR)libicompat.a: libcompat.a
+ -rm -f $@
+ cp libcompat.a $@
+ @$(UTILDIR)make-lib.sh $(SYSTEM) $@ -ranlib
+ -@ls -gls $@
+ -@echo ""
+
+$(LINTDIR)llib-licompat: llib-lcompat
+ -cp $@ zllib-lcompat
+ -rm -f $@
+ sed -e 's%#include "\(.*\)"%#include "$(INCDIR)\1"%' \
+ < llib-lcompat | \
+ sed -e 's%#include "/usr/include/\(.*\)"%#include <\1>%' > $@
+ @$(UTILDIR)inst-lint.sh $(SYSTEM) $(OPTIONS) $@
+ -@ls -gls $@ $@.ln
+ -@echo ""
+
+libcompat: libcompat.a
+
+libcompat.a: compatvrsn.o
+ -rm -f $@
+ $(UTILDIR)make-lib.sh $(SYSTEM) $@ $(OFILES) \
+ compatvrsn.o
+ -@rm -f $(TOPDIR)libcompat.a $(TOPDIR)llib-lcompat
+ -@$(LN) libcompat.a $(TOPDIR)libcompat.a || cp libcompat.a $(TOPDIR)libcompat.a
+ -@$(LN) llib-lcompat $(TOPDIR)llib-lcompat
+ -@ls -l $@
+ -@echo "COMPAT library built normally"
+
+compatvrsn.c: $(OFILES)
+ @$(UTILDIR)version.sh compat > $@
+
+l-libcompat:; $(LINT) $(LFLAGS) -DBINPATH=\"$(BINDIR)\" \
+ -DETCPATH=\"$(ETCDIR)\" -DSBINPATH=\"$(SBINDIR)\" \
+ -DLOGPATH=\"$(LOGDIR)\" $(CFILES) compatvrsn.c \
+ | grep -v "warning: possible pointer alignment problem"
+
+general.o: $(HFILES)
+logger.o: $(HFILES) $(HDIR)logger.h $(HDIR)tailor.h
+select.o: $(HFILES) $(HDIR)logger.h $(HDIR)tailor.h
+signals.o: $(HFILES)
+asprintf.o: $(HFILES)
+explode.o: $(HFILES)
+implode.o: $(HFILES)
+isofiles.o: $(HFILES) $(HDIR)tailor.h $(HDIR)logger.h
+isohost.o: $(HFILES) $(HDIR)internet.h $(HDIR)tailor.h $(HDIR)logger.h
+sel2str.o: $(HFILES) $(HDIR)isoaddrs.h
+serror.o: $(HFILES)
+sprintb.o: $(HFILES)
+str2elem.o: $(HFILES)
+str2sel.o: $(HFILES) $(HDIR)tailor.h $(HDIR)logger.h
+str2vec.o: $(HFILES)
+tailor.o: $(HFILES) $(HDIR)isoaddrs.h $(HDIR)tailor.h $(HDIR)logger.h
+ $(CC) $(CFLAGS) -DBINPATH=\"$(BINDIR)\" \
+ -DETCPATH=\"$(ETCDIR)\" -DSBINPATH=\"$(SBINDIR)\" \
+ -DLOGPATH=\"$(LOGDIR)\" -c tailor.c
+baduser.o: $(HFILES) $(HDIR)tailor.h $(HDIR)logger.h
+chkpassword.o: $(HFILES)
+getpassword.o: $(HFILES)
+putenv.o: $(HFILES)
+chrcnv.o: $(HFILES)
+cmd_srch.o: $(HFILES) $(HDIR)cmd_srch.h
+lexequ.o: $(HFILES)
+lexnequ.o: $(HFILES)
+log_tai.o: $(HFILES) $(HDIR)logger.h
+nochrcnv.o: $(HFILES)
+rcmd_srch.o: $(HFILES) $(HDIR)cmd_srch.h
+smalloc.o: $(HFILES) $(HDIR)tailor.h
+sstr2arg.o: $(HFILES)
+strdup.o: $(HFILES)
+isoservent.o: $(HFILES) $(HDIR)isoservent.h $(HDIR)tailor.h $(HDIR)logger.h
+servbyname.o: $(HFILES) $(HDIR)isoservent.h $(HDIR)tailor.h $(HDIR)logger.h
+servbyport.o: $(HFILES) $(HDIR)isoservent.h $(HDIR)tailor.h $(HDIR)logger.h
+servbysel.o: $(HFILES) $(HDIR)isoservent.h $(HDIR)tailor.h $(HDIR)logger.h
+isoaddrs.o: $(HFILES) $(HDIR)isoaddrs.h $(HDIR)internet.h $(HDIR)tailor.h \
+ $(HDIR)logger.h
+str2saddr.o: $(HFILES) $(HDIR)isoaddrs.h
+str2taddr.o: $(HFILES) $(HDIR)isoaddrs.h
+saddr2str.o: $(HFILES) $(HDIR)isoaddrs.h
+taddr2str.o: $(HFILES) $(HDIR)isoaddrs.h
+na2norm.o: $(HFILES) $(HDIR)isoaddrs.h $(HDIR)internet.h $(HDIR)tailor.h \
+ $(HDIR)logger.h
+norm2na.o: $(HDIR)psap.h $(HFILES) $(HDIR)isoaddrs.h $(HDIR)tailor.h \
+ $(HDIR)logger.h
+na2str.o: $(HFILES) $(HDIR)isoaddrs.h
+pa2str.o: $(HFILES) $(HDIR)isoaddrs.h
+internet.o: $(HFILES) $(HDIR)internet.h
+dgram.o: $(HFILES) $(HDIR)tailor.h $(HDIR)logger.h \
+ $(HDIR)dgram.h $(HDIR)internet.h $(HDIR)tp4.h
+bridge.o: $(HFILES) $(HDIR)internet.h $(HDIR)internet.h $(HDIR)tailor.h \
+ $(HDIR)logger.h $(HDIR)tpkt.h $(HDIR)tsap.h
+camtec.o: $(HFILES) $(HDIR)x25.h $(HDIR)tailor.h $(HDIR)logger.h \
+ $(HDIR)tpkt.h $(HDIR)tsap.h
+sunlink.o: $(HFILES) $(HDIR)isoaddrs.h $(HDIR)x25.h $(HDIR)tailor.h \
+ $(HDIR)logger.h
+ubcx25.o: $(HFILES) $(HDIR)x25.h $(HDIR)tailor.h $(HDIR)logger.h \
+ $(HDIR)tpkt.h $(HDIR)tsap.h
+ultrix.o: $(HFILES) $(HDIR)x25.h $(HDIR)tailor.h $(HDIR)logger.h \
+ $(HDIR)tpkt.h $(HDIR)tsap.h
+hpuxx25.o: $(HFILES) $(HDIR)x25.h $(HDIR)tailor.h $(HDIR)logger.h \
+ $(HDIR)tpkt.h $(HDIR)tsap.h
+x25addr.o: $(HFILES) $(HDIR)x25.h $(HDIR)tailor.h $(HDIR)logger.h \
+ $(HDIR)tpkt.h $(HDIR)tsap.h
+
+
+################################################################
+# isologs
+################################################################
+
+inst-isologs: $(SBINDIR)isologs
+
+$(SBINDIR)isologs: isologs.sh Makefile
+ -cp $@ zxisologs
+ -rm -f $@
+ sed -e 's%@(ETCDIR)%$(ETCDIR)%' < isologs.sh | \
+ sed -e 's%@(LOGDIR)%$(LOGDIR)%' > $@
+ chmod a+rx $@
+ -@ls -gls $@
+ -@echo ""
+
+
+################################################################
+# manual pages
+################################################################
+
+MANUALS = libicompat.3
+
+manuals:; @$(UTILDIR)inst-man.sh $(MANOPTS) $(MANUALS)
+ -@echo ""
+
+
+################################################################
+# clean
+################################################################
+
+clean:; rm -f *.o *.a z* _* core compatvrsn.c
+
+grind:; iprint Makefile
+ tgrind -lc $(CFILES) compatvrsn.c llib-lcompat
+ @echo $(MANUALS) | \
+ tr " " "\012" | \
+ sed -e "s%.*%itroff -man &%" | \
+ sh -ve
diff --git a/src/isode/compat/asprintf.c b/src/isode/compat/asprintf.c
new file mode 100644
index 000000000..d27152324
--- /dev/null
+++ b/src/isode/compat/asprintf.c
@@ -0,0 +1,112 @@
+/* asprintf.c - sprintf with errno */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:26:54 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:21 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:28 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:48 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include <varargs.h>
+#include "general.h"
+#include "manifest.h"
+
+/* DATA */
+
+extern int errno;
+
+/* */
+
+void asprintf (bp, ap) /* what, fmt, args, ... */
+char *bp;
+va_list ap;
+{
+ char *what;
+
+ what = va_arg (ap, char *);
+
+ _asprintf (bp, what, ap);
+}
+
+
+void _asprintf (bp, what, ap) /* fmt, args, ... */
+register char *bp;
+char *what;
+va_list ap;
+{
+ register int eindex;
+ char *fmt;
+
+ eindex = errno;
+
+ *bp = NULL;
+ fmt = va_arg (ap, char *);
+
+ if (fmt) {
+#ifndef VSPRINTF
+ struct _iobuf iob;
+#endif
+
+#ifndef VSPRINTF
+#ifdef pyr
+ bzero ((char *) &iob, sizeof iob);
+ iob._file = _NFILE;
+#endif
+ iob._flag = _IOWRT | _IOSTRG;
+#if !defined(vax) && !defined(pyr)
+ iob._ptr = (unsigned char *) bp;
+#else
+ iob._ptr = bp;
+#endif
+ iob._cnt = BUFSIZ;
+ _doprnt (fmt, ap, &iob);
+ putc (NULL, &iob);
+#else
+ (void) vsprintf (bp, fmt, ap);
+#endif
+ bp += strlen (bp);
+
+ }
+
+ if (what) {
+ if (*what) {
+ (void) sprintf (bp, " %s: ", what);
+ bp += strlen (bp);
+ }
+ (void) strcpy (bp, sys_errname (eindex));
+ bp += strlen (bp);
+ }
+
+ errno = eindex;
+}
diff --git a/src/isode/compat/baduser.c b/src/isode/compat/baduser.c
new file mode 100644
index 000000000..9ec4ded03
--- /dev/null
+++ b/src/isode/compat/baduser.c
@@ -0,0 +1,88 @@
+/* baduser.c - check file of bad users */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:26:56 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:23 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:29 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:49 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* */
+
+int baduser (file, user)
+char *file,
+ *user;
+{
+ int hit,
+ tries;
+ register char *bp;
+ char buffer[BUFSIZ];
+ FILE *fp;
+
+ hit = 0;
+ for (tries = 0; tries < 2 && !hit; tries++) {
+ switch (tries) {
+ case 0:
+ if (file) {
+ bp = isodefile (file, 0);
+ break;
+ }
+ tries++;
+ /* and fall */
+ default:
+ bp = "/etc/ftpusers";
+ break;
+ }
+ if ((fp = fopen (bp, "r")) == NULL)
+ continue;
+
+ while (fgets (buffer, sizeof buffer, fp)) {
+ if (bp = index (buffer, '\n'))
+ *bp = NULL;
+ if (strcmp (buffer, user) == 0) {
+ hit++;
+ break;
+ }
+ }
+
+ (void) fclose (fp);
+ }
+
+
+ return hit;
+}
diff --git a/src/isode/compat/bridge.c b/src/isode/compat/bridge.c
new file mode 100644
index 000000000..45fd18179
--- /dev/null
+++ b/src/isode/compat/bridge.c
@@ -0,0 +1,434 @@
+/* bridge.c - X.25 abstractions for TCP bridge to X25 */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ * Contributed by Julian Onions, Nottingham University in the UK
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:26:59 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:25 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:32 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:49 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+#include "internet.h"
+#include "tpkt.h"
+
+/* TCP/X.25 BRIDGE */
+
+#ifdef BRIDGE_X25
+
+
+static int assfd[FD_SETSIZE];
+static char bridge_inited = 0;
+
+/* */
+
+/* ARGSUSED */
+
+int start_bridge_client (local)
+struct NSAPaddr *local;
+{
+ int sd;
+ u_short port;
+ register struct servent *sp;
+
+ if ((sp = getservbyname ("x25bridge", "tcp")) == NULL)
+ port = x25_bridge_port;
+ else
+ port = sp -> s_port;
+
+ if ((sd = in_connect (x25_bridge_host, port)) == NOTOK)
+ return NOTOK;
+
+ if (write_tcp_socket (sd, "\01", 1) != 1) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("initial write"));
+
+ (void) close_tcp_socket (sd);
+ return NOTOK;
+ }
+
+ return sd;
+}
+
+/* */
+
+static int in_connect (addr, port)
+char *addr;
+u_short port;
+{
+ int sd;
+ struct sockaddr_in in_socket;
+ register struct sockaddr_in *isock = &in_socket;
+ register struct hostent *hp;
+
+ if ((hp = gethostbystring (addr)) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP, ("%s: unknown host", addr));
+
+ return NOTOK;
+ }
+
+ bzero ((char *) isock, sizeof *isock);
+ isock -> sin_family = hp -> h_addrtype;
+ isock -> sin_port = port;
+ inaddr_copy (hp, isock);
+
+ if ((sd = start_tcp_client ((struct sockaddr_in *) NULL, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("start_tcp_client"));
+
+ return NOTOK;
+ }
+
+ if (join_tcp_server (sd, isock) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("join_tcp_server"));
+
+ (void) close_tcp_socket (sd);
+ return NOTOK;
+ }
+
+ return sd;
+}
+
+/* */
+
+int join_bridge_server (fd, remote)
+int fd;
+register struct NSAPaddr *remote;
+{
+ if (remote != NULLNA)
+ remote -> na_stack = NA_BRG, remote -> na_community = ts_comm_x25_default;
+ if (bridge_write_nsap_addr (fd, remote, write_tcp_socket) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP, ("write of NSAP failed"));
+
+ return NOTOK;
+ }
+
+ return fd;
+}
+
+/* */
+
+int start_bridge_server (local, backlog, opt1, opt2)
+struct NSAPaddr *local;
+int backlog,
+ opt1,
+ opt2;
+{
+ int len,
+ new,
+ sd;
+ u_short port;
+ struct servent *sp;
+ struct sockaddr_in in_socket;
+ register struct sockaddr_in *isock = &in_socket;
+
+ if (bridge_inited == 0) {
+ for (sd = 0; sd < FD_SETSIZE; sd++)
+ assfd[sd] = NOTOK;
+ bridge_inited = 1;
+ }
+ if ((sp = getservbyname ("x25bridge", "tcp")) == NULL)
+ port = x25_bridge_port;
+ else
+ port = sp -> s_port;
+
+ if ((sd = in_connect (x25_bridge_host, port)) == NOTOK)
+ return NOTOK;
+
+ if (write_tcp_socket (sd, "\02", 1) != 1) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("initial write"));
+
+ (void) close_tcp_socket (sd);
+ return NOTOK;
+ }
+
+ if (local != NULLNA)
+ local -> na_stack = NA_BRG, local -> na_community = ts_comm_x25_default;
+ if (local != NULLNA && local -> na_dtelen == 0)
+ {
+ (void) strcpy (local -> na_dte, x25_bridge_addr);
+ local -> na_dtelen = strlen(x25_bridge_addr);
+ }
+ if (local != NULLNA) {
+ DLOG (compat_log, LLOG_DEBUG,
+ ("addr", "type=%d '%s' len=%d",
+ local -> na_stack, local -> na_dte,local -> na_dtelen));
+ DLOG (compat_log, LLOG_DEBUG,
+ ("addr", "pid='%s'(%d) fac='%s'(%d) cudf='%s'(%d)",
+ local -> na_pid, local -> na_pidlen,
+ local -> na_fac, local -> na_faclen,
+ local -> na_pid, local -> na_pidlen,
+ local -> na_cudf, local -> na_cudflen));
+ }
+
+ if (bridge_write_nsap_addr (sd, local, write_tcp_socket) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP, ("write of NSAP failed"));
+
+ (void) close_tcp_socket (sd);
+ return NOTOK;
+ }
+
+ if ((new = in_listen (backlog, opt1, opt2)) == NOTOK) {
+ (void) close_tcp_socket (sd);
+ return NOTOK;
+ }
+
+ len = sizeof *isock;
+ if (getsockname (new, (struct sockaddr *) isock, &len) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("getsockname"));
+
+out: ;
+ (void) close_tcp_socket (sd);
+ (void) close_tcp_socket (new);
+ return NOTOK;
+ }
+
+ isock -> sin_family = htons (isock -> sin_family);
+ if (write_tcp_socket (sd, (char *)isock, sizeof *isock) != sizeof *isock) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("write of sockaddr_in"));
+
+ goto out;
+ }
+ assfd[new] = sd;
+
+ return new;
+}
+
+int get_bridge_assfd(fd)
+int fd;
+{
+ if (!bridge_inited)
+ return NOTOK;
+ return assfd[fd];
+}
+
+/* */
+
+static int in_listen (backlog, opt1, opt2)
+int backlog,
+ opt1,
+ opt2;
+{
+ int sd;
+ char *cp;
+ struct sockaddr_in lo_socket;
+ register struct sockaddr_in *lsock = &lo_socket;
+ register struct hostent *hp;
+
+ if ((hp = gethostbystring (cp = getlocalhost ())) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP, ("%s: unknown host", cp));
+
+ return NOTOK;
+ }
+
+ bzero ((char *) lsock, sizeof *lsock);
+ lsock -> sin_family = hp -> h_addrtype;
+ inaddr_copy (hp, lsock);
+
+ if ((sd = start_tcp_server (lsock, backlog, opt1, opt2)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("start_tcp_server"));
+
+ return NOTOK;
+ }
+
+ return sd;
+}
+
+/* */
+
+int join_bridge_client (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ int new;
+ struct sockaddr_in in_socket;
+ struct NSAPaddr sock;
+
+ if ((new = join_tcp_client (fd, &in_socket)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("join_tcp_client"));
+
+ return NOTOK;
+ }
+
+ if (bridge_read_nsap_addr (new, &sock, read_tcp_socket) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("read of NSAP"));
+
+ (void) close_tcp_socket (new);
+ return NOTOK;
+ }
+ DLOG (compat_log, LLOG_DEBUG,
+ ("addr", "type=%d '%s' len=%d", sock.na_stack, sock.na_dte,
+ sock.na_dtelen));
+ DLOG (compat_log, LLOG_DEBUG,
+ ("addr", "pid='%s'(%d) fac='%s'(%d) cudf='%s'(%d)",
+ sock.na_pid, sock.na_pidlen,
+ sock.na_fac, sock.na_faclen,
+ sock.na_pid, sock.na_pidlen,
+ sock.na_cudf, sock.na_cudflen));
+ sock.na_stack = ntohl (sock.na_stack);
+ *remote = sock;
+ DLOG (compat_log, LLOG_DEBUG,
+ ("addr", "type=%d '%s' len=%d",
+ remote -> na_stack, remote -> na_dte,remote -> na_dtelen));
+ DLOG (compat_log, LLOG_DEBUG,
+ ("addr", "pid='%s'(%d) fac='%s'(%d) cudf='%s'(%d)",
+ remote -> na_pid, remote -> na_pidlen,
+ remote -> na_fac, remote -> na_faclen,
+ remote -> na_pid, remote -> na_pidlen,
+ remote -> na_cudf, remote -> na_cudflen));
+ return new;
+}
+
+int close_bridge_socket (sd)
+int sd;
+{
+ if (bridge_inited && assfd[sd] != NOTOK)
+ (void) close_tcp_socket (assfd[sd]);
+ assfd[sd] = NOTOK;
+ return close_tcp_socket (sd);
+}
+
+/* ARGSUSED */
+
+int bridgediscrim (na)
+struct NSAPaddr *na;
+{
+#ifndef X25
+ return 1; /* must be bridge */
+#else
+ int len = strlen (x25_bridge_discrim);
+
+ if (len == 1 && *x25_bridge_discrim == '-')
+ return 0;
+
+ return (len == 0 ? 1
+ : strncmp (na -> na_dte, x25_bridge_discrim, len) == 0);
+#endif
+}
+#endif
+
+/*
+ * Structure is as follows :-
+ * 0-1 type
+ * 2-17 dte
+ * 18 dte len
+ * 19-22 pid
+ * 23 pid len
+ * 24-39 user data
+ * 40 user data len
+ * 41-46 facilities
+ * 47 facility length
+ */
+
+int bridge_write_nsap_addr (fd, nsap, writefnx)
+int fd;
+struct NSAPaddr *nsap;
+IFP writefnx;
+{
+ u_short na_stack;
+ char buffer[50];
+
+ if (nsap == NULLNA || (na_stack = nsap -> na_stack) != NA_BRG)
+ return NOTOK;
+ na_stack = htons(na_stack);
+ bcopy ((char *)&na_stack, buffer, sizeof(na_stack));
+ bcopy (nsap -> na_dte, &buffer[2], 16);
+ buffer[18] = nsap -> na_dtelen;
+ bcopy (nsap -> na_pid, &buffer[19], 4);
+ buffer[23] = nsap -> na_pidlen;
+ bcopy (nsap -> na_cudf, &buffer[24], 16);
+ buffer[40] = nsap -> na_cudflen;
+ bcopy (nsap -> na_fac, &buffer[41], 6);
+ buffer[47] = nsap -> na_faclen;
+ if ((*writefnx) (fd, buffer, 48) != 48)
+ return NOTOK;
+ return OK;
+}
+
+static int readx ();
+
+int bridge_read_nsap_addr (fd, nsap, readfnx)
+int fd;
+struct NSAPaddr *nsap;
+IFP readfnx;
+{
+ u_short na_stack;
+ char buffer[50];
+
+ if (readx (fd, buffer, 48, readfnx) != 48)
+ return NOTOK;
+ bcopy (buffer, (char *)&na_stack, sizeof(na_stack));
+ na_stack = ntohs(na_stack);
+ if (na_stack != NA_BRG)
+ return NOTOK;
+ nsap -> na_stack = na_stack;
+ bcopy (&buffer[2], nsap -> na_dte, 16);
+ nsap -> na_dtelen = buffer[18];
+ bcopy (&buffer[19], nsap -> na_pid, 4);
+ nsap -> na_pidlen = buffer[23];
+ bcopy (&buffer[24], nsap -> na_cudf, 16);
+ nsap -> na_cudflen = buffer[40];
+ bcopy (&buffer[41], nsap -> na_fac, 6);
+ nsap -> na_faclen = buffer[47];
+ return OK;
+}
+
+static int readx (fd, buffer, n, readfnx)
+int fd;
+char *buffer;
+int n;
+IFP readfnx;
+{
+ register int i,
+ cc;
+ register char *bp;
+
+ for (bp = buffer, i = n; i > 0; bp += cc, i -= cc) {
+ switch (cc = (*readfnx) (fd, bp, i)) {
+ case NOTOK:
+ return (i = bp - buffer) ? i : NOTOK;
+
+ case OK:
+ break;
+
+ default:
+ continue;
+ }
+ break;
+ }
+
+ return (bp - buffer);
+}
diff --git a/src/isode/compat/camtec.c b/src/isode/compat/camtec.c
new file mode 100644
index 000000000..20e251bec
--- /dev/null
+++ b/src/isode/compat/camtec.c
@@ -0,0 +1,268 @@
+/* camtec.c - X.25, CONS abstractions for CAMTEC CCL */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ * Contributed by Keith Ruttle, CAMTEC Electronics Ltd
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:01 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:27 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:34 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:50 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+#ifdef X25
+
+#include "x25.h"
+#include "isoaddrs.h"
+
+
+#ifdef CAMTEC_CCL
+
+#include "tailor.h"
+#include "tpkt.h"
+
+/* 4.[23] UNIX: CCL X25 */
+
+
+static char calling_dte[NSAP_DTELEN + 1];
+
+/* */
+
+int start_x25_client (local)
+struct NSAPaddr *local;
+{
+ int sd, pgrp;
+ CONN_DB l_iov;
+
+ if (local != NULLNA)
+ local -> na_stack = NA_X25, local -> na_community = ts_comm_x25_default;
+ if ((sd = socket (AF_CCL, SOCK_STREAM, CCLPROTO_X25)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ l_iov.ccl_iovec[0].iov_base = calling_dte;
+ gen2if(local, &l_iov, ADDR_LOCAL);
+
+ return sd;
+}
+
+/* */
+
+int start_x25_server (local, backlog, opt1, opt2)
+struct NSAPaddr *local;
+int backlog,
+ opt1,
+ opt2;
+{
+ int sd, pgrp;
+ CONN_DB b_iov;
+ char param1[128];
+
+ b_iov.ccl_iovec[0].iov_base = param1;
+
+ if ((sd = socket (AF_CCL, SOCK_STREAM, CCLPROTO_X25)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK; /* Can't get an X.25 socket */
+ }
+
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ if (local != NULLNA) {
+ local -> na_stack = NA_X25, local -> na_community = ts_comm_x25_default;
+ if (local -> na_dtelen == 0) {
+ (void) strcpy (local -> na_dte, x25_local_dte);
+ local -> na_dtelen = strlen(x25_local_dte);
+ if (local -> na_pidlen == 0 && *x25_local_pid)
+ local -> na_pidlen =
+ str2sel (x25_local_pid, -1, local -> na_pid, NPSIZE);
+ }
+ }
+
+ (void) gen2if (local, &b_iov, ADDR_LISTEN);
+ if (bind (sd, &b_iov, sizeof(b_iov)) != NOTOK) {
+ if (ioctl(sd, CCL_AUTO_ACCEPT, 1) < 0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("CCL_AUTO_ACCEPT"));
+ close (sd);
+ return NOTOK;
+ }
+ (void) listen (sd, backlog);
+ return sd;
+ }
+
+ (void) close (sd);
+ return NOTOK;
+}
+
+/* */
+
+int join_x25_client (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB sck;
+ struct iovec *iov;
+ int i, len = 0;
+ int nfd;
+ char param1[128];
+ char param2[128];
+ char param3[128];
+ char param4[256];
+
+ iov = &(sck.ccl_iovec[0]);
+ if((nfd = accept (fd, (char *) 0, &len)) == NOTOK)
+ return NOTOK;
+ iov[0].iov_base = param1;
+ iov[1].iov_base = param2;
+ iov[2].iov_base = param3;
+ iov[3].iov_base = param4;
+ iov[0].iov_len = iov[1].iov_len = iov[2].iov_len = 128;
+ iov[3].iov_len = 256;
+ iov[4].iov_len = iov[5].iov_len = iov[6].iov_len = 0;
+ if (ioctl(nfd, CCL_FETCH_CONNECT, &iov[0]) < 0)
+ return NOTOK;
+ (void) if2gen (remote, &sck, ADDR_REMOTE);
+ ioctl (nfd, CCL_SEND_TYPE, 0);
+ return nfd;
+}
+
+int join_x25_server (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB zsck;
+ CONN_DB *sck = &zsck;
+ int r;
+ struct iovec *iov = &( zsck.ccl_iovec[0] );
+ char param1[128];
+ char param3[128];
+ char param4[256];
+
+ if (remote == NULLNA || remote -> na_stack != NA_X25)
+ {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("Invalid type na%d", remote->na_stack));
+ return NOTOK;
+ }
+
+ iov[0].iov_base = param1;
+ iov[1].iov_base = calling_dte;
+ iov[1].iov_len = strlen(calling_dte);
+ iov[2].iov_base = param3;
+ iov[3].iov_base = param4;
+ iov[4].iov_len = iov[5].iov_len = iov[6].iov_len = 0;
+
+ (void) gen2if (remote, sck, ADDR_REMOTE);
+ if ((r = connect (fd, sck, sizeof (CONN_DB))) >= 0)
+ ioctl (fd, CCL_SEND_TYPE, 0);
+ bzero(calling_dte, sizeof calling_dte );
+ return (r);
+}
+
+int read_x25_socket (fd, buffer, len)
+int fd, len;
+char *buffer;
+{
+ static u_char mode;
+ int cc, count = 0, total = len;
+ char *p = buffer;
+
+ do {
+ cc = recv (fd, p, total, 0);
+ switch (cc) {
+ case NOTOK:
+ if (errno == ECONNRESET) {
+ struct iovec iov[7];
+ char parm[34];
+ int i;
+ iov[0].iov_base = parm;
+ iov[0].iov_len = 1;
+ iov[1].iov_base = parm + 1;
+ iov[1].iov_len = 32;
+ for (i = 2; i < 7; i++) {
+ iov[i].iov_base = (char *)0;
+ iov[i].iov_len = 0;
+ }
+ ioctl(fd, CCL_FETCH_RESET, iov);
+ elucidate_x25_err( 1 << RECV_DIAG, iov[0].iov_base);
+ }
+ case 0:
+ return cc;
+
+ default:
+ ioctl (fd, CCL_RECV_TYPE, &mode);
+ count += cc;
+ p += cc;
+ total -= cc;
+ break;
+ }
+ } while (total > 0 && (mode & MORE_DATA));
+
+ DLOG (compat_log, LLOG_DEBUG,
+ ("X25 read, total %d", count ));
+ return count;
+}
+
+int write_x25_socket (fd, buffer, len)
+int fd, len;
+char *buffer;
+{
+ int count;
+ int cc;
+
+ count = send(fd, buffer, len, 0);
+ DLOG (compat_log, LLOG_DEBUG,
+ ("X25 write, total %d/%d", count, len));
+ return count;
+}
+#else /* CAMTEC_CCL */
+int _camtec_sunlink_stub2 () {}
+#endif /* CAMTEC_CCL */
+#else /* X25 */
+int _camtec_sunlink_stub () {}
+#endif /* X25 */
diff --git a/src/isode/compat/chkpassword.c b/src/isode/compat/chkpassword.c
new file mode 100644
index 000000000..bbb54124a
--- /dev/null
+++ b/src/isode/compat/chkpassword.c
@@ -0,0 +1,101 @@
+/* chkpassword.c - check the password */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:03 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:30 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:35 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:50 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+
+char *crypt ();
+
+
+#ifdef KRB_PASSWD
+#include <krb.h>
+#endif
+
+/* L.McLoughlin added kerberos passwd checking - based on original
+ * code from xnlock by S. Lacey.
+ * Takes the username, the password from the password file, and the passwd
+ * the user is trying to use.
+ * Returns 1 if the passwd matches otherwise 0.
+ */
+
+#ifndef KRB_PASSWD
+/* ARGSUSED */
+#endif
+
+int chkpassword ( usrname, pwpass, usrpass )
+char *usrname;
+char *pwpass;
+char *usrpass;
+{
+#ifdef KRB_PASSWD
+ char realm[REALM_SZ];
+ int krbval;
+
+ /*
+ * check to see if the passwd is `*krb*'
+ * if it is, use kerberos
+ */
+
+ if (strcmp(pwpass, "*krb*") == 0) {
+ /*
+ * use kerberos, first of all find the realm
+ */
+ if (krb_get_lrealm(realm, 1) != KSUCCESS) {
+ (void) strncpy(realm, KRB_REALM, sizeof(realm));
+ }
+
+ /*
+ * now check the passwd
+ */
+ krbval = krb_get_pw_in_tkt(usrname, "",
+ realm, "krbtgt",
+ realm,
+ DEFAULT_TKT_LIFE, usrpass);
+
+ return (krbval == INTK_OK);;
+ }
+#endif
+
+ /*
+ * use passwd file password
+ */
+ return (strcmp(crypt(usrpass, pwpass), pwpass) == 0);
+}
diff --git a/src/isode/compat/chrcnv.c b/src/isode/compat/chrcnv.c
new file mode 100644
index 000000000..ec53a1a05
--- /dev/null
+++ b/src/isode/compat/chrcnv.c
@@ -0,0 +1,82 @@
+/* chrcnv.c - character conversion table */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:05 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:32 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:37 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:51 isode
+ * Release 7.0
+ *
+ *
+ */
+
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+
+/* */
+
+char /* character conversion table */
+ chrcnv[] = /* lower to upper case letters */
+{
+ '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7',
+ '\10', '\t', '\n', '\13', '\14', '\r', '\16', '\17',
+ '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27',
+ '\30', '\31', '\32', '\33', '\34', '\35', '\36', '\37',
+ ' ', '!', '"', '#', '$', '%', '&', '\47',
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
+ '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7',
+ '\10', '\t', '\n', '\13', '\14', '\r', '\16', '\17',
+ '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27',
+ '\30', '\31', '\32', '\33', '\34', '\35', '\36', '\37',
+ ' ', '!', '"', '#', '$', '%', '&', '\47',
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '{', '|', '}', '~', '\177'
+};
+
diff --git a/src/isode/compat/cmd_srch.c b/src/isode/compat/cmd_srch.c
new file mode 100644
index 000000000..7266d81ff
--- /dev/null
+++ b/src/isode/compat/cmd_srch.c
@@ -0,0 +1,58 @@
+/* cmd_srch.c - search a lookup table: return numeric value */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:07 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:34 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:38 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:51 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include "manifest.h"
+#include "cmd_srch.h"
+
+/* */
+
+/* map a string onto a value */
+
+cmd_srch(str, cmd)
+register char *str;
+register CMD_TABLE *cmd;
+{
+ extern char chrcnv[];
+
+ for(;cmd->cmd_key != NULLCP; cmd++)
+ if(chrcnv[*str] == chrcnv[*cmd->cmd_key] &&
+ lexequ(str, cmd->cmd_key) == 0)
+ return(cmd->cmd_value);
+ return(cmd->cmd_value);
+}
diff --git a/src/isode/compat/configure.in b/src/isode/compat/configure.in
new file mode 100644
index 000000000..cdff2db09
--- /dev/null
+++ b/src/isode/compat/configure.in
@@ -0,0 +1,2 @@
+AC_INIT(configure.in)
+AC_OUTPUT(Makefile)
diff --git a/src/isode/compat/dgram.c b/src/isode/compat/dgram.c
new file mode 100644
index 000000000..7c15fb247
--- /dev/null
+++ b/src/isode/compat/dgram.c
@@ -0,0 +1,805 @@
+/* dgram.c - datagram (CL-mode TS) abstractions */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:11 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:37 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:42 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:52 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+#include "dgram.h"
+#ifdef TCP
+#include "internet.h"
+#endif
+#ifdef TP4
+#include "tp4.h"
+#endif
+
+
+#if defined(SOCKETS) && (defined(TCP) || defined(CLTS))
+#ifndef DEBUG
+#define action(s,f,i)
+#else
+static action ();
+#endif
+
+extern int errno;
+extern IFP set_check_fd ();
+
+/* */
+
+union sockaddr_un { /* 'cause sizeof (struct sockaddr_iso) == 32 */
+ struct sockaddr sa;
+
+#ifdef TCP
+ struct sockaddr_in sin;
+#endif
+
+#ifdef BSD_TP4
+ union sockaddr_osi sosi;
+#endif
+};
+
+
+struct dgramblk {
+ int dgram_parent;
+ union sockaddr_un dgram_peer;
+#ifdef BSD44
+ u_char dgram_addrlen;
+#endif
+
+ struct qbuf dgram_queue;
+};
+
+
+static int maxpeers = 0;
+static struct dgramblk *peers = NULL;
+
+/* */
+
+#ifdef TCP
+
+/* ARGSUSED */
+
+int start_udp_server (sock, backlog, opt1, opt2)
+struct sockaddr_in *sock;
+int backlog,
+ opt1,
+ opt2;
+{
+ register int port;
+ int sd;
+#ifdef BSD43
+ int onoff;
+#endif
+ register struct dgramblk *up,
+ *vp;
+
+ if (peers == NULL) {
+ maxpeers = getdtablesize ();
+ peers = (struct dgramblk *) calloc ((unsigned)maxpeers, sizeof *peers);
+ if (peers == NULL)
+ return NOTOK;
+
+ for (vp = (up = peers) + maxpeers; up < vp; up++) {
+ up -> dgram_parent = NOTOK;
+ up -> dgram_queue.qb_forw = up -> dgram_queue.qb_back =
+ &up -> dgram_queue;
+ }
+ }
+
+ if ((sd = socket (AF_INET, SOCK_DGRAM, 0)) == NOTOK)
+ return NOTOK;
+
+ if (sock -> sin_port != 0) {
+ action ("BIND", sd, (struct sockaddr *) sock);
+
+ if (bind (sd, (struct sockaddr *) sock, sizeof *sock) != NOTOK)
+ goto got_socket;
+
+ (void) close (sd);
+ return NOTOK;
+ }
+ else
+ sock -> sin_family = AF_INET;
+
+ for (port = IPPORT_RESERVED;; port++) {
+ sock -> sin_port = htons ((u_short) port);
+
+ action ("BIND", sd, (struct sockaddr *) sock);
+
+ if (bind (sd, (struct sockaddr *) sock, sizeof *sock) != NOTOK)
+ break;
+
+ switch (errno) {
+ case EADDRINUSE:
+ continue;
+
+ case EADDRNOTAVAIL:
+ default:
+ (void) close (sd);
+ return NOTOK;
+ }
+ }
+
+got_socket: ;
+#ifdef DEBUG
+ {
+ int len = sizeof *sock;
+
+ action ("FOO1", sd, (struct sockaddr *) sock);
+ if (getsockname (sd, (struct sockaddr *) sock, &len) != NOTOK)
+ action ("FOO2", sd, (struct sockaddr *) sock);
+ }
+#endif
+
+#ifndef BSD43
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, NULLCP, 0);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, NULLCP, 0);
+#else
+ onoff = 1;
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, (char *)&onoff, sizeof onoff);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, (char *)&onoff, sizeof onoff);
+#endif
+
+ (void) set_check_fd (sd, check_dgram_socket, NULLCP);
+ return (peers[sd].dgram_parent = sd);
+}
+#endif
+
+/* */
+
+#ifdef BSD_TP4
+
+/* ARGSUSED */
+
+int start_clts_server (sock, backlog, opt1, opt2)
+union sockaddr_osi *sock;
+int backlog,
+ opt1,
+ opt2;
+{
+ int sd;
+#ifdef BSD43
+ int onoff;
+#endif
+ u_char *cp;
+ register struct dgramblk *up,
+ *vp;
+ struct sockaddr_iso *ifaddr = &sock -> osi_sockaddr;
+
+ if (peers == NULL) {
+ maxpeers = getdtablesize ();
+ peers = (struct dgramblk *) calloc ((unsigned)maxpeers, sizeof *peers);
+ if (peers == NULL)
+ return NOTOK;
+
+ for (vp = (up = peers) + maxpeers; up < vp; up++) {
+ up -> dgram_parent = NOTOK;
+ up -> dgram_queue.qb_forw = up -> dgram_queue.qb_back =
+ &up -> dgram_queue;
+ }
+ }
+
+ if ((sd = socket (AF_ISO, SOCK_DGRAM, 0)) == NOTOK)
+ return NOTOK;
+
+ if (ifaddr -> siso_tlen != 0) {
+ action ("BIND", sd, (struct sockaddr *) ifaddr);
+
+ if (bind (sd, (struct sockaddr *) ifaddr, (int) ifaddr -> siso_len)
+ != NOTOK)
+ goto got_socket;
+
+ (void) close (sd);
+ return NOTOK;
+ }
+ else
+ ifaddr -> siso_family = AF_ISO;
+
+ {
+ int pid;
+ u_char *dp,
+ *ep,
+ *fp;
+
+ pid = getpid ();
+ cp = fp = (u_char *) ifaddr -> siso_data + ifaddr -> siso_nlen;
+ for (ep = (dp = (u_char *) &pid) + sizeof pid; dp < ep; dp++)
+ *cp++ = *dp;
+ ifaddr -> siso_tlen = (cp - fp) + 1;
+ ifaddr -> siso_slen = ifaddr -> siso_plen = 0;
+ ifaddr -> siso_len = sizeof *ifaddr;
+ }
+
+ for (*cp = 0x00; *cp < 0xff; *cp += 1) {
+ action ("BIND", sd, (struct sockaddr *) ifaddr);
+
+ if (bind (sd, (struct sockaddr *) ifaddr, (int) ifaddr -> siso_len)
+ != NOTOK)
+ goto got_socket;
+
+ switch (errno) {
+ case EADDRINUSE:
+ continue;
+
+ case EADDRNOTAVAIL:
+ default:
+ (void) close (sd);
+ return NOTOK;
+ }
+ }
+ (void) close (sd);
+ errno = EADDRNOTAVAIL;
+ return NOTOK;
+
+got_socket: ;
+#ifdef DEBUG
+ {
+ int len = sizeof *sock;
+
+ action ("FOO1", sd, ifaddr);
+ if (getsockname (sd, (struct sockaddr *) ifaddr, &len) != NOTOK)
+ action ("FOO2", sd, ifaddr);
+ }
+#endif
+
+#ifndef BSD43
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, NULLCP, 0);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, NULLCP, 0);
+#else
+ onoff = 1;
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, (char *)&onoff, sizeof onoff);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, (char *)&onoff, sizeof onoff);
+#endif
+
+ (void) set_check_fd (sd, check_dgram_socket, NULLCP);
+ return (peers[sd].dgram_parent = sd);
+}
+#endif
+
+/* */
+
+int join_dgram_aux (fd, sock, newfd)
+int fd,
+ newfd;
+struct sockaddr *sock;
+{
+ int nfds,
+ sd;
+ fd_set ifds;
+ register struct qbuf *qb;
+ register struct dgramblk *up;
+
+ if (fd < 0 || fd >= maxpeers || peers[fd].dgram_parent != fd) {
+ errno = EINVAL;
+ return NOTOK;
+ }
+
+ if (newfd) {
+ FD_ZERO (&ifds);
+
+ nfds = fd + 1;
+ FD_SET (fd, &ifds);
+ if (select_dgram_socket (nfds, &ifds, NULLFD, NULLFD, OK) == NOTOK)
+ return NOTOK;
+
+ up = &peers[fd];
+ if ((qb = up -> dgram_queue.qb_forw) == &up -> dgram_queue) {
+ errno = EWOULDBLOCK;
+ return NOTOK;
+ }
+
+ if ((sd = dup (fd)) == NOTOK)
+ return NOTOK;
+ (void) set_check_fd (fd, check_dgram_socket, NULLCP);
+
+ up = &peers[sd];
+#ifdef BSD44
+ bcopy (qb -> qb_base, (caddr_t) sock,
+ ((struct sockaddr *) qb -> qb_base) -> sa_len);
+#else
+ *sock = *((struct sockaddr *) qb -> qb_base); /* struct copy */
+#endif
+
+ remque (qb);
+ insque (qb, up -> dgram_queue.qb_back);
+ }
+ else
+ up = &peers[fd];
+
+ up -> dgram_parent = fd;
+#ifdef BSD44
+ if (sock -> sa_len == 0)
+ sock -> sa_len = sizeof *sock;
+ bcopy ((caddr_t) sock, (caddr_t) &up -> dgram_peer, sock -> sa_len);
+ {
+ struct sockaddr_in *sin;
+
+ up -> dgram_addrlen = sock -> sa_family != AF_INET ? sock -> sa_len
+ : sizeof *sin - sizeof sin -> sin_zero;
+ }
+#else
+ up -> dgram_peer.sa = *sock; /* struct copy */
+#endif
+
+ action ("JOIN", newfd ? sd : fd, sock);
+
+ return (newfd ? sd : OK);
+}
+
+/* */
+
+int read_dgram_socket (fd, q)
+int fd;
+struct qbuf **q;
+{
+ int nfds;
+ fd_set ifds,
+ mask;
+ register struct qbuf *qb;
+ register struct dgramblk *up;
+
+ if (fd < 0
+ || fd >= maxpeers
+ || (up = &peers[fd]) -> dgram_parent == NOTOK) {
+ errno = EINVAL;
+ return NOTOK;
+ }
+
+ if ((qb = up -> dgram_queue.qb_forw) == &up -> dgram_queue) {
+ FD_ZERO (&mask);
+
+ nfds = fd + 1;
+ FD_SET (fd, &mask);
+ for (ifds = mask;; ifds = mask) {
+ if (select_dgram_socket (nfds, &ifds, NULLFD, NULLFD, NOTOK)
+ == NOTOK)
+ return NOTOK;
+
+ if ((qb = up -> dgram_queue.qb_forw) != &up -> dgram_queue)
+ break;
+ }
+ }
+
+ remque (qb);
+ qb -> qb_forw = qb -> qb_back = qb;
+
+ *q = qb;
+
+ return qb -> qb_len;
+}
+
+/* */
+
+int hack_dgram_socket (fd, sock)
+int fd;
+struct sockaddr *sock;
+{
+ register struct dgramblk *up;
+
+ if (fd < 0
+ || fd >= maxpeers
+ || (up = &peers[fd]) -> dgram_parent != fd) {
+ errno = EINVAL;
+ return NOTOK;
+ }
+
+ if (sock == NULL) {
+ bzero ((caddr_t) &up -> dgram_peer, sizeof up -> dgram_peer);
+ return OK;
+ }
+
+#ifdef BSD44
+ if (sock -> sa_len == 0)
+ sock -> sa_len = sizeof *sock;
+ bcopy ((caddr_t) sock, (caddr_t) &up -> dgram_peer, sock -> sa_len);
+ up -> dgram_addrlen = 0;
+#else
+ up -> dgram_peer.sa = *sock; /* struct copy */
+#endif
+
+ action ("HACK", fd, sock);
+
+ return OK;
+}
+
+
+int write_dgram_socket (fd, qb)
+int fd;
+register struct qbuf *qb;
+{
+ register struct dgramblk *up;
+
+ if (fd < 0
+ || fd >= maxpeers
+ || (up = &peers[fd]) -> dgram_parent == NOTOK
+ || up -> dgram_peer.sa.sa_family == 0) {
+ errno = EINVAL;
+ return NOTOK;
+ }
+
+ action ("SENDTO", fd, &up -> dgram_peer.sa);
+
+#ifdef BSD44
+ return sendto (fd, qb -> qb_data, qb -> qb_len, NULL,
+ &up -> dgram_peer.sa, (int) up -> dgram_peer.sa.sa_len);
+#else
+ return sendto (fd, qb -> qb_data, qb -> qb_len, NULL,
+ &up -> dgram_peer.sa, sizeof up -> dgram_peer.sa);
+#endif
+}
+
+
+/* */
+
+int close_dgram_socket (fd)
+int fd;
+{
+ register struct dgramblk *up,
+ *vp;
+
+ if (fd < 0
+ || fd >= maxpeers
+ || (up = &peers[fd]) -> dgram_parent == NOTOK) {
+ errno = EINVAL;
+ return NOTOK;
+ }
+
+ action ("CLOSE", fd, &up -> dgram_peer.sa);
+
+ up -> dgram_parent = NOTOK;
+ bzero ((char *) &up -> dgram_peer, sizeof up -> dgram_peer);
+ QBFREE (&up -> dgram_queue);
+
+ for (vp = (up = peers) + maxpeers; up < vp; up++)
+ if (up -> dgram_parent == fd)
+ up -> dgram_parent = up - peers;
+
+ (void) set_check_fd (fd, NULLIFP, NULLCP);
+ return close (fd);
+}
+
+/* */
+
+int select_dgram_socket (nfds, rfds, wfds, efds, secs)
+int nfds;
+fd_set *rfds,
+ *wfds,
+ *efds;
+int secs;
+{
+ register int fd;
+ int cc,
+ mfds,
+ result;
+ fd_set ifds,
+ jfds;
+ register struct qbuf *qb;
+ register struct dgramblk *up,
+ *vp;
+ struct dgramblk *wp;
+ union sockaddr_un *sock;
+
+ if (rfds) {
+ jfds = *rfds;
+
+ if (secs != OK)
+ for (vp = (up = peers) + maxpeers, fd = 0; up < vp; up++, fd++)
+ if (up -> dgram_parent != NOTOK
+ && FD_ISSET (fd, &jfds)
+ && up -> dgram_queue.qb_forw != &up -> dgram_queue) {
+ secs = OK;
+ break;
+ }
+ }
+
+ if ((result = selsocket (nfds, rfds, wfds, efds, secs)) == NOTOK
+ || rfds == NULLFD)
+ return result;
+
+ ifds = *rfds;
+ if ((mfds = nfds) > maxpeers)
+ mfds = maxpeers;
+ for (fd = 0, up = peers; fd < mfds; fd++, up++)
+ if (FD_ISSET (fd, &ifds)) {
+ int slen;
+ u_char len;
+ char *data;
+
+ FD_CLR (fd, &ifds);
+
+ if (up -> dgram_parent == NOTOK)
+ continue;
+
+ if ((qb = (struct qbuf *) malloc ((unsigned) (sizeof *qb
+ + (slen
+ = sizeof *sock)
+ + MAXDGRAM)))
+ == NULL)
+ return NOTOK;
+
+ sock = (union sockaddr_un *) qb -> qb_base;
+ qb -> qb_data = qb -> qb_base + slen;
+ if ((cc = recvfrom (fd, qb -> qb_data, MAXDGRAM, NULL,
+ &sock -> sa, &slen)) == NOTOK) {
+ free ((char *) qb);
+ return NOTOK;
+ }
+#ifdef BSD44
+ sock -> sa.sa_len = slen;
+#endif
+ qb -> qb_len = cc;
+
+ action ("RECVFROM", fd, &sock -> sa);
+
+ vp = up;
+ data = sock -> sa.sa_data;
+ switch (sock -> sa.sa_family) {
+ case AF_INET: /* XXX: doesn't take into account padding */
+ len = sizeof sock -> sa.sa_data
+ - sizeof sock -> sin.sin_zero;
+ break;
+
+ default:
+#ifdef BSD44
+ len = sock -> sa.sa_len;
+#else
+ len = sizeof sock -> sa;
+#endif
+ break;
+ }
+ if (
+#ifdef BSD44
+ len != up -> dgram_addrlen ||
+#endif
+ bcmp (data, up -> dgram_peer.sa.sa_data, (int) len)
+ != 0) {
+ for (wp = (vp = peers) + maxpeers; vp < wp; vp++)
+ if (vp != up
+ && vp -> dgram_parent == up -> dgram_parent
+#ifdef BSD44
+ && len == vp -> dgram_addrlen
+#endif
+ && bcmp (data, vp -> dgram_peer.sa.sa_data,
+ (int) len) == 0)
+ break;
+ if (vp >= wp
+ && (vp = &peers[up -> dgram_parent])
+ -> dgram_peer.sa.sa_family != 0) {
+ free ((char *) qb);
+ continue;
+ }
+ }
+
+ insque (qb, vp -> dgram_queue.qb_back);
+
+ if (--result <= 0
+ || (result = selsocket (nfds, &ifds, NULLFD, NULLFD, OK))
+ <= 0)
+ break;
+
+ }
+
+ for (vp = (up = peers) + maxpeers, fd = 0; up < vp; up++, fd++)
+ if (up -> dgram_parent != NOTOK && FD_ISSET (fd, &jfds))
+ if (up -> dgram_queue.qb_forw != &up -> dgram_queue)
+ FD_SET (fd, rfds);
+ else
+ FD_CLR (fd, rfds);
+
+ result = 0;
+ ifds = *rfds;
+ if (wfds)
+ for (fd = 0; fd < nfds; fd++)
+ if (FD_ISSET (fd, wfds))
+ FD_SET (fd, &ifds);
+ if (efds)
+ for (fd = 0; fd < nfds; fd++)
+ if (FD_ISSET (fd, efds))
+ FD_SET (fd, &ifds);
+ for (fd = 0; fd < nfds; fd++)
+ if (FD_ISSET (fd, &ifds))
+ result++;
+
+ return result;
+}
+
+/* */
+
+int check_dgram_socket (fd)
+int fd;
+{
+ int nfds;
+ fd_set ifds;
+
+ FD_ZERO (&ifds);
+
+ nfds = fd + 1;
+ FD_SET (fd, &ifds);
+
+ return select_dgram_socket (nfds, &ifds, NULLFD, NULLFD, OK);
+}
+
+/* */
+
+#ifdef DEBUG
+
+#ifdef TCP
+#include "isoaddrs.h"
+
+
+static inetprint (sin, bp)
+struct sockaddr_in *sin;
+char *bp;
+{
+ (void) sprintf (bp, "Internet=%s+%d+%d", inet_ntoa (sin -> sin_addr),
+ (int) ntohs (sin -> sin_port), NA_TSET_UDP);
+}
+#endif
+
+/* */
+
+#ifdef CLTS
+/* prints OSI address using the format described in:
+
+ "A string encoding of Presentation Address"
+
+ S.E. Kille, Research Note RN/89/14, February 1989
+ Department of Computer Science
+ University College London
+
+ */
+
+#ifndef SSEL
+#define SSEL(s) ((s)->siso_tlen + TSEL(s))
+#define PSEL(s) ((s)->siso_slen + SSEL(s))
+#endif
+
+
+static isoprint (siso, bp)
+register struct sockaddr_iso *siso;
+char *bp;
+{
+ int didone = 0;
+
+ if (siso -> siso_plen) {
+ hexprint (bp, siso -> siso_plen, PSEL (siso), "'", "'H");
+ bp += strlen (bp);
+ *bp++ = '/';
+ didone++;
+ }
+ if (siso -> siso_slen || didone) {
+ hexprint (bp, siso -> siso_slen, SSEL (siso), "'", "'H");
+ bp += strlen (bp);
+ *bp++ = '/';
+ didone++;
+ }
+ if (siso -> siso_tlen || didone) {
+ hexprint (bp, siso -> siso_tlen, TSEL (siso), "'", "'H");
+ bp += strlen (bp);
+ *bp++ = '/';
+ didone++;
+ }
+ hexprint (bp, siso -> siso_nlen, siso -> siso_data, "NS+", "");
+}
+
+
+static hexprint (bp, n, buf, start, stop)
+char *bp;
+int n;
+u_char *buf;
+char *start,
+ *stop;
+{
+ register u_char *in = buf, *top = in + n;
+
+ if (n == 0)
+ return;
+
+ (void) strcpy (bp, start);
+ bp += strlen (bp);
+
+ while (in < top) {
+ (void) sprintf (bp, "%02x", *in++ & 0xff);
+ bp += 2;
+ }
+
+ (void) strcpy (bp, stop);
+}
+#endif
+
+/* */
+
+static struct printent {
+ int p_family;
+ IFP p_function;
+} ents[] = {
+#ifdef TCP
+ AF_INET, inetprint,
+#endif
+
+#ifdef CLTS
+ AF_ISO, isoprint,
+#endif
+
+ NULL
+};
+
+static action (s, fd, sock)
+char *s;
+int fd;
+struct sockaddr *sock;
+{
+ char buffer[BUFSIZ];
+ register struct printent *p;
+
+ if (!(compat_log -> ll_events & LLOG_TRACE))
+ return;
+
+ for (p = ents; p -> p_family; p++)
+ if (p -> p_family == sock -> sa_family)
+ break;
+ if (!p -> p_family) {
+ DLOG (compat_log, LLOG_EXCEPTIONS,
+ ("unknown dgram address family 0x%x", sock -> sa_family));
+ return;
+ }
+
+ (void) (*p -> p_function) (sock, buffer);
+
+ DLOG (compat_log, LLOG_TRACE, ("%-10.10s %d %s", s, fd, buffer));
+}
+#endif
+
+#else
+
+/* */
+
+int dgram_dummy () {}
+
+#endif
diff --git a/src/isode/compat/explode.c b/src/isode/compat/explode.c
new file mode 100644
index 000000000..a26cdcdf5
--- /dev/null
+++ b/src/isode/compat/explode.c
@@ -0,0 +1,69 @@
+/* explode.c - explode octets into ascii */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:12 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:39 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:43 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:53 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* DATA */
+
+static char nib2hex[0x10] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+};
+
+/* */
+
+int explode (a, b, n)
+register char *a;
+register u_char *b;
+register int n;
+{
+ register int i;
+ register u_char c;
+
+ for (i = 0; i < n; i++) {
+ c = *b++;
+ *a++ = nib2hex[(u_char)(c & 0xf0) >> 4];
+ *a++ = nib2hex[(c & 0x0f)];
+ }
+ *a = NULL;
+
+ return (n * 2);
+}
diff --git a/src/isode/compat/general.c b/src/isode/compat/general.c
new file mode 100644
index 000000000..3d5bb27dc
--- /dev/null
+++ b/src/isode/compat/general.c
@@ -0,0 +1,162 @@
+/* general.c - general utilities for emulation of 4.2BSD */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:14 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:41 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:45 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:53 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* Berkeley UNIX: 4.2 */
+
+#ifdef BSD42
+
+/* Simply including "general.h" is sufficient. */
+
+int _general_stub () {};
+
+#endif
+
+/* non-Berkeley UNIX */
+
+#if !defined(BSDLIBC) || defined(BSD44)
+
+#ifndef lint
+
+struct qelem {
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char q_data[1]; /* extensible */
+};
+
+
+insque (elem, pred)
+struct qelem *elem,
+ *pred;
+{
+ pred -> q_forw -> q_back = elem;
+ elem -> q_forw = pred -> q_forw;
+ elem -> q_back = pred;
+ pred -> q_forw = elem;
+}
+
+
+remque (elem)
+struct qelem *elem;
+{
+ elem -> q_forw -> q_back = elem -> q_back;
+ elem -> q_back -> q_forw = elem -> q_forw;
+}
+
+#endif
+#endif
+
+/* DUP2 */
+
+#ifndef BSD42
+#ifdef SYS5
+#include <fcntl.h>
+#endif
+
+
+extern int errno;
+
+
+int dup2 (d1, d2)
+register int d1,
+ d2;
+{
+ int d;
+
+ if (d1 == d2)
+ return OK;
+
+ (void) close (d2);
+#ifdef F_DUPFD
+ if ((d = fcntl (d1, F_DUPFD, d2)) == NOTOK)
+ return NOTOK;
+#else
+ if ((d = dup2_aux (d1, d2)) == NOTOK)
+ return NOTOK;
+#endif
+ if (d == d2)
+ return OK;
+
+ errno = 0;
+ return NOTOK;
+}
+
+
+#ifndef F_DUPFD
+dup2_aux (d1, d2)
+int d1,
+ d2;
+{
+ int fd,
+ result;
+
+ if ((fd = dup (d1)) == NOTOK || fd == d2)
+ return fd;
+
+ result = dup2_aux (d1, d2);
+
+ (void) close (fd);
+
+ return result;
+}
+#endif
+#endif
+
+/* BYTEORDER */
+
+#ifndef SWABLIB
+
+/* ROS and HP-UX don't seem to have these in libc.a */
+
+#undef ntohs
+u_short ntohs (netshort) u_short netshort; { return netshort; }
+
+#undef htons
+u_short htons (hostshort) u_short hostshort; { return hostshort; }
+
+#undef ntohl
+u_long ntohl (netlong) u_long netlong; { return netlong; }
+
+#undef htonl
+u_long htonl (hostlong) u_long hostlong; { return hostlong; }
+
+#endif
diff --git a/src/isode/compat/getpassword.c b/src/isode/compat/getpassword.c
new file mode 100644
index 000000000..984b3f071
--- /dev/null
+++ b/src/isode/compat/getpassword.c
@@ -0,0 +1,144 @@
+/* getpassword.c - generic read-the-password-from-the-tty */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:16 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:43 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:46 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:54 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <signal.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "sys.file.h"
+
+#ifdef BSD44
+char *getpass ();
+#endif
+
+/* */
+
+/* roll our own since want to get past UNIX's limit of 8 octets... */
+
+char *getpassword (prompt)
+char *prompt;
+{
+#ifndef BSD44
+ register int c;
+ int flags,
+ isopen;
+ register char *bp,
+ *ep;
+#if !defined(SYS5) && !defined(XOS_2)
+ struct sgttyb sg;
+#else
+ struct termio sg;
+#endif
+ SFP istat;
+ FILE *fp;
+ static char buffer[BUFSIZ];
+
+#ifdef SUNLINK_7_0
+ fp = stdin, isopen = 0; /* will help greatly to work off a script */
+#else
+ if ((c = open ("/dev/tty", O_RDWR)) != NOTOK && (fp = fdopen (c, "r")))
+ setbuf (fp, NULLCP), isopen = 1;
+ else {
+ if (c != NOTOK)
+ (void) close (c);
+
+ fp = stdin, isopen = 0;
+ }
+#endif
+
+ istat = signal (SIGINT, SIG_IGN);
+
+#if !defined(SYS5) && !defined(XOS_2)
+ (void) gtty (fileno (fp), &sg);
+ flags = sg.sg_flags;
+ sg.sg_flags &= ~ECHO;
+ (void) stty (fileno (fp), &sg);
+#else
+ (void) ioctl (fileno (fp), TCGETA, (char *) &sg);
+ flags = sg.c_lflag;
+ sg.c_lflag &= ~ECHO;
+ (void) ioctl (fileno (fp), TCSETAW, (char *) &sg);
+#endif
+
+#ifdef SUNLINK_7_0
+ (void) fprintf (stdout, "%s", prompt);
+ (void) fflush (stdout);
+#else
+ (void) fprintf (stderr, "%s", prompt);
+ (void) fflush (stderr);
+#endif
+
+ for (ep = (bp = buffer) + sizeof buffer - 1; (c = getc (fp)) != EOF;)
+#ifndef apollo
+ if (c == '\n')
+#else
+ if (c == '\n' || c == '\r')
+#endif
+ break;
+ else
+ if (bp < ep)
+ *bp++ = c;
+ *bp = NULL;
+
+#ifdef SUNLINK_7_0
+ (void) fprintf (stdout, "\n");
+ (void) fflush (stdout);
+#else
+ (void) fprintf (stderr, "\n");
+ (void) fflush (stderr);
+#endif
+
+#if !defined(SYS5) && !defined(XOS_2)
+ sg.sg_flags = flags;
+ (void) stty (fileno (fp), &sg);
+#else
+ sg.c_lflag = flags;
+ (void) ioctl (fileno (fp), TCSETAW, (char *) &sg);
+#endif
+
+ (void) signal (SIGINT, istat);
+
+ if (isopen)
+ (void) fclose (fp);
+
+ return buffer;
+#else
+ return getpass (prompt);
+#endif
+}
diff --git a/src/isode/compat/hpuxx25.c b/src/isode/compat/hpuxx25.c
new file mode 100644
index 000000000..22ee713b8
--- /dev/null
+++ b/src/isode/compat/hpuxx25.c
@@ -0,0 +1,922 @@
+/* hpuxx25.c - X.25 abstractions for HPUX X25/9000 */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ * Contributed by John Pavel, Department of Trade and Industry/National
+ * Physical Laboratory in the UK
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:18 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:46 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:48 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:54 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include <signal.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* HP UNIX: X25/9000 */
+
+#ifdef X25
+
+#include "x25.h"
+#include "isoaddrs.h"
+
+#ifdef HPUX_X25
+
+#define CALLING 0
+#define CALLED 1
+#define PROBE (-1)
+
+struct fdl_st {
+ int fd;
+ struct fdl_st *next;
+ };
+static struct fdl_st *fdl = NULL;
+static void setup_sigurg ();
+static void clear_sigurg ();
+
+/* */
+
+#ifdef DEBUG
+void print_x25_facilities ();
+#endif
+
+/* */
+
+/* ARGSUSED */
+
+int start_x25_client (local, priv)
+struct NSAPaddr *local;
+int priv;
+{
+ int sd, pgrp;
+
+ if ((sd = socket (AF_CCITT, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK;
+ }
+
+ pgrp = -getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ return sd;
+}
+
+/* */
+
+int start_x25_server (local, backlog, opt1, opt2)
+struct NSAPaddr *local;
+int backlog,
+ opt1,
+ opt2;
+{
+ CONN_DB sbuf;
+ CONN_DB *sock;
+ int sd, onoff, pgrp;
+ char cudfbuf [NPSIZE + CUDFSIZE];
+
+ bzero(&sbuf, sizeof(CONN_DB));
+ sbuf.addr.x25_family = AF_CCITT;
+ if ((sd = socket (AF_CCITT, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK;
+ }
+
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ /* if neither dte or pid are given use dte from interface */
+ if (!(local->na_dtelen || local->na_pidlen)) {
+ strcpy (sbuf.addr.x25ifname, "x25_0");
+ if (ioctl (sd, X25_RD_HOSTADR, (char *) &sbuf.addr) == NOTOK) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_HOSTADR"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+ sbuf.addr.x25ifname [0] = '\0';
+ sbuf.addr.x25hostlen = strlen(sbuf.addr.x25_host);
+ if (x25_dnic_prefix && *x25_dnic_prefix)
+ strcpy (local->na_dte, x25_dnic_prefix);
+ strcat (local->na_dte, sbuf.addr.x25_host);
+ local->na_dtelen = strlen (local->na_dte);
+ }
+ /* Avoid a null local dte address, set it to '0', */
+ /* gen2if will set it back to zero in interface address */
+ if (!local->na_dtelen) {
+ local->na_dtelen = 1;
+ local->na_dte [0] = '0';
+ }
+ sock = gen2if(local, &sbuf, ADDR_LISTEN);
+
+ if (sock->cudf.x25_cud_len)
+ if (ioctl (sd, X25_WR_USER_DATA, &sock->cudf) == -1) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_WR_USER_DATA"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+ if (bind (sd, (X25_ADDR *) &sock->addr, sizeof(X25_ADDR)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+
+#ifndef BSD43
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, NULLCP, 0);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, NULLCP, 0);
+#else
+ onoff = 1;
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, (char *)&onoff, sizeof onoff);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, (char *)&onoff, sizeof onoff);
+#endif
+
+ if (set_x25_facilities(sd, CALLED, "Acceptable") == NOTOK) {
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+
+ (void) listen (sd, backlog);
+
+ onoff = 0;
+ if (ioctl (sd, X25_CALL_ACPT_APPROVAL, (char *) &onoff) == NOTOK) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed",
+ ("X25_CALL_ACPT_APPROVAL"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+
+ return sd;
+}
+
+/* */
+
+int join_x25_server (fd, remote)
+register int fd;
+register struct NSAPaddr *remote;
+{
+ CONN_DB sbuf;
+ CONN_DB *sock = &sbuf;
+ register int nfd;
+
+ bzero(&sbuf, sizeof(CONN_DB));
+ sbuf.addr.x25_family = AF_CCITT;
+ sock = gen2if (remote, sock, ADDR_REMOTE);
+
+ if (set_x25_facilities(fd, CALLING, "Proposed") == NOTOK)
+ return NOTOK;
+
+ if (sock->cudf.x25_cud_len)
+ if (ioctl (fd, X25_WR_USER_DATA, &sock->cudf) == -1) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_WR_USER_DATA"));
+ return NOTOK;
+ }
+ setup_sigurg (fd);
+ if ((nfd = connect (fd, (X25_ADDR *) &sock->addr, sizeof (X25_ADDR)))
+ == NOTOK) {
+ return nfd;
+ }
+#ifdef DEBUG
+ else
+ if (x25_log -> ll_events & LLOG_DEBUG)
+ (void) log_x25_facilities(fd, CALLING, "Effective Calling");
+#endif
+
+ remote = if2gen (remote, sock, ADDR_REMOTE);
+
+ return nfd;
+}
+
+/* */
+
+int join_x25_client (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB sbuf;
+ CONN_DB *sock = &sbuf;
+ int len = sizeof *sock;
+ int nfd;
+
+ bzero(&sbuf, sizeof(CONN_DB));
+ sbuf.addr.x25_family = AF_CCITT;
+ if ((nfd = accept (fd, (X25_ADDR *) &sock->addr, &len)) == NOTOK) {
+ return nfd;
+ }
+
+ setup_sigurg (nfd);
+ if (ioctl(nfd,X25_SEND_CALL_ACEPT, NULLCP) < 0)
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_SEND_CALL_ACEPT"));
+
+#ifdef DEBUG
+ if (x25_log -> ll_events & LLOG_DEBUG)
+ (void) log_x25_facilities(fd, CALLED, "Effective Called");
+#endif
+ remote = if2gen (remote, sock, ADDR_REMOTE);
+
+ return nfd;
+}
+
+/* */
+
+int fac_ccitt2hp (ccitt, hp)
+CCITT_FACILITY_DB *ccitt;
+FACILITY_DB *hp;
+{
+ register int i, j;
+ int returncode = OK;
+
+ memset (hp, 0, sizeof (FACILITY_DB));
+ for (i = 0; i < ccitt->x25_fac_len; i++)
+ switch (ccitt->x25_fac [i]) {
+ case 0x01:
+ hp->t_01 = ccitt->x25_fac [++i];
+ break;
+ case 0x02:
+ hp->t_02 = ccitt->x25_fac [++i];
+ break;
+ case 0x03:
+ hp->t_03_sel = 1;
+ hp->t_03 = ccitt->x25_fac [++i];
+ break;
+ case 0x07:
+ hp->t_07 = ccitt->x25_fac [++i];
+ break;
+ case 0x41:
+ hp->t_41_sel = 1;
+ hp->t_41 = ccitt->x25_fac [++i] << 8;
+ hp->t_41 += ccitt->x25_fac [++i];
+ break;
+ case 0x42:
+ hp->t_42 [0] = ccitt->x25_fac [++i];
+ hp->t_42 [1] = ccitt->x25_fac [++i];
+ break;
+ case 0x43:
+ hp->t_43 [0] = ccitt->x25_fac [++i];
+ hp->t_43 [1] = ccitt->x25_fac [++i];
+ break;
+ case 0x44:
+ hp->t_44_sel = 1;
+ hp->t_44 = ccitt->x25_fac [++i] << 8;
+ hp->t_44 += ccitt->x25_fac [++i];
+ break;
+ default:
+ /* ignore parameter */
+ returncode = NOTOK;
+ switch (ccitt->x25_fac [i] & 0xc0) {
+ case 0x00:
+ i += 1; break;
+ case 0x40:
+ i += 2; break;
+ case 0x80:
+ i += 3; break;
+ case 0xc0:
+ i += ccitt->x25_fac [++i]; break;
+ }
+ }
+ return (returncode);
+}
+
+
+void fac_hp2ccitt (hp, ccitt)
+FACILITY_DB *hp;
+CCITT_FACILITY_DB *ccitt;
+{
+ register int i;
+
+ memset (ccitt, 0, sizeof (CCITT_FACILITY_DB));
+ i = 0;
+ if (hp->t_01) {
+ ccitt->x25_fac_len += 2;
+ ccitt->x25_fac [i++] = 0x01;
+ ccitt->x25_fac [i++] = hp->t_01;
+ }
+ if (hp->t_02) {
+ ccitt->x25_fac_len += 2;
+ ccitt->x25_fac [i++] = 0x02;
+ ccitt->x25_fac [i++] = hp->t_02;
+ }
+ if (hp->t_03_sel) {
+ ccitt->x25_fac_len += 2;
+ ccitt->x25_fac [i++] = 0x03;
+ ccitt->x25_fac [i++] = hp->t_03;
+ }
+ if (hp->t_07) {
+ ccitt->x25_fac_len += 2;
+ ccitt->x25_fac [i++] = 0x07;
+ ccitt->x25_fac [i++] = hp->t_07;
+ }
+ if (hp->t_41_sel) {
+ ccitt->x25_fac_len += 3;
+ ccitt->x25_fac [i++] = 0x41;
+ ccitt->x25_fac [i++] = hp->t_41 >> 8;
+ ccitt->x25_fac [i++] = hp->t_41 && 0xff;
+ }
+ if (hp->t_42 [0] || hp->t_42 [1]) {
+ ccitt->x25_fac_len += 3;
+ ccitt->x25_fac [i++] = 0x42;
+ ccitt->x25_fac [i++] = hp->t_42 [0];
+ ccitt->x25_fac [i++] = hp->t_42 [1];
+ }
+ if (hp->t_43 [0] || hp->t_43 [1]) {
+ ccitt->x25_fac_len += 3;
+ ccitt->x25_fac [i++] = 0x43;
+ ccitt->x25_fac [i++] = hp->t_43 [0];
+ ccitt->x25_fac [i++] = hp->t_43 [1];
+ }
+ if (hp->t_44_sel) {
+ ccitt->x25_fac_len += 3;
+ ccitt->x25_fac [i++] = 0x44;
+ ccitt->x25_fac [i++] = hp->t_44 >> 8;
+ ccitt->x25_fac [i++] = hp->t_44 && 0xff;
+ }
+}
+
+
+int set_x25_facilities(sd, coc, caption)
+int sd, coc;
+char *caption;
+{
+ FACILITY_DB facilities;
+ CCITT_FACILITY_DB ccitt_facilities;
+
+ bzero ((char *) &facilities, sizeof (FACILITY_DB));
+ bzero ((char *) &ccitt_facilities, sizeof (CCITT_FACILITY_DB));
+
+ if (ioctl (sd, X25_RD_FACILITIES, (char *) &ccitt_facilities) == NOTOK) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_FACILITIES"));
+ return NOTOK;
+ }
+ if (fac_ccitt2hp (&ccitt_facilities, &facilities) == NOTOK)
+ SLOG (x25_log, LLOG_EXCEPTIONS, "unkonwn parameter(s)", ("fac_ccitt2hp"));
+
+ if (coc == PROBE
+ || !(coc == CALLED
+ || reverse_charge || recvpktsize || sendpktsize
+ || recvwndsize || sendwndsize || recvthruput
+ || sendthruput || cug_req /* || cug_index */
+ || fast_select_type || rpoa_req /* || rpoa */)) {
+ if (facilities.t_42 [0])
+ recvpktsize = 1 << facilities.t_42 [0];
+ if (facilities.t_42 [1])
+ sendpktsize = 1 << facilities.t_42 [1];
+ return OK;
+ }
+
+ if (reverse_charge)
+ facilities.t_01 |= 0x01;
+ else
+ facilities.t_01 &= ~0x01;
+
+ switch (recvpktsize) {
+ case 16:
+ facilities.t_42 [0] = 4;
+ break;
+ case 32:
+ facilities.t_42 [0] = 5;
+ break;
+ case 64:
+ facilities.t_42 [0] = 6;
+ break;
+ case 128:
+ facilities.t_42 [0] = 7;
+ break;
+ case 256:
+ facilities.t_42 [0] = 8;
+ break;
+ case 512:
+ facilities.t_42 [0] = 9;
+ break;
+ case 1024:
+ facilities.t_42 [0] = 10;
+ }
+ switch (sendpktsize) {
+ case 16:
+ facilities.t_42 [1] = 4;
+ break;
+ case 32:
+ facilities.t_42 [1] = 5;
+ break;
+ case 64:
+ facilities.t_42 [1] = 6;
+ break;
+ case 128:
+ facilities.t_42 [1] = 7;
+ break;
+ case 256:
+ facilities.t_42 [1] = 8;
+ break;
+ case 512:
+ facilities.t_42 [1] = 9;
+ break;
+ case 1024:
+ facilities.t_42 [1] = 10;
+ }
+
+ if (recvwndsize)
+ facilities.t_43 [0] = recvwndsize;
+ if (sendwndsize)
+ facilities.t_43 [1] = sendwndsize;
+
+ if (sendthruput)
+ facilities.t_02 = (facilities.t_02 & 0xf0) | (sendthruput & 0x0f);
+ if (recvthruput)
+ facilities.t_02 = (facilities.t_02 & 0x0f) | (recvthruput << 4);
+
+ if (cug_req) {
+ facilities.t_03_sel = 1;
+ facilities.t_03 = cug_index;
+ }
+
+ switch (fast_select_type) {
+ case 0:
+ facilities.t_01 &= ~CCITT_FAST_SELECT;
+ if (coc == CALLED)
+ facilities.t_01 |= CCITT_FAST_ACPT_CLR;
+ break;
+ case 1:
+ facilities.t_01 &= ~CCITT_FAST_SELECT;
+ facilities.t_01 |= CCITT_FAST_CLR_ONLY;
+ break;
+ case 2:
+ facilities.t_01 &= ~CCITT_FAST_SELECT;
+ facilities.t_01 |= CCITT_FAST_ACPT_CLR;
+ break;
+ default:
+ SLOG (x25_log, LLOG_EXCEPTIONS, "illegal value",
+ ("fast_select_type"));
+ }
+
+ /* rpoa not supported - is this parameter t_41 in ccitt-description ??? */
+
+ fac_hp2ccitt (&facilities, &ccitt_facilities);
+ if (ioctl (sd, X25_WR_FACILITIES, (char *) &ccitt_facilities) == NOTOK) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_WR_FACILITIES"));
+ return NOTOK;
+ }
+
+#ifdef DEBUG
+ if (x25_log -> ll_events & LLOG_DEBUG)
+ print_x25_facilities (facilities, coc, caption);
+#endif
+
+ if (facilities.t_42 [0])
+ recvpktsize = 1 << facilities.t_42 [0];
+ if (facilities.t_42 [1])
+ sendpktsize = 1 << facilities.t_42 [1];
+
+ return OK;
+}
+
+/* */
+
+int log_cause_and_diag(fd)
+int fd;
+{
+ char buf [MAX_EVENT_SIZE];
+ int buflen;
+ char flags = 0;
+
+ for (;;) {
+ if ((buflen = recv (fd, buf, MAX_EVENT_SIZE, MSG_OOB)) == NOTOK) {
+ if (x25_log -> ll_events & LLOG_NOTICE)
+ SLOG (x25_log, LLOG_NOTICE,
+ "failed", ("recv %d (MSG_OOB)", fd));
+ clear_sigurg (fd);
+ return OK;
+ }
+ else if (!buflen)
+ return OK;
+ switch (buf [1]) {
+ case OOB_INTERRUPT:
+ SLOG (x25_log, LLOG_NOTICE, NULLCP, ("OOB_INTERRUPT"));
+ break;
+ case OOB_VC_RESET:
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP, ("OOB_VC_RESET"));
+ flags = (1 << RECV_DIAG);
+ close_x25_socket (fd);
+ break;
+ case OOB_VC_CLEAR:
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP, ("OOB_VC_CLEAR"));
+ flags = (1 << RECV_DIAG) | (1 << DIAG_TYPE);
+ close_x25_socket (fd);
+ break;
+ case OOB_VC_RESET_CONF:
+ SLOG (x25_log, LLOG_NOTICE, NULLCP, ("OOB_VC_RESET_CONF"));
+ break;
+ case OOB_VC_INTERRUPT_CONF:
+ SLOG (x25_log, LLOG_NOTICE, NULLCP, ("OOB_VC_INTERRUPT_CONF"));
+ break;
+ case OOB_VC_DBIT_CONF:
+ SLOG (x25_log, LLOG_NOTICE, NULLCP, ("OOB_VC_DBIT_CONF"));
+ break;
+ case OOB_VC_MSG_TOO_BIG:
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP, ("OOB_VC_MSG_TOO_BIG"));
+ close_x25_socket (fd);
+ break;
+ case OOB_VC_L2DOWN:
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP, ("OOB_VC_L2DOWN"));
+ close_x25_socket (fd);
+ break;
+ }
+ (void) elucidate_x25_err (flags, &buf [2]);
+ }
+}
+
+
+void sigurg (sig, code, scp)
+int sig, code;
+struct sigcontext *scp;
+{
+ struct fdl_st *fdlp = fdl, *nfdlp;
+
+ (void) signal (SIGURG, sigurg);
+ while (fdlp != NULL) {
+ log_cause_and_diag (fdlp->fd);
+ fdlp = fdlp->next;
+ }
+ if (scp == NULL) {
+ SLOG (x25_log, LLOG_NOTICE, NULLCP, ("No signal context"));
+ return;
+ };
+ if (scp->sc_syscall != SYS_NOTSYSCALL)
+ scp->sc_syscall_action = SIG_RESTART;
+}
+
+void setup_sigurg (fd)
+int fd;
+{
+ struct fdl_st *fdlp = fdl;
+
+ (void) signal (SIGURG, sigurg);
+ while (fdlp != NULL)
+ if (fdlp->fd == fd)
+ return;
+ else
+ fdlp = fdlp->next;
+ if ((fdlp = malloc (sizeof (struct fdl_st))) == NULL) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("malloc (sigurg-struct)"));
+ return;
+ }
+ fdlp->fd = fd;
+ fdlp->next = fdl;
+ fdl = fdlp;
+}
+
+void clear_sigurg (fd)
+int fd;
+{
+ struct fdl_st *fdlp = fdl, *nfdlp;
+
+ if ((fdl != NULL) && (fdl->fd == fd)) {
+ fdl = fdl->next;
+ if (free (fdlp) == NOTOK)
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed",
+ ("free (sigurg-struct)"));
+ return;
+ }
+ else while (fdlp != NULL)
+ if ((fdlp->next != NULL) && (fdlp->next->fd == fd)) {
+ nfdlp = fdlp->next;
+ fdlp->next = fdlp->next->next;
+ if (free (nfdlp) == NOTOK)
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed",
+ ("free (sigurg-struct)"));
+ }
+ else
+ fdlp = fdlp->next;
+}
+
+int close_x25_socket (fd)
+int fd;
+{
+ clear_sigurg (fd);
+ return (close (fd));
+};
+
+
+/* */
+
+#ifdef DEBUG
+
+static int log_x25_facilities (fd, coc, caption)
+int fd;
+int coc;
+char *caption;
+{
+ FACILITY_DB hp;
+ CCITT_FACILITY_DB ccitt;
+
+ if (ioctl (fd, X25_RD_FACILITIES, (char *) &ccitt) == NOTOK) {
+ SLOG (x25_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_FACILITIES"));
+ return NOTOK;
+ }
+
+ fac_ccitt2hp (&ccitt, &hp);
+ print_x25_facilities (&hp, coc, caption);
+
+ return OK;
+}
+
+/* */
+
+static void print_x25_facilities (hp, coc, caption)
+FACILITY_DB *hp;
+int coc;
+char *caption;
+{
+ int i, baud;
+
+ DLOG (x25_log, LLOG_DEBUG, ("%s X.25 Facilities:", caption));
+
+ /* reverse charge */
+ switch (hp->t_01 & REVCHARGE) {
+ case 0:
+ DLOG (x25_log, LLOG_DEBUG, ((coc == CALLED)
+ ? "reverse charging not allowed"
+ : "reverse charging not requested"));
+ break;
+
+ case 1:
+ DLOG (x25_log, LLOG_DEBUG, ((coc == CALLING)
+ ? "reverse charging requested"
+ : "reverse charging allowed"));
+ break;
+ }
+
+ /* ACK expected */
+ if (hp->t_07 & ACK_EXPECTED)
+ DLOG (x25_log, LLOG_DEBUG, ("ACK-packets expected"));
+ else
+ DLOG (x25_log, LLOG_DEBUG, ("no ACK-packets expected"));
+
+ /* NACK expected */
+ if (hp->t_07 & NACK_EXPECTED)
+ DLOG (x25_log, LLOG_DEBUG, ("NACK-packets expected"));
+ else
+ DLOG (x25_log, LLOG_DEBUG, ("no NACK-packets expected"));
+
+ /* recvpktsize */
+ switch (i = hp->t_42 [0] ? (1 << hp->t_42 [0]) : 0) {
+ case 0:
+ DLOG (x25_log, LLOG_DEBUG, ("default recv packet size"));
+ break;
+
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ case 512:
+ case 1024:
+ DLOG (x25_log, LLOG_DEBUG, ("recv packet size %d", i));
+ break;
+
+ default:
+ DLOG (x25_log, LLOG_DEBUG, ("invalid recv packet size %d", i));
+ break;
+ }
+
+ /* sendpktsize */
+ switch (i = hp->t_42 [1] ? (1 << hp->t_42 [1]) : 0) {
+ case 0:
+ DLOG (x25_log, LLOG_DEBUG, ("default send packet size"));
+ break;
+
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ case 512:
+ case 1024:
+ DLOG (x25_log, LLOG_DEBUG, ("send packet size %d", i));
+ break;
+
+ default:
+ DLOG (x25_log, LLOG_DEBUG, ("invalid send packet size %d", i));
+ break;
+ }
+
+ DLOG (x25_log, LLOG_DEBUG,
+ (hp->t_43 [0] == 0 ? "default recv window size"
+ : 1 <= hp->t_43 [0] && hp->t_43 [0] <= 127
+ ? "recv window size %d"
+ : "invalid recv window size %d",
+ hp->t_43 [0]));
+
+ DLOG (x25_log, LLOG_DEBUG,
+ (hp->t_43 [1] == 0 ? "default send window size"
+ : 1 <= hp->t_43 [1] && hp->t_43 [1] <= 127
+ ? "send window size %d"
+ : "invalid send window size %d",
+ hp->t_43 [1]));
+
+ /* recvthruput */
+ switch (hp->t_02 >> 4) {
+ case 0:
+ DLOG (x25_log, LLOG_DEBUG, ("default recv throughput"));
+ break;
+
+ case 3:
+ baud = 75;
+print_recv: ;
+ DLOG (x25_log, LLOG_DEBUG, ("recv throughput %dbps", baud));
+ break;
+
+ case 4:
+ baud = 150;
+ goto print_recv;
+
+ case 5:
+ baud = 300;
+ goto print_recv;
+
+ case 6:
+ baud = 600;
+ goto print_recv;
+
+ case 7:
+ baud = 1200;
+ goto print_recv;
+
+ case 8:
+ baud = 2400;
+ goto print_recv;
+
+ case 9:
+ baud = 4800;
+ goto print_recv;
+
+ case 10:
+ baud = 9600;
+ goto print_recv;
+
+ case 11:
+ baud = 19200;
+ goto print_recv;
+
+ case 12:
+ baud = 48000;
+ goto print_recv;
+
+ default:
+ DLOG (x25_log, LLOG_DEBUG, ("invalid recv throughput %d",
+ hp->t_02 >> 4));
+ break;
+ }
+
+ /* sendthruput */
+ switch (hp->t_02 & 0x0f) {
+ case 0:
+ DLOG (x25_log, LLOG_DEBUG, ("default send throughput"));
+ break;
+
+ case 3:
+ baud = 75;
+print_send: ;
+ DLOG (x25_log, LLOG_DEBUG, ("send throughput %dbps", baud));
+ break;
+
+ case 4:
+ baud = 150;
+ goto print_send;
+
+ case 5:
+ baud = 300;
+ goto print_send;
+
+ case 6:
+ baud = 600;
+ goto print_send;
+
+ case 7:
+ baud = 1200;
+ goto print_send;
+
+ case 8:
+ baud = 2400;
+ goto print_send;
+
+ case 9:
+ baud = 4800;
+ goto print_send;
+
+ case 10:
+ baud = 9600;
+ goto print_send;
+
+ case 11:
+ baud = 19200;
+ goto print_send;
+
+ case 12:
+ baud = 48000;
+ goto print_send;
+
+ default:
+ DLOG (x25_log, LLOG_DEBUG, ("invalid send throughput %d",
+ hp->t_02 & 0x0f));
+ break;
+ }
+
+ if (hp->t_03_sel)
+ DLOG (x25_log, LLOG_DEBUG, ("closed user group 0x%x (BCD)",
+ hp->t_03));
+ else
+ DLOG (x25_log, LLOG_DEBUG, ("no closed user group"));
+
+ if (hp->t_41_sel)
+ DLOG (x25_log, LLOG_DEBUG, ("bilateral closed user group 0x%x (BCD)",
+ hp->t_41 [0] << 8 + hp->t_41 [1]));
+ else
+ DLOG (x25_log, LLOG_DEBUG, ("no bilateral closed user group"));
+
+ switch (hp->t_01 & CCITT_FAST_SELECT) {
+ case CCITT_FAST_OFF:
+ DLOG (x25_log, LLOG_DEBUG, ("don't use fast select"));
+ break;
+
+ case CCITT_FAST_CLR_ONLY:
+ DLOG (x25_log, LLOG_DEBUG, ("clear is fast select response"));
+ break;
+
+ case CCITT_FAST_ACPT_CLR:
+ DLOG (x25_log, LLOG_DEBUG,
+ ("clear or call accepted is fast select response"));
+ break;
+
+ default:
+ DLOG (x25_log, LLOG_DEBUG, ("invalid fast select type %d",
+ hp->t_01 & CCITT_FAST_SELECT));
+ break;
+ }
+
+/*
+ * Don't know the meaning of this parameter (is t_44 ?)
+ *
+ switch (f.rpoa_req) {
+ case 0:
+ DLOG (x25_log, LLOG_DEBUG, ("no RPOA transit request"));
+ break;
+
+ case 1:
+ DLOG (x25_log, LLOG_DEBUG, ("RPOA transit request 0x%x",
+ f.rpoa_req));
+ break;
+
+ default:
+ DLOG (x25_log, LLOG_DEBUG, ("invalid RPOA transit request %d",
+ f.rpoa_req));
+ }
+ *
+ *
+ */
+}
+#endif
+#else
+int _hpuxx25_stub2 (){;}
+#endif
+#else
+int _hpuxx25_stub (){;}
+#endif
diff --git a/src/isode/compat/implode.c b/src/isode/compat/implode.c
new file mode 100644
index 000000000..e3969148c
--- /dev/null
+++ b/src/isode/compat/implode.c
@@ -0,0 +1,80 @@
+/* implode.c - explode ascii into octets */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:20 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:48 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:50 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:55 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* DATA */
+
+char hex2nib[0x80] = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+/* */
+
+int implode (a, b, n)
+register u_char *a;
+register char *b;
+register int n;
+{
+ register int i;
+
+ for (i = 0; i < n; i += 2) {
+ *a++ = (hex2nib[b[0] & 0x7f] << 4) | (hex2nib[b[1] & 0x7f]);
+ b += 2;
+ }
+
+ return (n / 2);
+}
diff --git a/src/isode/compat/inst-man.sh b/src/isode/compat/inst-man.sh
new file mode 100644
index 000000000..50f4e3394
--- /dev/null
+++ b/src/isode/compat/inst-man.sh
@@ -0,0 +1,167 @@
+: run this script through /bin/sh
+
+# for a non standard base directory, set MANDIR
+
+# set MANOPTS in config/CONFIG.make -- may be one of:
+# -bsd42 man<n>/<file>
+# -bsd44 cat<n>/thing.0
+# -ros man<n>/<file> -- using /etc/install
+# -sys5 <a|p|u>_man/man<n>/<file>
+# -aix <a|p|u>_man/man<n>/<file>
+# -local manl/<base>.l
+# -l man<n>/<base>.<n>l
+# -hpux hpux
+
+BINDIR="@(BINDIR)"
+ETCDIR="@(ETCDIR)"
+INCDIR="@(INCDIR)"
+LOGDIR="@(LOGDIR)"
+SBINDIR="@(SBINDIR)"
+MANDIR="@(MANDIR)"
+
+M=BSD42
+
+if test ! -d ${MANDIR}
+then
+ echo "inst-man: ${MANDIR} non-existant directory" 1>&2
+ exit 0
+fi
+
+for A in $*
+do
+ case $A in
+ -bsd42) M=BSD42
+ ;;
+
+ -bsd44) M=BSD44
+ ;;
+
+ -ros) M=ROS
+ ;;
+
+ -local) M=LOCAL
+ ;;
+
+ -l) M=L
+ ;;
+
+ -sys5) M=SYS5
+ ;;
+
+ -aix) M=AIX
+ ;;
+
+ -hpux) M=HPUX
+ ;;
+
+ -*) echo "inst-man: $A unknown" 1>&2
+ exit 1
+ ;;
+
+ *) if test ! -f $A
+ then
+ exit 0
+ fi
+ F=`basename $A`
+ E=`echo $F | sed -e "s%^.*\.\([1-8]\).*%\1%"`
+
+ X=/tmp/$F
+ rm -f $X
+ echo '.ds BD @(BINDIR)' > $X
+ echo '.ds ED @(ETCDIR)' >> $X
+ echo '.ds ID @(INCDIR)' >> $X
+ echo '.ds LD @(LOGDIR)' >> $X
+ echo '.ds SD @(SBINDIR)' >> $X
+ cat $A >> $X
+
+ case $M in
+ BSD42)
+ echo install -m 0644 -c $X ${MANDIR}man$E/$F
+ install -m 0644 -c $X ${MANDIR}man$E/$F
+ ;;
+
+ BSD44)
+ echo "nroff -man $X > ${MANDIR}cat$E/$F" | \
+ sed -e 's%\.\([1-8]\)[1-8cn]*$%.0%' | \
+ sh -ve
+ ;;
+
+ LOCAL)
+ (cd /tmp ; \
+ echo $F | \
+ sed -e "s%.*%install -m 0644 -c & ${MANDIR}manl/&%" | \
+ sed -e 's%\.[1-8cn]*$%.l%' | \
+ sh -ve)
+ ;;
+
+ L)
+ (cd /tmp ; \
+ echo "install -m 0644 -c $F ${MANDIR}man$E/$F" | \
+ sed -e 's%\.\([1-8]\)[1-8cn]*$%.\1l%' | \
+ sh -ve)
+ ;;
+
+ SYS5|AIX)
+ case $E in
+ 3) D=p_man ;;
+ 5) D=p_man E=4 ;;
+ 8) D=a_man E=1 ;;
+ *) D=u_man ;;
+ esac
+ echo /etc/install -m 0644 -f ${MANDIR}$D/man$E $X
+ /etc/install -m 0644 -f ${MANDIR}$D/man$E $X
+ case $D in
+ a_man)
+ F=`basename $A .8c`.1m
+ echo mv ${MANDIR}$D/man$E/$A \
+ ${MANDIR}$D/man$E/$F
+ mv ${MANDIR}$D/man$E/$A ${MANDIR}$D/man$E/$F
+ ;;
+
+ p_man)
+ if [ "$E" = "4" ]; then
+ F=`basename $A .5`.4
+ echo mv ${MANDIR}$D/man$E/$A \
+ ${MANDIR}$D/man$E/$F
+ mv ${MANDIR}$D/man$E/$A \
+ ${MANDIR}$D/man$E/$F
+ fi
+ ;;
+ esac
+ ;;
+
+ HPUX)
+ case $E in
+ 5) E=4 ;;
+ 8) E=1m ;;
+ esac
+ echo /etc/install -m 0644 -f ${MANDIR}man$E $X
+ /etc/install -m 0644 -f ${MANDIR}man$E $X
+ case $E in
+ 4) F=`basename $A .5`.4
+ echo mv ${MANDIR}man$E/$A ${MANDIR}man$E/$F
+ mv ${MANDIR}man$E/$A ${MANDIR}man$E/$F
+ ;;
+
+ 1m) F=`basename $A .8c`.1m
+ echo mv ${MANDIR}man$E/$A ${MANDIR}man$E/$F
+ mv ${MANDIR}man$E/$A ${MANDIR}man$E/$F
+ ;;
+ esac
+ ;;
+
+ ROS)
+ echo /etc/install -m 0644 -c $X ${MANDIR}man$E/$F
+ /etc/install -m 0644 -c $X ${MANDIR}man$E/$F
+ ;;
+
+ *) echo "inst-man: mode botch" 1>&2
+ exit 1
+ ;;
+ esac
+ rm -f $X
+ ;;
+ esac
+done
+
+exit 0
diff --git a/src/isode/compat/internet.c b/src/isode/compat/internet.c
new file mode 100644
index 000000000..b6e0ea548
--- /dev/null
+++ b/src/isode/compat/internet.c
@@ -0,0 +1,700 @@
+/* internet.c - TCP/IP abstractions */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:24 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:52 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:53 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:56 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* */
+
+#ifdef TCP
+#include "internet.h"
+
+
+extern int errno;
+
+/* Berkeley UNIX: 4.2 */
+
+#ifdef SOCKETS
+
+/* For real networking, nothing is better than 4BSD! */
+
+
+int start_tcp_client (sock, priv)
+struct sockaddr_in *sock;
+int priv;
+{
+ register int port;
+ int eindex,
+ sd;
+#ifdef BSD43
+ int onoff;
+#endif
+
+ if ((sd = socket (AF_INET, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK;
+ }
+
+ if (sock == NULL)
+ goto got_socket;
+
+ for (port = IPPORT_RESERVED - priv;; priv ? port-- : port++) {
+ sock -> sin_port = htons ((u_short) port);
+
+ if (bind (sd, (struct sockaddr *) sock, sizeof *sock) != NOTOK)
+ break;
+
+ switch (errno) {
+ case EADDRINUSE:
+ if (!priv || (port >= IPPORT_RESERVED / 2))
+ continue; /* else fall */
+
+ case EADDRNOTAVAIL:
+ default:
+ eindex = errno;
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_tcp_socket (sd);
+ errno = eindex;
+ return NOTOK;
+ }
+ }
+
+got_socket: ;
+#ifndef BSD43
+ if (setsockopt (sd, SOL_SOCKET, SO_KEEPALIVE, NULLCP, 0) == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("set SO_KEEPALIVE"));
+#else
+ onoff = 1;
+ if (setsockopt (sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &onoff,
+ sizeof onoff) == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("set SO_KEEPALIVE"));
+#endif
+
+ return sd;
+}
+
+/* */
+
+int start_tcp_server (sock, backlog, opt1, opt2)
+struct sockaddr_in *sock;
+int backlog,
+ opt1,
+ opt2;
+{
+ register int port;
+ int eindex,
+ sd;
+#ifdef BSD43
+ int onoff;
+#endif
+
+ if ((sd = socket (AF_INET, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK;
+ }
+
+ if (sock -> sin_port != 0) {
+ if (bind (sd, (struct sockaddr *) sock, sizeof *sock) != NOTOK)
+ goto got_socket;
+
+ eindex = errno;
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_tcp_socket (sd);
+ errno = eindex;
+ return NOTOK;
+ }
+
+ for (port = IPPORT_RESERVED;; port++) {
+ sock -> sin_port = htons ((u_short) port);
+
+ if (bind (sd, (struct sockaddr *) sock, sizeof *sock) != NOTOK)
+ break;
+
+ switch (errno) {
+ case EADDRINUSE:
+ continue;
+
+ case EADDRNOTAVAIL:
+ default:
+ eindex = errno;
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_tcp_socket (sd);
+ errno = eindex;
+ return NOTOK;
+ }
+ }
+
+got_socket: ;
+#ifndef BSD43
+ if (setsockopt (sd, SOL_SOCKET, SO_KEEPALIVE, NULLCP, 0) == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("set SO_KEEPALIVE"));
+ if (opt1 && setsockopt (sd, SOL_SOCKET, opt1, NULLCP, 0) == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("set socket option 0x%x", opt1));
+ if (opt2 && setsockopt (sd, SOL_SOCKET, opt2, NULLCP, 0) == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("set socket option 0x%x", opt2));
+#else
+ onoff = 1;
+ if (setsockopt (sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &onoff,
+ sizeof onoff) == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("set SO_KEEPALIVE"));
+ if (opt1
+ && setsockopt (sd, SOL_SOCKET, opt1, (char *) &onoff, sizeof onoff)
+ == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("set socket option 0x%x", opt1));
+ if (opt2
+ && setsockopt (sd, SOL_SOCKET, opt2, (char *) &onoff, sizeof onoff)
+ == NOTOK)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("set socket option 0x%x", opt2));
+#endif
+
+ (void) listen (sd, backlog);
+
+ return sd;
+}
+
+/* */
+
+int join_tcp_client (fd, sock)
+int fd;
+struct sockaddr_in *sock;
+{
+ int eindex,
+ len = sizeof *sock,
+ result;
+
+ if ((result = accept (fd, (struct sockaddr *) sock, &len)) == NOTOK) {
+ eindex = errno;
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("accept"));
+ errno = eindex;
+ }
+
+ return result;
+}
+
+/* */
+
+int join_tcp_server (fd, sock)
+int fd;
+struct sockaddr_in *sock;
+{
+ int eindex,
+ result;
+
+ if ((result = connect (fd, (struct sockaddr *) sock, sizeof *sock))
+ == NOTOK) {
+ eindex = errno;
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("connect"));
+ errno = eindex;
+ }
+
+ return result;
+}
+
+/* */
+
+close_tcp_socket (fd)
+int fd;
+{
+#ifdef never_do_this_if_from_join_tcp_client
+ (void) shutdown (fd, 2);
+#endif
+
+ return (close (fd));
+}
+
+#endif
+
+/* AT&T UNIX: 5r3 using TLI */
+
+
+/* AT&T UNIX: 5 with EXOS 8044 TCP/IP card */
+
+#ifdef EXOS
+
+/* If we had a getsockname() for the EXOS card, then we could postpone some
+ of the binding until connect time. But since we don't, our hand is forced
+ and we must prematurely bind the sockets to IP addresses. */
+
+
+start_tcp_client (sock, priv)
+struct sockaddr_in *sock;
+int priv;
+{
+ register int port;
+ int sd;
+ register struct hostent *hp;
+
+ if (sock == NULL)
+ return socket (SOCK_STREAM, 0, (struct sockaddr *) 0, SO_KEEPALIVE);
+
+ if (sock -> sin_addr.s_addr == 0) {
+ if ((hp = gethostbyname ("localhost")) == NULL) {
+ errno = EADDRNOTAVAIL;
+ return NOTOK;
+ }
+ sock -> sin_family = hp -> h_addrtype;
+ inaddr_copy (hp, sock);
+ }
+
+ for (port = IPPORT_RESERVED - priv;; priv ? port-- : port++) {
+ sock -> sin_port = htons ((u_short) port);
+
+ if ((sd = socket (SOCK_STREAM, 0, (struct sockaddr *) sock,
+ SO_KEEPALIVE)) != NOTOK)
+ return sd;
+
+ switch (errno) {
+ case EADDRINUSE:
+ if (!priv || (port >= IPPORT_RESERVED / 2))
+ continue; /* else fall */
+
+ case EADDRNOTAVAIL:
+ default:
+ return NOTOK;
+ }
+ }
+}
+
+/* */
+
+int start_tcp_server (sock, backlog, opt1, opt2)
+struct sockaddr_in *sock;
+int backlog,
+ opt1,
+ opt2;
+{
+ register int port;
+ int sd;
+ register struct hostent *hp;
+
+ if (backlog != 1)
+ return socket (SOCK_STREAM, 0, (struct sockaddr *) sock,
+ SO_ACCEPTCONN | SO_KEEPALIVE | opt1 | opt2);
+
+ if (sock -> sin_addr.s_addr == 0) {
+ if ((hp = gethostbyname ("localhost")) == NULL) {
+ errno = EADDRNOTAVAIL;
+ return NOTOK;
+ }
+ sock -> sin_family = hp -> h_addrtype;
+ inaddr_copy (hp, sock);
+ }
+
+ for (port = IPPORT_RESERVED;; port++) {
+ sock -> sin_port = htons ((u_short) port);
+
+ if ((sd = socket (SOCK_STREAM, 0, (struct sockaddr *) sock,
+ SO_ACCEPTCONN | SO_KEEPALIVE | opt1 | opt2)) != NOTOK)
+ return sd;
+
+ switch (errno) {
+ case EADDRINUSE:
+ continue;
+
+ case EADDRNOTAVAIL:
+ default:
+ return NOTOK;
+ }
+ }
+}
+
+#endif
+
+/* GETHOSTENT PLUS */
+
+static char *empty = NULL;
+#ifdef h_addr
+static char *addrs[2] = { NULL };
+#endif
+
+struct hostent *gethostbystring (s)
+char *s;
+{
+ register struct hostent *h;
+#ifndef DG
+ static u_long iaddr;
+#else
+ static struct in_addr iaddr;
+#endif
+ static struct hostent hs;
+
+ iaddr = inet_addr (s);
+#ifndef DG
+ if (iaddr == NOTOK)
+#else
+ if (iaddr.s_addr == NOTOK)
+#endif
+ return gethostbyname (s);
+
+ h = &hs;
+ h -> h_name = s;
+ h -> h_aliases = &empty;
+ h -> h_addrtype = AF_INET;
+ h -> h_length = sizeof (iaddr);
+#ifdef h_addr
+ h -> h_addr_list = addrs;
+ bzero ((char *) addrs, sizeof addrs);
+#endif
+ h -> h_addr = (char *) &iaddr;
+
+ return h;
+}
+
+/* AT&T UNIX: 5 with EXOS 8044 TCP/IP card */
+
+#ifdef EXOS
+
+long rhost ();
+char *raddr ();
+
+
+struct hostent *gethostbyaddr (addr, len, type)
+char *addr;
+int len,
+ type;
+{
+ long iaddr;
+ char *name;
+ static char buffer[BUFSIZ];
+ static struct hostent hs;
+ register struct hostent *h = &hs;
+
+ if (len != sizeof (long) || type != AF_INET)
+ return NULL;
+ bcopy (addr, (char *) &iaddr, len);
+ if ((name = raddr (iaddr)) == NULL)
+ return NULL;
+
+ (void) strcpy (buffer, name);
+ free (name);
+
+ h -> h_name = buffer;
+ h -> h_aliases = &empty;
+ h -> h_addrtype = type;
+ h -> h_length = len;
+ h -> h_addr = addr;
+
+ return h;
+}
+
+
+struct hostent *gethostbyname (name)
+char *name;
+{
+ static long iaddr;
+ static char buffer[BUFSIZ];
+ static struct hostent hs;
+ register struct hostent *h = &hs;
+
+ if ((iaddr = rhost (&name)) == NOTOK)
+ return NULL;
+
+ (void) strcpy (buffer, name);
+ free (name);
+
+ h -> h_name = buffer;
+ h -> h_aliases = &empty;
+ h -> h_addrtype = AF_INET;
+ h -> h_length = sizeof (iaddr);
+ h -> h_addr = (char *) &iaddr;
+
+ return h;
+
+}
+
+/* */
+
+/* really only need the "tsap" entry in this table... but why not? */
+
+static struct servent services[] = {
+ "tsap", NULL, 102, "tcp",
+ "miscellany", NULL, 17000, "lpp",
+
+ "echo", NULL, 7, "tcp", /* Network standard functions */
+ "echo", NULL, 7, "udp",
+ "sink", NULL, 9, "tcp",
+ "sink", NULL, 9, "udp",
+ "users", NULL, 11, "tcp",
+ "users", NULL, 11, "udp",
+ "daytime", NULL, 13, "tcp",
+ "daytime", NULL, 13, "udp",
+ "netstat", NULL, 15, "tcp",
+ "netstat", NULL, 15, "udp",
+ "qotd", NULL, 17, "tcp",
+ "qotd", NULL, 17, "udp",
+ "chargen", NULL, 19, "tcp",
+ "chargen", NULL, 19, "udp",
+ "ftp", NULL, 21, "tcp",
+ "telnet", NULL, 23, "tcp",
+ "smtp", NULL, 25, "tcp",
+ "imagen", NULL, 35, "udp",
+ "time", NULL, 37, "tcp",
+ "time", NULL, 37, "udp",
+ "name", NULL, 42, "tcp",
+ "name", NULL, 42, "udp",
+ "whois", NULL, 43, "tcp",
+ "whois", NULL, 43, "udp",
+ "nameserver", NULL, 53, "tcp",
+ "nameserver", NULL, 53, "udp",
+ "mtp", NULL, 57, "tcp",
+ "hostnames", NULL, 101, "tcp",
+ "pop", NULL, 109, "tcp",
+ "pwdgen", NULL, 129, "tcp",
+ "pwdgen", NULL, 129, "udp",
+ "x25bridge", NULL, 146, "tcp",
+ "iso-ip", NULL, 147, "udp",
+
+ "tftp", NULL, 69, "udp", /* Host specific functions */
+ "rje", NULL, 77, "tcp",
+ "nmui", NULL, 77, "udp",
+ "finger", NULL, 79, "tcp",
+ "finger", NULL, 79, "udp",
+ "link", NULL, 87, "tcp",
+ "supdup", NULL, 95, "tcp",
+ "path", NULL, 117, "tcp",
+
+ "exec", NULL, 512, "tcp", /* UNIX TCP sockets */
+ "login", NULL, 513, "tcp",
+ "shell", NULL, 514, "tcp",
+ "printer", NULL, 515, "tcp",
+ "rfile", NULL, 522, "tcp",
+ "ingreslock", NULL, 1524, "tcp",
+
+ "biff", NULL, 512, "udp", /* UNIX UDP sockets */
+ "who", NULL, 513, "udp",
+ "syslog", NULL, 514, "udp",
+ "talk", NULL, 517, "udp",
+ "routed", NULL, 520, "udp",
+ "router_1", NULL, 521, "udp",
+
+ NULL, &empty, 0, NULL
+};
+
+
+
+struct servent *getservbyname (name, proto)
+register char *name,
+ *proto;
+{
+ register struct servent *s;
+
+ for (s = services; s -> s_name; s++)
+ if (strcmp (name, s -> s_name) == 0
+ && strcmp (proto, s -> s_proto) == 0) {
+ if (s -> s_aliases == NULL) {
+ s -> s_aliases = &empty;
+ s -> s_port = htons ((u_short) s -> s_port);
+ }
+
+ return s;
+ }
+
+ return NULL;
+}
+
+/* */
+
+#define s2a(b) (((int) (b)) & 0xff)
+
+char *inet_ntoa (in)
+struct in_addr in;
+{
+ register char *s = (char *) &in;
+ static char addr[4 * 3 + 3 + 1];
+
+ (void) sprintf (addr, "%d.%d.%d.%d",
+ s2a (s[0]), s2a (s[1]), s2a (s[2]), s2a (s[3]));
+
+ return addr;
+}
+
+
+u_long inet_addr (cp)
+char *cp;
+{
+ register int base;
+ register char c;
+ register u_long val;
+ u_long parts[4];
+ register u_long *pp = parts;
+
+ for (;;) {
+ val = 0, base = 10;
+ if (*cp == '0')
+ base = 8, cp++;
+ if (*cp == 'x' || *cp == 'X')
+ base = 16, cp++;
+
+ for (; isxdigit ((u_char) (c = *cp)); cp++)
+ if (base == 16)
+ val = (val << 4) + (c + 10 - (islower ((u_char) c) ? 'a' : 'A'));
+ else
+ if (isdigit ((u_char) c))
+ val = (val * base) + (c - '0');
+ else
+ break;
+
+ switch (*cp) {
+ case '.':
+ if (pp >= parts + 4)
+ return NOTOK;
+ *pp++ = val, cp++;
+ continue;
+
+ default:
+ if (*cp && !isspace ((u_char) *cp))
+ return NOTOK;
+ *pp++ = val;
+ break;
+ }
+
+ break;
+ }
+
+ switch (pp - parts) {
+ case 1:
+ val = parts[0];
+ break;
+
+ case 2:
+ val = ((parts[0] & 0xff) << 24)
+ | (parts[1] & 0xffffff);
+ break;
+
+ case 3:
+ val = ((parts[0] & 0xff) << 24)
+ | ((parts[1] & 0xff) << 16)
+ | (parts[2] & 0xffff);
+ break;
+
+ case 4:
+ val = ((parts[0] & 0xff) << 24)
+ | ((parts[1] & 0xff) << 16)
+ | ((parts[2] & 0xff) << 8)
+ | (parts[3] & 0xff);
+ break;
+
+ default:
+ return NOTOK;
+ }
+
+ return htonl (val);
+}
+
+u_long inet_network (cp)
+char *cp;
+{
+ register int base;
+ register char c;
+ register u_long val;
+ u_long parts[4];
+ register u_long *pp = parts;
+
+ for (;;) {
+ val = 0, base = 10;
+ if (*cp == '0')
+ base = 8, cp++;
+ if (*cp == 'x' || *cp == 'X')
+ base = 16, cp++;
+
+ for (; isxdigit ((u_char) (c = *cp)); cp++)
+ if (base == 16)
+ val = (val << 4) + (c + 10 - (islower ((u_char) c) ? 'a' : 'A'));
+ else
+ if (isdigit ((u_char) c))
+ val = (val * base) + (c - '0');
+ else
+ break;
+
+ switch (*cp) {
+ case '.':
+ if (pp >= parts + 4)
+ return NOTOK;
+ *pp++ = val, cp++;
+ continue;
+
+ default:
+ if (*cp && !isspace ((u_char) *cp))
+ return NOTOK;
+ *pp++ = val;
+ break;
+ }
+
+ break;
+ }
+
+ switch (pp - parts) {
+ case 1:
+ val = (parts[0] & 0xff) << 24;
+ break;
+
+ case 2:
+ val = ((parts[0] & 0xff) << 24)
+ | ((parts[1] & 0xff) << 16);
+ break;
+
+ case 3:
+ val = ((parts[0] & 0xff) << 24)
+ | ((parts[1] & 0xff) << 16)
+ | ((parts[2] & 0xff) << 8)
+ break;
+
+ case 4:
+ val = ((parts[0] & 0xff) << 24)
+ | ((parts[1] & 0xff) << 16)
+ | ((parts[2] & 0xff) << 8)
+ | (parts[3] & 0xff);
+ break;
+
+ default:
+ return NOTOK;
+ }
+
+ return htonl (val);
+}
+#endif
+#endif
diff --git a/src/isode/compat/isoaddrs.c b/src/isode/compat/isoaddrs.c
new file mode 100644
index 000000000..c1a0d5aab
--- /dev/null
+++ b/src/isode/compat/isoaddrs.c
@@ -0,0 +1,1234 @@
+/* isoaddrs.c - simple parsing of ISODE addresses */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:26 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:54 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.2 1994/06/06 19:51:28 eichin
+ * NULL is not a char
+ *
+ * Revision 1.1 1994/05/31 20:33:55 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:57 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+#include "internet.h"
+#include "tailor.h"
+
+/* DATA */
+
+static int read_macros ();
+static int read_file ();
+static int add_macro ();
+static char *isomacros = "isomacros";
+
+#define MBUCKETS 128
+#define MHASH(nm) \
+ (((nm)[1]) ? (((chrcnv[((nm)[0])] - chrcnv[((nm)[1])]) & 0x1f) \
+ + ((chrcnv[(nm)[2]]) & 0x5f)) \
+ : (chrcnv[(nm)[0]]) & 0x7f)
+
+struct macro {
+ char *m_name;
+ char *m_value;
+
+ struct macro *m_chain;
+};
+
+static int inited = 0;
+static struct macro *Mbuckets[MBUCKETS];
+
+/* MACROS */
+
+static struct macro *name2macro (name)
+char *name;
+{
+ register struct macro *m;
+
+ read_macros ();
+
+ for (m = Mbuckets[MHASH (name)];
+ m && lexequ (m -> m_name, name);
+ m = m -> m_chain)
+ continue;
+
+ if (m)
+ LLOG (addr_log, LLOG_DEBUG,
+ ("MACRO \"%s\" VALUE \"%s\"", m -> m_name, m -> m_value));
+ else
+ LLOG (addr_log, LLOG_DEBUG,
+ ("lookup of MACRO \"%s\" failed", name));
+
+ return m;
+}
+
+/* */
+
+static struct macro *value2macro (value)
+char *value;
+{
+ register int i,
+ j,
+ k;
+ register struct macro *m,
+ *p,
+ **np,
+ **pp;
+
+ read_macros ();
+
+ p = NULL, i = 0;
+ k = strlen (value);
+ for (pp = (np = Mbuckets) + MBUCKETS; np < pp; np++)
+ for (m = *np; m; m = m -> m_chain)
+ if ((j = strlen (m -> m_value)) <= k
+ && j > i
+ && strncmp (value, m -> m_value, j) == 0)
+ p = m, i = j;
+
+ if (p)
+ LLOG (addr_log, LLOG_DEBUG,
+ ("MACRO \"%s\" VALUE \"%s\" differential %d",
+ p -> m_name, p -> m_value, k - strlen (p -> m_value)));
+ else
+ LLOG (addr_log, LLOG_DEBUG,
+ ("lookup of VALUE \"%s\" failed", value));
+
+ return p;
+}
+
+/* */
+
+static int read_macros ()
+{
+ register char *hp;
+ char buffer[BUFSIZ];
+
+ if (inited)
+ return;
+ inited = 1;
+
+ bzero ((char *) Mbuckets, sizeof Mbuckets);
+
+ read_file (isodefile (isomacros, 0));
+
+ if ((hp = getenv ("HOME")) == NULL)
+ hp = ".";
+ (void) sprintf (buffer, "%s/.isode_macros", hp);
+ read_file (buffer);
+}
+
+/* */
+
+static int read_file (file)
+char *file;
+{
+ register char *cp;
+ char buffer[BUFSIZ + 1],
+ *vec[NVEC + NSLACK + 1];
+ register FILE *fp;
+
+ if ((fp = fopen (file, "r")) == NULL)
+ return;
+
+ while (fgets (buffer, sizeof buffer, fp)) {
+ if (*buffer == '#')
+ continue;
+ if (cp = index (buffer, '\n'))
+ *cp = NULL;
+ if (str2vec (buffer, vec) < 2)
+ continue;
+
+ if (add_macro (vec[0], vec[1]) == NOTOK)
+ break;
+ }
+
+ (void) fclose (fp);
+}
+
+/* */
+
+static int add_macro (name, value)
+char *name,
+ *value;
+{
+ int i;
+ register char *cp;
+ char buffer[BUFSIZ];
+ register struct macro *m,
+ *p;
+
+ if (cp = index (value, '=')) {
+ *cp++ = NULL;
+ if ((p = name2macro (value)) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("macro \"%s\" references non-existant macro \"%s\"",
+ name, value));
+ return OK;
+ }
+
+ (void) sprintf (value = buffer, "%s%s", p -> m_value, cp);
+ }
+
+ if ((m = (struct macro *) calloc (1, sizeof *m)) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("calloc of macro structure failed"));
+ return NOTOK;
+ }
+ if ((m -> m_name = malloc ((unsigned) (strlen (name) + 1))) == NULL
+ || (m -> m_value = malloc ((unsigned) (strlen (value) + 1)))
+ == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("malloc of alias structure failed"));
+ if (m -> m_name)
+ free (m -> m_name);
+ free ((char *) m);
+ return NOTOK;
+ }
+ (void) strcpy (m -> m_name, name);
+ (void) strcpy (m -> m_value, value);
+
+ m -> m_chain = Mbuckets[i = MHASH (m -> m_name)];
+ Mbuckets[i] = m;
+
+ return OK;
+}
+
+/* */
+
+char *macro2str (name)
+char *name;
+{
+ register struct macro *m = name2macro (name);
+
+ return (m ? m -> m_value : NULLCP);
+}
+
+/* STR2PADDR */
+
+#define PS_INIT 0 /* <selector> or <network-address> */
+#define PS_SEL1 1 /* .. got one selector already */
+#define PS_SEL2 2 /* .. got two selectors already */
+#define PS_SEL3 3 /* <network-address> */
+
+
+static struct afi_info {
+ char *p_name;
+ char *p_dec0, *p_hex0, *p_dec1, *p_hex1, *p_ia5;
+ int p_idi_len, p_dec_dsp_len, p_hex_dsp_len;
+} afi_entries[] = {
+ "X121", "36", "37", "52", "53", NULL, 14, 24, 9,
+ "DCC", "38", "39", NULL, NULL, NULL, 3, 35, 14,
+ "TELEX", "40", "41", "54", "55", NULL, 8, 30, 12,
+ "PSTN", "42", "43", "56", "57", NULL, 12, 26, 10,
+ "ISDN", "44", "45", "58", "59", NULL, 15, 23, 9,
+ "ICD", "46", "47", NULL, NULL, NULL, 4, 34, 13,
+ "LOCAL", "48", "49", NULL, NULL, "50", 0, 38, 19,
+
+ NULL
+};
+#define p_ia5_dsp_len(pp) \
+ (pp -> p_ia5 == NULL ? NOTOK : (pp -> p_dec_dsp_len >> 1))
+
+
+static char sel1[TSSIZE];
+static char sel2[TSSIZE];
+static char sel3[TSSIZE];
+static char *sels[3] = {
+ sel1, sel2, sel3
+};
+
+
+#define IMPLODE(intres,octres,octval,intval,losing,loslab) \
+{ \
+ register int z = (intval); \
+ register char *y = (octval); \
+ register char *zp = y + z; \
+ \
+ while (zp-- > y) \
+ if (!isxdigit ((u_char) *zp)) { \
+loslab: ; \
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP, \
+ ("invalid hexstring: \"%*.*s\"", \
+ z, z, y)); \
+ return (losing); \
+ } \
+ if (z % 2) \
+ goto loslab; \
+ (intres) = implode ((u_char *) (octres), y, z); \
+}
+
+/* */
+
+struct PSAPaddr *str2paddr (str)
+char *str;
+{
+ register int state,
+ *lp;
+ int j,
+ lens[3];
+ register char *cp,
+ *dp,
+ *ep,
+ *fp,
+ *np,
+ **sp;
+ char buf1[BUFSIZ],
+ buf2[BUFSIZ],
+ nsap[NASIZE * 2 + 1];
+ register struct macro *m;
+ register struct afi_info *pp;
+ static int i = 0;
+ static struct PSAPaddr pas[2];
+ register struct PSAPaddr *pa = &pas[i++];
+ register struct SSAPaddr *sa = &pa -> pa_addr;
+ register struct TSAPaddr *ta = &sa -> sa_addr;
+ register struct NSAPaddr *na = ta -> ta_addrs;
+
+ LLOG (addr_log, LLOG_DEBUG, ("str2paddr: %s", str));
+ i = i % 2;
+
+ bzero ((char *) pa, sizeof *pa);
+ (void) strcpy (buf1, str);
+
+ state = PS_INIT;
+ sp = sels, lp = lens;
+
+ for (cp = buf1; *cp; )
+ switch (state) {
+ case PS_INIT:
+ case PS_SEL1:
+ case PS_SEL2:
+ switch (*cp) {
+ case '"': /* '"' <otherstring> '"' */
+ if ((cp = index (dp = cp + 1, '"')) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("missing double-quote in selector: %s",
+ str));
+ return NULLPA;
+ }
+ *cp++ = NULL;
+ (void) strcpy (*sp, dp);
+ *lp = strlen (dp);
+ break;
+
+ case '#': /* '#' <digitstring> */
+ j = 0;
+ for (cp++; isdigit ((u_char) *cp); cp++)
+ j = j * 10 + *cp - '0';
+ if (j > 0xffff) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("invalid #-style selector: %s", str));
+ return NULLPA;
+ }
+ (*sp)[0] = (j >> 8) & 0xff;
+ (*sp)[1] = j & 0xff;
+ *lp = 2;
+ break;
+
+ case '\'': /* "'" <hexstring> "'H" */
+ if ((cp = index (dp = cp + 1, '\'')) == NULL) {
+missing_quoteH: ;
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("missing 'H in selector: %s",str));
+ return NULLPA;
+ }
+ *cp++ = NULL;
+ if (*cp++ != 'H')
+ goto missing_quoteH;
+ IMPLODE (*lp, *sp, dp, strlen (dp), NULLPA, L1);
+ break;
+
+ case '/': /* empty selector */
+ *lp = 0;
+ break;
+
+ default:
+ goto stuff_selectors;
+ }
+ sp++, lp++;
+ if (*cp++ != '/') {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("missing selector seperator at position %d: %s",
+ cp - buf1, str));
+ return NULLPA;
+ }
+ state++;
+ break;
+
+stuff_selectors: ;
+ state = PS_SEL3;
+ /* and fall */
+
+ case PS_SEL3:
+ if ((cp = index (ep = cp, '|')) == NULL)
+ cp = ep + strlen (ep);
+ else
+ *cp++ = NULL;
+
+ if (dp = index (ep, '=')) {
+ *dp++ = NULL;
+ if ((m = name2macro (ep)) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("non-existant macro \"%s\"", ep));
+ return NULLPA;
+ }
+ (void) sprintf (ep = buf2, "%s%s", m -> m_value, dp);
+ }
+
+ {
+ register int k,
+ l,
+ n;
+ register struct ts_interim *ts,
+ *tp;
+
+ tp = NULL, n = 0;
+ k = strlen (ep);
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (ts -> ts_value
+ && (l = strlen (ts -> ts_value)) <= k
+ && l > n
+ && strncmp (ep, ts -> ts_value, l) == 0)
+ tp = ts, n = l;
+ if (tp)
+ na -> na_community = tp -> ts_subnet;
+ else {
+ /* Assume all the AFI+IDI[+DSP] formats are
+ * SUBNET_REALNS until later. Note that the X121 format
+ * without a DSP is converted to SUBNET_INT_X25 later.
+ */
+ for (pp = afi_entries; pp -> p_name; pp++)
+ if (strncmp (pp -> p_name, ep,
+ strlen (pp -> p_name) - 1) == 0 &&
+ ep[strlen (pp -> p_name)] == '+')
+ break;
+ if (!pp -> p_name) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unable to determine community for %s",ep));
+ return NULLPA;
+ }
+ na -> na_community = SUBNET_REALNS;
+ }
+ }
+
+ if ((ep = index (dp = ep, '+')) == NULL) {
+missing_seperator: ;
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("missing network-address seperator: %s", str));
+ return NULLPA;
+ }
+ *ep++ = NULL;
+ if (ta -> ta_naddr >= NTADDR) {
+#ifdef h_addr
+too_many: ;
+#endif
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("too many network addresses starting at position %d: %s",
+ dp - buf1 + 1, str));
+ return pa;
+ }
+
+ na -> na_stack = NA_NSAP;
+ LLOG (addr_log, LLOG_DEBUG,
+ ("str2paddr: dp='%s', ep='%s'", dp, ep));
+
+ if (lexequ (dp, "NS") == 0) {
+ IMPLODE (na -> na_addrlen, na -> na_address, ep,
+ strlen (ep), NULLPA, L2);
+ }
+ else {
+ int len;
+ char padchar;
+
+ for (pp = afi_entries; pp -> p_name; pp++)
+ if (lexequ (pp -> p_name, dp) == 0)
+ break;
+ if (!pp -> p_name) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown AFI \"%s\": %s", dp, str));
+ return NULLPA;
+ }
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+ for (fp = dp; *fp; fp++)
+ if (!isdigit ((u_char) *fp))
+ break;
+ if (*fp) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("invalid IDI \"%s\": %s", dp, cp));
+ return NULLPA;
+ }
+ if (lexequ (pp -> p_name, "X121") == 0 &&
+ *ep == NULL) {
+ /* X121 form -- should be more general
+ * Only applies if the DSP is NULL
+ */
+ (void) strcpy (nsap, dp);
+ if ((na -> na_dtelen = strlen (nsap)) > NSAP_DTELEN) {
+ dp = nsap;
+ goto invalid_dte;
+ }
+ (void) strcpy (na -> na_dte, nsap);
+#ifdef BRIDGE_X25
+ na -> na_stack = bridgediscrim (na) ? NA_BRG : NA_X25;
+#else
+ na -> na_stack = NA_X25;
+#endif
+ na -> na_community = SUBNET_INT_X25;
+ goto next;
+ }
+ switch (*ep) {
+ case 'd':
+ case 0:
+ if (*dp == '0' && pp -> p_dec1 != NULL)
+ fp = pp -> p_dec1, padchar = '1';
+ else
+ fp = pp -> p_dec0, padchar = '0';
+ (void) strcpy (nsap, fp);
+ fp = nsap + strlen (nsap);
+ for (len = pp -> p_idi_len - strlen (dp);
+ len > 0;
+ len--)
+ *fp++ = padchar;
+ (void) strcpy (fp, dp);
+ fp += strlen (fp);
+ if (*ep != NULL)
+ (void) strcpy (fp, ep + 1);
+ goto handle_dsp;
+
+ case 'x':
+ if (*dp == '0' && pp -> p_hex1 != NULL)
+ fp = pp -> p_hex1, padchar = '1';
+ else
+ fp = pp -> p_hex0, padchar = '0';
+ (void) strcpy (nsap, fp);
+ fp = nsap + strlen (nsap);
+ for (len = pp -> p_idi_len - strlen (dp);
+ len > 0;
+ len--)
+ *fp++ = padchar;
+ (void) strcpy (fp, dp);
+ /* Odd length IDI padded below */
+ goto handle_dsp;
+
+ case 'l':
+ if (pp -> p_ia5 == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("No IA5 syntax for AFI \"%s\"",
+ pp -> p_name));
+ return NULLPA;
+ }
+ (void) strcpy (nsap, pp -> p_ia5);
+ goto handle_dsp;
+
+handle_dsp: ;
+ np = nsap, dp = na -> na_address;
+ while (*np) {
+ *dp = (*np++ - '0') << 4;
+ if (*np)
+ *dp++ |= (*np++ - '0') & 0x0f;
+ else
+ *dp++ |= 0x0f;
+ }
+ na -> na_addrlen = dp - na -> na_address;
+ if (*ep == 'x') {
+ IMPLODE (j, dp, ep + 1, strlen (ep + 1),
+ NULLPA, L3);
+ na -> na_addrlen += j;
+ }
+ else
+ if (*ep == 'l') {
+ (void) strcpy (dp, ep + 1);
+ na -> na_addrlen += strlen (ep + 1);
+ }
+ break;
+
+ default:
+ if (*dp == '0' && pp -> p_dec1 != NULL)
+ fp = pp -> p_dec1, padchar = '1';
+ else
+ fp = pp -> p_dec0, padchar = '0';
+ (void) strcpy (nsap, fp);
+ fp = nsap + strlen (nsap);
+ for (len = pp -> p_idi_len - strlen (dp);
+ len > 0;
+ len--)
+ *fp++ = padchar;
+ (void) strcpy (fp, dp);
+ if (strncmp ("RFC-1006+", ep,
+ sizeof "RFC-1006+" - 1) == 0) {
+#ifdef h_addr
+ register char **ap;
+#endif
+ register struct hostent *hp;
+
+ na -> na_stack = NA_TCP;
+ ep += sizeof "RFC-1006+" - 1;
+ if ((ep = index (dp = ep, '+')) == NULL)
+ goto missing_seperator;
+ *ep++ = NULL;
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+
+ if ((hp = gethostbystring (dp)) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%s: unknown host", dp));
+ return NULLPA;
+ }
+ (void) strcpy (na -> na_domain,
+ inet_ntoa (*(struct in_addr *)
+ hp -> h_addr));
+ if (*ep) {
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+ na -> na_port = htons ((u_short) atoi(dp));
+
+ if (*ep)
+ na -> na_tset = atoi (ep);
+ }
+#ifdef h_addr
+ for (ap = hp -> h_addr_list + 1; *ap; ap++) {
+ ta -> ta_naddr++, na++;
+
+ if (ta -> ta_naddr >= NTADDR)
+ goto too_many;
+ bcopy ((char *) (na - 1), (char *) na,
+ sizeof *na);
+ (void) strcpy (na -> na_domain,
+ inet_ntoa (*(struct in_addr *) *ap));
+ }
+#endif
+ break;
+ }
+ if (strncmp ("X.25(80)+", ep,
+ sizeof "X.25(80)+" - 1) == 0) {
+ na -> na_stack = NA_X25;
+ ep += sizeof "X.25(80)+" - 1;
+ if ((ep = index (dp = ep, '+')) == NULL)
+ goto missing_seperator;
+ *ep++ = NULL;
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+ for (np = dp; *np; np++)
+ if (!isdigit ((u_char) *np)) {
+invalid_dte: ;
+ SLOG (addr_log, LLOG_EXCEPTIONS,
+ NULLCP,
+ ("invalid DTE \"%s\": %s",
+ dp, str));
+ return NULLPA;
+ }
+ if (np - dp > NSAP_DTELEN + 1)
+ goto invalid_dte;
+ (void) strcpy (na -> na_dte, dp);
+ na -> na_dtelen = strlen (na -> na_dte);
+ if (*ep) {
+ char *cudf,
+ *clen;
+
+ if ((ep = index (dp = ep, '+')) == NULL)
+ goto missing_seperator;
+ *ep++ = NULL;
+
+ if (lexequ (dp, "CUDF") == 0) {
+ cudf = na -> na_cudf;
+ clen = &na -> na_cudflen;
+ j = sizeof na -> na_cudf;
+ }
+ else
+ if (lexequ (dp, "PID") == 0) {
+ cudf = na -> na_pid;
+ clen = &na -> na_pidlen;
+ j = sizeof na -> na_pid;
+ }
+ else {
+invalid_field: ;
+ SLOG (addr_log, LLOG_EXCEPTIONS,
+ NULLCP,
+ ("invalid field \"%s\": %s",
+ dp, str));
+ return NULLPA;
+ }
+ if (j * 2 < ((int)strlen (ep)))
+ goto invalid_field;
+ IMPLODE (j, cudf, ep, strlen (ep),
+ NULLPA, L4);
+ *clen = j & 0xff;
+ }
+#ifdef BRIDGE_X25
+ na -> na_stack = bridgediscrim (na) ? NA_BRG
+ : NA_X25;
+#endif
+ break;
+ }
+#ifdef notdef
+ if (lexequ ("ECMA-117-Binary", ep) == 0) {
+ /* some day support this... */
+ break;
+ }
+ if (lexequ ("ECMA-117-Decimal", ep) == 0) {
+ /* some day support this... */
+ break;
+ }
+#endif
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown DSP \"%s\": %s", ep, str));
+ return NULLPA;
+ }
+ }
+next: ;
+ ta -> ta_naddr++, na++;
+ break;
+ }
+
+ switch (sp - sels) {
+ case 3: /* PSEL+SSEL+TSEL */
+ bcopy (*--sp, ta -> ta_selector,
+ ta -> ta_selectlen = *--lp);
+ bcopy (*--sp, sa -> sa_selector,
+ sa -> sa_selectlen = *--lp);
+ bcopy (*--sp, pa -> pa_selector,
+ pa -> pa_selectlen = *--lp);
+ break;
+
+ case 2: /* SSEL+TSEL */
+ bcopy (*--sp, ta -> ta_selector,
+ ta -> ta_selectlen = *--lp);
+ bcopy (*--sp, sa -> sa_selector,
+ sa -> sa_selectlen = *--lp);
+ break;
+
+ case 1: /* TSEL */
+ bcopy (*--sp, ta -> ta_selector,
+ ta -> ta_selectlen = *--lp);
+ break;
+
+ default:
+ break;
+ }
+
+ return pa;
+}
+
+/* */
+
+int macro2comm (name, ts)
+char *name;
+register struct ts_interim *ts;
+{
+ int j,
+ len;
+ register char *ap,
+ *cp,
+ *dp,
+ *ep,
+ *fp,
+ *np;
+ char padchar,
+ addr[NASIZE * 2 + 1],
+ buffer[BUFSIZ];
+ register struct afi_info *pp;
+
+ ts -> ts_length = 0, ts -> ts_syntax = NA_NSAP;
+ if ((cp = macro2str (name)) == NULLCP)
+ return NOTOK;
+ ts -> ts_value = cp;
+ (void) strcpy (buffer, cp);
+ ap = addr;
+
+ if ((ep = index (dp = buffer, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+
+ if (lexequ (dp, "NS") == 0) {
+ IMPLODE (ts -> ts_length, ts -> ts_prefix, ep, strlen (ep),
+ NOTOK, L5);
+
+ return OK;
+ }
+
+ for (pp = afi_entries; pp -> p_name; pp++)
+ if (lexequ (pp -> p_name, dp) == 0)
+ break;
+ if (!pp -> p_name) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown AFI \"%s\": %s", dp, cp));
+ return NOTOK;
+ }
+
+ if (!ep) {
+ /* No IDI */
+ (void) strcpy (ap, pp -> p_dec0);
+ ap += strlen (ap);
+ goto out;
+ }
+
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+
+ for (fp = dp; *fp; fp++)
+ if (!isdigit ((u_char) *fp))
+ break;
+ if (*fp) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("invalid IDI \"%s\": %s", dp, cp));
+ return NOTOK;
+ }
+
+ if (lexequ (pp -> p_name, "X121") == 0 && *ep == NULL) {
+ /* Only used if there is no DSP */
+ (void) strcpy (ap, dp);
+ ap += strlen (ap);
+
+ ts -> ts_syntax = NA_X25;
+ ts -> ts_subnet = SUBNET_INT_X25;
+ goto out;
+ }
+
+ switch (*ep) {
+ case 'd':
+ case 0:
+ if (*dp == '0' && pp -> p_dec1 != NULL)
+ fp = pp -> p_dec1, padchar = '1';
+ else
+ fp = pp -> p_dec0, padchar = '0';
+ (void) strcpy (ap, fp);
+ ap += strlen (ap);
+ for (len = pp -> p_idi_len - strlen (dp); len > 0; len--)
+ *ap++ = padchar;
+ (void) strcpy (ap, dp);
+ ap += strlen (ap);
+ if (*ep != NULL)
+ (void) strcpy (ap, ep + 1);
+ break;
+
+ case 'x':
+ if (*dp == '0' && pp -> p_hex1 != NULL)
+ fp = pp -> p_hex1, padchar = '1';
+ else
+ fp = pp -> p_hex0, padchar = '0';
+ (void) strcpy (ap, fp);
+ ap += strlen (ap);
+ for (len = pp -> p_idi_len - strlen (dp); len > 0; len--)
+ *ap++ = padchar;
+ (void) strcpy (ap, dp);
+ /* Odd length IDI padded below */
+ break;
+
+ case 'l':
+ if (pp -> p_ia5 == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("No IA5 syntax for AFI \"%s\": %s", pp -> p_name, cp));
+ return NOTOK;
+ }
+ (void) strcpy (ap, pp -> p_ia5);
+ break;
+
+ default:
+ if (*dp == '0' && pp -> p_dec1 != NULL)
+ fp = pp -> p_dec1, padchar = '1';
+ else
+ fp = pp -> p_dec0, padchar = '0';
+ (void) strcpy (ap, fp);
+ ap += strlen (ap);
+ for (len = pp -> p_idi_len - strlen (dp); len > 0; len--)
+ *ap++ = padchar;
+ (void) strcpy (ap, dp);
+ ap += strlen (ap);
+
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+ if (lexequ (dp, "RFC-1006") == 0)
+ ts -> ts_syntax = NA_TCP;
+ else
+ if (lexequ (dp, "X.25(80)") == 0)
+ ts -> ts_syntax = NA_X25;
+ else {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown DSP \"%s\": %s", dp, cp));
+ return NOTOK;
+ }
+ if ((ep = index (dp = ep, '+')) == NULL)
+ ep = dp + strlen (dp);
+ else
+ *ep++ = NULL;
+
+ (void) strcpy (ap, dp);
+
+ if (*ep) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("invalid MACRO for community \"%s\": %s", name, cp));
+ return NOTOK;
+ }
+ break;
+ }
+
+out: ;
+ ap = addr, np = ts -> ts_prefix;
+ while (*ap) {
+ *np = (*ap++ - '0') << 4;
+ if (*ap)
+ *np++ |= (*ap++ - '0') & 0x0f;
+ else
+ *np++ |= 0x0f;
+ }
+ switch (*ep) {
+ case 'x':
+ IMPLODE (j, np, ep + 1, strlen (ep + 1), NOTOK, L6);
+ np += j;
+ break;
+
+ case 'l':
+ (void) strcpy (np, ep + 1);
+ np += strlen (ep + 1);
+ break;
+
+ default:
+ break;
+ }
+ ts -> ts_length = np - ts -> ts_prefix;
+
+ return OK;
+}
+
+/* PADDR2STR */
+
+static char *SEL2STR (sel, len)
+char *sel;
+int len;
+{
+ register char *cp,
+ *dp,
+ *ep;
+ static char buffer[PSSIZE * 2 + 4];
+
+ if (len <= 0)
+ return "";
+
+ cp = buffer;
+ *cp++ = '"';
+ for (ep = (dp = sel) + len; dp < ep; dp++) {
+ switch (*dp) {
+ case '+':
+ case '-':
+ case '.':
+ break;
+
+ default:
+ if (!isalnum ((u_char) *dp)) {
+ cp = buffer;
+ *cp++ = '\'';
+ cp += explode (cp, (u_char *) sel, len);
+ (void) strcpy (cp, "'H");
+ return buffer;
+ }
+ break;
+ }
+
+ *cp++ = *dp;
+ }
+ *cp++ = '"';
+ *cp = NULL;
+
+ return buffer;
+}
+
+/* */
+
+char *_paddr2str (pa, na, compact)
+register struct PSAPaddr *pa;
+register struct NSAPaddr *na;
+int compact;
+{
+ register int n;
+ int first;
+ register char *bp,
+ *cp,
+ *dp;
+ register struct macro *m;
+ register struct SSAPaddr *sa;
+ register struct TSAPaddr *ta;
+ register struct NSAPaddr *ca;
+ static int i = 0;
+ static char buf1[BUFSIZ],
+ buf2[BUFSIZ];
+ static char *bufs[] = { buf1, buf2 };
+
+ LLOG (addr_log, LLOG_DEBUG,
+ ("paddr2str: pa=%x, na=%x, compact=%d", pa, na, compact));
+
+ bp = cp = bufs[i++];
+ i = i % 2;
+
+ if (pa == NULLPA) {
+bad_pa: ;
+ (void) strcpy (bp, "NULLPA");
+ return bp;
+ }
+ sa = &pa -> pa_addr;
+ ta = &sa -> sa_addr;
+
+ if (na)
+ n = 1;
+ else
+ if ((n = ta -> ta_naddr) > 0)
+ na = ta -> ta_addrs;
+
+ if (pa -> pa_selectlen > 0) {
+ (void) sprintf (cp, "%s/",
+ SEL2STR (pa -> pa_selector, pa -> pa_selectlen));
+ cp += strlen (cp);
+ }
+ if (sa -> sa_selectlen > 0 || bp != cp) {
+ (void) sprintf (cp, "%s/",
+ SEL2STR (sa -> sa_selector, sa -> sa_selectlen));
+ cp += strlen (cp);
+ }
+ if (ta -> ta_selectlen > 0 || bp != cp) {
+ (void) sprintf (cp, "%s/",
+ SEL2STR (ta -> ta_selector, ta -> ta_selectlen));
+ cp += strlen (cp);
+ }
+
+ /*
+ ** This may happen when a wildcard TSAP is bound over a
+ ** wildcard NSAP (i.e. the address of the endpoint onto which
+ ** a connection is accepted via the TLI under some implementations)
+ **
+ ** Should we do this or return "/"?
+ */
+ if (n == 0 && bp == cp)
+ goto bad_pa;
+
+ for (first = 1; n > 0; na++, n--) {
+ register struct ts_interim *ts;
+
+ if (first)
+ first = 0;
+ else
+ *cp++ = '|';
+
+ if (compact > 0) {
+ if ((ca = na2norm (na)) == NULLNA)
+ goto bad_pa;
+
+ (void) strcpy (cp, "NS+");
+ cp += strlen (cp);
+
+ cp += explode (cp, (u_char *) ca -> na_address, ca -> na_addrlen);
+ *cp = NULL;
+ continue;
+ }
+
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (ts -> ts_subnet == na -> na_community)
+ break;
+ if (!ts -> ts_name) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unable to find community #%d", na -> na_community));
+ goto bad_pa;
+ }
+ if (!ts -> ts_value) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("community \"%s\" (subnet #%d) has no corresponding MACRO",
+ ts -> ts_name, na -> na_community));
+ goto bad_pa;
+ }
+ (void) strcpy (dp = cp, ts -> ts_value);
+ cp += strlen (cp) - 1;
+ if (*cp != '+')
+ *++cp = '+', *++cp = NULL;
+ else
+ cp++;
+
+ switch (na -> na_stack) {
+ struct afi_info *a;
+
+ case NA_NSAP:
+ (void) strcpy (cp = dp, "NS+");
+ cp += strlen (cp);
+
+ cp += explode (cp, (u_char *) na -> na_address, na -> na_addrlen);
+ *cp = NULL;
+
+ /* Use afi_info to pretty print as AFI+IDI+DSP */
+ for (cp = dp + 3, a = afi_entries; a->p_name; a++) {
+ char pad, dspmark;
+ char buf[BUFSIZ];
+ char *dsp;
+
+ if (a->p_dec0 && bcmp(a->p_dec0, cp, 2) == 0)
+ (pad = a->p_dec1 ? '0' : '\0'), dspmark = 'd';
+ else if (a->p_dec1 && bcmp(a->p_dec1, cp, 2) == 0)
+ pad = '1', dspmark = 'd';
+ else if (a->p_hex0 && bcmp(a->p_hex0, cp, 2) == 0)
+ (pad = a->p_hex1 ? '0' : '\0'), dspmark = 'x';
+ else if (a->p_hex1 && bcmp(a->p_hex1, cp, 2) == 0)
+ pad = '1', dspmark = 'x';
+ else if (a->p_ia5 && bcmp(a->p_ia5, cp, 2) == 0)
+ pad = '\0', dspmark = 'l';
+ else
+ continue;
+ cp += 2; /* skip AFI */
+ dsp = cp + a->p_idi_len; /* find DSP */
+ while (cp < dsp && *cp == pad)
+ cp++; /* skip pad chars */
+ (void) sprintf(buf, "%s+%.*s", a->p_name, dsp - cp, cp);
+
+ /*
+ * If we have an odd number of characters in IDI &
+ * the next character is 'f' then it must be a pad
+ * because a pad is only not inserted if the DSP is
+ * decimal syntax in which case 'f' is illegal,
+ * otherwise check for a trailing pad if decimal
+ * syntax.
+ */
+ if ((dsp - (dp + 3)) % 2 && *dsp == 'f')
+ dsp++;
+ else if (dspmark == 'd' && *(cp = dsp + strlen(dsp) - 1) ==
+ 'f')
+ *cp = '\0';
+ if (*dsp)
+ (void) sprintf(buf+strlen(buf), "+%c%s", dspmark, dsp);
+ (void) strcpy(dp, buf);
+ cp = dp + strlen(dp);
+ break;
+ }
+ break;
+
+
+ case NA_TCP:
+ (void) strcpy (cp, na -> na_domain);
+ cp += strlen (cp);
+ if (na -> na_port) {
+ (void) sprintf (cp, "+%d", (int) ntohs (na -> na_port));
+ cp += strlen (cp);
+
+ if (na -> na_tset) {
+ (void) sprintf (cp, "+%d", (int) na -> na_tset);
+ cp += strlen (cp);
+ }
+ }
+ break;
+
+ case NA_X25:
+ case NA_BRG:
+ if (na -> na_community == SUBNET_INT_X25
+ && na -> na_cudflen == 0
+ && na -> na_pidlen == 0
+ && na -> na_dte[0] != '0') {
+ (void) sprintf (cp = dp, "X121+%s", na -> na_dte);
+ cp += strlen (cp);
+ }
+ else {
+ (void) strcpy (cp, na -> na_dte);
+ cp += strlen (cp);
+ if (na -> na_pidlen > 0) {
+ (void) strcpy (cp, "+PID+");
+ cp += strlen (cp);
+
+ cp += explode (cp, (u_char *) na -> na_pid,
+ (int) na -> na_pidlen);
+ }
+ else
+ if (na -> na_cudflen > 0) {
+ (void) strcpy (cp, "+CUDF+");
+ cp += strlen (cp);
+
+ cp += explode (cp, (u_char *) na -> na_cudf,
+ (int) na -> na_cudflen);
+ }
+ *cp = NULL;
+ }
+ break;
+
+ default:
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown address type 0x%x", na -> na_stack));
+ goto bad_pa;
+ }
+
+ SLOG (addr_log, LLOG_DEBUG, NULLCP, ("dp = %s",dp));
+
+ if (!compact && (m = value2macro (dp))) {
+ char buffer[BUFSIZ];
+
+ (void) sprintf (buffer, "%s=%s", m -> m_name,
+ dp + strlen (m -> m_value));
+ (void) strcpy (dp, buffer);
+ cp = dp + strlen (dp);
+ }
+ }
+ *cp = NULL;
+
+ return bp;
+}
+
+/* */
+
+#ifdef PEP_TEST
+free_macros () {
+ register int i;
+ register struct macro *m,
+ *p;
+
+ for (i = MBUCKETS; i-- > 0; )
+ for (p = Mbuckets[i]; p; p = m) {
+ m = p -> m_chain;
+
+ if (p -> m_name)
+ free (p -> m_name);
+ if (p -> m_value)
+ free (p -> m_value);
+
+ free (p);
+ }
+}
+#endif
diff --git a/src/isode/compat/isofiles.c b/src/isode/compat/isofiles.c
new file mode 100644
index 000000000..393769c61
--- /dev/null
+++ b/src/isode/compat/isofiles.c
@@ -0,0 +1,64 @@
+/* isofiles.c - ISODE files */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:28 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:56 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:57 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:58 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* */
+
+char *_isodefile (path, file)
+char *path,
+ *file;
+{
+ static char buffer[BUFSIZ];
+
+ isodetailor (NULLCP, 0); /* not really recursive */
+
+ if (*file == '/'
+ || (*file == '.'
+ && (file[1] == '/'
+ || (file[1] == '.' && file[2] == '/'))))
+ (void) strcpy (buffer, file);
+ else
+ (void) sprintf (buffer, "%s%s", path, file);
+
+ return buffer;
+}
diff --git a/src/isode/compat/isohost.c b/src/isode/compat/isohost.c
new file mode 100644
index 000000000..2f6ddeb79
--- /dev/null
+++ b/src/isode/compat/isohost.c
@@ -0,0 +1,94 @@
+/* isohost.c - getlocalhost */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:30 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:15:58 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:33:58 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:17:58 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#ifdef TCP
+#include "internet.h"
+#endif
+#include "tailor.h"
+#ifdef SYS5
+#include <sys/utsname.h>
+#endif
+
+/* */
+
+char *getlocalhost () {
+ register char *cp;
+#ifdef TCP
+ register struct hostent *hp;
+#endif
+#ifdef SYS5
+ struct utsname uts;
+#endif
+ static char buffer[BUFSIZ];
+
+ if (buffer[0])
+ return buffer;
+
+ isodetailor (NULLCP, 0);
+ if (*isodename)
+ (void) strcpy (buffer, isodename);
+ else {
+#if !defined(SOCKETS) && !defined(SYS5)
+ (void) strcpy (buffer, "localhost");
+#endif
+#ifdef SOCKETS
+ (void) gethostname (buffer, sizeof buffer);
+#endif
+#ifdef SYS5
+ (void) uname (&uts);
+ (void) strcpy (buffer, uts.nodename);
+#endif
+
+#ifdef TCP
+ if (hp = gethostbyname (buffer))
+ (void) strcpy (buffer, hp -> h_name);
+ else
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%s: unknown host", buffer));
+#endif
+
+ if (cp = index (buffer, '.'))
+ *cp = NULL;
+ }
+
+ return buffer;
+}
diff --git a/src/isode/compat/isologs.sh b/src/isode/compat/isologs.sh
new file mode 100644
index 000000000..4cf9c6a70
--- /dev/null
+++ b/src/isode/compat/isologs.sh
@@ -0,0 +1,36 @@
+: run this script through /bin/sh
+
+x=`fgrep logpath @(ETCDIR)isotailor 2>/dev/null | awk '{ print $2 }'`
+if [ "x$x" != x ]; then
+ cd $x
+else
+ cd @(LOGDIR)
+fi
+
+rm -f iso.*.log ros.*.log [0-9]*.log
+
+for A in [a-z]*.log
+do
+ x=2
+ while [ $x -gt 0 ];
+ do
+ y=`expr $x - 1`
+ mv $A-$y $A-$x >/dev/null 2>&1
+ x=$y
+ done
+
+ if [ ! -f $A ];
+ then
+ continue
+ fi
+
+ if [ -s $A ];
+ then
+ mv $A $A-0 >/dev/null 2>&1
+ fi
+
+ > $A
+ chmod 666 $A
+done
+
+exit 0
diff --git a/src/isode/compat/isoman.rf b/src/isode/compat/isoman.rf
new file mode 100644
index 000000000..1fc21935f
--- /dev/null
+++ b/src/isode/compat/isoman.rf
@@ -0,0 +1,8 @@
+.\" isoman.rf - include file for ISODE manual entries
+.\" Sat Nov 4 23:15:36 1989 Marshall T. Rose <mrose@cheetah.ca.psi.com>
+
+.ds BD @(BINDIR)
+.ds ED @(ETCDIR)
+.ds ID @(INCDIR)
+.ds LD @(LOGDIR)
+.ds SD @(SBINDIR)
diff --git a/src/isode/compat/isoservent.c b/src/isode/compat/isoservent.c
new file mode 100644
index 000000000..ef2d1904c
--- /dev/null
+++ b/src/isode/compat/isoservent.c
@@ -0,0 +1,144 @@
+/* isoservent.c - look-up ISODE services */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:36 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:04 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:04 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:00 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoservent.h"
+#include "tailor.h"
+
+/* DATA */
+
+static char *isoservices = "isoservices";
+
+static FILE *servf = NULL;
+static int stayopen = 0;
+
+static struct isoservent iss;
+
+/* */
+
+int setisoservent (f)
+int f;
+{
+ if (servf == NULL)
+ servf = fopen (isodefile (isoservices, 0), "r");
+ else
+ rewind (servf);
+ stayopen |= f;
+
+ return (servf != NULL);
+}
+
+
+int endisoservent () {
+ if (servf && !stayopen) {
+ (void) fclose (servf);
+ servf = NULL;
+ }
+
+ return 1;
+}
+
+/* */
+
+struct isoservent *getisoservent () {
+ int mask,
+ vecp;
+ register char *cp;
+ register struct isoservent *is = &iss;
+ static char buffer[BUFSIZ + 1],
+ file[BUFSIZ];
+ static char *vec[NVEC + NSLACK + 1];
+
+ if (servf == NULL
+ && (servf = fopen (isodefile (isoservices, 0), "r")) == NULL)
+ return NULL;
+
+ bzero ((char *) is, sizeof *is);
+
+ while (fgets (buffer, sizeof buffer, servf) != NULL) {
+ if (*buffer == '#')
+ continue;
+ if (cp = index (buffer, '\n'))
+ *cp = NULL;
+ if ((vecp = str2vecX (buffer, vec, 1 + 1, &mask, NULL, 1)) < 3)
+ continue;
+
+ if ((cp = index (vec[0], '/')) == NULL)
+ continue;
+ *cp++ = NULL;
+
+ is -> is_provider = vec[0];
+ is -> is_entity = cp;
+ is -> is_selectlen = str2sel (vec[1], (mask & (1 << 1)) ? 1 : 0,
+ is -> is_selector, ISSIZE);
+
+ is -> is_vec = vec + 2;
+ is -> is_tail = vec + vecp;
+
+ if (strcmp (cp = is -> is_vec[0], "tsapd-bootstrap"))
+ (void) strcpy (is -> is_vec[0] = file, isodefile (cp, 1));
+
+ return is;
+ }
+
+ return NULL;
+}
+
+/* */
+
+#ifdef DEBUG
+_printsrv (is)
+register struct isoservent *is;
+{
+ register int n = is -> is_tail - is -> is_vec - 1;
+ register char **ap = is -> is_vec;
+
+ LLOG (addr_log, LLOG_DEBUG,
+ ("\tENT: \"%s\" PRV: \"%s\" SEL: %s",
+ is -> is_entity, is -> is_provider,
+ sel2str (is -> is_selector, is -> is_selectlen, 1)));
+
+ for (; n >= 0; ap++, n--)
+ LLOG (addr_log, LLOG_DEBUG,
+ ("\t\t%d: \"%s\"\n", ap - is -> is_vec, *ap));
+}
+#endif
diff --git a/src/isode/compat/lexequ.c b/src/isode/compat/lexequ.c
new file mode 100644
index 000000000..e0f242004
--- /dev/null
+++ b/src/isode/compat/lexequ.c
@@ -0,0 +1,68 @@
+/* lexequ.c - Compare two strings ignoring case */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:37 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:07 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:06 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:00 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+
+/* */
+
+lexequ (str1, str2)
+register char *str1,
+ *str2;
+{
+ if (str1 == NULL)
+ if (str2 == NULL)
+ return (0);
+ else
+ return (-1);
+
+ if (str2 == NULL)
+ return (1);
+
+ while (chrcnv[*str1] == chrcnv[*str2]) {
+ if (*str1++ == NULL)
+ return (0);
+ str2++;
+ }
+
+ if (chrcnv[*str1] > chrcnv[*str2])
+ return (1);
+ else
+ return (-1);
+}
diff --git a/src/isode/compat/lexnequ.c b/src/isode/compat/lexnequ.c
new file mode 100644
index 000000000..666f7f4b1
--- /dev/null
+++ b/src/isode/compat/lexnequ.c
@@ -0,0 +1,73 @@
+/* lexnequ.c - Compare two strings ignoring case upto n octets */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:39 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:08 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:08 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:01 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+
+/* */
+
+lexnequ (str1, str2, len)
+register char *str1,
+ *str2;
+int len;
+{
+ register int count = 1;
+
+ if (str1 == NULL)
+ if (str2 == NULL)
+ return (0);
+ else
+ return (1);
+
+ if (str2 == NULL)
+ return (-1);
+
+ while (chrcnv[*str1] == chrcnv[*str2++]) {
+ if (count++ >= len)
+ return (0);
+ if (*str1++ == NULL)
+ return (0);
+ }
+
+ str2--;
+ if (chrcnv[*str1] > chrcnv[*str2])
+ return (1);
+ else
+ return (-1);
+}
diff --git a/src/isode/compat/libicompat.3 b/src/isode/compat/libicompat.3
new file mode 100644
index 000000000..5eea8d7c5
--- /dev/null
+++ b/src/isode/compat/libicompat.3
@@ -0,0 +1,35 @@
+.TH LIBICOMPAT 3 "03 Jul 1986"
+.\" $Header$
+.\"
+.\"
+.\" $Log$
+.\" Revision 1.1 1994/06/10 03:27:41 eichin
+.\" autoconfed isode for kerberos work
+.\"
+Revision 1.1 94/06/10 03:16:10 eichin
+autoconfed isode for kerberos work
+
+# Revision 1.1 1994/05/31 20:34:10 eichin
+# reduced-isode release from /mit/isode/isode-subset/src
+#
+.\" Revision 8.0 91/07/17 12:18:01 isode
+.\" Release 7.0
+.\"
+.\"
+.SH NAME
+libicompat \- compatibility library
+.SH SYNOPSIS
+\fIcc\fR\0...\0\fB\-licompat\fR
+.SH DESCRIPTION
+The \fIlibicompat\fR library makes an attempt of providing an interface for
+similar services under different operating systems.
+Currently, the library works on most variants of Berkeley UNIX and AT&T UNIX.
+.SH FILES
+None
+.SH DIAGNOSTICS
+.SH AUTHOR
+Marshall T. Rose
+.SH BUGS
+To misquote M.A.\0Padlipsky,
+\*(lqsometimes when you try to make an apple look like an orange you get back
+something that smells like a lemon.\*(rq
diff --git a/src/isode/compat/log_tai.c b/src/isode/compat/log_tai.c
new file mode 100644
index 000000000..e45293c3d
--- /dev/null
+++ b/src/isode/compat/log_tai.c
@@ -0,0 +1,146 @@
+/* log_tai.c - system tailoring routines */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:43 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:12 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:13 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:03 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "cmd_srch.h"
+#include "general.h"
+#include "manifest.h"
+#include "logger.h"
+
+/* */
+
+#define LG_FILE 1
+#define LG_SFLAGS 2
+#define LG_DFLAGS 3
+#define LG_LEVEL 4
+#define LG_SIZE 5
+#define LG_DLEVEL 6
+#define LG_SSLEVEL 7
+#define LG_DSLEVEL 8
+
+static CMD_TABLE log_tbl[] = {
+ "FILE", LG_FILE,
+ "SFLAGS", LG_SFLAGS,
+ "DFLAGS", LG_DFLAGS,
+ "LEVEL", LG_LEVEL,
+ "SLEVEL", LG_LEVEL,
+ "DLEVEL", LG_DLEVEL,
+ "SSLEVEL", LG_SSLEVEL,
+ "DSLEVEL", LG_DSLEVEL,
+ "SIZE", LG_SIZE,
+ 0, -1,
+};
+
+static CMD_TABLE log_lvltbl[] = {
+ "NONE", LLOG_NONE,
+ "FATAL", LLOG_FATAL,
+ "EXCEPTIONS", LLOG_EXCEPTIONS,
+ "NOTICE", LLOG_NOTICE,
+ "TRACE", LLOG_TRACE,
+ "DEBUG", LLOG_DEBUG,
+ "PDUS", LLOG_PDUS,
+ "ALL", LLOG_ALL,
+ 0, -1
+};
+
+static CMD_TABLE log_flgtbl[] = {
+ "CLOSE", LLOGCLS,
+ "CREATE", LLOGCRT,
+ "ZERO", LLOGZER,
+ "TTY", LLOGTTY,
+ 0, -1
+};
+
+/* */
+
+log_tai(lgptr, av, ac) /* for now only alter the level - files etc later */
+LLog *lgptr;
+char **av;
+int ac;
+{
+ register int i;
+ register char *p;
+ int val;
+
+ for(i = 0; i < ac; i++)
+ {
+ if((p = index(av[i], '=')) == NULLCP)
+ continue;
+ *p++ = NULL;
+ switch(cmd_srch(av[i], log_tbl))
+ {
+ case LG_LEVEL:
+ val = cmd_srch(p,log_lvltbl);
+ if (val != -1)
+ lgptr->ll_events |= val;
+ break;
+ case LG_DSLEVEL:
+ val = cmd_srch (p, log_lvltbl);
+ if (val != -1)
+ lgptr -> ll_syslog &= ~val;
+ break;
+ case LG_SSLEVEL:
+ val = cmd_srch (p, log_lvltbl);
+ if (val != -1)
+ lgptr -> ll_syslog |= val;
+ break;
+ case LG_DLEVEL:
+ val = cmd_srch(p,log_lvltbl);
+ if (val != -1)
+ lgptr->ll_events &= ~ val;
+ break;
+ case LG_FILE:
+ lgptr->ll_file = strdup (p);
+ break;
+ case LG_SFLAGS:
+ val = cmd_srch(p,log_flgtbl);
+ if (val != -1)
+ lgptr->ll_stat |= val;
+ break;
+ case LG_DFLAGS:
+ val = cmd_srch(p,log_flgtbl);
+ if (val != -1)
+ lgptr->ll_stat &= ~ val;
+ break;
+ case LG_SIZE:
+ lgptr->ll_msize = atoi(p);
+ break;
+ }
+ }
+}
diff --git a/src/isode/compat/logger.c b/src/isode/compat/logger.c
new file mode 100644
index 000000000..8ad5cfc11
--- /dev/null
+++ b/src/isode/compat/logger.c
@@ -0,0 +1,622 @@
+/* logger.c - system logging routines */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:44 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:14 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:15 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:03 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include <varargs.h>
+#include "general.h"
+#include "manifest.h"
+#include "logger.h"
+#include "tailor.h"
+
+#ifdef NULL
+#undef NULL
+#endif
+#include <sys/param.h>
+#ifndef NULL
+#define NULL 0
+#endif
+#include "sys.file.h"
+#include <sys/stat.h>
+
+#if linux
+/*
+ * Linux's syslog.h includes stdargs.h, which is not compatible with
+ * varargs.h.
+ */
+#define LOG_EMERG 0 /* system is unusable */
+#define LOG_ALERT 1 /* action must be taken immediately */
+#define LOG_CRIT 2 /* critical conditions */
+#define LOG_ERR 3 /* error conditions */
+#define LOG_WARNING 4 /* warning conditions */
+#define LOG_NOTICE 5 /* normal but significant condition */
+#define LOG_INFO 6 /* informational */
+#define LOG_DEBUG 7 /* debug-level messages */
+#else
+#ifndef SYS5
+#include <syslog.h>
+#endif
+#endif
+
+/* */
+
+#ifndef lint
+static
+#endif
+int _ll_printf ();
+
+struct ll_private {
+ int ll_checks;
+#define CHKINT 15 /* call ll_check 1 in every 15 uses... */
+};
+
+static struct ll_private *llp = NULL;
+static IFP _ll_header_routine = ll_defmhdr;
+
+long lseek ();
+
+/* */
+
+/* [eichin:19940412.1858EST] to supply getdtablesize for solaris... */
+#if defined(hpux) || defined(__svr4__)
+#include <sys/resource.h>
+int getdtablesize() {
+ struct rlimit rl;
+ getrlimit(RLIMIT_NOFILE, &rl);
+ return rl.rlim_cur;
+}
+#endif
+
+int ll_open (lp)
+register LLog *lp;
+{
+ int mask,
+ mode;
+ char *bp,
+ buffer[BUFSIZ];
+
+ if (llp == NULL
+ && (llp = (struct ll_private *)
+ calloc ((unsigned int) getdtablesize (),
+ sizeof *llp)) == NULL)
+ goto you_lose;
+
+ if (lp -> ll_file == NULLCP
+ || *lp -> ll_file == NULL) {
+you_lose: ;
+ (void) ll_close (lp);
+ lp -> ll_stat |= LLOGERR;
+ return NOTOK;
+ }
+
+ lp -> ll_stat &= ~LLOGERR;
+
+ if (lp -> ll_fd != NOTOK)
+ return OK;
+
+ if (strcmp (lp -> ll_file, "-") == 0) {
+ lp -> ll_stat |= LLOGTTY;
+ return OK;
+ }
+
+ (void) sprintf (bp = buffer, _isodefile (isodelogpath, lp -> ll_file),
+ getpid ());
+
+ mode = O_WRONLY | O_APPEND;
+ if (lp -> ll_stat & LLOGCRT)
+ mode |= O_CREAT;
+
+ mask = umask (~0666);
+ lp -> ll_fd = open (bp, mode, 0666);
+ (void) umask (mask);
+
+ if (ll_check (lp) == NOTOK)
+ return (NOTOK);
+ if (lp -> ll_fd != NOTOK)
+ llp[lp -> ll_fd].ll_checks = CHKINT;
+
+ return (lp -> ll_fd != NOTOK ? OK : NOTOK);
+}
+
+/* */
+
+int ll_close (lp)
+register LLog *lp;
+{
+ int status;
+
+ if (lp -> ll_fd == NOTOK)
+ return OK;
+
+ status = close (lp -> ll_fd);
+ lp -> ll_fd = NOTOK;
+
+ return status;
+}
+
+/* */
+
+#ifndef lint
+int ll_log (va_alist)
+va_dcl
+{
+ int event,
+ result;
+ LLog *lp;
+ va_list ap;
+
+ va_start (ap);
+
+ lp = va_arg (ap, LLog *);
+ event = va_arg (ap, int);
+
+ result = _ll_log (lp, event, ap);
+
+ va_end (ap);
+
+ return result;
+}
+#else
+/* VARARGS4 */
+
+int ll_log (lp, event, what, fmt)
+LLog *lp;
+int event;
+char *what,
+ *fmt;
+{
+ return ll_log (lp, event, what, fmt);
+}
+#endif
+
+/* */
+
+int _ll_log (lp, event, ap) /* what, fmt, args ... */
+register LLog *lp;
+int event;
+va_list ap;
+{
+ int cc,
+ status;
+ register char *bp;
+ char *what,
+ buffer[BUFSIZ];
+
+ if (!(lp -> ll_events & event))
+ return OK;
+
+ bp = buffer;
+
+ /* Create header */
+ (*_ll_header_routine)(bp, lp -> ll_hdr, lp -> ll_dhdr);
+
+ bp += strlen (bp);
+
+ what = va_arg (ap, char *);
+
+ _asprintf (bp, what, ap);
+
+#ifndef SYS5
+ if (lp -> ll_syslog & event) {
+ int priority;
+
+ switch (event) {
+ case LLOG_FATAL:
+ priority = LOG_ERR;
+ break;
+
+ case LLOG_EXCEPTIONS:
+ priority = LOG_WARNING;
+ break;
+
+ case LLOG_NOTICE:
+ priority = LOG_INFO;
+ break;
+
+ case LLOG_PDUS:
+ case LLOG_TRACE:
+ case LLOG_DEBUG:
+ priority = LOG_DEBUG;
+ break;
+
+ default:
+ priority = LOG_NOTICE;
+ break;
+ }
+
+ (void) syslog (priority, "%s", buffer + 13);
+
+ if (lp -> ll_stat & LLOGCLS)
+ (void) closelog ();
+ }
+#endif
+
+ if (!(lp -> ll_stat & LLOGTTY)
+ && lp -> ll_fd == NOTOK
+ && strcmp (lp -> ll_file, "-") == 0)
+ lp -> ll_stat |= LLOGTTY;
+
+ if (lp -> ll_stat & LLOGTTY) {
+ (void) fflush (stdout);
+
+ if (lp -> ll_fd != NOTOK)
+ (void) fprintf (stderr, "LOGGING: ");
+ (void) fputs (bp, stderr);
+ (void) fputc ('\n', stderr);
+ (void) fflush (stderr);
+ }
+ bp += strlen (bp);
+
+ if (lp -> ll_fd == NOTOK) {
+ if ((lp -> ll_stat & (LLOGERR | LLOGTTY)) == (LLOGERR | LLOGTTY))
+ return OK;
+ if (ll_open (lp) == NOTOK)
+ return NOTOK;
+ }
+ else
+ if ((!llp || llp[lp -> ll_fd].ll_checks-- < 0)
+ && ll_check (lp) == NOTOK)
+ return NOTOK;
+
+ *bp++ = '\n', *bp = NULL;
+ cc = bp - buffer;
+
+ if ((status = write (lp -> ll_fd, buffer, cc)) != cc) {
+ if (status == NOTOK) {
+ (void) ll_close (lp);
+error: ;
+ lp -> ll_stat |= LLOGERR;
+ return NOTOK;
+ }
+
+ status = NOTOK;
+ }
+ else
+ status = OK;
+
+ if ((lp -> ll_stat & LLOGCLS) && ll_close (lp) == NOTOK)
+ goto error;
+
+ return status;
+}
+
+/* */
+
+void ll_hdinit (lp, prefix)
+register LLog *lp;
+char *prefix;
+{
+ register char *cp,
+ *up;
+ char buffer[BUFSIZ],
+ user[10];
+
+ if (prefix == NULLCP) {
+ if ((lp -> ll_stat & LLOGHDR) && strlen (lp -> ll_hdr) == 25)
+ (cp = lp -> ll_hdr)[8] = NULL;
+ else
+ cp = "unknown";
+ }
+ else {
+ if ((cp = rindex (prefix, '/')))
+ cp++;
+ if (cp == NULL || *cp == NULL)
+ cp = prefix;
+ }
+
+ if ((up = getenv ("USER")) == NULLCP
+ && (up = getenv ("LOGNAME")) == NULLCP) {
+ (void) sprintf (user, "#%d", getuid ());
+ up = user;
+ }
+ (void) sprintf (buffer, "%-8.8s %05d (%-8.8s)",
+ cp, getpid () % 100000, up);
+
+ if (lp -> ll_stat & LLOGHDR)
+ free (lp -> ll_hdr);
+ lp -> ll_stat &= ~LLOGHDR;
+
+ if ((lp -> ll_hdr = malloc ((unsigned) (strlen (buffer) + 1))) == NULLCP)
+ return;
+
+ (void) strcpy (lp -> ll_hdr, buffer);
+ lp -> ll_stat |= LLOGHDR;
+}
+
+/* */
+
+void ll_dbinit (lp, prefix)
+register LLog *lp;
+char *prefix;
+{
+ register char *cp;
+ char buffer[BUFSIZ];
+
+ ll_hdinit (lp, prefix);
+
+ if (prefix) {
+ if ((cp = rindex (prefix, '/')))
+ cp++;
+ if (cp == NULL || *cp == NULL)
+ cp = prefix;
+
+ (void) sprintf (buffer, "./%s.log", cp);
+
+ if ((lp -> ll_file = malloc ((unsigned) (strlen (buffer) + 1)))
+ == NULLCP)
+ return;
+
+ (void) strcpy (lp -> ll_file, buffer);
+ }
+
+ lp -> ll_events |= LLOG_ALL;
+ lp -> ll_stat |= LLOGTTY;
+}
+
+/* */
+
+#ifndef lint
+int ll_printf (va_alist)
+va_dcl
+{
+ int result;
+ LLog *lp;
+ va_list ap;
+
+ va_start (ap);
+
+ lp = va_arg (ap, LLog *);
+
+ result = _ll_printf (lp, ap);
+
+ va_end (ap);
+
+ return result;
+}
+#else
+/* VARARGS2 */
+
+int ll_printf (lp, fmt)
+LLog *lp;
+char *fmt;
+{
+ return ll_printf (lp, fmt);
+}
+#endif
+
+/* */
+
+#ifndef lint
+static
+#endif
+int _ll_printf (lp, ap) /* fmt, args ... */
+register LLog *lp;
+va_list ap;
+{
+ int cc,
+ status;
+ register char *bp;
+ char buffer[BUFSIZ];
+ char *fmt;
+ va_list fp = ap;
+
+ fmt = va_arg (fp, char *);
+ if (strcmp (fmt, "%s") != 0) {
+ bp = buffer;
+ _asprintf (bp, NULLCP, ap);
+ }
+ else {
+ bp = NULL;
+ fmt = va_arg (fp, char *);
+ }
+
+ if (!(lp -> ll_stat & LLOGTTY)
+ && lp -> ll_fd == NOTOK
+ && strcmp (lp -> ll_file, "-") == 0)
+ lp -> ll_stat |= LLOGTTY;
+
+ if (lp -> ll_stat & LLOGTTY) {
+ (void) fflush (stdout);
+
+ if (bp)
+ (void) fputs (bp, stderr);
+ else
+ (void) fputs (fmt, stderr);
+ (void) fflush (stderr);
+ }
+ if (bp)
+ bp += strlen (bp);
+
+ if (lp -> ll_fd == NOTOK) {
+ if ((lp -> ll_stat & (LLOGERR | LLOGTTY)) == (LLOGERR | LLOGTTY))
+ return OK;
+ if (ll_open (lp) == NOTOK)
+ return NOTOK;
+ }
+ else
+ if ((!llp || llp[lp -> ll_fd].ll_checks-- < 0)
+ && ll_check (lp) == NOTOK)
+ return NOTOK;
+
+ if (bp)
+ cc = bp - buffer;
+ else
+ cc = strlen (fmt);
+
+ if ((status = write (lp -> ll_fd, bp ? buffer : fmt, cc)) != cc) {
+ if (status == NOTOK) {
+ (void) ll_close (lp);
+ lp -> ll_stat |= LLOGERR;
+ return NOTOK;
+ }
+
+ status = NOTOK;
+ }
+ else
+ status = OK;
+
+ return status;
+}
+
+/* */
+
+int ll_sync (lp)
+register LLog *lp;
+{
+ if (lp -> ll_stat & LLOGCLS)
+ return ll_close (lp);
+
+ return OK;
+}
+
+/* */
+
+#ifndef lint
+char *ll_preset (va_alist)
+va_dcl
+{
+ va_list ap;
+ static char buffer[BUFSIZ];
+
+ va_start (ap);
+
+ _asprintf (buffer, NULLCP, ap);
+
+ va_end (ap);
+
+ return buffer;
+}
+#else
+/* VARARGS1 */
+
+char *ll_preset (fmt)
+char *fmt;
+{
+ return ll_preset (fmt);
+}
+#endif
+
+/* */
+
+int ll_check (lp)
+register LLog *lp;
+{
+#ifndef BSD42
+ int fd;
+ char buffer[BUFSIZ];
+#endif
+ long size;
+ struct stat st;
+
+ if ((size = lp -> ll_msize) <= 0)
+ return OK;
+
+ if (llp && lp -> ll_fd != NOTOK)
+ llp[lp -> ll_fd].ll_checks = CHKINT;
+ if (lp -> ll_fd == NOTOK
+ || (fstat (lp -> ll_fd, &st) != NOTOK
+ && st.st_size < (size <<= 10)))
+ return OK;
+
+ if (!(lp -> ll_stat & LLOGZER)) {
+ (void) ll_close (lp);
+
+#ifndef BSD42
+error: ;
+#endif
+ lp -> ll_stat |= LLOGERR;
+ return NOTOK;
+ }
+
+#ifdef BSD42
+#ifdef SUNOS4
+ (void) ftruncate (lp -> ll_fd, (off_t) 0);
+#else
+ (void) ftruncate (lp -> ll_fd, 0);
+#endif
+ (void) lseek (lp -> ll_fd, 0L, 0);
+ return OK;
+#else
+ (void) sprintf (buffer, _isodefile (isodelogpath, lp -> ll_file),
+ getpid ());
+ if ((fd = open (buffer, O_WRONLY | O_APPEND | O_TRUNC)) == NOTOK)
+ goto error;
+ (void) close (fd);
+ return OK;
+#endif
+}
+
+/* */
+
+/*
+ * ll_defmhdr - Default "make header" routine.
+ */
+int ll_defmhdr(bufferp, headerp, dheaderp)
+char *bufferp; /* Buffer pointer */
+char *headerp; /* Static header string */
+char *dheaderp; /* Dynamic header string */
+{
+ time_t clock;
+ register struct tm *tm;
+
+ (void) time (&clock);
+ tm = localtime (&clock);
+
+ (void) sprintf (bufferp, "%2d/%2d %2d:%02d:%02d %s %s ",
+ tm -> tm_mon + 1, tm -> tm_mday,
+ tm -> tm_hour, tm -> tm_min, tm -> tm_sec,
+ headerp ? headerp : "",
+ dheaderp ? dheaderp : "");
+ return OK;
+}
+
+/* */
+
+/*
+ * ll_setmhdr - Set "make header" routine, overriding default.
+ */
+IFP ll_setmhdr (make_header_routine)
+IFP make_header_routine;
+{
+ IFP result = _ll_header_routine;
+
+ _ll_header_routine = make_header_routine;
+
+ return result;
+
+}
diff --git a/src/isode/compat/na2norm.c b/src/isode/compat/na2norm.c
new file mode 100644
index 000000000..254faa8b0
--- /dev/null
+++ b/src/isode/compat/na2norm.c
@@ -0,0 +1,163 @@
+/* na2norm.c - normalize NSAPaddr */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:46 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:16 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:18 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:04 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+#include "internet.h"
+#include "tailor.h"
+
+/* Encoding based on
+
+ "An interim approach to use of Network Addresses",
+ S.E. Kille, January 16, 1989
+
+ */
+
+/* */
+
+struct NSAPaddr *na2norm (na)
+register struct NSAPaddr *na;
+{
+ int ilen;
+ register char *cp,
+ *dp;
+ char nsap[NASIZE * 2 + 1];
+ register struct hostent *hp;
+ register struct ts_interim *ts;
+ static struct NSAPaddr nas;
+ register struct NSAPaddr *ca = &nas;
+
+ if (na -> na_stack == NA_NSAP) {
+ *ca = *na; /* struct copy */
+ return ca;
+ }
+
+ bzero ((char *) ca, sizeof *ca);
+ ca -> na_stack = NA_NSAP;
+
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (ts -> ts_subnet == na -> na_community)
+ break;
+ if (!ts -> ts_name) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unable to find community #%d", na -> na_community));
+ return NULLNA;
+ }
+
+ cp = nsap;
+ switch (na -> na_stack) {
+ case NA_TCP:
+ if ((hp = gethostbystring (na -> na_domain)) == NULL) {
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%s: unknown host", na -> na_domain));
+ return NULLNA;
+ }
+#define s2a(b) (((int) (b)) & 0xff)
+ (void) sprintf (cp, "%03d%03d%03d%03d",
+ s2a (hp -> h_addr[0]),
+ s2a (hp -> h_addr[1]),
+ s2a (hp -> h_addr[2]),
+ s2a (hp -> h_addr[3]));
+ cp += strlen (cp);
+#undef s2a
+
+ if (na -> na_port) {
+ (void) sprintf (cp, "%05d", (int) ntohs (na -> na_port));
+ cp += strlen (cp);
+
+ if (na -> na_tset || na -> na_tset != NA_TSET_TCP) {
+ (void) sprintf (cp, "%05d", (int) na -> na_tset);
+ cp += strlen (cp);
+ }
+ }
+ break;
+
+ case NA_X25:
+ case NA_BRG:
+ if (na -> na_community == SUBNET_INT_X25
+ && na -> na_cudflen == 0
+ && na -> na_pidlen == 0
+ && na -> na_dte[0] != '0') { /* SEK - X121 form */
+ /* should be more general */
+ (void) sprintf (nsap, "36%014s", na -> na_dte);
+ ts = NULL;
+ break;
+ }
+
+ if (ilen = na -> na_pidlen & 0xff)
+ *cp++ = '1', dp = na -> na_pid;
+ else
+ if (ilen = na -> na_cudflen & 0xff)
+ *cp++ = '2', dp = na -> na_cudf;
+ else
+ *cp++ = '0';
+ if (ilen) {
+ (void) sprintf (cp, "%01d", ilen);
+ cp += strlen (cp);
+
+ for (; ilen-- > 0; cp += 3)
+ (void) sprintf (cp, "%03d", *dp++ & 0xff);
+ }
+ (void) strcpy (cp, na -> na_dte);
+ break;
+
+ default:
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown address type 0x%x", na -> na_stack));
+ return NULLNA;
+ }
+
+ cp = nsap, dp = ca -> na_address;
+ if (ts) {
+ bcopy (ts -> ts_prefix, dp, ts -> ts_length);
+ dp += ts -> ts_length;
+ }
+ while (*cp) {
+ *dp = (*cp++ - '0') << 4;
+ if (*cp)
+ *dp++ |= (*cp++ - '0') & 0x0f;
+ else
+ *dp++ |= 0x0f;
+ }
+ ca -> na_addrlen = dp - ca -> na_address;
+
+ return ca;
+}
diff --git a/src/isode/compat/na2str.c b/src/isode/compat/na2str.c
new file mode 100644
index 000000000..21bbf3066
--- /dev/null
+++ b/src/isode/compat/na2str.c
@@ -0,0 +1,62 @@
+/* na2str.c - pretty-print NSAPaddr */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:48 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:17 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:20 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:05 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* Network Address to String */
+
+char *na2str (na)
+register struct NSAPaddr *na;
+{
+ switch (na -> na_stack) {
+ case NA_TCP:
+ return na -> na_domain;
+
+ case NA_X25:
+ case NA_BRG:
+ return na -> na_dte;
+
+ case NA_NSAP:
+ default:
+ return sel2str (na -> na_address, na -> na_addrlen, 0);
+ }
+}
diff --git a/src/isode/compat/nochrcnv.c b/src/isode/compat/nochrcnv.c
new file mode 100644
index 000000000..4377c0d55
--- /dev/null
+++ b/src/isode/compat/nochrcnv.c
@@ -0,0 +1,81 @@
+/* nochrcnv.c - character conversion table, no case folding */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:50 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:20 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:21 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:05 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+
+/* */
+
+char /* straight mapping - Non case sensive */
+ /* used for consistency */
+ nochrcnv[] =
+{
+ '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7',
+ '\10', '\11', '\12', '\13', '\14', '\15', '\16', '\17',
+ '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27',
+ '\30', '\31', '\32', '\33', '\34', '\35', '\36', '\37',
+ '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47',
+ '\50', '\51', '\52', '\53', '\54', '\55', '\56', '\57',
+ '\60', '\61', '\62', '\63', '\64', '\65', '\66', '\67',
+ '\70', '\71', '\72', '\73', '\74', '\75', '\77', '\77',
+ '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
+ '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
+ '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
+ '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
+ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+ '\170', '\171', '\172', '\173', '\174', '\175', '\177', '\177',
+ '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7',
+ '\10', '\11', '\12', '\13', '\14', '\15', '\16', '\17',
+ '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27',
+ '\30', '\31', '\32', '\33', '\34', '\35', '\36', '\37',
+ '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47',
+ '\50', '\51', '\52', '\53', '\54', '\55', '\56', '\57',
+ '\60', '\61', '\62', '\63', '\64', '\65', '\66', '\67',
+ '\70', '\71', '\72', '\73', '\74', '\75', '\77', '\77',
+ '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
+ '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
+ '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
+ '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
+ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+ '\170', '\171', '\172', '\173', '\174', '\175', '\177', '\177'
+};
diff --git a/src/isode/compat/norm2na.c b/src/isode/compat/norm2na.c
new file mode 100644
index 000000000..7a872ab0a
--- /dev/null
+++ b/src/isode/compat/norm2na.c
@@ -0,0 +1,287 @@
+/* norm2na.c - normalize NSAPaddr to NSAP struct */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:52 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:22 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:23 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:06 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "psap.h"
+#include "isoaddrs.h"
+#include "tailor.h"
+#include "internet.h"
+
+/* Encoding on "unrealNS" addresses based on
+
+ "An interim approach to use of Network Addresses",
+ S.E. Kille, January 16, 1989
+
+ */
+
+/* */
+
+int norm2na (p, len, na)
+char *p;
+int len;
+struct NSAPaddr *na;
+{
+ na -> na_stack = NA_NSAP;
+
+ if ((len == 8) && ((p[0] == 0x36) || (p[0] == 0x37))) {
+ int xlen; /* SEK - X121 form */
+ register char *cp,
+ *cp2,
+ *dp;
+ char nsap[14];
+
+ dp = nsap;
+ for (cp2 = (cp = p + 1) + 7; cp < cp2; cp++) {
+ register int j;
+
+ if ((j = ((*cp & 0xf0) >> 4)) > 9)
+ goto concrete;
+ *dp++ = j + '0';
+
+ if ((j = (*cp & 0x0f)) > 9) {
+ if (j != 0x0f)
+ goto concrete;
+ }
+ else
+ *dp++ = j + '0';
+ }
+
+ for (cp = nsap, xlen = 14; *cp == '0'; cp++, xlen--)
+ continue;
+ na -> na_dtelen = xlen;
+ for (cp2 = na -> na_dte; xlen-- > 0; )
+ *cp2++ = *cp++;
+ *cp2 = NULL;
+#ifdef BRIDGE_X25
+ na -> na_stack = bridgediscrim (na) ? NA_BRG : NA_X25;
+#else
+ na -> na_stack = NA_X25;
+#endif
+ na -> na_community = SUBNET_INT_X25;
+ }
+ else {
+ register struct ts_interim *ts,
+ *tp;
+
+ tp = NULL;
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (len > ts -> ts_length
+ && (tp == NULL || ts -> ts_length > tp -> ts_length)
+ && bcmp (p, ts -> ts_prefix, ts -> ts_length) == 0)
+ tp = ts;
+ if (tp) {
+ int i,
+ ilen,
+ rlen;
+ register char *cp,
+ *dp,
+ *ep;
+ char nsap[NASIZE * 2 + 1];
+
+ if (tp -> ts_syntax == NA_NSAP)
+ goto lock_and_load;
+ dp = nsap;
+ for (cp = p + tp -> ts_length, ep = p + len;
+ cp < ep;
+ cp++) {
+ register int j;
+
+ if ((j = ((*cp & 0xf0) >> 4)) > 9) {
+concrete: ;
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("invalid concrete encoding"));
+ goto realNS;
+ }
+ *dp++ = j + '0';
+
+ if ((j = (*cp & 0x0f)) > 9) {
+ if (j != 0x0f)
+ goto concrete;
+ }
+ else
+ *dp++ = j + '0';
+ }
+ *dp = NULL;
+
+ cp = nsap;
+lock_and_load: ;
+ na -> na_community = tp -> ts_subnet;
+ switch (na -> na_stack = tp -> ts_syntax) {
+ case NA_NSAP:
+ goto unrealNS;
+
+ case NA_X25:
+ if ((int)strlen (cp) < 1) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("missing DTE+CUDF indicator: %s", nsap));
+ goto realNS;
+ }
+ (void) sscanf (cp, "%1d", &i);
+ cp += 1;
+ switch (i) {
+ case 0: /* DTE only */
+ break;
+
+ case 1: /* DTE+PID */
+ case 2: /* DTE+CUDF */
+ if ((int)strlen (cp) < 1) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("missing DTE+CUDF indicator: %s",
+ nsap));
+ goto realNS;
+ }
+ (void) sscanf (cp, "%1d", &ilen);
+ cp += 1;
+ rlen = ilen * 3;
+ if ((int)strlen (cp) < rlen) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("bad DTE+CUDF length: %s", nsap));
+ goto realNS;
+ }
+ if (i == 1) {
+ if (ilen > NPSIZE) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("PID too long: %s", nsap));
+ goto realNS;
+ }
+ dp = na -> na_pid;
+ na -> na_pidlen = ilen;
+ }
+ else {
+ if (ilen > CUDFSIZE) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("CUDF too long: %s", nsap));
+ goto realNS;
+ }
+ dp = na -> na_cudf;
+ na -> na_cudflen = ilen;
+ }
+ for (; rlen > 0; rlen -= 3) {
+ (void) sscanf (cp, "%3d", &i);
+ cp += 3;
+
+ if (i > 255) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("invalid PID/CUDF: %s", nsap));
+ goto realNS;
+ }
+ *dp++ = i & 0xff;
+ }
+ break;
+
+ default:
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("invalid DTE+CUDF indicator: %s", nsap));
+ goto realNS;
+ }
+ (void) strcpy (na -> na_dte, cp);
+ na -> na_dtelen = strlen (na -> na_dte);
+
+#ifdef BRIDGE_X25
+ if (bridgediscrim (na))
+ na -> na_stack = NA_BRG;
+#endif
+ break;
+
+ case NA_TCP:
+ if ((int)strlen (cp) < 12) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("missing IP address: %s", nsap));
+ goto realNS;
+ }
+ {
+ int q[4];
+
+ (void) sscanf (cp, "%3d%3d%3d%3d", q, q + 1, q + 2,
+ q + 3);
+ (void) sprintf (na -> na_domain,
+ "%d.%d.%d.%d", q[0], q[1], q[2], q[3]);
+ }
+ cp += 12;
+
+ if (*cp) {
+ if ((int)strlen (cp) < 5) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("missing port: %s", nsap));
+ goto realNS;
+ }
+ (void) sscanf (cp, "%5d", &i);
+ cp += 5;
+ na -> na_port = htons ((u_short) i);
+
+ if (*cp) {
+ if ((int)strlen (cp) < 5) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("missing tset: %s", nsap));
+ goto realNS;
+ }
+ (void) sscanf (cp, "%5d", &i);
+ cp += 5;
+ na -> na_tset = (u_short) i;
+
+ if (*cp)
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("extra TCP information: %s", nsap));
+ }
+ }
+ break;
+
+ default:
+ LLOG (addr_log, LLOG_NOTICE,
+ ("unknown syntax %d for DSP: %s", ts -> ts_syntax,
+ nsap));
+ goto realNS;
+ }
+ }
+ else {
+realNS: ;
+ na -> na_stack = NA_NSAP;
+ na -> na_community = SUBNET_REALNS;
+unrealNS: ;
+ if (len > sizeof na -> na_address) {
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("NSAP address too long: %d octets", len));
+ return NOTOK;
+ }
+ bcopy (p, na -> na_address, na -> na_addrlen = len);
+ }
+ }
+
+ return OK;
+}
diff --git a/src/isode/compat/pa2str.c b/src/isode/compat/pa2str.c
new file mode 100644
index 000000000..8ea39c512
--- /dev/null
+++ b/src/isode/compat/pa2str.c
@@ -0,0 +1,107 @@
+/* pa2str.c - pretty-print PSAPaddr */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:54 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:23 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:25 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:07 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* Presentation Address to String */
+
+char *pa2str (px)
+register struct PSAPaddr *px;
+{
+ register char *bp;
+ struct PSAPaddr pas;
+ register struct PSAPaddr *pa = &pas;
+ register struct TSAPaddr *ta = &pa -> pa_addr.sa_addr;
+ static char buffer[BUFSIZ];
+
+ bp = buffer;
+
+ *pa = *px; /* struct copy */
+ if (ta -> ta_selectlen > 0
+ && ta -> ta_selectlen < sizeof ta -> ta_selector) {
+ register char *dp,
+ *ep;
+ register struct TSAPaddr *tz;
+ register int n, m;
+
+ /* does this look like an encoded TSEL? */
+ m = ta -> ta_selectlen;
+ n = ta -> ta_selector[0];
+ if (m > 4 &&
+ ta -> ta_selector[0] == ta -> ta_selector[1] &&
+ n > 2 && n <= m - 2)
+ { /* encoded! */
+ tz = &px -> pa_addr.sa_addr;
+ bzero ((char *)ta, sizeof *ta);
+ if ((ta -> ta_selectlen = m - n - 2) > 0)
+ bcopy (&tz -> ta_selector[n+2], ta -> ta_selector,
+ ta -> ta_selectlen);
+ if (norm2na (&tz -> ta_selector[2], n, ta -> ta_addrs) != OK) {
+ *pa = *px;
+ goto normal;
+ }
+ ta -> ta_naddr = 1;
+ goto bridge;
+ }
+ for (ep = (dp = ta -> ta_selector) + ta -> ta_selectlen, *ep = NULL;
+ dp < ep;
+ dp++)
+ if (!isprint ((u_char) *dp) && *dp != ' ')
+ break;
+ if (dp >= ep && (tz = str2taddr (ta -> ta_selector))) {
+ pa -> pa_addr.sa_addr = *tz; /* struct copy */
+ bridge:
+ (void) sprintf (bp, "%s through TS bridge at ",
+ paddr2str (pa, NULLNA));
+ bp += strlen (bp);
+
+ bzero ((char *) pa, sizeof *pa);
+ *ta = px -> pa_addr.sa_addr; /* struct copy */
+ ta -> ta_selectlen = 0;
+ }
+ }
+normal:
+ (void) strcpy (bp, paddr2str (pa, NULLNA));
+
+ return buffer;
+}
diff --git a/src/isode/compat/putenv.c b/src/isode/compat/putenv.c
new file mode 100644
index 000000000..24013dc9a
--- /dev/null
+++ b/src/isode/compat/putenv.c
@@ -0,0 +1,116 @@
+/* putenv.c - generic putenv() */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:55 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:25 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:26 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:07 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* */
+
+extern char **environ;
+static nvmatch ();
+
+/* */
+
+int setenv (name, value)
+register char *name,
+ *value;
+{
+ register int i;
+ register char **ep,
+ **nep,
+ *cp;
+
+ if ((cp = malloc ((unsigned) (strlen (name) + strlen (value) + 2)))
+ == NULL)
+ return 1;
+ (void) sprintf (cp, "%s=%s", name, value);
+
+ for (ep = environ, i = 0; *ep; ep++, i++)
+ if (nvmatch (name, *ep)) {
+ *ep = cp;
+ return 0;
+ }
+
+ if ((nep = (char **) malloc ((unsigned) ((i + 2) * sizeof *nep)))
+ == NULL) {
+ free (cp);
+ return 1;
+ }
+ for (ep = environ, i = 0; *ep; nep[i++] = *ep++)
+ continue;
+ nep[i++] = cp;
+ nep[i] = NULL;
+ environ = nep;
+ return 0;
+}
+
+/* */
+
+int unsetenv (name)
+char *name;
+{
+ char **ep,
+ **nep;
+
+ for (ep = environ; *ep; ep++)
+ if (nvmatch (name, *ep))
+ break;
+ if (*ep == NULL)
+ return 1;
+
+ for (nep = ep + 1; *nep; nep++)
+ continue;
+ *ep = *--nep;
+ *nep = NULL;
+ return 0;
+}
+
+/* */
+
+static nvmatch (s1, s2)
+register char *s1,
+ *s2;
+{
+ while (*s1 == *s2++)
+ if (*s1++ == '=')
+ return 1;
+
+ return (*s1 == '\0' && *--s2 == '=');
+}
diff --git a/src/isode/compat/rcmd_srch.c b/src/isode/compat/rcmd_srch.c
new file mode 100644
index 000000000..c8a0747f8
--- /dev/null
+++ b/src/isode/compat/rcmd_srch.c
@@ -0,0 +1,53 @@
+/* rcmd_srch.c: search a lookup table: return string value */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:57 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:27 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:28 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:08 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include "manifest.h"
+#include "cmd_srch.h"
+
+/* */
+
+char *rcmd_srch(val, cmd)
+register int val;
+register CMD_TABLE *cmd;
+{
+ for(;cmd->cmd_key != NULLCP; cmd++)
+ if(val == cmd->cmd_value)
+ return(cmd->cmd_key);
+ return(NULLCP);
+}
diff --git a/src/isode/compat/saddr2str.c b/src/isode/compat/saddr2str.c
new file mode 100644
index 000000000..9d8fb65d2
--- /dev/null
+++ b/src/isode/compat/saddr2str.c
@@ -0,0 +1,59 @@
+/* saddr2str.c - SSAPaddr to string value */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:27:59 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:29 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:29 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:08 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* */
+
+char *saddr2str (sa)
+register struct SSAPaddr *sa;
+{
+ struct PSAPaddr pas;
+ register struct PSAPaddr *pa = &pas;
+
+ if (!sa)
+ return NULL;
+ bzero ((char *) pa, sizeof *pa);
+ pa -> pa_addr = *sa; /* struct copy */
+
+ return paddr2str (pa, NULLNA);
+}
diff --git a/src/isode/compat/sel2str.c b/src/isode/compat/sel2str.c
new file mode 100644
index 000000000..6a9468259
--- /dev/null
+++ b/src/isode/compat/sel2str.c
@@ -0,0 +1,98 @@
+/* sel2str.c - selector to string */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:02 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:31 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:31 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:09 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* */
+
+char *sel2str (sel, len, quoted)
+char *sel;
+int len,
+ quoted;
+{
+ register char *cp,
+ *dp,
+ *ep;
+ static int i = 0;
+ static char buf1[NASIZE * 2 + 1],
+ buf2[NASIZE * 2 + 1],
+ buf3[NASIZE * 2 + 1],
+ buf4[NASIZE * 2 + 1];
+ static char *bufs[] = { buf1, buf2, buf3, buf4 };
+
+ cp = bufs[i++];
+ i = i % 4;
+
+ if (quoted) {
+#ifndef NOGOSIP
+ if (len == 2) {
+ if (quoted < 0)
+ goto ugly;
+ (void) sprintf (cp, "#%d",
+ (sel[0] & 0xff) << 8 | (sel[1] & 0xff));
+ goto out;
+ }
+#endif
+
+ for (ep = (dp = sel) + len; dp < ep; dp++)
+ if (!isprint ((u_char) *dp))
+ goto ugly;
+
+ if (len > NASIZE * 2)
+ len = NASIZE * 2;
+
+ (void) sprintf (cp, len ? "\"%*.*s\"" : "\"\"", len, len, sel);
+ }
+ else {
+ugly: ;
+ if (len > NASIZE) /* XXX */
+ len = NASIZE;
+
+ cp[explode (cp, (u_char *) sel, len)] = NULL;
+ }
+#ifndef NOGOSIP
+out: ;
+#endif
+
+ return cp;
+}
diff --git a/src/isode/compat/select.c b/src/isode/compat/select.c
new file mode 100644
index 000000000..9bfb13e6e
--- /dev/null
+++ b/src/isode/compat/select.c
@@ -0,0 +1,389 @@
+/* select.c - select() abstractions */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:04 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:33 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:33 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:09 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <errno.h>
+#include <stdio.h>
+#include "manifest.h"
+#include "tailor.h"
+#include <sys/stat.h>
+
+
+extern int errno;
+
+
+int xselect_blocking_on_intr = 0;
+
+/* */
+
+#if defined(SOCKETS) && !defined(TLI_POLL)
+
+#include <sys/time.h>
+
+
+/* Synchronous multiplexing:
+ < 0 : block indefinately
+ = 0 : poll
+ > 0 : wait
+ */
+
+int selsocket (nfds, rfds, wfds, efds, secs)
+int nfds;
+fd_set *rfds,
+ *wfds,
+ *efds;
+int secs;
+{
+ int n;
+ fd_set ifds,
+ ofds,
+ xfds;
+#if defined(masscomp) && defined(_ATT)
+ int msecs;
+#else
+ struct timeval tvs;
+ register struct timeval *tv = &tvs;
+#endif
+
+#if defined(masscomp) && defined(_ATT)
+ if (secs != NOTOK)
+ msecs = secs * 1000;
+ else
+ msecs = -1;
+#else
+ if (secs != NOTOK)
+ tv -> tv_sec = secs, tv -> tv_usec = 0;
+ else
+ tv = NULL;
+#endif
+
+ if (rfds)
+ ifds = *rfds;
+ if (wfds)
+ ofds = *wfds;
+ if (efds)
+ xfds = *efds;
+#if defined(masscomp) && defined(_ATT)
+ if (efds)
+ FD_ZERO(efds);
+#endif
+
+ for (;;) {
+#if defined(masscomp) && defined(_ATT)
+ switch (n = select (nfds, rfds, wfds, msecs)) {
+#else
+ switch (n = select (nfds, rfds, wfds, efds, tv)) {
+#endif
+ case OK:
+ if (secs == NOTOK)
+ break;
+ return OK;
+
+ case NOTOK:
+ if (xselect_blocking_on_intr
+ && errno == EINTR
+ && secs == NOTOK)
+ continue;
+ /* else fall... */
+
+ default:
+ return n;
+ }
+
+ if (rfds)
+ *rfds = ifds;
+ if (wfds)
+ *wfds = ofds;
+ if (efds)
+ *efds = xfds;
+ }
+}
+#endif
+
+/* */
+
+#ifdef EXOS
+
+#ifdef SYS5
+
+/* There seems to be a bug in the SYS5 EXOS select() routine when a socket can
+ be read immediately (don't know about write). The bug is that select()
+ returns ZERO, and the mask is zero'd as well. The code below explicitly
+ checks for this case.
+*/
+
+#include "sys/soioctl.h"
+
+
+int selsocket (nfds, rfds, wfds, efds, secs)
+int nfds;
+fd_set *rfds,
+ *wfds,
+ *efds;
+int secs;
+{
+ register int fd;
+ int n;
+ fd_set ifds,
+ ofds;
+ long nbytes,
+ usecs;
+
+ if (secs != NOTOK)
+ usecs = secs * 1000;
+ else
+ usecs = 0xffff; /* used to be ~(1L << (8 * sizeof usecs - 1)) */
+
+ if (rfds)
+ ifds = *rfds;
+ if (wfds)
+ ofds = *wfds;
+ if (efds)
+ FD_ZERO (efds);
+
+ for (;;) {
+ switch (n = select (nfds + 1, rfds, wfds, usecs)) { /* +1 for UNISYS */
+ case OK:
+ if (rfds)
+ for (fd = 0; fd < nfds; fd++)
+ if (FD_ISSET (fd, &ifds)
+ && ioctl (fd, FIONREAD, (char *) &nbytes)
+ != NOTOK
+ && nbytes > 0) {
+ FD_SET (fd, rfds);
+ n++;
+ }
+ if (n == 0 && secs == NOTOK)
+ break;
+ return n;
+
+ case NOTOK:
+ default:
+ return n;
+ }
+
+ if (rfds)
+ *rfds = ifds;
+ if (wfds)
+ *wfds = ofds;
+ }
+}
+#endif
+#endif
+
+#if defined(TLI_TP) && defined(TLI_POLL)
+#include <poll.h>
+
+int selsocket (nfds, rfds, wfds, efds, secs)
+int nfds;
+fd_set *rfds, *wfds, *efds;
+int secs;
+{
+ int i, j, n;
+ struct pollfd pollfds[128];
+
+ for (i = j = 0; i < nfds; i++) {
+ pollfds[j].fd = NOTOK;
+ pollfds[j].events = 0;
+ if (rfds && FD_ISSET (i, rfds)) {
+ pollfds[j].fd = i;
+ pollfds[j].events |= POLLIN | POLLPRI;
+ }
+ if (wfds && FD_ISSET (i, wfds)) {
+ pollfds[j].fd = i;
+ pollfds[j].events |= POLLOUT;
+ }
+ if (efds && FD_ISSET(i, efds)) {
+ pollfds[j].fd = i;
+ /* one always gets notified of exceptions */
+ }
+ if (pollfds[j].fd == i)
+ j ++;
+
+ }
+
+ if (rfds) FD_ZERO(rfds);
+ if (wfds) FD_ZERO(wfds);
+ if (efds) FD_ZERO(efds);
+
+ if (secs != 0 && secs != NOTOK)
+ secs *= 1000;
+
+again:
+ n = poll (pollfds, (unsigned long)j, secs);
+ if (n == NOTOK) {
+ if (errno == EAGAIN)
+ goto again;
+ if (errno != EINTR)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("poll"));
+ return NOTOK;
+ }
+
+ for (i = 0; i < j; i++) {
+ if (rfds && (pollfds[i].revents & (POLLIN | POLLPRI)))
+ FD_SET (pollfds[i].fd, rfds);
+ if (wfds && (pollfds[i].revents & POLLOUT))
+ FD_SET (pollfds[i].fd, wfds);
+ if (efds && (pollfds[i].revents & (POLLERR | POLLHUP | POLLNVAL)))
+ FD_SET (pollfds[i].fd, efds);
+ }
+ return n;
+}
+
+#endif
+
+/* */
+
+/* This routine used to be used for devices that didn't support real select.
+ Those devices are no longer supported.
+
+ Instead the routine is used to check if an I/O abstraction has some data
+ buffered in user-space for reading...
+ */
+
+static IFP sfnx[FD_SETSIZE] = { NULL };
+static caddr_t sdata[FD_SETSIZE] = { NULL };
+
+
+IFP set_check_fd (fd, fnx, data)
+int fd;
+IFP fnx;
+caddr_t data;
+{
+ IFP ofnx;
+
+ if (fd < 0 || fd >= FD_SETSIZE)
+ return NULLIFP;
+
+ ofnx = sfnx[fd];
+ sfnx[fd] = fnx, sdata[fd] = data;
+
+ return ofnx;
+}
+
+/* */
+
+int xselect (nfds, rfds, wfds, efds, secs)
+int nfds;
+fd_set *rfds,
+ *wfds,
+ *efds;
+int secs;
+{
+ register int fd;
+ int n;
+ fd_set ifds,
+ ofds,
+ xfds;
+ static int nsysfds = NOTOK;
+
+ if (nsysfds == NOTOK)
+ nsysfds = getdtablesize ();
+ if (nfds > FD_SETSIZE)
+ nfds = FD_SETSIZE;
+ if (nfds > nsysfds + 1)
+ nfds = nsysfds + 1;
+
+ FD_ZERO (&ifds);
+ n = 0;
+
+ for (fd = 0; fd < nfds; fd++)
+ if (sfnx[fd] != NULLIFP
+ && rfds
+ && FD_ISSET (fd, rfds)
+ && (*sfnx[fd]) (fd, sdata[fd]) == DONE) {
+ FD_SET (fd, &ifds);
+ n++;
+ }
+
+ if (n > 0) {
+ *rfds = ifds; /* struct copy */
+ if (wfds)
+ FD_ZERO (wfds);
+ if (efds)
+ FD_ZERO (efds);
+
+ return n;
+ }
+
+ if (rfds)
+ ifds = *rfds; /* struct copy */
+ if (wfds)
+ ofds = *wfds; /* struct copy */
+ if (efds)
+ xfds = *efds; /* struct copy */
+
+ if ((n = selsocket (nfds, rfds, wfds, efds, secs)) != NOTOK)
+ return n;
+
+ if (errno == EBADF) {
+ struct stat st;
+
+ if (rfds)
+ FD_ZERO (rfds);
+ if (wfds)
+ FD_ZERO (wfds);
+ if (efds)
+ FD_ZERO (efds);
+
+ n = 0;
+ for (fd = 0; fd < nfds; fd++)
+ if (((rfds && FD_ISSET (fd, &ifds))
+ || (wfds && FD_ISSET (fd, &ofds))
+ || (efds && FD_ISSET (fd, &xfds)))
+ && fstat (fd, &st) == NOTOK) {
+ if (rfds && FD_ISSET (fd, &ifds))
+ FD_SET (fd, rfds);
+ if (wfds && FD_ISSET (fd, &ofds))
+ FD_SET (fd, wfds);
+ if (efds && FD_ISSET (fd, &xfds))
+ FD_SET (fd, efds);
+
+ SLOG (compat_log, LLOG_EXCEPTIONS, "",
+ ("fd %d has gone bad", fd));
+ n++;
+ }
+
+ if (n)
+ return n;
+
+ errno = EBADF;
+ }
+
+ return NOTOK;
+}
diff --git a/src/isode/compat/serror.c b/src/isode/compat/serror.c
new file mode 100644
index 000000000..e75794251
--- /dev/null
+++ b/src/isode/compat/serror.c
@@ -0,0 +1,61 @@
+/* serror.c - get system error */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:06 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:35 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:34 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:10 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* DATA */
+
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+/* */
+
+char *sys_errname (i)
+int i;
+{
+ static char buffer[30];
+
+ if (0 < i && i < sys_nerr)
+ return sys_errlist[i];
+ (void) sprintf (buffer, "Error %d", i);
+
+ return buffer;
+}
diff --git a/src/isode/compat/servbyname.c b/src/isode/compat/servbyname.c
new file mode 100644
index 000000000..1b8be300b
--- /dev/null
+++ b/src/isode/compat/servbyname.c
@@ -0,0 +1,76 @@
+/* servbyname.c - getisoserventbyname */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:09 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:37 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:36 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:10 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoservent.h"
+#include "tailor.h"
+
+/* */
+
+struct isoservent *getisoserventbyname (entity, provider)
+char *entity,
+ *provider;
+{
+ register struct isoservent *is;
+
+ isodetailor (NULLCP, 0);
+ DLOG (addr_log, LLOG_TRACE,
+ ("getisoserventbyname \"%s\" \"%s\"", entity, provider));
+
+ (void) setisoservent (0);
+ while (is = getisoservent ())
+ if (strcmp (entity, is -> is_entity) == 0
+ && strcmp (provider, is -> is_provider) == 0)
+ break;
+ (void) endisoservent ();
+
+ if (is) {
+#ifdef DEBUG
+ if (addr_log -> ll_events & LLOG_DEBUG)
+ _printsrv (is);
+#endif
+ }
+ else
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("lookup of local service %s/%s failed", provider, entity));
+
+ return is;
+}
diff --git a/src/isode/compat/servbyport.c b/src/isode/compat/servbyport.c
new file mode 100644
index 000000000..9beb333eb
--- /dev/null
+++ b/src/isode/compat/servbyport.c
@@ -0,0 +1,79 @@
+/* servbyport.c - getisoserventbyport */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:11 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:39 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:38 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:11 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoservent.h"
+#include "tailor.h"
+#include "internet.h"
+
+/* */
+
+struct isoservent *getisoserventbyport (provider, port)
+char *provider;
+unsigned short port;
+{
+ register struct isoservent *is;
+
+ isodetailor (NULLCP, 0);
+ DLOG (addr_log, LLOG_TRACE,
+ ("getisoserventbyport \"%s\" %d", provider, (int) ntohs (port)));
+
+ (void) setisoservent (0);
+ while (is = getisoservent ())
+ if (sizeof (port) == is -> is_selectlen
+ && port == is -> is_port
+ && strcmp (provider, is -> is_provider) == 0)
+ break;
+ (void) endisoservent ();
+
+ if (is) {
+#ifdef DEBUG
+ if (addr_log -> ll_events & LLOG_DEBUG)
+ _printsrv (is);
+#endif
+ }
+ else
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("lookup of local service %s/%d failed",
+ provider, (int) ntohs (port)));
+
+ return is;
+}
diff --git a/src/isode/compat/servbysel.c b/src/isode/compat/servbysel.c
new file mode 100644
index 000000000..bda1f15eb
--- /dev/null
+++ b/src/isode/compat/servbysel.c
@@ -0,0 +1,80 @@
+/* servbysel.c - getisoserventbyselector */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:12 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:41 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:41 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:11 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoservent.h"
+#include "tailor.h"
+
+/* */
+
+struct isoservent *getisoserventbyselector (provider, selector, selectlen)
+char *provider,
+ *selector;
+int selectlen;
+{
+ register struct isoservent *is;
+
+ isodetailor (NULLCP, 0);
+ DLOG (addr_log, LLOG_TRACE,
+ ("getisoserventbyselector \"%s\" %s",
+ provider, sel2str (selector, selectlen, 1)));
+
+ (void) setisoservent (0);
+ while (is = getisoservent ())
+ if (selectlen == is -> is_selectlen
+ && bcmp (selector, is -> is_selector, is -> is_selectlen) == 0
+ && strcmp (provider, is -> is_provider) == 0)
+ break;
+ (void) endisoservent ();
+
+ if (is) {
+#ifdef DEBUG
+ if (addr_log -> ll_events & LLOG_DEBUG)
+ _printsrv (is);
+#endif
+ }
+ else
+ SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
+ ("lookup of local service %s %s failed",
+ provider, sel2str (selector, selectlen, 1)));
+
+ return is;
+}
diff --git a/src/isode/compat/signals.c b/src/isode/compat/signals.c
new file mode 100644
index 000000000..7c4d3bb7a
--- /dev/null
+++ b/src/isode/compat/signals.c
@@ -0,0 +1,151 @@
+/* signals.c - signal handling */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:14 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:43 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:42 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:12 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <signal.h>
+#ifndef BADSIG
+#define BADSIG ((SFP) -1)
+#endif
+#include "manifest.h"
+
+/* */
+
+int _iosignals_set = 0;
+
+/* Berkeley UNIX: 4.2 */
+
+#ifndef XOS_2
+#ifdef BSDSIGS
+
+/* Simply including <signal.h> is sufficient for everything but AIX */
+
+#ifdef AIX /* #define'd to be _signal */
+IFP signal (sig, func)
+int sig;
+IFP func;
+{
+ struct sigvec sv1,
+ sv2;
+
+ sv1.sv_handler = func;
+ sv1.sv_mask = sv1.sv_onstack = 0;
+ return (sigvec (sig, &sv1, &sv2) != NOTOK ? sv2.sv_handler : BADSIG);
+}
+#endif
+
+#else
+
+/* AT&T UNIX: 5 */
+
+
+/* Probably a race condition or two in this code */
+
+
+static int blocked = 0;
+static int pending = 0;
+
+static SFP handler[NSIG];
+
+static SFD sigser (sig)
+int sig;
+{
+ (void) signal (sig, sigser);
+
+ pending |= sigmask (sig);
+}
+
+/* */
+#ifndef SVR4_UCB
+
+int sigblock (mask)
+int mask;
+{
+ register int sig,
+ smask;
+ long omask = blocked;
+
+ if (mask == 0)
+ return blocked;
+
+ for (sig = 1, smask = sigmask (sig); sig < NSIG; sig++, smask <<= 1)
+ if ((smask & mask) && !(smask & blocked)) {
+ pending &= ~smask;
+ handler[sig] = signal (sig, sigser);
+ blocked |= smask;
+ }
+
+ return omask;
+}
+
+#ifdef linux
+sigset_t sigsetmask (mask)
+#else
+int sigsetmask (mask)
+#endif
+int mask;
+{
+ register int sig,
+ smask;
+ long omask = blocked;
+
+ for (sig = 1, smask = sigmask (sig); sig < NSIG; sig++, smask <<= 1)
+ if (smask & mask) {
+ if (smask & blocked)
+ continue;
+
+ pending &= ~smask;
+ handler[sig] = signal (sig, sigser);
+ blocked |= smask;
+ }
+ else
+ if (smask & blocked) {
+ blocked &= ~smask;
+ (void) signal (sig, handler[sig] != BADSIG ? handler[sig]
+ : SIG_DFL);
+ if (smask & pending) {
+ pending &= ~smask;
+ (void) kill (getpid (), sig);
+ }
+ }
+
+ return omask;
+}
+
+#endif
+#endif
+#endif
diff --git a/src/isode/compat/smalloc.c b/src/isode/compat/smalloc.c
new file mode 100644
index 000000000..fbd471a86
--- /dev/null
+++ b/src/isode/compat/smalloc.c
@@ -0,0 +1,60 @@
+/* smalloc.c - error checking malloc */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:16 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:44 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:44 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:12 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* */
+
+char *
+smalloc(size)
+int size;
+{
+ register char *ptr;
+
+ if ((ptr = malloc((unsigned) size)) == NULL){
+ LLOG (compat_log,LLOG_FATAL, ("malloc() failure"));
+ abort ();
+ /* NOTREACHED */
+ }
+
+ return(ptr);
+}
diff --git a/src/isode/compat/sprintb.c b/src/isode/compat/sprintb.c
new file mode 100644
index 000000000..b1c4136d7
--- /dev/null
+++ b/src/isode/compat/sprintb.c
@@ -0,0 +1,77 @@
+/* sprintb.c - sprintf on bits */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:18 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:46 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:46 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:13 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* */
+
+char *sprintb (v, bits)
+register int v;
+register char *bits;
+{
+ register int i,
+ j;
+ register char c,
+ *bp;
+ static char buffer[BUFSIZ];
+
+ (void) sprintf (buffer, bits && *bits == 010 ? "0%o" : "0x%x", v);
+ bp = buffer + strlen (buffer);
+
+ if (bits && *++bits) {
+ j = 0;
+ *bp++ = '<';
+ while (i = *bits++)
+ if (v & (1 << (i - 1))) {
+ if (j++)
+ *bp++ = ',';
+ for (; (c = *bits) > 32; bits++)
+ *bp++ = c;
+ }
+ else
+ for (; *bits > 32; bits++)
+ continue;
+ *bp++ = '>';
+ *bp = NULL;
+ }
+
+ return buffer;
+}
diff --git a/src/isode/compat/sstr2arg.c b/src/isode/compat/sstr2arg.c
new file mode 100644
index 000000000..d52c379aa
--- /dev/null
+++ b/src/isode/compat/sstr2arg.c
@@ -0,0 +1,164 @@
+/* sstr2arg: convert string into argument list */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:26 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:48 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:47 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:13 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "manifest.h"
+#include "general.h"
+#include <errno.h>
+extern int errno;
+
+/* */
+
+/*
+ stash a pointer to each field into the passed array. any common seperators
+ split the words. extra white-space between fields is ignored.
+
+ specially-interpreted characters:
+ double-quote, backslash (preceding a special char with a backslash
+ removes its interpretation. A backslash not followed by a special is
+ used to preface an octal specification for one character a string begun
+ with double-quote has only double-quote and backslash as special
+ characters.
+
+*/
+
+
+
+
+sstr2arg (srcptr, maxpf, argv, dlmstr)
+register char *srcptr; /* source data */
+int maxpf; /* maximum number of permitted fields */
+char *argv[]; /* where to put the pointers */
+char *dlmstr; /* Delimiting character */
+{
+ char gotquote; /* currently parsing quoted string */
+ register int ind;
+ register char *destptr;
+ char idex[256];
+
+ if (srcptr == 0)
+ return (NOTOK);
+
+ bzero (idex, sizeof idex);
+ for (destptr = dlmstr; *destptr; destptr++)
+ idex[*destptr] = 1;
+
+ for (ind = 0, maxpf -= 2;; ind++) {
+ if (ind >= maxpf)
+ return (NOTOK);
+
+ /* Skip leading white space */
+ for (; *srcptr == ' ' || *srcptr == '\t'; srcptr++);
+
+ argv [ind] = srcptr;
+ destptr = srcptr;
+
+ for (gotquote = 0; ; ) {
+
+ if (idex[*srcptr])
+ {
+ if (gotquote) { /* don't interpret the char */
+ *destptr++ = *srcptr++;
+ continue;
+ }
+
+ srcptr++;
+ *destptr = '\0';
+ goto nextarg;
+ } else {
+ switch (*srcptr) {
+ default: /* just copy it */
+ *destptr++ = *srcptr++;
+ break;
+
+ case '\"': /* beginning or end of string */
+ gotquote = (gotquote) ? 0 : 1 ;
+ srcptr++; /* just toggle */
+ break;
+
+ case '\\': /* quote next character */
+ srcptr++; /* skip the back-slash */
+ switch (*srcptr) {
+ /* Octal character */
+ case '0': case '1':
+ case '2': case '3':
+ case '4': case '5':
+ case '6': case '7':
+ *destptr = '\0';
+ do
+ *destptr = (*destptr << 3) | (*srcptr++ - '0');
+ while (*srcptr >= '0' && *srcptr <= '7');
+ destptr++;
+ break;
+ /* C escape char */
+ case 'b':
+ *destptr++ = '\b';
+ srcptr++;
+ break;
+ case 'n':
+ *destptr++ = '\n';
+ srcptr++;
+ break;
+ case 'r':
+ *destptr++ = '\r';
+ srcptr++;
+ break;
+ case 't':
+ *destptr++ = '\t';
+ srcptr++;
+ break;
+
+ /* Boring -- just copy ASIS */
+ default:
+ *destptr++ = *srcptr++;
+ }
+ break;
+
+ case '\0':
+ *destptr = '\0';
+ ind++;
+ argv[ind] = (char *) 0;
+ return (ind);
+ }
+ }
+ }
+ nextarg:
+ continue;
+ }
+}
diff --git a/src/isode/compat/str2elem.c b/src/isode/compat/str2elem.c
new file mode 100644
index 000000000..b0858ec8c
--- /dev/null
+++ b/src/isode/compat/str2elem.c
@@ -0,0 +1,71 @@
+/* str2elem.c - string to list of integers */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:27 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:50 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:49 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:14 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+/* */
+
+int str2elem (s, elements)
+char *s;
+unsigned int elements[];
+{
+ register int i;
+ register unsigned int *ip;
+ register char *cp,
+ *dp;
+
+ ip = elements, i = 0;
+ for (cp = s; *cp && i <= NELEM; cp = ++dp) {
+ for (dp = cp; isdigit ((u_char) *dp); dp++)
+ continue;
+ if ((cp == dp) || (*dp && *dp != '.'))
+ break;
+ *ip++ = (unsigned int) atoi (cp), i++;
+ if (*dp == NULL)
+ break;
+ }
+ if (*dp || i >= NELEM)
+ return NOTOK;
+ *ip = 0;
+
+ return i;
+}
diff --git a/src/isode/compat/str2saddr.c b/src/isode/compat/str2saddr.c
new file mode 100644
index 000000000..f5f997140
--- /dev/null
+++ b/src/isode/compat/str2saddr.c
@@ -0,0 +1,56 @@
+/* str2saddr.c - string value to SSAPaddr */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:29 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:52 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:51 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:16 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* */
+
+struct SSAPaddr *str2saddr (str)
+char *str;
+{
+ register struct PSAPaddr *pa;
+
+ if (pa = str2paddr (str))
+ return (&pa -> pa_addr);
+
+ return NULLSA;
+}
diff --git a/src/isode/compat/str2sel.c b/src/isode/compat/str2sel.c
new file mode 100644
index 000000000..b8089f6df
--- /dev/null
+++ b/src/isode/compat/str2sel.c
@@ -0,0 +1,135 @@
+/* str2sel.c - string to selector */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:31 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:54 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.2 1994/06/06 19:51:31 eichin
+ * NULL is not a char
+ *
+ * Revision 1.1 1994/05/31 20:34:52 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:18 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+
+#define QUOTE '\\'
+
+/* STR2SEL */
+
+int str2sel (s, quoted, sel, n)
+char *s,
+ *sel;
+int quoted,
+ n;
+{
+ int i,
+ r;
+ register char *cp;
+
+ if (*s == NULL)
+ return 0;
+
+ if (quoted <= 0) {
+ for (cp = s; *cp; cp++)
+ if (!isxdigit ((u_char) *cp))
+ break;
+
+ if (*cp == NULL && (i = (cp - s)) >= 2 && (i & 0x01) == 0) {
+ if (i > (r = n * 2))
+ i = r;
+ i = implode ((u_char *) sel, s, i);
+ if ((r = (n - i)) > 0)
+ bzero (sel + i, r);
+ return i;
+ }
+ if (*s == '#') { /* gosip style, network byte-order */
+ i = atoi (s + 1);
+ sel[0] = (i >> 8) & 0xff;
+ sel[1] = i & 0xff;
+
+ return 2;
+ }
+
+ DLOG (compat_log, LLOG_EXCEPTIONS, ("invalid selector \"%s\"", s));
+ }
+
+ for (cp = sel; *s && n > 0; cp++, s++, n--)
+ if (*s != QUOTE)
+ *cp = *s;
+ else
+ switch (*++s) {
+ case 'b':
+ *cp = '\b';
+ break;
+ case 'f':
+ *cp = '\f';
+ break;
+ case 'n':
+ *cp = '\n';
+ break;
+ case 'r':
+ *cp = '\r';
+ break;
+ case 't':
+ *cp = '\t';
+ break;
+
+ case 0:
+ s--;
+ case QUOTE:
+ *cp = QUOTE;
+ break;
+
+ default:
+ if (!isdigit ((u_char) *s)) {
+ *cp++ = QUOTE;
+ *cp = *s;
+ break;
+ }
+ r = *s != '0' ? 10 : 8;
+ for (i = 0; isdigit ((u_char) *s); s++)
+ i = i * r + *s - '0';
+ s--;
+ *cp = toascii (i);
+ break;
+ }
+ if (n > 0)
+ *cp = NULL;
+
+ return (cp - sel);
+}
diff --git a/src/isode/compat/str2taddr.c b/src/isode/compat/str2taddr.c
new file mode 100644
index 000000000..63fdd29e2
--- /dev/null
+++ b/src/isode/compat/str2taddr.c
@@ -0,0 +1,56 @@
+/* str2taddr.c - string value to TSAPaddr */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:33 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:56 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:54 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:18 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* */
+
+struct TSAPaddr *str2taddr (str)
+char *str;
+{
+ register struct PSAPaddr *pa;
+
+ if (pa = str2paddr (str))
+ return (&pa -> pa_addr.sa_addr);
+
+ return NULLTA;
+}
diff --git a/src/isode/compat/str2vec.c b/src/isode/compat/str2vec.c
new file mode 100644
index 000000000..93dfa82e9
--- /dev/null
+++ b/src/isode/compat/str2vec.c
@@ -0,0 +1,105 @@
+/* str2vec.c - string to vector */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:35 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:16:58 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:56 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:19 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+
+#define QUOTE '\\'
+
+/* */
+
+int str2vecX (s, vec, nmask, mask, brk, docomma)
+register char *s,
+ **vec,
+ brk;
+int nmask,
+ *mask,
+ docomma;
+{
+ register int i;
+ char comma = docomma ? ',' : ' ';
+
+ if (mask)
+ *mask = 0;
+
+ for (i = 0; i <= NVEC;) {
+ vec[i] = NULL;
+ if (brk > 0) {
+ if (i > 0 && *s == brk)
+ *s++ = NULL;
+ }
+ else
+ while (isspace ((u_char) *s) || *s == comma)
+ *s++ = NULL;
+ if (*s == NULL)
+ break;
+
+ if (*s == '"') {
+ if (i < nmask)
+ *mask |= 1 << i;
+ for (vec[i++] = ++s; *s != NULL && *s != '"'; s++)
+ if (*s == QUOTE) {
+ if (*++s == '"')
+ (void) strcpy (s - 1, s);
+ s--;
+ }
+ if (*s == '"')
+ *s++ = NULL;
+ continue;
+ }
+ if (*s == QUOTE && *++s != '"')
+ s--;
+ vec[i++] = s;
+
+ if (brk > 0) {
+ if (*s != brk)
+ for (s++; *s != NULL && *s != brk; s++)
+ continue;
+ }
+ else
+ for (s++; *s != NULL && !isspace ((u_char) *s) && *s != comma; s++)
+ continue;
+ }
+ vec[i] = NULL;
+
+ return i;
+}
diff --git a/src/isode/compat/strdup.c b/src/isode/compat/strdup.c
new file mode 100644
index 000000000..736396b01
--- /dev/null
+++ b/src/isode/compat/strdup.c
@@ -0,0 +1,69 @@
+/* strdup.c - create a duplicate copy of the given string */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:37 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:00 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:57 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:19 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* */
+#if (!defined(SVR4) && !defined(linux))
+
+char *strdup (str)
+register char *str;
+{
+ register char *ptr;
+
+ if ((ptr = malloc((unsigned) (strlen (str) + 1))) == NULL){
+ LLOG (compat_log,LLOG_FATAL, ("strdup malloc() failure"));
+ abort ();
+ /* NOTREACHED */
+ }
+
+ (void) strcpy (ptr, str);
+
+ return ptr;
+}
+
+#else
+
+strdup_stub ()
+{;}
+
+#endif
diff --git a/src/isode/compat/sunlink.c b/src/isode/compat/sunlink.c
new file mode 100644
index 000000000..493e9676d
--- /dev/null
+++ b/src/isode/compat/sunlink.c
@@ -0,0 +1,683 @@
+/* sunlink.c - X.25 abstractions for SunLink X25 */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ * Contributed by John Pavel, Department of Trade and Industry/National
+ * Physical Laboratory in the UK
+ * much hacked my others since then - i.e., don't blame John!
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:39 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:02 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:34:59 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:20 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+
+/* SUN UNIX: SunLink X25 */
+
+#ifdef X25
+
+#include "x25.h"
+#include "isoaddrs.h"
+
+#ifdef SUN_X25
+
+#define CALLING 0
+#define CALLED 1
+#define PROBE (-1)
+
+/* */
+
+#ifdef DEBUG
+void print_x25_facilities ();
+static int log_x25_facilities ();
+#endif
+
+/* */
+
+/* ARGSUSED */
+
+int start_x25_client (local, priv)
+struct NSAPaddr *local;
+int priv;
+{
+ int sd;
+
+ if ((sd = socket (AF_X25, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK;
+ }
+
+ return sd;
+}
+
+/* */
+
+int start_x25_server (local, backlog, opt1, opt2)
+struct NSAPaddr *local;
+int backlog,
+ opt1,
+ opt2;
+{
+ CONN_DB sbuf,
+ xbuf;
+ CONN_DB *sock = &sbuf,
+ *xs = &xbuf;
+ int sd, onoff;
+
+ if ((sd = socket (AF_X25, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK;
+ }
+
+ onoff = 0;
+ if (ioctl (sd, X25_CALL_ACPT_APPROVAL, (char *) &onoff) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("X25_CALL_ACPT_APPROVAL"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+
+#ifdef AEF_NSAP
+ if (local -> na_stack == NA_NSAP) {
+ FACILITY f;
+
+ f.type = T_CALLED_AEF;
+ if (nsap2if (local, &f.f_called_aef) == NOTOK)
+ return NOTOK;
+ if (ioctl (sd, X25_SET_FACILITY, &f) == NOTOK)
+ return NOTOK;
+ bzero ((char *)xs, sizeof *xs);
+ if (bind (sd, (struct sockaddr *)xs, sizeof *xs) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+ }
+ else {
+#endif
+ if (ioctl (sd, X25_RD_HOSTADR, (char *) xs) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_HOSTADR"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+ /* if null DTE in /etc/x25params
+ then ALWAYS use null DTE for
+ listen if PID is specified */
+ if (xs -> hostlen == 0 && local -> na_pidlen > 0) {
+ if (local -> na_pidlen > NPSIZE)
+ local -> na_pidlen = NPSIZE;
+ *sock = *xs; /* struct copy */
+ bzero((char *) sock -> data, NPSIZE);
+ bcopy (local -> na_pid, (char *) sock -> data, local -> na_pidlen);
+ bcopy (local -> na_cudf, (char *) sock -> data + NPSIZE,
+ local -> na_cudflen);
+ sock -> datalen = local -> na_pidlen + local -> na_cudflen;
+ }
+ else
+ sock = gen2if(local, sock, ADDR_LISTEN);
+
+ /* Adopt the convention that if a null DTE is given,
+ we should get the one from /etc/x25params */
+ if(!local->na_dtelen) {
+ /* Now set the generic local address */
+ local = if2gen(local, xs, ADDR_LOCAL);
+ /* Modified by INRIA to avoid a null local address */
+ if (!local->na_dtelen) {
+ local->na_dtelen = 1;
+ local->na_dte[0] = '0';
+ }
+ }
+ if (bind (sd, (struct sockaddr *) sock, sizeof(CONN_DB)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+#ifdef AEF_NSAP
+ }
+#endif
+
+#ifndef BSD43
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, NULLCP, 0);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, NULLCP, 0);
+#else
+ onoff = 1;
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, (char *)&onoff, sizeof onoff);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, (char *)&onoff, sizeof onoff);
+#endif
+
+ if (set_x25_facilities(sd, CALLED, "Acceptable") == NOTOK) {
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+
+ (void) listen (sd, backlog);
+
+ return sd;
+}
+
+/* */
+
+int join_x25_server (fd, remote)
+register int fd;
+register struct NSAPaddr *remote;
+{
+ CONN_DB sbuf;
+ CONN_DB *sock = &sbuf;
+ register int nfd;
+
+ if ((sock = gen2if (remote, sock, ADDR_REMOTE)) == NULL)
+ return NOTOK;
+
+ if (set_x25_facilities(fd, CALLING, "Proposed") == NOTOK)
+ return NOTOK;
+#ifdef ANY_LINK
+ sock -> hostlen |= ANY_LINK;
+#endif
+#ifdef AEF_NONE /* sunnet 7.0 or > */
+
+ /*
+ * For sunnet 7.0 - if we have a real nsap then use that. The
+ * X121 should be filled in as NULL.
+ */
+
+ if (remote -> na_stack == NA_NSAP) {
+ FACILITY f;
+ f.type = T_CALLED_AEF;
+ if (nsap2if (remote, &f.f_called_aef) == NOTOK)
+ return NOTOK;
+ if (ioctl (fd, X25_SET_FACILITY, &f) == NOTOK)
+ return NOTOK;
+ }
+#endif
+ if ((nfd = connect (fd, (struct sockaddr *)sock, sizeof (CONN_DB)))
+ == NOTOK) {
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_cause_and_diag(fd); /* Sun's documentation throwns
+ no light as to whether, or
+ not this will result in any
+ useful information */
+ }
+#ifdef DEBUG
+ else
+ if (compat_log -> ll_events & LLOG_DEBUG)
+ (void) log_x25_facilities(fd, CALLING, "Effective Calling");
+#endif
+
+ return nfd;
+}
+
+/* */
+
+int join_x25_client (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB sbuf;
+ CONN_DB *sock = &sbuf;
+ int len = sizeof *sock;
+ int nfd;
+#ifdef AEF_NSAP
+ FACILITY f;
+#endif
+
+ if ((nfd = accept (fd, (struct sockaddr *) sock, &len)) == NOTOK) {
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_cause_and_diag(fd); /* Sun's documentation throwns
+ no light as to whether, or
+ not this will result in any
+ useful information */
+ }
+#ifdef DEBUG
+ else
+ if (compat_log -> ll_events & LLOG_DEBUG)
+ (void) log_x25_facilities(fd, CALLED, "Effective Called");
+#endif
+ if (nfd < 0) return nfd;
+
+ /* May also need to send call accept packet if using
+ * FAST_ACPT_CLR, or X25_CALL_ACPT_APPROVAL
+ * there was a SUNLINK bug in this area
+ *
+ * May as well try it -- if it fails, so what ??
+ */
+ if (ioctl(nfd,X25_SEND_CALL_ACPT, NULLCP) < 0)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_SEND_CALL_ACPT"));
+
+#ifdef AEF_NONE /* sunnet 7.0 or > */
+
+ /*
+ * For sunnet 7.0 - see if we have a real nsap and use that.
+ */
+
+ f.type = T_CALLING_AEF;
+ if (ioctl (nfd, X25_GET_FACILITY, &f) == NOTOK ||
+ if2nsap (&f.f_calling_aef, remote) == NOTOK)
+#endif
+
+ remote = if2gen (remote, sock, ADDR_REMOTE);
+
+ return nfd;
+}
+
+/* */
+
+/* There is a bug whereby if the thruput is set, calls fail. pb@cl.cam.ac.uk */
+
+int sun_fixed_thruput = 0;
+
+/* Set up X.25 Facilities. Note that setting even one value causes
+ the default (/etc/x25params) values to be set explicitly on the
+ call request (and probably also call accept). This can screw
+ things up, if your /etc/x25params has not been properly
+ localised as is normally the case. */
+
+/* ARGSUSED */
+int set_x25_facilities(sd, coc, caption)
+int sd, coc;
+char *caption;
+{
+ FACILITY_DB facilities;
+
+ bzero ((char *) &facilities, sizeof facilities);
+
+ if (coc != CALLED
+ && ioctl (sd, X25_RD_FACILITY, (char *) &facilities) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_FACILITY"));
+ return NOTOK;
+ }
+
+ if (coc == PROBE
+ || !(coc == CALLED
+ || reverse_charge || recvpktsize || sendpktsize
+ || recvwndsize || sendwndsize || recvthruput
+ || sendthruput || cug_req /* || cug_index */
+ || fast_select_type || rpoa_req /* || rpoa */)) {
+ if (facilities.recvpktsize)
+ recvpktsize = facilities.recvpktsize;
+ if (facilities.sendpktsize)
+ sendpktsize = facilities.sendpktsize;
+
+ return OK;
+ }
+
+ if (reverse_charge)
+ facilities.reverse_charge = reverse_charge;
+ if (recvpktsize)
+ facilities.recvpktsize = recvpktsize;
+ if (sendpktsize)
+ facilities.sendpktsize = sendpktsize;
+ if (recvwndsize)
+ facilities.recvwndsize = recvwndsize;
+ if (sendwndsize)
+ facilities.sendwndsize = sendwndsize;
+ if (sun_fixed_thruput) { /* get round Sun bug */
+ if (recvthruput)
+ facilities.recvthruput = recvthruput;
+ if (sendthruput)
+ facilities.sendthruput = sendthruput;
+ }
+ else
+ facilities.recvthruput = facilities.sendthruput = 0;
+ if (cug_req)
+ facilities.cug_req = cug_req;
+ if (cug_index)
+ facilities.cug_index = cug_index;
+ if (fast_select_type)
+ facilities.fast_select_type = fast_select_type;
+ /* May as well accept FCS calls */
+ else
+ if (coc == CALLED)
+ facilities.fast_select_type = FAST_ACPT_CLR;
+ if (rpoa_req)
+ facilities.rpoa_req = rpoa_req;
+ if (rpoa)
+ facilities.rpoa = rpoa;
+
+#undef DO_NOT_USE_FACILITIES
+#ifndef DO_NOT_USE_FACILITIES
+#ifdef DEBUG
+ if (compat_log -> ll_events & LLOG_DEBUG)
+ print_x25_facilities (facilities, coc, caption);
+#endif
+
+ if (ioctl (sd, X25_WR_FACILITY, (char *) &facilities) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_WR_FACILITY"));
+ return NOTOK;
+ }
+#endif
+
+#ifdef notyet
+ if (facilities.recvpktsize)
+ recvpktsize = facilities.recvpktsize;
+ if (facilities.sendpktsize)
+ sendpktsize = facilities.sendpktsize;
+#endif
+
+ return OK;
+}
+
+/* */
+
+int log_cause_and_diag(fd)
+int fd;
+{
+ X25_CAUSE_DIAG diag;
+
+ if (ioctl(fd, X25_RD_CAUSE_DIAG, (char *) &diag) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_CAUSE_DIAG"));
+ return NOTOK;
+ }
+
+ return elucidate_x25_err ((int) diag.flags, diag.data);
+
+}
+
+/* */
+
+#ifdef DEBUG
+
+static int log_x25_facilities (fd, coc, caption)
+int fd;
+int coc;
+char *caption;
+{
+ FACILITY_DB f;
+
+ if (ioctl (fd, X25_RD_FACILITY, (char *) &f) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_FACILITY"));
+ return NOTOK;
+ }
+
+ print_x25_facilities (f, coc, caption);
+
+ return OK;
+}
+
+/* */
+
+static void print_x25_facilities (f, coc, caption)
+FACILITY_DB f;
+int coc;
+char *caption;
+{
+ int baud;
+
+ DLOG (compat_log, LLOG_DEBUG, ("%s X.25 Facilities:", caption));
+
+ switch (f.reverse_charge) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ((coc == CALLED)
+ ? "reverse charging not requested"
+ : "reverse charging not allowed"));
+ break;
+
+ case 1:
+ DLOG (compat_log, LLOG_DEBUG, ((coc == CALLING)
+ ? "reverse charging requested"
+ : "reverse charging allowed"));
+ break;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid reverse_charge: %d",
+ f.reverse_charge));
+ break;
+ }
+
+ switch (f.recvpktsize) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ("default recv packet size"));
+ break;
+
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ case 512:
+ case 1024:
+ DLOG (compat_log, LLOG_DEBUG, ("recv packet size %d",
+ f.recvpktsize));
+ break;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid recv packet size %d",
+ f.recvpktsize));
+ break;
+ }
+
+ switch (f.sendpktsize) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ("default send packet size"));
+ break;
+
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ case 512:
+ case 1024:
+ DLOG (compat_log, LLOG_DEBUG, ("send packet size %d",
+ f.sendpktsize));
+ break;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid send packet size %d",
+ f.sendpktsize));
+ break;
+ }
+
+ DLOG (compat_log, LLOG_DEBUG,
+ (f.recvwndsize == 0 ? "default recv window size"
+ : 1 <= f.recvwndsize && f.recvwndsize <= 127
+ ? "recv window size %d"
+ : "invalid recv window size %d",
+ f.recvwndsize));
+
+ DLOG (compat_log, LLOG_DEBUG,
+ (f.sendwndsize == 0 ? "default send window size"
+ : 1 <= f.sendwndsize && f.sendwndsize <= 127
+ ? "send window size %d"
+ : "invalid send window size %d",
+ f.sendwndsize));
+
+ switch (f.recvthruput) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ("default recv throughput"));
+ break;
+
+ case 3:
+ baud = 75;
+print_recv: ;
+ DLOG (compat_log, LLOG_DEBUG, ("recv throughput %dbps", baud));
+ break;
+
+ case 4:
+ baud = 150;
+ goto print_recv;
+
+ case 5:
+ baud = 300;
+ goto print_recv;
+
+ case 6:
+ baud = 600;
+ goto print_recv;
+
+ case 7:
+ baud = 1200;
+ goto print_recv;
+
+ case 8:
+ baud = 2400;
+ goto print_recv;
+
+ case 9:
+ baud = 4800;
+ goto print_recv;
+
+ case 10:
+ baud = 9600;
+ goto print_recv;
+
+ case 11:
+ baud = 19200;
+ goto print_recv;
+
+ case 12:
+ baud = 48000;
+ goto print_recv;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid recv throughput %d",
+ f.recvthruput));
+ break;
+ }
+
+ switch (f.sendthruput) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ("default send throughput"));
+ break;
+
+ case 3:
+ baud = 75;
+print_send: ;
+ DLOG (compat_log, LLOG_DEBUG, ("send throughput %dbps", baud));
+ break;
+
+ case 4:
+ baud = 150;
+ goto print_send;
+
+ case 5:
+ baud = 300;
+ goto print_send;
+
+ case 6:
+ baud = 600;
+ goto print_send;
+
+ case 7:
+ baud = 1200;
+ goto print_send;
+
+ case 8:
+ baud = 2400;
+ goto print_send;
+
+ case 9:
+ baud = 4800;
+ goto print_send;
+
+ case 10:
+ baud = 9600;
+ goto print_send;
+
+ case 11:
+ baud = 19200;
+ goto print_send;
+
+ case 12:
+ baud = 48000;
+ goto print_send;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid send throughput %d",
+ f.sendthruput));
+ break;
+ }
+
+ switch (f.cug_req) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ("no closed user group"));
+ break;
+
+ case 1:
+ DLOG (compat_log, LLOG_DEBUG, ("closed user group 0x%x (BCD)",
+ f.cug_req));
+ break;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid closed user group %d",
+ f.cug_req));
+ break;
+ }
+
+ switch (f.fast_select_type) {
+ case FAST_OFF:
+ DLOG (compat_log, LLOG_DEBUG, ("don't use fast select"));
+ break;
+
+ case FAST_CLR_ONLY:
+ DLOG (compat_log, LLOG_DEBUG, ("clear is fast select response"));
+ break;
+
+ case FAST_ACPT_CLR:
+ DLOG (compat_log, LLOG_DEBUG,
+ ("clear or call accepted is fast select response"));
+ break;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid fast select type %d",
+ f.fast_select_type));
+ break;
+ }
+
+ switch (f.rpoa_req) {
+ case 0:
+ DLOG (compat_log, LLOG_DEBUG, ("no RPOA transit request"));
+ break;
+
+ case 1:
+ DLOG (compat_log, LLOG_DEBUG, ("RPOA transit request 0x%x",
+ f.rpoa_req));
+ break;
+
+ default:
+ DLOG (compat_log, LLOG_DEBUG, ("invalid RPOA transit request %d",
+ f.rpoa_req));
+ }
+}
+#endif
+#endif
+#else
+int _sunlink_stub () {}
+#endif
diff --git a/src/isode/compat/taddr2str.c b/src/isode/compat/taddr2str.c
new file mode 100644
index 000000000..049b2e5db
--- /dev/null
+++ b/src/isode/compat/taddr2str.c
@@ -0,0 +1,59 @@
+/* taddr2str.c - TSAPaddr to string value */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:41 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:04 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:35:01 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:21 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+
+/* */
+
+char *taddr2str (ta)
+register struct TSAPaddr *ta;
+{
+ struct PSAPaddr pas;
+ register struct PSAPaddr *pa = &pas;
+
+ if (!ta)
+ return NULL;
+ bzero ((char *) pa, sizeof *pa);
+ pa -> pa_addr.sa_addr = *ta; /* struct copy */
+
+ return paddr2str (pa, NULLNA);
+}
diff --git a/src/isode/compat/tailor.c b/src/isode/compat/tailor.c
new file mode 100644
index 000000000..cef583b63
--- /dev/null
+++ b/src/isode/compat/tailor.c
@@ -0,0 +1,962 @@
+/* tailor.c - ISODE tailoring */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:43 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:06 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.2 1994/06/06 19:51:33 eichin
+ * NULL is not a char
+ *
+ * Revision 1.1 1994/05/31 20:35:02 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:21 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <ctype.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "isoaddrs.h"
+#include "tailor.h"
+#include "internet.h"
+
+static int events_value ();
+
+#define SUBNET_MAX (6 + 10) /* maximum number of subnet entries */
+
+/* DATA */
+
+struct pair {
+ char *p_name;
+ int p_value;
+};
+
+
+static char *isotailor = "isotailor";
+
+
+char *isodename = "";
+
+char *isodebinpath = BINPATH;
+char *isodesbinpath = SBINPATH;
+char *isodetcpath = ETCPATH;
+char *isodelogpath = LOGPATH;
+
+
+static struct pair ll_pairs[] = {
+ "none", LLOG_NONE,
+ "fatal", LLOG_FATAL,
+ "exceptions", LLOG_EXCEPTIONS,
+ "notice", LLOG_NOTICE,
+ "pdus", LLOG_PDUS,
+ "trace", LLOG_TRACE,
+ "debug", LLOG_DEBUG,
+ "all", LLOG_ALL,
+
+ NULL
+};
+
+static char *compatdebug = "none";
+LLog _compat_log = {
+ "%d.log", NULLCP, "compat", LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *compat_log = &_compat_log;
+
+static char *addrdebug = "none";
+LLog _addr_log = {
+ "%d.log", "addr", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *addr_log = &_addr_log;
+
+static char *tsapdebug = "none";
+LLog _tsap_log = {
+ "%d.tpkt", "tsap", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *tsap_log = &_tsap_log;
+
+static char *ssapdebug = "none";
+LLog _ssap_log = {
+ "%d.spkt", "ssap", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *ssap_log = &_ssap_log;
+
+static char *psapdebug = "none";
+LLog _psap_log = {
+ "%d.pe", NULLCP, "psap", LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *psap_log = &_psap_log;
+
+static char *psap2debug = "none";
+LLog _psap2_log = {
+ "%d.ppkt", "psap2", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *psap2_log = &_psap2_log;
+
+static char *acsapdebug = "none";
+LLog _acsap_log = {
+ "%d.acpkt", "acsap", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *acsap_log = &_acsap_log;
+
+static char *rtsapdebug = "none";
+LLog _rtsap_log = {
+ "%d.rtpkt", "rtsap", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *rtsap_log = &_rtsap_log;
+
+static char *rosapdebug = "none";
+LLog _rosap_log = {
+ "%d.ropkt", "rosap", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *rosap_log = &_rosap_log;
+
+
+#define TS_MASK "\020\01TCP\02X25\03BRG\04TP4\05X2584"
+
+static struct pair ts_pairs[] = {
+ "tcp", TS_TCP,
+ "x25", TS_X25,
+ "x25-84", TS_X2584,
+ "bridge", TS_BRG,
+ "tp4", TS_TP4,
+ "all", TS_ALL,
+
+ NULL
+};
+
+static char *_ts_stacks = "all";
+int ts_stacks = TS_ALL;
+
+static char *_ts_interim = "";
+struct ts_interim ts_interim[SUBNET_MAX + 1] = {
+ "realNS", NULL, SUBNET_REALNS, NA_NSAP, "", 0,
+ "Int-X25", NULL, SUBNET_INT_X25, NA_X25, "", 0,
+ "Internet", NULL, SUBNET_INTERNET, NA_TCP, "", 0,
+ "Janet", NULL, SUBNET_DYNAMIC - 1, NA_X25, "", 0,
+ "localTCP", NULL, SUBNET_DYNAMIC - 2, NA_TCP, "", 0,
+ "IXI", NULL, SUBNET_DYNAMIC - 3, NA_X25, "", 0,
+
+ NULL
+};
+
+static char *_ts_communities = "all";
+int ts_communities[SUBNET_MAX + 1];
+
+static char *_ts_comm_nsap_default = "realNS";
+int ts_comm_nsap_default = SUBNET_REALNS;
+
+static char *_ts_comm_x25_default = "Int-X25";
+int ts_comm_x25_default = SUBNET_INT_X25;
+
+static char *_ts_comm_tcp_default = "Internet";
+int ts_comm_tcp_default = SUBNET_INTERNET;
+
+int tsb_communities[SUBNET_MAX + 1];
+char *tsb_addresses[SUBNET_MAX + 1];
+static char *_tsb_config = "";
+char *tsb_default_address = "undefined";
+
+
+#ifdef X25
+char *x25_local_dte = "";
+char *x25_local_pid = "";
+
+static char *x25_intl_zero_str = "off";
+char x25_intl_zero = 0;
+
+static char *x25_strip_dnic_str = "off";
+char x25_strip_dnic = 0;
+
+char *x25_dnic_prefix = "";
+
+ /* 0 = don't request/allow reverse charging
+ * 1 = reverse charge request/allowed
+ */
+static char *reverse_charge_default = "0";
+u_char reverse_charge = 0;
+
+ /* 0= default recv packet size.
+ * 16, 32, 64, 128,
+ * 256, 512, 1024
+ * ( octets in decimal )
+ */
+static char *recvpktsize_default = "0";
+u_short recvpktsize = 0;
+
+ /* same as above, but for send packet size */
+static char *sendpktsize_default = "0";
+u_short sendpktsize = 0;
+
+ /* 0= default recv window size.
+ * 7, 127 ( in decimal )
+ */
+static char *recvwndsize_default = "0";
+u_char recvwndsize = 0;
+
+ /* same as above, but for send window size */
+static char *sendwndsize_default = "0";
+u_char sendwndsize = 0;
+
+ /* 0= default recv throughtput.
+ * 3= 75 8= 2400
+ * 4= 150 9= 4800
+ * 5= 300 10= 9600
+ * 6= 600 11= 19200
+ * 7= 1200 12= 48000
+ * ( bps in decimal )
+ */
+static char *recvthruput_default = "0";
+u_char recvthruput = 0;
+
+ /* same as above, but for send throughput */
+ /* 1 = use closed user group in cug_index */
+static char *sendthruput_default = "0";
+u_char sendthruput = 0;
+
+ /* 0 = no closed user group. */
+ /* 1 = use closed user group in cug_index */
+static char *cug_req_default = "0";
+u_char cug_req = 0;
+
+ /* valid when cug_req= 1.
+ * 0x00 ~ 0x99 ( closed user group in BCD)
+ */
+static char *cug_index_default = "0";
+u_char cug_index = 0;
+
+ /* 0= don't use fast select
+ * 1= clear is fast select response
+ * 2= clear or call accepted
+ * is fast select response
+ */
+static char *fast_select_type_default = "0";
+u_char fast_select_type = 0;
+
+ /* 0= no RPOA transit request
+ * 1= use RPOA transit request in rpoa
+ */
+static char *rpoa_req_default = "0";
+u_char rpoa_req = 0;
+
+ /* valid when rpoa_req= 1 */
+ /* 0x0000 ~ 0x9999 (RPOA transit group in BCD) */
+static char *rpoa_default = "0";
+u_short rpoa = 0;
+
+static char *x25debug = "none";
+static LLog _x25_log = {
+ "x25log", "x25", NULLCP, LLOG_NONE, LLOG_NONE, -1,
+ LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *x25_log = &_x25_log;
+
+#ifdef CAMTEC_CCL
+static char *x25_outgoing_port_str = "A";
+char x25_outgoing_port = 'A';
+#endif
+#endif
+
+
+#ifdef BRIDGE_X25
+char *x25_bridge_host = "x25bridge";
+char *x25_bridge_addr = "000021000018";
+char *x25_bridge_listen = "";
+char *x25_bridge_pid = "";
+char *x25_bridge_discrim = "0000";
+#endif
+
+#ifdef ULTRIX_X25
+char *x25_default_filter = "Isode";
+char *x25_default_template = "Default";
+char *x25_default_class = "dte-0";
+#endif
+
+#if defined (BRIDGE_X25) || defined (X25)
+static char *x25_bridge_port_default = "146";
+u_short x25_bridge_port = 0;
+#endif
+
+
+static char *_ses_ab_timer = "30"; /* drain for 30 seconds on ABORTs */
+int ses_ab_timer = 30;
+
+static char *_ses_dn_timer = "30"; /* drain for 30 seconds on DISCONNECTs */
+int ses_dn_timer = 30;
+
+static char *_ses_rf_timer = "30"; /* drain for 30 seconds on REFUSEs */
+int ses_rf_timer = 30;
+
+
+char ns_enabled = 0;
+static char *usens = "off";
+
+char *ns_address = "undefined";
+
+/* */
+
+static struct bind {
+ char *b_key;
+
+ char **b_value;
+ int b_dynamic;
+} binds[] = {
+ "localname", &isodename, 0,
+ "binpath", &isodebinpath, 0,
+ "sbinpath", &isodesbinpath, 0,
+ "etcpath", &isodetcpath, 0,
+ "logpath", &isodelogpath, 0,
+
+ "compatlevel", &compatdebug, 0,
+ "compatfile", &_compat_log.ll_file, 0,
+
+ "addrlevel", &addrdebug, 0,
+ "addrfile", &_addr_log.ll_file, 0,
+
+ "tsaplevel", &tsapdebug, 0,
+ "tsapfile", &_tsap_log.ll_file, 0,
+
+ "ssaplevel", &ssapdebug, 0,
+ "ssapfile", &_ssap_log.ll_file, 0,
+
+ "psaplevel", &psapdebug, 0,
+ "psapfile", &_psap_log.ll_file, 0,
+
+ "psap2level", &psap2debug, 0,
+ "psap2file", &_psap2_log.ll_file, 0,
+
+ "acsaplevel", &acsapdebug, 0,
+ "acsapfile", &_acsap_log.ll_file, 0,
+
+ "rtsaplevel", &rtsapdebug, 0,
+ "rtsapfile", &_rtsap_log.ll_file, 0,
+
+ "rosaplevel", &rosapdebug, 0,
+ "rosapfile", &_rosap_log.ll_file, 0,
+
+ "ts_stacks", &_ts_stacks, 0,
+ "ts_interim", &_ts_interim, 0,
+ "ts_communities", &_ts_communities, 0,
+
+ "default_nsap_community", &_ts_comm_nsap_default, 0,
+ "default_x25_community", &_ts_comm_x25_default, 0,
+ "default_tcp_community", &_ts_comm_tcp_default, 0,
+
+ "tsb_communities", &_tsb_config, 0,
+ "tsb_default_address", &tsb_default_address, 0,
+
+#ifdef X25
+ "x25_local_dte", &x25_local_dte, 0,
+ "x25_local_pid", &x25_local_pid, 0,
+ "x25_dnic_prefix", &x25_dnic_prefix, 0,
+ "x25_intl_zero", &x25_intl_zero_str, 0,
+ "x25_strip_dnic", &x25_strip_dnic_str, 0,
+
+ "reverse_charge", &reverse_charge_default, 0,
+ "recvpktsize", &recvpktsize_default, 0,
+ "sendpktsize", &sendpktsize_default, 0,
+ "recvwndsize", &recvwndsize_default, 0,
+ "sendwndsize", &sendwndsize_default, 0,
+ "recvthruput", &recvthruput_default, 0,
+ "sendthruput", &sendthruput_default, 0,
+ "cug_req", &cug_req_default, 0,
+ "cug_index", &cug_index_default, 0,
+ "fast_select_type", &fast_select_type_default, 0,
+ "rpoa_req", &rpoa_req_default, 0,
+ "rpoa", &rpoa_default, 0,
+
+ "x25level", &x25debug, 0,
+ "x25file", &_x25_log.ll_file, 0,
+
+#ifdef CAMTEC_CCL
+ "x25_outgoing_port", &x25_outgoing_port_str, 0,
+#endif
+
+#ifdef ULTRIX_X25
+ "x25_default_filter", &x25_default_filter ,0,
+ "x25_default_template", &x25_default_template ,0,
+ "x25_default_class", &x25_default_class ,0,
+#endif
+
+#endif
+
+#ifdef BRIDGE_X25
+ "x25_bridge_host", &x25_bridge_host, 0,
+ "x25_bridge_addr", &x25_bridge_addr, 0,
+ "x25_bridge_listen", &x25_bridge_listen, 0,
+ "x25_bridge_pid", &x25_bridge_pid, 0,
+ "x25_bridge_discrim", &x25_bridge_discrim, 0,
+#endif
+
+
+#if defined (BRIDGE_X25) || defined (X25)
+ "x25_bridge_port", &x25_bridge_port_default,0,
+#endif
+
+ "ses_abort_timer", &_ses_ab_timer, 0,
+ "ses_disconnect_timer", &_ses_dn_timer, 0,
+ "ses_refuse_timer", &_ses_rf_timer, 0,
+
+ "ns_enable", &usens, 0,
+ "ns_address", &ns_address, 0,
+
+ NULL
+};
+
+
+int tailor_read ();
+char *tailor_value ();
+
+/* */
+
+char *isodesetailor (file)
+char *file;
+{
+ char *ofile = isotailor;
+
+ if ((isotailor = file) == NULLCP)
+ isotailor = "isotailor";
+
+ return ofile;
+}
+
+/* */
+
+void isodetailor (myname, wantuser)
+char *myname;
+int wantuser;
+{
+ register char *hp,
+ *mp;
+ char buffer[BUFSIZ];
+ static int inited = 0;
+
+ if (inited)
+ return;
+ inited = 1;
+
+ tsb_addresses[0] = NULL;
+
+ tailor_read (isodefile (isotailor, 0));
+
+ if (wantuser) {
+ if ((hp = getenv ("HOME")) == NULL)
+ hp = ".";
+ if (myname) {
+ if (mp = rindex (myname, '/'))
+ mp++;
+ if (mp == NULL || *mp == NULL)
+ mp = myname;
+ }
+ else
+ mp = "isode";
+ (void) sprintf (buffer, "%s/.%s_tailor", hp, mp);
+ tailor_read (buffer);
+ }
+
+ isodexport (myname);
+}
+
+/* */
+
+static int tailor_read (file)
+char *file;
+{
+ register char *bp,
+ *cp;
+ char buffer[BUFSIZ];
+ register FILE *fp;
+
+ if (fp = fopen (file, "r")) {
+ while (fgets (buffer, sizeof buffer, fp)) {
+ if ((cp = index (buffer, '\n')) == NULL) {
+ (void) fprintf (stderr, "%s: line too long\n", file);
+ break;
+ }
+ *cp = NULL;
+ if (*buffer == '#' || *buffer == NULL)
+ continue;
+ if ((bp = index (buffer, ':')) == NULL) {
+ (void) fprintf (stderr, "%s: invalid syntax in \"%s\"\n",
+ file, buffer);
+ break;
+ }
+ for (cp = bp - 1; cp >= buffer; cp--)
+ if (isspace ((u_char) *cp))
+ *cp = NULL;
+ else
+ break;
+
+ *bp++ = NULL;
+ while (isspace ((u_char) *bp))
+ *bp++ = NULL;
+
+ for (cp = bp + strlen (bp) - 1; cp >= bp; cp--)
+ if (isspace ((u_char) *cp))
+ *cp = NULL;
+ else
+ break;
+
+ if ((cp = tailor_value (bp))
+ && isodesetvar (buffer, cp, 1) == NOTOK)
+ free (cp);
+ }
+
+ (void) fclose (fp);
+ }
+}
+
+/* */
+
+int isodesetvar (name, value, dynamic)
+char *name,
+ *value;
+int dynamic;
+{
+ register struct bind *b;
+
+ for (b = binds; b -> b_key; b++)
+ if (strcmp (b -> b_key, name) == 0) {
+ if (b -> b_dynamic && *b -> b_value)
+ free (*b -> b_value);
+ *b -> b_value = value, b -> b_dynamic = dynamic;
+ return OK;
+ }
+
+ return NOTOK;
+}
+
+/* */
+
+void isodexport (myname)
+char *myname;
+{
+ compat_log -> ll_events = events_value (ll_pairs, compatdebug, "compatlevel");
+ addr_log -> ll_events = events_value (ll_pairs, addrdebug, "addrlevel");
+ tsap_log -> ll_events = events_value (ll_pairs, tsapdebug, "tsaplevel");
+ ssap_log -> ll_events = events_value (ll_pairs, ssapdebug, "ssaplevel");
+ psap_log -> ll_events = events_value (ll_pairs, psapdebug, "psaplevel");
+ psap2_log -> ll_events = events_value (ll_pairs, psap2debug, "psap2level");
+ acsap_log -> ll_events = events_value (ll_pairs, acsapdebug, "acsaplevel");
+ rtsap_log -> ll_events = events_value (ll_pairs, rtsapdebug, "rtsaplevel");
+ rosap_log -> ll_events = events_value (ll_pairs, rosapdebug, "rosaplevel");
+#ifdef X25
+ x25_log -> ll_events = events_value (ll_pairs, x25debug, "x25level");
+#endif
+
+ ll_hdinit (compat_log, myname);
+ ll_hdinit (addr_log, myname);
+ ll_hdinit (tsap_log, myname);
+ ll_hdinit (ssap_log, myname);
+ ll_hdinit (psap_log, myname);
+ ll_hdinit (psap2_log, myname);
+ ll_hdinit (acsap_log, myname);
+ ll_hdinit (rtsap_log, myname);
+ ll_hdinit (rosap_log, myname);
+#ifdef X25
+ ll_hdinit (x25_log, myname);
+#endif
+
+ ts_stacks = events_value (ts_pairs, _ts_stacks, "ts_stacks");
+#ifndef TCP
+ ts_stacks &= ~TS_TCP;
+#endif
+#ifndef X25
+ ts_stacks &= ~(TS_X25|TS_X2584);
+#endif
+#ifndef BRIDGE_X25
+ ts_stacks &= ~TS_BRG;
+#endif
+#ifndef TP4
+ ts_stacks &= ~TS_TP4;
+#endif
+
+ {
+ register int *ip,
+ *jp,
+ *kp;
+ int j;
+ register char *cp,
+ *adrp,
+ **ap,
+ **cpp;
+ register struct ts_interim *ts;
+ static struct ts_interim *te = NULL;
+ char buffer[BUFSIZ],
+ *vec[NVEC + NSLACK + 1];
+
+ if (te)
+ te -> ts_name = NULL;
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (macro2comm (ts -> ts_name, ts) == NOTOK)
+ (void) fprintf (stderr, "internal error for community \"%s\"\n",
+ ts -> ts_name);
+ if (te == NULL)
+ te = ts;
+
+ (void) strcpy (buffer, _ts_interim);
+ (void) str2vec (buffer, ap = vec);
+ j = SUBNET_DYNAMIC;
+ while (cp = *ap++) {
+ register struct ts_interim *tp;
+
+ ts -> ts_subnet = 0;
+ if (macro2comm (cp, ts) == NOTOK) {
+ (void) fprintf (stderr, "invalid community name \"%s\"\n", cp);
+ break;
+ }
+ for (tp = ts_interim; tp < ts; tp++)
+ if (tp -> ts_length == ts -> ts_length
+ && bcmp (tp -> ts_prefix, ts -> ts_prefix,
+ tp -> ts_length) == 0) {
+ (void) fprintf (stderr,
+ "duplicate prefixes for communities \"%s\" and \"%s\"\n",
+ tp -> ts_name, cp);
+ break;
+ }
+ if (tp < ts)
+ continue;
+
+ ts -> ts_name = strdup (cp);
+ if (ts -> ts_subnet == 0)
+ ts -> ts_subnet = j++;
+ ts++;
+ }
+ ts -> ts_name = NULL;
+
+ (void) strcpy (buffer, _ts_communities);
+ (void) str2vec (buffer, ap = vec);
+ ip = ts_communities;
+ while (cp = *ap++) {
+ if (strcmp (cp, "all") == 0) {
+ for (ts = ts_interim; ts -> ts_name; ts++) {
+ for (jp = ts_communities; jp < ip; jp++)
+ if (*jp == ts -> ts_subnet)
+ break;
+ if (jp >= ip)
+ *ip++ = ts -> ts_subnet;
+ }
+ break;
+ }
+
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (lexequ (ts -> ts_name, cp) == 0)
+ break;
+ if (!ts -> ts_name) {
+ (void) fprintf (stderr,
+ "unknown community name \"%s\" for variable ts_communities\n",
+ cp);
+ continue;
+ }
+
+ for (jp = ts_communities; jp < ip; jp++)
+ if (*jp == ts -> ts_subnet)
+ break;
+ if (jp >= ip)
+ *ip++ = ts -> ts_subnet;
+ }
+ *ip = NULL;
+
+ for (ap = tsb_addresses; *ap; ap++)
+ free (*ap);
+ (void) strcpy (buffer, _tsb_config);
+ (void) str2vec (buffer, ap = vec);
+ ip = tsb_communities, cpp = tsb_addresses;
+ while (cp = *ap++) {
+ if ((adrp = *ap++) == NULLCP) {
+ (void) fprintf (stderr,
+ "missing address for tsb_community \"%s\"\n", cp);
+ break;
+ }
+
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (lexequ (ts -> ts_name, cp) == 0)
+ break;
+ if (!ts -> ts_name) {
+ (void) fprintf (stderr,
+ "unknown community name \"%s\" for variable tsb_communities\n",
+ cp);
+ continue;
+ }
+
+ for (jp = tsb_communities; jp < ip; jp++)
+ if (*jp == ts -> ts_subnet)
+ break;
+ if (jp >= ip) {
+ *ip++ = ts -> ts_subnet, *cpp++ = strdup (adrp);
+
+ for (kp = ts_communities; *kp; kp++)
+ if (*kp == ts -> ts_subnet)
+ break;
+ if (!*kp)
+ *kp++ = ts -> ts_subnet, *kp = NULL;
+ }
+ }
+ *ip = NULL, *cpp = NULLCP;
+
+ cp = _ts_comm_nsap_default;
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (lexequ (ts -> ts_name, cp) == 0)
+ break;
+ if (ts -> ts_name && ts -> ts_syntax == NA_NSAP)
+ ts_comm_nsap_default = ts -> ts_subnet;
+ else
+ (void) fprintf (stderr,
+ "bad community name \"%s\" for variable default_nsap_community\n",
+ cp);
+
+ cp = _ts_comm_x25_default;
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (lexequ (ts -> ts_name, cp) == 0)
+ break;
+ if (ts -> ts_name && ts -> ts_syntax == NA_X25)
+ ts_comm_x25_default = ts -> ts_subnet;
+ else
+ (void) fprintf (stderr,
+ "bad community name \"%s\" for variable default_x25_community\n",
+ cp);
+
+ cp = _ts_comm_tcp_default;
+ for (ts = ts_interim; ts -> ts_name; ts++)
+ if (lexequ (ts -> ts_name, cp) == 0)
+ break;
+ if (ts -> ts_name && ts -> ts_syntax == NA_TCP)
+ ts_comm_tcp_default = ts -> ts_subnet;
+ else
+ (void) fprintf (stderr,
+ "bad community name \"%s\" for variable default_tcp_community\n",
+ cp);
+
+ if (addr_log -> ll_events & LLOG_DEBUG) {
+ LLOG (addr_log, LLOG_DEBUG,
+ ("ts_stacks: %s", sprintb (ts_stacks, TS_MASK)));
+
+ for (ts = ts_interim; ts -> ts_name; ts++) {
+ LLOG (addr_log, LLOG_DEBUG,
+ ("community %s value \"%s\" subnet %d syntax %d",
+ ts -> ts_name, ts -> ts_value ? ts -> ts_value : "",
+ ts -> ts_subnet, ts -> ts_syntax));
+ buffer[explode(buffer, (u_char *) ts -> ts_prefix,
+ ts -> ts_length)] = NULL;
+ LLOG (addr_log, LLOG_DEBUG,
+ (" prefix \"%s\" (%d octets)", buffer,
+ ts -> ts_length));
+ }
+
+ for (ip = ts_communities; *ip; ip++)
+ LLOG (addr_log, LLOG_DEBUG, ("community %d enabled", *ip));
+
+ LLOG (addr_log, LLOG_DEBUG,
+ ("default communities: nsap=%d x25=%d tcp=%d",
+ ts_comm_nsap_default, ts_comm_x25_default,
+ ts_comm_tcp_default));
+
+ for (ip = tsb_communities, cpp = tsb_addresses; *ip; ip++, cpp++) {
+ LLOG (addr_log, LLOG_DEBUG,
+ ("TSB for community %d residing at %s", *ip, *cpp));
+ if (str2taddr (*cpp) == NULLTA)
+ LLOG (addr_log, LLOG_EXCEPTIONS,
+ ("invalid address for TSB to community %d: %s",
+ *ip, *cpp));
+ }
+ }
+ }
+
+#ifdef X25
+ reverse_charge = (u_char) atoi (reverse_charge_default);
+ recvpktsize = (u_short) atoi (recvpktsize_default);
+ sendpktsize = (u_short) atoi (sendpktsize_default);
+ recvwndsize = (u_char) atoi (recvwndsize_default);
+ sendwndsize = (u_char) atoi (sendwndsize_default);
+ recvthruput = (u_char) atoi (recvthruput_default);
+ sendthruput = (u_char) atoi (sendthruput_default);
+ cug_req = (u_char) atoi (cug_req_default);
+ cug_index = (u_char) atoi (cug_index_default);
+ fast_select_type = (u_char) atoi (fast_select_type_default);
+ rpoa_req = atoi (rpoa_req_default);
+ rpoa = (u_short) atoi (rpoa_default);
+
+#ifdef CAMTEC_CCL
+ x25_outgoing_port = *x25_outgoing_port_str;
+#endif
+
+ x25_intl_zero = !strcmp (x25_intl_zero_str, "on");
+ x25_strip_dnic = !strcmp (x25_strip_dnic_str, "on");
+#endif
+
+#if defined (BRIDGE_X25) || defined (X25)
+ x25_bridge_port = htons ((u_short) atoi (x25_bridge_port_default));
+#endif
+
+ ns_enabled = !strcmp (usens, "on");
+}
+
+/* */
+
+#define QUOTE '\\'
+
+
+static char *tailor_value (s)
+register char *s;
+{
+ register int i,
+ r;
+ register char *bp;
+ char buffer[BUFSIZ];
+
+ for (bp = buffer; *s; bp++, s++)
+ if (*s != QUOTE)
+ *bp = *s;
+ else
+ switch (*++s) {
+ case '0':
+ *bp = '\0';
+ break;
+ case 'b':
+ *bp = '\b';
+ break;
+ case 'f':
+ *bp = '\f';
+ break;
+ case 'n':
+ *bp = '\n';
+ break;
+ case 'r':
+ *bp = '\r';
+ break;
+ case 't':
+ *bp = '\t';
+ break;
+
+ case 0: s--;
+ case QUOTE:
+ *bp = QUOTE;
+ break;
+
+ default:
+ if (!isdigit ((u_char) *s)) {
+ *bp++ = QUOTE;
+ *bp = *s;
+ break;
+ }
+ r = *s != '0' ? 10 : 8;
+ for (i = 0; isdigit ((u_char) *s); s++)
+ i = i * r + *s - '0';
+ s--;
+ *bp = toascii (i);
+ break;
+ }
+ *bp = NULL;
+
+ if ((bp = malloc ((unsigned) (strlen (buffer) + 1))) != NULL)
+ (void) strcpy (bp, buffer);
+
+ return bp;
+}
+
+/* */
+
+static int events_value (pairs, s, var)
+struct pair *pairs;
+char *s,
+ *var;
+{
+ int value;
+ register char *cp,
+ **ap;
+ register struct pair *pp;
+ char buffer[BUFSIZ],
+ *vec[NVEC + NSLACK + 1];
+
+ value = 0;
+ (void) strcpy (buffer, s);
+ (void) str2vec (buffer, ap = vec);
+ while (cp = *ap++) {
+ for (pp = pairs; pp -> p_name; pp++)
+ if (strcmp (pp -> p_name, cp) == 0) {
+ value |= pp -> p_value;
+ break;
+ }
+ if (!pp -> p_name)
+ (void) fprintf (stderr, "unknown value \"%s\" for variable %s\n",
+ cp, var);
+ }
+
+ return value;
+}
+
+/* */
+
+#ifdef PEP_TEST
+tailorfree () {
+ register struct bind *b;
+
+ for (b = binds; b -> b_key; b++)
+ if (b -> b_dynamic && *b -> b_value) {
+ free (*b -> b_value);
+ *b -> b_value = NULL;
+ }
+
+ ll_hdfree (compat_log);
+ ll_hdfree (addr_log);
+ ll_hdfree (tsap_log);
+ ll_hdfree (ssap_log);
+ ll_hdfree (psap_log);
+ ll_hdfree (psap2_log);
+ ll_hdfree (acsap_log);
+ ll_hdfree (rtsap_log);
+ ll_hdfree (rosap_log);
+#ifdef X25
+ ll_hdfree (x25_log);
+#endif
+
+ free_macros ();
+ free_bp ();
+ free_oid ();
+}
+
+
+ll_hdfree (lp)
+register LLog *lp;
+{
+ if (lp -> ll_stat & LLOGHDR)
+ free (lp -> ll_hdr);
+ lp -> ll_stat &= ~LLOGHDR;
+}
+#endif
diff --git a/src/isode/compat/ubcx25.c b/src/isode/compat/ubcx25.c
new file mode 100644
index 000000000..cdabf6577
--- /dev/null
+++ b/src/isode/compat/ubcx25.c
@@ -0,0 +1,320 @@
+/* ubcx25.c - X.25 abstractions for UBC X25 */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ * Contributed by Julian Onions, Nottingham University in the UK
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:45 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:08 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:35:04 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:22 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+#include "tpkt.h"
+
+/* 4.[23] UNIX: UBC X25 */
+
+#ifdef X25
+#ifdef UBC_X25
+
+#include "x25.h"
+#include <sys/uio.h>
+
+#define X25_MBIT 0x40
+#define X25_QBIT 0x80
+
+/* */
+
+int start_x25_client (local)
+struct NSAPaddr *local;
+{
+ int sd, pgrp;
+
+ if (local != NULLNA)
+ local -> na_stack = NA_X25, local -> na_community = ts_comm_x25_default;
+ if ((sd = socket (AF_CCITT, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ return sd;
+}
+
+/* */
+
+int start_x25_server (local, backlog, opt1, opt2)
+struct NSAPaddr *local;
+int backlog,
+ opt1,
+ opt2;
+{
+ int sd, pgrp;
+#ifdef notyet
+#ifdef BSD43
+ int onoff;
+#endif
+#endif
+ CONN_DB zsck;
+ CONN_DB *sck = &zsck;
+
+ if ((sd = socket (AF_CCITT, SOCK_STREAM, 0)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
+ return NOTOK; /* Can't get an X.25 socket */
+ }
+
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("SIOCSPGRP"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ if (local != NULLNA) {
+ local -> na_stack = NA_X25, local -> na_community = ts_comm_x25_default;
+ if (local -> na_dtelen == 0) {
+ (void) strcpy (local -> na_dte, x25_local_dte);
+ local -> na_dtelen = strlen(x25_local_dte);
+ if (local -> na_pidlen == 0 && *x25_local_pid)
+ local -> na_pidlen =
+ str2sel (x25_local_pid, -1, local -> na_pid, NPSIZE);
+ }
+ }
+
+ (void) gen2if (local, sck, ADDR_LISTEN);
+ if (bind (sd, sck, sizeof(CONN_DB)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("bind"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+
+
+#ifdef notyet /* not sure if these are supported... */
+#ifndef BSD43
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, NULLCP, 0);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, NULLCP, 0);
+#else
+ onoff = 1;
+ if (opt1)
+ (void) setsockopt (sd, SOL_SOCKET, opt1, (char *)&onoff, sizeof onoff);
+ if (opt2)
+ (void) setsockopt (sd, SOL_SOCKET, opt2, (char *)&onoff, sizeof onoff);
+#endif
+#endif
+
+ (void) listen (sd, backlog);
+
+ return sd;
+}
+
+/* */
+
+int join_x25_client (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB sck;
+ int len = sizeof sck;
+ int nfd;
+
+ if((nfd = accept (fd, (struct sockaddr *) &sck, &len)) == NOTOK)
+ return NOTOK;
+ (void) if2gen (remote, &sck, ADDR_REMOTE);
+ return nfd;
+}
+
+int join_x25_server (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB zsck;
+ CONN_DB *sck = &zsck;
+
+ if (remote == NULLNA || remote -> na_stack != NA_X25)
+ {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("Invalid type na%d", remote->na_stack));
+ return NOTOK;
+ }
+ (void) gen2if (remote, sck, ADDR_REMOTE);
+ return connect (fd, sck, sizeof (CONN_DB));
+}
+
+int read_x25_socket (fd, buffer, len)
+int fd, len;
+char *buffer;
+{
+ static u_char mode;
+ static struct iovec iov[2] = {
+ (char *)&mode, 1,
+ "", 0
+ };
+ char *p = buffer;
+ int cc, count = 0, total = len;
+
+ do {
+ iov[1].iov_base = p;
+ iov[1].iov_len = total > X25_PACKETSIZE ? X25_PACKETSIZE : total;
+
+ switch (cc = readv (fd, iov, 2)) {
+ /*
+ * for the -1,0 & 1 cases these returns should be ok
+ * if it's the first time through, then they are valid anyway
+ * later stages means the M bit is set so there must
+ * be more data else someone is violating the
+ * protocol badly.
+ */
+
+ case NOTOK:
+ case 0:
+ return cc;
+
+ case 1:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("strange return from read_x25_socket"));
+ return NOTOK;
+
+ default:
+ cc --; /* discount the info byte */
+ count += cc;
+ p += cc;
+ total -= cc;
+ }
+ } while (len > 0 && (mode & X25_MBIT));
+ DLOG (compat_log, LLOG_DEBUG, ("X25 read, total %d/%d", count, len));
+
+ return count;
+}
+
+#ifdef UBC_X25_WRITEV
+/* God this all very bizarre - iovecs work on read but not write!! */
+
+/*
+ * OK, this is due to a bug in UBC implementation. It may or may not
+ * be fixed in later versions. If writev allows you to write single
+ * bytes in the first vector then use this version. It's much more
+ * efficient.
+ */
+
+int write_x25_socket (fd, buffer, len)
+int fd, len;
+char *buffer;
+{
+ static u_char mode;
+ static struct iovec iov[2] = {
+ (char *)&mode, 1,
+ "", 0
+ };
+ int cc;
+ char *p = buffer;
+ int count, total = 0;
+
+ do {
+ count = len > X25_PACKETSIZE ? X25_PACKETSIZE : len;
+ mode = len > X25_PACKETSIZE ? X25_MBIT : 0;
+ iov[1].iov_base = p;
+ iov[1].iov_len = count;
+ switch (cc = writev (fd, iov, 2))
+ {
+ case NOTOK:
+ case 0:
+ return cc;
+
+ case 1:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("strange return from write_x25_socket"));
+ return NOTOK;
+
+ default:
+ cc --;
+ len -= cc;
+ p += cc;
+ total += cc;
+ }
+ } while (len > 0);
+ DLOG (compat_log, LLOG_DEBUG, ("X25 write, total %d/%d", total, len));
+ return total;
+}
+#else
+int write_x25_socket (fd, buffer, len)
+int fd, len;
+char *buffer;
+{
+ char mybuffer[X25_PACKETSIZE+1];
+ char *p = buffer;
+ int count, total = 0;
+ int cc;
+
+ do {
+ count = len > X25_PACKETSIZE ? X25_PACKETSIZE : len;
+ mybuffer[0] = len > X25_PACKETSIZE ? X25_MBIT : 0;
+ bcopy (p, &mybuffer[1], count);
+ switch (cc = write (fd, mybuffer, count + 1))
+ {
+ case NOTOK:
+ case 0:
+ return cc;
+
+ case 1:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("strange return from write_x25_socket"));
+ return NOTOK;
+
+ default:
+ cc --;
+ len -= cc;
+ p += cc;
+ total += cc;
+ }
+ } while (len > 0);
+ DLOG (compat_log, LLOG_DEBUG, ("X25 write, total %d/%d", total, len));
+ return total;
+}
+#endif
+
+#else /* UBC_X25 */
+int _ubcx25_stub2 () {}
+#endif /* UBC_X25 */
+#else /* X25 */
+int _ubcx25_stub () {}
+#endif /* X25 */
diff --git a/src/isode/compat/ultrix25.c b/src/isode/compat/ultrix25.c
new file mode 100644
index 000000000..47c2d4fd0
--- /dev/null
+++ b/src/isode/compat/ultrix25.c
@@ -0,0 +1,773 @@
+/* ultrix25.c - X.25 abstractions for Ultrix X25 */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+
+/*
+ * $Header$
+ *
+ * Contributed by George Michaelson, University of Queensland in Australia
+ *
+ * -based on the ubcx25.c and sunlink.c modules
+ * by Julian Onions and John Pavel respectively,
+ *
+ * Using the example code for the Ultrix X.25 interface
+ * written by DEC NAC here in Australia
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:47 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:10 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:35:06 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:23 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/* LINTLIBRARY */
+
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+#include "tailor.h"
+#include "tpkt.h"
+
+/* Ultrix: X25 */
+
+#ifdef X25
+#ifdef ULTRIX_X25
+
+#include "x25.h"
+
+/* are these needed george? */
+#define X25_MBIT 0x40
+#define X25_QBIT 0x80
+
+/*
+ * from examples/socket_incoming.c et al
+ */
+
+/*
+ * these routines in the Ultrix X.25 library do encoding and decoding
+ * of call params. They'll probably be unused, but if I get clever
+ * enough It'd be nice to use them to build up non-standard facilities
+ * and other X.25 call stuff.
+ *
+ * I think they're varargs. should this be ansi-ized at some point???
+ */
+
+extern int X25Decode();
+extern int X25Encode();
+
+/*
+ * Definitions for Call
+ */
+
+#define CALLING 0
+#define CALLED 1
+
+#define BACKLOG 2
+#define MAXMESSAGESIZE 4096
+
+/*
+ * global structs used during decoding and encoding of call params.
+ * -these are probably way oversize.
+ */
+
+static char enc_buf[1024];
+static int enc_buf_len;
+
+/* */
+
+int start_x25_client (local)
+struct NSAPaddr *local;
+{
+ int sd, pgrp;
+
+ if (local != NULLNA)
+ local -> na_stack = NA_X25, local -> na_community = ts_comm_x25_default;
+ if ((sd = socket (AF_X25, SOCK_SEQPACKET, X25_ACCESS)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 socket()"));
+ return NOTOK; /* Error can be found in errno */
+ }
+
+ /*
+ * somebody tell me sometime why setting the process group on
+ * the socket is such a big deal. This is getting like alchemy
+ * with myself doing this 'cos its in the other fellers code...
+ *
+ * camtec & ubc does it, sunlink doesn't.
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 ioctl(SIOCSPGRP)"));
+ return NOTOK;
+ }
+ */
+
+ return sd;
+}
+
+/* */
+
+int start_x25_server (local, backlog, opt1, opt2)
+struct NSAPaddr *local;
+int backlog,
+ /*
+ * in Ultrix X.25 socket functions like turn off/on packet
+ * assembly and call acceptance are done with setsockopt.
+ * it looks like other X.25 socket interfaces are using
+ * "traditional" features like SO_KEEPALIVE, and this
+ * is being passed down in the call from tsap/tsaplisten.c
+ * but I really don't think it applies here.
+ *
+ * thus, the following two arguments are ignored in this
+ * module.
+ */
+ opt1,
+ opt2;
+{
+ int sd, pgrp;
+ CONN_DB zsck;
+ CONN_DB *sck = &zsck;
+ sockaddr_x25 addr;
+
+ if ((sd = socket (AF_X25, SOCK_SEQPACKET, X25_ACCESS)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 socket()"));
+ return NOTOK; /* Can't get an X.25 socket */
+ }
+
+ /*
+ * somebody tell me sometime why setting the process group on
+ * the socket is such a big deal. This is getting like alchemy
+ * with myself doing this 'cos its in the other fellers code...
+ *
+ * camtec & ubc does it, sunlink doesn't.
+ pgrp = getpid();
+ if (ioctl(sd, SIOCSPGRP, &pgrp)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 ioctl(SIOCSPGRP)"));
+ return NOTOK;
+ }
+ */
+
+ if (local != NULLNA) {
+ local -> na_stack = NA_X25, local -> na_community = ts_comm_x25_default;
+ if (local -> na_dtelen == 0) {
+ (void) strcpy (local -> na_dte, x25_local_dte);
+ local -> na_dtelen = strlen(x25_local_dte);
+ if (local -> na_pidlen == 0 && *x25_local_pid)
+ local -> na_pidlen =
+ str2sel (x25_local_pid, -1, local -> na_pid, NPSIZE);
+ }
+ }
+
+ (void) gen2if (local, sck, ADDR_LISTEN);
+ /*
+ * now munge this into DEC format.
+ */
+ addr.sx25_family = AF_X25;
+ addr.sx25_flags = 0;
+ addr.sx25_namelen = strlen(x25_default_filter);
+ strcpy(addr.sx25_name, x25_default_filter);
+
+ if (bind (sd, &addr, sizeof(addr)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 bind()"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+ if (listen (sd, backlog) < 0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 listen()"));
+ (void) close_x25_socket (sd);
+ return NOTOK;
+ }
+ return sd;
+}
+
+/* */
+
+int join_x25_client (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB zsck;
+ CONN_DB *sck = &zsck;
+ sockaddr_x25 filter;
+ int len = sizeof filter;
+ int stat;
+ int nfd;
+
+ if((nfd = accept (fd, &filter, &len)) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 accept()"));
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_call_status(fd); /* decode useful information */
+ return NOTOK;
+ }
+ /*
+ * as well as doing a socket level accept, have to accept responsibilty
+ * for the X.25 incoming request as well...
+ */
+ enc_buf_len = sizeof(enc_buf);
+ if ((stat = getsockopt(nfd,X25_ACCESS,XSO_TAKECALL,enc_buf,&enc_buf_len) < 0 ) ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Taking inbound X.25 Call"));
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_call_status(fd); /* decode useful information */
+ return NOTOK;
+ }
+#ifdef DEBUG
+ if (compat_log -> ll_events & LLOG_DEBUG)
+ (void) print_x25_facilities(fd, CALLED, "Effective Called");
+#endif
+ /*
+ * snarf the incoming call details. could permit some local
+ * sanityclaus checks on the X.25 guff but what the hell...
+ */
+
+ sck->na_dtelen = sizeof(sck->na_dte);
+ if ((stat = X25Decode(enc_buf, enc_buf_len, X25I_CALLINGDTE, sck->na_dte, &(sck->na_dtelen) ) ) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Getting remote DTE"));
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_call_status(fd); /* decode useful information */
+ return NOTOK;
+ }
+
+ sck->na_cudflen = sizeof(sck->na_cudf);
+ if ((stat = X25Decode(enc_buf, enc_buf_len, X25I_USERDATA, sck->na_cudf, &(sck->na_cudflen) ) ) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Getting remote CUDF"));
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_call_status(fd); /* decode useful information */
+ return NOTOK;
+ }
+
+ (void) if2gen (remote, sck, ADDR_REMOTE);
+
+ /*
+ * now send the poor bozo the X.25 acceptance (at last!)
+ */
+ if (setsockopt(nfd,X25_ACCESS,XSO_ACCEPTCALL,(caddr_t)0, 0) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Sending Ultrix X.25 Connect Accept"));
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_call_status(fd); /* decode useful information */
+ return NOTOK;
+ }
+ return nfd;
+}
+
+int join_x25_server (fd, remote)
+int fd;
+struct NSAPaddr *remote;
+{
+ CONN_DB zsck;
+ CONN_DB *sck = &zsck;
+ sockaddr_x25 template;
+
+ register int nfd;
+
+ if (remote == NULLNA || remote -> na_stack != NA_X25)
+ {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Invalid type na%d", remote->na_stack));
+ return NOTOK;
+ }
+ (void) gen2if (remote, sck, ADDR_REMOTE);
+ /*
+ * now we have to re-map the generic forms of the DTE/CUDF/facil
+ * into DECspeak using the X25Encode() call.
+ */
+ if ((enc_buf_len = X25Encode (enc_buf, 1024, X25I_NULL)) <0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Initializing Ultrix X.25 Call Template"));
+ return NOTOK;
+ }
+ if ((enc_buf_len = X25Encode (enc_buf, 1024,
+ X25I_DTECLASS,
+ strlen(x25_default_class), x25_default_class,
+ X25I_CALLEDDTE,
+ sck->na_dtelen, sck->na_dte,
+ X25I_USERDATA,
+ sck->na_cudflen, sck->na_cudf,
+ X25I_NULL)) < 0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Encoding Ultrix X.25 Call Template"));
+ return NOTOK;
+ }
+ if (setsockopt(fd,X25_ACCESS,XSO_SETCONN,enc_buf,enc_buf_len) <0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Overriding Ultrix X.25 Template Values"));
+ return NOTOK;
+ }
+ template.sx25_family = AF_X25;
+ template.sx25_flags = 0;
+ template.sx25_namelen = strlen(x25_default_template);
+ strcpy(template.sx25_name, x25_default_template);
+
+ /*
+ * poached from sunlink.c
+ */
+ if ((nfd = connect (fd, &template, sizeof (template))) == NOTOK) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("x25 connect()"));
+ if (compat_log -> ll_events & LLOG_EXCEPTIONS)
+ (void) log_call_status(fd); /* decode useful information */
+ return NOTOK;
+ }
+#ifdef DEBUG
+ else
+ if (compat_log -> ll_events & LLOG_DEBUG)
+ (void) log_x25_facilities(fd, CALLING, "Effective Calling");
+#endif
+ remote = if2gen (remote, sck, ADDR_REMOTE);
+ return nfd;
+}
+
+close_x25_socket(fd)
+int fd;
+{
+ struct X25ClearData cbuf;
+ struct X25ClearData *cdata = &cbuf;
+ int cbl = sizeof(cbuf);
+ int stat;
+
+ cdata->clearCause = 0; /* DTE originated */
+ cdata->clearDiagnostic = 0; /* no additional information */
+ cdata->clearDetailsLength = 0; /* no Clear Details information */
+
+ if ((stat = setsockopt(fd, X25_ACCESS, XSO_CLEARCALL, cdata, cbl)) < 0) {
+ if (errno != EACCES)
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("x25 setsockopt(XSO_CLEARCALL)"));
+ }
+
+ log_call_status(fd);
+ close(fd);
+}
+
+log_call_status(fd)
+int fd;
+{
+ struct X25PortStatus sbuf;
+ struct X25PortStatus *stats = &sbuf;
+ int sbl = sizeof(sbuf);
+ int stat;
+
+ /*
+ * get X25PortStatus information
+ */
+ if ((stat = getsockopt(fd,X25_ACCESS,XSO_SHOWSTATUS,stats,&sbl) < 0)) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("x25 getsockopt(XSO_SHOWSTATUS)"));
+ return;
+ }
+ switch (stats->portState) {
+ case X25S_OPEN:
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_OPEN: No connection is in Progress."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_CLEARED:
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_CLEARED: The connection has been cleared."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_RUNNING:
+#ifdef DEBUG
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_RUNNING: The connection is still open."));
+ log_call_clear(fd, 0);
+#endif DEBUG
+ break;
+
+ case X25S_CALLING: /* Connection in progress */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_CALLING: Connection in progress."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_CALLED: /* Call received and taken */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_CALLED: Call received and taken."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_SYNC: /* Unconfirmed user reset */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_SYNC: Unconfirmed user reset."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_UNSYNC: /* Unconfirmed reset indic */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_UNSYNC: Unconfirmed reset indication."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_CLEARING: /* User requested clearing */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_CLEARING: User requested clearing."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_NOCOMM: /* No communication with net */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_NOCOMM: No communication with net."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_CLEARBYDIR: /* Cleared by directive */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_CLEARBYDIR: Cleared by directive."));
+ log_call_clear(fd, 0);
+ break;
+
+ case X25S_INCALL: /* Untaken incoming call */
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("X25S_INCALL: Untaken incoming call."));
+ log_call_clear(fd, 0);
+ break;
+
+ default:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("unknown return from getsockopt(XSO_SHOWSTATUS)= %d [see /usr/include/netx25/x25.h]", stats->portState));
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("restricted = %d", stats->restrictedInterface));
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("Int Msg Size = %d", stats->interruptMessageSize));
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("Data Msg Size in = %d", stats->dataMessageSizeIn));
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("Data Msg Size out = %d", stats->dataMessageSizeOut));
+ SLOG (compat_log, LLOG_DEBUG, NULLCP,
+ ("Error BitMap = %2x", stats->errorBitMap));
+ }
+ return;
+}
+
+log_call_clear(fd, type)
+int fd;
+int type;
+{
+ struct X25ClearData cbuf;
+ struct X25ClearData *cdata = &cbuf;
+ int cbl = sizeof(cbuf);
+ int stat;
+ int flags;
+ unsigned char buf[2];
+ extern void elucidate_x25_err();
+ char dbuf[128];
+ int dlen = sizeof(dbuf);
+
+ /*
+ * get X25ClearData information
+ */
+ if ((stat = getsockopt(fd,X25_ACCESS,XSO_CLEARDATA,cdata,&cbl) < 0) &&
+ errno != ENOMSG) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("x25 getsockopt(XSO_CLEARDATA)"));
+ return;
+ }
+ if (errno == ENOMSG)
+ return;
+ /*
+ * set up argbuf to call elucidate_x25_err()
+ */
+ flags = 0;
+ flags = 1 << RECV_DIAG; /* we have diagnostics */
+ if (type == 0) /* diag type (clear/reset) */
+ flags |= 1 << DIAG_TYPE; /* we have call clear diagnostics */
+ buf[0] = cdata->clearCause;
+ buf[1] = cdata->clearDiagnostic;
+ elucidate_x25_err(flags, buf);
+
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("[Clear origin was %s]",
+ cdata->clearOrigin == X25R_ORIGINREMOTE ? "remote" :
+ cdata->clearOrigin == X25R_ORIGINLOCAL ? "local" :
+ "unknown" ));
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("and %d bytes of info", cdata->clearDetailsLength));
+
+ dlen = sizeof(dbuf);
+ if ((stat = X25Decode(cdata->clearDetails,
+ cdata->clearDetailsLength,
+ X25I_CHARGEMON,
+ dbuf, &dlen) ) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("X25Decode(X25I_CHARGEMON)"));
+ return;
+ }
+ if (stat > 0)
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%*s Money Units", stat, dlen, dlen, dbuf));
+ dlen = sizeof(dbuf);
+ if ((stat = X25Decode(cdata->clearDetails,
+ cdata->clearDetailsLength,
+ X25I_CHARGESEG,
+ dbuf, &dlen) ) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("X25Decode(X25I_CHARGESEG)"));
+ return;
+ }
+ if (stat > 0)
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%*s Segments", dlen, dbuf));
+ dlen = sizeof(dbuf);
+ if ((stat = X25Decode(cdata->clearDetails,
+ cdata->clearDetailsLength,
+ X25I_CHARGETIME,
+ dbuf, &dlen) ) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("X25Decode(X25I_CHARGETIME)"));
+ return;
+ }
+ if (stat > 0)
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%*s Time Units", dlen, dbuf));
+ dlen = sizeof(dbuf);
+ if ((stat = X25Decode(cdata->clearDetails,
+ cdata->clearDetailsLength,
+ X25I_USERDATA,
+ dbuf, &dlen) ) <0 ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("X25Decode(X25I_USERDATA)"));
+ return;
+ }
+ if (stat > 0)
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%d Bytes User Data", dlen));
+ return;
+}
+
+
+#ifdef DEBUG
+
+static int log_x25_facilities (fd, coc, caption)
+int fd;
+int coc;
+char *caption;
+{
+ int stat;
+
+ enc_buf_len = sizeof(enc_buf);
+ if (coc == CALLING) {
+ if ((stat = getsockopt(fd,
+ X25_ACCESS,
+ XSO_ACCEPTDETAILS,
+ enc_buf,&enc_buf_len) < 0 ) ) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("getsockopt(XSO_ACCEPTDETAILS)"));
+ return NOTOK;
+ }
+ }
+
+ print_x25_facilities (fd, coc, caption);
+
+ return OK;
+}
+
+/* */
+
+void *
+epl_prtstr (fmt, val, vallen)
+char *fmt;
+char *val;
+int vallen;
+{
+ static char abuf[128];
+ static char tbuf[128];
+ char *c, *d;
+
+ abuf[0] = 0;
+ if (vallen > 0) {
+ for (c = val, d = abuf; vallen; c++, vallen--) {
+ if (!isprint(*c)) {
+ sprintf(d, " 0x%02x ", *c & 0xff);
+ d += 6;
+ } else {
+ sprintf(d, "%c", *c);
+ d++;
+ }
+ }
+ *d = 0;
+ }
+ sprintf(tbuf, fmt, abuf);
+ return tbuf;
+}
+
+void *
+epl_prtbool (fmt, val, vallen)
+char *fmt;
+short *val;
+int vallen;
+{
+ static char *true = "true";
+ static char *false = "false";
+
+ if (*val == 0)
+ return (true);
+ else
+ return (false);
+}
+
+void *
+epl_prtint (fmt, val, vallen)
+char *fmt;
+short *val;
+int vallen;
+{
+ static char tbuf[128];
+
+ sprintf(tbuf, fmt, *val);
+ return tbuf;
+}
+
+void *
+epl_prtlst (fmt, val, vallen)
+char *fmt;
+short *val;
+int vallen;
+{
+ static char *list = "[LIST]";
+
+ return list;
+}
+
+static struct {
+ short code;
+ char type;
+#define EPL_STR 0
+#define EPL_BOOL 1
+#define EPL_INT 2
+#define EPL_LIST 3
+ char *fmt;
+} epl_tab[] = {
+ X25I_CALLEDEXTISO, EPL_STR, "Address ext for dest (ISO): %s",
+ X25I_CALLEDEXTNONISO, EPL_STR, "Non-ISO format: %s",
+ X25I_CALLINGEXTISO, EPL_STR, "Address ext for target (ISO): %s",
+ X25I_CALLINGEXTNONISO, EPL_STR, "Non-ISO format: %s",
+ X25I_CHARGEMON, EPL_STR, "Call charge in monetary units: %s",
+ X25I_CHARGESEG, EPL_STR, "Call charge in segment counts: %s",
+ X25I_CHARGETIME, EPL_STR, "Call charge in elapsed time: %s",
+ X25I_CHARGEINFO, EPL_BOOL, "Charging information request: %s",
+ X25I_CUG, EPL_STR, "Closed User Group: %s",
+ X25I_ETETRANSITDELAY, EPL_LIST, "End-to-end transit delay request: %s",
+ X25I_EXPEDITE, EPL_BOOL, "Interrupts allowed: %s",
+ X25I_NOEXPEDITE, EPL_BOOL, "Interrupts not allowed: %s",
+ X25I_FASTSELECT, EPL_BOOL, "Fast select facility: %s",
+ X25I_FASTSELECTRESTR, EPL_BOOL, "Fast select restricted response : %s",
+ X25I_NONX25FACILITIES, EPL_STR, "Non-X.25 facilities: %s",
+ X25I_CALLINGSUBADDR, EPL_STR, "Calling DTE subaddress: %s",
+ X25I_MINTHRUCLSIN, EPL_INT, "Minimum throughput class incoming: %d",
+ X25I_MINTHRUCLSOUT, EPL_INT, "Minimum throughput class outgoing: %d",
+ X25I_NETUSERID, EPL_STR, "Network-specific user ID: %s",
+ X25I_NSAPMAP, EPL_BOOL, "NSAP mapping to DTE: %s",
+ X25I_PKTSIZEIN, EPL_INT, "Requested incoming packet size: %d",
+ X25I_PKTSIZEOUT, EPL_INT, "Requested outgoing packet size: %d",
+ X25I_PRIORITY, EPL_STR, "Connection priority: %s",
+ X25I_PROTECTION, EPL_STR, "Protection: %s",
+ X25I_CALLINGDTE, EPL_STR, "Calling DTE address: %s",
+ X25I_RPOA, EPL_LIST, "Specify how call is to be routed: %s",
+ X25I_THRUCLSIN, EPL_INT, "Maximum incoming data rate for VC: %d",
+ X25I_THRUCLSOUT, EPL_INT, "Maximum outgoing data rate for VC: %d",
+ X25I_TRANSITDELAY, EPL_INT, "Actual transit delay for our call: %d",
+ X25I_USERDATA, EPL_STR, "User data: %s",
+ X25I_WINSIZEIN, EPL_INT, "Window size for incoming call: %d",
+ X25I_WINSIZEOUT, EPL_INT, "Window size for outgoing call: %d",
+ X25I_DTECLASS, EPL_STR, "DTE class name: %s",
+ X25I_TEMPLATE, EPL_STR, "Template for XSO_ACCEPTCALL: %s",
+ X25I_BUFFPREALLOC, EPL_BOOL, "Buffer pre-allocation by gateway: %s",
+ X25I_CALLEDDTE, EPL_STR, "Requested DTE address: %s",
+ X25I_LOCALDTE, EPL_STR, "DTE receiving incoming call: %s",
+ X25I_REDIRECTREASON, EPL_INT, "Reason for call redirection: %d",
+ 0, 0, 0,
+};
+
+print_x25_facilities (fd, coc, caption)
+int fd;
+int coc;
+char *caption;
+{
+ int numitems,stat,baud,i,j;
+ char cbuf[128];
+ int cbl = sizeof(cbuf);
+ char *cptr = cbuf;
+ short lbuf[128];
+ int lbl;
+
+ DLOG (compat_log, LLOG_DEBUG, ("%s X.25 Facilities:", caption));
+
+ lbl = sizeof(lbuf);
+ if ((numitems = X25GetItemList(enc_buf, enc_buf_len, lbuf, &lbl)) < 0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Getting Returned Facilities List"));
+ }
+ for (i=0;i < numitems; i++) {
+ cbl = sizeof(cbuf);
+ if ((stat = X25Decode(enc_buf, enc_buf_len,
+ lbuf[i], cbuf, &cbl)) < 0) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, "failed",
+ ("Getting Facility [%d] = X25I_%d", i, lbuf[i]));
+ }
+ if (stat > 0) {
+ char *tptr;
+ for(j=0; epl_tab[j].code != 0 && epl_tab[j].code != lbuf[i]; j++);
+ if (epl_tab[j].code == 0)
+ DLOG (compat_log, LLOG_DEBUG, ("unknown facility %d", lbuf[i]));
+ else {
+ switch (epl_tab[j].type) {
+ case EPL_STR:
+ tptr = epl_prtstr((epl_tab[j].fmt), cptr, cbl);
+ DLOG (compat_log, LLOG_DEBUG, ("%s", tptr));
+ break;
+ case EPL_BOOL:
+ tptr = epl_prtbool((epl_tab[j].fmt), (short *)cptr, cbl);
+ DLOG (compat_log, LLOG_DEBUG, ("%s", tptr));
+ break;
+ case EPL_INT:
+ tptr = epl_prtint((epl_tab[j].fmt), (short *)cptr, cbl);
+ DLOG (compat_log, LLOG_DEBUG, ("%s", tptr));
+ break;
+ case EPL_LIST:
+ tptr = epl_prtlst((epl_tab[j].fmt), (short *)cptr, cbl);
+ DLOG (compat_log, LLOG_DEBUG, ("%s", tptr));
+ break;
+ default:
+ DLOG (compat_log, LLOG_DEBUG,
+ ("unknown type of EPL %d", epl_tab[j].code));
+ break;
+ }
+ }
+ }
+ }
+ return OK;
+}
+#endif
+#else /* ULTRIX_X25 */
+int _ultrix25_stub2 () {;}
+#endif /* ULTRIX_X25 */
+#else /* X25 */
+int _ultrix25_stub () {;}
+#endif /* X25 */
diff --git a/src/isode/compat/version.major b/src/isode/compat/version.major
new file mode 100644
index 000000000..7f8f011eb
--- /dev/null
+++ b/src/isode/compat/version.major
@@ -0,0 +1 @@
+7
diff --git a/src/isode/compat/version.minor b/src/isode/compat/version.minor
new file mode 100644
index 000000000..573541ac9
--- /dev/null
+++ b/src/isode/compat/version.minor
@@ -0,0 +1 @@
+0
diff --git a/src/isode/compat/x25addr.c b/src/isode/compat/x25addr.c
new file mode 100644
index 000000000..bb10a7177
--- /dev/null
+++ b/src/isode/compat/x25addr.c
@@ -0,0 +1,1476 @@
+/* x25addr.c - X.25 level generic <-> interface address munging */
+
+#ifndef lint
+static char *rcsid = "$Header$";
+#endif
+
+/*
+ * $Header$
+ *
+ * Contributed by George Michaelson, Julian Onions, and John Pavel
+ *
+ *
+ * $Log$
+ * Revision 1.1 1994/06/10 03:28:53 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 94/06/10 03:17:16 eichin
+ * autoconfed isode for kerberos work
+ *
+ * Revision 1.1 1994/05/31 20:35:13 eichin
+ * reduced-isode release from /mit/isode/isode-subset/src
+ *
+ * Revision 8.0 91/07/17 12:18:24 isode
+ * Release 7.0
+ *
+ *
+ */
+
+/*
+ * NOTICE
+ *
+ * Acquisition, use, and distribution of this module and related
+ * materials are subject to the restrictions of a license agreement.
+ * Consult the Preface in the User's Manual for the full terms of
+ * this agreement.
+ *
+ */
+
+
+/* LINTLIBRARY */
+
+/*
+ * for *really* generic address translation
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include "general.h"
+#include "manifest.h"
+
+#ifdef X25
+#include "tailor.h"
+#include "tpkt.h"
+#include "sys.file.h"
+#include "x25.h"
+
+#ifndef DEBUG
+#define DEBUG
+#endif
+
+/* */
+
+static int char2bcd ();
+static int bcd2char ();
+
+/*
+ * convert from the generic X25 structure to interface specific
+ */
+/* ARGSUSED */
+CONN_DB *gen2if (generic, specific, context)
+struct NSAPaddr *generic;
+CONN_DB *specific;
+int context;
+{
+ int dtelen;
+ char dte[NSAP_DTELEN + 1];
+#ifdef CAMTEC_CCL
+ struct iovec *iov;
+#endif
+
+ if (generic == NULLNA
+ || specific == (CONN_DB *) 0)
+ return (CONN_DB *)0;
+ if (generic -> na_stack != NA_X25) {
+#ifdef SUN_X25 /* really NSAP specific */
+#ifdef AEF_NSAP
+ /* for suns, with sunnet 7.0 or >,
+ * if this a real NSAP, we have a NULL X121
+ * and let the routing tables do the business
+ */
+
+ if (generic -> na_stack == NA_NSAP) {
+ bzero ((char *)specific, sizeof *specific);
+ return specific;
+ }
+#endif
+#endif
+ return (CONN_DB *)0;
+ }
+
+ if (x25_dnic_prefix && *x25_dnic_prefix) {
+ /* need DNIC on local calls? */
+ register int i;
+
+ if ( strncmp(generic -> na_dte, x25_dnic_prefix,
+ i = strlen(x25_dnic_prefix)) == 0 )
+ {
+ if (x25_strip_dnic) bcopy(generic -> na_dte + i, dte, dtelen =
+ generic -> na_dtelen - i);
+ else bcopy (generic -> na_dte, dte, dtelen = generic -> na_dtelen);
+ }
+ else
+ if (x25_intl_zero)
+ {
+ bcopy(generic -> na_dte, dte + 1, dtelen = generic-> na_dtelen);
+ *dte = '0', dtelen++;
+ }
+ else bcopy(generic -> na_dte, dte, dtelen = generic -> na_dtelen);
+
+ }
+ else bcopy (generic -> na_dte, dte, dtelen = generic -> na_dtelen);
+ dte[dtelen] = NULL;
+
+#ifdef SUN_X25_HACK
+ /*
+ * If your X.25 provider expects to receive the subaddress alone
+ * on listen requests, and you are using SunLink X.25, you may need
+ * to enable SUN_X25_HACK in your config file. This will allow you
+ * to use x25_local_dte in isotailor to specify a dte mask to be
+ * stripped when listening, and thus use full DTE strings in
+ * isoentities and QUIPU EDB files. You will also have to use the
+ * tsapd -a <dte> option to specify the listen address in
+ * /etc/rc.local and other tsapd startups since by default this equals
+ * x25_local_dte and thus will be masked to <null> unless overridden
+ * with full DTE + subaddress.
+ */
+
+ /*
+ * in ADDR_LISTEN context, it may be neccessary to only listen
+ * on the sub-address, because certain PTT-provided networks
+ * remove the local DTE from incoming CR packets.
+ *
+ * SunLink X.25 listen asserts whatever DTE it is given as a simple
+ * string-compare, and will never receive inbound calls that bear
+ * only the sub-address if you assert the full DTE.
+ *
+ * this behaviour is orthogonal to any requirements to remove DNIC
+ * or add a leading 0 on outbound calls, and so needs a separate
+ * test. It uses tailor variable x25_local_dte to assert the local
+ * DTE *without* subaddress which should be tested for and stripped
+ * when detected.
+ */
+
+ if ((context == ADDR_LISTEN) && x25_local_dte && *x25_local_dte)
+ {
+ register int i;
+
+ if ( strncmp(generic -> na_dte, x25_local_dte,
+ i = strlen(x25_local_dte)) == 0 )
+ {
+ bcopy(generic -> na_dte + i, dte, dtelen =
+ generic -> na_dtelen - i);
+ dte[dtelen] = NULL;
+ }
+ }
+#endif
+
+ DLOG (x25_log, LLOG_DEBUG,
+ ("gen2if %s -> %s, %d octets; PID %s",
+ generic -> na_dte, dte, dtelen,
+ sel2str (generic -> na_pid, (int) generic -> na_pidlen,1)));
+
+
+#if !defined(CAMTEC_CCL) && !defined(HPUX_X25)
+ bzero ((char *)specific, sizeof *specific);
+#endif
+
+#ifdef UBC_X25
+ if ((specific -> xaddr_len = dtelen) != 0) {
+ bcopy (dte, specific -> xaddr_addr,
+ dtelen);
+ specific -> xaddr_len = dtelen;
+ specific -> xaddr_facilities = 0;
+ bcopy (generic -> na_pid, specific -> xaddr_proto,
+ generic -> na_pidlen);
+ bcopy (generic -> na_cudf, specific -> xaddr_userdata,
+ generic -> na_cudflen);
+ }
+#endif
+
+#ifdef HPUX_X25
+ if ((dtelen != 1) || (dte [0] != '0'))
+ bcopy (dte, specific -> addr.x25_host,
+ specific -> addr.x25hostlen = dtelen);
+
+ /* Zero PID */
+ if (generic -> na_pidlen) { /* non-null PID */
+ if (generic -> na_pidlen > NPSIZE) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("PID too long (%d > %d)", generic -> na_pidlen, NPSIZE));
+ return (CONN_DB *)0;
+ } else {
+ bzero((char *)specific -> addr.x25pid, NPSIZE);
+ bcopy (generic -> na_pid, (char *)specific -> addr.x25pid,
+ specific -> addr.x25pidlen = generic -> na_pidlen);
+ bcopy (generic -> na_pid, (char *)specific -> cudf.x25_cu_data,
+ specific -> cudf.x25_cud_len = generic -> na_pidlen);
+ }
+ /* copy in CUDF */
+ if (generic -> na_cudflen) {
+ if (generic -> na_cudflen + specific -> cudf.x25_cud_len > X25_MAX_C
+ U_LEN) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("CALL-USERDATA too long (%d > %d)",
+ generic -> na_cudflen + specific -> cudf.x25_cud_len,
+ X25_MAX_CU_LEN));
+ return (CONN_DB *)0;
+ } else {
+ bcopy (generic -> na_cudf,
+ &specific -> cudf.x25_cu_data [specific -> cudf.x25_cud_len]
+ ,
+ generic -> na_cudflen);
+ specific -> cudf.x25_cud_len += generic -> na_cudflen;
+ }
+ }
+ } else {
+ /* PID ws empty, use first four Byte of cudf */
+ /* CUDF has PID - I hope so */
+ bcopy (generic -> na_cudf, specific -> addr.x25pid,
+ specific -> addr.x25pidlen =
+ (generic -> na_cudflen <= NPSIZE) ?
+ generic -> na_cudflen : NPSIZE);
+ if (generic -> na_cudflen > X25_MAX_CU_LEN) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("CALL-USERDATA too long (%d > %d)",
+ generic -> na_cudflen - NPSIZE, X25_MAX_CU_LEN));
+ return (CONN_DB *)0;
+ } else
+ bcopy (generic -> na_cudf, specific -> cudf.x25_cu_data,
+ specific -> cudf.x25_cud_len = generic -> na_cudflen);
+ }
+
+#endif
+
+#ifdef SUN_X25
+ specific -> hostlen = char2bcd (dte, dtelen, specific -> host);
+
+ /* Zero PID */
+ if (generic -> na_pidlen) { /* non-null PID */
+ if (generic -> na_pidlen > NPSIZE) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("PID too long (%d > %d)", generic -> na_pidlen, NPSIZE));
+ return (CONN_DB *)0;
+ } else {
+ bzero((char *)specific -> data, NPSIZE);
+ bcopy (generic -> na_pid, (char *)specific -> data,
+ generic -> na_pidlen);
+ bcopy (generic -> na_cudf, (char *) specific -> data + NPSIZE,
+ generic -> na_cudflen);
+ specific -> datalen = generic -> na_pidlen + generic -> na_cudflen;
+ }
+ } else { /* Null PID (just copy in CUDF, the first four octets of which
+ will be the PID in any case) */
+ bcopy (generic -> na_cudf, (char *)specific -> data,
+ generic -> na_cudflen);
+ specific -> datalen = generic -> na_cudflen;
+ }
+#endif
+
+#ifdef CAMTEC_CCL
+ switch (context) {
+ case ADDR_REMOTE:
+ iov = &(specific -> ccl_iovec[0]);
+ if (x25_outgoing_port == '#') {
+ char *a, *b;
+ int i;
+
+ iov -> iov_len = dtelen + 4;
+ bzero(iov -> iov_base, iov -> iov_len + 1);
+ a = iov -> iov_base;
+ b = dte;
+ *a++ = '#';
+ *a++ = '[';
+ for (i = 0; i < dtelen; i++) {
+ if (i == 2) *a++ = ':';
+ else if (i == 14) *a++ = ']';
+ *a++ = *b++;
+ }
+ }
+ else {
+ iov -> iov_len = dtelen+1;
+ bcopy(dte, (iov -> iov_base)+1, dtelen);
+ *(iov -> iov_base) = x25_outgoing_port;
+ }
+ break;
+
+ case ADDR_LOCAL:
+ iov = &(specific -> ccl_iovec[0]);
+ strncpy(iov -> iov_base, generic -> na_dte, generic -> na_dtelen);
+ iov -> iov_base[generic -> na_dtelen] = '\0';
+ return (specific);
+
+ case ADDR_LISTEN:
+ iov = &(specific -> ccl_iovec[0]);
+ if (generic -> na_pidlen)
+ { /* listen on a PID */
+ register int i;
+ iov -> iov_base[0] = 'C';
+ bcopy(generic -> na_pid, iov -> iov_base + 1,
+ i = generic -> na_pidlen);
+ iov -> iov_len = i + 1;
+ }
+ else
+ if (generic -> na_dtelen < 6)
+ { /* listen on a subaddress */
+ register int i;
+ iov -> iov_base[0] = 'S';
+ bcopy(generic -> na_dte, iov -> iov_base + 1,
+ i = generic -> na_dtelen);
+ iov -> iov_len = i + 1;
+ }
+ else /* full DTE */
+ bcopy(dte, iov -> iov_base,
+ iov -> iov_len = dtelen);
+ return (specific);
+ }
+ /*
+ * CUDF & PID must be merged. malloc initailly PIDsize space
+ * and bzero it. this may be UK net specific action which
+ * ensures we do NOT fall foul of listeners which use pid
+ * to match as well as "true" cudf & DTE.
+ */
+
+ (iov = &(specific -> ccl_iovec[2])) -> iov_len = 0;
+ if (generic -> na_faclen != 0)
+ bcopy (generic -> na_fac, iov -> iov_base,
+ iov -> iov_len = min( generic -> na_faclen, FACSIZE) );
+ iov++;
+ if ( (iov -> iov_len = generic -> na_pidlen) != 0)
+ bcopy (generic -> na_pid, iov -> iov_base, generic -> na_pidlen);
+
+ /*
+ * if there is any other user data add that in now...
+ * actually cudf is a variable length field so this is
+ * all very suspect.
+ */
+
+ if (generic -> na_cudflen != 0)
+ bcopy(generic -> na_cudf, iov -> iov_base + iov -> iov_len,
+ generic -> na_cudflen), iov -> iov_len += generic -> na_cudflen;
+#endif
+
+#ifdef ULTRIX_X25
+ if (generic -> na_dtelen != 0) {
+ specific -> na_dtelen = specific -> na_pidlen
+ = specific -> na_cudflen = 0;
+ bcopy (generic -> na_dte,
+ specific -> na_dte,
+ specific -> na_dtelen = generic -> na_dtelen);
+ /*
+ * concatenate PID and CUDF into CUDF buffer.
+ */
+ if (generic -> na_pidlen > 0) {
+ bcopy (generic -> na_pid,
+ specific -> na_cudf,
+ specific -> na_cudflen = generic -> na_pidlen);
+ }
+ if (generic -> na_cudflen > 0) {
+ bcopy (generic -> na_cudf,
+ specific -> na_cudf + specific -> na_pidlen,
+ generic -> na_cudflen);
+ specific -> na_cudflen += generic -> na_cudflen;
+ }
+ }
+#endif /* ULTRIX_X25 */
+ return(specific);
+}
+
+/* */
+
+/*
+ * convert from interface specific format to generic X.25 structure
+ */
+/* ARGSUSED */
+struct NSAPaddr *if2gen (generic, specific, context)
+struct NSAPaddr *generic;
+CONN_DB *specific;
+int context;
+{
+ int dtelen;
+ char dte[NSAP_DTELEN + 1];
+#ifdef CAMTEC_CCL
+ struct iovec *iov;
+#endif
+
+ if (generic == NULLNA || specific == (CONN_DB *) 0)
+ return NULLNA;
+ bzero ((char *)generic, sizeof *generic);
+ bzero (dte, sizeof dte);
+ dtelen = 0;
+
+ generic -> na_stack = NA_X25;
+ generic -> na_community = ts_comm_x25_default;
+
+#ifdef UBC_X25
+ if (specific -> xaddr_len != 0) {
+ bcopy (specific -> xaddr_addr, dte, specific -> xaddr_len);
+ dtelen = specific -> xaddr_len;
+ bcopy (specific -> xaddr_proto, generic -> na_pid,
+ sizeof(specific -> xaddr_proto));
+ generic -> na_pidlen = sizeof specific -> xaddr_proto;
+ bcopy (specific -> xaddr_userdata, generic -> na_cudf,
+ sizeof(specific -> xaddr_userdata));
+ generic -> na_cudflen = sizeof specific -> xaddr_userdata;
+ }
+#endif
+
+#ifdef SUN_X25
+ dtelen = bcd2char (specific -> host, dte, (int) specific -> hostlen);
+
+ if (specific -> datalen > NPSIZE) { /* have some real user data after the PID */
+ bcopy((char *)specific -> data, generic -> na_pid,
+ generic -> na_pidlen = NPSIZE);
+ bcopy((char *) specific -> data + generic -> na_pidlen,
+ generic -> na_cudf,
+ generic -> na_cudflen = specific -> datalen - generic -> na_pidlen);
+ }
+ else { /* PID only */
+ bcopy((char *)specific -> data, generic -> na_pid,
+ generic -> na_pidlen = specific -> datalen);
+ generic -> na_cudflen = 0;
+ }
+
+#endif
+
+#ifdef HPUX_X25
+ if (specific -> addr.x25hostlen)
+ bcopy (specific -> addr.x25_host, dte,
+ dtelen = specific -> addr.x25hostlen);
+ else {
+ dte [0] = '0';
+ dte [1] = NULL;
+ dtelen = 1;
+ }
+
+ if (specific -> addr.x25pidlen > NPSIZE) {
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("PID too long (%d > %d)", specific -> addr.x25pidlen, NPSIZE));
+ specific -> addr.x25pidlen = NPSIZE;
+ }
+ bcopy((char *)specific -> addr.x25pid, generic -> na_pid,
+ generic -> na_pidlen = specific -> addr.x25pidlen);
+
+ if (specific -> cudf.x25_cud_len) {
+ bcopy (specific -> cudf.x25_cu_data, generic -> na_cudf,
+ generic -> na_cudflen = specific -> cudf.x25_cud_len);
+ }
+#endif
+
+
+#ifdef CAMTEC_CCL
+ switch (context) {
+ case ADDR_REMOTE:
+
+ iov = &(specific -> ccl_iovec[1]);
+ if (iov -> iov_len) {
+ if (*(iov->iov_base) == '#') {
+ char *a;
+
+ a = iov -> iov_base;
+ while (*a && iov -> iov_len) {
+ if (*a == ']') {
+ iov -> iov_len--;
+ a++;
+ break;
+ }
+ iov -> iov_len--;
+ a++;
+ }
+ if (*a == 0 || iov -> iov_len == 0)
+ dtelen = 0;
+ else {
+ dtelen = iov -> iov_len;
+ bcopy (a, dte, dtelen);
+ }
+ }
+ else {
+ dtelen = iov -> iov_len - 1;
+ bcopy ((iov -> iov_base)+1, dte,
+ dtelen);
+ }
+ }
+ else dtelen = 0;
+ break;
+
+ case ADDR_LOCAL:
+ iov = &(specific -> ccl_iovec[0]);
+ if (iov -> iov_len) {
+ dtelen = iov -> iov_len -1;
+ bcopy ((iov -> iov_base)+1, dte,
+ dtelen);
+ }
+ else dtelen = 0;
+ break;
+
+ case ADDR_LISTEN:
+ return NULLNA;
+ }
+
+ if ( (iov = &(specific -> ccl_iovec[2])) -> iov_len )
+ bcopy( iov -> iov_base, generic -> na_fac,
+ generic -> na_faclen = min( iov -> iov_len, FACSIZE));
+
+ if ( ++iov -> iov_len)
+ {
+ bcopy( iov -> iov_base, generic -> na_pid,
+ generic -> na_pidlen = min( iov -> iov_len, NPSIZE));
+ if ( iov -> iov_len > NPSIZE)
+ bcopy( iov -> iov_base + NPSIZE, generic -> na_cudf,
+ generic -> na_cudflen = min(iov -> iov_len - NPSIZE, CUDFSIZE));
+ }
+#endif
+
+#ifdef ULTRIX_X25
+ if (specific -> na_dtelen > 0) {
+ bcopy (specific -> na_dte, dte, specific -> na_dtelen);
+ dtelen = specific -> na_dtelen;
+
+ /*
+ * if CUDF non-zero, copy up to first NPSIZE (or cufdlen if less)
+ * bytes into pid field and shift remainder down.
+ */
+ if (specific -> na_cudflen > 0) {
+ bcopy(specific -> na_cudf,
+ generic -> na_pid,
+ generic -> na_pidlen = (specific -> na_cudflen <= NPSIZE ?
+ specific -> na_cudflen : NPSIZE));
+ if (specific -> na_cudflen > NPSIZE) {
+ bcopy(specific -> na_cudf + NPSIZE,
+ generic -> na_cudf,
+ generic -> na_cudflen = specific -> na_cudflen - NPSIZE);
+ }
+ } else {
+ generic -> na_pidlen = 0;
+ generic -> na_pid[0] = 0;
+ generic -> na_cudflen = 0;
+ generic -> na_cudf[0] = 0;
+ }
+ }
+#endif /* ULTRIX_X25 */
+
+ if (x25_dnic_prefix && *x25_dnic_prefix) {
+ register int i;
+
+ i = 0;
+ if (x25_intl_zero && dte[0] == '0' && dte[1] != '0')
+ i = 1;
+ else
+ if (x25_dnic_prefix
+ && *x25_dnic_prefix
+ && x25_strip_dnic
+ && dtelen < 12) /* local call... */
+ bcopy (x25_dnic_prefix, generic -> na_dte,
+ generic -> na_dtelen = strlen (x25_dnic_prefix));
+
+ bcopy (dte + i, generic -> na_dte + generic -> na_dtelen, dtelen - i);
+ generic -> na_dtelen += dtelen - i;
+ }
+ else
+ bcopy (dte, generic -> na_dte, generic -> na_dtelen = dtelen);
+
+ DLOG (x25_log, LLOG_DEBUG,
+ ("if2gen %s -> %s, %d octets; PID %s",
+ dte, generic -> na_dte, generic -> na_dtelen,
+ sel2str (generic -> na_pid, (int) generic -> na_pidlen,1)));
+
+ return(generic);
+}
+
+/* */
+
+elucidate_x25_err (flags, pkt)
+int flags;
+unsigned char * pkt;
+{
+ char * cp;
+
+ if (flags & (1 << RECV_DIAG)) {
+#ifdef HPUX_X25
+ if (flags & (1 << DIAG_TYPE)) /* cleared */
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("cleared 0x%02x", pkt[0] ));
+ else if (flags & (1 << REST_TYPE))
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("restart 0x%02x", pkt[0] ));
+ else
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("reset 0x%02x", pkt[0] ));
+
+#else
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ (( flags & (1 << DIAG_TYPE) ) ?
+ "cleared 0x%02x" : "reset 0x%02x",
+ pkt[0] ));
+#endif
+
+ if ((flags) & (1 << DIAG_TYPE)) /* cleared */
+ switch(pkt[0]) {
+ case 0x00:
+ cp = "DTE Clearing";
+ break;
+
+ case 0x01:
+ cp = "Number Busy";
+ break;
+
+ case 0x09:
+ cp = "Out of Order";
+ break;
+
+ case 0x11:
+ cp = "Remote Procedure Error";
+ break;
+
+ case 0x19:
+ cp = "Reverse Charging not subscribed";
+ break;
+
+ case 0x03:
+ cp = "Invalid Facility Request";
+ break;
+
+ case 0x0B:
+ cp = "Access Barred";
+ break;
+
+ case 0x13:
+ cp = "Local Procedure Error";
+ break;
+
+ case 0x05:
+ cp = "Network Congestion";
+ break;
+
+ case 0x0D:
+ cp = "Not Obtainable";
+ break;
+
+ case 0x21:
+ cp = "DTE Incompatible Call";
+ break;
+
+ case 0x29:
+ cp = "Fast Select Acceptance not Subscribed";
+ break;
+
+ default:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("clearing cause 0x2%x", pkt[0]));
+ goto next;
+ }
+#ifdef HPUX_X25
+ else if ((flags) & (1 << REST_TYPE))
+ switch((unsigned char)(pkt[0] & 0x7f)) {
+ case 0x01:
+ cp = "Local Procedure Error";
+ break;
+
+ case 0x03:
+ cp = "Network Congestion";
+ break;
+
+ case 0x07:
+ cp = "Network Operational";
+ break;
+
+ case 0x7f:
+ cp = "Registration/Cancellation Confirmed";
+ break;
+
+ default:
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("restarting cause 0x2%x", pkt[0]));
+ goto next;
+ }
+#endif
+ else /* reset */
+ switch(pkt[0]) {
+ case 0x00:
+ cp = "DTE Reset";
+ break;
+
+ case 0x01:
+ cp = "Out of Order (PVC Only)";
+ break;
+
+ case 0x03:
+ cp = "Remote Procedure Error";
+ break;
+
+ case 0x05:
+ cp = "Local Procedure Error";
+ break;
+
+ case 0x07:
+ cp = "Network Congestion";
+ break;
+
+ case 0x09:
+ cp = "Remote DTE Operational (PVC Only)";
+ break;
+
+ case 0x0F:
+ cp = "Network Operational (PVC Only";
+ break;
+
+ default:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("resetting cause 0x%2x", pkt[0]));
+ goto next;
+
+ }
+#ifdef HPUX_X25
+ if (flags & (1 << DIAG_TYPE)) /* cleared */
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%sclearing cause: %s (%d)",
+ (pkt[0] & 0x80) ? "Remote DTE " : "", cp, pkt [0]));
+ else if (flags & (1 << REST_TYPE))
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%srestarting cause: %s (%d)",
+ (pkt[0] & 0x80) ? "Remote DTE " : "", cp, pkt [0]));
+ else
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("%sresetting cause: %s (%d)",
+ (pkt[0] & 0x80) ? "Remote DTE " : "", cp, pkt [0]));
+#else
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP, ("%s%s",
+ ( flags & (1 << DIAG_TYPE) ) ? "clearing cause " :
+ "resetting cause ", cp));
+
+#endif
+
+next: ;
+ /* The following may only be applicable to PSS in the UK */
+ /* In any case, if someone is keen, they can stuff it all
+ into a text file and read it out */
+
+ switch (pkt[1]) {
+ case 0x00:
+ cp = "NO ADDITIONAL INFORMATION";
+ break;
+
+ case 0x01:
+ cp = "INVALID P(S)\tRESET";
+ break;
+
+ case 0x02:
+ cp = "INVALID P(R)\tRESET";
+ break;
+
+ case 0x11:
+ cp = "PACKET TYPE INVALID FOR STATE r1\tRESTART";
+ break;
+
+ case 0x12:
+ cp = "PACKET TYPE INVALID FOR STATE r2\tRESTART";
+ break;
+
+ case 0x13:
+ cp = "PACKET TYPE INVALID FOR STATE r3\tRESTART";
+ break;
+
+ case 0x14:
+ cp = "PACKET TYPE INVALID FOR STATE p1\tCLEAR";
+ break;
+
+ case 0x15:
+ cp = "PACKET TYPE INVALID FOR STATE p2\tCLEAR";
+ break;
+
+ case 0x16:
+ cp = "PACKET TYPE INVALID FOR STATE p3\tCLEAR";
+ break;
+
+ case 0x17:
+ cp = "PACKET TYPE INVALID FOR STATE p4\tCLEAR";
+ break;
+
+ case 0x18:
+ cp = "PACKET TYPE INVALID FOR STATE p5\tRESET";
+ break;
+
+ case 0x19:
+ cp = "PACKET TYPE INVALID FOR STATE p6\tCLEAR";
+ break;
+
+ case 0x1A:
+ cp = "PACKET TYPE INVALID FOR STATE p7\tCLEAR";
+ break;
+
+ case 0x1B:
+ cp = "PACKET TYPE INVALID FOR STATE d1\tRESET";
+ break;
+
+ case 0x1C:
+ cp = "PACKET TYPE INVALID FOR STATE d2\tRESET";
+ break;
+
+ case 0x1D:
+ cp = "PACKET TYPE INVALID FOR STATE d3\tRESET";
+ break;
+
+ case 0x20:
+ cp = "PACKET NOT ALLOWED";
+ break;
+
+ case 0x21:
+ cp = "UNIDENTIFIABLE PACKET";
+ break;
+
+ case 0x22:
+ cp = "CALL ON ONE-WAY LOGICAL CHANNEL\tCLEAR";
+ break;
+
+ case 0x23:
+ cp = "INVALID PACKET TYPE ON PVC\tRESET";
+ break;
+
+ case 0x24:
+ cp = "PACKET ON UNASSIGNED LCN\tCLEAR";
+ break;
+
+ case 0x25:
+ cp = "REJECT NOT SUBSCRIBED TO\tRESET";
+ break;
+
+ case 0x26:
+ cp = "PACKET TOO SHORT\tRESET";
+ break;
+
+ case 0x27:
+ cp = "PACKET TOO LONG\tRESET";
+ break;
+
+ case 0x28:
+ cp = "INVALID GFI\tCLEAR";
+ break;
+
+ case 0x29:
+ cp = "RESTART WITH NON-ZERO BITS 5-16";
+ break;
+
+ case 0x2A:
+ cp = "PACKET TYPE NOT COMPATIBLE WITH FACILITY\tCLEAR";
+ break;
+
+ case 0x2B:
+ cp = "UNAUTHORISED INTERRUPT CONF\tRESET";
+ break;
+
+ case 0x2C:
+ cp = "UNAUTHORISED INTERRUPT\tRESET";
+ break;
+
+ case 0x31:
+ cp = "TIMER EXPIRED; INCOMING CALL";
+ break;
+
+ case 0x32:
+ cp = "TIMER EXPIRED;\tCLEAR INDICATION";
+ break;
+
+ case 0x33:
+ cp = "TIMER EXPIRED;\tRESET INDICATION";
+ break;
+
+ case 0x34:
+ cp = "TIMER EXPIRED;\tRESTART IND";
+ break;
+
+ case 0x40:
+ cp = "UNSPECIFIED CALL SET-UP PROBLEM CLEAR";
+ break;
+
+ case 0x41:
+ cp = "FACILITY CODE NOT ALLOWED\tCLEAR";
+ break;
+
+ case 0x42:
+ cp = "FACILITY PARAMETER NOT ALLOWED\tCLEAR";
+ break;
+
+ case 0x43:
+ cp = "INVALID CALLED ADDRESS\tCLEAR";
+ break;
+
+ case 0x44:
+ cp = "INVALID CALLING ADDRESS\tCLEAR";
+ break;
+
+ case 0x90:
+ cp = "DTE/DCE CONGESTION\tRESET";
+ break;
+
+ case 0x91:
+ cp = "RECEIVED FAST SELECT CLEAR REQUEST";
+ break;
+
+ case 0x92:
+ cp = "LINE RESTARTING BY INMC COMMAND\tRESTART";
+ break;
+
+ case 0xA0:
+#ifdef HPUX_X25
+ cp = "REVERSE CHARGE REQUESTED WHEN NOT ALLOWED - RESET";
+ #else
+ cp = "NON-ZERO RESET CAUSE FROM DTE\tRESET";
+#endif
+ break;
+
+ case 0xA1:
+#ifdef HPUX_X25
+ cp = "LEVEL 2 IS COMING UP - RESET";
+#else
+ cp = "DATA PACKET TOO LONG\tRESET";
+#endif
+ break;
+
+ case 0xA2:
+#ifdef HPUX_X25
+ cp = "LEVEL 2 OR 3 IS DOWN - RESET";
+#else
+ cp = "INTERRUPT PACKET TOO LONG\tRESET";
+#endif
+ break;
+
+ case 0xA3:
+#ifdef HPUX_X25
+ cp = "LACK OF MEMORY - RESET";
+#else
+ cp = "INT PACKET TOO SHORT; NO USER DATA\tRESET";
+#endif
+ break;
+
+ case 0xA4:
+#ifdef HPUX_X25
+ cp = "FAST SELECT NOT SUBSCRIBED - CLEAR";
+#else
+ cp = "INT CONFIRMATION PACKET TOO LONG\tRESET";
+#endif
+ break;
+
+ case 0xA5:
+ cp = "RR PACKET TOO LONG\tRESET";
+ break;
+
+ case 0xA6:
+ cp = "RNR PACKET TOO LONG\tRESET";
+ break;
+
+ case 0xA7:
+ cp = "RESET PACKET TOO LONG\tRESET";
+ break;
+
+ case 0xA8:
+ cp = "RESET CONF PACKET TOO LONG\tRESET";
+ break;
+
+ case 0xA9:
+ cp = "INVALID `Q' BIT IN DATA PACKET\tRESET";
+ break;
+
+ case 0xAA:
+ cp = "PACKET WINDOW RANGE EXCEEDED\tRESET";
+ break;
+
+ case 0xAB:
+ cp = "UNABLE TO TRANSMIT PACKET\tRESET";
+ break;
+
+ case 0xAC:
+ cp = "diagnostic `Q' BIT SET IN NON-DATA PACKET\tRESET";
+ break;
+
+ case 0xAD:
+ cp = "OUTSTANDING PACKET COUNT LESS THAN ZERO\tRESET";
+ break;
+
+ case 0xAE:
+ cp = "RETRANSMISSION ERROR\tRESET";
+ break;
+
+ case 0xAF:
+ cp = "RESET PACKET TOO SHORT (NO CAUSE)\tRESET";
+ break;
+
+ case 0xB0:
+ cp = "REJECT PACKET TOO LONG\tRESET";
+ break;
+
+ case 0xB1:
+ cp = "INVALID 1D PACKET\tRESET";
+ break;
+
+ case 0xB2:
+ cp = "UNSUCCESSFUL RECONNECTION RESNC\tCLEAR";
+ break;
+
+ case 0xB3:
+ cp = "NON-RECONNECT CALL IN STATE C1\tCLEAR";
+ break;
+
+ case 0xB4:
+ cp = "SECOND 1D PACKET FROM DTE\tCLEAR";
+ break;
+
+ case 0xB5:
+ cp = "BAD DATA TRANSFER STATE IN RECONNECT\tCLEAR";
+ break;
+
+ case 0xB6:
+ cp = "PACKET FORMAT INVALID\tCLEAR";
+ break;
+
+ case 0xB7:
+ cp = "FACILITY BYTE COUNT TOO LARGE\tCLEAR";
+ break;
+
+ case 0xB8:
+ cp = "INVALID PACKET DETECTED\tCLEAR";
+ break;
+
+ case 0xB9:
+ cp = "FACILITY/UTILITY FIELD BYTE COUNT > 63\tCLEAR";
+ break;
+
+ case 0xBA:
+ cp = "OUTGOING CALLS BARRED\tCLEAR";
+ break;
+
+ case 0xBB:
+ cp = "INCOMING CALLS BARRED\tCLEAR";
+ break;
+
+ case 0xBC:
+ cp = "CLEARING OF PVC\tCLEAR";
+ break;
+
+ case 0xBD:
+ cp = "CALLED ADDRESS TOO LONG\tCLEAR";
+ break;
+
+ case 0xBE:
+ cp = "CALLED ADDRESS TOO SHORT\tCLEAR";
+ break;
+
+ case 0xBF:
+ cp = "CALLING ADDRESS TOO LONG\tCLEAR";
+ break;
+
+ case 0xC0:
+ cp = "CALLING ADDRESS TOO SHORT\tCLEAR";
+ break;
+
+ case 0xC1:
+ cp = "BCD ERROR IN CALL ADDRESS\tCLEAR";
+ break;
+
+ case 0xC2:
+ cp = "BCD ERROR IN CALLING ADDRESS\tCLEAR";
+ break;
+
+ case 0xC3:
+ cp = "USER DATA FIELD TOO LONG\tCLEAR";
+ break;
+
+ case 0xC4:
+ cp = "NO BUFFER AVAILABLE\tCLEAR";
+ break;
+
+ case 0xC5:
+ cp = "LOCAL DTE IS NOT ENHANCED\tCLEAR";
+ break;
+
+ case 0xC6:
+ cp = "FACILITY NEGOTIATION INVALID\tCLEAR";
+ break;
+
+ case 0xC7:
+ cp = "MANDATORY UTILITY NOT INPUT\tCLEAR";
+ break;
+
+ case 0xC8:
+ cp = "BUFFER NO AVAILABLE FOR TNIC\tCLEAR";
+ break;
+
+ case 0xC9:
+ cp = "OVERFLOW OF TNIC IN BUFFER\tCLEAR";
+ break;
+
+ case 0xCA:
+ cp = "DTE LINE CONGESTED\tCLEAR";
+ break;
+
+ case 0xCB:
+ cp = "TABLE ERROR IN PACKET PROCEDURES";
+ break;
+
+ case 0xCC:
+ cp = "INSERT TABLE OVERFLOW";
+ break;
+
+ case 0xCD:
+ cp = "DELETE TABLE OVERFLOW";
+ break;
+
+ case 0xD0:
+ cp = "TRUNK LINE RESTART\tRESTART";
+ break;
+
+ case 0xD1:
+ cp = "INVALID EVENT IN STATE p2";
+ break;
+
+ case 0xD2:
+ cp = "INVALID EVENT IN STATE p3";
+ break;
+
+ case 0xD3:
+ cp = "INVALID 1D EVENT IN STATE d1";
+ break;
+
+ case 0xD4:
+ cp = "CALL COLLISION ON TRUNK LINE";
+ break;
+
+ case 0xD5:
+ cp = "NO BUFFER AVAILABLE";
+ break;
+
+ case 0xD6:
+
+ cp = "CALL COLLISION ON DTE LINE";
+ break;
+
+ case 0xD7:
+ cp = "DTE RESTART";
+ break;
+
+ case 0xD8:
+ cp = "CALL REQUEST TO TRUNK LINE TIMEOUT";
+ break;
+
+ case 0xD9:
+ cp = "RECONNECT SET-UP TIMED OUT";
+ break;
+
+ case 0xDA:
+ cp = "INVALID OUTPUT SIDE STATE";
+ break;
+
+ case 0xDB:
+ cp = "ERROR DETECTED IN BLINK PACKET QUEUE PROCEDURE";
+ break;
+
+ case 0xDC:
+ cp = "RESET INDICATION RETRANSMISSION COUNT EXPIRED";
+ break;
+
+ case 0xDD:
+ cp = "INVALID OUTPUT SIDE STATE";
+ break;
+
+ case 0xDE:
+ cp = "BLIND BUFFER QUEUE OVERFLOW IN STATE d4";
+ break;
+
+ case 0xDF:
+ cp = "BLIND BUFFER QUEUE OVERFLOW IN STATE c1";
+ break;
+
+ case 0xE0:
+ cp = "BLIND BUFFER QUEUE OVERFLOW IN STATE c2";
+ break;
+
+ case 0xE1:
+#ifdef HPUX_X25
+ cp = "DISCONNECTION (TRANSIENT CONDITION) - CLEAR";
+#else
+ cp = "CLEAR PACKET BYTE COUNT TOO LARGE OR TOO SMALL";
+#endif
+ break;
+
+ case 0xE2:
+#ifdef HPUX_X25
+ cp = "CONNECTION REJECTION (TRANSIENT CONDITION) - CLEAR";
+#else
+ cp = "NON-ZERO\tCLEAR CAUSE";
+#endif
+ break;
+
+ case 0xE3:
+ cp = "CLEAR CONF PACKET BYTE COUNT TOO SMALL OR TOO LARGE";
+ break;
+
+ case 0xE4:
+#ifdef HPUX_X25
+ cp = "CONNECTION REJECTION (REASON UNSPECIFIED) - CLEAR";
+#else
+ cp = "CALL COLLISION";
+#endif
+ break;
+
+ case 0xE5:
+ cp = "INVALID TP LOAD REQUEST CALL PKT";
+ break;
+
+ case 0xE6:
+ cp = "MAXIMUM HOPCOUNT EXCEEDED";
+ break;
+
+ case 0xE7:
+#ifdef HPUX_X25
+ cp = "NSAP UNREACHABLE (TRANSIENT CONDITION) - CLEAR";
+#else
+ cp = "ROUTING LOOP DETECTED";
+#endif
+ break;
+
+ case 0xE8:
+#ifdef HPUX_X25
+ cp = "NSAP UNREACHABLE (PERMANENT CONDITION) - CLEAR";
+#else
+ cp = "PVC CALL REQUEST FAILURE";
+#endif
+ break;
+
+ case 0xE9:
+#ifdef HPUX_X25
+ cp = "RESET CAUSE UNSPECIFIED - RESET";
+#else
+ cp = "RECONNECT CALL REQUEST FAILED";
+#endif
+ break;
+
+ case 0xEA:
+ cp = "NO LC AVAILABLE ON OUTPUT SIDE";
+ break;
+
+ case 0xEB:
+ cp = "NO BUFFER AVAILABLE";
+ break;
+
+ case 0xEC:
+ cp = "CALL REDIRECTION CLEAR";
+ break;
+
+ case 0xED:
+ cp = "NO PATH ROUTE CALL";
+ break;
+
+ case 0xEE:
+ cp = "CALL ROUTED TO DTE LINE";
+ break;
+
+ case 0xEF:
+ cp = "CALL CANNOT BE REROUTED";
+ break;
+
+ case 0xF0:
+ cp = "ADDRESS NOT IN ROUTING TABLES";
+ break;
+
+ case 0xF1:
+#ifdef HPUX_X25
+ cp = "NORMAL DISCONNECTION - CLEAR";
+#else
+ cp = "ROUTING TABLE CHANGE DURING CALL ROUTING";
+#endif
+ break;
+
+ case 0xF2:
+#ifdef HPUX_X25
+ cp = "ABNORMAL DISCONNECTION - CLEAR";
+#else
+ cp = "NO LC AVAILABLE ON FAKE TRUNK";
+#endif
+ break;
+
+ case 0xF3:
+ cp = "REMOTE DTE DOWN ON A PVC";
+ break;
+
+ case 0xF4:
+ cp = "INVALID EVENT DETECTED";
+ break;
+
+ case 0xF5:
+ cp = "INVALID PACKET RECEIVED; STATE d4";
+ break;
+
+ case 0xF6:
+ cp = "INVALID PACKET RECEIVED; STATE d5";
+ break;
+
+ case 0xF7:
+ cp = "INVALID PACKET RECEIVED; STATE p8";
+ break;
+
+ case 0xF8:
+ cp = "INTERNAL PROCESSING FAILURE";
+ break;
+
+ case 0xF9:
+ cp = "INVALID RESTART INDICATION";
+ break;
+
+ case 0xFA:
+#ifdef HPUX_X25
+ cp = "USER SYNCHRONISATION - RESET";
+#else
+ cp = "LINE STATUS CHANGE IN STATE r4";
+#endif
+ break;
+
+ case 0xFB:
+ cp = "INVALID PACKET RECEIVED; STATE r4";
+ break;
+
+ case 0xFC:
+ cp = "INVALID PACKET RECEIVED; STATE r3";
+ break;
+
+ case 0xFD:
+ cp = "LINE STATUS CHANGE IN STATE r2";
+ break;
+
+ case 0xFE:
+ cp = "LINE STATUS CHANGE IN STATE r1";
+ break;
+
+ case 0xFF:
+ cp = "LINE STATUS CHANGE IN STATE r0";
+ break;
+
+ default:
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("diagnostic: 0x%2x", pkt[1]));
+ goto done;
+ }
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP, ("diagnostic %s", cp));
+#ifdef HPUX_X25
+ if (flags & (1 << DIAG_TYPE)) /* cleared */
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("clearing source: %s (%d)",
+ pkt [2] ? "X25-Level 2" : "network prov./firmware",
+ pkt [2] ));
+ else if (flags & (1 << REST_TYPE))
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("restart source unknown (%d)", pkt [2] ));
+ else
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("resetting source: %s (%d)",
+ pkt [2] ? "network provider" : "undefined", pkt [2] ));
+#endif
+ }
+ else /* Not RECV_DIAG */
+#ifdef HPUX_X25
+ SLOG (x25_log, LLOG_EXCEPTIONS, NULLCP,
+ ("cause: 0x%02x - diag code: 0x%02x", pkt [0], pkt [1]));
+#else
+ if (flags)
+ SLOG (compat_log, LLOG_EXCEPTIONS, NULLCP,
+ ("diag flags: 0x%02x", flags));
+#endif
+
+done: ;
+ return OK;
+};
+
+/* */
+
+#ifdef SUN_X25
+#ifdef AEF_NSAP
+int nsap2if (nsap, aef)
+struct NSAPaddr *nsap;
+AEF *aef;
+{
+ char buf[NASIZE*2+1];
+ int len;
+
+ if (nsap -> na_stack != NA_NSAP)
+ return NOTOK;
+ aef -> aef_type = AEF_NSAP;
+ len = explode (buf, (u_char *) nsap -> na_address, nsap -> na_addrlen);
+ aef -> aef_len = char2bcd (buf, len, aef -> aef);
+ return OK;
+}
+#endif
+
+static int char2bcd (s, n, d)
+register char *s;
+int n;
+register u_char *d;
+{
+ register int c,
+ i;
+
+ for (i = 0; *s && n-- > 0; i++) {
+ if ((c = *s++) >= 'a' && c <= 'f')
+ c -= 'a' + 0x0a;
+ else
+ if (c >= 'A' && c <= 'F')
+ c -= 'A' + 0x0a;
+ else
+ if (c >= '0' && c <= '9')
+ c -= '0';
+ else
+ c = 0;
+
+ if (i & 1)
+ *d++ |= c & 0xf;
+ else
+ *d = (c & 0xf) << 4;
+ }
+
+ return i;
+}
+
+/* */
+#ifdef AEF_NSAP
+int if2nsap (aef, nsap)
+AEF *aef;
+struct NSAPaddr *nsap;
+{
+ char buf[NASIZE*2+1];
+ int len;
+
+ if (aef -> aef_type != AEF_NSAP)
+ return NOTOK;
+
+ nsap -> na_stack = NA_NSAP;
+ len = bcd2char (aef -> aef, buf, (int)aef -> aef_len);
+ nsap -> na_addrlen = implode ((u_char *) nsap -> na_address, buf, len);
+ return OK;
+}
+#endif
+
+static int bcd2char (s, d, len)
+register u_char *s;
+register char *d;
+int len;
+{
+ register int i,
+ g;
+
+ for (i = 0; i < len; i++) {
+ g = s[i >> 1];
+ if ((i & 1) == 0)
+ g >>= 4;
+ g &= 0xf;
+
+ if (g < 0x0a)
+ *d++ = g + '0';
+ else
+ *d++ = g + 'a' - 0x0a;
+ }
+
+ *d = NULL;
+
+ return len;
+}
+#endif
+#else
+int _x25addr_stub () {}
+#endif