|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T i
Length: 5209 (0x1459)
Types: TextFile
Names: »interim.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/others/interim/interim.c«
/* interim.c - convert address in old string format to new string format */
#ifndef lint
static char *rcsid = "$Header: /f/osi/others/interim/RCS/interim.c,v 6.0 89/03/18 23:35:09 mrose Rel $";
#endif
/*
* $Header: /f/osi/others/interim/RCS/interim.c,v 6.0 89/03/18 23:35:09 mrose Rel $
*
*
* $Log: interim.c,v $
* Revision 6.0 89/03/18 23:35:09 mrose
* Release 5.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 <isode/general.h>
#include <isode/manifest.h>
#include <isode/isoaddrs.h>
#include <isode/tailor.h>
struct PSAPaddr *o_str2paddr ();
/* \f
*/
/* ARGSUSED */
main (argc, argv, envp)
int argc;
char **argv,
**envp;
{
char *cp;
struct PSAPaddr *pa;
isodetailor (argv[0], 0);
ll_dbinit (addr_log, argv[0]);
for (argv++; *argv; argv++)
if ((pa = o_str2paddr (*argv)) == NULL)
fprintf (stderr, "%s: loses\n", *argv);
else
if (cp = paddr2str (pa, NULLNA))
printf ("%s\n", cp);
else
fprintf (stderr," %s: can't encode\n", *argv);
exit (0);
}
/* \f
OLD-STYLE */
/* \f
DATA */
static int mask;
static int vecp;
static char *vec[NVEC + NSLACK + 1];
struct nsap_entry {
char *ns_service;
IFP ns_parse;
};
int tcpparse (), x25parse (), nsapparse ();
static struct nsap_entry _nsap_entries[] = {
"NS", nsapparse,
"TCP", tcpparse,
"X.25", x25parse,
NULL
};
/* \f
*/
/*
syntax:
<psel> # <ssel> # <tsel> # <net> # <arg1> # <arg2> # <arg3> # <arg4>
# | <net> # ...
where
<net> is one of: NS, X.25, or TCP
for
NS: <arg1> is the NSAP address
TCP: <arg1> is the domain
<arg2> is the port number
<arg3> is the transport set
X.25: <arg1> is the dte
<arg2> is the pid
<arg3> is the cudf (not yet)
<arg4> is the fac (not yet)
*/
/* \f
*/
static struct PSAPaddr *o_str2paddr (str)
char *str;
{
register char **ap,
**np;
char buffer[BUFSIZ];
register struct nsap_entry *ns;
static int i = 0;
static struct PSAPaddr pas[2];
register struct PSAPaddr *pa = &pas[i++];
register struct SSAPaddr *sa = &pa -> pa_addr;
register struct TSAPaddr *ta = &sa -> sa_addr;
register struct NSAPaddr *na = ta -> ta_addrs;
i = i % 2;
bzero ((char *) pa, sizeof *pa);
(void) strcpy (buffer, str);
if ((vecp = str2vecX (buffer, vec, 2 + 1, &mask, '#')) < 4)
return NULLPA;
pa -> pa_selectlen = str2sel (vec[0], (mask & (1 << 0)) ? 1 : 0,
pa -> pa_selector, PSSIZE);
sa -> sa_selectlen = str2sel (vec[1], (mask & (1 << 1)) ? 1 : 0,
sa -> sa_selector, SSSIZE);
ta -> ta_selectlen = str2sel (vec[2], (mask & (1 << 2)) ? 1 : 0,
ta -> ta_selector, TSSIZE);
for (ap = vec + 3; *ap; ap = np) {
for (np = ap + 1; *np; np++)
if (strcmp (*np, "|") == 0) {
*np++ = NULL;
break;
}
for (ns = _nsap_entries; ns -> ns_service; ns++)
if (strcmp (ns -> ns_service, *ap) == 0)
if ((*ns -> ns_parse) (na, ap + 1) == OK) {
ta -> ta_naddr++, na++;
break;
}
else
return NULLPA;
if (!ns -> ns_service)
return NULLPA;
if (ta -> ta_naddr >= NTADDR)
break;
}
return pa;
}
/* \f
*/
static int nsapparse (na, args)
register struct NSAPaddr *na;
char **args;
{
char *cp;
na -> na_type = NA_NSAP;
if ((cp = *args++) == NULL) {
na -> na_addrlen = 0;
return OK;
}
na -> na_addrlen = implode ((u_char *) na -> na_address, cp, strlen (cp));
return OK;
}
/* \f
*/
static int tcpparse (na, args)
register struct NSAPaddr *na;
char **args;
{
int i;
if (*args == NULL)
return NOTOK;
na -> na_type = NA_TCP;
(void) strncpy (na -> na_domain, *args++, sizeof na -> na_domain);
if (*args && (i = atoi (*args++)) > 0) {
na -> na_port = htons ((u_short) i);
if (*args)
na -> na_tset = atoi (*args++);
}
return OK;
}
/* \f
*/
static int x25parse (na, args)
register struct NSAPaddr *na;
char **args;
{
register char *cp;
if (*args == NULL)
return NOTOK;
for (cp = *args; *cp; cp++)
if (!isxdigit (*cp))
return NOTOK;
if (cp - *args > (NSAP_DTELEN + 1) /* Maximum X.121 DTE address length */ )
return NOTOK;
(void) strcpy (na -> na_dte, *args++);
na -> na_dtelen = strlen (na -> na_dte);
/* The only optional argument is the Protocol ID.
* This may be a hex string (e.g. 03010100) or a (quoted) string.
*/
if (*args) {
#ifdef DEBUG
int len;
if ((len = strlen (*args)) != NPSIZE * 2)
SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
("invalid PID string \"%s\" length %d (should be %d)",
*args, len, NPSIZE * 2));
#endif
/* bogus use of -1 for "quoted" argument, really should be told if quoted or
not */
na -> na_pidlen = str2sel (*args, -1, na -> na_pid, NPSIZE);
}
#ifdef BRIDGE_X25
na -> na_type = bridgediscrim (na) ? NA_BRG : NA_X25;
#else
na -> na_type = NA_X25;
#endif
return OK;
}