Start development on 386BSD 0.0
[unix-history] / .ref-BSD-4_3_Net_2 / usr / src / contrib / isode / ftam / ftambulk2.c
CommitLineData
53102063
C
1/* ftambulk2.c - FPM: respond to bulk data transfer */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/ftam/RCS/ftambulk2.c,v 7.1 91/02/22 09:22:43 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/ftam/RCS/ftambulk2.c,v 7.1 91/02/22 09:22:43 mrose Interim $
9 *
10 *
11 * $Log: ftambulk2.c,v $
12 * Revision 7.1 91/02/22 09:22:43 mrose
13 * Interim 6.8
14 *
15 * Revision 7.0 89/11/23 21:53:28 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-TRANSFER-END.RESPONSE */
38
39int FTransEndResponse (sd, action, sharedASE, diag, ndiag, fti)
40int sd;
41int action;
42PE sharedASE;
43struct FTAMdiagnostic diag[];
44int ndiag;
45struct FTAMindication *fti;
46{
47 SBV smask;
48 int result;
49 register struct ftamblk *fsb;
50
51 switch (action) {
52 case FACTION_SUCCESS:
53 case FACTION_TRANS:
54 case FACTION_PERM:
55 break;
56
57 default:
58 return ftamlose (fti, FS_GEN_NOREASON, 0, NULLCP,
59 "bad value for action parameter");
60 }
61 toomuchP (diag, ndiag, NFDIAG, "diagnostic");
62 missingP (fti);
63
64 smask = sigioblock ();
65
66 ftamPsig (fsb, sd);
67
68 result = FTransEndResponseAux (fsb, action, sharedASE, diag, ndiag, fti);
69
70 (void) sigiomask (smask);
71
72 return result;
73}
74
75/* \f */
76
77static int FTransEndResponseAux (fsb, action, sharedASE, diag, ndiag, fti)
78register struct ftamblk *fsb;
79int action;
80PE sharedASE;
81struct FTAMdiagnostic diag[];
82int ndiag;
83struct FTAMindication *fti;
84{
85 int result;
86 PE pe;
87 struct PSAPindication pis;
88 struct PSAPindication *pi = &pis;
89 struct PSAPabort *pa = &pi -> pi_abort;
90 register struct type_FTAM_PDU *pdu;
91 register struct type_FTAM_F__TRANSFER__END__response *rsp;
92
93 if (fsb -> fsb_flags & FSB_INIT)
94 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "not responder");
95 if (fsb -> fsb_state != FSB_DATAFIN2)
96 return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state");
97
98 pe = NULLPE;
99 if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) {
100no_mem: ;
101 (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory");
102out: ;
103 if (pe)
104 pe_free (pe);
105 if (pdu)
106 free_FTAM_PDU (pdu);
107 if (fti -> fti_abort.fta_action == FACTION_PERM)
108 freefsblk (fsb);
109 return NOTOK;
110 }
111 pdu -> offset = type_FTAM_PDU_f__transfer__end__response;
112 if ((rsp = (struct type_FTAM_F__TRANSFER__END__response *)
113 calloc (1, sizeof *rsp)) == NULL)
114 goto no_mem;
115 pdu -> un.f__transfer__end__response = rsp;
116 if ((rsp -> action__result =
117 (struct type_FTAM_Action__Result *)
118 calloc (1, sizeof *rsp -> action__result)) == NULL)
119 goto no_mem;
120 rsp -> action__result -> parm = action;
121 if (sharedASE
122 && (rsp -> shared__ASE__information =
123 shared2fpm (fsb, sharedASE, fti)) == NULL)
124 goto out;
125 if (ndiag > 0
126 && (rsp -> diagnostic = diag2fpm (fsb, 0, diag, ndiag, fti))
127 == NULL)
128 goto out;
129
130 if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) {
131 (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP,
132 "error encoding PDU: %s", PY_pepy);
133 goto out;
134 }
135
136 pe -> pe_context = fsb -> fsb_id;
137
138 fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.REQUEST", "F-TRANSFER-END-response",
139 pe, 0));
140
141 result = PDataRequest (fsb -> fsb_fd, &pe, 1, pi);
142
143 pe_free (pe);
144 pe = NULLPE;
145 free_FTAM_PDU (pdu);
146 pdu = NULL;
147
148 if (result == NOTOK) {
149 (void) ps2ftamlose (fsb, fti, "PDataRequest", pa);
150 goto out;
151 }
152
153 fsb -> fsb_state = FSB_DATAIDLE;
154
155 return OK;
156}