|
|
1.1 root 1: /* conn_init.c - deal with incoming association requests */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/quipu/RCS/conn_init.c,v 7.4 90/07/09 14:45:24 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/quipu/RCS/conn_init.c,v 7.4 90/07/09 14:45:24 mrose Exp $
9: *
10: *
11: * $Log: conn_init.c,v $
12: * Revision 7.4 90/07/09 14:45:24 mrose
13: * sync
14: *
15: * Revision 7.3 90/03/15 11:18:42 mrose
16: * quipu-sync
17: *
18: * Revision 7.2 89/12/19 16:20:03 mrose
19: * sync
20: *
21: * Revision 7.1 89/11/24 16:21:53 mrose
22: * sync
23: *
24: * Revision 7.0 89/11/23 22:16:46 mrose
25: * Release 6.0
26: *
27: */
28:
29: /*
30: * NOTICE
31: *
32: * Acquisition, use, and distribution of this module and related
33: * materials are subject to the restrictions of a license agreement.
34: * Consult the Preface in the User's Manual for the full terms of
35: * this agreement.
36: *
37: */
38:
39:
40: #include "quipu/dsap.h"
41: #include "tsap.h"
42: #include "quipu/util.h"
43: #include "quipu/connection.h"
44:
45: extern LLog * log_dsap;
46: #ifndef NO_STATS
47: extern LLog * log_stat;
48: #endif
49:
50: void ds_log();
51:
52: struct connection * conn_alloc();
53: void acs_log();
54:
55: extern time_t timenow;
56:
57: conn_init(cn)
58: struct connection * cn;
59: {
60: int result;
61: char **vec;
62: struct DSAPstart * ds;
63: struct DSAPindication di_s;
64: struct DSAPindication * di = &di_s;
65: struct DSAPabort * da = &(di->di_abort);
66: struct TSAPdisconnect td_s;
67: struct TSAPdisconnect * td = &td_s;
68:
69: DLOG (log_dsap,LLOG_TRACE,( "conn_init()"));
70:
71: vec = cn->cn_start.cs_vec;
72: ds = &(cn->cn_start.cs_ds);
73:
74: watch_dog ("DBindInit");
75: result = DBindInit (cn->cn_start.cs_vecp, vec, ds, di);
76: watch_dog_reset();
77:
78: if (result != OK)
79: {
80: LLOG (log_dsap,LLOG_EXCEPTIONS,( "conn_init(): DBindInit() != OK"));
81: ds_log(da, "initialization fails");
82: conn_extract (cn);
83: free((char *)ds);
84: return;
85: }
86:
87: DLOG (log_dsap,LLOG_TRACE,( "conn_init(): DBindInit() OK"));
88:
89: /*
90: * Log the arrival of a connection request.
91: */
92: LLOG (log_dsap,LLOG_NOTICE, ("Association (%d) from %s",
93: ds->ds_sd, paddr2str(&(ds->ds_start.acs_start.ps_calling),NULLNA)));
94:
95: DLOG (log_dsap,LLOG_NOTICE, ("Context: %s; Caller: %s; Callee: %s.",
96: oid2ode(ds->ds_start.acs_context),
97: sprintaei (&ds->ds_start.acs_callingtitle),
98: sprintaei (&ds->ds_start.acs_calledtitle)));
99:
100: cn->cn_ad = ds->ds_sd;
101: cn->cn_initiator = FALSE;
102: cn->cn_ctx = ds->ds_ctx;
103:
104: cn->cn_dn = dn_cpy(ds->ds_bind_arg.dba_dn);
105:
106: /*
107: * If we haven't returned yet then the protocol for binding has been
108: * satisfactorily completed.
109: * Now attempt to perform the ds_bind for the argument decoded, which
110: * can either succeed, fail or suspend waiting for a remote compare.
111: * If a remote compare has been scheduled then return, otherwise
112: * complete the connection initialisation by sending a bind result.
113: */
114:
115: if (TSetQueuesOK (cn->cn_ad, 1, td) == NOTOK)
116: td_log (td, "TSetQueuesOK (incoming)");
117:
118: switch(ds_bind_init(cn))
119: {
120: case DS_OK:
121: conn_init_res(cn);
122: break;
123: case DS_ERROR_CONNECT:
124: conn_init_err(cn);
125: break;
126: case DS_CONTINUE:
127: cn->cn_state = CN_INDICATED;
128: break;
129: default:
130: LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unexpected return by ds_bind_init"));
131: watch_dog ("DBindReject");
132: (void) DBindReject (ds, ACS_TRANSIENT, ACS_USER_NOREASON, di);
133: watch_dog_reset();
134: break;
135: }
136: }
137:
138: conn_init_res(cn)
139: struct connection * cn;
140: {
141: int result;
142: struct DSAPindication di_s;
143: struct DSAPindication *di = &(di_s);
144: struct DSAPabort *da = &(di->di_abort);
145: struct DSAPstart * ds = &(cn->cn_start.cs_ds);
146: struct AcSAPstart * acs = &(ds->ds_start);
147: struct PSAPstart * ps = &(acs->acs_start);
148:
149: DLOG(log_dsap,LLOG_TRACE, ("conn_init_res()"));
150:
151: DLOG(log_dsap,LLOG_NOTICE, ("D-BIND.RESULT"));
152:
153: #ifdef DEBUG
154: {
155: int i;
156:
157: for(i=0; i<ps->ps_ctxlist.pc_nctx; i++)
158: {
159: DLOG(log_dsap, LLOG_DEBUG, ("ctx[%d] id = %d, res = %d.", i,
160: ps->ps_ctxlist.pc_ctx[i].pc_id,
161: ps->ps_ctxlist.pc_ctx[i].pc_result));
162: }
163: }
164: #endif
165:
166: watch_dog ("DBindResult");
167: result = DBindResult (cn->cn_ad, acs->acs_context, NULLAEI, NULLPA,
168: &(ps->ps_ctxlist), ps->ps_defctxresult, PR_MYREQUIRE,
169: ps->ps_srequirements & (ROS_MYREQUIRE | SR_NEGOTIATED),
170: SERIAL_NONE, ps->ps_settings, &(ps->ps_connect),
171: &(cn->cn_start.cs_res), ds->ds_pctx_id, di);
172: watch_dog_reset();
173:
174: if (result == OK)
175: {
176: cn->cn_state = CN_OPEN;
177: }
178: else
179: {
180: ds_log(da, "D-BIND.RESULT");
181: DLOG(log_dsap, LLOG_DEBUG, ("conn_init_res(): DBindResult failed, extracting conn"));
182: conn_extract(cn);
183: }
184:
185: }
186:
187: conn_init_err(cn)
188: struct connection * cn;
189: {
190: int result;
191: struct DSAPindication di_s;
192: struct DSAPindication *di = &di_s;
193: struct DSAPabort *da = &di->di_abort;
194: struct DSAPstart * ds = &(cn->cn_start.cs_ds);
195: struct AcSAPstart * acs = &(ds->ds_start);
196: struct PSAPstart * ps = &(acs->acs_start);
197:
198: DLOG(log_dsap,LLOG_TRACE, ("conn_init_err()"));
199:
200: DLOG(log_dsap,LLOG_NOTICE, ("D-BIND.ERROR"));
201:
202: #ifdef DEBUG
203: {
204: int i;
205:
206: for(i=0; i<ps->ps_ctxlist.pc_nctx; i++)
207: {
208: DLOG(log_dsap, LLOG_DEBUG, ("ctx[%d] id = %d, res = %d.", i,
209: ps->ps_ctxlist.pc_ctx[i].pc_id,
210: ps->ps_ctxlist.pc_ctx[i].pc_result));
211: }
212: }
213: #endif
214:
215: watch_dog ("DBindError");
216: result = DBindError (cn->cn_ad, acs->acs_context, NULLAEI, NULLPA,
217: &(ps->ps_ctxlist), ps->ps_defctxresult, PR_MYREQUIRE,
218: ps->ps_srequirements & (ROS_MYREQUIRE | SR_NEGOTIATED),
219: SERIAL_NONE, ps->ps_settings, &(ps->ps_connect),
220: &(cn->cn_start.cs_err), ds->ds_pctx_id, di);
221: watch_dog_reset();
222:
223: if (result == OK)
224: {
225: DLOG(log_dsap,LLOG_TRACE, ("status != ACS_ACCEPT"));
226: DLOG(log_dsap, LLOG_DEBUG, ("conn_init_err(): DBindError succeeded, extracting conn"));
227: conn_extract(cn);
228: }
229: else
230: {
231: ds_log(da, "D-BIND.ERROR");
232: DLOG(log_dsap, LLOG_DEBUG, ("conn_init_err(): DBindError failed, extracting conn"));
233: conn_extract(cn);
234: }
235:
236: }
237:
238: conn_pre_init(newfd, vecp, vec)
239: int newfd;
240: int vecp;
241: char **vec;
242: {
243: struct connection * cn;
244:
245: cn = conn_alloc();
246:
247: cn->cn_next = connlist;
248: connlist = cn;
249: conns_used++;
250:
251: cn->cn_ad = newfd;
252: cn->cn_initiator = FALSE;
253:
254: cn->cn_start.cs_vecp = vecp;
255: if (vec[0])
256: cn->cn_start.cs_svec[0] = cn->cn_start.cs_vec[0] = strdup (vec[0]);
257: if (vec[1])
258: cn->cn_start.cs_svec[1] = cn->cn_start.cs_vec[1] = strdup (vec[1]);
259: if (vec[2])
260: cn->cn_start.cs_svec[2] = cn->cn_start.cs_vec[2] = strdup (vec[2]);
261: if (vec[3])
262: cn->cn_start.cs_svec[3] = cn->cn_start.cs_vec[3] = strdup (vec[3]);
263:
264: cn->cn_state = CN_OPENING;
265:
266: cn->cn_last_used = timenow;
267:
268: if (newfd == NOTOK)
269: conn_init (cn);
270: else
271: DLOG (log_dsap,LLOG_NOTICE, ("opening association on %d",newfd ));
272: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.