BSD 4_3_Net_2 development
[unix-history] / usr / src / contrib / isode / psap2 / psapabort.c
CommitLineData
9e8e5516
C
1/* psapabort.c - PPM: user abort */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/psap2/RCS/psapabort.c,v 7.2 91/02/22 09:37:28 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/psap2/RCS/psapabort.c,v 7.2 91/02/22 09:37:28 mrose Interim $
9 *
10 *
11 * $Log: psapabort.c,v $
12 * Revision 7.2 91/02/22 09:37:28 mrose
13 * Interim 6.8
14 *
15 * Revision 7.1 90/07/01 21:04:56 mrose
16 * pepsy
17 *
18 * Revision 7.0 89/11/23 22:14:17 mrose
19 * Release 6.0
20 *
21 */
22
23/*
24 * NOTICE
25 *
26 * Acquisition, use, and distribution of this module and related
27 * materials are subject to the restrictions of a license agreement.
28 * Consult the Preface in the User's Manual for the full terms of
29 * this agreement.
30 *
31 */
32
33
34/* LINTLIBRARY */
35
36#include <stdio.h>
37#include <signal.h>
38#include "PS-types.h"
39#include "ppkt.h"
40#include "tailor.h"
41
42/* \f P-U-ABORT.REQUEST */
43
44int PUAbortRequest (sd, data, ndata, pi)
45int sd;
46PE *data;
47int ndata;
48struct PSAPindication *pi;
49{
50 SBV smask;
51 int len,
52 result;
53 char *base;
54 PE pe;
55 register struct psapblk *pb;
56 struct SSAPindication sis;
57 register struct SSAPabort *sa = &sis.si_abort;
58 register struct type_PS_ARU__PPDU *pdu;
59
60 toomuchP (data, ndata, NPDATA, "abort");
61 missingP (pi);
62
63 smask = sigioblock ();
64
65 if ((pb = findpblk (sd)) == NULL) {
66 (void) sigiomask (smask);
67 return psaplose (pi, PC_PARAMETER, NULLCP,
68 "invalid presentation descriptor");
69 }
70
71 pe = NULLPE;
72 base = NULLCP;
73 result = NOTOK;
74 if ((pdu = (struct type_PS_ARU__PPDU *) calloc (1, sizeof *pdu)) == NULL) {
75no_mem: ;
76 (void) psaplose (pi, PC_CONGEST, NULLCP, "out of memory");
77 goto out2;
78 }
79 pdu -> offset = type_PS_ARU__PPDU_normal__mode;
80 if ((pdu -> un.normal__mode = (struct element_PS_4 *)
81 calloc (1, sizeof (struct element_PS_4)))
82 == NULL)
83 goto no_mem;
84 if (data && ndata > 0) {
85 if (pb -> pb_ncontext > 0
86 && (pdu -> un.normal__mode -> context__list =
87 silly_list (pb, pi)) == NULL)
88 goto out2;
89
90 if ((pdu -> un.normal__mode -> user__data = info2ppdu (pb, pi,
91 data, ndata,
92 PPDU_NONE))
93 == NULL)
94 goto out2;
95 }
96
97 if (encode_PS_ARU__PPDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) {
98 (void) psaplose (pi, PC_CONGEST, NULLCP, "error encoding PDU: %s",
99 PY_pepy);
100 goto out2;
101 }
102
103 PLOGP (psap2_log,PS_ARU__PPDU, pe, "ARU-PPDU", 0);
104
105 if (pe2ssdu (pe, &base, &len) == NOTOK)
106 goto no_mem;
107
108 if ((result = SUAbortRequest (pb -> pb_fd, base, len, &sis)) == NOTOK)
109 if (SC_FATAL (sa -> sa_reason)) {
110 (void) ss2pslose (pb, pi, "SUAbortRequest", sa);
111 goto out2;
112 }
113 else {
114 (void) ss2pslose (NULLPB, pi, "SUAbortRequest", sa);
115 goto out1;
116 }
117
118 result = OK;
119 pb -> pb_fd = NOTOK;
120
121out2: ;
122 freepblk (pb);
123
124out1: ;
125 if (pdu)
126 free_PS_ARU__PPDU (pdu);
127 if (pe)
128 pe_free (pe);
129 if (base)
130 free (base);
131
132 (void) sigiomask (smask);
133
134 return result;
135}