|
|
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 d
Length: 8287 (0x205f)
Types: TextFile
Names: »dse.py«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z«
└─⟦de7628f85⟧
└─⟦this⟧ »isode-6.0/acsap/dse.py«
-- dse.py - help out co-resident DSE
-- $Header: /f/osi/acsap/RCS/dse.py,v 7.1 89/12/04 08:44:12 mrose Exp $
--
--
-- $Log: dse.py,v $
-- Revision 7.1 89/12/04 08:44:12 mrose
-- touch-up
--
-- Revision 7.0 89/11/23 21:22: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.
--
--
DSE DEFINITIONS ::=
%{
#ifndef lint
static char *rcsid = "$Header: /f/osi/acsap/RCS/dse.py,v 7.1 89/12/04 08:44:12 mrose Exp $";
#endif
#include <stdio.h>
#include "psap.h"
#include "isoaddrs.h"
#include "tailor.h"
/* Encoding on "unrealNS" addresses based on
"An interim approach to use of Network Addresses",
S.E. Kille, January 16, 1989
*/
/* \f
*/
#define getstr(ss,sl,ds,dl,dn,w) \
if (sl > dn) { \
advise (NULLCP, "%s too long", w); \
return NOTOK; \
} \
bcopy (ss, ds, dl = sl);
%}
BEGIN
ENCODER build
PSAPaddr
%{
register int n;
struct PSAPaddr *pa = (struct PSAPaddr *) parm;
struct SSAPaddr *sa = &pa -> pa_addr;
struct TSAPaddr *ta = &sa -> sa_addr;
register struct NSAPaddr *na,
*ca;
%}
::=
SEQUENCE {
pSelector[0]
OCTET STRING
[[ o pa -> pa_selector $ pa -> pa_selectlen ]]
OPTIONAL << pa -> pa_selectlen >>,
sSelector[1]
OCTET STRING
[[ o sa -> sa_selector $ sa -> sa_selectlen ]]
OPTIONAL << sa -> sa_selectlen >>,
tSelector[2]
OCTET STRING
[[ o ta -> ta_selector $ ta -> ta_selectlen ]]
OPTIONAL << ta -> ta_selectlen >>,
nAddress[3]
SET OF
%{
if ((ca = na2norm (na)) == NULLNA) {
advise (NULLCP,
"unable to normalize address, check logs");
return NOTOK;
}
%}
<<na = ta -> ta_addrs, n = ta -> ta_naddr; n > 0; na++, n-->>
OCTET STRING
[[ o ca -> na_address $ ca -> na_addrlen ]]
}
DECODER parse
PSAPaddr
%{
struct PSAPaddr *pa = (struct PSAPaddr *) parm;
struct SSAPaddr *sa = &pa -> pa_addr;
struct TSAPaddr *ta = &sa -> sa_addr;
%}
::=
%{
bzero ((char *) pa, sizeof *pa);
%}
SEQUENCE {
pSelector[0]
OCTET STRING
%{
getstr ($$, $$_len, pa -> pa_selector, pa -> pa_selectlen,
sizeof pa -> pa_selector, "psap selector");
%}
OPTIONAL,
sSelector[1]
OCTET STRING
%{
getstr ($$, $$_len, sa -> sa_selector, sa -> sa_selectlen,
sizeof sa -> sa_selector, "ssap selector");
%}
OPTIONAL,
tSelector[2]
OCTET STRING
%{
getstr ($$, $$_len, ta -> ta_selector, ta -> ta_selectlen,
sizeof ta -> ta_selector, "tsap selector");
%}
OPTIONAL,
nAddress[3]
SET OF
%{
if (ta -> ta_naddr >= NTADDR) {
advise (NULLCP, "too many network addresses");
return NOTOK;
}
%}
NSAPaddr
[[ p (char *) &ta -> ta_addrs[ta -> ta_naddr++] ]]
}
NSAPaddr
%{
struct NSAPaddr *na = (struct NSAPaddr *) parm;
%}
::=
OCTET STRING
%{
if (($$_len == 8)
&& (($$[0] == 0x36) || ($$[0] == 0x37))) {
int xlen; /* SEK - X121 form */
register char *cp,
*cp2,
*dp;
char nsap[14];
dp = nsap;
for (cp2 = (cp = $$ + 1) + 7; cp < cp2; cp++) {
register int j;
if ((j = ((*cp & 0xf0) >> 4)) > 9)
goto concrete;
*dp++ = j + '0';
if ((j = (*cp & 0x0f)) > 9) {
if (j != 0x0f)
goto concrete;
}
else
*dp++ = j + '0';
}
for (cp = nsap, xlen = 14; *cp == '0'; cp++, xlen--)
continue;
na -> na_dtelen = xlen;
for (cp2 = na -> na_dte; xlen-- > 0; )
*cp2++ = *cp++;
*cp2 = NULL;
#ifdef BRIDGE_X25
na -> na_type = bridgediscrim (na) ? NA_BRG : NA_X25;
#else
na -> na_type = NA_X25;
#endif
na -> na_subnet = SUBNET_INT_X25;
}
else {
register struct ts_interim *ts,
*tp;
tp = NULL;
for (ts = ts_interim; ts -> ts_name; ts++)
if ($$_len > ts -> ts_length
&& (tp == NULL
|| ts -> ts_length > tp -> ts_length)
&& bcmp ($$, ts -> ts_prefix,
ts -> ts_length) == 0)
tp = ts;
if (tp) {
int i,
ilen,
rlen;
register char *cp,
*dp,
*ep;
char nsap[NASIZE * 2 + 1];
dp = nsap;
for (cp = $$ + tp -> ts_length, ep = $$ + $$_len;
cp < ep;
cp++) {
register int j;
if ((j = ((*cp & 0xf0) >> 4)) > 9) {
concrete: ;
LLOG (addr_log, LLOG_EXCEPTIONS,
("invalid concrete encoding"));
goto realNS;
}
*dp++ = j + '0';
if ((j = (*cp & 0x0f)) > 9) {
if (j != 0x0f)
goto concrete;
}
else
*dp++ = j + '0';
}
*dp = NULL;
cp = nsap;
na -> na_subnet = tp -> ts_subnet;
switch (na -> na_type = tp -> ts_syntax) {
case NA_X25:
if (strlen (cp) < 1) {
LLOG (addr_log, LLOG_EXCEPTIONS,
("missing DTE+CUDF indicator: %s",
nsap));
goto realNS;
}
(void) sscanf (cp, "%1d", &i);
cp += 1;
switch (i) {
case 0: /* DTE only */
break;
case 1: /* DTE+PID */
case 2: /* DTE+CUDF */
if (strlen (cp) < 1) {
LLOG (addr_log, LLOG_EXCEPTIONS,
("missing DTE+CUDF indicator: %s",
nsap));
goto realNS;
}
(void) sscanf (cp, "%1d", &ilen);
cp += 1;
rlen = ilen * 3;
if (strlen (cp) < rlen) {
LLOG (addr_log, LLOG_EXCEPTIONS,
("bad DTE+CUDF length: %s",
nsap));
goto realNS;
}
if (i == 1) {
if (ilen > NPSIZE) {
LLOG (addr_log,
LLOG_EXCEPTIONS,
("PID too long: %s",
nsap));
goto realNS;
}
dp = na -> na_pid;
na -> na_pidlen = ilen;
}
else {
if (ilen > CUDFSIZE) {
LLOG (addr_log,
LLOG_EXCEPTIONS,
("CUDF too long: %s",
nsap));
goto realNS;
}
dp = na -> na_cudf;
na -> na_cudflen = ilen;
}
for (; rlen > 0; rlen -= 3) {
(void) sscanf (cp, "%3d", &i);
cp += 3;
if (i > 255) {
LLOG (addr_log,
LLOG_EXCEPTIONS,
("invalid PID/CUDF: %s",
nsap));
goto realNS;
}
*dp++ = i & 0xff;
}
break;
default:
LLOG (addr_log, LLOG_EXCEPTIONS,
("invalid DTE+CUDF indicator: %s",
nsap));
goto realNS;
}
(void) strcpy (na -> na_dte, cp);
na -> na_dtelen = strlen (na -> na_dte);
#ifdef BRIDGE_X25
if (bridgediscrim (na))
na -> na_type = NA_BRG;
#endif
break;
case NA_TCP:
if (strlen (cp) < 12) {
LLOG (addr_log, LLOG_EXCEPTIONS,
("missing IP address: %s", nsap));
goto realNS;
}
{
int q[4];
(void) sscanf (cp, "%3d%3d%3d%3d", q,
q + 1, q + 2, q + 3);
(void) sprintf (na -> na_domain,
"%d.%d.%d.%d",
q[0], q[1], q[2], q[3]);
}
cp += 12;
if (*cp) {
if (strlen (cp) < 5) {
LLOG (addr_log, LLOG_EXCEPTIONS,
("missing port: %s", nsap));
goto realNS;
}
(void) sscanf (cp, "%5d", &i);
cp += 5;
na -> na_port = htons ((u_short) i);
if (*cp) {
if (strlen (cp) < 5) {
LLOG (addr_log, LLOG_EXCEPTIONS,
("missing tset: %s", nsap));
goto realNS;
}
(void) sscanf (cp, "%5d", &i);
cp += 5;
na -> na_tset = (u_short) i;
if (*cp)
LLOG (addr_log, LLOG_EXCEPTIONS,
("extra TCP information: %s",
nsap));
}
}
break;
default:
LLOG (addr_log, LLOG_NOTICE,
("unknown syntax %d for DSP: %s",
ts -> ts_syntax, nsap));
goto realNS;
}
}
else {
realNS: ;
na -> na_type = NA_NSAP;
na -> na_subnet = SUBNET_REALNS;
getstr ($$, $$_len, na -> na_address, na -> na_addrlen,
sizeof na -> na_address, "NSAP address");
}
}
%}
PRINTER print
PSAPaddr ::=
SEQUENCE {
pSelector[0]
OCTET STRING
OPTIONAL,
sSelector[1]
OCTET STRING
OPTIONAL,
tSelector[2]
OCTET STRING
OPTIONAL,
nAddress[3]
SET OF
OCTET STRING
}
END