|
|
1.1 ! root 1: /* acsapreleas1.c - ACPM: initiate release */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/acsap/RCS/acsapreleas1.c,v 7.1 90/07/01 21:02:02 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/acsap/RCS/acsapreleas1.c,v 7.1 90/07/01 21:02:02 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: acsapreleas1.c,v $ ! 12: * Revision 7.1 90/07/01 21:02:02 mrose ! 13: * pepsy ! 14: * ! 15: * Revision 7.0 89/11/23 21:21:54 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 "ACS-types.h" ! 36: #define ACSE ! 37: #include "acpkt.h" ! 38: #include "tailor.h" ! 39: ! 40: /* A-RELEASE.REQUEST */ ! 41: ! 42: int AcRelRequest (sd, reason, data, ndata, secs, acr, aci) ! 43: int sd; ! 44: int reason; ! 45: PE *data; ! 46: int ndata; ! 47: int secs; ! 48: struct AcSAPrelease *acr; ! 49: struct AcSAPindication *aci; ! 50: { ! 51: SBV smask; ! 52: int result; ! 53: register struct assocblk *acb; ! 54: register struct type_ACS_RLRQ__apdu *rlrq; ! 55: ! 56: switch (reason) { ! 57: case ACF_NORMAL: ! 58: case ACF_URGENT: ! 59: case ACF_USERDEFINED: ! 60: break; ! 61: ! 62: default: ! 63: return acsaplose (aci, ACS_PARAMETER, NULLCP, ! 64: "invalid value for reason parameter"); ! 65: } ! 66: toomuchP (data, ndata, NACDATA, "release"); ! 67: if (data) { /* XXX: probably should have a more intensive check... */ ! 68: register int i; ! 69: register PE *pep; ! 70: ! 71: for (pep = data, i = ndata; i > 0; pep++, i--) ! 72: if ((*pep) -> pe_context == PE_DFLT_CTX) ! 73: return acsaplose (aci, ACS_PARAMETER, NULLCP, ! 74: "default context not allowed for user-data at slot %d", ! 75: pep - data); ! 76: } ! 77: missingP (acr); ! 78: missingP (aci); ! 79: ! 80: smask = sigioblock (); ! 81: ! 82: acsapPsig (acb, sd); ! 83: ! 84: if ((rlrq = (struct type_ACS_RLRQ__apdu *) calloc (1, sizeof *rlrq)) ! 85: == NULL) { ! 86: (void) acsaplose (aci, ACS_CONGEST, NULLCP, "out of memory"); ! 87: goto out2; ! 88: } ! 89: rlrq -> optionals |= opt_ACS_RLRQ__apdu_reason; ! 90: rlrq -> reason = reason; ! 91: if (data ! 92: && ndata > 0 ! 93: && (rlrq -> user__information = info2apdu (acb, aci, data, ndata)) ! 94: == NULL) ! 95: goto out2; ! 96: ! 97: result = encode_ACS_RLRQ__apdu (&acb -> acb_retry, 1, 0, NULLCP, rlrq); ! 98: ! 99: free_ACS_RLRQ__apdu (rlrq); ! 100: rlrq = NULL; ! 101: ! 102: if (result == NOTOK) { ! 103: (void) acsaplose (aci, ACS_CONGEST, NULLCP, "error encoding PDU: %s", ! 104: PY_pepy); ! 105: goto out2; ! 106: } ! 107: acb -> acb_retry -> pe_context = acb -> acb_id; ! 108: ! 109: PLOGP (acsap_log,ACS_ACSE__apdu, acb -> acb_retry, "RLRQ-apdu", 0); ! 110: ! 111: result = AcRelRetryRequestAux (acb, secs, acr, aci); ! 112: goto out1; ! 113: ! 114: out2: ; ! 115: if (acb -> acb_retry) { ! 116: pe_free (acb -> acb_retry); ! 117: acb -> acb_retry = NULLPE; ! 118: } ! 119: freeacblk (acb); ! 120: if (rlrq) ! 121: free_ACS_RLRQ__apdu (rlrq); ! 122: result = NOTOK; ! 123: ! 124: out1: ; ! 125: (void) sigiomask (smask); ! 126: ! 127: return result; ! 128: } ! 129: ! 130: /* A-RELEASE-RETRY.REQUEST (pseudo) */ ! 131: ! 132: int AcRelRetryRequest (sd, secs, acr, aci) ! 133: int sd; ! 134: int secs; ! 135: struct AcSAPrelease *acr; ! 136: struct AcSAPindication *aci; ! 137: { ! 138: SBV smask; ! 139: int result; ! 140: register struct assocblk *acb; ! 141: ! 142: missingP (acr); ! 143: missingP (aci); ! 144: ! 145: smask = sigioblock (); ! 146: ! 147: if ((acb = findacblk (sd)) == NULL) ! 148: result = acsaplose (aci, ACS_PARAMETER, NULLCP, ! 149: "invalid association descriptor"); ! 150: else ! 151: if (!(acb -> acb_flags & ACB_RELEASE)) ! 152: result = acsaplose (aci, ACS_OPERATION, "release not in progress"); ! 153: else ! 154: result = AcRelRetryRequestAux (acb, secs, acr, aci); ! 155: ! 156: (void) sigiomask (smask); ! 157: ! 158: return result; ! 159: } ! 160: ! 161: /* */ ! 162: ! 163: static int AcRelRetryRequestAux (acb, secs, acr, aci) ! 164: register struct assocblk *acb; ! 165: int secs; ! 166: struct AcSAPrelease *acr; ! 167: struct AcSAPindication *aci; ! 168: { ! 169: int result; ! 170: char *id = acb -> acb_flags & ACB_RELEASE ? "PRelRetryRequest" ! 171: : "PRelRequest"; ! 172: PE pe; ! 173: struct PSAPrelease prs; ! 174: register struct PSAPrelease *pr = &prs; ! 175: struct PSAPindication pis; ! 176: register struct PSAPabort *pa = &pis.pi_abort; ! 177: struct type_ACS_ACSE__apdu *pdu = NULL; ! 178: register struct type_ACS_RLRE__apdu *rlre; ! 179: ! 180: bzero ((char *) pr, sizeof *pr); ! 181: ! 182: if ((result = (acb -> acb_flags & ACB_RELEASE) ! 183: ? PRelRetryRequest (acb -> acb_fd, secs, pr, &pis) ! 184: : PRelRequest (acb -> acb_fd, &acb -> acb_retry, 1, ! 185: secs, pr, &pis)) == NOTOK) { ! 186: if (pa -> pa_reason == PC_TIMER) { ! 187: acb -> acb_flags |= ACB_RELEASE; ! 188: ! 189: return ps2acslose (NULLACB, aci, id, pa); ! 190: } ! 191: ! 192: if (pa -> pa_peer) { ! 193: (void) AcABORTser (acb -> acb_fd, pa, aci); ! 194: goto out1; ! 195: } ! 196: if (PC_FATAL (pa -> pa_reason)) { ! 197: (void) ps2acslose (acb, aci, id, pa); ! 198: goto out2; ! 199: } ! 200: else { ! 201: (void) ps2acslose (NULLACB, aci, id, pa); ! 202: goto out1; ! 203: } ! 204: } ! 205: ! 206: bzero ((char *) acr, sizeof *acr); ! 207: ! 208: if (pr -> pr_ninfo == 0) { ! 209: result = acsaplose (aci, ACS_PROTOCOL, NULLCP, ! 210: "no user-data on P-RELEASE"); ! 211: goto out3; ! 212: } ! 213: ! 214: result = decode_ACS_ACSE__apdu (pe = pr -> pr_info[0], 1, NULLIP, NULLVP, ! 215: &pdu); ! 216: ! 217: #ifdef DEBUG ! 218: if (result == OK && (acsap_log -> ll_events & LLOG_PDUS)) ! 219: pvpdu (acsap_log, print_ACS_ACSE__apdu_P, pe, "ACSE-apdu", 1); ! 220: #endif ! 221: ! 222: pe_free (pe); ! 223: pe = pr -> pr_info[0] = NULLPE; ! 224: ! 225: if (result == NOTOK) { ! 226: (void) acpktlose (acb, aci, ACS_PROTOCOL, NULLCP, "%s", PY_pepy); ! 227: goto out3; ! 228: } ! 229: ! 230: if (pdu -> offset != type_ACS_ACSE__apdu_rlre) { ! 231: (void) acpktlose (acb, aci, ACS_PROTOCOL, NULLCP, ! 232: "unexpected PDU %d on P-RELEASE", pdu -> offset); ! 233: goto out3; ! 234: } ! 235: ! 236: rlre = pdu -> un.rlre; ! 237: if (rlre -> optionals & opt_ACS_RLRE__apdu_reason) ! 238: acr -> acr_reason = rlre -> reason; ! 239: else ! 240: acr -> acr_reason = int_ACS_reason_normal; ! 241: if (apdu2info (acb, aci, rlre -> user__information, acr -> acr_info, ! 242: &acr -> acr_ninfo) == NOTOK) ! 243: goto out3; ! 244: ! 245: if (acr -> acr_affirmative = pr -> pr_affirmative) { ! 246: acb -> acb_fd = NOTOK; ! 247: result = OK; ! 248: } ! 249: else ! 250: result = DONE; ! 251: ! 252: out3: ; ! 253: PRFREE (pr); ! 254: ! 255: out2: ; ! 256: if (result == DONE) ! 257: result = OK; ! 258: else ! 259: freeacblk (acb), acb = NULLACB; ! 260: out1: ; ! 261: if (acb && acb -> acb_retry) { ! 262: pe_free (acb -> acb_retry); ! 263: acb -> acb_retry = NULLPE; ! 264: } ! 265: if (pdu) ! 266: free_ACS_ACSE__apdu (pdu); ! 267: ! 268: return result; ! 269: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.