|
|
1.1 root 1: /* acsaprovider.c - implement the association control protocol */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/acsap/RCS/acsaprovider.c,v 7.0 89/11/23 21:21:59 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/acsap/RCS/acsaprovider.c,v 7.0 89/11/23 21:21:59 mrose Rel $
9: *
10: *
11: * $Log: acsaprovider.c,v $
12: * Revision 7.0 89/11/23 21:21:59 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: /* LINTLIBRARY */
29:
30: #include <stdio.h>
31: #include <signal.h>
32: #include "ACS-types.h"
33: #define ACSE
34: #include "acpkt.h"
35: #include "tailor.h"
36:
37: /* PSAP interface */
38:
39: int ps2acslose (acb, aci, event, pa)
40: register struct assocblk *acb;
41: register struct AcSAPindication *aci;
42: char *event;
43: register struct PSAPabort *pa;
44: {
45: int reason;
46: char *cp,
47: buffer[BUFSIZ];
48:
49: if (event)
50: SLOG (addr_log, LLOG_EXCEPTIONS, NULLCP,
51: (pa -> pa_cc > 0 ? "%s: %s [%*.*s]": "%s: %s", event,
52: PErrString (pa -> pa_reason), pa -> pa_cc, pa -> pa_cc,
53: pa -> pa_data));
54:
55: cp = "";
56: switch (pa -> pa_reason) {
57: case PC_ADDRESS:
58: reason = ACS_ADDRESS;
59: break;
60:
61: case PC_REFUSED:
62: reason = ACS_REFUSED;
63: break;
64:
65: case PC_CONGEST:
66: reason = ACS_CONGEST;
67: break;
68:
69: case PC_PARAMETER:
70: reason = ACS_PARAMETER;
71: break;
72:
73: case PC_OPERATION:
74: reason = ACS_OPERATION;
75: break;
76:
77: case PC_TIMER:
78: reason = ACS_TIMER;
79: break;
80:
81: default:
82: (void) sprintf (cp = buffer, " (%s at presentation)",
83: PErrString (pa -> pa_reason));
84: case PC_SESSION:
85: reason = ACS_PRESENTATION;
86: break;
87: }
88:
89: if (ACS_FATAL (reason)) {
90: if (pa -> pa_cc > 0)
91: return acpktlose (acb, aci, reason, NULLCP, "%*.*s%s",
92: pa -> pa_cc, pa -> pa_cc, pa -> pa_data, cp);
93: else
94: return acpktlose (acb, aci, reason, NULLCP, "%s",
95: *cp ? cp + 1 : cp);
96: }
97: else {
98: if (pa -> pa_cc > 0)
99: return acsaplose (aci, reason, NULLCP, "%*.*s%s",
100: pa -> pa_cc, pa -> pa_cc, pa -> pa_data, cp);
101: else
102: return acsaplose (aci, reason, NULLCP, "%s",
103: *cp ? cp + 1 : cp);
104: }
105: }
106:
107: /* INTERNAL */
108:
109: /*
110: Owing to laziness on our part, we use only ASN.1 transfer syntax.
111: */
112:
113: /* ARGSUSED */
114:
115: struct type_ACS_Association__information *info2apdu (acb, aci, data, ndata)
116: struct assocblk *acb;
117: struct AcSAPindication *aci;
118: PE *data;
119: int ndata;
120: {
121: register PE pe;
122: struct type_ACS_Association__information *info;
123: register struct type_ACS_Association__information **pp,
124: *p;
125: register struct type_UNIV_EXTERNAL *q;
126:
127: for (pp = &info; ndata-- > 0; pp = &p -> next) {
128: if ((*pp = p = (struct type_ACS_Association__information *)
129: calloc (1, sizeof *p)) == NULL
130: || (p -> EXTERNAL = (struct type_UNIV_EXTERNAL *)
131: calloc (1, sizeof *q)) == NULL
132: || (p -> EXTERNAL -> encoding = (struct choice_UNIV_0 *)
133: malloc (sizeof (struct choice_UNIV_0))) == NULL)
134: goto out;
135: q = p -> EXTERNAL;
136:
137: if (!(acb -> acb_flags & ACB_CONN)
138: && (q -> direct__reference = oid_cpy (ode2oid (BER)))
139: == NULLOID)
140: goto out;
141: q -> indirect__reference = (pe = *data++) -> pe_context;
142: q -> encoding -> offset = choice_UNIV_0_single__ASN1__type;
143: (q -> encoding -> un.single__ASN1__type = pe) -> pe_refcnt++;
144: }
145: (*pp) = NULL;
146:
147: return info;
148:
149: out: ;
150: free_ACS_Association__information (info);
151:
152: (void) acsaplose (aci, ACS_CONGEST, NULLCP, "out of memory");
153:
154: return NULL;
155: }
156:
157: /* */
158:
159: /* ARGSUSED */
160:
161: int apdu2info (acb, aci, info, data, ndata)
162: struct assocblk *acb;
163: struct AcSAPindication *aci;
164: struct type_ACS_Association__information *info;
165: PE *data;
166: int *ndata;
167: {
168: register int i;
169: register PE pe;
170: register struct type_UNIV_EXTERNAL *q;
171:
172: for (i = 0; info; info = info -> next, i++) {
173: if (i > NACDATA)
174: return acpktlose (acb, aci, ACS_CONGEST, NULLCP,
175: "too much user information");
176:
177: q = info -> EXTERNAL;
178: if (q -> encoding -> offset != choice_UNIV_0_single__ASN1__type)
179: return acpktlose (acb, aci, ACS_PROTOCOL, NULLCP,
180: "EXTERNAL data not single-ASN1-type");
181:
182: (pe = q -> encoding -> un.single__ASN1__type) -> pe_refcnt++;
183: pe -> pe_context = q -> indirect__reference;
184:
185: *data++ = pe;
186: }
187: *ndata = i;
188:
189: return OK;
190: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.