|
|
1.1 root 1: /* dapbind.c - Establish directory association */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/dsap/net/RCS/dapbind.c,v 7.0 90/07/26 14:45:20 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/dsap/net/RCS/dapbind.c,v 7.0 90/07/26 14:45:20 mrose Exp $
9: *
10: *
11: * $Log: dapbind.c,v $
12: * Revision 7.0 90/07/26 14:45:20 mrose
13: * *** empty log message ***
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 "quipu/util.h"
31: #include "quipu/oid.h"
32: #include "quipu/dap2.h"
33:
34: extern LLog * log_dsap;
35: extern int dsap_ad; /* Association descriptor */
36: extern int dsap_id; /* Last id sent */
37: extern char * dsa_address; /* address of default dsa */
38: struct PSAPaddr dsa_bound;
39:
40:
41: ds_bind (arg, error, result)
42: struct ds_bind_arg *arg;
43: struct ds_bind_arg *result;
44: struct ds_bind_error *error;
45: {
46: /* reverse compatability for bind */
47: arg->dba_auth_type = DBA_AUTH_SIMPLE;
48: arg->dba_time1 = NULLCP;
49: arg->dba_time2 = NULLCP;
50:
51: return (secure_ds_bind (arg,error,result));
52: }
53:
54: secure_ds_bind (arg, error, result)
55: struct ds_bind_arg *arg;
56: struct ds_bind_arg *result;
57: struct ds_bind_error *error;
58: {
59: struct PSAPaddr *addr;
60:
61: if ((addr = str2paddr (dsa_address)) == NULLPA)
62: {
63: LLOG(log_dsap, LLOG_EXCEPTIONS, ("invalid name %s",dsa_address));
64: return (DS_ERROR_LOCAL);
65: }
66:
67: return(dap_bind(&(dsap_ad), arg, error, result, addr));
68: }
69:
70: dap_bind (ad, arg, error, result, addr)
71: int * ad;
72: struct ds_bind_arg *arg;
73: struct ds_bind_arg *result;
74: struct ds_bind_error *error;
75: struct PSAPaddr *addr;
76: {
77: int ret;
78: struct DAPconnect dc_s;
79: struct DAPconnect *dc = &dc_s;
80: struct DAPindication di_s;
81: struct DAPindication *di = &di_s;
82:
83: DLOG(log_dsap, LLOG_DEBUG, ("dap_bind: Address: %s", paddr2str(addr,NULLNA)));
84:
85: ret = DapAsynBindRequest ( addr, arg, dc, di, ROS_SYNC);
86:
87: if (ret == NOTOK)
88: {
89: LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapAsynBindRequest() failed"));
90: return (DS_ERROR_CONNECT);
91: }
92:
93: if (dc->dc_result == DC_RESULT)
94: {
95:
96: dsa_bound = dc->dc_connect.acc_connect.pc_responding; /* struct copy */
97:
98: (*ad) = dc->dc_sd;
99:
100: *result = dc->dc_un.dc_bind_res; /* struct copy */
101:
102: DCFREE(dc);
103: return (DS_OK);
104: }
105:
106: if (dc->dc_result == DC_ERROR)
107: {
108: *error = dc->dc_un.dc_bind_err;
109:
110: DCFREE(dc);
111: return (DS_X500_ERROR);
112: }
113:
114: return (DS_ERROR_CONNECT);
115:
116: }
117:
118: /* DAP-BIND.REQUEST */
119:
120: /* ARGSUSED */
121:
122: int DapAsynBindReqAux (callingtitle, calledtitle, callingaddr,
123: calledaddr, prequirements, srequirements, isn, settings,
124: sf, bindarg, qos, dc, di, async)
125: AEI callingtitle;
126: AEI calledtitle;
127: struct PSAPaddr * callingaddr;
128: struct PSAPaddr * calledaddr;
129: int prequirements;
130: int srequirements;
131: long isn;
132: int settings;
133: struct SSAPref * sf;
134: struct ds_bind_arg * bindarg;
135: struct QOStype * qos;
136: struct DAPconnect * dc;
137: struct DAPindication * di;
138: int async;
139: {
140: int result;
141: OID app_ctx;
142: struct PSAPctxlist pc_s;
143: struct PSAPctxlist * pc = &(pc_s);
144: OID def_ctx;
145: PE bindargpe;
146: struct RoNOTindication rni_s;
147: struct RoNOTindication * rni = &(rni_s);
148: struct AcSAPconnect * acc = &(dc->dc_connect);
149: OID acse_pci;
150:
151: /*
152: * Set application-context, presentation context definition list,
153: * and default-context.
154: */
155:
156: DLOG(log_dsap, LLOG_TRACE, ("DapAsynBindReqAux():"));
157:
158: if((acse_pci = oid_cpy(DIR_ACSE)) == NULLOID)
159: {
160: LLOG(log_dsap, LLOG_EXCEPTIONS, ("acse pci version 1 OID not found"));
161: return (NOTOK);
162: }
163:
164: app_ctx = oid_cpy (DIR_ACCESS_AC);
165: def_ctx = oid_cpy (DIR_ACCESS_AS);
166:
167: pc->pc_nctx = 2;
168: pc->pc_ctx[0].pc_id = DIR_ACCESS_PC_ID;
169: pc->pc_ctx[0].pc_asn = oid_cpy(def_ctx);
170: pc->pc_ctx[0].pc_atn = NULLOID;
171: pc->pc_ctx[1].pc_id = DIR_ACSE_PC_ID;
172: pc->pc_ctx[1].pc_asn = acse_pci;
173: pc->pc_ctx[1].pc_atn = NULLOID;
174:
175:
176: /* Encode Bind Argument */
177: if (encode_DAS_DirectoryBindArgument (&bindargpe, 1, 0, NULLCP, bindarg) != OK)
178: {
179: return (daplose (di, DA_ARG_ENC, NULLCP, "DAP BIND REQUEST"));
180: }
181: bindargpe->pe_context = DIR_ACCESS_PC_ID;
182:
183: result = RoAsynBindRequest (app_ctx, callingtitle, calledtitle,
184: callingaddr, calledaddr, pc, def_ctx, prequirements,
185: srequirements, isn, settings, sf, bindargpe, qos,
186: acc, rni, async);
187:
188: if (bindargpe != NULLPE)
189: pe_free (bindargpe);
190:
191: if (result == NOTOK)
192: {
193: return (ronot2daplose (di, "DAP-BIND.REQUEST", rni));
194: }
195:
196: /* Set the connection identifier */
197: dc->dc_sd = acc->acc_sd;
198:
199: if (((!async) && (result == OK)) || (async && (result == DONE)))
200: {
201: /*
202: * Check the type of return and attempt to decode user data.
203: */
204: if (DapBindDecode (acc, dc) != OK)
205: {
206: return (daplose (di, DA_RES_DEC, NULLCP, "DAP BIND REQUEST"));
207: }
208: }
209:
210: return (result);
211: }
212:
213: int DapAsynBindRequest (calledaddr, bindarg, dc, di, async)
214: struct PSAPaddr * calledaddr;
215: struct ds_bind_arg * bindarg;
216: struct DAPconnect * dc;
217: struct DAPindication * di;
218: int async;
219: {
220: struct SSAPref sf_s;
221: struct SSAPref * sf = &(sf_s);
222: struct QOStype qos;
223:
224: if ((sf = addr2ref (PLocalHostName ())) == NULL)
225: {
226: sf = &sf_s;
227: (void) bzero ((char *) sf, sizeof *sf);
228: }
229:
230: (void) bzero ((char *) &qos, sizeof qos);
231: qos.qos_sversion = NOTOK; /* Negotiate highest session */
232: qos.qos_maxtime = NOTOK; /* No time out specified */
233:
234: return (DapAsynBindReqAux (NULLAEI, NULLAEI, NULLPA, calledaddr,
235: PR_MYREQUIRE, ROS_MYREQUIRE, SERIAL_NONE, 0, sf,
236: bindarg, &qos, dc, di, async));
237: }
238:
239: int DapAsynBindRetry (sd, do_next_nsap, dc, di)
240: int sd;
241: int do_next_nsap;
242: struct DAPconnect * dc;
243: struct DAPindication * di;
244: {
245: int result;
246: struct RoNOTindication rni_s;
247: struct RoNOTindication * rni = &(rni_s);
248: struct AcSAPconnect * acc = &(dc->dc_connect);
249:
250: result = RoAsynBindRetry (sd, do_next_nsap, acc, rni);
251:
252: if (result == NOTOK)
253: {
254: return (ronot2daplose (di, "DAP-BIND.RETRY", rni));
255: }
256:
257: if (result == DONE)
258: {
259: if (DapBindDecode (acc, dc) != OK)
260: {
261: return (daplose (di, DA_RES_DEC, NULLCP, "DAP BIND RETRY"));
262: }
263: }
264:
265: return (result);
266: }
267:
268: int DapBindDecode (acc, dc)
269: struct AcSAPconnect * acc;
270: struct DAPconnect * dc;
271: {
272: struct ds_bind_arg * bind_res;
273: struct ds_bind_error * bind_err;
274:
275: switch(acc->acc_result)
276: {
277: case ACS_ACCEPT:
278: DLOG(log_dsap, LLOG_NOTICE, ("DapBindDecode ACCEPT"));
279: bind_res = &(dc->dc_un.dc_bind_res);
280: if ((acc->acc_ninfo == 1) && (acc->acc_info[0] != NULLPE))
281: {
282: if(decode_DAS_DirectoryBindResult(acc->acc_info[0], 1, NULLIP, NULLVP, bind_res) != OK)
283: {
284: LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unable to parse DirectoryBindResult"));
285: dc->dc_result = DC_REJECT;
286: return (NOTOK);
287: }
288: dc->dc_result = DC_RESULT;
289: }
290: else
291: {
292: LLOG(log_dsap, LLOG_EXCEPTIONS, ("No DirectoryBindResult"));
293: dc->dc_result = DC_REJECT;
294: return (NOTOK);
295: }
296: break;
297:
298: case ACS_PERMANENT:
299: /*
300: * Get the DirectoryBindError
301: */
302: DLOG(log_dsap, LLOG_NOTICE, ("DapBindDecode PERMANENT"));
303: bind_err = &(dc->dc_un.dc_bind_err);
304: if ((acc->acc_ninfo == 1) && (acc->acc_info[0] != NULLPE))
305: {
306: if(decode_DAS_DirectoryBindError(acc->acc_info[0], 1, NULLIP, NULLVP, bind_err) != OK)
307: {
308: LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unable to decode DirectoryBindError"));
309: dc->dc_result = DC_REJECT;
310: return (NOTOK);
311: }
312: dc->dc_result = DC_ERROR;
313: }
314: else
315: {
316: LLOG(log_dsap, LLOG_EXCEPTIONS, ("No DirectoryBindError"));
317: dc->dc_result = DC_REJECT;
318: return (NOTOK);
319: }
320: break;
321:
322: default:
323: DLOG(log_dsap, LLOG_NOTICE, ("DapBindDecode OTHER"));
324: LLOG (log_dsap,LLOG_EXCEPTIONS,( "Association rejected: [%s]",
325: AcErrString(acc->acc_result)));
326: dc->dc_result = DC_REJECT;
327: return (NOTOK);
328:
329: } /* switch acc->acc_result */
330:
331: return(OK);
332: }
333:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.