Start development on 386BSD 0.0
[unix-history] / .ref-BSD-4_3_Net_2 / usr / src / contrib / isode / ronot / ronotbind1.c
CommitLineData
d626f7a5
C
1/* ronotbind1.c - RONOT: ABSTRACT-BIND mapping onto A-ASSOCIATE.REQUEST */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/ronot/RCS/ronotbind1.c,v 7.3 91/02/22 09:50:30 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/ronot/RCS/ronotbind1.c,v 7.3 91/02/22 09:50:30 mrose Interim $
9 *
10 *
11 * $Log: ronotbind1.c,v $
12 * Revision 7.3 91/02/22 09:50:30 mrose
13 * Interim 6.8
14 *
15 * Revision 7.2 90/08/08 14:14:48 mrose
16 * update
17 *
18 * Revision 7.1 90/07/26 14:33:55 mrose
19 * template
20 *
21 */
22
23/*
24 * NOTICE
25 *
26 * Acquisition, use, and distribution of this module and related
27 * materials are subject to the restrictions of a license agreement.
28 * Consult the Preface in the User's Manual for the full terms of
29 * this agreement.
30 *
31 */
32
33
34/* LINTLIBRARY */
35
36#include "tailor.h"
37#include "logger.h"
38#include "ronot.h"
39#include "RONOT-types.h"
40
41
42/* \f RO-BIND.REQUEST */
43
44/* ARGSUSED */
45
46int RoAsynBindRequest (context, callingtitle, calledtitle,
47 callingaddr, calledaddr, ctxlist, defctxname,
48 prequirements, srequirements, isn, settings, ref,
49 bindargpe, qos, acc, rni, async)
50OID context;
51AEI callingtitle;
52AEI calledtitle;
53struct PSAPaddr * callingaddr;
54struct PSAPaddr * calledaddr;
55struct PSAPctxlist * ctxlist;
56OID defctxname;
57int prequirements;
58int srequirements;
59long isn;
60int settings;
61struct SSAPref * ref;
62PE bindargpe;
63struct QOStype * qos;
64struct AcSAPconnect * acc;
65struct RoNOTindication * rni;
66int async;
67{
68 int result;
69 PE user_data;
70 PE * user_data_p = &(user_data);
71 int ndata;
72 struct AcSAPindication aci_s;
73 struct AcSAPindication * aci = &(aci_s);
74 struct AcSAPabort * aca = &(aci->aci_abort);
75
76
77 /* Wrap the user data with the remote operations BIND ARGUMENT tag */
78
79 if (bindargpe != NULLPE)
80 {
81 if (encode_RONOT_BindArgumentValue (user_data_p, 1, 0, NULLCP, bindargpe) == NOTOK)
82 {
83 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.REQUEST : encode_RONOT_BindArgumentValue failed"));
84 return (ronotlose (rni, RBI_ENC_BIND_ARG, NULLCP, NULLCP));
85 }
86
87 /*
88 * Set the context of the user data presentation element
89 * from the context of the bind argument presentation element
90 */
91 (*user_data_p)->pe_context = bindargpe->pe_context;
92 ndata = 1;
93 }
94 else
95 {
96 (*user_data_p) = NULLPE;
97 ndata = 0;
98 }
99
100 result = AcAsynAssocRequest (context, callingtitle, calledtitle,
101 callingaddr, calledaddr, ctxlist, defctxname,
102 prequirements, srequirements, isn, settings, ref,
103 user_data_p, ndata, qos, acc, aci, async);
104
105 if ((*user_data_p) != NULLPE)
106 {
107 pe_free ((*user_data_p));
108 }
109
110 if (result == NOTOK)
111 {
112 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.REQUEST : RoAsynBindRequest failed"));
113 /* Have an AcSAPindication, need to return RoNOTindication */
114 (void) acs2ronotlose (rni, "RO-BIND.REQUEST", aca);
115 ACAFREE (aca);
116 return (NOTOK);
117 }
118
119 if (((!async) && (result == OK)) || (async && (result == DONE)))
120 {
121 if (acc->acc_result == ACS_ACCEPT)
122 {
123 struct RoSAPindication roi_s;
124
125 if (RoSetService (acc->acc_sd, RoPService, &(roi_s)) == NOTOK)
126 {
127 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.REQUEST : RoSetService failed"));
128 return (ronotlose (rni, RBI_SET_ROSE_PRES, NULLCP, NULLCP));
129 }
130 }
131
132 if (ParseRoBindResponse (acc, rni) != OK)
133 {
134 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.REQUEST : ParseRoBindResponse failed"));
135 ACCFREE (acc);
136 return (NOTOK);
137 }
138 }
139
140 return (result);
141}
142
143/* \f RO-BIND.RETRY */
144
145/* ARGSUSED */
146
147int RoAsynBindRetry (ad, do_next_nsap, acc, rni)
148int ad;
149int do_next_nsap;
150struct AcSAPconnect * acc;
151struct RoNOTindication * rni;
152{
153 int result;
154 struct AcSAPindication aci_s;
155 struct AcSAPindication * aci = &aci_s;
156 struct AcSAPabort * aca = &(aci->aci_abort);
157
158 if (do_next_nsap)
159 {
160 result = AcAsynNextRequest (ad, acc, aci);
161 }
162 else
163 {
164 result = AcAsynRetryRequest (ad, acc, aci);
165 }
166
167 if (result == NOTOK)
168 {
169 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.RETRY : AcAsynRetryRequest failed"));
170 (void) acs2ronotlose (rni, "RO-BIND.RETRY", aca);
171 ACAFREE (aca);
172 return (NOTOK);
173 }
174
175 if (result == DONE)
176 {
177 if (acc->acc_result == ACS_ACCEPT)
178 {
179 struct RoSAPindication roi_s;
180
181 if (RoSetService (acc->acc_sd, RoPService, &(roi_s)) == NOTOK)
182 {
183 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.REQUEST : RoSetService failed"));
184 return (ronotlose (rni, RBI_SET_ROSE_PRES, NULLCP, NULLCP));
185 }
186 }
187
188 if (ParseRoBindResponse (acc, rni) != OK)
189 {
190 LLOG (rosap_log, LLOG_NOTICE, ("RO-BIND.RETRY : ParseRoBindResponse failed"));
191 ACCFREE (acc);
192 return (NOTOK);
193 }
194 }
195
196 return (result);
197}
198
199int ParseRoBindResponse (acc, rni)
200struct AcSAPconnect *acc;
201struct RoNOTindication * rni;
202{
203 PE pe;
204
205 if (acc->acc_ninfo == 0)
206 return (OK);
207
208 if (acc->acc_ninfo != 1)
209 return (ronotlose (rni, RBI_DEC_NINFO, NULLCP, NULLCP));
210
211 if (acc->acc_info[0] == NULLPE)
212 return (ronotlose (rni, RBI_DEC_NINFO, NULLCP, NULLCP));
213
214 pe = acc->acc_info[0];
215 acc->acc_info[0] = NULLPE;
216 if (acc->acc_result == ACS_ACCEPT)
217 {
218 if (decode_RONOT_BindResultValue (pe, 1, NULLIP, NULLVP, &acc->acc_info[0]) != OK)
219 {
220 /* ADT: Should end association here !?! */
221 LLOG (rosap_log, LLOG_EXCEPTIONS, ("ParseRoBindResponse: decode_RONOT_BindResultValue failed"));
222 acc->acc_ninfo = 0;
223 pe_free (pe);
224 return (ronotlose (rni, RBI_DEC_BIND_RES, NULLCP, NULLCP));
225 }
226 }
227 else
228 {
229 if (decode_RONOT_BindErrorValue (pe, 1, NULLIP, NULLVP, &acc->acc_info[0]) != OK)
230 {
231 LLOG (rosap_log, LLOG_EXCEPTIONS, ("ParseRoBindResponse: decode_RONOT_BindErrorValue failed"));
232 acc->acc_ninfo = 0;
233 pe_free (pe);
234 return (ronotlose (rni, RBI_DEC_BIND_ERR, NULLCP, NULLCP));
235 }
236 }
237 pe_free (pe);
238
239 return (OK);
240}
241