|
|
1.1 ! root 1: /* ftambulk.c - FPM: bulk data transfer */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/ftam/RCS/ftambulk.c,v 7.0 89/11/23 21:53:26 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/ftam/RCS/ftambulk.c,v 7.0 89/11/23 21:53:26 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: ftambulk.c,v $ ! 12: * Revision 7.0 89/11/23 21:53:26 mrose ! 13: * Release 6.0 ! 14: * ! 15: */ ! 16: ! 17: /* ! 18: * NOTICE ! 19: * ! 20: * Acquisition, use, and distribution of this module and related ! 21: * materials are subject to the restrictions of a license agreement. ! 22: * Consult the Preface in the User's Manual for the full terms of ! 23: * this agreement. ! 24: * ! 25: */ ! 26: ! 27: ! 28: /* LINTLIBRARY */ ! 29: ! 30: #include <stdio.h> ! 31: #include <signal.h> ! 32: #include "fpkt.h" ! 33: ! 34: /* F-DATA.REQUEST */ ! 35: ! 36: int FDataRequest (sd, fadus, nfadu, fti) ! 37: int sd; ! 38: PE fadus[]; ! 39: int nfadu; ! 40: struct FTAMindication *fti; ! 41: { ! 42: SBV smask; ! 43: int result; ! 44: register struct ftamblk *fsb; ! 45: ! 46: missingP (fti); ! 47: ! 48: smask = sigioblock (); ! 49: ! 50: ftamPsig (fsb, sd); ! 51: ! 52: result = FDataRequestAux (fsb, fadus, nfadu, fti); ! 53: ! 54: (void) sigiomask (smask); ! 55: ! 56: return result; ! 57: } ! 58: ! 59: /* */ ! 60: ! 61: static int FDataRequestAux (fsb, fadus, nfadu, fti) ! 62: register struct ftamblk *fsb; ! 63: PE fadus[]; ! 64: int nfadu; ! 65: struct FTAMindication *fti; ! 66: { ! 67: register int i; ! 68: PE pe, ! 69: *pep; ! 70: struct PSAPindication pis; ! 71: struct PSAPindication *pi = &pis; ! 72: struct PSAPabort *pa = &pi -> pi_abort; ! 73: ! 74: switch (fsb -> fsb_state) { ! 75: case FSB_DATAREAD: ! 76: if (fsb -> fsb_flags & FSB_INIT) ! 77: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, ! 78: "not responder"); ! 79: break; ! 80: ! 81: case FSB_DATAWRITE: ! 82: if (!(fsb -> fsb_flags & FSB_INIT)) ! 83: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, ! 84: "not initiator"); ! 85: break; ! 86: ! 87: default: ! 88: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state"); ! 89: } ! 90: ! 91: for (pep = fadus, i = nfadu - 1; i >= 0; pep++, i--) { ! 92: if ((pe = *pep) == NULLPE) ! 93: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, ! 94: "empty FADU at slot %d", nfadu - i - 1); ! 95: ! 96: if (pe -> pe_context == PE_DFLT_CTX) ! 97: pe -> pe_context = fsb -> fsb_id; ! 98: ! 99: if (pe -> pe_context == fsb -> fsb_id) ! 100: switch (PE_ID (pe -> pe_class, pe -> pe_id)) { ! 101: case PE_ID (PE_CLASS_APPL, FADU_NODESCR): ! 102: case PE_ID (PE_CLASS_APPL, FADU_ENTERTREE): ! 103: case PE_ID (PE_CLASS_APPL, FADU_EXITREE): ! 104: break; ! 105: ! 106: default: ! 107: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, ! 108: "bad context at slot %d", nfadu - i - 1); ! 109: } ! 110: } ! 111: ! 112: if (PDataRequest (fsb -> fsb_fd, fadus, nfadu, pi) == NOTOK) { ! 113: (void) ps2ftamlose (fsb, fti, "PDataRequest", pa); ! 114: if (PC_FATAL (pa -> pa_reason)) ! 115: freefsblk (fsb); ! 116: ! 117: return NOTOK; ! 118: } ! 119: ! 120: return OK; ! 121: } ! 122: ! 123: /* F-DATA-END.REQUEST */ ! 124: ! 125: int FDataEndRequest (sd, action, diag, ndiag, fti) ! 126: int sd; ! 127: int action; ! 128: struct FTAMdiagnostic diag[]; ! 129: int ndiag; ! 130: struct FTAMindication *fti; ! 131: { ! 132: SBV smask; ! 133: int result; ! 134: register struct ftamblk *fsb; ! 135: ! 136: switch (action) { ! 137: case FACTION_SUCCESS: ! 138: case FACTION_TRANS: ! 139: case FACTION_PERM: ! 140: break; ! 141: ! 142: default: ! 143: return ftamlose (fti, FS_GEN_NOREASON, 0, NULLCP, ! 144: "bad value for action parameter"); ! 145: } ! 146: toomuchP (diag, ndiag, NFDIAG, "diagnostic"); ! 147: missingP (fti); ! 148: ! 149: smask = sigioblock (); ! 150: ! 151: ftamPsig (fsb, sd); ! 152: ! 153: result = FDataEndRequestAux (fsb, action, diag, ndiag, fti); ! 154: ! 155: (void) sigiomask (smask); ! 156: ! 157: return result; ! 158: } ! 159: ! 160: /* */ ! 161: ! 162: static int FDataEndRequestAux (fsb, action, diag, ndiag, fti) ! 163: register struct ftamblk *fsb; ! 164: int action; ! 165: struct FTAMdiagnostic diag[]; ! 166: int ndiag; ! 167: struct FTAMindication *fti; ! 168: { ! 169: int result; ! 170: PE pe; ! 171: struct PSAPindication pis; ! 172: struct PSAPindication *pi = &pis; ! 173: struct PSAPabort *pa = &pi -> pi_abort; ! 174: register struct type_FTAM_PDU *pdu; ! 175: register struct type_FTAM_F__DATA__END__request *req; ! 176: ! 177: switch (fsb -> fsb_state) { ! 178: case FSB_DATAREAD: ! 179: if (fsb -> fsb_flags & FSB_INIT) ! 180: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, ! 181: "not responder"); ! 182: break; ! 183: ! 184: case FSB_DATAWRITE: ! 185: if (!(fsb -> fsb_flags & FSB_INIT)) ! 186: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, ! 187: "not initiator"); ! 188: break; ! 189: ! 190: default: ! 191: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state"); ! 192: } ! 193: ! 194: pe = NULLPE; ! 195: if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) { ! 196: no_mem: ; ! 197: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory"); ! 198: out: ; ! 199: if (pe) ! 200: pe_free (pe); ! 201: if (pdu) ! 202: free_FTAM_PDU (pdu); ! 203: if (fti -> fti_abort.fta_action == FACTION_PERM) ! 204: freefsblk (fsb); ! 205: return NOTOK; ! 206: } ! 207: pdu -> offset = type_FTAM_PDU_f__data__end__request; ! 208: if ((req = (struct type_FTAM_F__DATA__END__request *) ! 209: calloc (1, sizeof *req)) == NULL) ! 210: goto no_mem; ! 211: pdu -> un.f__data__end__request = req; ! 212: if ((req -> action__result = ! 213: (struct type_FTAM_Action__Result *) ! 214: calloc (1, sizeof *req -> action__result)) == NULL) ! 215: goto no_mem; ! 216: req -> action__result -> parm = action; ! 217: if (ndiag > 0 ! 218: && (req -> diagnostic = diag2fpm (fsb, 0, diag, ndiag, fti)) ! 219: == NULL) ! 220: goto out; ! 221: ! 222: if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) { ! 223: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, ! 224: "error encoding PDU: %s", PY_pepy); ! 225: goto out; ! 226: } ! 227: ! 228: pe -> pe_context = fsb -> fsb_id; ! 229: ! 230: fsbtrace (fsb, ! 231: (fsb -> fsb_fd, "P-DATA.REQUEST", "F-DATA-END-request", pe, 0)); ! 232: ! 233: result = PDataRequest (fsb -> fsb_fd, &pe, 1, pi); ! 234: ! 235: pe_free (pe); ! 236: pe = NULLPE; ! 237: free_FTAM_PDU (pdu); ! 238: pdu = NULL; ! 239: ! 240: if (result == NOTOK) { ! 241: (void) ps2ftamlose (fsb, fti, "PDataRequest", pa); ! 242: goto out; ! 243: } ! 244: ! 245: fsb -> fsb_state = FSB_DATAFIN1; ! 246: ! 247: return OK; ! 248: } ! 249: ! 250: /* F-CANCEL.REQUEST */ ! 251: ! 252: int FCancelRequest (sd, action, sharedASE, diag, ndiag, fti) ! 253: int sd; ! 254: int action; ! 255: PE sharedASE; ! 256: struct FTAMdiagnostic diag[]; ! 257: int ndiag; ! 258: struct FTAMindication *fti; ! 259: { ! 260: SBV smask; ! 261: int result; ! 262: register struct ftamblk *fsb; ! 263: ! 264: switch (action) { ! 265: case FACTION_SUCCESS: ! 266: case FACTION_TRANS: ! 267: case FACTION_PERM: ! 268: break; ! 269: ! 270: default: ! 271: return ftamlose (fti, FS_GEN_NOREASON, 0, NULLCP, ! 272: "bad value for action parameter"); ! 273: } ! 274: toomuchP (diag, ndiag, NFDIAG, "diagnostic"); ! 275: missingP (fti); ! 276: ! 277: smask = sigioblock (); ! 278: ! 279: ftamPsig (fsb, sd); ! 280: ! 281: result = FCancelRequestAux (fsb, action, sharedASE, diag, ndiag, fti); ! 282: ! 283: (void) sigiomask (smask); ! 284: ! 285: return result; ! 286: } ! 287: ! 288: /* */ ! 289: ! 290: static int FCancelRequestAux (fsb, action, sharedASE, diag, ndiag, fti) ! 291: register struct ftamblk *fsb; ! 292: int action; ! 293: PE sharedASE; ! 294: struct FTAMdiagnostic diag[]; ! 295: int ndiag; ! 296: struct FTAMindication *fti; ! 297: { ! 298: int result, ! 299: settings; ! 300: char *prequest; ! 301: PE pe; ! 302: struct PSAPindication pis; ! 303: struct PSAPindication *pi = &pis; ! 304: struct PSAPabort *pa = &pi -> pi_abort; ! 305: register struct type_FTAM_PDU *pdu; ! 306: register struct type_FTAM_F__CANCEL__request *req; ! 307: ! 308: switch (fsb -> fsb_state) { ! 309: case FSB_DATAREAD: ! 310: case FSB_DATAWRITE: ! 311: break; ! 312: ! 313: default: ! 314: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state"); ! 315: } ! 316: ! 317: pe = NULLPE; ! 318: if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) { ! 319: no_mem: ; ! 320: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory"); ! 321: out: ; ! 322: if (pe) ! 323: pe_free (pe); ! 324: if (pdu) ! 325: free_FTAM_PDU (pdu); ! 326: if (fti -> fti_abort.fta_action == FACTION_PERM) ! 327: freefsblk (fsb); ! 328: return NOTOK; ! 329: } ! 330: pdu -> offset = type_FTAM_PDU_f__cancel__request; ! 331: if ((req = (struct type_FTAM_F__CANCEL__request *) ! 332: calloc (1, sizeof *req)) == NULL) ! 333: goto no_mem; ! 334: pdu -> un.f__cancel__request = req; ! 335: if ((req -> action__result = ! 336: (struct type_FTAM_Action__Result *) ! 337: calloc (1, sizeof *req -> action__result)) == NULL) ! 338: goto no_mem; ! 339: req -> action__result -> parm = action; ! 340: if (sharedASE ! 341: && (req -> shared__ASE__information = ! 342: shared2fpm (fsb, sharedASE, fti)) == NULL) ! 343: goto out; ! 344: if (ndiag > 0 ! 345: && (req -> diagnostic = diag2fpm (fsb, 0, diag, ndiag, fti)) ! 346: == NULL) ! 347: goto out; ! 348: ! 349: if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) { ! 350: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, ! 351: "error encoding PDU: %s", PY_pepy); ! 352: goto out; ! 353: } ! 354: ! 355: pe -> pe_context = fsb -> fsb_id; ! 356: ! 357: if (fsb -> fsb_srequirements & SR_RESYNC) { ! 358: fsbtrace (fsb, (fsb -> fsb_fd, "P-RESYNCHRONIZE.REQUEST", ! 359: "F-CANCEL-request", pe, 0)); ! 360: ! 361: settings = 0; /* XXX: more later! */ ! 362: ! 363: result = PReSyncRequest (fsb -> fsb_fd, SYNC_ABANDON, SERIAL_NONE, ! 364: settings, &pe, 1, pi); ! 365: ! 366: prequest = "PReSyncRequest"; ! 367: } ! 368: else { ! 369: fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.REQUEST", "F-CANCEL-request", ! 370: pe, 0)); ! 371: ! 372: result = PDataRequest (fsb -> fsb_fd, &pe, 1, pi); ! 373: ! 374: prequest = "PDataRequest"; ! 375: } ! 376: ! 377: pe_free (pe); ! 378: pe = NULLPE; ! 379: free_FTAM_PDU (pdu); ! 380: pdu = NULL; ! 381: ! 382: if (result == NOTOK) { ! 383: (void) ps2ftamlose (fsb, fti, prequest, pa); ! 384: goto out; ! 385: } ! 386: ! 387: fsb -> fsb_flags |= FSB_CANCEL; ! 388: fsb -> fsb_state = FSB_DATACANCEL; ! 389: fsb -> fsb_cancelaction = action; ! 390: if (fsb -> fsb_cancelshared = sharedASE) ! 391: fsb -> fsb_cancelshared -> pe_refcnt++; ! 392: fsb -> fsb_canceldiags = diag; ! 393: fsb -> fsb_cancelndiag = ndiag; ! 394: ! 395: return FWaitRequestAux (fsb, NOTOK, fti); ! 396: } ! 397: ! 398: /* F-CANCEL.RESPONSE */ ! 399: ! 400: int FCancelResponse (sd, action, sharedASE, diag, ndiag, fti) ! 401: int sd; ! 402: int action; ! 403: PE sharedASE; ! 404: struct FTAMdiagnostic diag[]; ! 405: int ndiag; ! 406: struct FTAMindication *fti; ! 407: { ! 408: SBV smask; ! 409: int result; ! 410: register struct ftamblk *fsb; ! 411: ! 412: switch (action) { ! 413: case FACTION_SUCCESS: ! 414: case FACTION_TRANS: ! 415: case FACTION_PERM: ! 416: break; ! 417: ! 418: default: ! 419: return ftamlose (fti, FS_GEN_NOREASON, 0, NULLCP, ! 420: "bad value for action parameter"); ! 421: } ! 422: toomuchP (diag, ndiag, NFDIAG, "diagnostic"); ! 423: missingP (fti); ! 424: ! 425: smask = sigioblock (); ! 426: ! 427: ftamPsig (fsb, sd); ! 428: ! 429: result = FCancelResponseAux (fsb, action, sharedASE, diag, ndiag, fti); ! 430: ! 431: (void) sigiomask (smask); ! 432: ! 433: return result; ! 434: } ! 435: ! 436: /* */ ! 437: ! 438: int FCancelResponseAux (fsb, action, sharedASE, diag, ndiag, fti) ! 439: register struct ftamblk *fsb; ! 440: int action; ! 441: PE sharedASE; ! 442: struct FTAMdiagnostic diag[]; ! 443: int ndiag; ! 444: struct FTAMindication *fti; ! 445: { ! 446: int result; ! 447: char *prequest; ! 448: PE pe; ! 449: struct PSAPindication pis; ! 450: struct PSAPindication *pi = &pis; ! 451: struct PSAPabort *pa = &pi -> pi_abort; ! 452: register struct type_FTAM_PDU *pdu; ! 453: register struct type_FTAM_F__CANCEL__response *rsp; ! 454: ! 455: if (fsb -> fsb_state != FSB_DATACANCEL) ! 456: return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state"); ! 457: ! 458: pe = NULLPE; ! 459: if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) { ! 460: no_mem: ; ! 461: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory"); ! 462: out: ; ! 463: if (pe) ! 464: pe_free (pe); ! 465: if (pdu) ! 466: free_FTAM_PDU (pdu); ! 467: if (fti -> fti_abort.fta_action == FACTION_PERM) ! 468: freefsblk (fsb); ! 469: return NOTOK; ! 470: } ! 471: pdu -> offset = type_FTAM_PDU_f__cancel__response; ! 472: if ((rsp = (struct type_FTAM_F__CANCEL__response *) ! 473: calloc (1, sizeof *rsp)) == NULL) ! 474: goto no_mem; ! 475: pdu -> un.f__cancel__response = rsp; ! 476: if ((rsp -> action__result = ! 477: (struct type_FTAM_Action__Result *) ! 478: calloc (1, sizeof *rsp -> action__result)) == NULL) ! 479: goto no_mem; ! 480: rsp -> action__result -> parm = action; ! 481: if (sharedASE ! 482: && (rsp -> shared__ASE__information = ! 483: shared2fpm (fsb, sharedASE, fti)) == NULL) ! 484: goto out; ! 485: if (ndiag > 0 ! 486: && (rsp -> diagnostic = diag2fpm (fsb, 0, diag, ndiag, fti)) ! 487: == NULL) ! 488: goto out; ! 489: ! 490: if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) { ! 491: (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, ! 492: "error encoding PDU: %s", PY_pepy); ! 493: goto out; ! 494: } ! 495: ! 496: pe -> pe_context = fsb -> fsb_id; ! 497: ! 498: if (fsb -> fsb_srequirements & SR_RESYNC) { ! 499: fsbtrace (fsb, (fsb -> fsb_fd, "P-RESYNCHRONIZE.RESPONSE", ! 500: "F-CANCEL-response", pe, 0)); ! 501: ! 502: result = PReSyncResponse (fsb -> fsb_fd, SERIAL_NONE, ! 503: fsb -> fsb_settings, &pe, 1, pi); ! 504: ! 505: prequest = "PReSyncResponse"; ! 506: } ! 507: else { ! 508: fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.REQUEST", "F-CANCEL-response", ! 509: pe, 0)); ! 510: ! 511: result = PDataRequest (fsb -> fsb_fd, &pe, 1, pi); ! 512: ! 513: prequest = "PDataRequest"; ! 514: } ! 515: ! 516: pe_free (pe); ! 517: pe = NULLPE; ! 518: free_FTAM_PDU (pdu); ! 519: pdu = NULL; ! 520: ! 521: if (result == NOTOK) { ! 522: (void) ps2ftamlose (fsb, fti, prequest, pa); ! 523: goto out; ! 524: } ! 525: ! 526: fsb -> fsb_state = FSB_DATAIDLE; ! 527: ! 528: return OK; ! 529: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.