|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 9407 (0x24bf) Types: TextFile Names: »minitialise.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« └─⟦d846658bd⟧ └─⟦this⟧ »osimis/msap/minitialise.c«
/* * Copyright (c) 1988 University College London * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Department of Computer Science, University College London. * The name of the University may not be used to * endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* Routines to establish a management association */ /* * By George Pavlou, April 1990 */ #include <stdio.h> #include "isode/rosap.h" #include "msap.h" static void M_Fail (); /* LINTLIBRARY */ /* M_InitialiseReq - Calling is equivalent to a M-Initialise.Request * a succesful return is equivalent to a M-Initialise.Confirm */ int M_InitialiseReq (CallingTitle, CallingAddr, CalledTitle, CalledAddr, context, protvrsn, fununits, access, info, mc, mi) AEI CallingTitle, CalledTitle; char * context; struct PSAPaddr * CallingAddr, * CalledAddr; int protvrsn, fununits; External * access, * info; struct MSAPconnect * mc; struct MSAPindication * mi; { struct AcSAPconnect accs; struct AcSAPindication acis; struct PSAPctxlist pctx; OID ctx; struct SSAPref sfs, * sf; struct RoSAPindication rois; struct MSAPassocinfo mcis; PE pe; if ((ctx = ode2oid(context)) == NULLOID) { mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = MA_LOCAL; mi->mi_abort.ma_reason = ACS_ADDRESS; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, "Can't find Context", MA_SIZE); return NOTOK; } if ((ctx = oid_cpy(ctx)) == NULLOID) goto no_mem; pctx.pc_nctx = 1; pctx.pc_ctx[0].pc_id = 1; pctx.pc_ctx[0].pc_atn = NULLOID; if ((pctx.pc_ctx[0].pc_asn = oid_cpy(str2oid("2.9.1.1.4"))) == NULLOID) goto no_mem; if ((sf = addr2ref(PLocalHostName())) == NULL) { sf = &sfs; (void) bzero((char*) sf, sizeof *sf); } mcis.mai_protvrsn = protvrsn; mcis.mai_funits = fununits; mcis.mai_access = access; mcis.mai_info = info; if (build_CMIPAssoc_CMIPUserInfo(&pe, 1, 0, NULLCP, &mcis) == NOTOK) goto no_mem; pe -> pe_context = 1; if (AcAssocRequest(ctx, CallingTitle, CalledTitle, CallingAddr, CalledAddr, &pctx, pctx.pc_ctx[0].pc_asn, 0, ROS_MYREQUIRE, SERIAL_NONE, 0, sf, &pe, 1, NULLQOS, &accs, &acis ) == NOTOK) { mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = acis.aci_abort.aca_source == ACA_LOCAL ? MA_LOCAL : MA_PROVIDER; mi->mi_abort.ma_reason = acis.aci_abort.aca_reason; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, acis.aci_abort.aca_data, MA_SIZE); pe_free(pe); ACAFREE(&acis.aci_abort); return NOTOK; } oid_free(ctx); oid_free(pctx.pc_ctx[0].pc_asn); pe_free(pe); if (accs.acc_result != ACS_ACCEPT) { mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = acis.aci_abort.aca_source == ACA_LOCAL ? MA_LOCAL : MA_PROVIDER; mi->mi_abort.ma_reason = ACS_REJECT; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, "Association Rejected by Peer", MA_SIZE); return NOTOK; } if (accs.acc_ninfo != 1) { M_Fail(accs.acc_sd, MA_BADINFO, "No User Info", NULLEXTERN, mi); return NOTOK; } mc -> mc_info.mai_protvrsn = mc -> mc_info.mai_funits = 0; mc -> mc_info.mai_access = mc -> mc_info.mai_info = NULL; if (parse_CMIPAssoc_CMIPUserInfo(accs.acc_info[0], 0, NULLINTP, NULLVP, &mc -> mc_info) == NOTOK) { M_Fail(accs.acc_sd, MA_BADINFO, "Malformed User Info", NULLEXTERN, mi); return NOTOK; } pe_free(accs.acc_info[0]); if (RoSetService(accs.acc_sd, RoPService, &rois) == NOTOK) { M_Fail(accs.acc_sd, MA_ROS, "Can't Set Service", NULLEXTERN, mi); return NOTOK; } mc -> mc_sd = accs.acc_sd; mc->mc_result = accs.acc_result; mc -> mc_resptitle = accs.acc_respondtitle; /* struct copy */ mc -> mc_context = accs.acc_context; accs.acc_context = NULLOID; ACCFREE(&accs); return OK; no_mem: ; /* comes here if it cannot form MPDU */ mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = MA_LOCAL; mi->mi_abort.ma_reason = ACS_CONGEST; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, "Out of Memory", MA_SIZE); return NOTOK; } /* M_Init - Called when program invoked to recapture context. * A successful return is equivalent to a M-Initialise.indication */ /* ARGSUSED */ int M_Init (vecp, vec, ms, mi) int vecp; char ** vec; struct MSAPindication * mi; struct MSAPstart * ms; { struct AcSAPstart acss; struct AcSAPindication acis; if (AcInit(vecp, vec, &acss, &acis) == NOTOK) { mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = acis.aci_abort.aca_source == ACA_LOCAL ? MA_LOCAL : MA_PROVIDER; mi->mi_abort.ma_reason = acis.aci_abort.aca_reason; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, acis.aci_abort.aca_data, MA_SIZE); ACAFREE(&acis.aci_abort); return NOTOK; } if (oid_cmp(acss.acs_start.ps_ctxlist.pc_ctx[0].pc_asn, str2oid("2.9.1.1.4")) != 0) { M_Fail(acss.acs_sd, MA_BADPCTX, "Bad Presentation Context", NULLEXTERN, mi); return NOTOK; } if (acss.acs_ninfo != 1) { M_Fail(acss.acs_sd, MA_BADINFO, "No User Info", NULLEXTERN, mi); return NOTOK; } ms -> ms_info.mai_protvrsn = ms -> ms_info.mai_funits = 0; ms -> ms_info.mai_access = ms -> ms_info.mai_info = NULL; if (parse_CMIPAssoc_CMIPUserInfo(acss.acs_info[0], 0, NULLINTP, NULLVP, &ms -> ms_info) == NOTOK) { pe_free(acss.acs_info[0]); M_Fail(acss.acs_sd, MA_BADINFO, "Malformed User Info", NULLEXTERN, mi); return NOTOK; } if ((ms -> ms_info.mai_protvrsn & (1 << 0)) == 0) { if (AcAssocResponse(acss.acs_sd, ACS_PERMANENT, ACS_USER_NOREASON, NULLOID, NULLAEI, &acss.acs_start.ps_called, NULLPC, acss.acs_start.ps_defctxresult, acss.acs_start.ps_prequirements, ROS_MYREQUIRE, SERIAL_NONE, acss.acs_start.ps_settings, &acss.acs_start.ps_connect, NULLPEP, 0, &acis) == NOTOK ) { fprintf(stderr, "AcAssocResponse failed: %d\n", acis.aci_abort.aca_reason); } mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = MA_PROVIDER; mi->mi_abort.ma_reason = MA_NOVRSN; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, "No Common CMIP Version", MA_SIZE); return NOTOK; } ms -> ms_sd = acss.acs_sd; ms -> ms_calling = acss.acs_callingtitle; /* struct copy */ ms -> ms_called = acss.acs_calledtitle; /* .. */ ms -> ms_start = acss.acs_start; /* .. */ ms -> ms_context = acss.acs_context; acss.acs_context = NULLOID; ACSFREE(&acss); return OK; } /* M_InitialiseResp - Respond to a connection request, * equivalent to M-Initialise.Response */ /* ARGSUSED */ int M_InitialiseResp (ms, status, resptitle, respaddr, context, protvrsn, fununits, access, info, mi) struct MSAPstart * ms; int status; AEI resptitle; struct PSAPaddr * respaddr; OID context; int protvrsn, fununits; External * access, * info; struct MSAPindication * mi; { struct AcSAPindication acis; struct RoSAPindication rois; struct MSAPassocinfo mcis; PE pe; mcis.mai_protvrsn = protvrsn; mcis.mai_funits = fununits; mcis.mai_access = access; mcis.mai_info = info; if (build_CMIPAssoc_CMIPUserInfo(&pe, 1, 0, NULLCP, &mcis) == NOTOK) { M_Fail(ms->ms_sd, ACS_CONGEST, "Out of Memory", NULLEXTERN, mi); return NOTOK; } pe -> pe_context = 1; if (AcAssocResponse(ms->ms_sd, status, status != ACS_ACCEPT ? ACS_USER_NOREASON : ACS_USER_NULL, context, resptitle, respaddr, NULLPC, ms->ms_start.ps_defctxresult, ms->ms_start.ps_prequirements, ROS_MYREQUIRE, SERIAL_NONE, ms->ms_start.ps_settings, &ms->ms_start.ps_connect, &pe, 1, &acis) == NOTOK ) { mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = acis.aci_abort.aca_source == ACA_LOCAL ? MA_LOCAL : MA_PROVIDER; mi->mi_abort.ma_reason = acis.aci_abort.aca_reason; mi->mi_abort.ma_info = NULL; (void) strncpy(mi->mi_abort.ma_data, acis.aci_abort.aca_data, MA_SIZE); pe_free(pe); ACAFREE(&acis.aci_abort); return NOTOK; } pe_free(pe); if (status == M_ACCEPT && RoSetService(ms->ms_sd, RoPService, &rois) == NOTOK) { M_Fail(ms->ms_sd, MA_ROS, "Can't Set Service", NULLEXTERN, mi); return NOTOK; } return OK; } /* M_Fail - abort an association while being established due to fatal error */ /* ARGSUSED */ static void M_Fail (msd, code, expl, info, mi) int msd, code; char * expl; External * info; struct MSAPindication * mi; { struct AcSAPindication acis; struct MSAPabort mas; PE pe; mas.ma_info = info; mas.ma_source = MA_PROVIDER; (void) build_CMIPAbort_CMIPAbortInfo(&pe, 1, 0, NULLCP, &mas); pe -> pe_context = 1; (void) AcUAbortRequest(msd, &pe, 1, &acis); pe_free(pe); mi->mi_type = MI_ABORT; mi->mi_abort.ma_source = MA_PROVIDER; mi->mi_abort.ma_reason = code; (void) strncpy(mi->mi_abort.ma_data, expl, MA_SIZE); }