Commit | Line | Data |
---|---|---|
9e8e5516 C |
1 | /* psaplose.c - PPM: you lose */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/psap2/RCS/psaplose.c,v 7.2 91/02/22 09:37:34 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/psap2/RCS/psaplose.c,v 7.2 91/02/22 09:37:34 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: psaplose.c,v $ | |
12 | * Revision 7.2 91/02/22 09:37:34 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.1 90/07/01 21:05:04 mrose | |
16 | * pepsy | |
17 | * | |
18 | * Revision 7.0 89/11/23 22:14:21 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 <varargs.h> | |
38 | #include "PS-types.h" | |
39 | #include "ppkt.h" | |
40 | #include "tailor.h" | |
41 | ||
42 | /* \f */ | |
43 | ||
44 | #ifndef lint | |
45 | int ppktlose (va_alist) | |
46 | va_dcl | |
47 | { | |
48 | int len, | |
49 | ppdu, | |
50 | reason, | |
51 | result, | |
52 | value; | |
53 | char *base; | |
54 | register struct psapblk *pb; | |
55 | PE pe; | |
56 | register struct PSAPindication *pi; | |
57 | register struct PSAPabort *pa; | |
58 | struct SSAPindication sis; | |
59 | struct type_PS_ARP__PPDU pdus; | |
60 | register struct type_PS_ARP__PPDU *pdu = &pdus; | |
61 | va_list ap; | |
62 | ||
63 | va_start (ap); | |
64 | ||
65 | pb = va_arg (ap, struct psapblk *); | |
66 | pi = va_arg (ap, struct PSAPindication *); | |
67 | reason = va_arg (ap, int); | |
68 | ppdu = va_arg (ap, int); | |
69 | ||
70 | result = _psaplose (pi, reason, ap); | |
71 | ||
72 | va_end (ap); | |
73 | ||
74 | if ((pa = &pi -> pi_abort) -> pa_cc > 0) { | |
75 | SLOG (psap2_log, LLOG_EXCEPTIONS, NULLCP, | |
76 | ("ppktlose [%s] %*.*s", PErrString (pa -> pa_reason), | |
77 | pa -> pa_cc, pa -> pa_cc, pa -> pa_data)); | |
78 | } | |
79 | else | |
80 | SLOG (psap2_log, LLOG_EXCEPTIONS, NULLCP, | |
81 | ("ppktlose [%s]", PErrString (pa -> pa_reason))); | |
82 | ||
83 | if (pb -> pb_fd == NOTOK) | |
84 | return result; | |
85 | ||
86 | switch (reason) { | |
87 | case PC_NOTSPECIFIED: | |
88 | default: | |
89 | reason = int_PS_Abort__reason_reason__not__specified; | |
90 | break; | |
91 | ||
92 | case PC_UNRECOGNIZED: | |
93 | case PC_UNEXPECTED: | |
94 | case PC_SSPRIMITIVE: | |
95 | case PC_PPPARAM1: | |
96 | case PC_PPPARAM2: | |
97 | case PC_INVALID: | |
98 | reason -= PC_ABORT_BASE; | |
99 | break; | |
100 | } | |
101 | ||
102 | pdu -> provider__reason = (struct type_PS_Abort__reason *) &reason; | |
103 | pdu -> event = ppdu != PPDU_NONE | |
104 | ? (struct type_PS_Event__identifier *) &ppdu | |
105 | : NULL; | |
106 | ||
107 | pe = NULLPE; | |
108 | base = NULL, len = 0; | |
109 | if (encode_PS_ARP__PPDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) { | |
110 | PLOGP (psap2_log,PS_ARP__PPDU, pe, "ARP-PPDU", 0); | |
111 | ||
112 | (void) pe2ssdu (pe, &base, &len); | |
113 | } | |
114 | if (pe) | |
115 | pe_free (pe); | |
116 | ||
117 | if (SUAbortRequest (pb -> pb_fd, base, len, &sis) != NOTOK) | |
118 | pb -> pb_fd = NOTOK; | |
119 | ||
120 | if (base) | |
121 | free (base); | |
122 | ||
123 | return result; | |
124 | } | |
125 | #else | |
126 | /* VARARGS6 */ | |
127 | ||
128 | int ppktlose (pb, pi, reason, ppdu, what, fmt) | |
129 | register struct psapblk *pb; | |
130 | register struct PSAPindication *pi; | |
131 | int reason, | |
132 | ppdu; | |
133 | char *what, | |
134 | *fmt; | |
135 | { | |
136 | return ppktlose (pb, pi, reason, ppdu, what, fmt); | |
137 | } | |
138 | #endif | |
139 | ||
140 | /* \f */ | |
141 | ||
142 | #ifndef lint | |
143 | int psaplose (va_alist) | |
144 | va_dcl | |
145 | { | |
146 | int reason, | |
147 | result; | |
148 | struct PSAPindication *pi; | |
149 | va_list ap; | |
150 | ||
151 | va_start (ap); | |
152 | ||
153 | pi = va_arg (ap, struct PSAPindication *); | |
154 | reason = va_arg (ap, int); | |
155 | ||
156 | result = _psaplose (pi, reason, ap); | |
157 | ||
158 | va_end (ap); | |
159 | ||
160 | return result; | |
161 | } | |
162 | #else | |
163 | /* VARARGS4 */ | |
164 | ||
165 | int psaplose (pi, reason, what, fmt) | |
166 | struct PSAPindication *pi; | |
167 | int reason; | |
168 | char *what, | |
169 | *fmt; | |
170 | { | |
171 | return psaplose (pi, reason, what, fmt); | |
172 | } | |
173 | #endif | |
174 | ||
175 | /* \f */ | |
176 | ||
177 | #ifndef lint | |
178 | static int _psaplose (pi, reason, ap) /* what, fmt, args ... */ | |
179 | register struct PSAPindication *pi; | |
180 | int reason; | |
181 | va_list ap; | |
182 | { | |
183 | register char *bp; | |
184 | char buffer[BUFSIZ]; | |
185 | register struct PSAPabort *pa; | |
186 | ||
187 | if (pi) { | |
188 | bzero ((char *) pi, sizeof *pi); | |
189 | pi -> pi_type = PI_ABORT; | |
190 | pa = &pi -> pi_abort; | |
191 | ||
192 | asprintf (bp = buffer, ap); | |
193 | bp += strlen (bp); | |
194 | ||
195 | pa -> pa_peer = 0; | |
196 | pa -> pa_reason = reason; | |
197 | pa -> pa_ninfo = 0; | |
198 | copyPSAPdata (buffer, bp - buffer, pa); | |
199 | } | |
200 | ||
201 | return NOTOK; | |
202 | } | |
203 | #endif |