|
|
1.1 root 1: /* ssapwrite.c - SPM: write various SPDUs */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/ssap/RCS/ssapwrite.c,v 7.0 89/11/23 22:25:52 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/ssap/RCS/ssapwrite.c,v 7.0 89/11/23 22:25:52 mrose Rel $
9: *
10: *
11: * $Log: ssapwrite.c,v $
12: * Revision 7.0 89/11/23 22:25:52 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 "spkt.h"
32:
33: /* */
34:
35: int SWriteRequestAux (sb, code, data, cc, type, ssn, settings,
36: id, oid, ref, si)
37: register struct ssapblk *sb;
38: int code;
39: char *data;
40: int cc,
41: type,
42: settings;
43: long ssn;
44: struct SSAPactid *id,
45: *oid;
46: struct SSAPref *ref;
47: struct SSAPindication *si;
48: {
49: int result;
50: register struct ssapkt *s,
51: *p;
52: struct TSAPdisconnect tds;
53: register struct TSAPdisconnect *td = &tds;
54: struct udvec uvs[3];
55: register struct udvec *uv;
56:
57: if (sb -> sb_flags & SB_EXPD)
58: switch (code) {
59: case SPDU_MAA:
60: result = PR_MAA;
61: goto send_pr;
62:
63: case SPDU_AI:
64: case SPDU_AD:
65: case SPDU_RS:
66: result = PR_RS;
67: goto send_pr;
68:
69: case SPDU_AIA:
70: case SPDU_ADA:
71: case SPDU_RA:
72: result = PR_RA;
73: send_pr: ;
74: if ((p = newspkt (SPDU_PR)) == NULL)
75: return ssaplose (si, SC_CONGEST, NULLCP, "out of memory");
76: p -> s_mask |= SMASK_PR_TYPE;
77: p -> s_pr_type = result;
78: result = spkt2sd (p, sb -> sb_fd, 1, si);
79: freespkt (p);
80: if (result == NOTOK)
81: return NOTOK;
82: break;
83:
84: default:
85: break;
86: }
87:
88: uv = uvs;
89: uvs[0].uv_base = uvs[1].uv_base = NULL;
90:
91: switch (code) {
92: case SPDU_MAP:
93: case SPDU_MIP:
94: case SPDU_RS:
95: case SPDU_AS:
96: case SPDU_AR:
97: case SPDU_AD:
98: case SPDU_AI:
99: #ifdef notdef /* aka SPDU_MAP */
100: case SPDU_AE:
101: #endif
102: case SPDU_CD:
103: if (s = newspkt (SPDU_GT))
104: s -> s_mask |= SMASK_SPDU_GT;
105: break;
106:
107: default:
108: s = newspkt (SPDU_PT);
109: break;
110: }
111: if (s == NULL)
112: return ssaplose (si, SC_CONGEST, NULLCP, "out of memory");
113:
114: if (spkt2tsdu (s, &uv -> uv_base, &uv -> uv_len) == NOTOK) {
115: (void) ssaplose (si, s -> s_errno, NULLCP, NULLCP);
116: goto out1;
117: }
118: freespkt (s);
119: uv++;
120:
121: if ((s = newspkt (code)) == NULL) {
122: (void) ssaplose (si, SC_CONGEST, NULLCP, "out of memory");
123: goto out2;
124: }
125: switch (code) {
126: case SPDU_MAP:
127: if (type) {
128: s -> s_mask |= SMASK_MAP_SYNC;
129: s -> s_map_sync = type;
130: }
131: s -> s_mask |= SMASK_MAP_SERIAL;
132: s -> s_map_serial = ssn;
133: break;
134:
135: case SPDU_MAA:
136: s -> s_mask |= SMASK_MAA_SERIAL;
137: s -> s_maa_serial = ssn;
138: break;
139:
140: case SPDU_MIP:
141: if (type == SYNC_NOCONFIRM) {
142: s -> s_mask |= SMASK_MIP_SYNC;
143: s -> s_mip_sync = MIP_SYNC_NOEXPL;
144: }
145: s -> s_mask |= SMASK_MIP_SERIAL;
146: s -> s_mip_serial = ssn;
147: break;
148:
149: case SPDU_MIA:
150: s -> s_mask |= SMASK_MIA_SERIAL;
151: s -> s_mia_serial = ssn;
152: break;
153:
154: case SPDU_RS:
155: if (sb -> sb_requirements & SR_TOKENS) {
156: s -> s_mask |= SMASK_RS_SET;
157: s -> s_rs_settings = settings;
158: }
159: s -> s_mask |= SMASK_RS_TYPE;
160: s -> s_rs_type = type;
161: s -> s_mask |= SMASK_RS_SSN;
162: s -> s_rs_serial = ssn;
163: break;
164:
165: case SPDU_RA:
166: if (sb -> sb_requirements & SR_TOKENS) {
167: s -> s_mask |= SMASK_RA_SET;
168: s -> s_ra_settings = settings;
169: }
170: s -> s_mask |= SMASK_RA_SSN;
171: s -> s_ra_serial = ssn;
172: break;
173:
174: case SPDU_AS:
175: s -> s_mask |= SMASK_AS_ID;
176: s -> s_as_id = *id; /* struct copy */
177: break;
178:
179: case SPDU_AR:
180: s -> s_mask |= SMASK_AR_OID | SMASK_AR_SSN | SMASK_AR_ID;
181: s -> s_ar_oid = *oid; /* struct copy */
182: s -> s_ar_serial = ssn;
183: s -> s_ar_id = *id; /* struct copy */
184: if (ref) {
185: s -> s_mask |= SMASK_AR_REF;
186: s -> s_ar_reference = *ref; /* struct copy */
187: }
188: break;
189:
190: case SPDU_AI:
191: s -> s_mask |= SMASK_AI_REASON;
192: s -> s_ai_reason = type;
193: break;
194:
195: case SPDU_AD:
196: s -> s_mask |= SMASK_AD_REASON;
197: s -> s_ad_reason = type;
198: break;
199:
200: case SPDU_ED:
201: s -> s_mask |= SMASK_ED_REASON;
202: s -> s_ed_reason = type;
203: break;
204:
205: default:
206: break;
207: }
208:
209: if (cc > 0) {
210: s -> s_mask |= SMASK_UDATA_PGI;
211: s -> s_udata = data, s -> s_ulen = cc;
212: }
213: else
214: s -> s_udata = NULL, s -> s_ulen = 0;
215: result = spkt2tsdu (s, &uv -> uv_base, &uv -> uv_len);
216: s -> s_mask &= ~SMASK_UDATA_PGI;
217: s -> s_udata = NULL, s -> s_ulen = 0;
218:
219: if (result == NOTOK) {
220: (void) ssaplose (si, s -> s_errno, NULLCP, NULLCP);
221: goto out3;
222: }
223: freespkt (s);
224: uv++;
225:
226: uv -> uv_base = NULL;
227:
228: if ((result = TWriteRequest (sb -> sb_fd, uvs, td)) == NOTOK)
229: (void) ts2sslose (si, "TWriteRequest", td);
230:
231: free (uvs[0].uv_base);
232: free (uvs[1].uv_base);
233:
234: return result;
235:
236: out3: ;
237: if (uvs[1].uv_base)
238: free (uvs[1].uv_base);
239: out2: ;
240: if (uvs[0].uv_base)
241: free (uvs[0].uv_base);
242: out1: ;
243: freespkt (s);
244:
245: return NOTOK;
246: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.