/* na2norm.c - normalize NSAPaddr */
static char *rcsid
= "$Header: /f/osi/compat/RCS/na2norm.c,v 7.3 91/02/22 09:15:36 mrose Interim $";
* $Header: /f/osi/compat/RCS/na2norm.c,v 7.3 91/02/22 09:15:36 mrose Interim $
* Revision 7.3 91/02/22 09:15:36 mrose
* Revision 7.2 90/08/08 14:03:00 mrose
* Revision 7.1 90/07/09 14:32:04 mrose
* Revision 7.0 89/11/23 21:23:18 mrose
* 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
"An interim approach to use of Network Addresses",
S.E. Kille, January 16, 1989
struct NSAPaddr
*na2norm (na
)
register struct NSAPaddr
*na
;
char nsap
[NASIZE
* 2 + 1];
register struct hostent
*hp
;
register struct ts_interim
*ts
;
static struct NSAPaddr nas
;
register struct NSAPaddr
*ca
= &nas
;
if (na
-> na_stack
== NA_NSAP
) {
*ca
= *na
; /* struct copy */
bzero ((char *) ca
, sizeof *ca
);
ca
-> na_stack
= NA_NSAP
;
for (ts
= ts_interim
; ts
-> ts_name
; ts
++)
if (ts
-> ts_subnet
== na
-> na_community
)
SLOG (addr_log
, LLOG_EXCEPTIONS
, NULLCP
,
("unable to find community #%d", na
-> na_community
));
switch (na
-> na_stack
) {
if ((hp
= gethostbystring (na
-> na_domain
)) == NULL
) {
SLOG (addr_log
, LLOG_EXCEPTIONS
, NULLCP
,
("%s: unknown host", na
-> na_domain
));
#define s2a(b) (((int) (b)) & 0xff)
(void) sprintf (cp
, "%03d%03d%03d%03d",
(void) sprintf (cp
, "%05d", (int) ntohs (na
-> na_port
));
if (na
-> na_tset
|| na
-> na_tset
!= NA_TSET_TCP
) {
(void) sprintf (cp
, "%05d", (int) na
-> na_tset
);
if (na
-> na_community
== SUBNET_INT_X25
&& na
-> na_dte
[0] != '0') { /* SEK - X121 form */
/* should be more general */
(void) sprintf (nsap
, "36%014s", na
-> na_dte
);
if (ilen
= na
-> na_pidlen
& 0xff)
*cp
++ = '1', dp
= na
-> na_pid
;
if (ilen
= na
-> na_cudflen
& 0xff)
*cp
++ = '2', dp
= na
-> na_cudf
;
(void) sprintf (cp
, "%01d", ilen
);
for (; ilen
-- > 0; cp
+= 3)
(void) sprintf (cp
, "%03d", *dp
++ & 0xff);
(void) strcpy (cp
, na
-> na_dte
);
SLOG (addr_log
, LLOG_EXCEPTIONS
, NULLCP
,
("unknown address type 0x%x", na
-> na_stack
));
cp
= nsap
, dp
= ca
-> na_address
;
bcopy (ts
-> ts_prefix
, dp
, ts
-> ts_length
);
*dp
= (*cp
++ - '0') << 4;
*dp
++ |= (*cp
++ - '0') & 0x0f;
ca
-> na_addrlen
= dp
- ca
-> na_address
;