|
|
1.1 ! root 1: /* psaplose.c - PPM: you lose */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/psap2-lpp/RCS/psaplose.c,v 7.1 90/07/01 21:05:27 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/psap2-lpp/RCS/psaplose.c,v 7.1 90/07/01 21:05:27 mrose Exp $ ! 9: * ! 10: * Contributed by The Wollongong Group, Inc. ! 11: * ! 12: * ! 13: * $Log: psaplose.c,v $ ! 14: * Revision 7.1 90/07/01 21:05:27 mrose ! 15: * pepsy ! 16: * ! 17: * Revision 7.0 89/11/23 22:15:55 mrose ! 18: * Release 6.0 ! 19: * ! 20: */ ! 21: ! 22: /* ! 23: * NOTICE ! 24: * ! 25: * Acquisition, use, and distribution of this module and related ! 26: * materials are subject to the restrictions of a license agreement. ! 27: * Consult the Preface in the User's Manual for the full terms of ! 28: * this agreement. ! 29: * ! 30: */ ! 31: ! 32: ! 33: /* LINTLIBRARY */ ! 34: ! 35: #include <stdio.h> ! 36: #include <varargs.h> ! 37: #define LPP ! 38: #include "PS-types.h" ! 39: #include "ppkt.h" ! 40: #include "tailor.h" ! 41: ! 42: /* */ ! 43: ! 44: #ifndef lint ! 45: int ppktlose (va_alist) ! 46: va_dcl ! 47: { ! 48: int reason, ! 49: result; ! 50: PE pe; ! 51: register struct psapblk *pb; ! 52: register struct PSAPindication *pi; ! 53: register struct PSAPabort *pa; ! 54: register struct type_PS_Abort__PDU *pdu; ! 55: struct type_PS_SessionConnectionIdentifier *pref; ! 56: va_list ap; ! 57: ! 58: va_start (ap); ! 59: ! 60: pb = va_arg (ap, struct psapblk *); ! 61: pi = va_arg (ap, struct PSAPindication *); ! 62: reason = va_arg (ap, int); ! 63: pref = va_arg (ap, struct type_PS_SessionConnectionIdentifier *); ! 64: ! 65: result = _psaplose (pi, reason, ap); ! 66: ! 67: va_end (ap); ! 68: ! 69: if ((pa = &pi -> pi_abort) -> pa_cc > 0) { ! 70: SLOG (psap2_log, LLOG_EXCEPTIONS, NULLCP, ! 71: ("ppktlose [%s] %*.*s", PErrString (pa -> pa_reason), ! 72: pa -> pa_cc, pa -> pa_cc, pa -> pa_data)); ! 73: } ! 74: else ! 75: SLOG (psap2_log, LLOG_EXCEPTIONS, NULLCP, ! 76: ("ppktlose [%s]", PErrString (pa -> pa_reason))); ! 77: ! 78: if (pb -> pb_fd == NOTOK) ! 79: return result; ! 80: ! 81: if (pb -> pb_reliability == LOW_QUALITY) { ! 82: if (pref == NULLRF && (pref = pb -> pb_reference) == NULLRF) ! 83: return result; ! 84: } ! 85: else ! 86: pref = NULLRF; ! 87: ! 88: switch (reason) { ! 89: case PC_NOTSPECIFIED: ! 90: default: ! 91: reason = int_PS_Abort__reason_reason__not__specified; ! 92: break; ! 93: ! 94: case PC_UNRECOGNIZED: ! 95: case PC_UNEXPECTED: ! 96: case PC_PPPARAM1: ! 97: reason = int_PS_Abort__reason_unrecognized__ppdu ! 98: + (reason - PC_UNRECOGNIZED); ! 99: break; ! 100: ! 101: case PC_INVALID: ! 102: reason = int_PS_Abort__reason_invalid__ppdu__parameter; ! 103: break; ! 104: ! 105: case PC_SESSION: ! 106: reason = int_PS_Abort__reason_reference__mismatch; ! 107: break; ! 108: } ! 109: ! 110: if ((pdu = (struct type_PS_Abort__PDU *) malloc (sizeof *pdu)) ! 111: && (pdu -> reason = (struct type_PS_Abort__reason *) ! 112: malloc (sizeof (struct type_PS_Abort__reason)))) { ! 113: pdu -> reference = pref; ! 114: pdu -> user__data = NULLPE; ! 115: pdu -> reason -> parm = reason; ! 116: ! 117: pe = NULLPE; ! 118: if (encode_PS_Abort__PDU (&pe, 1, 0, NULLCP, pdu) != NOTOK) { ! 119: PLOGP (psap2_log,PS_PDUs, pe, "Abort-PDU", 0); ! 120: ! 121: (void) pe2ps (pb -> pb_stream, pe); ! 122: } ! 123: if (pe) ! 124: pe_free (pe); ! 125: ! 126: pdu -> reference = NULL; ! 127: free_PS_Abort__PDU (pdu); ! 128: } ! 129: ! 130: return result; ! 131: } ! 132: #else ! 133: /* VARARGS6 */ ! 134: ! 135: int ppktlose (pb, pi, reason, pref, what, fmt) ! 136: register struct psapblk *pb; ! 137: register struct PSAPindication *pi; ! 138: int reason; ! 139: struct type_PS_SessionConnectionIdentifier *pref; ! 140: char *what, ! 141: *fmt; ! 142: { ! 143: return ppktlose (pb, pi, reason, pref, what, fmt); ! 144: } ! 145: #endif ! 146: ! 147: /* */ ! 148: ! 149: #ifndef lint ! 150: int psaplose (va_alist) ! 151: va_dcl ! 152: { ! 153: int reason, ! 154: result; ! 155: struct PSAPindication *pi; ! 156: va_list ap; ! 157: ! 158: va_start (ap); ! 159: ! 160: pi = va_arg (ap, struct PSAPindication *); ! 161: reason = va_arg (ap, int); ! 162: ! 163: result = _psaplose (pi, reason, ap); ! 164: ! 165: va_end (ap); ! 166: ! 167: return result; ! 168: } ! 169: #else ! 170: /* VARARGS4 */ ! 171: ! 172: int psaplose (pi, reason, what, fmt) ! 173: struct PSAPindication *pi; ! 174: int reason; ! 175: char *what, ! 176: *fmt; ! 177: { ! 178: return psaplose (pi, reason, what, fmt); ! 179: } ! 180: #endif ! 181: ! 182: /* */ ! 183: ! 184: #ifndef lint ! 185: static int _psaplose (pi, reason, ap) /* what, fmt, args ... */ ! 186: register struct PSAPindication *pi; ! 187: int reason; ! 188: va_list ap; ! 189: { ! 190: register char *bp; ! 191: char buffer[BUFSIZ]; ! 192: register struct PSAPabort *pa; ! 193: ! 194: if (pi) { ! 195: bzero ((char *) pi, sizeof *pi); ! 196: pi -> pi_type = PI_ABORT; ! 197: pa = &pi -> pi_abort; ! 198: ! 199: asprintf (bp = buffer, ap); ! 200: bp += strlen (bp); ! 201: ! 202: pa -> pa_peer = 0; ! 203: pa -> pa_reason = reason; ! 204: pa -> pa_ninfo = 0; ! 205: copyPSAPdata (buffer, bp - buffer, pa); ! 206: } ! 207: ! 208: return NOTOK; ! 209: } ! 210: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.