BSD 4_3_Net_2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 22 Feb 1991 02:26:43 +0000 (18:26 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 22 Feb 1991 02:26:43 +0000 (18:26 -0800)
Work on file usr/src/contrib/isode/imisc/Makefile
Work on file usr/src/contrib/isode/imisc/imisc.1c
Work on file usr/src/contrib/isode/imisc/imisc.c
Work on file usr/src/contrib/isode/imisc/imisc.ry
Work on file usr/src/contrib/isode/imisc/imiscd.8c
Work on file usr/src/contrib/isode/imisc/imiscd.c
Work on file usr/src/contrib/isode/imisc/make
Work on file usr/src/contrib/isode/imisc/ryinitiator.c
Work on file usr/src/contrib/isode/imisc/ryinitiator.h
Work on file usr/src/contrib/isode/imisc/ryresponder.c
Work on file usr/src/contrib/isode/imisc/ryresponder.h
Work on file usr/src/contrib/isode/others/Makefile
Work on file usr/src/contrib/isode/others/READ-ME
Work on file usr/src/contrib/isode/others/make
Work on file usr/src/contrib/isode/others/callback/Makefile
Work on file usr/src/contrib/isode/others/callback/READ-ME
Work on file usr/src/contrib/isode/others/callback/callback.h
Work on file usr/src/contrib/isode/others/callback/initiator.c
Work on file usr/src/contrib/isode/others/callback/make
Work on file usr/src/contrib/isode/others/callback/report.c
Work on file usr/src/contrib/isode/others/callback/responder.c

Synthesized-from: CSRG/cd2/net.2

21 files changed:
usr/src/contrib/isode/imisc/Makefile [new file with mode: 0644]
usr/src/contrib/isode/imisc/imisc.1c [new file with mode: 0644]
usr/src/contrib/isode/imisc/imisc.c [new file with mode: 0644]
usr/src/contrib/isode/imisc/imisc.ry [new file with mode: 0644]
usr/src/contrib/isode/imisc/imiscd.8c [new file with mode: 0644]
usr/src/contrib/isode/imisc/imiscd.c [new file with mode: 0644]
usr/src/contrib/isode/imisc/make [new file with mode: 0644]
usr/src/contrib/isode/imisc/ryinitiator.c [new file with mode: 0644]
usr/src/contrib/isode/imisc/ryinitiator.h [new file with mode: 0644]
usr/src/contrib/isode/imisc/ryresponder.c [new file with mode: 0644]
usr/src/contrib/isode/imisc/ryresponder.h [new file with mode: 0644]
usr/src/contrib/isode/others/Makefile [new file with mode: 0644]
usr/src/contrib/isode/others/READ-ME [new file with mode: 0644]
usr/src/contrib/isode/others/callback/Makefile [new file with mode: 0644]
usr/src/contrib/isode/others/callback/READ-ME [new file with mode: 0644]
usr/src/contrib/isode/others/callback/callback.h [new file with mode: 0644]
usr/src/contrib/isode/others/callback/initiator.c [new file with mode: 0644]
usr/src/contrib/isode/others/callback/make [new file with mode: 0644]
usr/src/contrib/isode/others/callback/report.c [new file with mode: 0644]
usr/src/contrib/isode/others/callback/responder.c [new file with mode: 0644]
usr/src/contrib/isode/others/make [new file with mode: 0644]

diff --git a/usr/src/contrib/isode/imisc/Makefile b/usr/src/contrib/isode/imisc/Makefile
new file mode 100644 (file)
index 0000000..93303b8
--- /dev/null
@@ -0,0 +1,180 @@
+###############################################################################
+#   Instructions to Make, for compilation of ROS-based miscellaneous services
+###############################################################################
+
+###############################################################################
+#
+# $Header: /f/osi/imisc/RCS/Makefile,v 7.5 91/02/22 09:26:12 mrose Interim $
+#
+#
+# $Log:        Makefile,v $
+# Revision 7.5  91/02/22  09:26:12  mrose
+# Interim 6.8
+# 
+# Revision 7.4  90/12/23  18:41:53  mrose
+# update
+# 
+# Revision 7.3  90/07/09  14:38:43  mrose
+# sync
+# 
+# Revision 7.2  90/07/01  21:03:59  mrose
+# pepsy
+# 
+# Revision 7.0  89/11/23  21:57:34  mrose
+# Release 6.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.
+#
+###############################################################################
+
+
+PEPYPATH=      -DPEPYPATH
+
+.SUFFIXES:     .ry .py .c .o
+
+.c.o:;         $(CC) $(CFLAGS) -c $*.c
+
+
+LIBES   =      $(TOPDIR)libisode$(LPP).a
+LLIBS   =      $(TOPDIR)llib-lisode$(LPP)
+CFILES =       imiscd.c imisc.c IMISC-ops.c ryinitiator.c ryresponder.c
+RYFILES        =       imisc.ry
+HFILES =       $(HDIR)rosy.h $(HDIR)rosap.h $(HDIR)acsap.h $(HDIR)psap2.h \
+               $(HDIR)psap.h $(HDIR)ssap.h $(HDIR)isoaddrs.h \
+               $(HDIR)manifest.h $(HDIR)general.h $(HDIR)config.h
+
+ROS    =       ros.
+
+
+##################################################################
+# Here it is...
+##################################################################
+
+all:           imiscd imisc
+inst-all:      inst-imiscd inst-imisc manuals
+install:       inst-all clean
+lint:          l-imiscd l-imisc
+
+all-lpp:;      $(MAKE) LPP=-lpp all
+inst-lpp:;     $(MAKE) LPP=-lpp ROS=lpp. inst-all
+install-lpp:;  $(MAKE) LPP=-lpp ROS=lpp. install
+lint-lpp:;     $(MAKE) LPP=-lpp lint
+
+
+##################################################################
+# imiscd
+##################################################################
+
+inst-imiscd:   $(SBINDIR)$(ROS)imisc
+
+$(SBINDIR)$(ROS)imisc: ximiscd$(LPP)
+               -cp $@ z$(ROS)imisc
+               -rm -f $@
+               cp ximiscd$(LPP) $@
+               -@ls -gls $@
+               -@echo ""
+
+imiscd:                ximiscd$(LPP)
+
+ximiscd$(LPP): imiscd.o IMISC-Rops.o ryresponder.o IMISC_tables.o $(LIBES)
+               $(LDCC) $(LDFLAGS) -o $@ imiscd.o IMISC-Rops.o ryresponder.o \
+                       IMISC_tables.o $(LIBES) $(LSOCKET)
+
+l-imiscd:      IMISC-ops.c IMISC_tables.c true
+               $(LINT) $(LFLAGS) -DPERFORMER imiscd.c IMISC-ops.c \
+                       ryresponder.c IMISC_tables.c $(LLIBS) \
+                       | grep -v "warning: possible pointer alignment problem"
+
+imiscd.o:      ryresponder.h IMISC-ops.h IMISC-types.h $(HFILES) \
+                       $(HDIR)logger.h
+
+IMISC-Rops.o:  IMISC-ops.c IMISC-ops.h $(HFILES)
+               $(CC) $(CFLAGS) -DPERFORMER -c IMISC-ops.c
+               mv IMISC-ops.o $@
+
+ryresponder.o: ryresponder.h $(HFILES) $(HDIR)tailor.h
+
+
+##################################################################
+# imisc
+##################################################################
+
+inst-imisc:    $(BINDIR)imisc$(LPP)
+
+$(BINDIR)imisc$(LPP):  ximisc$(LPP)
+               -cp $@ zximisc$(LPP)
+               -rm -f $@
+               cp ximisc$(LPP) $@
+               -@ls -gls $@
+               -@echo ""
+
+imisc:         ximisc$(LPP)
+
+ximisc$(LPP):  imisc.o IMISC-Iops.o ryinitiator.o IMISC_tables.o $(LIBES)
+               $(LDCC) $(LDFLAGS) -o $@ imisc.o IMISC-Iops.o ryinitiator.o \
+                       IMISC_tables.o $(LIBES) $(LSOCKET)
+
+l-imisc:       IMISC-ops.c IMISC_tables.c true
+               $(LINT) $(LFLAGS) -DINVOKER imisc.c IMISC-ops.c \
+                       ryinitiator.c IMISC_tables.c IMISC-stubs.c $(LLIBS) \
+                       | grep -v "warning: possible pointer alignment problem"
+
+imisc.o:       ryinitiator.h IMISC-ops.h IMISC-types.h $(HFILES)
+
+IMISC-Iops.o:  IMISC-ops.c IMISC-ops.h $(HFILES)
+               $(CC) $(CFLAGS) -DINVOKER -c IMISC-ops.c
+               mv IMISC-ops.o $@
+
+ryinitiator.o: ryinitiator.h $(HFILES)
+
+
+################################################################
+# libimisc
+################################################################
+
+IMISC_tables.o:        IMISC_tables.c IMISC-types.h
+
+IMISC_tables.c IMISC-types.h: IMISC-asn.py $(TOPDIR)pepsy/xpepsy
+               $(TOPDIR)pepsy/xpepsy -A -f -h -m IMISC-asn.py
+
+IMISC-asn.py:  imisc.ry $(TOPDIR)rosy/xrosy
+               $(TOPDIR)rosy/xrosy -m -pepsy -o $@ imisc.ry
+IMISC-ops.c:   imisc.ry
+IMISC-ops.h:   imisc.ry
+IMISC-stubs.c: imisc.ry
+
+
+################################################################
+# manual pages
+################################################################
+
+MANUALS        =       imiscd.8c imisc.1c
+
+manuals:;      @$(UTILDIR)inst-man.sh $(MANOPTS) $(MANUALS)
+               -@echo ""
+
+
+################################################################
+# clean
+################################################################
+
+clean:;                rm -f *.ph *.o *.a IMISC* x* z* _* core
+
+grind:;                iprint Makefile
+               tgrind -lc ryinitiator.h ryresponder.h $(CFILES)
+               tgrind -lpepy -d $(TOPDIR)pepy/grindefs $(RYFILES)
+               @echo $(MANUALS) | \
+                       tr " " "\012" | \
+                       sed -e "s%.*%itroff -man &%" | \
+                       sh -ve
+
+true:;
diff --git a/usr/src/contrib/isode/imisc/imisc.1c b/usr/src/contrib/isode/imisc/imisc.1c
new file mode 100644 (file)
index 0000000..725f577
--- /dev/null
@@ -0,0 +1,76 @@
+.TH IMISC 1C "31 May 1988"
+.\" $Header: /f/osi/imisc/RCS/imisc.1c,v 7.1 91/02/22 09:26:16 mrose Interim $
+.\"
+.\"
+.\" $Log:      imisc.1c,v $
+.\" Revision 7.1  91/02/22  09:26:16  mrose
+.\" Interim 6.8
+.\" 
+.\" Revision 7.0  89/11/23  21:57:35  mrose
+.\" Release 6.0
+.\" 
+.SH NAME
+imisc \- miscellaneous network service \-\- initiator
+.SH SYNOPSIS
+.in +.5i
+.ti -.5i
+.B imisc
+host
+\%[\0prefix\0arguments\0]
+\%[operation\0[\0arguments\0...\0]\0]
+.in -.5i
+.SH DESCRIPTION
+The \fIimisc\fR program requests an operation from
+the miscellaneous network service
+provided by a server using remote operations services.
+The currently supported operations are:
+.sp
+.in +.5i
+.nf
+.ta \w'\fIoperation\fR  'u
+\fIoperation\fR        \fIdescription\fR
+\fButctime\fR  the universal time
+\fBgentime\fR  the generalized time
+\fBtime\fR     the current time since the epoch
+\fBusers\fR    the users logged in on the system
+\fBchargen\fR  the character generation pattern
+\fBqotd\fR     the quote of the day
+\fBfinger\fR   the finger of users logged in
+\fBpwdgen\fR   some pseudo-randomly generated passwords
+\fBtell\fR     send a message to a remote user
+\fBping\fR     ping test for performance measurement
+\fBsink\fR     sink test for performance measurement
+\fBecho\fR     echo test for performance measurement
+.re
+.fi
+.in -.5i
+.sp
+This program initiates remote operations to the \*(lqisode
+miscellany\*(rq service.
+.PP
+The prefix arguments are used to direct how many times the performance
+measurement tests should run:
+the `-c\0count' switch indicates the number of iterations to try,
+and the `-l\0length' switch indicates the number of octets to send as
+user data for each iteration.
+.PP
+If no operation is given on the command line,
+then \fIimisc\fR enters interactive mode:
+\fIimisc\fR will examine each line of the standard\-input,
+treating the first word as the operation, and any remaining words as
+arguments.
+(Currently, only the \fIfinger\fR operation takes arguments.)
+.PP
+The pseudo\-operations \fIhelp\fR and \fIquit\fR do the obvious things.
+.SH FILES
+.nf
+.ta \w'\*(EDisoservices  'u
+\*(EDisoentities       ISODE entities database
+\*(EDisobjects ISODE objects database
+\*(EDisoservices       ISODE services database
+.re
+.fi
+.SH DIAGNOSTICS
+Obvious.
+.SH AUTHOR
+Marshall T. Rose
diff --git a/usr/src/contrib/isode/imisc/imisc.c b/usr/src/contrib/isode/imisc/imisc.c
new file mode 100644 (file)
index 0000000..026da2d
--- /dev/null
@@ -0,0 +1,471 @@
+/* imisc.c - miscellaneous network service -- initiator */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/imisc/RCS/imisc.c,v 7.3 91/02/22 09:26:17 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/imisc/RCS/imisc.c,v 7.3 91/02/22 09:26:17 mrose Interim $
+ *
+ *
+ * $Log:       imisc.c,v $
+ * Revision 7.3  91/02/22  09:26:17  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.2  90/07/09  14:38:45  mrose
+ * sync
+ * 
+ * Revision 7.1  90/07/01  21:04:02  mrose
+ * pepsy
+ * 
+ * Revision 7.0  89/11/23  21:57:35  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include <pwd.h>
+#include "ryinitiator.h"       /* for generic interactive initiators */
+#include "IMISC-ops.h"         /* IMISC operation definitions */
+#include "IMISC-types.h"       /* IMISC type definitions */
+
+
+#ifdef SYS5
+struct passwd *getpwuid ();
+#endif
+
+/* \f   DATA */
+
+static char *myservice = "isode miscellany";/* should be something other
+                                              than mycontext */
+
+static char *mycontext = "isode miscellany";
+static char *mypci = "isode miscellany pci";
+
+
+extern int length;
+static type_IMISC_Data *data = NULLPE;
+
+                                       /* TYPES */
+struct type_IMISC_IA5List *vec2ia5list (); 
+
+
+                                       /* ARGUMENTS */
+int    do_finger (), do_tell (), do_data (), do_help (), do_quit ();
+
+
+                                       /* RESULTS */
+#define        gentime_result  utctime_result
+
+int    utctime_result (), timeofday_result (), ia5_result (), tell_result (),
+       null_result (), echo_result ();
+
+                                       /* ERRORS */
+int    imisc_error ();
+
+
+static struct dispatch dispatches[] = {
+    "utctime", operation_IMISC_utcTime,
+    NULLIFP, NULL, 0,
+    utctime_result, imisc_error,    
+    "the universal time",
+
+    "gentime", operation_IMISC_genTime,
+    NULLIFP, NULL, 0,
+    gentime_result, imisc_error,
+    "the generalized time",
+
+    "time",    operation_IMISC_timeOfDay,
+    NULLIFP, NULL, 0,
+    timeofday_result, imisc_error,
+    "the current time since the epoch",
+
+    "users",   operation_IMISC_users,
+    NULLIFP, NULL, 0,
+    ia5_result, imisc_error,
+    "the users logged in on the system",
+
+    "chargen", operation_IMISC_charGen,
+    NULLIFP, NULL, 0,
+    ia5_result, imisc_error,
+    "the character generation pattern",
+
+    "qotd",    operation_IMISC_qotd,
+    NULLIFP, NULL, 0,
+    ia5_result, imisc_error,
+    "the quote of the day",
+
+    "finger",  operation_IMISC_finger,
+    do_finger, &_ZIMISC_mod, _ZIA5ListIMISC,
+    ia5_result, imisc_error,
+    "the finger of users logged in",
+
+    "pwdgen",  operation_IMISC_pwdGen,
+    NULLIFP, NULL, 0,
+    ia5_result, imisc_error,
+    "some pseudo-randomly generated passwords",
+
+    "tell", operation_IMISC_tellUser,
+    do_tell, &_ZIMISC_mod, _ZIA5ListIMISC,
+    tell_result, imisc_error,
+    "send a message to a remote user",
+
+    "ping", operation_IMISC_ping,
+    NULLIFP, NULL, 0,
+    null_result, imisc_error,
+    "ping responder",
+
+    "sink", operation_IMISC_sink,
+    do_data, NULL, 0,
+    null_result, imisc_error,
+    "sink data",
+
+    "echo", operation_IMISC_echo,
+    do_data, NULL, 0,
+    echo_result, imisc_error,
+    "echo data",
+    
+    "help", 0,
+    do_help, NULL, 0,
+    NULLIFP, NULLIFP,
+    "print this information",
+
+    "quit", 0,
+    do_quit, NULL, 0,
+    NULLIFP, NULLIFP,
+    "terminate the association and exit",
+
+    NULL
+};
+
+
+char   *ctime ();
+
+/* \f   MAIN */
+
+/* ARGSUSED */
+
+main (argc, argv, envp)
+int    argc;
+char  **argv,
+      **envp;
+{
+    ryinitiator (argc, argv, myservice, mycontext, mypci,
+                table_IMISC_Operations, dispatches, do_quit);
+
+    exit (0);                  /* NOTREACHED */
+}
+
+/* \f   TYPES */
+
+struct type_IMISC_IA5List *vec2ia5list (vec)
+char  **vec;
+{
+    struct type_IMISC_IA5List  *ia5;
+    register struct type_IMISC_IA5List **ia5p;
+
+    ia5 = NULL;
+    ia5p = &ia5;
+
+    for (; *vec; vec++) {
+       if ((*ia5p = (struct type_IMISC_IA5List *) calloc (1, sizeof **ia5p))
+               == NULL)
+           adios (NULLCP, "out of memory");
+
+       if (((*ia5p) -> IA5String = str2qb (*vec, strlen (*vec), 1)) == NULL)
+           adios (NULLCP, "out of memory");
+
+       ia5p = &((*ia5p) -> next);
+    }
+
+    return ia5;
+}
+
+/* \f */
+
+static print_ia5list (ia5)
+register struct type_IMISC_IA5List *ia5;
+{
+    register struct qbuf *p,
+                        *q;
+    
+    for (; ia5; ia5 = ia5 -> next) {
+       p = ia5 -> IA5String;
+       for (q = p -> qb_forw; q != p ; q = q -> qb_forw)
+           printf ("%*.*s", q -> qb_len, q -> qb_len, q -> qb_data);
+       printf ("\n");
+    }
+}
+
+/* \f   ARGUMENTS */
+
+/* ARGSUSED */
+
+static int  do_finger (sd, ds, args, ia5)
+int    sd;
+struct dispatch *ds;
+char  **args;
+struct type_IMISC_IA5List **ia5;
+{
+    *ia5 = vec2ia5list (args);
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  do_tell (sd, ds, args, ia5)
+int    sd;
+struct dispatch *ds;
+char  **args;
+register struct type_IMISC_IA5List **ia5;
+{
+    char   *cp,
+           *dp,
+           buffer[BUFSIZ];
+    register struct type_IMISC_IA5List  *ia52;
+    register struct passwd *pw;
+
+    if (args[0] == NULL || args[1] == NULL) {
+       advise (NULLCP, "usage: tell user message ...");
+       return NOTOK;
+    }
+
+    *ia5 = vec2ia5list (args);
+
+    cp = (pw = getpwuid (getuid ())) ? pw -> pw_name : "anon";
+    dp = PLocalHostName ();
+
+    if ((ia52 = (struct type_IMISC_IA5List *) calloc (1, sizeof *ia52))
+           == NULL)
+       adios (NULLCP, "out of memory");
+    (void) sprintf (buffer, "%s@%s", cp, dp);
+    if ((ia52 -> IA5String = str2qb (buffer, strlen (buffer), 1)) == NULL)
+       adios (NULLCP, "out of memory");
+
+/* kludge this arg onto front of list - HACK ATTACK */
+    ia52 -> next = *ia5;
+    *ia5 = ia52;
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  do_data (sd, ds, args, pep)
+int    sd;
+struct dispatch *ds;
+char  **args;
+register struct type_IMISC_Data **pep;
+{
+    char   *cp;
+    
+    if (data == NULLPE) {
+       if (length > 0) {
+           if ((cp = malloc ((unsigned) length)) == NULL)
+               adios (NULLCP, "no memory");
+       }
+       else
+           cp = NULL;
+       if ((data = oct2prim (cp, length)) == NULLPE)
+           adios (NULLCP, "no memory");
+       if (cp)
+           free (cp);
+    }
+
+    *pep = data;
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  do_help (sd, ds, args, dummy)
+int    sd;
+register struct dispatch *ds;
+char  **args;
+caddr_t *dummy;
+{
+    printf ("\nCommands are:\n");
+    for (ds = dispatches; ds -> ds_name; ds++)
+       printf ("%s\t%s\n", ds -> ds_name, ds -> ds_help);
+
+    return NOTOK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  do_quit (sd, ds, args, dummy)
+int    sd;
+struct dispatch *ds;
+char  **args;
+caddr_t *dummy;
+{
+    struct AcSAPrelease acrs;
+    register struct AcSAPrelease   *acr = &acrs;
+    struct AcSAPindication  acis;
+    register struct AcSAPindication *aci = &acis;
+    register struct AcSAPabort *aca = &aci -> aci_abort;
+
+    if (AcRelRequest (sd, ACF_NORMAL, NULLPEP, 0, NOTOK, acr, aci) == NOTOK)
+       acs_adios (aca, "A-RELEASE.REQUEST");
+
+    if (!acr -> acr_affirmative) {
+       (void) AcUAbortRequest (sd, NULLPEP, 0, aci);
+       adios (NULLCP, "release rejected by peer: %d", acr -> acr_reason);
+    }
+
+    ACRFREE (acr);
+
+    exit (0);
+}
+
+/* \f   RESULTS */
+
+/* ARGSUSED */
+
+static int  utctime_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+register struct type_IMISC_UTCResult *result;
+struct RoSAPindication *roi;
+{
+    register struct qbuf *q;
+
+    for (q = result -> qb_forw; q != result; q = q -> qb_forw)
+       printf ("%*.*s", q -> qb_len, q -> qb_len, q -> qb_data);
+    printf ("\n");
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  timeofday_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+register struct type_IMISC_TimeResult *result;
+struct RoSAPindication *roi;
+{
+    long       s;
+
+    s = result -> parm - 2208988800L;  /* UNIX epoch */
+    printf ("%s", ctime (&s));
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  ia5_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+register struct type_IMISC_IA5List *result;
+struct RoSAPindication *roi;
+{
+    print_ia5list (result);
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  tell_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+caddr_t result;
+struct RoSAPindication *roi;
+{
+    printf ("told.\n");
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  null_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+caddr_t result;
+struct RoSAPindication *roi;
+{
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  echo_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+struct type_IMISC_Data *result;
+struct RoSAPindication *roi;
+{
+    if (pe_cmp (result, data))
+       advise (NULLCP, "data mismatch");
+
+    return OK;
+}
+
+/* \f   ERRORS */
+
+/* ARGSUSED */
+
+static int  imisc_error (sd, id, error, parameter, roi)
+int    sd,
+       id,
+       error;
+register struct type_IMISC_IA5List *parameter;
+struct RoSAPindication *roi;
+{    
+    register struct RyError *rye;
+
+    if (error == RY_REJECT) {
+       advise (NULLCP, "%s", RoErrString ((int) parameter));
+       return OK;
+    }
+
+    if (rye = finderrbyerr (table_IMISC_Errors, error))
+       advise (NULLCP, "%s",  rye -> rye_name);
+    else
+       advise (NULLCP, "Error %d", error);
+
+    if (parameter)
+       print_ia5list (parameter);
+
+    return OK;
+}
diff --git a/usr/src/contrib/isode/imisc/imisc.ry b/usr/src/contrib/isode/imisc/imisc.ry
new file mode 100644 (file)
index 0000000..508ad6b
--- /dev/null
@@ -0,0 +1,157 @@
+-- imisc.ry - IMISC remote operations definitions
+
+-- $Header: /f/osi/imisc/RCS/imisc.ry,v 7.1 91/02/22 09:26:19 mrose Interim $
+--
+--
+-- $Log:       imisc.ry,v $
+-- Revision 7.1  91/02/22  09:26:19  mrose
+-- Interim 6.8
+-- 
+-- Revision 7.0  89/11/23  21:57:38  mrose
+-- Release 6.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.
+--
+--
+
+
+IMISC DEFINITIONS ::=
+
+BEGIN
+
+-- operations
+
+utcTime OPERATION
+       RESULT          UTCResult
+       ERRORS          { congested, unableToDetermineTime }
+       ::=             0
+
+timeOfDay OPERATION
+       RESULT          TimeResult
+       ERRORS          { congested, unableToDetermineTime }
+       ::=             1
+
+users OPERATION
+       RESULT          IA5List
+       ERRORS          { congested, unableToOpenFile }
+       ::=             2
+
+charGen OPERATION
+       RESULT          IA5List
+       ERRORS          { congested }
+       ::=             3
+
+qotd   OPERATION
+       RESULT          IA5List
+       ERRORS          { congested, unableToAccessFile, unableToPipe,
+                         unableToFork, errorReading }
+       ::=             4
+
+finger OPERATION
+       ARGUMENT        IA5List
+       RESULT          IA5List
+       ERRORS          { congested, unableToAccessFile, unableToPipe,
+                         unableToFork, errorReading }
+       ::=             5
+
+pwdGen OPERATION
+       RESULT          IA5List
+       ERRORS          { congested }
+       ::=             6
+
+genTime        OPERATION
+       RESULT          GenResult
+       ERRORS          { congested, unableToDetermineTime }
+       ::=             7
+
+tellUser OPERATION
+       ARGUMENT        IA5List
+       RESULT          Empty
+       ERRORS          { congested, unableToOpenFile, userNotLoggedIn }
+       ::=             8
+
+ping OPERATION
+       ARGUMENT        Empty
+       RESULT          Empty
+       ERRORS          { congested }
+       ::=             9
+           
+sink OPERATION
+       ARGUMENT        Data
+       RESULT          Empty
+       ERRORS          { congested }
+       ::=             10
+           
+echo OPERATION
+       ARGUMENT        Data
+       RESULT          Data
+       ERRORS          { congested }
+       ::=             11
+           
+-- errors
+
+congested
+       ERROR
+       ::=             0
+
+unableToDetermineTime
+       ERROR
+       ::=             1
+
+unableToOpenFile
+       ERROR
+       PARAMETER       IA5List
+       ::=             2
+
+unableToAccessFile
+       ERROR
+       PARAMETER       IA5List
+       ::=             3
+
+unableToPipe
+       ERROR
+       PARAMETER       IA5List
+       ::=             4
+
+unableToFork
+       ERROR
+       PARAMETER       IA5List
+       ::=             5
+
+errorReading
+       ERROR
+       PARAMETER       IA5List
+       ::=             6
+
+userNotLoggedIn
+       ERROR
+       ::=             7
+
+-- types
+
+IA5List ::=
+       SEQUENCE OF IA5String
+
+UTCResult ::=
+       UniversalTime
+
+TimeResult ::=
+       INTEGER
+
+GenResult ::=
+       GeneralizedTime
+
+Data ::=
+       ANY
+
+Empty ::=
+       NULL
+
+END
diff --git a/usr/src/contrib/isode/imisc/imiscd.8c b/usr/src/contrib/isode/imisc/imiscd.8c
new file mode 100644 (file)
index 0000000..069f5a2
--- /dev/null
@@ -0,0 +1,62 @@
+.TH IMISCD 8C "31 May 1988"
+.\" $Header: /f/osi/imisc/RCS/imiscd.8c,v 7.1 91/02/22 09:26:20 mrose Interim $
+.\"
+.\"
+.\" $Log:      imiscd.8c,v $
+.\" Revision 7.1  91/02/22  09:26:20  mrose
+.\" Interim 6.8
+.\" 
+.\" Revision 7.0  89/11/23  21:57:39  mrose
+.\" Release 6.0
+.\" 
+.SH NAME
+imiscd \- miscellaneous network service \-\- responder
+.SH SYNOPSIS
+.in +.5i
+.ti -.5i
+.B \*(SDros.imisc
+\fImagic\0arguments\fR
+.in -.5i
+(under \fI\*(SDtsapd\fR\0)
+.SH DESCRIPTION
+The \fIimiscd\fR server implements the miscellaneous network service
+using remote operations services.
+The currently supported operations are:
+.sp
+.in +.5i
+.nf
+.ta \w'\fBtimeOfDay\fR  'u
+\fIoperation\fR        \fIdescription\fR
+\fButcTime\fR  the universal time
+\fBgenTime\fR  the generalized time
+\fBtimeOfDay\fR        the current time since the epoch
+\fBusers\fR    the users logged in on the system
+\fBcharGen\fR  the character generation pattern
+\fBqotd\fR     the quote of the day
+\fBfinger\fR   the finger of users logged in
+\fBpwdGen\fR   some pseudo-randomly generated passwords
+\fBtellUser\fR send a message to a remote user
+\fBping\fR     ping test for performance measurement
+\fBsink\fR     sink test for performance measurement
+\fBecho\fR     echo test for performance measurement
+.re
+.fi
+.in -.5i
+.sp
+Formally,
+it is known as the \*(lqisode miscellany\*(rq,
+responding with the \*(lqisode miscellany\*(rq application context
+utilizing the \*(lqisode miscellany pci\*(rq presentation context.
+.SH FILES
+.nf
+.ta \w'\*(LDimisc.log  'u
+\*(EDisoentities       ISODE entities database
+\*(EDisobjects ISODE objects database
+\*(EDisoservices       ISODE services database
+\*(LDimisc.log log file
+.re
+.fi
+.SH DIAGNOSTICS
+Obvious.
+.SH AUTHOR
+Marshall T. Rose
diff --git a/usr/src/contrib/isode/imisc/imiscd.c b/usr/src/contrib/isode/imisc/imiscd.c
new file mode 100644 (file)
index 0000000..134e850
--- /dev/null
@@ -0,0 +1,1150 @@
+/* imiscd.c - miscellaneous network service -- responder */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/imisc/RCS/imiscd.c,v 7.4 91/02/22 09:26:21 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/imisc/RCS/imiscd.c,v 7.4 91/02/22 09:26:21 mrose Interim $
+ *
+ *
+ * $Log:       imiscd.c,v $
+ * Revision 7.4  91/02/22  09:26:21  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.3  90/11/21  11:37:04  mrose
+ * update
+ * 
+ * Revision 7.2  90/07/09  14:38:48  mrose
+ * sync
+ * 
+ * Revision 7.1  90/07/01  21:04:05  mrose
+ * pepsy
+ * 
+ * Revision 7.0  89/11/23  21:57:39  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include "IMISC-types.h"       /* IMISC type definitions */
+#include "ryresponder.h"       /* for generic idempotent responders */
+#include "IMISC-ops.h"         /* IMISC operation definitions */
+#include <utmp.h>
+#ifdef SYS5
+#include <sys/times.h>
+#endif
+#include <sys/stat.h>
+
+/* \f   DATA */
+
+static char *myservice = "isode miscellany";   /* should be something else */
+
+static int execuid = 1;
+static int execgid = 1;
+
+
+                                       /* OPERATIONS */
+int    op_utcTime (), op_genTime (), op_timeOfDay (), op_users (),
+       op_charGen (), op_pwdGen (), op_exec (), op_tellUser (), op_data ();
+
+static struct dispatch dispatches[] = {
+    "utcTime", operation_IMISC_utcTime, op_utcTime,
+
+    "genTime", operation_IMISC_genTime, op_genTime,
+
+    "timeOfDay", operation_IMISC_timeOfDay, op_timeOfDay,
+
+    "users", operation_IMISC_users, op_users,
+
+    "chargen", operation_IMISC_charGen, op_charGen,
+
+    "pwdGen", operation_IMISC_pwdGen, op_pwdGen,
+
+    "qotd", operation_IMISC_qotd, op_exec,
+
+    "finger", operation_IMISC_finger, op_exec,
+
+    "tellUser", operation_IMISC_tellUser, op_tellUser,
+
+    "ping", operation_IMISC_ping, op_data,
+
+    "sink", operation_IMISC_sink, op_data,
+
+    "echo", operation_IMISC_echo, op_data,
+
+    NULL
+};
+
+
+                                       /* TYPES */
+struct type_IMISC_IA5List *str2ia5list ();
+
+
+extern int  errno;
+
+
+long   time ();
+char   *ctime ();
+
+/* \f   MAIN */
+
+/* ARGSUSED */
+
+main (argc, argv, envp)
+int    argc;
+char  **argv,
+      **envp;
+{
+    ryresponder (argc, argv, PLocalHostName (), myservice, NULLCP,
+                dispatches, table_IMISC_Operations, NULLIFP, NULLIFP);
+
+    exit (0);                  /* NOTREACHED */
+}
+
+/* \f   OPERATIONS */
+
+/* ARGSUSED */
+
+static int  op_utcTime (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    long    clock;
+    char   *cp;
+    register struct tm *tm;
+    struct UTCtime  uts;
+    register struct UTCtime *ut = &uts;
+    register struct type_IMISC_UTCResult *ur;
+
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    if (time (&clock) == NOTOK || (tm = gmtime (&clock)) == NULL)
+       return error (sd, error_IMISC_unableToDetermineTime, (caddr_t) NULL,
+                   rox, roi);
+
+    tm2ut (tm, ut);
+
+    if ((cp = utct2str (ut)) == NULLCP
+           || (ur = str2qb (cp, strlen (cp), 1)) == NULL)
+       return error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) ur, ROS_NOPRIO, roi) == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+
+    free_IMISC_UTCResult (ur);
+
+    return OK;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  op_genTime (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    long    clock;
+    char   *cp;
+#if    defined(BSD42) || defined (HPUX)
+    struct timeval  tvs;
+#endif
+    register struct tm *tm;
+    struct UTCtime  uts;
+    register struct UTCtime *ut = &uts;
+    register struct type_IMISC_GenResult *gr;
+
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+#if    defined(BSD42) || defined (HPUX)
+    if (gettimeofday (&tvs, (struct timezone *) 0) == NOTOK)
+       return error (sd, error_IMISC_unableToDetermineTime, (caddr_t) NULL,
+                   rox, roi);
+    clock = tvs.tv_sec;
+#else
+    if (time (&clock) == NOTOK)
+       return error (sd, error_IMISC_unableToDetermineTime, (caddr_t) NULL,
+                   rox, roi);
+#endif
+    if ((tm = gmtime (&clock)) == NULL)
+       return error (sd, error_IMISC_unableToDetermineTime, (caddr_t) NULL,
+                   rox, roi);
+    tm2ut (tm, ut);
+#ifdef BSD42
+    ut -> ut_flags |= UT_USEC;
+    ut -> ut_usec = tvs.tv_usec;
+#endif
+
+    if ((cp = gent2str (ut)) == NULLCP
+           || (gr = str2qb (cp, strlen (cp), 1)) == NULL)
+       return error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) gr, ROS_NOPRIO, roi) == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+
+    free_IMISC_GenResult (gr);
+
+    return OK;
+}
+
+/* \f */
+
+/* Return the number of seconds since 00:00 (midnight) 1 January 1900 GMT */
+
+/* ARGSUSED */
+
+static int  op_timeOfDay (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    long       clock;
+    struct type_IMISC_TimeResult trs;
+    register struct type_IMISC_TimeResult *tr = &trs;
+
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    if (time (&clock) == NOTOK)
+       return error (sd, error_IMISC_unableToDetermineTime, (caddr_t) NULL,
+                   rox, roi);
+    tr -> parm = clock + 2208988800;
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) tr, ROS_NOPRIO, roi) == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+
+    return OK;
+}
+
+/* \f */
+
+#ifdef sun
+#define        BSD42
+#undef SYS5
+#endif
+
+#ifdef bsd43_ut_host
+#undef BSD42
+#define        SYS5
+#endif
+
+#ifdef BSD42
+#define        HMAX    (sizeof (ut -> ut_host))
+#endif
+#define        LMAX    (sizeof (ut -> ut_line))
+#define        NMAX    (sizeof (ut -> ut_name))
+
+#ifdef SYS5
+struct utmp *getutent ();
+#endif
+
+
+/* ARGSUSED */
+
+static int  op_users (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+#ifndef        SYS5
+    int            ud;
+#endif
+    register char  *dp;
+    char    buffer[BUFSIZ];
+    struct utmp uts;
+    register struct utmp   *ut = &uts;
+    struct type_IMISC_IA5List *ia5;
+    register struct type_IMISC_IA5List **ia5p;
+
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    ia5 = NULL;
+    ia5p = &ia5;
+
+#ifndef        SYS5
+    if ((ud = open ("/etc/utmp", 0)) == NOTOK) {
+       int     result;
+
+       (void) sprintf (buffer, "/etc/utmp: %s", sys_errname (errno));
+       if ((*ia5p = str2ia5list (buffer)) == NULL)
+           goto congested;
+       ia5p = &((*ia5p) -> next);
+
+       result = error (sd, error_IMISC_unableToOpenFile, (caddr_t) ia5, rox,
+                   roi);
+
+       free_IMISC_IA5List (ia5);
+
+       return result;
+    }
+
+    while (read (ud, (char *) ut, sizeof *ut) == sizeof *ut) {
+       if (ut -> ut_name[0] == NULL)
+           continue;
+       if ((dp = ctime (&ut -> ut_time)) == NULL)
+           goto congested;
+       (void) sprintf (buffer, "%-*.*s %-*.*s %.12s",
+               NMAX, NMAX, ut -> ut_name, LMAX, LMAX, ut -> ut_line, dp + 4);
+#ifdef BSD42
+       if (ut -> ut_host[0])
+           (void) sprintf (buffer + strlen (buffer), "\t(%.*s)",
+                   HMAX, ut -> ut_host);
+#endif
+
+       if ((*ia5p = str2ia5list (buffer)) == NULL)
+           goto congested;
+       ia5p = &((*ia5p) -> next);
+    }
+    (void) close (ud);
+#else
+    setutent ();
+    while (ut = getutent ()) {
+       if (ut -> ut_type != USER_PROCESS)
+           continue;
+       if ((dp = ctime (&ut -> ut_time)) == NULL)
+           goto congested;
+       (void) sprintf (buffer, "%-*.*s %-*.*s %.12s",
+               NMAX, NMAX, ut -> ut_name, LMAX, LMAX, ut -> ut_line,
+               dp + 4);
+
+       if ((*ia5p = str2ia5list (buffer)) == NULL)
+           goto congested;
+       ia5p = &((*ia5p) -> next);
+    }
+    endutent ();
+#endif
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) ia5, ROS_NOPRIO, roi)
+           == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+    free_IMISC_IA5List (ia5);
+
+    return OK;
+
+congested: ;
+    free_IMISC_IA5List (ia5);
+
+    return error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+}
+
+
+#ifdef bsd43_ut_host
+#define        BSD42
+#undef SYS5
+#endif
+
+/* \f */
+
+#define        NBYTES  512
+#define        LINSIZ  72
+
+
+/* ARGSUSED */
+
+static int  op_charGen (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    register int    i,
+                    j;
+    register char  *dp,
+                   *de,
+                   *rs,
+                   *rp,
+                   *re;
+    char    line[LINSIZ + 1],
+            ring[BUFSIZ];
+    struct type_IMISC_IA5List *ia5;
+    register struct type_IMISC_IA5List **ia5p;
+
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    re = ring;
+    for (i = 0; i < 0x80; i++)
+       if (isprint ((u_char) i))
+           *re++ = i;
+
+    ia5 = NULL;
+    ia5p = &ia5;
+
+    for (rs = ring, i = NBYTES; i > 0; rs++, i -= j) {
+       if (rs >= re)
+           rs = ring;
+       j = i > LINSIZ ? LINSIZ : i;
+       for (de = (dp = line) + j, rp = rs; dp < de; dp++, rp++) {
+           if (rp >= re)
+               rp = ring;
+           *dp = *rp;
+       }
+
+       *dp = NULL;
+       if ((*ia5p = str2ia5list (line)) == NULL)
+           goto congested;
+       ia5p = &((*ia5p) -> next);
+    }
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) ia5, ROS_NOPRIO, roi)
+           == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+    free_IMISC_IA5List (ia5);
+
+    return OK;
+
+congested: ;
+    free_IMISC_IA5List (ia5);
+
+    return error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+}
+
+/* \f */
+
+#define        NPASS   6
+
+
+/* ARGSUSED */
+
+static int  op_pwdGen (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    register int    i;
+    char    buffer[BUFSIZ];
+    struct type_IMISC_IA5List *ia5;
+    register struct type_IMISC_IA5List **ia5p;
+
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    ia5 = NULL;
+    ia5p = &ia5;
+
+    for (i = NPASS; i > 0; i--) {
+       if (pwdgen (buffer) == NOTOK)
+           goto congested;
+
+       if ((*ia5p = str2ia5list (buffer)) == NULL)
+           goto congested;
+       ia5p = &((*ia5p) -> next);
+    }
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) ia5, ROS_NOPRIO, roi)
+           == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+    free_IMISC_IA5List (ia5);
+
+    return OK;
+
+congested: ;
+    free_IMISC_IA5List (ia5);
+
+    return error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+}
+
+/* \f */
+
+/* Based on an f77 algorithm supplied by Frank Wancho <Wancho@SIMTEL20>,
+   which was based on a basic algorithm by Paul D. Merillat and Arthur A. Key.
+
+   Strings returned are built by alternating vowels and consonants.
+   However, there are "Digraphs", and these are presorted according to
+   END, MIDDLE, and START positions.
+
+   Not going into combinatorial analysis (with 7 characters the "possible"
+   combinations exceed 20 million).
+ */
+
+
+#define        TOT     54636577
+
+static struct pair {
+    char   *p_form;
+    int     p_value;
+} pairs[] = {
+       "cvcvcvce", 0,
+       "vcvcvcvc", 10827189,
+       "cpcpce", 13725209,
+       "dvcpce", 14036249,
+       "vcvcpce", 14327369,
+       "cvcpme", 15296369,
+       "dvcvcvc", 15746954,
+       "cpcvcvc", 16617618,
+       "cvmvcvc", 17547858,
+       "cvcpcvc", 23616474,
+       "cvcvmvc", 24546714,
+       "dpcvce", 30618378,
+       "dvmvce", 30908898,
+       "cpmvce", 32807107,
+       "vmvcvce", 34838173,
+       "vcpcvce", 41163763,
+       "vcvmvce", 42132163,
+       "vmvmvc", 48449078,
+       "vmpcvc", 51995642,
+       "vmvcpc", 52539386,
+       "vcvmpc", 52962661,
+       "vmpme", 53385611,
+       "dvmpc", 53648987,
+       "cpmpc", 53776002,
+       "cvcvcpc", 53912072,
+
+       NULL, TOT
+};
+            
+
+static char *Mx;
+static char *Nx =              /* XXX */
+    "BBBCBFBKBLBMBNBPBTBVCCCDCFCMCPDBDCDDDFDGDKDLDMDNDPDTDVDWDZFBFCFDFGFKFMFNF\
+PFZGBGDGFGJGMGNGPGTGVKBKDKFKMKNKPKTKVKZLBLCLFLGLMLNLRLVLZMBMCMDMFMGMJMKMLMMMNM\
+RMTMVMZNBNCNFNOSZTBTCTDTFTGTJTKTLTMTNTPTVVCVGVLVPNJNLNPNRPCPDPFPGPKPMPNPVPZRBR\
+CRDRFRGRJRLSBSDSFSGSJSRSV";
+
+static char *Cx =              /* consonants */
+    "BCDFGHJKLMNPRSTVWZ";
+
+static char *Vx =              /* vowels */
+    "AEIOU";
+
+static char *Dx =              /* consonant pairs */
+    "BRCHCLCRDRFLFRGLGRKLKRPHPLPRQUSCSHSKSLSMSNSPSTSWTHTRTW";
+
+static char *Lx =              /* end-consonant pairs */
+    "BSCKCSCTDSFSFTGSHSKSLLLDLKLPLSLTMPMSNDNKNNNSNTPPPSPTRKRMRNRPRSSSTSVSWS";
+
+static char *Px =              /* vowel pairs */
+    "AIEAEEIEIOOIOOOU";
+
+static char *Ex =              /* end-vowels */
+    "EOAY";
+
+static char *Zx =              /* end-vowel pairs */
+    "EEOOAYEYOY";
+
+static struct web {
+    char    w_key;
+    int            w_length;
+    int            w_factor;
+    char  **w_string;
+    char   *w_special;
+} webs[] = {
+    'm', 189, 2, &Mx, NULL,
+    'c', 18, 1, &Cx, "HWJ",
+    'v', 5, 1, &Vx, NULL,
+    'd', 27, 2, &Dx, NULL,
+    'l', 35, 2, &Lx, NULL,
+    'p', 8, 2, &Px, NULL,
+    'e', 4, 1, &Ex, NULL,
+    'z', 5, 2, &Zx, NULL,
+
+    NULL, 0, 0, NULL, NULL
+};
+
+/* \f */
+
+#define        ifix(f)         ((int) ((float) (f) + 0.5))
+#ifndef        SYS5
+#define        nrand()         (((float) (random ()) / (float) 2147483647))
+
+long   random ();
+#else
+#define        nrand()         (((float) (rand ()) / (float) 2147483647))
+
+int    rand (), srand ();
+#endif
+#define        rng(a,b)        if (((i = ifix (a * nrand ()) * b) ? i -= b : i) < 0 \
+                               || i >= a * b + (1 - b)) \
+                           return NOTOK;
+
+
+static int  pwdgen (pw)
+char   *pw;
+{
+    register int    i,
+                    j;
+    register char   c,
+                   *f,
+                   *s;
+    register struct pair   *pair;
+    register struct web *web;
+    static int  latch = 0;
+
+    if (!latch) {
+       if ((Mx = malloc
+                   (((unsigned) (strlen (Dx) + strlen (Lx) + strlen (Nx)))))
+               == NULL)
+           return NOTOK;
+       (void) strcpy (s = Mx, Dx);
+       s += strlen (s);
+       (void) strcpy (s, Lx);
+       s += strlen (s);
+       (void) strcpy (s, Nx);
+       s += strlen (s);
+
+#ifndef        SYS5
+       (void) srandom ((int) time ((long *) 0));
+#else
+       (void) srand ((unsigned int) time ((long *) 0));
+#endif
+
+       latch++;
+    }
+
+    rng (TOT, 1.0);
+    for (pair = pairs; pair -> p_form; pair++)
+       if (pair -> p_value < i)
+           f = pair -> p_form;
+       else
+           break;
+
+    do {
+       for (s = pw; c = *f++;) {
+           for (web = webs; web -> w_key != c; web++)
+               if (web -> w_key == c)
+                   break;
+           if (!web -> w_key)
+               return NOTOK;
+
+           rng (web -> w_length, web -> w_factor);
+
+           for (j = web -> w_factor; j > 0; j--)
+               *s++ = (*web -> w_string)[i++];
+           if (web -> w_special && *f == NULL) {
+               s--, i--;
+               while (index (web -> w_special, *s))
+                   *s = (*web -> w_string)[--i];
+               s++;
+           }
+       }
+
+       *s = NULL;
+    } while (object (pw));
+
+    return OK;
+}
+
+/* \f */
+
+static struct obj {
+    char   *o_string;
+    int     o_advance;
+} objects[] = {
+    "TRAFLLEHPARCTIHS", 4,
+    "SIPSSATITDOGCUFKUF", 3,
+
+    NULL, 0
+};
+
+
+static int  object (pw)
+register char   *pw;
+{
+    register int    n;
+    register char  *f,
+                   *s;
+    char    buffer[BUFSIZ];
+    register struct obj *o;
+
+    for (f = buffer + strlen (s = pw), *f = NULL; *s; s++)
+       *--f = *s;
+
+    for (o = objects; s = o -> o_string; o++)
+       for (n = o -> o_advance; *s; s += n)
+           if (strncmp (f, s, n) == 0)
+               return NOTOK;
+
+    return OK;
+}
+
+/* \f */
+
+#ifndef        FORTUNE
+#define        FORTUNE "/usr/games/fortune"
+#endif
+#ifndef        RFINGER
+#ifndef        SYS5
+#define        RFINGER "/usr/ucb/finger"
+#else
+#define        RFINGER "/usr/bin/finger"
+#endif
+#endif
+
+
+static int  op_exec (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    int     fd,
+            i,
+            result,
+            vecp,
+           vecq,
+            pd[2];
+    register char  *bp,
+                   *dp;
+    char    buffer[BUFSIZ],
+            data[BUFSIZ],
+          *pgm,
+           *vec[NVEC + 1];
+    struct type_IMISC_IA5List *ia5;
+    register struct type_IMISC_IA5List **ia5p;
+
+    vecp = vecq = 0;
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       result = ureject (sd, ROS_IP_LINKED, rox, roi);
+       goto out;
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    if (ryo -> ryo_op == operation_IMISC_qotd) {
+       vec[vecp++] = pgm = FORTUNE;
+       vecq = vecp;
+    }
+    else {
+       vec[vecp++] = pgm = RFINGER;
+#ifdef RFOPT1
+       vec[vecp++] = RFOPT1;
+#endif
+#ifdef RFOPT2
+       vec[vecp++] = RFOPT2;
+#endif
+       vecq = vecp;
+       for (ia5 = (struct type_IMISC_IA5List *) in; ia5; ia5 = ia5 -> next)
+           if (vecp >= NVEC
+                   || (vec[vecp++] = qb2str (ia5 -> IA5String)) == NULLCP) {
+               result = error (sd, error_IMISC_congested, (caddr_t) NULL, rox,
+                           roi);
+               goto out;
+           }
+    }
+    vec[vecp] = NULLCP;
+
+    ia5 = NULL;
+    ia5p = &ia5;
+
+    if (access (pgm, 1) == NOTOK) {
+       result = error_IMISC_unableToAccessFile;
+
+oops: ;
+       free_IMISC_IA5List (ia5);
+       ia5 = NULL;
+       ia5p = &ia5;
+
+       (void) sprintf (buffer, "%s: %s", pgm, sys_errname (errno));
+       if ((*ia5p = str2ia5list (buffer)) == NULL)
+           goto congested;
+       ia5p = &((*ia5p) -> next);
+
+       result = error (sd, result, (caddr_t) ia5, rox, roi);
+
+       free_IMISC_IA5List (ia5);
+
+       goto out;
+    }
+    if (pipe (pd) == NOTOK) {
+       result = error_IMISC_unableToPipe;
+       goto oops;
+    }
+
+    switch (vfork ()) {
+       case NOTOK: 
+           (void) close (pd[0]);
+           (void) close (pd[1]);
+           result = error_IMISC_unableToFork;
+           goto oops;
+
+       case OK: 
+           if ((fd = open ("/dev/null", 2)) != NOTOK) {
+               if (fd != 0)
+                   (void) dup2 (fd, 0), (void) close (fd);
+           }
+           (void) dup2 (pd[1], 1);
+           (void) dup2 (pd[1], 2);
+           (void) close (pd[0]);
+           (void) close (pd[1]);
+           if (execuid != 0) {
+               (void) setgid (execgid);
+               (void) setuid (execuid);
+           }
+           execvp (pgm, vec);
+           _exit (1);
+
+       default: 
+           (void) close (pd[1]);
+           for (vecp = vecq; bp = vec[vecp]; vecp++) {
+               free (bp);
+               vec[vecp] = NULL;
+           }
+
+           for (; vecq < vecp; vecq++)
+               if (bp = vec[vecq])
+                   free (bp);
+           for (dp = data;;)
+               switch (i = read (pd[0], buffer, sizeof buffer)) {
+                   case NOTOK: 
+                       i = errno;
+                       (void) close (pd[0]);
+                       errno = i;
+                       result = error_IMISC_errorReading;
+                       goto oops;
+
+                   case OK: 
+                       (void) close (pd[0]);
+                       if (dp != data) {
+                           *dp = NULL;
+                           if ((*ia5p = str2ia5list (data)) == NULL)
+                               goto congested;
+                           ia5p = &((*ia5p) -> next);
+                       }
+                       if (RyDsResult (sd, rox -> rox_id, (caddr_t) ia5,
+                               ROS_NOPRIO, roi) == NOTOK)
+                           ros_adios (&roi -> roi_preject, "RESULT");
+                       free_IMISC_IA5List (ia5);
+                       result = OK;
+                       goto out;
+
+                   default: 
+                       for (bp = buffer; i > 0; bp++, i--)
+                           switch (*bp) {
+                               case '\n': 
+                                   *dp = NULL;
+                                   if ((*ia5p = str2ia5list (data)) == NULL)
+                                       goto congested;
+                                   ia5p = &((*ia5p) -> next);
+                                   dp = data;
+                                   break;
+
+                               case NULL: 
+                                   break;
+
+                               default: 
+                                   *dp++ = *bp;
+                                   break;
+                           }
+                       continue;
+               }
+    }
+
+congested: ;
+    free_IMISC_IA5List (ia5);
+    result = error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+
+out: ;
+    for (vecp = vecq; bp = vec[vecp]; vecp++)
+       free (bp);
+
+    return result;
+}
+
+/* \f */
+
+/* ARGSUSED */
+
+static int  op_tellUser (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+#ifndef        SYS5
+    int     ud;
+#endif
+    int     hit,
+            result,
+            vecp;
+    char   *bp,
+          *fromuser,
+           *touser,
+            buffer[BUFSIZ],
+          **vec,
+           *vecl[NVEC + 1];
+    struct utmp uts;
+    register struct utmp   *ut = &uts;
+    struct type_IMISC_IA5List  *ia5;
+
+    vecp = 0;
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       result = ureject (sd, ROS_IP_LINKED, rox, roi);
+       goto out;
+    }
+    advise (LLOG_NOTICE, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    for (ia5 = (struct type_IMISC_IA5List  *) in; ia5; ia5 = ia5 -> next)
+       if (vecp >= NVEC
+               || (vecl[vecp++] = qb2str (ia5 -> IA5String)) == NULLCP)
+           goto congested;
+    vecl[vecp] = NULLCP;
+
+    if (vecp < 3) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "too few arguments (got %d, wanted at least 3)", vecp);
+       result = ureject (sd, ROS_IP_MISTYPED, rox, roi);
+       goto out;
+    }
+    fromuser = vecl[0];
+    touser = vecl[1];
+    vec = &vecl[2], vecp -= 2;
+
+    hit = 0;
+    result = error_IMISC_userNotLoggedIn;
+#ifndef        SYS5
+    if ((ud = open ("/etc/utmp", 0)) == NOTOK) {
+       (void) sprintf (buffer, "/etc/utmp: %s", sys_errname (errno));
+       if ((ia5 = str2ia5list (buffer)) == NULL)
+           goto congested;
+
+       result = error (sd, error_IMISC_unableToOpenFile, (caddr_t) ia5, rox,
+               roi);
+
+       free_IMISC_IA5List (ia5);
+
+       goto out;
+    }
+
+    while (read (ud, (char *) ut, sizeof *ut) == sizeof *ut) {
+       if (ut -> ut_name[0] == NULL)
+           continue;
+       if (strncmp (ut -> ut_name, touser, sizeof ut -> ut_name) == 0)
+           if (do_the_tell (ut, fromuser, vec, vecp) != NOTOK)
+               hit++;
+           else
+               result = error_IMISC_unableToOpenFile;
+    }
+    (void) close (ud);
+#else
+    setutent ();
+    while (ut = getutent ()) {
+       if (ut -> ut_type != USER_PROCESS)
+           continue;
+       if (strncmp (ut -> ut_name, touser, sizeof ut -> ut_name) == 0)
+           if (do_the_tell (ut, fromuser, vec, vecp) != NOTOK)
+               hit++;
+           else
+               result = error_IMISC_unableToOpenFile;
+    }
+    endutent ();
+#endif
+    if (hit == 0) {
+       result = error (sd, result, (caddr_t) NULL, rox, roi);
+       goto out;
+    }
+
+    if (RyDsResult (sd, rox -> rox_id, (caddr_t) NULL, ROS_NOPRIO, roi)
+           == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+
+    result = OK;
+    goto out;
+
+congested: ;
+    result = error (sd, error_IMISC_congested, (caddr_t) NULL, rox, roi);
+
+out: ;
+    for (vecp = 0; bp = vecl[vecp]; vecp++)
+       free (bp);
+
+    return result;
+}
+
+/* \f */
+
+static int  do_the_tell (ut, from, vec, vecp)
+struct utmp    *ut;
+char   *from;
+char   *vec[];
+int    vecp;
+{
+    int     i,
+            pid;
+    char   *bp,
+           tty[5 + LMAX + 1];
+    struct stat st;
+    FILE   *fp;
+
+    (void) strcpy (bp = tty, "/dev/");
+    bp += strlen (bp);
+    (void) strncpy (bp, ut -> ut_line, LMAX);
+    bp += LMAX;
+    *bp = NULL;
+    if (stat (tty, &st) == NOTOK
+           || (st.st_mode & (S_IWRITE >> 3)) != (S_IWRITE >> 3))
+       return NOTOK;
+
+    for (i = 0; i < 5; i++) {
+       switch (pid = fork ()) {
+           case NOTOK: 
+               continue;
+
+           case 0: 
+               break;
+
+           default: 
+               return OK;
+       }
+       break;
+    }
+    if (pid == NOTOK)
+       return NOTOK;
+    if ((fp = fopen (tty, "w")) == NULL)
+       _exit (1);
+    fprintf (fp, "\r\nmessage from %s:\r\n\007", from);
+    for (i = 0, bp = NULL; i < vecp; i++, bp = " ") {
+       if (bp)
+           fputs (bp, fp);
+       fputs (vec[i], fp);
+    }
+    fputs ("\r\n", fp);
+    (void) fclose (fp);
+    _exit (0);                 /* NOTREACHED */
+}
+
+/* \f */
+
+static int  op_data (sd, ryo, rox, in, roi)
+int    sd;
+struct RyOperation *ryo;
+struct RoSAPinvoke *rox;
+caddr_t        in;
+struct RoSAPindication *roi;
+{
+    if (rox -> rox_nolinked == 0) {
+       advise (LLOG_EXCEPTIONS, NULLCP,
+               "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
+               sd, ryo -> ryo_name, rox -> rox_linkid);
+       return ureject (sd, ROS_IP_LINKED, rox, roi);
+    }
+    if (debug)
+       advise (LLOG_DEBUG, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
+           sd, ryo -> ryo_name);
+
+    if (RyDsResult (sd, rox -> rox_id, ryo -> ryo_op == operation_IMISC_echo
+                           ? in : (caddr_t) NULL, ROS_NOPRIO, roi) == NOTOK)
+       ros_adios (&roi -> roi_preject, "RESULT");
+
+    return OK;
+}
+
+/* \f   ERROR */
+
+static int  error (sd, err, param, rox, roi)
+int    sd,
+       err;
+caddr_t        param;
+struct RoSAPinvoke *rox;
+struct RoSAPindication *roi;
+{
+    if (RyDsError (sd, rox -> rox_id, err, param, ROS_NOPRIO, roi) == NOTOK)
+       ros_adios (&roi -> roi_preject, "ERROR");
+
+    return OK;
+}
+
+/* \f   U-REJECT */
+
+static int  ureject (sd, reason, rox, roi)
+int    sd,
+       reason;
+struct RoSAPinvoke *rox;
+struct RoSAPindication *roi;
+{
+    if (RyDsUReject (sd, rox -> rox_id, reason, ROS_NOPRIO, roi) == NOTOK)
+       ros_adios (&roi -> roi_preject, "U-REJECT");
+
+    return OK;
+}
+
+/* \f   TYPES */
+
+struct type_IMISC_IA5List *str2ia5list (s)
+char   *s;
+{
+    register struct type_IMISC_IA5List *ia5;
+
+    if ((ia5 = (struct type_IMISC_IA5List  *) calloc (1, sizeof *ia5)) == NULL)
+       return NULL;
+
+    if ((ia5 -> IA5String = str2qb (s, strlen (s), 1)) == NULL) {
+       free ((char *) ia5);
+       return NULL;
+    }
+
+    return ia5;
+}
diff --git a/usr/src/contrib/isode/imisc/make b/usr/src/contrib/isode/imisc/make
new file mode 100644 (file)
index 0000000..d861596
--- /dev/null
@@ -0,0 +1,7 @@
+: run this script through /bin/sh
+M=/bin/make
+if [ -f /usr/bin/make ]; then
+    M=/usr/bin/make
+fi
+
+exec $M TOPDIR=../ -f ../config/CONFIG.make -f Makefile ${1+"$@"}
diff --git a/usr/src/contrib/isode/imisc/ryinitiator.c b/usr/src/contrib/isode/imisc/ryinitiator.c
new file mode 100644 (file)
index 0000000..2215fe8
--- /dev/null
@@ -0,0 +1,638 @@
+/* ryinitiator.c - generic interactive initiator */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/imisc/RCS/ryinitiator.c,v 7.6 91/02/22 09:26:25 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/imisc/RCS/ryinitiator.c,v 7.6 91/02/22 09:26:25 mrose Interim $
+ *
+ *
+ * $Log:       ryinitiator.c,v $
+ * Revision 7.6  91/02/22  09:26:25  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.5  90/12/23  18:41:55  mrose
+ * update
+ * 
+ * Revision 7.4  90/12/11  10:52:56  mrose
+ * lock-and-load
+ * 
+ * Revision 7.3  90/10/29  18:38:16  mrose
+ * updates
+ * 
+ * Revision 7.2  90/07/09  14:38:52  mrose
+ * sync
+ * 
+ * Revision 7.1  90/07/01  21:04:09  mrose
+ * pepsy
+ * 
+ * Revision 7.0  89/11/23  21:57:42  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <stdio.h>
+#include <varargs.h>
+#include "ryinitiator.h"
+
+#undef TIMER
+#undef TMS
+#ifdef BSD42
+#define        TIMER
+#endif
+#ifdef SYS5
+#define        TIMER
+#ifndef        HPUX
+#include <sys/times.h>
+#define        TMS
+#endif
+#endif
+
+/* \f   DATA */
+
+static int count = 1;
+int    length = 536;
+
+
+#ifdef TIMER
+#define        DS_RESULT(ds)   (timing ? timing_result : (ds) -> ds_result)
+
+static int timing = 0;
+
+int    timing_result ();
+#else
+#define        DS_RESULT(ds)   ((ds) -> ds_result)
+#endif
+
+static char *myname = "ryinitiator";
+
+
+extern char *isodeversion;
+
+/* \f   INITIATOR */
+
+/* ARGSUSED */
+
+ryinitiator (argc, argv, myservice, mycontext, mypci, ops, dispatches, quit)
+int    argc;
+char  **argv,
+       *myservice,
+       *mycontext,
+       *mypci;
+struct RyOperation ops[];
+struct dispatch *dispatches;
+IFP    quit;
+{
+    int            iloop,
+           sd;
+    register char  *cp,
+                 **ap;
+    char    buffer[BUFSIZ],
+          *vec[NVEC + 1];
+    register struct dispatch   *ds;
+    struct QOStype qos;
+    struct SSAPref sfs;
+    register struct SSAPref *sf;
+    register struct PSAPaddr *pa;
+    struct AcSAPconnect accs;
+    register struct AcSAPconnect   *acc = &accs;
+    struct AcSAPindication  acis;
+    register struct AcSAPindication *aci = &acis;
+    register struct AcSAPabort *aca = &aci -> aci_abort;
+    AEI            aei;
+    OID            ctx,
+           pci;
+    struct PSAPctxlist pcs;
+    register struct PSAPctxlist *pc = &pcs;
+    struct RoSAPindication rois;
+    register struct RoSAPindication *roi = &rois;
+    register struct RoSAPpreject *rop = &roi -> roi_preject;
+
+    if (myname = rindex (argv[0], '/'))
+       myname++;
+    if (myname == NULL || *myname == NULL)
+       myname = argv[0];
+
+    isodetailor (myname, 1);
+
+    qos.qos_reliability = HIGH_QUALITY;
+
+    for (ap = argv + 1; cp = *ap; ap++) {
+       if (*cp != '-')
+           break;
+
+       if (strcmp (cp, "-low") == 0) {
+           qos.qos_reliability = LOW_QUALITY;
+           continue;
+       }
+       if (strcmp (cp, "-high") == 0) {
+           qos.qos_reliability = HIGH_QUALITY;
+           continue;
+       }
+       if (strcmp (cp, "-c") == 0) {
+           if ((cp = *++ap) == NULL
+                   || sscanf (cp, "%d", &count) != 1
+                   || count < 1)
+               adios (NULLCP, "usage: %s -c count", myname);
+#ifdef TIMER
+           timing++;
+#endif
+           continue;
+       }
+       if (strcmp (cp, "-l") == 0) {
+           if ((cp = *++ap) == NULL
+                   || sscanf (cp, "%d", &length) != 1
+                   || length < 0)
+               adios (NULLCP, "usage: %s -l length", myname);
+           continue;
+       }
+
+       adios (NULLCP, "%s: unknown switch", cp);
+    }
+
+    if ((cp = *ap++) == NULL)
+       adios (NULLCP, "usage: %s host [operation [ arguments ... ]]", myname);
+       
+    if ((aei = _str2aei (cp, myservice, mycontext, *ap == NULL, NULLCP,
+                        NULLCP)) == NULLAEI)
+       adios (NULLCP, "unable to resolve service: %s", PY_pepy);
+    if ((pa = aei2addr (aei)) == NULLPA)
+       adios (NULLCP, "address translation failed");
+
+    if ((ctx = ode2oid (mycontext)) == NULLOID)
+       adios (NULLCP, "%s: unknown object descriptor", mycontext);
+    if ((ctx = oid_cpy (ctx)) == NULLOID)
+       adios (NULLCP, "out of memory");
+    if ((pci = ode2oid (mypci)) == NULLOID)
+       adios (NULLCP, "%s: unknown object descriptor", mypci);
+    if ((pci = oid_cpy (pci)) == NULLOID)
+       adios (NULLCP, "out of memory");
+    pc -> pc_nctx = 1;
+    pc -> pc_ctx[0].pc_id = 1;
+    pc -> pc_ctx[0].pc_asn = pci;
+    pc -> pc_ctx[0].pc_atn = NULLOID;
+
+    if ((sf = addr2ref (PLocalHostName ())) == NULL) {
+       sf = &sfs;
+       (void) bzero ((char *) sf, sizeof *sf);
+    }
+
+    if (*ap == NULL) {
+       printf ("%s", myname);
+       if (sf -> sr_ulen > 2)
+           printf (" running on host %s", sf -> sr_udata + 2);
+       if (sf -> sr_clen > 2)
+           printf (" at %s", sf -> sr_cdata + 2);
+       printf (" [%s, ", oid2ode (ctx));
+       printf ("%s]\n", oid2ode (pci));
+       printf ("using %s\n", isodeversion);
+
+       printf ("%s... ", cp);
+       (void) fflush (stdout);
+    
+       iloop = 1;
+    }
+    else {
+       cp = *ap++;
+       for (ds = dispatches; ds -> ds_name; ds++)
+           if (strcmp (ds -> ds_name, cp) == 0)
+               break;
+       if (ds -> ds_name == NULL)
+           adios (NULLCP, "unknown operation \"%s\"", cp);
+
+       iloop = 0;
+    }
+
+    if (AcAssocRequest (ctx, NULLAEI, aei, NULLPA, pa, pc, NULLOID,
+               0, ROS_MYREQUIRE, SERIAL_NONE, 0, sf, NULLPEP, 0, &qos,
+               acc, aci)
+           == NOTOK)
+       acs_adios (aca, "A-ASSOCIATE.REQUEST");
+
+    if (acc -> acc_result != ACS_ACCEPT) {
+       if (iloop)
+           printf ("failed\n");
+
+       adios (NULLCP, "association rejected: [%s]",
+               AcErrString (acc -> acc_result));
+    }
+    if (iloop) {
+       printf ("connected\n");
+       (void) fflush (stdout);
+    }
+
+    sd = acc -> acc_sd;
+    ACCFREE (acc);
+
+    if (RoSetService (sd, RoPService, roi) == NOTOK)
+       ros_adios (rop, "set RO/PS fails");
+
+    if (iloop) {
+       for (;;) {
+           if (getline (buffer) == NOTOK)
+               break;
+
+           if (str2vec (buffer, vec) < 1)
+               continue;
+
+           for (ds = dispatches; ds -> ds_name; ds++)
+               if (strcmp (ds -> ds_name, vec[0]) == 0)
+                   break;
+           if (ds -> ds_name == NULL) {
+               advise (NULLCP, "unknown operation \"%s\"", vec[0]);
+               continue;
+           }
+
+           invoke (sd, ops, ds, vec + 1);
+       }
+    }
+    else
+       invoke (sd, ops, ds, ap);
+
+    (*quit) (sd, (struct dispatch *) NULL, (char **) NULL, (caddr_t *) NULL);
+}
+
+/* \f   INVOKE */
+
+static invoke (sd, ops, ds, args)
+int    sd;
+struct RyOperation ops[];
+register struct dispatch *ds;
+char  **args;
+{
+    register int    i;
+    int            cc,
+           result;
+    caddr_t in;
+    struct RoSAPindication  rois;
+    register struct RoSAPindication *roi = &rois;
+    register struct RoSAPpreject   *rop = &roi -> roi_preject;
+
+    in = NULL;
+    if (ds -> ds_argument && (*ds -> ds_argument) (sd, ds, args, &in) == NOTOK)
+       return;
+
+#ifdef TIMER
+    if (timing) {
+       register struct RyOperation *ryo = ops;
+       PE      pe;
+
+       cc = 0;
+
+       for (; ryo -> ryo_name; ryo++)
+           if (ryo -> ryo_op == ds -> ds_operation)
+               break;
+       if (!ryo -> ryo_name || !ryo -> ryo_arg_mod)
+           goto nope;
+
+       pe = NULLPE;
+       if (enc_f (ryo -> ryo_arg_index, ryo -> ryo_arg_mod, &pe, 1, NULL,
+                  NULLCP, in) != NOTOK)
+           cc = ps_get_abs (pe);
+       if (pe)
+           pe_free (pe);
+
+nope: ;
+       timer (0, 0);
+    }
+#endif
+
+    for (i = 0; i < count; i++)
+       switch (result = RyStub (sd, ops, ds -> ds_operation, RyGenID (sd),
+                                NULLIP, in, DS_RESULT (ds), ds -> ds_error,
+                                ROS_SYNC, roi)) {
+           case NOTOK:         /* failure */
+               if (ROS_FATAL (rop -> rop_reason))
+                   ros_adios (rop, "STUB");
+               ros_advise (rop, "STUB");
+               goto out;
+
+           case OK:            /* got a result/error response */
+               break;
+
+           case DONE:          /* got RO-END? */
+               adios (NULLCP, "got RO-END.INDICATION");
+               /* NOTREACHED */
+
+           default:
+               adios (NULLCP, "unknown return from RyStub=%d", result);
+               /* NOTREACHED */
+       }
+
+#ifdef TIMER
+    if (timing)
+       timer (cc, count);
+#endif
+
+out: ;
+    if (ds -> ds_fr_mod && in)
+       (void) fre_obj (in, ds -> ds_fr_mod -> md_dtab[ds -> ds_fr_index],
+                       ds -> ds_fr_mod, 1);
+}
+
+/* \f   INTERACTIVE */
+
+static int  getline (buffer)
+char   *buffer;
+{
+    register int    i;
+    register char  *cp,
+                   *ep;
+    static int  sticky = 0;
+
+    if (sticky) {
+       sticky = 0;
+       return NOTOK;
+    }
+
+    printf ("%s> ", myname);
+    (void) fflush (stdout);
+
+    for (ep = (cp = buffer) + BUFSIZ - 1; (i = getchar ()) != '\n';) {
+       if (i == EOF) {
+           printf ("\n");
+           clearerr (stdin);
+           if (cp != buffer) {
+               sticky++;
+               break;
+           }
+
+           return NOTOK;
+       }
+
+       if (cp < ep)
+           *cp++ = i;
+    }
+    *cp = NULL;
+
+    return OK;
+}
+
+/* \f   TIMER */
+
+#ifdef TIMER
+
+#ifndef        NBBY
+#define        NBBY    8
+#endif
+
+
+#ifndef        TMS
+static  timer (bytes, pkts)
+int     bytes,
+       pkts;
+{
+    long    ms;
+    float   bs,
+           ps;
+    struct timeval  stop,
+                    td;
+    static struct timeval   start;
+
+    if (pkts == 0) {
+       (void) gettimeofday (&start, (struct timezone *) 0);
+       return;
+    }
+    else
+       (void) gettimeofday (&stop, (struct timezone  *) 0);
+
+    tvsub (&td, &stop, &start);
+    ms = (td.tv_sec * 1000) + (td.tv_usec / 1000);
+    bs = (((float) bytes * pkts * NBBY * 1000) / (float) (ms ? ms : 1)) / NBBY;
+    ps = ((float) pkts * 1000) / (float) (ms ? ms : 1);
+
+    printf ("%d operations in %d.%02d seconds (%.2f ops/s)",
+           pkts, td.tv_sec, td.tv_usec / 10000, ps);
+    if (bytes > 0)
+       printf ("; %d bytes/op for %.2f Kbytes/s", bytes, bs / 1024);
+    printf ("\n");
+}
+
+
+static  tvsub (tdiff, t1, t0)
+register struct timeval *tdiff,
+                       *t1,
+                       *t0;
+{
+
+    tdiff -> tv_sec = t1 -> tv_sec - t0 -> tv_sec;
+    tdiff -> tv_usec = t1 -> tv_usec - t0 -> tv_usec;
+    if (tdiff -> tv_usec < 0)
+       tdiff -> tv_sec--, tdiff -> tv_usec += 1000000;
+}
+#else
+long   times ();
+
+
+static timer (bytes, pkts)
+int    bytes,
+       pkts;
+{
+    long    ms;
+    float   bs,
+           ps;
+    long    stop,
+           td,
+           secs,
+           msecs;
+    struct tms tm;
+    static long start;
+
+    if (pkts == 0) {
+       start = times (&tm);
+       return;
+    }
+    else
+       stop = times (&tm);
+
+    td = stop - start;
+    secs = td / 60, msecs = (td % 60) * 1000 / 60;
+    ms = (secs * 1000) +  msecs;
+    bs = (((float) bytes * pkts * NBBY * 1000) / (float) (ms ? ms : 1)) / NBBY;
+    ps = ((float) pkts * 1000) / (float) (ms ? ms : 1);
+
+    printf ("%d operations in %d.%02d seconds (%.2f ops/s)",
+           pkts, secs, msecs / 10, ps);
+    if (bytes > 0)
+       printf ("; %d bytes/op for %.2f Kbytes/s", bytes, bs / 1024);
+    printf ("\n");
+}
+#endif
+#endif
+
+/* \f */
+
+/* ARGSUSED */
+
+static int    timing_result (sd, id, dummy, result, roi)
+int    sd,
+       id,
+       dummy;
+caddr_t result;
+struct RoSAPindication *roi;
+{
+    return OK;
+}
+
+/* \f   ERRORS */
+
+void   ros_adios (rop, event)
+register struct RoSAPpreject *rop;
+char   *event;
+{
+    ros_advise (rop, event);
+
+    _exit (1);
+}
+
+
+void   ros_advise (rop, event)
+register struct RoSAPpreject *rop;
+char   *event;
+{
+    char    buffer[BUFSIZ];
+
+    if (rop -> rop_cc > 0)
+       (void) sprintf (buffer, "[%s] %*.*s", RoErrString (rop -> rop_reason),
+               rop -> rop_cc, rop -> rop_cc, rop -> rop_data);
+    else
+       (void) sprintf (buffer, "[%s]", RoErrString (rop -> rop_reason));
+
+    advise (NULLCP, "%s: %s", event, buffer);
+}
+
+/* \f */
+
+void   acs_adios (aca, event)
+register struct AcSAPabort *aca;
+char   *event;
+{
+    acs_advise (aca, event);
+
+    _exit (1);
+}
+
+
+void   acs_advise (aca, event)
+register struct AcSAPabort *aca;
+char   *event;
+{
+    char    buffer[BUFSIZ];
+
+    if (aca -> aca_cc > 0)
+       (void) sprintf (buffer, "[%s] %*.*s",
+               AcErrString (aca -> aca_reason),
+               aca -> aca_cc, aca -> aca_cc, aca -> aca_data);
+    else
+       (void) sprintf (buffer, "[%s]", AcErrString (aca -> aca_reason));
+
+       advise (NULLCP, "%s: %s (source %d)", event, buffer,
+               aca -> aca_source);
+}
+
+/* \f */
+
+#ifndef        lint
+void   _advise ();
+
+
+void   adios (va_alist)
+va_dcl
+{
+    va_list ap;
+
+    va_start (ap);
+
+    _advise (ap);
+
+    va_end (ap);
+
+    _exit (1);
+}
+#else
+/* VARARGS */
+
+void   adios (what, fmt)
+char   *what,
+       *fmt;
+{
+    adios (what, fmt);
+}
+#endif
+
+
+#ifndef        lint
+void   advise (va_alist)
+va_dcl
+{
+    va_list ap;
+
+    va_start (ap);
+
+    _advise (ap);
+
+    va_end (ap);
+}
+
+
+static void  _advise (ap)
+va_list        ap;
+{
+    char    buffer[BUFSIZ];
+
+    asprintf (buffer, ap);
+
+    (void) fflush (stdout);
+
+    fprintf (stderr, "%s: ", myname);
+    (void) fputs (buffer, stderr);
+    (void) fputc ('\n', stderr);
+
+    (void) fflush (stderr);
+}
+#else
+/* VARARGS */
+
+void   advise (what, fmt)
+char   *what,
+       *fmt;
+{
+    advise (what, fmt);
+}
+#endif
+
+
+#ifndef        lint
+void   ryr_advise (va_alist)
+va_dcl
+{
+    va_list ap;
+
+    va_start (ap);
+
+    _advise (ap);
+
+    va_end (ap);
+}
+#else
+/* VARARGS */
+
+void   ryr_advise (what, fmt)
+char   *what,
+       *fmt;
+{
+    ryr_advise (what, fmt);
+}
+#endif
diff --git a/usr/src/contrib/isode/imisc/ryinitiator.h b/usr/src/contrib/isode/imisc/ryinitiator.h
new file mode 100644 (file)
index 0000000..67e64fb
--- /dev/null
@@ -0,0 +1,55 @@
+/* ryinitiator.h - include file for the generic interactive initiator */
+
+/* 
+ * $Header: /f/osi/imisc/RCS/ryinitiator.h,v 7.2 91/02/22 09:26:26 mrose Interim $
+ *
+ *
+ * $Log:       ryinitiator.h,v $
+ * Revision 7.2  91/02/22  09:26:26  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.1  90/07/01  21:04:12  mrose
+ * pepsy
+ * 
+ * Revision 7.0  89/11/23  21:57:44  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#ifndef PEPSY_VERSION
+#define PEPSY_VERSION 1
+#endif
+#include "rosy.h"
+
+
+static struct dispatch {
+    char   *ds_name;
+    int            ds_operation;
+
+    IFP            ds_argument;
+    modtyp *ds_fr_mod;        /* pointer to table for arguement type */
+    int     ds_fr_index;      /* index to entry in tables */
+
+    IFP            ds_result;
+    IFP            ds_error;
+
+    char   *ds_help;
+};
+
+
+void   adios (), advise ();
+void   acs_adios (), acs_advise ();
+void   ros_adios (), ros_advise ();
+
+int    ryinitiator ();
diff --git a/usr/src/contrib/isode/imisc/ryresponder.c b/usr/src/contrib/isode/imisc/ryresponder.c
new file mode 100644 (file)
index 0000000..ca8e89e
--- /dev/null
@@ -0,0 +1,445 @@
+/* ryresponder.c - generic idempotent responder */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/imisc/RCS/ryresponder.c,v 7.3 91/02/22 09:26:27 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/imisc/RCS/ryresponder.c,v 7.3 91/02/22 09:26:27 mrose Interim $
+ *
+ *
+ * $Log:       ryresponder.c,v $
+ * Revision 7.3  91/02/22  09:26:27  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.2  90/12/11  10:52:58  mrose
+ * lock-and-load
+ * 
+ * Revision 7.1  90/07/09  14:38:54  mrose
+ * sync
+ * 
+ * Revision 7.0  89/11/23  21:57:44  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <stdio.h>
+#include <setjmp.h>
+#include <varargs.h>
+#include "ryresponder.h"
+#include "tsap.h"              /* for listening */
+#include "tailor.h"
+
+/* \f   DATA */
+
+int    debug = 0;
+
+static LLog _pgm_log = {
+    "responder.log", NULLCP, NULLCP,
+    LLOG_FATAL | LLOG_EXCEPTIONS | LLOG_NOTICE, LLOG_FATAL, -1,
+    LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+LLog *pgm_log = &_pgm_log;
+
+static char *myname = "ryresponder";
+
+
+static jmp_buf toplevel;
+
+
+static IFP     startfnx;
+static IFP     stopfnx;
+
+int    ros_init (), ros_work (), ros_indication (), ros_lose ();
+
+
+extern int  errno;
+
+/* \f   RESPONDER */
+
+ryresponder (argc, argv, host, myservice, mycontext, dispatches, ops,
+            start, stop)
+int    argc;
+char  **argv,
+       *host,
+       *myservice,
+       *mycontext;
+struct dispatch *dispatches;
+struct RyOperation *ops;
+IFP    start,
+       stop;
+{
+    register struct dispatch   *ds;
+    AEI            aei;
+    struct TSAPdisconnect   tds;
+    struct TSAPdisconnect  *td = &tds;
+    struct RoSAPindication  rois;
+    register struct RoSAPindication *roi = &rois;
+    register struct RoSAPpreject   *rop = &roi -> roi_preject;
+
+    if (myname = rindex (argv[0], '/'))
+       myname++;
+    if (myname == NULL || *myname == NULL)
+       myname = argv[0];
+
+    isodetailor (myname, 0);
+    if (debug = isatty (fileno (stderr)))
+       ll_dbinit (pgm_log, myname);
+    else {
+       static char  myfile[BUFSIZ];
+
+       (void) sprintf (myfile, "%s.log",
+                       (strncmp (myname, "ros.", 4)                    
+                                   && strncmp (myname, "lpp.", 4))
+                               || myname[4] == NULL
+                           ? myname : myname + 4);
+       pgm_log -> ll_file = myfile;
+       ll_hdinit (pgm_log, myname);
+    }
+
+    advise (LLOG_NOTICE, NULLCP, "starting");
+
+    if ((aei = _str2aei (host, myservice, mycontext, 0, NULLCP, NULLCP))
+           == NULLAEI)
+       adios (NULLCP, "unable to resolve service: %s", PY_pepy);
+
+    for (ds = dispatches; ds -> ds_name; ds++)
+       if (RyDispatch (NOTOK, ops, ds -> ds_operation, ds -> ds_vector, roi)
+               == NOTOK)
+           ros_adios (rop, ds -> ds_name);
+
+    startfnx = start;
+    stopfnx = stop;
+
+    if (isodeserver (argc, argv, aei, ros_init, ros_work, ros_lose, td)
+           == NOTOK) {
+       if (td -> td_cc > 0)
+           adios (NULLCP, "isodeserver: [%s] %*.*s",
+                   TErrString (td -> td_reason),
+                   td -> td_cc, td -> td_cc, td -> td_data);
+       else
+           adios (NULLCP, "isodeserver: [%s]",
+                   TErrString (td -> td_reason));
+    }
+
+    exit (0);
+}
+
+/* \f */
+
+static int  ros_init (vecp, vec)
+int    vecp;
+char  **vec;
+{
+    int            reply,
+           result,
+           sd;
+    struct AcSAPstart   acss;
+    register struct AcSAPstart *acs = &acss;
+    struct AcSAPindication  acis;
+    register struct AcSAPindication *aci = &acis;
+    register struct AcSAPabort   *aca = &aci -> aci_abort;
+    register struct PSAPstart *ps = &acs -> acs_start;
+    struct RoSAPindication  rois;
+    register struct RoSAPindication *roi = &rois;
+    register struct RoSAPpreject   *rop = &roi -> roi_preject;
+
+    if (AcInit (vecp, vec, acs, aci) == NOTOK) {
+       acs_advise (aca, "initialization fails");
+       return NOTOK;
+    }
+    advise (LLOG_NOTICE, NULLCP,
+               "A-ASSOCIATE.INDICATION: <%d, %s, %s, %s, %d>",
+               acs -> acs_sd, oid2ode (acs -> acs_context),
+               sprintaei (&acs -> acs_callingtitle),
+               sprintaei (&acs -> acs_calledtitle), acs -> acs_ninfo);
+
+    sd = acs -> acs_sd;
+
+    for (vec++; *vec; vec++)
+       advise (LLOG_EXCEPTIONS, NULLCP, "unknown argument \"%s\"", *vec);
+
+    reply = startfnx ? (*startfnx) (sd, acs) : ACS_ACCEPT;
+
+    result = AcAssocResponse (sd, reply,
+               reply != ACS_ACCEPT ? ACS_USER_NOREASON : ACS_USER_NULL,
+               NULLOID, NULLAEI, NULLPA, NULLPC, ps -> ps_defctxresult,
+               ps -> ps_prequirements, ps -> ps_srequirements, SERIAL_NONE,
+               ps -> ps_settings, &ps -> ps_connect, NULLPEP, 0, aci);
+
+    ACSFREE (acs);
+
+    if (result == NOTOK) {
+       acs_advise (aca, "A-ASSOCIATE.RESPONSE");
+       return NOTOK;
+    }
+    if (reply != ACS_ACCEPT)
+       return NOTOK;
+
+    if (RoSetService (sd, RoPService, roi) == NOTOK)
+       ros_adios (rop, "set RO/PS fails");
+
+    return sd;
+}
+
+/* \f */
+
+static int  ros_work (fd)
+int    fd;
+{
+    int            result;
+    caddr_t out;
+    struct AcSAPindication  acis;
+    struct RoSAPindication  rois;
+    register struct RoSAPindication *roi = &rois;
+    register struct RoSAPpreject   *rop = &roi -> roi_preject;
+
+    switch (setjmp (toplevel)) {
+       case OK: 
+           break;
+
+       default: 
+           if (stopfnx)
+               (*stopfnx) (fd, (struct AcSAPfinish *) 0);
+       case DONE:
+           (void) AcUAbortRequest (fd, NULLPEP, 0, &acis);
+           (void) RyLose (fd, roi);
+           return NOTOK;
+    }
+
+    switch (result = RyWait (fd, NULLIP, &out, OK, roi)) {
+       case NOTOK: 
+           if (rop -> rop_reason == ROS_TIMER)
+               break;
+       case OK: 
+       case DONE: 
+           ros_indication (fd, roi);
+           break;
+
+       default: 
+           adios (NULLCP, "unknown return from RoWaitRequest=%d", result);
+    }
+
+    return OK;
+}
+
+/* \f */
+
+static int ros_indication (sd, roi)
+int    sd;
+register struct RoSAPindication *roi;
+{
+    int            reply,
+           result;
+
+    switch (roi -> roi_type) {
+       case ROI_INVOKE: 
+       case ROI_RESULT: 
+       case ROI_ERROR: 
+           adios (NULLCP, "unexpected indication type=%d", roi -> roi_type);
+           break;
+
+       case ROI_UREJECT: 
+           {
+               register struct RoSAPureject   *rou = &roi -> roi_ureject;
+
+               if (rou -> rou_noid)
+                   advise (LLOG_EXCEPTIONS, NULLCP,
+                           "RO-REJECT-U.INDICATION/%d: %s",
+                           sd, RoErrString (rou -> rou_reason));
+               else
+                   advise (LLOG_EXCEPTIONS, NULLCP,
+                           "RO-REJECT-U.INDICATION/%d: %s (id=%d)",
+                           sd, RoErrString (rou -> rou_reason),
+                           rou -> rou_id);
+           }
+           break;
+
+       case ROI_PREJECT: 
+           {
+               register struct RoSAPpreject   *rop = &roi -> roi_preject;
+
+               if (ROS_FATAL (rop -> rop_reason))
+                   ros_adios (rop, "RO-REJECT-P.INDICATION");
+               ros_advise (rop, "RO-REJECT-P.INDICATION");
+           }
+           break;
+
+       case ROI_FINISH: 
+           {
+               register struct AcSAPfinish *acf = &roi -> roi_finish;
+               struct AcSAPindication  acis;
+               register struct AcSAPabort *aca = &acis.aci_abort;
+
+               advise (LLOG_NOTICE, NULLCP, "A-RELEASE.INDICATION/%d: %d",
+                       sd, acf -> acf_reason);
+
+               reply = stopfnx ? (*stopfnx) (sd, acf) : ACS_ACCEPT;
+
+               result = AcRelResponse (sd, reply, ACR_NORMAL, NULLPEP, 0,
+                           &acis);
+
+               ACFFREE (acf);
+
+               if (result == NOTOK)
+                   acs_advise (aca, "A-RELEASE.RESPONSE");
+               else
+                   if (reply != ACS_ACCEPT)
+                       break;
+               longjmp (toplevel, DONE);
+           }
+       /* NOTREACHED */
+
+       default: 
+           adios (NULLCP, "unknown indication type=%d", roi -> roi_type);
+    }
+}
+
+/* \f */
+
+static int  ros_lose (td)
+struct TSAPdisconnect *td;
+{
+    if (td -> td_cc > 0)
+       adios (NULLCP, "TNetAccept: [%s] %*.*s",
+               TErrString (td -> td_reason), td -> td_cc, td -> td_cc,
+               td -> td_data);
+    else
+       adios (NULLCP, "TNetAccept: [%s]", TErrString (td -> td_reason));
+}
+
+/* \f   ERRORS */
+
+void   ros_adios (rop, event)
+register struct RoSAPpreject *rop;
+char   *event;
+{
+    ros_advise (rop, event);
+
+    longjmp (toplevel, NOTOK);
+}
+
+
+void   ros_advise (rop, event)
+register struct RoSAPpreject *rop;
+char   *event;
+{
+    char    buffer[BUFSIZ];
+
+    if (rop -> rop_cc > 0)
+       (void) sprintf (buffer, "[%s] %*.*s", RoErrString (rop -> rop_reason),
+               rop -> rop_cc, rop -> rop_cc, rop -> rop_data);
+    else
+       (void) sprintf (buffer, "[%s]", RoErrString (rop -> rop_reason));
+
+    advise (LLOG_EXCEPTIONS, NULLCP, "%s: %s", event, buffer);
+}
+
+/* \f */
+
+void   acs_advise (aca, event)
+register struct AcSAPabort *aca;
+char   *event;
+{
+    char    buffer[BUFSIZ];
+
+    if (aca -> aca_cc > 0)
+       (void) sprintf (buffer, "[%s] %*.*s",
+               AcErrString (aca -> aca_reason),
+               aca -> aca_cc, aca -> aca_cc, aca -> aca_data);
+    else
+       (void) sprintf (buffer, "[%s]", AcErrString (aca -> aca_reason));
+
+    advise (LLOG_EXCEPTIONS, NULLCP, "%s: %s (source %d)", event, buffer,
+               aca -> aca_source);
+}
+
+/* \f */
+
+#ifndef        lint
+void   adios (va_alist)
+va_dcl
+{
+    va_list ap;
+
+    va_start (ap);
+    
+    _ll_log (pgm_log, LLOG_FATAL, ap);
+
+    va_end (ap);
+
+    _exit (1);
+}
+#else
+/* VARARGS2 */
+
+void   adios (what, fmt)
+char   *what,
+       *fmt;
+{
+    adios (what, fmt);
+}
+#endif
+
+
+#ifndef        lint
+void   advise (va_alist)
+va_dcl
+{
+    int            code;
+    va_list ap;
+
+    va_start (ap);
+    
+    code = va_arg (ap, int);
+
+    _ll_log (pgm_log, code, ap);
+
+    va_end (ap);
+}
+#else
+/* VARARGS3 */
+
+void   advise (code, what, fmt)
+char   *what,
+       *fmt;
+int    code;
+{
+    advise (code, what, fmt);
+}
+#endif
+
+
+#ifndef        lint
+void   ryr_advise (va_alist)
+va_dcl
+{
+    va_list ap;
+
+    va_start (ap);
+    
+    _ll_log (pgm_log, LLOG_NOTICE, ap);
+
+    va_end (ap);
+}
+#else
+/* VARARGS2 */
+
+void   ryr_advise (what, fmt)
+char   *what,
+       *fmt;
+{
+    ryr_advise (what, fmt);
+}
+#endif
diff --git a/usr/src/contrib/isode/imisc/ryresponder.h b/usr/src/contrib/isode/imisc/ryresponder.h
new file mode 100644 (file)
index 0000000..a19b20c
--- /dev/null
@@ -0,0 +1,53 @@
+/* ryresponder.h - include file for the generic idempotent responder */
+
+/* 
+ * $Header: /f/osi/imisc/RCS/ryresponder.h,v 7.2 91/02/22 09:26:29 mrose Interim $
+ *
+ *
+ * $Log:       ryresponder.h,v $
+ * Revision 7.2  91/02/22  09:26:29  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.1  90/07/01  21:04:13  mrose
+ * pepsy
+ * 
+ * Revision 7.0  89/11/23  21:57:46  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#ifndef PEPSY_VERSION
+#define PEPSY_VERSION 1
+#endif
+#include "rosy.h"
+#include "logger.h"
+
+
+static struct dispatch {
+    char   *ds_name;
+    int            ds_operation;
+
+    IFP            ds_vector;
+};
+
+
+void   adios (), advise ();
+void   acs_advise ();
+void   ros_adios (), ros_advise ();
+void   ryr_advise ();
+
+int    ryresponder ();
+
+
+extern int  debug;
diff --git a/usr/src/contrib/isode/others/Makefile b/usr/src/contrib/isode/others/Makefile
new file mode 100644 (file)
index 0000000..222298c
--- /dev/null
@@ -0,0 +1,85 @@
+###############################################################################
+#   Instructions to Make, for compilation of other ISODE programs
+###############################################################################
+
+###############################################################################
+#
+# $Header: /f/osi/others/RCS/Makefile,v 7.5 91/02/22 09:26:31 mrose Interim $
+#
+#
+# $Log:        Makefile,v $
+# Revision 7.5  91/02/22  09:26:31  mrose
+# Interim 6.8
+# 
+# Revision 7.4  90/12/23  18:41:58  mrose
+# update
+# 
+# Revision 7.3  90/12/11  10:55:18  mrose
+# lock-and-load
+# 
+# Revision 7.2  90/07/09  14:38:58  mrose
+# sync
+# 
+# Revision 7.1  90/01/16  20:43:52  mrose
+# last check-out
+# 
+# Revision 7.0  89/11/23  21:57:58  mrose
+# Release 6.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.
+#
+###############################################################################
+
+
+DIRS   =       quipu/photo quipu/image mosy tsbridge
+
+OTHERS =       callback idist listen lookup ntp osilookup pingpong quipu rfa \
+                       rtf tp0bridge 
+
+
+##################################################################
+# Here it is...
+##################################################################
+
+all:;          @for i in $(DIRS); \
+                   do (echo "cd $$i; $(MAKE) all"; \
+                             cd $$i; $(MAKE) all); \
+                   done
+               cd quipu/photo; $(MAKE) Xphoto xfax
+               cd quipu; $(MAKE) pilot
+
+inst-all:;     @for i in $(DIRS); \
+                   do (echo "cd $$i; $(MAKE) inst-all"; \
+                             cd $$i; $(MAKE) inst-all); \
+                   done
+               cd quipu; $(MAKE) inst-pilot
+
+install:;      @for i in $(DIRS); \
+                   do (echo "cd $$i; $(MAKE) install"; \
+                             cd $$i; $(MAKE) install); \
+                   done
+
+lint:;         @for i in $(DIRS); \
+                   do (echo "cd $$i; $(MAKE) lint"; \
+                             cd $$i; $(MAKE) lint); \
+                   done
+
+clean:;                rm -f _*
+               @for i in $(DIRS) $(OTHERS); \
+                   do (echo "cd $$i; $(MAKE) clean"; \
+                             cd $$i; $(MAKE) clean); \
+                   done
+
+grind:;                @for i in $(DIRS); \
+                   do (echo "cd $$i; $(MAKE) grind"; \
+                             cd $$i; $(MAKE) grind); \
+                   done
diff --git a/usr/src/contrib/isode/others/READ-ME b/usr/src/contrib/isode/others/READ-ME
new file mode 100644 (file)
index 0000000..c9f00e1
--- /dev/null
@@ -0,0 +1,82 @@
+[ READ-ME - Fri Dec 21 18:22:14 1990 - Comments on others/ - /mtr ]
+
+
+     None of the programs which live under this directory need be
+     installed.  They are provided only in the case what you are
+     interested in trying the code out.
+
+
+X/             X-protocol onto the ISO Transport Service
+
+       Experimental.
+
+
+callback/      The ISODE callback demo
+
+       Used to demonstrate listening and dual session connections.
+
+
+idist/         ISODE idist utility
+
+       Just like the 4.3BSD rdist, but uses OSI
+
+
+listen/                The ISODE listen demo
+
+       Used to demonstrate network listening.
+
+
+lookup/                The ISODE password lookup demo
+
+       Described in the User's Manual, volume 4.
+
+
+mosy/          Managed Object Syntax-compiler (yacc-based)
+
+       An ASN.1 compiler that understand the OBJECT-TYPE macro used in
+       the Internet standard SMI.
+
+
+ntp/           NTP over OSI
+
+       The popular network time protocol mapped onto OSI remote
+       operations.
+
+
+osilookup/     ISODE/SunLink OSI conversion
+
+       A program to convert entries from the /etc/osi.hosts file into
+       network addresses formatted for the isoentities file.
+
+
+pingpong/      Asynchronous connection establishment
+
+       A program to test out the async connection establishment code.
+
+
+quipu/ Utility directory for the QUIPU Directory.
+
+        ...
+
+
+rfa/           Remote File Access
+
+       Access and Management for a partial file system tree that exists
+       at two side either as master files or slave files.
+
+
+rtf/           RT-file transfer utility
+
+       A simple file transfer utility which tests the new upcall
+       mechanisms in RTS.
+
+
+tsbridge/      ISODE TSB
+
+       A real transport service bridge.
+
+
+tp0bridge/     ISODE TCP/X.25 TP0 bridge
+
+       Permits a dual-stack host to gateway TP0 packets between a TCP
+       internet and an X.25 subnet.
diff --git a/usr/src/contrib/isode/others/callback/Makefile b/usr/src/contrib/isode/others/callback/Makefile
new file mode 100644 (file)
index 0000000..94b0c1f
--- /dev/null
@@ -0,0 +1,133 @@
+###############################################################################
+#   Instructions to Make, for compilation of the ISODE callback demo
+###############################################################################
+
+###############################################################################
+#
+# $Header: /f/osi/others/callback/RCS/Makefile,v 7.2 91/02/22 09:26:35 mrose Interim $
+#
+#
+# $Log:        Makefile,v $
+# Revision 7.2  91/02/22  09:26:35  mrose
+# Interim 6.8
+# 
+# Revision 7.1  90/12/23  18:44:12  mrose
+# update
+# 
+# Revision 7.0  89/11/23  21:58:09  mrose
+# Release 6.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.
+#
+###############################################################################
+
+
+###############################################################################
+# Options
+###############################################################################
+
+BINDIR =       /usr/new/
+
+
+###############################################################################
+# Generation Rules for program modules
+###############################################################################
+
+.c.o:;         $(CC) $(CFLAGS) -c $*.c
+
+
+###############################################################################
+# Programs and Libraries
+###############################################################################
+
+LIBES  =       $(TOPDIR)libisode.a
+LLIBS   =      $(TOPDIR)llib-lisode
+
+
+###############################################################################
+# Files
+###############################################################################
+
+HFILES =       callback.h
+CFILES =       initiator.c responder.c report.c
+
+
+##################################################################
+# Here it is...
+##################################################################
+
+all:           initiator responder
+inst-all:      inst-initiator inst-responder
+install:       inst-all clean
+lint:          l-initiator l-responder
+
+
+##################################################################
+# initiator
+##################################################################
+
+inst-initiator:        $(BINDIR)callback
+
+$(BINDIR)callback:     xinitiator
+               -cp $@ zcallback
+               -rm -f $@
+               cp xinitiator $@
+               -@ls -gls $@
+               -@echo ""
+
+initiator:     xinitiator
+
+xinitiator:    initiator.o report.o
+               $(LDCC) $(LDFLAGS) -o $@ initiator.o report.o $(LIBES) \
+                       $(LSOCKET)
+
+l-initiator:;  $(LINT) $(LFLAGS) initiator.c report.c $(LLIBS) \
+                       | grep -v "warning: possible pointer alignment problem"
+
+initiator.o:   $(HFILES)
+
+
+##################################################################
+# responder
+##################################################################
+
+inst-responder:        $(SBINDIR)iso.callback
+
+$(SBINDIR)iso.callback:        xresponder
+               -cp $@ ziso.callback
+               -rm -f $@
+               cp xresponder $@
+               -@ls -gls $@
+               -@echo ""
+
+responder:     xresponder
+
+xresponder:    responder.o report.o
+               $(LDCC) $(LDFLAGS)  -o $@ responder.o report.o $(LIBES) \
+                       $(LSOCKET)
+
+l-responder:;  $(LINT) $(LFLAGS) responder.c report.c $(LLIBS) \
+                       | grep -v "warning: possible pointer alignment problem"
+
+responder.o:   $(HFILES)
+
+
+##################################################################
+# clean
+##################################################################
+
+clean:;                rm -f *.o x* z* _* core 
+
+grind:;                iprint Makefile
+               tgrind -lc $(HFILES) $(CFILES)
+
+true:;
diff --git a/usr/src/contrib/isode/others/callback/READ-ME b/usr/src/contrib/isode/others/callback/READ-ME
new file mode 100644 (file)
index 0000000..5852ed0
--- /dev/null
@@ -0,0 +1,5 @@
+[ READ-ME - Sun Feb 14 08:12:18 1988 - ISODE callback demo notes - /mtr ]
+
+
+     This is just a simple demonstration of network listening and multiple
+     session connections.
diff --git a/usr/src/contrib/isode/others/callback/callback.h b/usr/src/contrib/isode/others/callback/callback.h
new file mode 100644 (file)
index 0000000..b2c1795
--- /dev/null
@@ -0,0 +1,51 @@
+/* callback.h - callback demo definitions */
+
+/* 
+ * $Header: /f/osi/others/callback/RCS/callback.h,v 7.1 91/02/22 09:26:37 mrose Interim $
+ *
+ *
+ * $Log:       callback.h,v $
+ * Revision 7.1  91/02/22  09:26:37  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.0  89/11/23  21:58:11  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include "psap2.h"
+#include "ssap.h"
+#include "tsap.h"
+#include "logger.h"
+
+#define        RMASK \
+    "\020\01HALFDUPLEX\02DUPLEX\03EXPEDITED\04MINORSYNC\05MAJORSYNC\06RESYNC\
+\07ACTIVITY\010NEGOTIATED\011CAPABILITY\012EXCEPTIONS\013TYPEDATA"
+
+
+typedef struct sblk {
+    int            sb_sd;              /* session-descriptor */
+
+    struct SSAPref sb_connect; /* session connection reference */
+
+    int            sb_requirements;    /* session requirements */
+    int            sb_settings;        /* initial settings */
+    int            sb_owned;           /* session tokens we own */
+
+    long    sb_ssn;            /* session serial number */
+    long    sb_isn;            /* initial serial number */
+}              *SB;
+
+
+void   adios (), advise ();
diff --git a/usr/src/contrib/isode/others/callback/initiator.c b/usr/src/contrib/isode/others/callback/initiator.c
new file mode 100644 (file)
index 0000000..9e976ac
--- /dev/null
@@ -0,0 +1,233 @@
+/* initiator.c -- initiator for callback demo */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/others/callback/RCS/initiator.c,v 7.1 91/02/22 09:26:38 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/others/callback/RCS/initiator.c,v 7.1 91/02/22 09:26:38 mrose Interim $
+ *
+ *
+ * $Log:       initiator.c,v $
+ * Revision 7.1  91/02/22  09:26:38  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.0  89/11/23  21:58:11  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <stdio.h>
+#include "callback.h"
+
+/* \f */
+
+static char *mycontext = "isode callback demo";
+
+/* \f */
+
+/* ARGSUSED */
+
+main (argc, argv, envp)
+int    argc;
+char  **argv,
+      **envp;
+{
+    int            vecp;
+    char   *taddr,
+          *vec[4];
+    struct TSAPaddr *ta;
+    struct TSAPdisconnect tds;
+    struct TSAPdisconnect *td = &tds;
+    register struct SSAPaddr *sz;
+    struct SSAPconnect scs;
+    register struct SSAPconnect *sc = &scs;
+    struct SSAPstart sss;
+    register struct SSAPstart *ss = &sss;
+    struct SSAPdata sxs;
+    register struct SSAPdata   *sx = &sxs;
+    struct SSAPrelease  srs;
+    register struct SSAPrelease *sr = &srs;
+    struct SSAPindication sis;
+    register struct SSAPindication *si = &sis;
+    register struct SSAPabort *sa = &si -> si_abort;
+    AEI            aei;
+    struct PSAPaddr *pa;
+    struct sblk incoming,
+               outgoing;
+    SB     sbi = &incoming,
+           sbo = &outgoing;
+
+    reportailor (argv[0]);
+
+    if (argc != 2)
+       adios (NULLCP, "usage: %s \"host\"", argv[0]);
+
+/* really should postpone this until after the session connect so we
+   can bind to the same network address (in the case of a multi-homed ES) */
+    if ((aei = str2aei (PLocalHostName (), mycontext)) == NULLAEI)
+       adios (NULLCP, "%s-%s: unknown application-entity",
+              PLocalHostName (), mycontext);
+    if ((pa = aei2addr (aei)) == NULLPA)
+       adios (NULLCP, "address translation failed");
+    ta = &pa -> pa_addr.sa_addr;
+    if (TNetUnique (ta, td) == NOTOK) {
+       if (td -> td_cc > 0)
+           adios (NULLCP, "TNetUnique: [%s] %*.*s", TErrString (td -> td_reason),
+                   td -> td_cc, td -> td_cc, td -> td_data);
+       else
+           adios (NULLCP, "TNetUnique: [%s]", TErrString (td -> td_reason));
+    }
+    if ((taddr = taddr2str (ta)) == NULLCP)
+       adios (NULLCP, "taddr2str failed");
+
+    if ((aei = str2aei (argv[1], mycontext)) == NULLAEI)
+       adios (NULLCP, "%s-%s: unknown application-entity",
+              argv[1], mycontext);
+    if ((pa = aei2addr (aei)) == NULLPA)
+       adios (NULLCP, "address translation failed");
+    sz = &pa -> pa_addr;
+
+    bzero ((char *) sbo, sizeof *sbo);
+    sbo -> sb_requirements = SR_BASUBSET;
+    sbo -> sb_settings = 0;
+#define dotoken(requires,shift,bit,type) \
+{ \
+    if (sbo -> sb_requirements & requires) \
+           sbo -> sb_settings |= ST_INIT_VALUE << shift; \
+}
+    dotokens ();
+#undef  dotoken
+    sbo -> sb_isn = SERIAL_NONE;
+
+       /* we pass the transport address we are listening on in the initial
+          user data */
+    if (SConnRequest (&sbo -> sb_connect, NULLSA, sz, sbo -> sb_requirements,
+                     sbo -> sb_settings, sbo -> sb_isn, taddr, strlen (taddr),
+                     NULLQOS, sc, si) == NOTOK)
+       adios (NULLCP, "S-CONNECT.REQUEST: %s", SErrString (sa -> sa_reason));
+    if (sc -> sc_result != SC_ACCEPT)
+       adios (NULLCP, "connection rejected by peer: %s",
+               SErrString (sc -> sc_result));
+    advise (LLOG_NOTICE, NULLCP,
+           "S-CONNECT.RESPONSE: <%d, %s, %s, %s, %ld, %d>",
+           sc -> sc_sd, sprintref (&sc -> sc_connect),
+           saddr2str (&sc -> sc_responding),
+           sprintb (sc -> sc_requirements, RMASK), sc -> sc_isn,
+           sc -> sc_ssdusize);
+
+    sbo -> sb_sd = sc -> sc_sd;
+    sbo -> sb_requirements = sc -> sc_requirements;
+    sbo -> sb_settings = sc -> sc_settings;
+#define dotoken(requires,shift,bit,type) \
+{ \
+    if (sbo -> sb_requirements & requires) \
+       if ((sbo -> sb_settings & (ST_MASK << shift)) == ST_INIT_VALUE) \
+           sbo -> sb_owned |= bit; \
+}
+    dotokens ();
+#undef  dotoken
+    sbo -> sb_ssn = sbo -> sb_isn = sc -> sc_isn;
+
+    SCFREE (sc);
+
+       /* now wait for the other end to call us back */
+    for (;;) {
+       if (TNetAccept (&vecp, vec, 0, NULLFD, NULLFD, NULLFD, NOTOK, td)
+               == NOTOK) {
+           if (td -> td_cc > 0)
+               adios (NULLCP, "TNetAccept: [%s] %*.*s", TErrString (td -> td_reason),
+                       td -> td_cc, td -> td_cc, td -> td_data);
+           else
+               adios (NULLCP, "TNetAccept: [%s]", TErrString (td -> td_reason));
+       }
+
+       if (vecp > 0)
+           break;
+    }
+
+    if (SInit (vecp, vec, ss, si) == NOTOK)
+       adios (NULLCP, "S-CONNECT.INDICATION: %s",
+              SErrString (sa -> sa_reason));
+    advise (LLOG_NOTICE, NULLCP,
+           "S-CONNECT.INDICATION: <%d, %s, %s, %s, %s, %ld, %d>",
+           ss -> ss_sd, sprintref (&ss -> ss_connect),
+           saddr2str (&ss -> ss_calling), saddr2str (&ss -> ss_called),
+           sprintb (ss -> ss_requirements, RMASK), ss -> ss_isn,
+           ss -> ss_ssdusize);
+
+       /* stop listening, we have what we want */
+    (void) TNetClose (NULLTA, td);
+
+    bzero ((char *) sbi, sizeof *sbi);
+    sbi -> sb_sd = ss -> ss_sd;
+    sbi -> sb_connect = ss -> ss_connect;      /* struct copy */    
+    sbi -> sb_requirements = ss -> ss_requirements & SR_BASUBSET;
+    sbi -> sb_settings = ss -> ss_settings;
+#define dotoken(requires,shift,bit,type) \
+{ \
+    if (sbi -> sb_requirements & requires) \
+       switch (sbi -> sb_settings & (ST_MASK << shift)) { \
+           case ST_CALL_VALUE << shift: \
+               sbi -> sb_settings &= ~(ST_MASK << shift); \
+               sbi -> sb_settings |= ST_INIT_VALUE << shift; \
+               break; \
+ \
+           case ST_INIT_VALUE: \
+               break; \
+ \
+           case ST_RESP_VALUE: \
+               sbi -> sb_owned |= bit; \
+               break; \
+ \
+           default: \
+               adios (NULLCP, "%s token: reserved", type); \
+               break; \
+       } \
+}
+    dotokens ();
+#undef dotoken
+    sbi -> sb_ssn = sbi -> sb_isn = ss -> ss_isn;
+
+    SSFREE (ss);
+
+    if (SConnResponse (sbi -> sb_sd, &sbi -> sb_connect, NULLSA, SC_ACCEPT,
+           sbi -> sb_requirements, sbi -> sb_settings, sbi -> sb_isn,
+           NULLCP, 0, si) == NOTOK)
+       adios (NULLCP, "S-CONNECT.RESPONSE: %s", SErrString (sa -> sa_reason));
+
+/* do work here */
+
+    if (SRelRequest (sbo -> sb_sd, NULLCP, 0, NOTOK, sr, si) == NOTOK)
+       adios (NULLCP, "S-RELEASE.REQUEST: %s", SErrString (sa -> sa_reason));
+    if (!sr -> sr_affirmative)
+       adios (NULLCP, "release rejected by peer");
+
+    switch (SReadRequest (sbi -> sb_sd, sx, NOTOK, si)) {
+       case NOTOK:
+           adios (NULLCP, "S-READ.REQUEST: %s", SErrString (sa -> sa_reason));
+
+       case OK:
+           adios (NULLCP, "not expecting DATA indication 0x%x", sx -> sx_type);
+
+       case DONE:
+           if (si -> si_type != SI_FINISH)
+               adios (NULLCP, "not expecting indication 0x%x", si -> si_type);
+           if (SRelResponse (sbi -> sb_sd, SC_ACCEPT, NULLCP, 0, si) == NOTOK)
+               adios (NULLCP, "S-RELEASE.RESPONSE: %s", SErrString (sa -> sa_reason));
+           break;
+    }
+
+    exit (0);
+}
diff --git a/usr/src/contrib/isode/others/callback/make b/usr/src/contrib/isode/others/callback/make
new file mode 100644 (file)
index 0000000..e3ccee0
--- /dev/null
@@ -0,0 +1,7 @@
+: run this script through /bin/sh
+M=/bin/make
+if [ -f /usr/bin/make ]; then
+    M=/usr/bin/make
+fi
+
+exec $M TOPDIR=../../ -f ../../config/CONFIG.make -f Makefile ${1+"$@"}
diff --git a/usr/src/contrib/isode/others/callback/report.c b/usr/src/contrib/isode/others/callback/report.c
new file mode 100644 (file)
index 0000000..e6670c1
--- /dev/null
@@ -0,0 +1,106 @@
+/* report.c -- event reporting */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/others/callback/RCS/report.c,v 7.1 91/02/22 09:26:41 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/others/callback/RCS/report.c,v 7.1 91/02/22 09:26:41 mrose Interim $
+ *
+ *
+ * $Log:       report.c,v $
+ * Revision 7.1  91/02/22  09:26:41  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.0  89/11/23  21:58:13  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <stdio.h>
+#include <varargs.h>
+#include "general.h"
+#include "manifest.h"
+#include "logger.h"
+
+
+static LLog _pgm_log = {
+    "callback.log", NULLCP, NULLCP, LLOG_FATAL | LLOG_EXCEPTIONS | LLOG_NOTICE,
+    LLOG_FATAL, -1, LLOGCLS | LLOGCRT | LLOGZER, NOTOK
+};
+static LLog *pgm_log = &_pgm_log;
+
+/* \f */
+
+reportailor (myname)
+char   *myname;
+{
+    isodetailor (myname, 0);
+    ll_hdinit (pgm_log, myname);
+}
+
+/* \f */
+
+#ifndef        lint
+void   adios (va_alist)
+va_dcl
+{
+    va_list ap;
+
+    va_start (ap);
+    
+    _ll_log (pgm_log, LLOG_FATAL, ap);
+
+    va_end (ap);
+
+    _exit (1);
+}
+#else
+/* VARARGS */
+
+void   adios (what, fmt)
+char   *what,
+       *fmt;
+{
+    adios (what, fmt);
+}
+#endif
+
+
+#ifndef        lint
+void   advise (va_alist)
+va_dcl
+{
+    int            code;
+    va_list ap;
+
+    va_start (ap);
+    
+    code = va_arg (ap, int);
+
+    _ll_log (pgm_log, code, ap);
+
+    va_end (ap);
+}
+#else
+/* VARARGS */
+
+void   advise (code, what, fmt)
+char   *what,
+       *fmt;
+int    code;
+{
+    advise (code, what, fmt);
+}
+#endif
diff --git a/usr/src/contrib/isode/others/callback/responder.c b/usr/src/contrib/isode/others/callback/responder.c
new file mode 100644 (file)
index 0000000..9edd719
--- /dev/null
@@ -0,0 +1,184 @@
+/* responder.c -- responder for callback demo */
+
+#ifndef        lint
+static char *rcsid = "$Header: /f/osi/others/callback/RCS/responder.c,v 7.1 91/02/22 09:26:42 mrose Interim $";
+#endif
+
+/* 
+ * $Header: /f/osi/others/callback/RCS/responder.c,v 7.1 91/02/22 09:26:42 mrose Interim $
+ *
+ *
+ * $Log:       responder.c,v $
+ * Revision 7.1  91/02/22  09:26:42  mrose
+ * Interim 6.8
+ * 
+ * Revision 7.0  89/11/23  21:58:14  mrose
+ * Release 6.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.
+ *
+ */
+
+
+#include <stdio.h>
+#include "callback.h"
+
+/* \f */
+
+/* ARGSUSED */
+
+main (argc, argv, envp)
+int    argc;
+char  **argv,
+      **envp;
+{
+    struct TSAPaddr tas;
+    struct TSAPaddr *ta = &tas;
+    register struct SSAPaddr *sz;
+    struct SSAPconnect scs;
+    register struct SSAPconnect *sc = &scs;
+    struct SSAPstart sss;
+    register struct SSAPstart *ss = &sss;
+    struct SSAPdata sxs;
+    register struct SSAPdata   *sx = &sxs;
+    struct SSAPrelease  srs;
+    register struct SSAPrelease *sr = &srs;
+    struct SSAPindication sis;
+    register struct SSAPindication *si = &sis;
+    register struct SSAPabort *sa = &si -> si_abort;
+    struct sblk incoming,
+               outgoing;
+    SB     sbi = &incoming,
+           sbo = &outgoing;
+
+    reportailor (argv[0]);
+
+       /* S-CONNECT.INDICATION */
+    if (SInit (argc, argv, ss, si) == NOTOK)
+       adios (NULLCP, "S-CONNECT.INDICATION: %s", SErrString (sa -> sa_reason));
+    advise (LLOG_NOTICE, NULLCP,
+           "S-CONNECT.INDICATION: <%d, %s, %s, %s, %s, %ld, %d>",
+           ss -> ss_sd, sprintref (&ss -> ss_connect),
+           saddr2str (&ss -> ss_calling), saddr2str (&ss -> ss_called),
+           sprintb (ss -> ss_requirements, RMASK), ss -> ss_isn,
+           ss -> ss_ssdusize);
+
+    bzero ((char *) sbi, sizeof *sbi);
+    sbi -> sb_sd = ss -> ss_sd;
+    sbi -> sb_connect = ss -> ss_connect;      /* struct copy */    
+    sbi -> sb_requirements = ss -> ss_requirements & SR_BASUBSET;
+    sbi -> sb_settings = ss -> ss_settings;
+#define dotoken(requires,shift,bit,type) \
+{ \
+    if (sbi -> sb_requirements & requires) \
+       switch (sbi -> sb_settings & (ST_MASK << shift)) { \
+           case ST_CALL_VALUE << shift: \
+               sbi -> sb_settings &= ~(ST_MASK << shift); \
+               sbi -> sb_settings |= ST_INIT_VALUE << shift; \
+               break; \
+ \
+           case ST_INIT_VALUE: \
+               break; \
+ \
+           case ST_RESP_VALUE: \
+               sbi -> sb_owned |= bit; \
+               break; \
+ \
+           default: \
+               adios (NULLCP, "%s token: reserved", type); \
+               break; \
+       } \
+}
+    dotokens ();
+#undef dotoken
+    sbi -> sb_ssn = sbi -> sb_isn = ss -> ss_isn;
+
+    if ((ta = str2taddr (ss -> ss_data)) == NULLTA)
+       adios (NULLCP, "str2taddr failed");
+
+    SSFREE (ss);
+
+    if (SConnResponse (sbi -> sb_sd, &sbi -> sb_connect, NULLSA, SC_ACCEPT,
+           sbi -> sb_requirements, sbi -> sb_settings, sbi -> sb_isn,
+           NULLCP, 0, si) == NOTOK)
+       adios (NULLCP, "S-CONNECT.RESPONSE: %s", SErrString (sa -> sa_reason));
+
+       /* we use the transport address passed in via the initial user data,
+          along with our our session selector */
+    sz = &ss -> ss_called;
+    sz -> sa_addr = *ta;       /* struct copy */
+
+    bzero ((char *) sbo, sizeof *sbo);
+    sbo -> sb_requirements = SR_BASUBSET;
+    sbo -> sb_settings = 0;
+#define dotoken(requires,shift,bit,type) \
+{ \
+    if (sbo -> sb_requirements & requires) \
+           sbo -> sb_settings |= ST_INIT_VALUE << shift; \
+}
+    dotokens ();
+#undef  dotoken
+    sbo -> sb_isn = SERIAL_NONE;
+
+       /* make the callback */
+    if (SConnRequest (&sbo -> sb_connect, NULLSA, sz, sbo -> sb_requirements,
+           sbo -> sb_settings, sbo -> sb_isn, NULLCP, 0, NULLQOS, sc, si)
+           == NOTOK)
+       adios (NULLCP, "S-CONNECT.REQUEST: %s", SErrString (sa -> sa_reason));
+    if (sc -> sc_result != SC_ACCEPT)
+       adios (NULLCP, "connection rejected by peer: %s",
+               SErrString (sc -> sc_result));
+    advise (LLOG_NOTICE, NULLCP,
+           "S-CONNECT.RESPONSE: <%d, %s, %s, %s, %ld, %d>",
+           sc -> sc_sd, sprintref (&sc -> sc_connect),
+           saddr2str (&sc -> sc_responding),
+           sprintb (sc -> sc_requirements, RMASK), sc -> sc_isn,
+           sc -> sc_ssdusize);
+
+    sbo -> sb_sd = sc -> sc_sd;
+    sbo -> sb_requirements = sc -> sc_requirements;
+    sbo -> sb_settings = sc -> sc_settings;
+#define dotoken(requires,shift,bit,type) \
+{ \
+    if (sbo -> sb_requirements & requires) \
+       if ((sbo -> sb_settings & (ST_MASK << shift)) == ST_INIT_VALUE) \
+           sbo -> sb_owned |= bit; \
+}
+    dotokens ();
+#undef  dotoken
+    sbo -> sb_ssn = sbo -> sb_isn = sc -> sc_isn;
+
+    SCFREE (sc);
+
+/* do work here */
+
+    switch (SReadRequest (sbi -> sb_sd, sx, NOTOK, si)) {
+       case NOTOK:
+           adios (NULLCP, "S-READ.REQUEST: %s", SErrString (sa -> sa_reason));
+
+       case OK:
+           adios (NULLCP, "not expecting DATA indication 0x%x", sx -> sx_type);
+
+       case DONE:
+           if (si -> si_type != SI_FINISH)
+               adios (NULLCP, "not expecting indication 0x%x", si -> si_type);
+           if (SRelResponse (sbi -> sb_sd, SC_ACCEPT, NULLCP, 0, si) == NOTOK)
+               adios (NULLCP, "S-RELEASE.RESPONSE: %s", SErrString (sa -> sa_reason));
+           break;
+    }
+
+    if (SRelRequest (sbo -> sb_sd, NULLCP, 0, NOTOK, sr, si) == NOTOK)
+       adios (NULLCP, "S-RELEASE.REQUEST: %s", SErrString (sa -> sa_reason));
+    if (!sr -> sr_affirmative)
+       adios (NULLCP, "release rejected by peer");
+
+    exit (0);
+}
diff --git a/usr/src/contrib/isode/others/make b/usr/src/contrib/isode/others/make
new file mode 100644 (file)
index 0000000..d861596
--- /dev/null
@@ -0,0 +1,7 @@
+: run this script through /bin/sh
+M=/bin/make
+if [ -f /usr/bin/make ]; then
+    M=/usr/bin/make
+fi
+
+exec $M TOPDIR=../ -f ../config/CONFIG.make -f Makefile ${1+"$@"}