


                                 Programmers Guide

                                     for the

                              IP/Application Gateway


                                    Revision 2








                                  June 27, 1994

			    Revised: September 29, 1995

























                                    Fulko Hew
                             Westinghouse Canada Inc.



           Any information contained herein is proprietary to Westinghouse
           Canada Inc. and cannot be disclosed without prior written consent.


    Purpose
    -------

    This document describes the software aspects of the W9600 IP Gateway
    product (refered to as a 'gateway').  It can be used to provide
    bi-directional information flow between an airline host and one
    or more application servers on a TCP/IP network.

    Components
    ----------

    A gateway consists of two major components:

        - Network Interface
        - Gateway Application

    The Network Interface consists of one or more W915 concentrators
    within a W9600.  The function of the W915 is to provide the physical
    interface point for network communications.  It extracts messages
    send to and from a configured set of addresses to the gateway
    application.

    The Gateway Application provides the transport mechanism between the
    Network Interface and any programs running on the W9600 and other
    IP connected application servers.

    Programmers Interface
    ---------------------

    The programer may send and receive messages from the DPM using the
    standard UNIX open, close, read and write routines.  The device
    used for these activities is: "/dev/dpma13".  This specifies the first
    W915 card within a W9600 chassis.  Should there be multiple cards,
    each card should have its own application attached using the convention:

        /dev/dpma13     /dev/dpmb13     ...     /dev/dpmf13


    All standard UNIX programming techniques apply.

    All messages read from and written to a dpm device must be of the
    form described in the next section "DPM Message Format".
    Refer to Appendix A for a sample program which transfers messages
    from the airline side to another IP connected host, and from that
    IP connected host back to the airline side.

    DPM Message Format
    ------------------

    Messages are send to and from W915 cards via a dual ported memory
    system.  The messages sent across that interface are of the form:

        -------------------------------------------------------------------
        | Protocol Type | Src HLD | Dst HLD | A1 | A2 | A3 | User Data... |
        -------------------------------------------------------------------

    Protocol Type - Used to designate the protocol used.  This field
                    determines the interpretation of the remaining
                    fields.  (1 byte, P1024B = 0x05)


    Src HLD - The 'high level designator' of the originator of the
              message.  For Ahost bound messages it is the HLD of
              the application or the application host.  For Uhost
              bound messages it is the HLD of the concentrator
              node that first received the message.  (2 bytes,
              most significant byte first)

    Dst HLD - The 'high level designator' of the 'consumer' of the
              message.  For Uhost bound messages it is the HLD of
              the application or the application host.  For Ahost
              bound messages it is the HLD of the concentrator
              node that first received the message.  (2 bytes,
              most significant byte first)

    A1 -      The number of the line in the originating or destination
              A-host within the W9600 network.
    A2 -      The first level of protocol addressing used for this
              connection. (IA in IPARS)
    A3 -      The second level of protocol addressing used for this
              connection. (TA in IPARS)

    User Data - The remainder is user traffic as per conventions
                used by the protocol used.

    ASCII to IPARS to ASCII Character Set Translation Tables
    --------------------------------------------------------

    Any gateway application must translate its data from the incomming
    IPARS character set into ASCII and back between the application and
    the W915 card.

    Any character designated as "N/A" should not be translated.
    Refer to Appendix A for an include file that can be used by "C"
    programmers to perform this translation.
			 Appendix A - Sample Perl Code

#!./perl

($them,$port) = @ARGV;
$port = 6600 unless $port;
$them = 'lab122' unless $them;

$AF_INET = 2;
$SOCK_STREAM = 1;

$SIG{'INT'} = 'dokill';
sub dokill {
	kill 9, $child if $child;
	print "shuting down\n";
	close DPM;
	shutdown(S,2);
}

sub proctoterm {
	$obuf = "";
	$len1 = length $_;
	for ($c = 0; $c < $len1; $c = $c +3) {
		$y = substr($_, $c, 2);
		$x = pack ('H2', $y);
		$obuf = $obuf.$x;
	}
}

sub proctohost {
	$obuf = "";
	for ($c = 0; $c < $len; $c++) {
		$y = substr($buf, $c, 1);
		$x = unpack ('H2', $y);
		$obuf = $obuf.$x." ";
	}
 }

$sockaddr = 'S n a4 x8';

chop($hostname = `hostname`);

($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port,'tcp')
	unless $port =~ /^\d+$/;;
($name, $aliases, $type, $len, @thisaddr) = gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);

$thataddr = (gethostbyname($them))[4];

	($a, $b, $c, $d) = unpack('C4', $thisaddr[0]);
	printf "us  : %d.%d.%d.%d\n", $a, $b, $c, $d;
	($a, $b, $c, $d) = unpack('C4', $thataddr[0]);
	printf "them: %d.%d.%d.%d\n", $a, $b, $c, $d;

$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);

	($one, $two, @three, $four) = unpack ($sockaddr, $that);
	($a, $b, $c, $d) = unpack('C4', $three[0]);
	printf "%d %d %d.%d.%d.%d %x\n", $one, $two, $a, $b, $c, $d, $four;


if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {  # make the socket filehandle
	print "socket ok\n";
}
else {
	die $!;
}

if (bind(S, $this)) {				# give the socket an address
	print "bind ok\n";
}
else {
	die $!;
}

if (connect(S,$that)) {				#call up the server
	print "connect ok\n";
}
else {
	die $!;
}

#set socket to be command buffered

select(S); $| = 1; select(STDOUT);
open (DPM, "+</dev/dpm/dpmb13");

#avoid deadlock by forking

if ($child = fork) {
	while (1) {
		$len = sysread(DPM,$buf,8000);
		if ($len == 0) {
			exit 0;
		}
		proctohost();
		print S "$obuf\n";
	}
}
else {
	while(<S>) {
	#print "$_";
		proctoterm();
		$len1--;
		$len1 = $len1 / 3;
		syswrite(DPM,$obuf,$len1);
	#print "len: $len1, xxx:$obuf\n";
	}
}
			 Appendix B - Sample Perl Code (Server)
#!./perl

($port) = @ARGV;
$port = 6600 unless $port;

sub flip {
$hex = substr($_,3,6);
$hen = substr($_,9,6);
$ostr = sprintf "%s",$_;
substr($ostr,3,6) = $hen;
substr($ostr,9,6) = $hex;
substr($ostr,24,0) = "5D 33 ";
substr($ostr,-4,0) = "33 21 ";
}

$AF_INET =2;
$SOCK_STREAM =1;
$sockaddr = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
if ($port !~ /^\d+$/) {
    ($name, $aliases, $port) = getservbyport($port, 'tcp');
}

print "Port = $port\n";

$this = pack($sockaddr, $AD_INET, $port, "\0\0\0\0");
select(NS); $| = 1; select(stdout);

socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
bind(S,$this) || die "bind: $!";
listen(S,5) || die "connect: $!";

select(S); $| =1; select(stdout);

for($con = 1; ; $con++) {
    printf("Listening for connection %d....\n",$con);
    ($addr = accept(NS,S)) || die $!;

    if (($child = fork()) == 0) {
        print "accept ok\n";

        ($af,$port,$inetaddr) = unpack($sockaddr,$addr);
        @inetaddr = unpack('C4',$inetaddr);
        print "$con: $af $port @inetaddr\n";

        while (<NS>) {
            print "$con: $_";
			select(NS);
			flip();
			print "$ostr";
			select(stdout);
        }
        close(NS);
        exit;
    }
    close(NS);
}





                                Appendix C

                                Sample "C" Code






#   Makefile for the simple gateway application

PROG = al2tcp
CFLAGS = -I.
OBJS = al2tcp.o msglog.o
LDLIBS =  -lsocket -lx
LDFLAGS =
INCLUDES = ahost-tr.h

all: $(PROG) $(INCLUDES)

$(PROG): $(OBJS)
    $(CC) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(PROG)



--------------------------------------------------------------------



# al2tcp.cfg
# Each Line contains:
# Hostname  Servive     dpm_device
#
# Hostname from /etc/hosts
# Service from /etc/services
# The relevant dpm device
myhost  w9600   /dev/dpm/dpma13


Jun 27 14:45 1995  al2tcp.c Page 1


/*******************************************************************
 * Airline2tcp.c  get Airline messages and pass them to the Unix world
 *
 * Configueration file entry in: /wnet/al2tcp.cfg are:
 * Hostname Service     dpm_device
 *
 *  This software is provided on an AS-IS basis.
 *
 *******************************************************************/

#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <fcntl.h>
#include <signal.h>

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>

#include <pwd.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "./ahost-tr.h"

#define OPTIONS     "RWxw"
#define LOG_ERR     0
#define LOG_WARN    5
#define LOG_DEBUG   9
#define LOG_TRACE   9

#define NEW     1
#define RESURRECT   2

#define ERR     -1
#define BUG     0
#define EOS     '\0'
#define L_SET       0       /* Absolute seek */
#define STDIN       0
#define STDOUT      1

#define  PROTOCOL   0x05
#define  BUFFER_SIZE    5120
#define  EOM        0x51            /* after ascii->ipars->mangle */
#define  CONFNAME   "/wnet/al2tcp.cfg"

char logname[50] = "\0";
char deflogname[] = "/wnet/lp/al2tcp.log";
char albuf[BUFFER_SIZE];            /* Big Airline buf */
char unixbuf[BUFFER_SIZE];          /* Big Unix buf */



Jun 27 14:45 1995  al2tcp.c Page 2



struct  sockaddr_in daemon_addr = { sizeof(daemon_addr), AF_INET };
struct  sockaddr_in hisaddr;
struct  sockaddr_in my_addr = { sizeof(my_addr), AF_INET };

struct  in_addr my_machine_addr;    /* inet addresses of the two machines */
struct  in_addr his_machine_addr;
char    hostname[MAXHOSTNAMELEN];
char    *his_name, *my_machine_name;
int isockt;
int osockt;

/* Prototypes */

static  void    do_ahost_copy(void);
static  void    dispatch(int) ;
static  void    do_uhost_copy(void);
static  int read_ahost(char *msg);
static  void    dpm_iopen(void);
static  void    dpm_oopen(void);
static  void    tr_unix_msg(char *msg);
static  void    tr_host_msg(uchar *msg, int len);
static  char    *tr(int *tr, uchar *t, uchar *f, int len);
static  void    die(int exit_rc);
static  void    config();
static  int sig_action();
static  int new_child();
static  void    write_ahost() ;
static  int     send_unix( char *s,int len);
static void     open_osockt();
static void     open_isockt();

static  char    *DPM_channel = "/dev/dpm/dpma13";
static  int DPM_ofd = ERR;
static  int DPM_ifd = ERR;
static  int Wait_open = 1;
static  int App_Mode = 0;
static  uchar   A_msg[BUFFER_SIZE];
static  int A_len;
static  uchar   U_msg[BUFFER_SIZE];
static  pid_t   Child_pid;
static  pid_t   Pid = 0;

int check_all = 0;
int Debug = 0;

/* Configuration file structure used by config() */

struct  altab {
    char    *di_host;       /* name of host */
    char    *di_service;        /* name of service */
    char    *di_dpm;        /* name of dpm_device */
    struct  altab *di_next;
} *altab;

struct  servent *sp;


Jun 27 14:45 1995  al2tcp.c Page 3


struct  hostent *hp;

FILE    *fconfig = NULL;
struct  altab al;       /* The configuration read, could be */
                /* expanded later for multiple connections */
char    line[256];
char    *skip(), *nextline();

/* airline addresses */

static  short   s_hld;
static  short   d_hld;
static  uchar   a1,a2,a3;
static  long    a123;

main(int argc, char *argv[])
{
extern int opterr, optind;
int _check_rhosts_file;
int ch, on = 1, fromlen,len;
struct sockaddr_in from;
extern char *optarg;
struct altab *sep;

while ((ch = getopt(argc, argv, OPTIONS)) != EOF)
    {
    switch (ch)
        {
        case 'R':
            App_Mode = ch;
            break;
        case 'W':
            App_Mode = ch;
            break;
        case 'x':
            Debug = atoi(optarg);
            break;
        case 'w':
            Wait_open = 1;
            break;
        case '?':
        default:
            usage(argv[0]);
            exit(2);
        }
    }
signal(SIGTERM, sig_action);
signal(SIGHUP,SIG_IGN);
signal(SIGINT,sig_action);
signal(SIGQUIT,sig_action);
signal(SIGKILL,sig_action);
signal(SIGCLD,new_child);

config();               /* read configuration file */
DPM_channel = al.di_dpm;



Jun 27 14:45 1995  al2tcp.c Page 4


switch (fork())             /* Become a true daemon */
    {
    case -1:
        msglog(LOG_ERR, "Can't fork");
        exit(2);
        break;
    case 0:             /* child process */
        sleep(60);
        break;
    default:            /* parent process should just die */
        _exit(0);
    }

switch (App_Mode)
    {
    case 0:             /* normal read/write mode */
        dispatch(NEW);
        break;

    case 'R':           /* ahost->uhost mode */
        DPM_ifd = STDIN;
        do_ahost_copy();
        break;

    case 'W':           /* uhost->ahost mode */
        DPM_ofd = STDOUT;
        do_uhost_copy();
        break;
    }
return 0;
}

/* read host messages translate them and send to Unix */

static void do_ahost_copy()
{
int len,rc;

while (1)               /* Start the main loop */
    {
    len = read_ahost(albuf);
    if (len)
        {
        tr_host_msg(albuf, len);
        msglog(LOG_DEBUG,U_msg);
        while(1)
            {   /* If error try to reestablish connection */
            rc = send_unix(U_msg,len);
            if (rc == 0)
                break;
            else
                {
                Debug = 9;
                msglog(LOG_ERR,"send_unix rc = %d",rc);
                Debug = 0;
                open_osockt();


Jun 27 14:45 1995  al2tcp.c Page 5


                }
            }
        }
    nap(100);   /* this is neccessary */
    }
}

/* Do separate 1st read to optain host address so we can fork The writer */

static void do_1stahost_copy()
{
int len,rc;

dpm_iopen();
open_osockt();

len = read_ahost(albuf);            /* Start the main loop */
while (1)
    {
    if (len)
        {
        tr_host_msg(albuf, len);
        msglog(LOG_DEBUG,U_msg);
        while (1)
            {   /* If error try to reestablish connection */
            rc = send_unix(U_msg,len);
            if (rc == 0)
                break;
            else
                open_osockt();
            }
        break;
        }
    nap(100);   /* this is neccessary */
    }
}

/* read unix message from socket translate and write to host */
static void do_uhost_copy()
{
int ac,len;

dpm_oopen();
open_isockt();

while (1)                   /* Start the main loop */
    {
    if ((ac = accept(isockt,(struct sockaddr *)0, (int *)0)) == -1)
            msglog(LOG_ERR,"accept failed %d",errno);
    if ((len = read(ac,unixbuf, sizeof(unixbuf))) == -1)
            msglog(LOG_ERR,"read failed %d",errno);
    unixbuf[len] = '%';
    unixbuf[len+1] = '\0';
    msglog(LOG_DEBUG,"len %d",len);
    close(ac);



Jun 27 14:45 1995  al2tcp.c Page 6



    tr_unix_msg(unixbuf);           /* sets A_buf, A_len */
    A_msg[A_len++] = EOM_CH;
    A_msg[A_len] = EOS;
    write_ahost();
    }
}

/*  dispatch -- start both uhost and ahost translators as 2 processes */

static void dispatch (int flg)
{
msglog(LOG_DEBUG, "Debug level: %d", Debug);

    /* 1 message must be read for the return addresses before we can fork */
if (flg == NEW)
    do_1stahost_copy();
else
    {
    dpm_iopen();
    open_osockt();
    }

if ((Child_pid = fork()) < 0)
    {
    msglog(LOG_ERR, "Can't fork");
    exit(2);
    }

if (Child_pid == 0)
    {               /* child, translate uhost messages */
    if (Pid != ERR) Pid = getpid();
    Wait_open = 0;  /* child doesn't wait */
    sleep(15);  /* So it be */
    do_uhost_copy();
    }
else                    /* parent, translate ahost messages */
    do_ahost_copy();
}

usage(s)
char *s;
{
fprintf(stderr,"Usage: %s -%s\n",s,OPTIONS);
fprintf(stderr,"       -R do only host to Unix\n");
fprintf(stderr,"       -W do only  Unix to Host\n");
fprintf(stderr,"       -x Debuglevel 0-9\n");
fprintf(stderr,"       -w No waitopen\n");
}

/* dpm_iopen -- used to open the DPM device.  The sleep 45 is used  */
/*  to slow the opens down in case of failure.          */

static void dpm_iopen(void)
{
while (1)


Jun 27 14:45 1995  al2tcp.c Page 7


    {
    DPM_ifd = open(DPM_channel,O_RDONLY , 0);
    if (DPM_ifd != ERR)
        {
        msglog(LOG_TRACE, "ahost:Ready %s -> %d", DPM_channel, DPM_ifd);
        return;
    }
    msglog(LOG_ERR, "Fatal: open %s failed: %d=%s",
        DPM_channel, errno, strerror(errno));
    if (Wait_open) sleep(45);
    }
}

/* dpm_oopen -- used to open the DPM device.  The sleep 45 is used  */
/*  to slow the opens down in case of failure.          */

static void dpm_oopen(void)
{
while (1)
    {
    DPM_ofd = open(DPM_channel, O_WRONLY, 0);
    if (DPM_ofd != ERR)
        {
        msglog(LOG_TRACE, "ahost:Ready %s -> %d", DPM_channel, DPM_ofd);
        return;
        }
    msglog(LOG_ERR, "Fatal: open %s failed: %d=%s",
        DPM_channel, errno, strerror(errno));
    if (Wait_open)
        sleep(45);
    }
}

/* read_ahost -- used to read a single message from the DPM device. */

static int read_ahost(char *msg)
{
int len = 0;

while ((len = read(DPM_ifd, msg, BUFFER_SIZE)) <= 0)
    {
    msglog(LOG_ERR, "a-host read failure on %s: %d=%s",
        DPM_channel, errno, strerror(errno));
    die (RESURRECT);
    }
msglog(LOG_DEBUG,"read_ahost %d ",len);
return len;
}

/* tr_unix_msg -- take the unix msg and translate it to a host message */

static void tr_unix_msg(char *msg)
{
uchar *p;

msglog(LOG_TRACE, "Send: %s", msg);


Jun 27 14:45 1995  al2tcp.c Page 8



p = A_msg;
*p++ = (uchar)PROTOCOL;

*p++ = (uchar)(d_hld >> 8); /* swap src/dst */
*p++ = (uchar) d_hld;

*p++ = (uchar)(s_hld >> 8);
*p++ = (uchar) s_hld;

*p++ = (uchar)Ipars_To_Mangle[(a123 >> 24) & 0xFF]; /* a1 */
*p++ = (uchar)Ipars_To_Mangle[(a123 >> 16) & 0xFF]; /* a2 */
*p++ = (uchar)Ipars_To_Mangle[(a123 >>  8) & 0xFF]; /* a3 */

p = (uchar *) tr(Ascii_To_Mangle, p, msg, strlen(msg));
A_len = p - A_msg;
msglog(LOG_DEBUG,"A_len %d",A_len);
}

/* tr_host_msg -- translate a host message to a unix msg    */

static void tr_host_msg(uchar *msg, int len)
{
uchar   *p, *end;
uchar   protocol;

    /* len < protocol+shld+dhld+a123d+xx+msg==1 */
if (len < 1+2+2+4+2+1)
    {
    msglog(LOG_TRACE, "Short message from a-host len=%d", len);
    *U_msg = EOS;
    return;
    }

p = msg;
protocol = *p++;        /* TODO assert protocol == PROTOCOL */

s_hld = (short)((*p <<8) + p[1]); p += 2;   /* high/low byte order */
d_hld = (short)((*p <<8) + p[1]); p += 2;   /* high/low byte order */

a1 = (uchar)Mangle_To_Ipars[*p++];
a2 = (uchar)Mangle_To_Ipars[*p++];
a3 = (uchar)Mangle_To_Ipars[*p++];
if (App_Mode != 'T') {          /* don't strip this if testing */
    p++;                /* cmd */
    p++;                /* la */
    }
a123 = (a1 << 24) | (a2 << 16) | (a3 << 8);

end = U_msg;

len -= p-msg;               /* skip past the header */
p = tr(Mangle_To_Ascii, end, p, len-1); /* translate all but last character */
*p ++ = '\n';               /* (the eom) */
*p = EOS;
}


Jun 27 14:45 1995  al2tcp.c Page 9



/* tr -- used to do a "TRanslate" on a block of data.           */
/*  The translate table is in tr.                   */
/*  t is where to translate to.                 */
/*  f is where to translate form.                   */
/*  len is the length to translate.                 */
/*  The translate table support DEL_CH to remove characters.    */

static char * tr(int *tr, uchar *t, uchar *f, int len)
{
uchar   *end = f+len;
int c;

for (; f < end; ++f)
    {
    c = tr[*f & 0x7F];      /* translate low 7bits  */
    if (c & EOM_CH)         /* End of Message character */
        {
        if (f < end-1) {    /* valid only at end */
            c = tr[' '];
            }
        }
    if (c & DEL_CH) continue;   /* delete character? */
    *t++ = (uchar)c;        /* save translated value */
    }
*t = EOS;
return t;
}

/* die -- called instead of exit so that we can kill the child process. */

static void die(int rc)
{
close(DPM_ifd);
close(DPM_ofd);
close(isockt);
close(osockt);
if (Child_pid)
    {
    kill(Child_pid, SIGTERM);
    Child_pid = 0;
    }
if (Wait_open)
    sleep(45);
if (rc == RESURRECT)
    dispatch(RESURRECT);
else
    exit(rc);
}

setconfig()
{
if (fconfig != NULL)
    {
    fseek(fconfig, 0L, L_SET);
    return (1);


Jun 27 14:45 1995  al2tcp.c Page 10


    }
fconfig = fopen(CONFNAME, "r");
return (fconfig != NULL);
}

endconfig()
{
if (fconfig)
    {
    (void) fclose(fconfig);
    fconfig = NULL;
    }
}

struct altab *getconfigent()
{
struct altab *sep = &al;
int argc;
char *cp, *arg, *newstr();

while ((cp = nextline(fconfig)) && *cp == '#')
    ;
if (cp == NULL)
    return ((struct altab *)0);
bzero((char *)sep, sizeof *sep);

sep->di_host = newstr(skip(&cp));
sep->di_service = newstr(skip(&cp));
sep->di_dpm = newstr(skip(&cp));
return (sep);
}

freeconfig(cp)
struct altab *cp;
{
if (cp->di_host)
    free(cp->di_host);
if (cp->di_service)
    free(cp->di_service);
if (cp->di_dpm)
    free(cp->di_dpm);
}

char *skip(cpp)
char **cpp;
{
register char *cp = *cpp;
char *start;

if (*cpp == NULL)
    return ((char *)0);

again:
    while (*cp == ' ' || *cp == '\t')
        cp++;
    if (*cp == '\0')


Jun 27 14:45 1995  al2tcp.c Page 11


        {
        int c;

        c = getc(fconfig);
        (void)ungetc(c, fconfig);
        if (c == ' ' || c == '\t')
            {
            if (cp = nextline(fconfig))
                goto again;
            {
        *cpp = (char *)0;
        return ((char *)0);
    }
    start = cp;
    while (*cp && *cp != ' ' && *cp != '\t')
        cp++;
    if (*cp != '\0')
        *cp++ = '\0';
    *cpp = cp;
    return (start);
}

char *nextline(fd)
FILE *fd;
{
char *cp;

if (fgets(line, sizeof (line), fd) == NULL)
    return ((char *)0);
cp = index(line, '\n');
if (cp)
    *cp = '\0';
return (line);
}

char *newstr(cp)
char *cp;
{
if (cp = strdup(cp ? cp : ""))
    return(cp);
syslog(LOG_ERR, "strdup: %m");
exit(-1);
}

void config()
{
register struct altab *sep, *cp, **sepp;
struct altab *getconfigent(), *enter();
long omask;
int n;
int port;

if (!setconfig())
    {
    msglog(LOG_ERR, "%s: %m", CONFNAME);
    return;


Jun 27 14:45 1995  al2tcp.c Page 12


    }
msglog(LOG_TRACE, "config file openned succefuly");
while (cp = getconfigent())
    {
    port = htons(atoi(cp->di_service));
    msglog(LOG_WARN,"%s %s %s", cp->di_host,
    cp->di_service, cp->di_dpm);
    if (!port)
        {
        sp = getservbyname(cp->di_service, "tcp");
        if (sp == 0)
            {
            msglog(LOG_ERR, "%s/%s: unknown service",
                cp->di_service, "tcp");
            continue;
            }
        port = sp->s_port;
        }
    msglog(LOG_TRACE,"port no %d found",port);
    }
endconfig();
}

static void open_osockt()
{
int length;
int on = 1;

Debug = 9;
msglog(LOG_ERR,"open_osock");
Debug = 0;
gethostname(hostname, sizeof (hostname));
my_machine_name = hostname;
msglog(LOG_TRACE,"mymachine is %s",my_machine_name);
hp = gethostbyname(my_machine_name);
if (hp == NULL)
    {
    msglog(LOG_ERR,"gethostbyname failed %s",al.di_host);
    exit(-1);
    }
msglog(LOG_DEBUG,"get my host by name succeeded ");
bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
my_addr.sin_addr = my_machine_addr;
my_addr.sin_port = sp->s_port;

osockt = socket(AF_INET, SOCK_STREAM, 0);
if (osockt <= 0)
    {
    msglog(LOG_ERR,"Bad socket");
    exit(1);
    }
msglog(LOG_TRACE,"socket succeeded");
bzero((char *)&hisaddr, sizeof (hisaddr));
hisaddr.sin_addr.s_addr = inet_addr(al.di_host);
if (hisaddr.sin_addr.s_addr != -1)
    {


Jun 27 14:45 1995  al2tcp.c Page 13


    hisaddr.sin_family = AF_INET;
    (void) strncpy(hostname, al.di_host, sizeof(hostname));
    }
else
    {
    hp = gethostbyname(al.di_host);
    if (hp == NULL)
        {
        msglog(LOG_ERR,"gethostbyname failed %s",al.di_host);
        exit(-1);
        }
    hisaddr.sin_family = hp->h_addrtype;
    bcopy(hp->h_addr_list[0], (caddr_t)&hisaddr.sin_addr, hp->h_length);
    (void) strncpy(hostname, hp->h_name, sizeof(hostname));
    }
hisaddr.sin_port = sp->s_port;
while (1)
    {
    int cc;
    cc = connect(osockt, (struct sockaddr *)&hisaddr, sizeof (hisaddr));
    if (cc  < 0)
        {           /* The other machine might be down */
        msglog("cannot connect socket errno %d",errno);
        sleep(10);
        }
    else
        break;
    }

if (getsockname(osockt, (struct sockaddr *)&my_addr, &length) == -1)
        msglog(LOG_ERR,"Bad address for socket %d",errno);

if(setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, (char *)&on,sizeof(on)) < 0)
        msglog(LOG_ERR,"sotsock faild t %d",errno);
}


static void open_isockt()
{
int length;
int on = 1;

gethostname(hostname, sizeof (hostname));
my_machine_name = hostname;
msglog(LOG_TRACE,"open_isock mymachine is %s",my_machine_name);
hp = gethostbyname(my_machine_name);
if (hp == NULL)
    {
    msglog(LOG_ERR,"gethostbyname failed %s",al.di_host);
    exit(-1);
    }
bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
my_addr.sin_addr = my_machine_addr;
my_addr.sin_port = sp->s_port;

isockt = socket(AF_INET, SOCK_STREAM, 0);


Jun 27 14:45 1995  al2tcp.c Page 14


if (isockt <= 0)
    {
    msglog(LOG_ERR,"Bad socket");
    exit(1);
    }
if (bind(isockt, (struct sockaddr *)&my_addr, sizeof(my_addr)) != 0)
    msglog(LOG_ERR,"Binding local socket %d",errno);
length = sizeof(my_addr);

if ((listen(isockt,5)) == -1)
    msglog(LOG_ERR,"listen failed local socket %d",errno);
if (getsockname(isockt, (struct sockaddr *)&my_addr, &length) == -1)
    msglog(LOG_ERR,"Bad address for socket %d",errno);
if (setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, (char *)&on,sizeof(on)) < 0)
    msglog(LOG_ERR,"sotsock faild t %d",errno);
}

static int send_unix( char *s,int len)
{
if(write(osockt,s,len) != len)
    {
    msglog(LOG_ERR,"send %d",errno);
    return(errno);
    }
return(0);
}

static int sig_action()
{
msglog(LOG_WARN,"Signal exiting ! ");
close(isockt);
close(osockt);
die(0);
}

/* write_ahost -- used to write an a-host message to the DPM device */

static void write_ahost()
{
char *cp;
if (A_len == 0)
    {
    msglog(LOG_ERR, "Write request size == 0");
    return;
    }

while (write(DPM_ofd, A_msg, A_len) != A_len)
    {
    msglog(LOG_ERR, "Write failure to %s: %s len=%d",
        DPM_channel, strerror(errno), A_len);
    die(1);
    }
}

/* close the DPM_fd reopen and reactivate the daemon */



Jun 27 14:45 1995  al2tcp.c Page 15


static int new_child()
{
close(DPM_ifd);
close(DPM_ofd);
close(isockt);
close(osockt);
dispatch(RESURRECT);
}


Jun 27 10:22 1995  msglog.c Page 1



/*
 * SYSLOG -- print message on log file
 *
 * This routine looks a lot like printf, except that it outputs to the
 * log file instead of the standard output.  Also:
 *  adds a timestamp,
 *  prints the module name in front of the message,
 *  has some other formatting types (or will sometime),
 *  adds a newline on the end of the message.
 *
 * The output of this routine is intended to be read by syslogd(8).
 *
 *  This software is provided on an AS-IS basis.
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/signal.h>
#include <sys/syslog.h>

#include <sys/uio.h>
#include <sys/wait.h>
#include <netdb.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <fcntl.h>
#define _PATH_CONSOLE "/dev/console"

extern char logname[],deflogname[];
extern int  Debug;
static FILE *LogFile ;
static int  connected;      /* have done connect */
static int  LogStat = 0;        /* status bits, set by openlog() */
static const char *LogTag = "msglog";   /* string to tag the entry with */
static int  LogFacility = LOG_USER; /* default facility code */
static void closelog();
static void openlog(const char *ident, int logstat, int logfac);

void msglog(int pri, const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
vmsglog(pri, fmt, ap);
va_end(ap);
}

vmsglog(pri, fmt, ap)
int pri;


Jun 27 10:22 1995  msglog.c Page 2


const char *fmt;
va_list ap;
{

register int cnt;
register char *p;
time_t now;
int fd, saved_errno;
char tbuf[2048], fmt_cpy[1024], *stdp;

if (pri > Debug) return;

saved_errno = errno;

if (LogFile < 0 || !connected)
    openlog(LogTag, LogStat | LOG_NDELAY, 0);

    /* build the message */

(void)time(&now);
(void)sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
for (p = tbuf; *p; ++p);
if (LogTag)
    {
    (void)strcpy(p, LogTag);
    for (; *p; ++p);
    }
if (LogStat & LOG_PID)
    {
    (void)sprintf(p, "[%d]", getpid());
    for (; *p; ++p);
    }
if (LogTag)
    {
    *p++ = ':';
    *p++ = ' ';
    }

    /* substitute error message for %m */
{
register char ch, *t1, *t2;
char *strerror();

for (t1 = fmt_cpy; ch = *fmt; ++fmt)
    {
    if (ch == '%' && fmt[1] == 'm')
        {
        ++fmt;
        for (t2 = strerror(saved_errno);
            *t1 = *t2++; ++t1);
        }
    else
        *t1++ = ch;
    }
*t1 = '\0';
}


Jun 27 10:22 1995  msglog.c Page 3



(void)vsprintf(p, fmt_cpy, ap);

cnt = strlen(tbuf);
tbuf[cnt++] = '\n';
tbuf[cnt] = '\0';

    /* output the message to the local logger */
    /* Use NUL as a message delimiter. */

if (fwrite( tbuf, cnt + 1,1,LogFile) >= 1)
    {
    fflush(LogFile);
    return;
    }
else        /* If the write fails, we try to reconect it next time. */
    closelog ();

    /* output the message to the console; don't worry about */
    /* blocking, if console blocks everything will. */

if ((fd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY, 0)) < 0)
    return;
(void)strcat(tbuf, "\r\n");
cnt += 2;
p = index(tbuf, '>') + 1;
(void)write( fd,p, cnt - (p - tbuf));
(void)close(fd);
}

    /* OPENLOG -- open system log */

void openlog(char *ident, int logstat, int logfac)
{
if (logname[0] == '\0')
    strcpy(logname,deflogname);
LogFile = fopen(logname,"a");
connected = 1;
}

/* CLOSELOG -- close the message log */

void closelog()
{
(void) fclose(LogFile);
LogFile = NULL;
connected = 0;
}



Jun 27 14:44 1995  ahost-tr.h Page 1


/*
 * Ipars/Ascii translate tables
 *   Auto generated Sun Nov 13 05:52:19 EST 1994
 */
typedef unsigned char uchar;

#define DEL_CH  0x100
#define EOM_CH  0x200

/*
 *  ipars   mangle  disp
 */
int Mangle_To_Ipars[] = {
    DEL_CH, /* 00   NUL  */
    DEL_CH, /* 01   NUL  */
    DEL_CH, /* 02   NUL  */
    DEL_CH, /* 03   NUL  */
    DEL_CH, /* 04   NUL  */
    DEL_CH, /* 05   NUL  */
    DEL_CH, /* 06   NUL  */
    DEL_CH, /* 07   NUL  */
    DEL_CH, /* 08   NUL  */
    DEL_CH, /* 09   NUL  */
    DEL_CH, /* 0A   NUL  */
    DEL_CH, /* 0B   NUL  */
    DEL_CH, /* 0C   NUL  */
    DEL_CH, /* 0D   NUL  */
    DEL_CH, /* 0E   NUL  */
    DEL_CH, /* 0F   NUL  */

    DEL_CH, /* 10   NUL  */
    DEL_CH, /* 11   NUL  */
    DEL_CH, /* 12   NUL  */
    DEL_CH, /* 13   NUL  */
    DEL_CH, /* 14   NUL  */
    DEL_CH, /* 15   NUL  */
    DEL_CH, /* 16   NUL  */
    DEL_CH, /* 17   NUL  */
    DEL_CH, /* 18   NUL  */
    DEL_CH, /* 19   NUL  */
    DEL_CH, /* 1A   NUL  */
    DEL_CH, /* 1B   NUL  */
    DEL_CH, /* 1C   NUL  */
    DEL_CH, /* 1D   NUL  */
    DEL_CH, /* 1E   NUL  */
    DEL_CH, /* 1F   NUL  */

    DEL_CH, /* 20   NUL  */
    DEL_CH, /* 21   NUL  */
    DEL_CH, /* 22   NUL  */
    DEL_CH, /* 23   NUL  */
    DEL_CH, /* 24   NUL  */
    DEL_CH, /* 25   NUL  */
    DEL_CH, /* 26   NUL  */
    DEL_CH, /* 27   NUL  */
    DEL_CH, /* 28   NUL  */


Jun 27 14:44 1995  ahost-tr.h Page 2


    DEL_CH, /* 29   NUL  */
    DEL_CH, /* 2A   NUL  */
    DEL_CH, /* 2B   NUL  */
    DEL_CH, /* 2C   NUL  */
    DEL_CH, /* 2D   NUL  */
    DEL_CH, /* 2E   NUL  */
    DEL_CH, /* 2F   NUL  */

    DEL_CH, /* 30   NUL  */
    DEL_CH, /* 31   NUL  */
    DEL_CH, /* 32   NUL  */
    DEL_CH, /* 33   NUL  */
    DEL_CH, /* 34   NUL  */
    DEL_CH, /* 35   NUL  */
    DEL_CH, /* 36   NUL  */
    DEL_CH, /* 37   NUL  */
    DEL_CH, /* 38   NUL  */
    DEL_CH, /* 39   NUL  */
    DEL_CH, /* 3A   NUL  */
    DEL_CH, /* 3B   NUL  */
    DEL_CH, /* 3C   NUL  */
    DEL_CH, /* 3D   NUL  */
    DEL_CH, /* 3E   NUL  */
    DEL_CH, /* 3F   NUL  */

     0x3F,  /* 40   --   */
     0x1F,  /* 41   ,    */
     0x2F,  /* 42   (    */
     0x0F,  /* 43   DC2  */
     0x37,  /* 44   G    */
     0x17,  /* 45   X    */
     0x27,  /* 46   P    */
     0x07,  /* 47   7    */
     0x3B,  /* 48   .    */
     0x1B,  /* 49   #    */
     0x2B,  /* 4A   >    */
     0x0B,  /* 4B   *    */
     0x33,  /* 4C   C    */
     0x13,  /* 4D   T    */
     0x23,  /* 4E   L    */
     0x03,  /* 4F   3    */

     0x3D,  /* 50   --   */
     0x1D,  /* 51   EOMc(%)  */
     0x2D,  /* 52   ;    */
     0x0D,  /* 53   $    */
     0x35,  /* 54   E    */
     0x15,  /* 55   V    */
     0x25,  /* 56   N    */
     0x05,  /* 57   5    */
     0x39,  /* 58   I    */
     0x19,  /* 59   Z    */
     0x29,  /* 5A   R    */
     0x09,  /* 5B   9    */
     0x31,  /* 5C   A    */
     0x11,  /* 5D   /    */


Jun 27 14:44 1995  ahost-tr.h Page 3


     0x21,  /* 5E   J    */
     0x01,  /* 5F   1    */

     0x3E,  /* 60   --   */
     0x1E,  /* 61   --   */
     0x2E,  /* 62   )    */
     0x0E,  /* 63   =    */
     0x36,  /* 64   F    */
     0x16,  /* 65   W    */
     0x26,  /* 66   O    */
     0x06,  /* 67   6    */
     0x3A,  /* 68   EOMi(?)  */
     0x1A,  /* 69   -    */
     0x2A,  /* 6A   :    */
     0x0A,  /* 6B   0    */
     0x32,  /* 6C   B    */
     0x12,  /* 6D   S    */
     0x22,  /* 6E   K    */
     0x02,  /* 6F   2    */

     0x3C,  /* 70   --   */
     0x1C,  /* 71   space    */
     0x2C,  /* 72   +    */
     0x0C,  /* 73   NL   */
     0x34,  /* 74   D    */
     0x14,  /* 75   U    */
     0x24,  /* 76   M    */
     0x04,  /* 77   4    */
     0x38,  /* 78   H    */
     0x18,  /* 79   Y    */
     0x28,  /* 7A   Q    */
     0x08,  /* 7B   8    */
     0x30,  /* 7C   &    */
     0x10,  /* 7D   '    */
     0x20,  /* 7E   @    */
     0x00,  /* 7F   NUL  */

};

/*
 *  mangle  ipars   disp
 */
int Ipars_To_Mangle[] = {
     0x7F,  /* 00   NUL  */
     0x5F,  /* 01   1    */
     0x6F,  /* 02   2    */
     0x4F,  /* 03   3    */
     0x77,  /* 04   4    */
     0x57,  /* 05   5    */
     0x67,  /* 06   6    */
     0x47,  /* 07   7    */
     0x7B,  /* 08   8    */
     0x5B,  /* 09   9    */
     0x6B,  /* 0A   0    */
     0x4B,  /* 0B   *    */
     0x73,  /* 0C   NL   */


Jun 27 14:44 1995  ahost-tr.h Page 4


     0x53,  /* 0D   $    */
     0x63,  /* 0E   =    */
     0x43,  /* 0F   DC2  */

     0x7D,  /* 10   '    */
     0x5D,  /* 11   /    */
     0x6D,  /* 12   S    */
     0x4D,  /* 13   T    */
     0x75,  /* 14   U    */
     0x55,  /* 15   V    */
     0x65,  /* 16   W    */
     0x45,  /* 17   X    */
     0x79,  /* 18   Y    */
     0x59,  /* 19   Z    */
     0x69,  /* 1A   -    */
     0x49,  /* 1B   #    */
     0x71,  /* 1C   space    */
     0x51,  /* 1D   EOMc(%)  */
     0x61,  /* 1E   --   */
     0x41,  /* 1F   ,    */

     0x7E,  /* 20   @    */
     0x5E,  /* 21   J    */
     0x6E,  /* 22   K    */
     0x4E,  /* 23   L    */
     0x76,  /* 24   M    */
     0x56,  /* 25   N    */
     0x66,  /* 26   O    */
     0x46,  /* 27   P    */
     0x7A,  /* 28   Q    */
     0x5A,  /* 29   R    */
     0x6A,  /* 2A   :    */
     0x4A,  /* 2B   >    */
     0x72,  /* 2C   +    */
     0x52,  /* 2D   ;    */
     0x62,  /* 2E   )    */
     0x42,  /* 2F   (    */

     0x7C,  /* 30   &    */
     0x5C,  /* 31   A    */
     0x6C,  /* 32   B    */
     0x4C,  /* 33   C    */
     0x74,  /* 34   D    */
     0x54,  /* 35   E    */
     0x64,  /* 36   F    */
     0x44,  /* 37   G    */
     0x78,  /* 38   H    */
     0x58,  /* 39   I    */
     0x68,  /* 3A   EOMi(?)  */
     0x48,  /* 3B   .    */
     0x70,  /* 3C   --   */
     0x50,  /* 3D   --   */
     0x60,  /* 3E   --   */
     0x40,  /* 3F   --   */

    DEL_CH, /* 40   --   */


Jun 27 14:44 1995  ahost-tr.h Page 5


    DEL_CH, /* 41   --   */
    DEL_CH, /* 42   --   */
    DEL_CH, /* 43   --   */
    DEL_CH, /* 44   --   */
    DEL_CH, /* 45   --   */
    DEL_CH, /* 46   --   */
    DEL_CH, /* 47   --   */
    DEL_CH, /* 48   --   */
    DEL_CH, /* 49   --   */
    DEL_CH, /* 4A   --   */
    DEL_CH, /* 4B   --   */
    DEL_CH, /* 4C   --   */
    DEL_CH, /* 4D   --   */
    DEL_CH, /* 4E   --   */
    DEL_CH, /* 4F   --   */

    DEL_CH, /* 50   --   */
    DEL_CH, /* 51   --   */
    DEL_CH, /* 52   --   */
    DEL_CH, /* 53   --   */
    DEL_CH, /* 54   --   */
    DEL_CH, /* 55   --   */
    DEL_CH, /* 56   --   */
    DEL_CH, /* 57   --   */
    DEL_CH, /* 58   --   */
    DEL_CH, /* 59   --   */
    DEL_CH, /* 5A   --   */
    DEL_CH, /* 5B   --   */
    DEL_CH, /* 5C   n/a  */
    DEL_CH, /* 5D   n/a  */
    DEL_CH, /* 5E   n/a  */
    DEL_CH, /* 5F   n/a  */

    DEL_CH, /* 60   --   */
    DEL_CH, /* 61   --   */
    DEL_CH, /* 62   --   */
    DEL_CH, /* 63   --   */
    DEL_CH, /* 64   --   */
    DEL_CH, /* 65   --   */
    DEL_CH, /* 66   --   */
    DEL_CH, /* 67   --   */
    DEL_CH, /* 68   --   */
    DEL_CH, /* 69   --   */
    DEL_CH, /* 6A   --   */
    DEL_CH, /* 6B   --   */
    DEL_CH, /* 6C   --   */
    DEL_CH, /* 6D   --   */
    DEL_CH, /* 6E   --   */
    DEL_CH, /* 6F   --   */

    DEL_CH, /* 70   --   */
    DEL_CH, /* 71   --   */
    DEL_CH, /* 72   --   */
    DEL_CH, /* 73   --   */
    DEL_CH, /* 74   --   */
    DEL_CH, /* 75   --   */


Jun 27 14:44 1995  ahost-tr.h Page 6


    DEL_CH, /* 76   --   */
    DEL_CH, /* 77   --   */
    DEL_CH, /* 78   --   */
    DEL_CH, /* 79   --   */
    DEL_CH, /* 7A   --   */
    DEL_CH, /* 7B   --   */
    DEL_CH, /* 7C   --   */
    DEL_CH, /* 7D   --   */
    DEL_CH, /* 7E   --   */
    DEL_CH, /* 7F   --   */

};

/*
 *   Mangle to ascii translate table
 *
 *  ascii   mangle  ipars   disp */
static int Mangle_To_Ascii[] = {
    DEL_CH, /* 00   --  --   */
    DEL_CH, /* 01   --  --   */
    DEL_CH, /* 02   --  --   */
    DEL_CH, /* 03   --  --   */
    DEL_CH, /* 04   --  --   */
    DEL_CH, /* 05   --  --   */
    DEL_CH, /* 06   --  --   */
    DEL_CH, /* 07   --  --   */
    DEL_CH, /* 08   --  --   */
    DEL_CH, /* 09   --  --   */
    DEL_CH, /* 0A   --  --   */
    DEL_CH, /* 0B   --  --   */
    DEL_CH, /* 0C   --  --   */
    DEL_CH, /* 0D   --  --   */
    DEL_CH, /* 0E   --  --   */
    DEL_CH, /* 0F   --  --   */

    DEL_CH, /* 10   --  --   */
    DEL_CH, /* 11   --  --   */
    DEL_CH, /* 12   --  --   */
    DEL_CH, /* 13   --  --   */
    DEL_CH, /* 14   --  --   */
    DEL_CH, /* 15   --  --   */
    DEL_CH, /* 16   --  --   */
    DEL_CH, /* 17   --  --   */
    DEL_CH, /* 18   --  --   */
    DEL_CH, /* 19   --  --   */
    DEL_CH, /* 1A   --  --   */
    DEL_CH, /* 1B   --  --   */
    DEL_CH, /* 1C   --  --   */
    DEL_CH, /* 1D   --  --   */
    DEL_CH, /* 1E   --  --   */
    DEL_CH, /* 1F   --  --   */

    DEL_CH, /* 20   --  --   */
    DEL_CH, /* 21   --  --   */
    DEL_CH, /* 22   --  --   */
    DEL_CH, /* 23   --  --   */


Jun 27 14:44 1995  ahost-tr.h Page 7


    DEL_CH, /* 24   --  --   */
    DEL_CH, /* 25   --  --   */
    DEL_CH, /* 26   --  --   */
    DEL_CH, /* 27   --  --   */
    DEL_CH, /* 28   --  --   */
    DEL_CH, /* 29   --  --   */
    DEL_CH, /* 2A   --  --   */
    DEL_CH, /* 2B   --  --   */
    DEL_CH, /* 2C   --  --   */
    DEL_CH, /* 2D   --  --   */
    DEL_CH, /* 2E   --  --   */
    DEL_CH, /* 2F   --  --   */

    DEL_CH, /* 30   --  --   */
    DEL_CH, /* 31   --  --   */
    DEL_CH, /* 32   --  --   */
    DEL_CH, /* 33   --  --   */
    DEL_CH, /* 34   --  --   */
    DEL_CH, /* 35   --  --   */
    DEL_CH, /* 36   --  --   */
    DEL_CH, /* 37   --  --   */
    DEL_CH, /* 38   --  --   */
    DEL_CH, /* 39   --  --   */
    DEL_CH, /* 3A   --  --   */
    DEL_CH, /* 3B   --  --   */
    DEL_CH, /* 3C   --  --   */
    DEL_CH, /* 3D   --  --   */
    DEL_CH, /* 3E   --  --   */
    DEL_CH, /* 3F   --  --   */

    DEL_CH, /* 40   3F  --   */
     0x2C,  /* 41   1F  ,    */
     0x28,  /* 42   2F  (    */
     0x12,  /* 43   0F  DC2  */
     0x47,  /* 44   37  G    */
     0x58,  /* 45   17  X    */
     0x50,  /* 46   27  P    */
     0x37,  /* 47   07  7    */
     0x2E,  /* 48   3B  .    */
     0x23,  /* 49   1B  #    */
     0x3E,  /* 4A   2B  >    */
     0x2A,  /* 4B   0B  *    */
     0x43,  /* 4C   33  C    */
     0x54,  /* 4D   13  T    */
     0x4C,  /* 4E   23  L    */
     0x33,  /* 4F   03  3    */

    DEL_CH, /* 50   3D  --   */
     0x25,  /* 51   1D  EOMc(%)  */
     0x3B,  /* 52   2D  ;    */
     0x24,  /* 53   0D  $    */
     0x45,  /* 54   35  E    */
     0x56,  /* 55   15  V    */
     0x4E,  /* 56   25  N    */
     0x35,  /* 57   05  5    */
     0x49,  /* 58   39  I    */


Jun 27 14:44 1995  ahost-tr.h Page 8


     0x5A,  /* 59   19  Z    */
     0x52,  /* 5A   29  R    */
     0x39,  /* 5B   09  9    */
     0x41,  /* 5C   31  A    */
     0x2F,  /* 5D   11  /    */
     0x4A,  /* 5E   21  J    */
     0x31,  /* 5F   01  1    */

    DEL_CH, /* 60   3E  --   */
    DEL_CH, /* 61   1E  --   */
     0x29,  /* 62   2E  )    */
     0x3D,  /* 63   0E  =    */
     0x46,  /* 64   36  F    */
     0x57,  /* 65   16  W    */
     0x4F,  /* 66   26  O    */
     0x36,  /* 67   06  6    */
     0x3F,  /* 68   3A  EOMi(?)  */
     0x2D,  /* 69   1A  -    */
     0x3A,  /* 6A   2A  :    */
     0x30,  /* 6B   0A  0    */
     0x42,  /* 6C   32  B    */
     0x53,  /* 6D   12  S    */
     0x4B,  /* 6E   22  K    */
     0x32,  /* 6F   02  2    */

    DEL_CH, /* 70   3C  --   */
     0x20,  /* 71   1C  space    */
     0x2B,  /* 72   2C  +    */
     0x8A,  /* 73   0C  NL   */
     0x44,  /* 74   34  D    */
     0x55,  /* 75   14  U    */
     0x4D,  /* 76   24  M    */
     0x34,  /* 77   04  4    */
     0x48,  /* 78   38  H    */
     0x59,  /* 79   18  Y    */
     0x51,  /* 7A   28  Q    */
     0x38,  /* 7B   08  8    */
     0x26,  /* 7C   30  &    */
     0x27,  /* 7D   10  '    */
     0x40,  /* 7E   20  @    */
     0x80,  /* 7F   00  NUL  */

};

/*
 *   Ascii to mangle translate table
 *
 *  mangle  ascii   ipars   disp */
static int Ascii_To_Mangle[] = {
     0x7F,  /* 00   00  NUL  */
     0x71,  /* 01   --       */
     0x71,  /* 02   --       */
     0x71,  /* 03   --       */
     0x71,  /* 04   --       */
     0x71,  /* 05   --       */
     0x71,  /* 06   --       */


Jun 27 14:44 1995  ahost-tr.h Page 9


     0x71,  /* 07   --       */
     0x71,  /* 08   --       */
     0x71,  /* 09   --       */
     0x73,  /* 0A   0C  NL   */
     0x71,  /* 0B   --       */
     0x71,  /* 0C   --       */
    DEL_CH, /* 0D   --  --   */
     0x71,  /* 0E   --       */
     0x71,  /* 0F   --       */

     0x71,  /* 10   --       */
     0x71,  /* 11   --       */
     0x43,  /* 12   0F  DC2  */
     0x71,  /* 13   --       */
     0x71,  /* 14   --       */
     0x71,  /* 15   --       */
     0x71,  /* 16   --       */
     0x71,  /* 17   --       */
     0x71,  /* 18   --       */
     0x71,  /* 19   --       */
     0x71,  /* 1A   --       */
     0x71,  /* 1B   --       */
     0x71,  /* 1C   --       */
     0x71,  /* 1D   --       */
     0x71,  /* 1E   --       */
     0x71,  /* 1F   --       */

     0x71,  /* 20   1C  space    */
     0x71,  /* 21   --       */
     0x71,  /* 22   --       */
     0x49,  /* 23   1B  #    */
     0x53,  /* 24   0D  $    */
    0x251,  /* 25   1D  EOMc(%)  */
     0x7C,  /* 26   30  &    */
     0x7D,  /* 27   10  '    */
     0x42,  /* 28   2F  (    */
     0x62,  /* 29   2E  )    */
     0x4B,  /* 2A   0B  *    */
     0x72,  /* 2B   2C  +    */
     0x41,  /* 2C   1F  ,    */
     0x69,  /* 2D   1A  -    */
     0x48,  /* 2E   3B  .    */
     0x5D,  /* 2F   11  /    */

     0x6B,  /* 30   0A  0    */
     0x5F,  /* 31   01  1    */
     0x6F,  /* 32   02  2    */
     0x4F,  /* 33   03  3    */
     0x77,  /* 34   04  4    */
     0x57,  /* 35   05  5    */
     0x67,  /* 36   06  6    */
     0x47,  /* 37   07  7    */
     0x7B,  /* 38   08  8    */
     0x5B,  /* 39   09  9    */
     0x6A,  /* 3A   2A  :    */
     0x52,  /* 3B   2D  ;    */


Jun 27 14:44 1995  ahost-tr.h Page 10


     0x71,  /* 3C   --       */
     0x63,  /* 3D   0E  =    */
     0x4A,  /* 3E   2B  >    */
    0x268,  /* 3F   3A  EOMi(?)  */

     0x7E,  /* 40   20  @    */
     0x5C,  /* 41   31  A    */
     0x6C,  /* 42   32  B    */
     0x4C,  /* 43   33  C    */
     0x74,  /* 44   34  D    */
     0x54,  /* 45   35  E    */
     0x64,  /* 46   36  F    */
     0x44,  /* 47   37  G    */
     0x78,  /* 48   38  H    */
     0x58,  /* 49   39  I    */
     0x5E,  /* 4A   21  J    */
     0x6E,  /* 4B   22  K    */
     0x4E,  /* 4C   23  L    */
     0x76,  /* 4D   24  M    */
     0x56,  /* 4E   25  N    */
     0x66,  /* 4F   26  O    */

     0x46,  /* 50   27  P    */
     0x7A,  /* 51   28  Q    */
     0x5A,  /* 52   29  R    */
     0x6D,  /* 53   12  S    */
     0x4D,  /* 54   13  T    */
     0x75,  /* 55   14  U    */
     0x55,  /* 56   15  V    */
     0x65,  /* 57   16  W    */
     0x45,  /* 58   17  X    */
     0x79,  /* 59   18  Y    */
     0x59,  /* 5A   19  Z    */
    DEL_CH, /* 5B   --  --   */
     0x71,  /* 5C   --       */
     0x71,  /* 5D   --       */
     0x71,  /* 5E   --       */
     0x71,  /* 5F   --       */

     0x71,  /* 60   --       */
     0x5C,  /* 61   31  a    */
     0x6C,  /* 62   32  b    */
     0x4C,  /* 63   33  c    */
     0x74,  /* 64   34  d    */
     0x54,  /* 65   35  e    */
     0x64,  /* 66   36  f    */
     0x44,  /* 67   37  g    */
     0x78,  /* 68   38  h    */
     0x58,  /* 69   39  i    */
     0x5E,  /* 6A   21  j    */
     0x6E,  /* 6B   22  k    */
     0x4E,  /* 6C   23  l    */
     0x76,  /* 6D   24  m    */
     0x56,  /* 6E   25  n    */
     0x66,  /* 6F   26  o    */



Jun 27 14:44 1995  ahost-tr.h Page 11


     0x46,  /* 70   27  p    */
     0x7A,  /* 71   28  q    */
     0x5A,  /* 72   29  r    */
     0x6D,  /* 73   12  s    */
     0x4D,  /* 74   13  t    */
     0x75,  /* 75   14  u    */
     0x55,  /* 76   15  v    */
     0x65,  /* 77   16  w    */
     0x45,  /* 78   17  x    */
     0x79,  /* 79   18  y    */
     0x59,  /* 7A   19  z    */
     0x71,  /* 7B   --       */
     0x71,  /* 7C   --       */
     0x71,  /* 7D   --       */
     0x71,  /* 7E   --       */
     0x71,  /* 7F   --       */

};

