DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦4f626253e⟧ TextFile

    Length: 8368 (0x20b0)
    Types: TextFile
    Names: »dse.py«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/acsap/dse.py« 

TextFile

-- dse.py - help out co-resident DSE

-- $Header: /f/osi/acsap/RCS/dse.py,v 6.0 89/03/18 23:24:37 mrose Rel $
--
--
-- $Log:	dse.py,v $
-- Revision 6.0  89/03/18  23:24:37  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.
--
--


DSE DEFINITIONS ::=
%{
#ifndef	lint
static char *rcsid = "$Header: /f/osi/acsap/RCS/dse.py,v 6.0 89/03/18 23:24:37 mrose Rel $";
#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
	%{
#define	x(a,b)	((char) (((a) << 4) | b))
	    static char interim_idp[] = {
		x (5, 4), x (0, 0), x (7, 2), x (8, 7), x (2, 2)
	    };
#undef	x

	    na -> na_type = NA_NSAP;

	    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_INTL_X25;
	    }
	    else
		if ($$_len > sizeof interim_idp
		        && bcmp ($$, interim_idp, sizeof interim_idp) ==0) {
		    int	    i,
			    ilen,
			    rlen;
		    register char   *cp,
				    *dp,
				    *ep;
		    char    nsap[NASIZE * 2 + 1];

		    dp = nsap;
		    for (cp = $$ + sizeof interim_idp, 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;
		    if (strlen (cp) < 2) {
			LLOG (addr_log, LLOG_EXCEPTIONS,
			      ("missing DSP prefix"));
			goto realNS;
		    }

		    (void) sscanf (cp, "%2d", &i);
		    cp += 2;
		    switch (na -> na_subnet = i) {
			case SUBNET_INTL_X25:
			case SUBNET_JANET:
			    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
			    na -> na_type = bridgediscrim (na) ? NA_BRG
							       : NA_X25;
#else
			    na -> na_type = NA_X25;
#endif
			    break;

			case SUBNET_INTERNET:
			    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));
				}
			    }

			    na -> na_type = NA_TCP;
			    break;

			default:
			    LLOG (addr_log, LLOG_EXCEPTIONS,
				  ("unknown DSP prefix for interim IDP: %s",
				   nsap));
			    goto realNS;
			}
		}
		else {
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