Start development on 386BSD 0.0
[unix-history] / .ref-BSD-4_3_Net_2 / usr / src / contrib / isode / ftam / ftamgroup2.c
CommitLineData
53102063
C
1/* ftamgroup2.c - FPM: respond to a grouped transaction */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/ftam/RCS/ftamgroup2.c,v 7.1 91/02/22 09:22:56 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/ftam/RCS/ftamgroup2.c,v 7.1 91/02/22 09:22:56 mrose Interim $
9 *
10 *
11 * $Log: ftamgroup2.c,v $
12 * Revision 7.1 91/02/22 09:22:56 mrose
13 * Interim 6.8
14 *
15 * Revision 7.0 89/11/23 21:53:39 mrose
16 * Release 6.0
17 *
18 */
19
20/*
21 * NOTICE
22 *
23 * Acquisition, use, and distribution of this module and related
24 * materials are subject to the restrictions of a license agreement.
25 * Consult the Preface in the User's Manual for the full terms of
26 * this agreement.
27 *
28 */
29
30
31/* LINTLIBRARY */
32
33#include <stdio.h>
34#include <signal.h>
35#include "fpkt.h"
36
37/* \f F-{MANAGE,BULK-{BEGIN,END}}.RESPONSE (group) */
38
39int FManageResponse (sd, ftg, fti)
40int sd;
41struct FTAMgroup *ftg;
42struct FTAMindication *fti;
43{
44 return FGroupResponse (sd, ftg, FTI_MANAGEMENT, FSB_INITIALIZED, fti);
45}
46
47
48int FBulkBeginResponse (sd, ftg, fti)
49int sd;
50struct FTAMgroup *ftg;
51struct FTAMindication *fti;
52{
53 return FGroupResponse (sd, ftg, FTI_BULKBEGIN, FSB_DATAIDLE, fti);
54}
55
56
57int FBulkEndResponse (sd, ftg, fti)
58int sd;
59struct FTAMgroup *ftg;
60struct FTAMindication *fti;
61{
62 return FGroupResponse (sd, ftg, FTI_BULKEND, FSB_INITIALIZED, fti);
63}
64
65/* \f F-GROUP.RESPONSE (group) */
66
67static int FGroupResponse (sd, ftg, type, state, fti)
68int sd;
69struct FTAMgroup *ftg;
70int type,
71 state;
72struct FTAMindication *fti;
73{
74 SBV smask;
75 int result;
76 register struct ftamblk *fsb;
77
78 missingP (ftg);
79 missingP (fti);
80
81 smask = sigioblock ();
82
83 ftamPsig (fsb, sd);
84
85 if ((result = frgrpchk (fsb, ftg, type, fti)) != NOTOK)
86 result = FGroupResponseAux (fsb, ftg, state, fti);
87
88 (void) sigiomask (smask);
89
90 return result;
91}
92
93/* \f */
94
95static int FGroupResponseAux (fsb, ftg, state, fti)
96register struct ftamblk *fsb;
97register struct FTAMgroup *ftg;
98int state;
99struct FTAMindication *fti;
100{
101 register int i;
102 int did_loop,
103 npdu,
104 result,
105 okstate;
106 char **txp,
107 *texts[NPDATA];
108 PE pe,
109 *pep,
110 info[NPDATA];
111 struct PSAPindication pis;
112 struct PSAPindication *pi = &pis;
113 struct PSAPabort *pa = &pi -> pi_abort;
114 struct type_FTAM_PDU **pdup,
115 *pdus[NPDATA];
116
117 bzero ((char *) texts, sizeof texts);
118 bzero ((char *) info, sizeof info);
119 bzero ((char *) pdus, sizeof pdus);
120
121 did_loop = 0;
122 if ((result = frgrp2pdus (fsb, ftg, pdus, texts, &npdu, fti)) == NOTOK)
123 goto out;
124 for (pdup = pdus, pep = info, txp = texts, i = npdu - 1;
125 i >= 0;
126 pdup++, pep++, txp++, i--) {
127 pe = NULLPE;
128 if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, *pdup) == NOTOK) {
129 result = ftamlose (fti, FS_GEN (fsb), 1, NULLCP,
130 "error encoding PDU: %s", PY_pepy);
131 goto out;
132 }
133 (*pep = pe) -> pe_context = fsb -> fsb_id;
134
135 fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.REQUEST", *txp, pe, 0));
136 }
137 did_loop = 1;
138
139 result = PDataRequest (fsb -> fsb_fd, info, npdu, pi);
140
141out: ;
142 for (pdup = pdus, pep = info, i = NPDATA - 1;
143 i >= 0;
144 pdup++, pep++, i--) {
145 if (*pep)
146 pe_free (*pep);
147 if (*pdup)
148 free_FTAM_PDU (*pdup);
149 }
150
151 if (result == NOTOK) {
152 if (did_loop)
153 (void) ps2ftamlose (fsb, fti, "PDataRequest", pa);
154 if (fti -> fti_abort.fta_action == FACTION_PERM)
155 freefsblk (fsb);
156
157 return NOTOK;
158 }
159
160 switch (state) {
161 case FSB_DATAIDLE:
162 if (ftg -> ftg_flags & FTG_SELECT)
163 okstate = ftg -> ftg_select.ftse_state;
164 else
165 okstate = ftg -> ftg_create.ftce_state;
166 if (okstate != FSTATE_SUCCESS
167 || ftg -> ftg_open.ftop_state != FSTATE_SUCCESS) {
168 fsb -> fsb_state = FSB_INITIALIZED;
169 break;
170 } /* else fall */
171
172 default:
173 fsb -> fsb_state = state;
174 break;
175 }
176
177 return OK;
178}
179
180/* \f */
181
182static int frgrpchk (fsb, ftg, type, fti)
183register struct ftamblk *fsb;
184register struct FTAMgroup *ftg;
185int type;
186struct FTAMindication *fti;
187{
188 if (fsb -> fsb_flags & FSB_INIT)
189 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "not responder");
190 switch (fsb -> fsb_state) {
191 case FSB_MANAGEMENT:
192 if (type != FTI_MANAGEMENT)
193 goto wrong_state;
194 if (ftg -> ftg_flags & ~fsb -> fsb_group) {
195reply_mismatch: ;
196 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
197 "group reply mismatch; expecting 0x%x, found 0x%x",
198 fsb -> fsb_group, ftg -> ftg_flags);
199 }
200 break;
201
202 case FSB_BULKBEGIN:
203 if (type != FTI_BULKBEGIN)
204 goto wrong_state;
205 if (ftg -> ftg_flags & ~fsb -> fsb_group)
206 goto reply_mismatch;
207 break;
208
209 case FSB_BULKEND:
210 if (type != FTI_BULKEND)
211 goto wrong_state;
212 if (ftg -> ftg_flags & ~fsb -> fsb_group)
213 goto reply_mismatch;
214 break;
215
216 default:
217 wrong_state: ;
218 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state");
219 }
220
221 if (ftg -> ftg_flags & FTG_SELECT) {
222 register struct FTAMselect *ftse = &ftg -> ftg_select;
223
224 switch (ftse -> ftse_state) {
225 case FSTATE_SUCCESS:
226 case FSTATE_FAILURE:
227 break;
228
229 default:
230 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
231 "bad value for select state parameter");
232 }
233 switch (ftse -> ftse_action) {
234 case FACTION_SUCCESS:
235 case FACTION_TRANS:
236 case FACTION_PERM:
237 break;
238
239 default:
240 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
241 "bad value for select action parameter");
242 }
243 if (ftse -> ftse_attrs.fa_present != FA_FILENAME)
244 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
245 "only filename should be present");
246 if (ftse -> ftse_ndiag > NFDIAG)
247 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
248 "too many select diagnostics");
249 }
250
251 if (ftg -> ftg_flags & FTG_CREATE) {
252 register struct FTAMcreate *ftce = &ftg -> ftg_create;
253
254 switch (ftce -> ftce_state) {
255 case FSTATE_SUCCESS:
256 case FSTATE_FAILURE:
257 break;
258
259 default:
260 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
261 "bad value for create state parameter");
262 }
263 switch (ftce -> ftce_action) {
264 case FACTION_SUCCESS:
265 case FACTION_TRANS:
266 case FACTION_PERM:
267 break;
268
269 default:
270 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
271 "bad value for create action parameter");
272 }
273 if (!(ftce -> ftce_attrs.fa_present & FA_FILENAME))
274 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
275 "filename not present");
276 if (!(ftce -> ftce_attrs.fa_present & FA_ACTIONS))
277 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
278 "permitted-actions not present");
279 if (!(ftce -> ftce_attrs.fa_present & FA_CONTENTS))
280 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
281 "contents-type not present");
282 if (ftce -> ftce_attrs.fa_present & ~FA_CRE_ATTRS)
283 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
284 "illegal attributes present");
285 if (!(fsb -> fsb_attrs & FATTR_STORAGE)
286 && (ftce -> ftce_attrs.fa_present & FA_STORAGE))
287 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
288 "storage attributes not permitted");
289 if (!(fsb -> fsb_attrs & FATTR_SECURITY)
290 && (ftce -> ftce_attrs.fa_present & FA_SECURITY))
291 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
292 "security attributes not permitted");
293 if (ftce -> ftce_ndiag > NFDIAG)
294 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
295 "too many create diagnostics");
296 }
297
298 if (ftg -> ftg_flags & FTG_CLOSE) {
299 register struct FTAMclose *ftcl = &ftg -> ftg_close;
300
301 switch (ftcl -> ftcl_action) {
302 case FACTION_SUCCESS:
303 case FACTION_TRANS:
304 case FACTION_PERM:
305 break;
306
307 default:
308 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
309 "bad value for close action parameter");
310 }
311 if (ftcl -> ftcl_ndiag > NFDIAG)
312 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
313 "too many close diagnostics");
314 }
315
316 if (ftg -> ftg_flags & FTG_RDATTR) {
317 register struct FTAMreadattr *ftra = &ftg -> ftg_readattr;
318
319 switch (ftra -> ftra_action) {
320 case FACTION_SUCCESS:
321 case FACTION_TRANS:
322 case FACTION_PERM:
323 break;
324
325 default:
326 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
327 "bad value for read attribute action parameter");
328 }
329 if (!(fsb -> fsb_attrs & FATTR_STORAGE)
330 && (ftra -> ftra_attrs.fa_present & FA_STORAGE))
331 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
332 "storage attributes not permitted");
333 if (!(fsb -> fsb_attrs & FATTR_SECURITY)
334 && (ftra -> ftra_attrs.fa_present & FA_SECURITY))
335 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
336 "security attributes not permitted");
337 if (ftra -> ftra_ndiag > NFDIAG)
338 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
339 "too many read attribute diagnostics");
340 }
341
342 if (ftg -> ftg_flags & FTG_CHATTR) {
343 register struct FTAMchngattr *ftca = &ftg -> ftg_chngattr;
344
345 switch (ftca -> ftca_action) {
346 case FACTION_SUCCESS:
347 case FACTION_TRANS:
348 case FACTION_PERM:
349 break;
350
351 default:
352 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
353 "bad value for change attribute action parameter");
354 }
355 if (!(fsb -> fsb_attrs & FATTR_STORAGE)
356 && (ftca -> ftca_attrs.fa_present & FA_STORAGE))
357 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
358 "storage attributes not permitted");
359 if (!(fsb -> fsb_attrs & FATTR_SECURITY)
360 && (ftca -> ftca_attrs.fa_present & FA_SECURITY))
361 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
362 "security attributes not permitted");
363 if (ftca -> ftca_attrs.fa_present & FA_CONTROL)
364 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
365 "encoding of access-control not supported (yet)");
366 if (ftca -> ftca_ndiag > NFDIAG)
367 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
368 "too many change attribute diagnostics");
369 }
370
371 if (ftg -> ftg_flags & FTG_DESELECT) {
372 register struct FTAMdeselect *ftde = &ftg -> ftg_deselect;
373
374 switch (ftde -> ftde_action) {
375 case FACTION_SUCCESS:
376 case FACTION_TRANS:
377 case FACTION_PERM:
378 break;
379
380 default:
381 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
382 "bad value for deselect action parameter");
383 }
384 if (!(fsb -> fsb_flags & FSB_DECHARGE)
385 && ftde -> ftde_charges.fc_ncharge > 0)
386 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
387 "deselect not permitted to include charges");
388 if (ftde -> ftde_charges.fc_ncharge > NFCHRG)
389 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
390 "too many deselect charges");
391 if (ftde -> ftde_ndiag > NFDIAG)
392 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
393 "too many deselect diagnostics");
394 }
395
396 if (ftg -> ftg_flags & FTG_DELETE) {
397 register struct FTAMdelete *ftxe = &ftg -> ftg_delete;
398
399 switch (ftxe -> ftxe_action) {
400 case FACTION_SUCCESS:
401 case FACTION_TRANS:
402 case FACTION_PERM:
403 break;
404
405 default:
406 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
407 "bad value for delete action parameter");
408 }
409 if (ftxe -> ftxe_charges.fc_ncharge > NFCHRG)
410 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
411 "too many delete charges");
412 if (ftxe -> ftxe_ndiag > NFDIAG)
413 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
414 "too many delete diagnostics");
415 }
416
417 if (ftg -> ftg_flags & FTG_OPEN) {
418 register struct FTAMopen *ftop = &ftg -> ftg_open;
419 register struct FTAMconcurrency *fc;
420
421 switch (ftop -> ftop_state) {
422 case FSTATE_SUCCESS:
423 case FSTATE_FAILURE:
424 break;
425
426 default:
427 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
428 "bad value for open state parameter");
429 }
430 switch (ftop -> ftop_action) {
431 case FACTION_SUCCESS:
432 case FACTION_TRANS:
433 case FACTION_PERM:
434 break;
435
436 default:
437 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
438 "bad value for open action parameter");
439 }
440 if (ftop -> ftop_contents == NULLOID)
441 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
442 "missing open contents type parameter");
443 if (fsb -> fsb_attrs & FATTR_STORAGE) {
444 fc = &ftop -> ftop_conctl;
445 if (fc -> fc_readattrlock != FLOCK_NOTREQD
446 || fc -> fc_chngattrlock != FLOCK_NOTREQD
447 || fc -> fc_deletelock != FLOCK_NOTREQD)
448 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
449 "bad settings for open concurrency control");
450 }
451 if (ftop -> ftop_ndiag > NFDIAG)
452 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
453 "too many open diagnostics");
454 }
455
456 return OK;
457}
458
459/* \f */
460
461static int frgrp2pdus (fsb, ftg, pdus, texts, npdu, fti)
462register struct ftamblk *fsb;
463register struct FTAMgroup *ftg;
464struct type_FTAM_PDU *pdus[];
465char *texts[];
466int *npdu;
467struct FTAMindication *fti;
468{
469 int flags,
470 i;
471 register struct type_FTAM_PDU *pdu;
472
473 i = 0;
474
475#define new_pdu(t,o,u,x) \
476 register struct t *req; \
477 \
478 if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) \
479 goto no_mem; \
480 pdus[i] = pdu; \
481 pdu -> offset = o; \
482 texts[i++] = x; \
483 if ((req = (struct t *) calloc (1, sizeof *req)) == NULL) \
484 goto no_mem; \
485 pdu -> un.u = req;
486
487#define new_state(s) \
488 if (s != int_FTAM_State__Result_success) { \
489 if ((req -> state__result = \
490 (struct type_FTAM_State__Result *) \
491 calloc (1, sizeof *req -> state__result)) \
492 == NULL) \
493 goto no_mem; \
494 req -> state__result -> parm = s; \
495 }
496
497#define new_action(a) \
498 if (a != int_FTAM_Action__Result_success) { \
499 if ((req -> action__result = \
500 (struct type_FTAM_Action__Result *) \
501 calloc (1, sizeof *req -> action__result)) \
502 == NULL) \
503 goto no_mem; \
504 req -> action__result -> parm = a; \
505 }
506
507 if ((flags = ftg -> ftg_flags) & FTG_SELECT) {
508 if (ftg -> ftg_select.ftse_state == FSTATE_FAILURE)
509 flags &= FTG_BEGIN | FTG_SELECT | FTG_END;
510 }
511 else
512 if (flags & FTG_CREATE) {
513 if (ftg -> ftg_create.ftce_state == FSTATE_FAILURE)
514 flags &= FTG_BEGIN | FTG_CREATE | FTG_END;
515 }
516
517 if (flags & FTG_BEGIN) {
518 if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL)
519 goto no_mem;
520 pdus[i] = pdu;
521 pdu -> offset = type_FTAM_PDU_f__begin__group__response;
522 texts[i++] = "F-BEGIN-GROUP-response";
523 }
524
525 if (flags & FTG_SELECT) {
526 register struct FTAMselect *ftse = &ftg -> ftg_select;
527
528 new_pdu (type_FTAM_F__SELECT__response,
529 type_FTAM_PDU_f__select__response,
530 f__select__response, "F-SELECT-response");
531 new_state (ftse -> ftse_state);
532 new_action (ftse -> ftse_action);
533 if ((req -> attributes = attr2fpm (fsb, &ftse -> ftse_attrs, fti))
534 == NULL)
535 return NOTOK;
536 if (ftse -> ftse_sharedASE
537 && (req -> shared__ASE__information =
538 shared2fpm (fsb, ftse -> ftse_sharedASE, fti)) == NULL)
539 return NOTOK;
540 if (ftse -> ftse_ndiag > 0
541 && (req -> diagnostic = diag2fpm (fsb, 0, ftse -> ftse_diags,
542 ftse -> ftse_ndiag, fti))
543 == NULL)
544 return NOTOK;
545 }
546
547 if (flags & FTG_CREATE) {
548 register struct FTAMcreate *ftce = &ftg -> ftg_create;
549
550 new_pdu (type_FTAM_F__CREATE__response,
551 type_FTAM_PDU_f__create__response,
552 f__create__response, "F-CREATE-response");
553 new_state (ftce -> ftce_state);
554 new_action (ftce -> ftce_action);
555 if ((req -> initial__attributes = attr2fpm (fsb, &ftce -> ftce_attrs,
556 fti)) == NULL)
557 return NOTOK;
558 if (ftce -> ftce_sharedASE
559 && (req -> shared__ASE__information =
560 shared2fpm (fsb, ftce -> ftce_sharedASE, fti)) == NULL)
561 return NOTOK;
562 if (ftce -> ftce_ndiag > 0
563 && (req -> diagnostic = diag2fpm (fsb, 0, ftce -> ftce_diags,
564 ftce -> ftce_ndiag, fti))
565 == NULL)
566 return NOTOK;
567 }
568
569 if (flags & FTG_CLOSE) {
570 register struct FTAMclose *ftcl = &ftg -> ftg_close;
571
572 new_pdu (type_FTAM_F__CLOSE__response,
573 type_FTAM_PDU_f__close__response,
574 f__close__response, "F-CLOSE-response");
575 new_action (ftcl -> ftcl_action);
576 if (ftcl -> ftcl_sharedASE
577 && (req -> shared__ASE__information =
578 shared2fpm (fsb, ftcl -> ftcl_sharedASE, fti)) == NULL)
579 return NOTOK;
580 if (ftcl -> ftcl_ndiag > 0
581 && (req -> diagnostic = diag2fpm (fsb, 0, ftcl -> ftcl_diags,
582 ftcl -> ftcl_ndiag, fti))
583 == NULL)
584 return NOTOK;
585 }
586
587 if (flags & FTG_RDATTR) {
588 register struct FTAMreadattr *ftra = &ftg -> ftg_readattr;
589
590 new_pdu (type_FTAM_F__READ__ATTRIB__response,
591 type_FTAM_PDU_f__read__attrib__response,
592 f__read__attrib__response, "F-READ-ATTRIB-response");
593 new_action (ftra -> ftra_action);
594 if (ftra -> ftra_attrs.fa_present
595 && (req -> attributes = attr2fpm (fsb, &ftra -> ftra_attrs,
596 fti)) == NULL)
597 return NOTOK;
598 if (ftra -> ftra_ndiag > 0
599 && (req -> diagnostic = diag2fpm (fsb, 0, ftra -> ftra_diags,
600 ftra -> ftra_ndiag, fti))
601 == NULL)
602 return NOTOK;
603 }
604
605 if (flags & FTG_CHATTR) {
606 register struct FTAMchngattr *ftca = &ftg -> ftg_chngattr;
607
608 new_pdu (type_FTAM_F__CHANGE__ATTRIB__response,
609 type_FTAM_PDU_f__change__attrib__response,
610 f__change__attrib__response, "F-CHANGE-ATTRIB-response");
611 new_action (ftca -> ftca_action);
612 if (ftca -> ftca_attrs.fa_present
613 && (req -> attributes = attr2fpm (fsb, &ftca -> ftca_attrs,
614 fti)) == NULL)
615 return NOTOK;
616 if (ftca -> ftca_ndiag > 0
617 && (req -> diagnostic = diag2fpm (fsb, 0, ftca -> ftca_diags,
618 ftca -> ftca_ndiag, fti))
619 == NULL)
620 return NOTOK;
621 }
622
623 if (flags & FTG_DESELECT) {
624 register struct FTAMdeselect *ftde = &ftg -> ftg_deselect;
625
626 new_pdu (type_FTAM_F__DESELECT__response,
627 type_FTAM_PDU_f__deselect__response,
628 f__deselect__response, "F-DESELECT-response");
629 new_action (ftde -> ftde_action);
630 if (ftde -> ftde_sharedASE
631 && (req -> shared__ASE__information =
632 shared2fpm (fsb, ftde -> ftde_sharedASE, fti)) == NULL)
633 return NOTOK;
634 if (ftde -> ftde_charges.fc_ncharge
635 && (req -> charging = chrg2fpm (fsb, &ftde -> ftde_charges,
636 fti)) == NULL)
637 return NOTOK;
638 if (ftde -> ftde_ndiag > 0
639 && (req -> diagnostic = diag2fpm (fsb, 0, ftde -> ftde_diags,
640 ftde -> ftde_ndiag, fti))
641 == NULL)
642 return NOTOK;
643 }
644
645 if (flags & FTG_DELETE) {
646 register struct FTAMdelete *ftxe = &ftg -> ftg_delete;
647
648 new_pdu (type_FTAM_F__DELETE__response,
649 type_FTAM_PDU_f__delete__response,
650 f__delete__response, "F-DELETE-response");
651 new_action (ftxe -> ftxe_action);
652 if (ftxe -> ftxe_sharedASE
653 && (req -> shared__ASE__information =
654 shared2fpm (fsb, ftxe -> ftxe_sharedASE, fti)) == NULL)
655 return NOTOK;
656 if (ftxe -> ftxe_charges.fc_ncharge
657 && (req -> charging = chrg2fpm (fsb, &ftxe -> ftxe_charges,
658 fti)) == NULL)
659 return NOTOK;
660 if (ftxe -> ftxe_ndiag > 0
661 && (req -> diagnostic = diag2fpm (fsb, 0, ftxe -> ftxe_diags,
662 ftxe -> ftxe_ndiag, fti))
663 == NULL)
664 return NOTOK;
665 }
666
667 if (flags & FTG_OPEN) {
668 register struct FTAMopen *ftop = &ftg -> ftg_open;
669 register struct type_FTAM_Contents__Type__Attribute *proposed;
670
671 new_pdu (type_FTAM_F__OPEN__response,
672 type_FTAM_PDU_f__open__response,
673 f__open__response, "F-OPEN-response");
674 new_state (ftop -> ftop_state);
675 new_action (ftop -> ftop_action);
676 if ((proposed = (struct type_FTAM_Contents__Type__Attribute *)
677 calloc (1, sizeof *proposed)) == NULL)
678 goto no_mem;
679 req -> contents__type = proposed;
680 if ((proposed -> document__type__name =
681 oid_cpy (ftop -> ftop_contents)) == NULLOID)
682 goto no_mem;
683 if (proposed -> parameter = ftop -> ftop_parameter)
684 proposed -> parameter -> pe_refcnt++;
685 if (conctl_present (&ftop -> ftop_conctl)
686 && (req -> concurrency__control =
687 conctl2fpm (fsb, &ftop -> ftop_conctl, fti))
688 == NULL)
689 return NOTOK;
690 if (ftop -> ftop_sharedASE
691 && (req -> shared__ASE__information =
692 shared2fpm (fsb, ftop -> ftop_sharedASE, fti)) == NULL)
693 return NOTOK;
694 if (ftop -> ftop_ndiag > 0
695 && (req -> diagnostic = diag2fpm (fsb, 0, ftop -> ftop_diags,
696 ftop -> ftop_ndiag, fti))
697 == NULL)
698 return NOTOK;
699 }
700
701 if (flags & FTG_END) {
702 if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL)
703 goto no_mem;
704 pdus[i] = pdu;
705 pdu -> offset = type_FTAM_PDU_f__end__group__response;
706 texts[i++] = "F-END-GROUP-response";
707 }
708
709 *npdu = i;
710 return OK;
711
712#undef new_pdu
713#undef new_state
714#undef new_action
715
716no_mem: ;
717 return ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory");
718}