|
|
1.1 ! root 1: /* ftam-assoc.c - interactive initiator FTAM -- association management */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/ftam2/RCS/ftam-assoc.c,v 7.3 90/07/09 14:37:10 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/ftam2/RCS/ftam-assoc.c,v 7.3 90/07/09 14:37:10 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: ftam-assoc.c,v $ ! 12: * Revision 7.3 90/07/09 14:37:10 mrose ! 13: * sync ! 14: * ! 15: * Revision 7.2 89/12/01 13:56:06 mrose ! 16: * touch-up ! 17: * ! 18: * Revision 7.1 89/11/30 23:51:50 mrose ! 19: * pa2str ! 20: * ! 21: * Revision 7.0 89/11/23 21:54:15 mrose ! 22: * Release 6.0 ! 23: * ! 24: */ ! 25: ! 26: /* ! 27: * NOTICE ! 28: * ! 29: * Acquisition, use, and distribution of this module and related ! 30: * materials are subject to the restrictions of a license agreement. ! 31: * Consult the Preface in the User's Manual for the full terms of ! 32: * this agreement. ! 33: * ! 34: */ ! 35: ! 36: ! 37: #include <stdio.h> ! 38: #include "ftamuser.h" ! 39: ! 40: /* */ ! 41: ! 42: static struct PSAPaddr vfs_bound; ! 43: ! 44: /* */ ! 45: ! 46: int f_open (vec) ! 47: char **vec; ! 48: { ! 49: register int i; ! 50: int manage; ! 51: char *p; ! 52: #ifndef BRIDGE ! 53: char buffer[BUFSIZ], ! 54: prompt[BUFSIZ]; ! 55: #endif ! 56: AEI aei; ! 57: register struct vfsmap *vf; ! 58: register struct PSAPaddr *pa; ! 59: struct FTAMcontentlist fcs; ! 60: register struct FTAMcontentlist *fc = &fcs; ! 61: register struct FTAMcontent *fx; ! 62: struct FTAMconnect ftcs; ! 63: register struct FTAMconnect *ftc = &ftcs; ! 64: struct FTAMindication ftis; ! 65: register struct FTAMindication *fti = &ftis; ! 66: ! 67: if (*++vec == NULL) { ! 68: #ifdef BRIDGE ! 69: return NOTOK; ! 70: #else ! 71: if (getline ("host: ", buffer) == NOTOK || str2vec (buffer, vec) < 1) ! 72: return OK; ! 73: #endif ! 74: } ! 75: ! 76: if (host) ! 77: free (host); ! 78: host = strdup (*vec); ! 79: ! 80: if (*++vec == NULL) { ! 81: #ifdef BRIDGE ! 82: return NOTOK; ! 83: #else ! 84: if (user == NULL) ! 85: user = strdup (myuser ? myuser : ""); ! 86: (void) sprintf (prompt, "user (%s:%s): ", host, user); ! 87: if (getline (prompt, buffer) == NOTOK) ! 88: return OK; ! 89: if (str2vec (buffer, vec) < 1) ! 90: *vec = user, user = NULL; ! 91: #endif ! 92: } ! 93: ! 94: if (user) ! 95: free (user); ! 96: user = strdup (*vec); ! 97: ! 98: if (*++vec) { ! 99: if (account) ! 100: free (account); ! 101: #ifdef BRIDGE ! 102: account = (**vec) ? strdup (*vec) : ""; ! 103: #else ! 104: account = strdup (*vec); ! 105: #endif ! 106: } ! 107: ! 108: #ifdef BRIDGE ! 109: if (!strcmp (user, "anonymous") || !strcmp (user, "ANONYMOUS") ){ ! 110: free (user); ! 111: user = strdup ("ANON"); ! 112: } ! 113: #endif ! 114: ! 115: if (strcmp (user, "anon") == 0) { ! 116: free (user); ! 117: user = strdup ("ANON"); ! 118: } ! 119: ! 120: #ifdef BRIDGE ! 121: if (strcmp (user, "ANON") && !*++vec) ! 122: return NOTOK; ! 123: else ! 124: p = *vec ? strdup(*vec) : ""; ! 125: #else ! 126: if (strcmp (user, "ANON")) { ! 127: (void) sprintf (prompt, "password (%s:%s): ", host, user); ! 128: p = getpassword (prompt); ! 129: } ! 130: else ! 131: p = myuser ? myuser : ""; ! 132: #endif ! 133: ! 134: #ifdef BRIDGE ! 135: if ((aei = _str2aei (host, "filestore", "iso ftam", 0)) == NULLAEI) { ! 136: advise (NULLCP, "unable to resolve service: %s", PY_pepy); ! 137: #else ! 138: if ((aei = _str2aei (host, storename, "iso ftam", ontty)) == NULLAEI) { ! 139: advise (NULLCP, "unable to resolve service: %s", PY_pepy); ! 140: #endif ! 141: return NOTOK; ! 142: } ! 143: if ((pa = aei2addr (aei)) == NULLPA) { ! 144: advise (NULLCP, "address translation failed"); ! 145: return NOTOK; ! 146: } ! 147: ! 148: manage = 0; ! 149: fqos = FQOS_NORECOVERY; ! 150: class = FCLASS_TM | FCLASS_TRANSFER | FCLASS_MANAGE; ! 151: units |= FUNIT_READ | FUNIT_WRITE | FUNIT_LIMITED | FUNIT_ENHANCED ! 152: | FUNIT_GROUPING; ! 153: attrs = FATTR_STORAGE; ! 154: fc -> fc_ncontent = 0; ! 155: for (vf = vfs; vf -> vf_entry; vf++) ! 156: if (vf -> vf_oid) ! 157: fc -> fc_contents[fc -> fc_ncontent++].fc_dtn = vf -> vf_oid; ! 158: ! 159: #ifndef BRIDGE ! 160: if (verbose) { ! 161: fprintf (stderr, "%s... ", host); ! 162: (void) fflush (stderr); ! 163: } ! 164: #endif ! 165: if (FInitializeRequest (NULLOID, NULLAEI, aei, NULLPA, pa, manage, class, ! 166: units, attrs, NULLPE, fqos, fc, ! 167: *user ? user : NULL, account, *p ? p : NULL, ! 168: strlen (p), &myqos, trace ? FTraceHook : NULLIFP, ! 169: ftc, fti) ! 170: == NOTOK) { ! 171: #ifndef BRIDGE ! 172: if (verbose) ! 173: fprintf (stderr, "loses big\n"); ! 174: #endif ! 175: ftam_advise (&fti -> fti_abort, "F-INITIALIZE.REQUEST"); ! 176: ! 177: return NOTOK; ! 178: } ! 179: ! 180: switch (ftc -> ftc_state) { ! 181: case FSTATE_SUCCESS: ! 182: #ifndef BRIDGE ! 183: if (verbose) ! 184: fprintf (stderr, "connected\n"); ! 185: #endif ! 186: #ifdef DEBUG ! 187: if (debug) ! 188: advise (NULLCP, ! 189: "responding AE title: %s, responding PSAP address: %s", ! 190: sprintaei (&ftc -> ftc_respondtitle), ! 191: paddr2str (&ftc -> ftc_respondaddr, NULLNA)); ! 192: #endif ! 193: vfs_bound = ftc -> ftc_respondaddr; /* struct copy */ ! 194: ! 195: ftamfd = ftc -> ftc_sd; ! 196: context = ftc -> ftc_context, ftc -> ftc_context = NULLOID; ! 197: fqos = ftc -> ftc_fqos; ! 198: class = ftc -> ftc_class; ! 199: units = ftc -> ftc_units; ! 200: attrs = ftc -> ftc_attrs; ! 201: ! 202: for (fx = ftc -> ftc_contents.fc_contents, ! 203: i = ftc -> ftc_contents.fc_ncontent - 1; ! 204: i >= 0; ! 205: fx++, i--) { ! 206: if (fx -> fc_result != PC_ACCEPT) ! 207: continue; ! 208: ! 209: for (vf = vfs; vf -> vf_entry; vf++) ! 210: if (oid_cmp (vf -> vf_oid, fx -> fc_dtn) == 0) { ! 211: vf -> vf_flags |= VF_OK; ! 212: vf -> vf_id = fx -> fc_id; ! 213: break; ! 214: } ! 215: } ! 216: for (vf = vfs; vf -> vf_entry; vf++) ! 217: if (vf -> vf_oid ! 218: && !(vf -> vf_flags & VF_OK) ! 219: && (vf -> vf_flags & VF_WARN)) ! 220: advise (NULLCP, ! 221: "warning: virtual filestore has no support for %ss", ! 222: vf -> vf_text); ! 223: ! 224: vf = &vfs[VFS_UBF]; ! 225: if (vf -> vf_oid == NULLOID || !(vf -> vf_flags & VF_OK)) ! 226: advise (NULLCP, ! 227: "%s files not negotiated, suggest you quit now!", ! 228: vf -> vf_entry); ! 229: ! 230: if ((vf = &vfs[tmode]) != &vfs[VFS_DEF] ! 231: && (vf -> vf_oid == NULLOID ! 232: || !(vf -> vf_flags & VF_OK))) { ! 233: advise (NULLCP, "negotiation prevents transfer of %ss", ! 234: vf -> vf_text); ! 235: ! 236: tmode = VFS_DEF; ! 237: } ! 238: ! 239: for (vf = vfs; vf -> vf_entry; vf++) /* prime the pump */ ! 240: if (vf -> vf_peek) ! 241: (void) (*vf -> vf_peek) (vf, NOTOK, NULLCP, ! 242: (struct stat *) 0, ftamfd); ! 243: ! 244: if ((fadusize = ftc -> ftc_ssdusize) < 0) ! 245: fadusize = 0; ! 246: break; ! 247: ! 248: default: ! 249: #ifndef BRIDGE ! 250: if (verbose) ! 251: fprintf (stderr, "failed\n"); ! 252: #endif ! 253: break; ! 254: } ! 255: ftam_diag (ftc -> ftc_diags, ftc -> ftc_ndiag, ! 256: ftamfd != NOTOK || fti -> fti_abort.fta_peer, ! 257: ftc -> ftc_action); ! 258: ! 259: FTCFREE (ftc); ! 260: ! 261: if (ftamfd != NOTOK) { ! 262: vec[0] = "sd"; ! 263: vec[1] = NULLCP; ! 264: ! 265: (void) f_cd (vec); ! 266: } ! 267: ! 268: return (ftamfd != NOTOK ? OK : NOTOK); ! 269: } ! 270: ! 271: /* */ ! 272: ! 273: /* ARGSUSED */ ! 274: ! 275: int f_close (vec) ! 276: char **vec; ! 277: { ! 278: struct FTAMrelease ftrs; ! 279: register struct FTAMrelease *ftr = &ftrs; ! 280: struct FTAMindication ftis; ! 281: register struct FTAMindication *fti = &ftis; ! 282: ! 283: #ifdef BRIDGE ! 284: if (ftamfd == NOTOK) ! 285: return OK; ! 286: #endif ! 287: ! 288: if (FTerminateRequest (ftamfd, NULLPE, ftr, fti) == NOTOK) { ! 289: ftam_advise (&fti -> fti_abort, "F-TERMINATE.REQUEST"); ! 290: ! 291: (void) FUAbortRequest (ftamfd, FACTION_PERM, ! 292: (struct FTAMdiagnostic *) 0, 0, &ftis); ! 293: ftamfd = NOTOK; ! 294: ! 295: return NOTOK; ! 296: } ! 297: ! 298: ftam_chrg (&ftr -> ftr_charges); ! 299: ! 300: FTRFREE (ftr); ! 301: ! 302: ftamfd = NOTOK; ! 303: if (rcwd) { ! 304: free (rcwd); ! 305: rcwd = NULL; ! 306: } ! 307: ! 308: return OK; ! 309: } ! 310: ! 311: /* */ ! 312: ! 313: int f_quit (vec) ! 314: char **vec; ! 315: { ! 316: if (ftamfd != NOTOK) ! 317: (void) f_close (vec); ! 318: ! 319: return DONE; ! 320: } ! 321: ! 322: /* */ ! 323: ! 324: #define AMASK "\020\01STORAGE\02SECURITY\03PRIVATE" ! 325: ! 326: ! 327: /* ARGSUSED */ ! 328: ! 329: #ifndef BRIDGE ! 330: int f_status (vec) ! 331: char **vec; ! 332: { ! 333: int hit; ! 334: register struct vfsmap *vf; ! 335: ! 336: printf ("associated with virtual filestore on \"%s\"\n at %s\n", ! 337: host, pa2str (&vfs_bound)); ! 338: printf (" as user \"%s\"", user); ! 339: if (account) ! 340: printf (" using account \"%s\"", account); ! 341: printf ("\n"); ! 342: ! 343: printf ("application-context: %s\nservice class: ", oid2ode (context)); ! 344: switch (class) { ! 345: case FCLASS_TRANSFER: ! 346: printf ("transfer"); ! 347: break; ! 348: ! 349: case FCLASS_ACCESS: ! 350: printf ("access"); ! 351: break; ! 352: ! 353: case FCLASS_MANAGE: ! 354: printf ("management"); ! 355: break; ! 356: ! 357: case FCLASS_TM: ! 358: printf ("transfer-and-management"); ! 359: break; ! 360: ! 361: case FCLASS_UNCONS: ! 362: printf ("unconstrained"); ! 363: break; ! 364: ! 365: default: ! 366: printf ("%d", class); ! 367: } ! 368: printf (", ftam-QoS: "); ! 369: switch (fqos) { ! 370: case FQOS_NORECOVERY: ! 371: printf ("no-recovery"); ! 372: break; ! 373: ! 374: default: ! 375: printf ("class-%d-recovery", fqos); ! 376: break; ! 377: } ! 378: ! 379: printf ("\nfunctional units: %s\n", sprintb (units, UMASK)); ! 380: ! 381: printf ("attribute groups: %s\n", sprintb (attrs, AMASK)); ! 382: ! 383: printf ("document types:"); ! 384: hit = 0; ! 385: for (vf = vfs; vf -> vf_entry; vf++) ! 386: if (vf -> vf_oid && (vf -> vf_flags & VF_OK)) { ! 387: printf ("\n %-16.16s %s (%s)", sprintoid (vf -> vf_oid), ! 388: vf -> vf_text, vf -> vf_entry); ! 389: hit = 1; ! 390: } ! 391: if (!hit) ! 392: printf (" none negotiated!"); ! 393: ! 394: printf ("\nestimated integral FADU size: %d\n", fadusize); ! 395: ! 396: return OK; ! 397: } ! 398: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.