DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T o

⟦39631ffdc⟧ TextFile

    Length: 41593 (0xa279)
    Types: TextFile
    Names: »objects.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« 
        └─⟦d846658bd⟧ 
            └─⟦this⟧ »osimis/sma/objects.c« 

TextFile

/*
 * 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.
 */

/* objects.c - the managed object class specific routines */

/*
 * By Simon Walton, October 1988
 * Modified by George Pavlou, April 1990
 */

#include <stdio.h>
#include "isode/rosap.h"
#include "msap.h"
#include "objects.h"


extern char * calloc();
extern time_t time();
extern OID oid_copy();
extern struct ManagedObject * findcomp(), * forccomp();
extern struct MO_ID * moid_alloc();
extern struct MO_ID * moid_cpy();
int init_X();
int del_X();
int init_ManagedSystem();
int del_ManagedSystem();
CMISerrors Get_ManagedSystem();
CMISerrors Set_ManagedSystem();
CMISerrors Add_ManagedSystem();
CMISerrors Remove_ManagedSystem();
int init_T_LayerSubsystem();
int del_T_LayerSubsystem();
int init_T_LayerEntity();
int del_T_LayerEntity();
CMISerrors Get_T_LayerEntity();
CMISerrors Set_T_LayerEntity();
CMISerrors Add_T_LayerEntity();
CMISerrors Remove_T_LayerEntity();
int init_T_EntityInvocation();
int del_T_EntityInvocation();
CMISerrors Get_T_EntityInvocation();
CMISerrors Set_T_EntityInvocation();
CMISerrors Add_T_EntityInvocation();
CMISerrors Remove_T_EntityInvocation();
int init_T_ConnectionEndpoint();
int del_T_ConnectionEndpoint();
CMISerrors Get_T_ConnectionEndpoint();
CMISerrors Set_T_ConnectionEndpoint();
CMISerrors Add_T_ConnectionEndpoint();
CMISerrors Remove_T_ConnectionEndpoint();
int init_C_Threshold();
int del_C_Threshold();
CMISerrors Get_C_Threshold();
CMISerrors Set_C_Threshold();
int init_G_Threshold();
int del_G_Threshold();
CMISerrors Get_G_Threshold();
CMISerrors Set_G_Threshold();
int init_ReportControl();
int del_ReportControl();
CMISerrors Get_ReportControl();
CMISerrors Add_ReportControl();
CMISerrors Remove_ReportControl();
int Make_Report1();
int Make_Report2();
int Make_Report3();
int Make_Report4();
void DefinedEvent_free();


struct MO_init_info
    {
    char * typeidstring;
    OID typeid;
    IFP initfunc;
    IFP delfunc;
    } MO_init_tab[]
    =
    {
    "2.37.1.2", NULLOID, init_X, del_X,
    "2.37.1.1.1", NULLOID, init_ManagedSystem, del_ManagedSystem,
    "2.37.1.2.1", NULLOID, init_T_LayerSubsystem, del_T_LayerSubsystem,
    "2.37.1.3.1", NULLOID, init_T_LayerEntity, del_T_LayerEntity,
    "2.37.1.4.1", NULLOID, init_T_EntityInvocation, del_T_EntityInvocation,
    "2.37.1.5.1", NULLOID, init_T_ConnectionEndpoint, del_T_ConnectionEndpoint,
    "2.37.3.1.1", NULLOID, init_C_Threshold, del_C_Threshold,
    "2.37.3.2.1", NULLOID, init_G_Threshold, del_G_Threshold,
    "2.37.3.3.1", NULLOID, init_ReportControl, del_ReportControl,
    NULLCP, NULLOID, NULLIFP, NULLIFP
    };

fill_MO_init()
{
register struct MO_init_info * p = MO_init_tab;
for (; p -> typeidstring != NULLCP; p++)
    p -> typeid = oid_cpy(str2oid(p -> typeidstring));
}

int (*idtype2moinit(idtype))()
OID idtype;
{
register struct MO_init_info * p = MO_init_tab;
for (; p -> typeidstring != NULLCP; p++)
    if (oid_cmp(p -> typeid, idtype) == 0) return (p -> initfunc);
return (NULLIFP);
}

int (*idtype2model(idtype))()
OID idtype;
{
register struct MO_init_info * p = MO_init_tab;
for (; p -> typeidstring != NULLCP; p++)
    if (oid_cmp(p -> typeid, idtype) == 0) return (p -> delfunc);
return (NULLIFP);
}

static C_Threshold * create_C_Threshold(mo, name)
struct ManagedObject * mo;
char * name;
{
static struct MO_ID threshid;
struct ManagedObject * newthresh;
if (threshid.rdntype.oid_nelem == 0)
    {
    if (oid_copy(str2oid("2.37.3.1.1"), &threshid.rdntype) == NULLOID)
	return (NULL);
    threshid.rdnval[0] = 1;
    }
strncpy(threshid.rdnval+1, name, 9);
threshid.rdnlen = strlen(name) + 1;
if ( (newthresh = forccomp(mo, &threshid)) == NULL) return (NULL);
return((C_Threshold*) newthresh -> attributes);
}

static G_Threshold * create_G_Threshold(mo, name)
struct ManagedObject * mo;
char * name;
{
static struct MO_ID threshid;
struct ManagedObject * newthresh;
if (threshid.rdntype.oid_nelem == 0)
    {
    if (oid_copy(str2oid("2.37.3.2.1"), &threshid.rdntype) == NULLOID)
	return (NULL);
    threshid.rdnval[0] = 1;
    }
strncpy(threshid.rdnval+1, name, 9);
threshid.rdnlen = strlen(name) + 1;
if ( (newthresh = forccomp(mo, &threshid)) == NULL) return (NULL);
return((G_Threshold*) newthresh -> attributes);
}

static ReportControl * create_ReportControl(mo, name)
struct ManagedObject * mo;
int name;
{
static struct MO_ID rci_id;
struct ManagedObject * newrci;

if (rci_id.rdntype.oid_nelem == 0)
    {
    if (oid_copy(str2oid("2.37.3.3.1"), &rci_id.rdntype) == NULLOID)
	return (NULL);
    rci_id.rdnlen = sizeof (int) + 1;
    }
bcopy((char*) &name, &rci_id.rdnval[1], sizeof (int) );
if ( (newrci = forccomp(mo, &rci_id)) == NULL) return (NULL);
return ((ReportControl*) newrci -> attributes);
}

static init_X(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID;
struct X * p;
if (MyClass == NULLOID) MyClass = oid_cpy(str2oid("2.37.1.1"));
if ( (oid_copy(MyClass, &mo -> Class)) == NULL) return (0);
if ( (p = (struct X*)calloc(1, sizeof(*p)) ) == NULL) return (0);
mo -> attributes = (caddr_t) p;
p -> sheep.Value = 64;
mo -> do_set = mo -> do_get = mo -> do_add = mo -> do_remove
    = mo -> do_action = NULLIFP;
return (1);
}

static del_X(mo)
struct ManagedObject * mo;
{
free(mo -> Class.oid_elements);
free(mo -> attributes);
return (0);
}

static init_ManagedSystem(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID, event1 = NULLOID, event2 = NULLOID;
ManagedSystem * at;
time_t tim;
ReportControl * rep;
struct MO_ID * repname1, * repname2;

if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.1.1")) ) == NULL) return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (ManagedSystem*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);
tim = time((time_t*)0);
tm2ut(localtime(&tim), &at -> systemCreationTime);
if (event1 == NULLOID)
    if ( ( event1 = oid_cpy(str2oid("2.37.2.1")) ) == NULL)
	return (free(at), 0);
if (oid_copy(event1, &at -> systemCreationEvent.eventype) == NULL)
	return (free(at), 0);
if (event2 == NULLOID)
    if ( ( event2 = oid_cpy(str2oid("2.37.2.2")) ) == NULL)
	return (free(at), 0);
if (oid_copy(event2, &at -> systemShutdownEvent.eventype) == NULL)
    return (free(at), 0);
if ( (rep = create_ReportControl(mo, 1)) == NULL)
    return (free(at), 0);
rep -> MakeEventReport = Make_Report1;

if ( (repname2 = moid_alloc("2.37.3.3.1", NULLCP, 1)) == NULL)
    return (free(at), 0);
if ( (repname1 = moid_alloc("2.37.1.1.1", NULLCP, -1)) == NULL)
    return (free(at), 0);
repname1 -> Next = repname2;
#ifdef DEBUG
fprintf(stderr,"Report Control ID:\n");
moid_print(repname1);
#endif
at -> systemCreationEvent.rcis[0] = repname1;
repname1 = moid_cpy(repname1);
at -> systemShutdownEvent.rcis[0] = repname1;
#ifdef DEBUG
fprintf(stderr,"Report Control ID:\n");
moid_print(repname1);
#endif

mo -> do_get = (IFP) Get_ManagedSystem;
mo -> do_set = (IFP) Set_ManagedSystem;
mo -> do_add = (IFP) Add_ManagedSystem;
mo -> do_remove = (IFP) Remove_ManagedSystem;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_ManagedSystem(mo)
struct ManagedObject * mo;
{
struct ManagedSystem * at;
free(mo -> Class.oid_elements);
at = (ManagedSystem*) mo -> attributes;
DefinedEvent_free(&at -> systemCreationEvent);
DefinedEvent_free(&at -> systemShutdownEvent);
free(mo -> attributes);
return (0);
}

static CMISerrors Get_ManagedSystem(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
ManagedSystem * attribs = (ManagedSystem*) mo -> attributes;
switch (id)
{
case 2:
    *res = utct2prim(&attribs -> systemCreationTime);
    break;

case 3:
    if (build_MIB_DefinedEvent(res, 1, 0, NULLCP,
	&attribs->systemCreationEvent) == NOTOK) return (m_processingFailure);
    break;

case 4:
    if (build_MIB_DefinedEvent(res, 1, 0, NULLCP,
	&attribs->systemShutdownEvent) == NOTOK) return (m_processingFailure);
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB GET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);

} /* close switch */
return (m_noError);
}

static CMISerrors Set_ManagedSystem(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
ManagedSystem * attribs = (ManagedSystem*) mo -> attributes;
switch (id)
{
case 2:
#ifdef DEBUG
    fprintf(stderr, "MIB SET: Can't Set attribute: %d\n", id);
#endif
    return (m_invalidOperation);

case 3:
    if (parse_MIB_DefinedEvent(value, 0, NULLIP, NULLVP,
	&attribs -> systemCreationEvent) == NOTOK)
	return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

case 4:
    if (parse_MIB_DefinedEvent(value, 0, NULLIP, NULLVP,
	&attribs -> systemShutdownEvent) == NOTOK)
	return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB SET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);

} /* close switch */
return (m_noError);
}

static CMISerrors Add_ManagedSystem(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
ManagedSystem * attribs = (ManagedSystem*) mo -> attributes;
switch (id)
{
case 2:
#ifdef DEBUG
    fprintf(stderr, "MIB REM: Can't Set attribute: %d\n", id);
#endif
    return (m_invalidOperation);

case 3:
case 4:
    {
    DefinedEvent * Ev;
    int i;
    struct MO_ID * newrci;
    DN newrcidn;
    Ev = (id == 3) ? &attribs -> systemCreationEvent :
	&attribs -> systemShutdownEvent;
    if ( decode_IF_DistinguishedName(value, 0, NULLIP, NULLVP, &newrcidn)
	== NOTOK) return (m_invalidAttributeValue);
    newrci = dn2moid(newrcidn);
    dn_free(newrcidn);
    for(i = 0; i < 3 && Ev -> rcis[i]; i++)
	if (moid_cmp(newrci, Ev -> rcis[i]))
	    {
	    moid_free(newrci);
	    (void) build_MIB_DefinedEvent(res, 1, 0, NULLCP, Ev);
	    return (m_noError);
	    }
    if (i < 3) Ev -> rcis[i] = newrci;
    (void) build_MIB_DefinedEvent(res, 1, 0, NULLCP, Ev);
    }
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB ADD: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);

} /* close switch */
return (m_noError);
}

static CMISerrors Remove_ManagedSystem(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
ManagedSystem * attribs = (ManagedSystem*) mo -> attributes;
switch (id)
{
case 2:
#ifdef DEBUG
    fprintf(stderr, "MIB REM: Can't Set attribute: %d\n", id);
#endif
    return (m_invalidOperation);

case 3:
case 4:
    {
    DefinedEvent * Ev;
    int i,f,t;
    struct MO_ID * newrci;
    DN newrcidn;
    Ev = (id == 3) ? &attribs -> systemCreationEvent :
	&attribs -> systemShutdownEvent;
    if ( decode_IF_DistinguishedName(value, 0, NULLIP, NULLVP, &newrcidn)
	== NOTOK) return (m_invalidAttributeValue);
    newrci = dn2moid(newrcidn);
    dn_free(newrcidn);
    for(i = 0; i < 3 && Ev -> rcis[i]; i++)
	if (moid_cmp(newrci, Ev -> rcis[i]))
	    {
	    moid_free(Ev -> rcis[i]);
	    Ev -> rcis[i] = NULL;
	    moid_free(newrci);
	    break;
	    }
    for(f = t = 0; f < 3; f++)
	if (Ev -> rcis[f])
	    {
	    Ev -> rcis[t] = Ev -> rcis[f];
	    if ( f != t++ ) Ev -> rcis[f] = NULL;
	    }

    (void) build_MIB_DefinedEvent(res, 1, 0, NULLCP, Ev);
    }
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB REM: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);

} /* close switch */
return (m_noError);
}


static init_T_LayerSubsystem(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID;
T_LayerSubsystem * at;

if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.1.2")) ) == NULL) return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (T_LayerSubsystem*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);

mo -> do_get = mo -> do_set =
    mo -> do_add = mo -> do_remove = mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_T_LayerSubsystem(mo)
struct ManagedObject * mo;
{
free(mo -> Class.oid_elements);
free(mo -> attributes);
return (0);
}

static init_T_LayerEntity(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID;
T_LayerEntity * at;
ReportControl * rep;

if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.1.3")) ) == NULL) return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (T_LayerEntity*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);

if ( (rep = create_ReportControl(mo, 2)) == NULL)
	return(free(at), 0);
rep -> MakeEventReport = Make_Report2;
if ( (rep = create_ReportControl(mo, 3)) == NULL)
	return(free(at), 0);
rep -> MakeEventReport = Make_Report3;
if ( (rep = create_ReportControl(mo, 4)) == NULL)
	return(free(at), 0);
rep -> MakeEventReport = Make_Report4;

mo -> do_get = (IFP) Get_T_LayerEntity;
mo -> do_set = NULLIFP;
mo -> do_add = NULLIFP;
mo -> do_remove = NULLIFP;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_T_LayerEntity(mo)
struct ManagedObject * mo;
{
struct T_LayerEntity * at;
struct TSAPaddr ** t;
free(mo -> Class.oid_elements);
at = (T_LayerEntity*) mo -> attributes;
for(t = at -> supportedTSAPs; t < &at -> supportedTSAPs[TLE_MAXTSAPS]; t++)
    if (*t) free(*t);
if (at -> boundNSAP) free(at -> boundNSAP);
free(at);
return (0);
}

static CMISerrors Get_T_LayerEntity(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
T_LayerEntity * attribs = (T_LayerEntity*) mo -> attributes;
Counter * c = NULL;
Gauge * g = NULL;
switch (id)
{
case 2:
    if (build_MIB_NAddress(res, 1, 0, NULLCP, attribs -> boundNSAP)
	== NOTOK) return (m_processingFailure);
    break;

case 3:
    if (build_MIB_TAddressList(res, 1, TLE_MAXTSAPS, NULLCP,
	attribs -> supportedTSAPs)
	== NOTOK) return (m_processingFailure);
    break;

case 4: g = &attribs -> activeEntityInvocations; break;
case 5: g = &attribs -> activeConnections; break;
case 6: c = &attribs -> previousConnections; break;
case 7: c = &attribs -> crTPDUSuccessfulIn; break;
case 8: c = &attribs -> crTPDUSuccessfulOut; break;
case 9: c = &attribs -> crTPDUUnsuccessfulIn; break;
case 10: c = &attribs -> crTPDUUnsuccessfulOut; break;
case 11: c = &attribs -> crTPDUCongestion; break;
case 12: c = &attribs -> crTPDUConfigurationError; break;
case 13: c = &attribs -> tProtocolError; break;
case 14: c = &attribs -> tPDUChecksumError; break;
case 15: c = &attribs -> numberTPDUSent; break;
case 16: c = &attribs -> numberTPDUReceived; break;
case 17: c = &attribs -> numberTPDURetransmitted; break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB GET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */

if (g)
    if (build_MIB_Gauge(res, 1, 0, NULLCP, g) == NOTOK)
	return (m_processingFailure);
if (c)
    if (build_MIB_Counter(res, 1, 0, NULLCP, c) == NOTOK)
	return (m_processingFailure);
return (m_noError);
}


static init_T_EntityInvocation(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID, event1 = NULLOID, event2 = NULLOID,
event3 = NULLOID, event4 = NULLOID, event5 = NULLOID, event6 = NULLOID,
event7 = NULLOID, event8 = NULLOID;
time_t tim;
T_EntityInvocation * at;
C_Threshold * thresh;
static struct MO_ID * repname1, * repname2, * repname3, * repname4;

if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.1.4")) ) == NULL) return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (T_EntityInvocation*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);
tim = time((time_t*)0);
tm2ut(localtime(&tim), &at -> creationTime);
if (event8 == NULLOID)
    if ( (event1 = oid_cpy(str2oid("2.37.2.3")) ) == NULLOID ||
	 (event2 = oid_cpy(str2oid("2.37.2.4")) ) == NULLOID ||
	 (event3 = oid_cpy(str2oid("2.37.2.5")) ) == NULLOID ||
	 (event4 = oid_cpy(str2oid("2.37.2.6")) ) == NULLOID ||
	 (event5 = oid_cpy(str2oid("2.37.2.7")) ) == NULLOID ||
	 (event6 = oid_cpy(str2oid("2.37.2.8")) ) == NULLOID ||
	 (event7 = oid_cpy(str2oid("2.37.2.9")) ) == NULLOID ||
	 (event8 = oid_cpy(str2oid("2.37.2.10")) ) == NULLOID )
	    return (free(at), 0);

if (oid_copy(event1, &at -> crTPDUUnsuccessInThldEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event2, &at -> crTPDUUnsuccessOutThldEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event3, &at -> crTPDUCongestionThldEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event4, &at -> crTPDUConfigErrorThldEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event5, &at -> tProtocolErrorThldEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event6, &at -> tPDUChecksumErrorThldEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event7, &at -> tEntinvCreationEvent.eventype) == NULL)
	return (free(at), 0);
if (oid_copy(event8, &at -> tEntinvShutdownEvent.eventype) == NULL)
	return (free(at), 0);

if ( (thresh = create_C_Threshold(mo, "CrFailIn")) == NULL)
	return (free(at), 0);
at -> crTPDUUnsuccessfulIn.Threshold = thresh;
thresh -> triggers[0] = &at -> crTPDUUnsuccessInThldEvent;
if ( (thresh = create_C_Threshold(mo, "CrFailOut")) == NULL)
	return (free(at), 0);
at -> crTPDUUnsuccessfulOut.Threshold = thresh;
thresh -> triggers[0] = &at -> crTPDUUnsuccessOutThldEvent;
if ( (thresh = create_C_Threshold(mo, "CrCongst")) == NULL)
	return (free(at), 0);
at -> crTPDUCongestion.Threshold = thresh;
thresh -> triggers[0] = &at -> crTPDUCongestionThldEvent;
if ( (thresh = create_C_Threshold(mo, "CrConfErr")) == NULL)
	return (free(at), 0);
at -> crTPDUConfigurationError.Threshold = thresh;
thresh -> triggers[0] = &at -> crTPDUConfigErrorThldEvent;
if ( (thresh = create_C_Threshold(mo, "ProtErr")) == NULL)
	return (free(at), 0);
at -> tProtocolError.Threshold = thresh;
thresh -> triggers[0] = &at -> tProtocolErrorThldEvent;
if ( (thresh = create_C_Threshold(mo, "CkSumErr")) == NULL)
	return (free(at), 0);
at -> tPDUChecksumError.Threshold = thresh;
thresh -> triggers[0] = &at -> tPDUChecksumErrorThldEvent;


if (repname1 == NULL)
    {
    if ( (repname4 = moid_alloc("2.37.3.3.1", NULLCP, 2)) == NULL)
	return (free(at), 0);
    if ( (repname3 = moid_alloc("2.37.1.3.1", "isode")) == NULL)
	return (free(at), 0);
    repname3 -> Next = repname4;
    if ( (repname2 = moid_alloc("2.37.1.2.1", NULLCP, -1)) == NULL)
	return (free(at), 0);
    repname2 -> Next = repname3;
    if ( (repname1 = moid_alloc("2.37.1.1.1", NULLCP, -1)) == NULL)
	return (free(at), 0);
    repname1 -> Next = repname2;
    }

if ( (at -> tEntinvCreationEvent.rcis[0] = moid_cpy(repname1)) == NULL )
    return (free(at), 0);
if ( (at -> tEntinvShutdownEvent.rcis[0] = moid_cpy(repname1)) == NULL )
    return (free(at), 0);
if ( (at -> crTPDUUnsuccessInThldEvent.rcis[0] = moid_cpy(repname1)) == NULL )
    return (free(at), 0);
if ( (at -> crTPDUUnsuccessOutThldEvent.rcis[0] = moid_cpy(repname1)) ==NULL )
    return (free(at), 0);
if ( (at -> crTPDUConfigErrorThldEvent.rcis[0] = moid_cpy(repname1)) == NULL )
    return (free(at), 0);
if ( (at -> tProtocolErrorThldEvent.rcis[0] = moid_cpy(repname1)) == NULL )
    return (free(at), 0);
if ( (at -> tPDUChecksumErrorThldEvent.rcis[0] = moid_cpy(repname1)) == NULL )
    return (free(at), 0);

#ifdef DEBUG
fprintf(stderr,"Report Control ID:\n");
moid_print(repname1);
#endif

mo -> do_get = (IFP) Get_T_EntityInvocation;
mo -> do_set = (IFP) Set_T_EntityInvocation;
mo -> do_add = (IFP) Add_T_EntityInvocation;
mo -> do_remove = (IFP) Remove_T_EntityInvocation;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}


static del_T_EntityInvocation(mo)
struct ManagedObject * mo;
{
struct T_EntityInvocation * at;
free(mo -> Class.oid_elements);
at = (T_EntityInvocation*) mo -> attributes;
DefinedEvent_free(&at -> crTPDUUnsuccessInThldEvent);
DefinedEvent_free(&at -> crTPDUUnsuccessOutThldEvent);
DefinedEvent_free(&at -> crTPDUCongestionThldEvent);
DefinedEvent_free(&at -> crTPDUConfigErrorThldEvent);
DefinedEvent_free(&at -> tProtocolErrorThldEvent);
DefinedEvent_free(&at -> tPDUChecksumErrorThldEvent);
DefinedEvent_free(&at -> tEntinvCreationEvent);
DefinedEvent_free(&at -> tEntinvShutdownEvent);
free(at);
return (0);
}

static CMISerrors Get_T_EntityInvocation(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
T_EntityInvocation * attribs = (T_EntityInvocation*) mo -> attributes;
Counter * c = NULL;
Gauge * g = NULL;
DefinedEvent * e = NULL;
switch (id)
{
case 2:
    *res = utct2prim(&attribs -> creationTime);
    break;

case 3: g = &attribs -> activeConnections; break;
case 4: c = &attribs -> crTPDUSuccessfulIn; break;
case 5: c = &attribs -> crTPDUSuccessfulOut; break;
case 6: c = &attribs -> crTPDUUnsuccessfulIn; break;
case 7: c = &attribs -> crTPDUUnsuccessfulOut; break;
case 8: c = &attribs -> crTPDUCongestion; break;
case 9: c = &attribs -> crTPDUConfigurationError; break;
case 10: c = &attribs -> tProtocolError; break;
case 11: c = &attribs -> tPDUChecksumError; break;
case 12: e = &attribs -> crTPDUUnsuccessInThldEvent; break;
case 13: e = &attribs -> crTPDUUnsuccessOutThldEvent; break;
case 14: e = &attribs -> crTPDUCongestionThldEvent; break;
case 15: e = &attribs -> crTPDUConfigErrorThldEvent; break;
case 16: e = &attribs -> tProtocolErrorThldEvent; break;
case 17: e = &attribs -> tPDUChecksumErrorThldEvent; break;
case 18: e = &attribs -> tEntinvCreationEvent; break;
case 19: e = &attribs -> tEntinvShutdownEvent; break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB GET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */

if (g)
    if (build_MIB_Gauge(res, 1, 0, NULLCP, g) == NOTOK)
	return (m_processingFailure);
if (c)
    if (build_MIB_Counter(res, 1, 0, NULLCP, c) == NOTOK)
	return (m_processingFailure);
if (e)
    if (build_MIB_DefinedEvent(res, 1, 0, NULLCP, e) == NOTOK)
	return (m_processingFailure);
return (m_noError);
}

static CMISerrors Set_T_EntityInvocation(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
T_EntityInvocation * attribs = (T_EntityInvocation*) mo -> attributes;
DefinedEvent * e = NULL;
if (id >= 2 && id <=11)
    {
#ifdef DEBUG
    fprintf(stderr, "MIB SET: Can't Set attribute: %d\n", id);
#endif
    return (m_invalidOperation);
    }
switch(id)
{
case 12: e = &attribs -> crTPDUUnsuccessInThldEvent; break;
case 13: e = &attribs -> crTPDUUnsuccessOutThldEvent; break;
case 14: e = &attribs -> crTPDUCongestionThldEvent; break;
case 15: e = &attribs -> crTPDUConfigErrorThldEvent; break;
case 16: e = &attribs -> tProtocolErrorThldEvent; break;
case 17: e = &attribs -> tPDUChecksumErrorThldEvent; break;
case 18: e = &attribs -> tEntinvCreationEvent; break;
case 19: e = &attribs -> tEntinvShutdownEvent; break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB SET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */

if (e)
    {
    if (parse_MIB_DefinedEvent(value, 0, NULLIP, NULLVP, e)
	== NOTOK) return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    }
return (m_noError);
}

static CMISerrors Add_T_EntityInvocation(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
T_EntityInvocation * attribs = (T_EntityInvocation*) mo -> attributes;
DefinedEvent * e = NULL;
struct MO_ID * newrci;
DN newrcidn;
int i;
if (id >= 2 && id <=11)
    {
#ifdef DEBUG
    fprintf(stderr, "MIB ADD: Can't Set attribute: %d\n", id);
#endif
    return (m_invalidOperation);
    }
switch(id)
{
case 12: e = &attribs -> crTPDUUnsuccessInThldEvent; break;
case 13: e = &attribs -> crTPDUUnsuccessOutThldEvent; break;
case 14: e = &attribs -> crTPDUCongestionThldEvent; break;
case 15: e = &attribs -> crTPDUConfigErrorThldEvent; break;
case 16: e = &attribs -> tProtocolErrorThldEvent; break;
case 17: e = &attribs -> tPDUChecksumErrorThldEvent; break;
case 18: e = &attribs -> tEntinvCreationEvent; break;
case 19: e = &attribs -> tEntinvShutdownEvent; break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB ADD: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */

if ( decode_IF_DistinguishedName(value, 0, NULLIP, NULLVP, &newrcidn)
    == NOTOK) return (m_invalidAttributeValue);
newrci = dn2moid(newrcidn);
dn_free(newrcidn);
for(i = 0; i < 3 && e -> rcis[i]; i++)
    if (moid_cmp(newrci, e -> rcis[i]))
	{
	moid_free(newrci);
	(void) build_MIB_DefinedEvent(res, 1, 0, NULLCP, e);
	return (m_noError);
	}
if (i < 3) e -> rcis[i] = newrci;
(void) build_MIB_DefinedEvent(res, 1, 0, NULLCP, e);
return (m_noError);
}

static CMISerrors Remove_T_EntityInvocation(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
T_EntityInvocation * attribs = (T_EntityInvocation*) mo -> attributes;
DefinedEvent * e = NULL;
struct MO_ID * newrci;
DN newrcidn;
int i,f,t;
if (id >= 2 && id <=11)
    {
#ifdef DEBUG
    fprintf(stderr, "MIB REM: Can't Set attribute: %d\n", id);
#endif
    return (m_invalidOperation);
    }
switch(id)
{
case 12: e = &attribs -> crTPDUUnsuccessInThldEvent; break;
case 13: e = &attribs -> crTPDUUnsuccessOutThldEvent; break;
case 14: e = &attribs -> crTPDUCongestionThldEvent; break;
case 15: e = &attribs -> crTPDUConfigErrorThldEvent; break;
case 16: e = &attribs -> tProtocolErrorThldEvent; break;
case 17: e = &attribs -> tPDUChecksumErrorThldEvent; break;
case 18: e = &attribs -> tEntinvCreationEvent; break;
case 19: e = &attribs -> tEntinvShutdownEvent; break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB REM: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */

if ( decode_IF_DistinguishedName(value, 0, NULLIP, NULLVP, &newrcidn)
    == NOTOK) return (m_invalidAttributeValue);
newrci = dn2moid(newrcidn);
dn_free(newrcidn);

for(i = 0; i < 3 && e -> rcis[i]; i++)
    if (moid_cmp(newrci, e -> rcis[i]))
	{
	moid_free(e -> rcis[i]);
	e -> rcis[i] = NULL;
	moid_free(newrci);
	break;
	}
for(f = t = 0; f < 3; f++)
    if (e -> rcis[f])
	{
	e -> rcis[t] = e -> rcis[f];
	if ( f != t++ ) e -> rcis[f] = NULL;
	}
(void) build_MIB_DefinedEvent(res, 1, 0, NULLCP, e);
return (m_noError);
}

init_T_ConnectionEndpoint(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID, event1 = NULLOID, event2 = NULLOID,
event3 = NULLOID, event4 = NULLOID, event5 = NULLOID;
time_t tim;
T_ConnectionEndpoint * at;
C_Threshold * thresh;
struct MO_ID * repname1, * repname2, * repname3, * repname4;
static MO_ID * rep3name, * rep4name;
if ( ( at = (T_ConnectionEndpoint*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);
if (MyClass == NULLOID)
    if (
    (MyClass = oid_cpy(str2oid("2.37.1.5")) ) == NULL ||
    (event1 = oid_cpy(str2oid("2.37.2.11")) ) == NULL ||
    (event2 = oid_cpy(str2oid("2.37.2.12")) ) == NULL ||
    (event3 = oid_cpy(str2oid("2.37.2.13")) ) == NULL ||
    (event4 = oid_cpy(str2oid("2.37.2.14")) ) == NULL ||
    (event5 = oid_cpy(str2oid("2.37.2.15")) ) == NULL )
	return (MyClass = NULLOID, 0);
if (
    oid_copy(MyClass, &mo -> Class) == NULLOID ||
    oid_copy(event1, &at -> numberTPDUSentThldEvent.eventype) == NULLOID ||
    oid_copy(event2, &at ->numberTPDUReceivedThldEvent.eventype) == NULLOID ||
    oid_copy(event3, &at -> numberTPDURetransThldEvent.eventype) == NULLOID ||
    oid_copy(event4, &at -> tCeptCreationEvent.eventype) == NULLOID ||
    oid_copy(event5, &at -> tCeptShutdownEvent.eventype) == NULLOID )
	return (free(at), 0);

if ( (thresh = create_C_Threshold(mo, "PDUSent")) == NULL)
	return (free(at), 0);
at -> numberTPDUSent.Threshold = thresh;
thresh -> triggers[0] = &at -> numberTPDUSentThldEvent;
thresh -> comparisonlevel[0] = 10; /* report every 10 PDUS */
thresh -> offset = 10;
thresh -> OnOff = 1;
if ( (thresh = create_C_Threshold(mo, "PDURecvd")) == NULL)
	return (free(at), 0);
at -> numberTPDUReceived.Threshold = thresh;
thresh -> triggers[0] = &at -> numberTPDUReceivedThldEvent;
thresh -> comparisonlevel[0] = 10; /* report every 10 PDUS */
thresh -> offset = 10;
thresh -> OnOff = 1;
if ( (thresh = create_C_Threshold(mo, "PDUReSent")) == NULL)
	return (free(at), 0);
at -> numberTPDURetransmitted.Threshold = thresh;
thresh -> triggers[0] = &at -> numberTPDURetransThldEvent;

if (rep3name == NULL || rep4name == NULL)
    {
    if ( (repname4 = moid_alloc("2.37.3.3.1", NULLCP, 3)) == NULL)
	return (free(at), 0);
    if ( (repname3 = moid_alloc("2.37.1.3.1", "isode")) == NULL)
	return (free(at), 0);
    repname3 -> Next = repname4;
    if ( (repname2 = moid_alloc("2.37.1.2.1", NULLCP, -1)) == NULL)
	return (free(at), 0);
    repname2 -> Next = repname3;
    if ( (repname1 = moid_alloc("2.37.1.1.1", NULLCP, -1)) == NULL)
	return (free(at), 0);
    repname1 -> Next = repname2;
    rep3name = moid_cpy(repname1);
    moid_free(repname4);
    if ( (repname4 = moid_alloc("2.37.3.3.1", NULLCP, 4)) == NULL)
	return (free(at), 0);
    repname3 -> Next = repname4;
    rep4name = repname1;
    }


#ifdef DEBUG
fprintf(stderr,"T-ConEndp - Report Control IDs:\n");
moid_print(rep3name);
fprintf(stderr, "   and\n");
moid_print(rep4name);
#endif

if ( (at -> tCeptCreationEvent.rcis[0] = moid_cpy(rep3name)) == NULL)
    return (free(at), 0);
if ( (at -> tCeptShutdownEvent.rcis[0] = moid_cpy(rep3name)) == NULL)
    return (free(at), 0);
if ( (at -> tCeptCreationEvent.rcis[1] = moid_cpy(rep4name)) == NULL)
    return (free(at), 0);
if ( (at -> tCeptShutdownEvent.rcis[1] = moid_cpy(rep4name)) == NULL)
    return (free(at), 0);
if ( (at -> numberTPDUSentThldEvent.rcis[0] = moid_cpy(rep3name)) == NULL)
    return (free(at), 0);
if ( (at -> numberTPDUReceivedThldEvent.rcis[0] = moid_cpy(rep3name)) == NULL)
    return (free(at), 0);
if ( (at -> numberTPDURetransThldEvent.rcis[0] = moid_cpy(rep3name)) == NULL)
    return (free(at), 0);

tim = time((time_t*)0);
tm2ut(localtime(&tim), &at -> creationTime);

mo -> do_get = (IFP) Get_T_ConnectionEndpoint;
mo -> do_set = NULLIFP;
mo -> do_add = NULLIFP;
mo -> do_remove = NULLIFP;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_T_ConnectionEndpoint(mo)
struct ManagedObject * mo;
{
struct T_ConnectionEndpoint * at;
free(mo -> Class.oid_elements);
at = (T_ConnectionEndpoint*)mo -> attributes;
if (at -> sourceAddress) free(at -> sourceAddress);
if (at -> destinationAddress) free(at -> destinationAddress);
DefinedEvent_free(&at -> numberTPDUSentThldEvent);
DefinedEvent_free(&at -> numberTPDUReceivedThldEvent);
DefinedEvent_free(&at -> numberTPDURetransThldEvent);
DefinedEvent_free(&at -> tCeptCreationEvent);
DefinedEvent_free(&at -> tCeptShutdownEvent);
free(at);
return (0);
}

static CMISerrors Get_T_ConnectionEndpoint(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
T_ConnectionEndpoint * attribs = (T_ConnectionEndpoint*) mo -> attributes;
Counter * c = NULL;
Gauge * g = NULL;
DefinedEvent * e = NULL;
switch (id)
{
case 2:
    *res = utct2prim(&attribs -> creationTime);
    break;

case 3:
case 4:
    if ( build_MIB_TAddress(res, 1, 0, NULLCP,
	id == 3 ? attribs -> sourceAddress : attribs -> destinationAddress)
	== NOTOK) return (m_processingFailure);
    break;

case 5: c = &attribs -> numberTPDUSent; break;
case 6: c = &attribs -> numberTPDUReceived; break;
case 7: c = &attribs -> numberTPDURetransmitted; break;
case 8: c = &attribs -> numberBytesSent; break;
case 9: c = &attribs -> numberBytesReceived; break;
case 10: c = &attribs -> numberBytesRetransmitted; break;
case 11:
    if (build_MIB_T__ProtocolState(res, 1, 0, NULLCP,
	(int*)&attribs -> tProtocol) == NOTOK) return (m_processingFailure);
    break;

case 12: e = &attribs -> numberTPDUSentThldEvent; break;
case 13: e = &attribs -> numberTPDUReceivedThldEvent; break;
case 14: e = &attribs -> numberTPDURetransThldEvent; break;
case 15: e = &attribs -> tCeptCreationEvent; break;
case 16: e = &attribs -> tCeptShutdownEvent; break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB GET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */

if (g)
    if (build_MIB_Gauge(res, 1, 0, NULLCP, g) == NOTOK)
	return (m_processingFailure);
if (c)
    if (build_MIB_Counter(res, 1, 0, NULLCP, c) == NOTOK)
	return (m_processingFailure);
if (e)
    if (build_MIB_DefinedEvent(res, 1, 0, NULLCP, e) == NOTOK)
	return (m_processingFailure);
return (m_noError);
}

static init_C_Threshold(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID;
C_Threshold * at;
int i;
if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.3.1")) ) == NULL )
	return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (C_Threshold*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);
for(i = 0; i < 10; i++) at -> comparisonlevel[i] = COMP_LEVEL_FREE;

mo -> do_get = (IFP) Get_C_Threshold;
mo -> do_set = (IFP) Set_C_Threshold;
mo -> do_add = NULLIFP;
mo -> do_remove = NULLIFP;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_C_Threshold(mo)
struct ManagedObject * mo;
{
free(mo -> Class.oid_elements);
free(mo -> attributes);
return (0);
}

static CMISerrors Get_C_Threshold(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
C_Threshold * attribs = (C_Threshold*) mo -> attributes;
switch (id)
{
case 2:
    if (build_MIB_ComparisonLevels(res, 1, 0, NULLCP,
	&attribs -> Levels ) == NOTOK) return (m_processingFailure);
    break;

case 3:
    if ( (*res = int2prim(attribs ->offset)) == NULLPE)
	return (m_processingFailure);
    break;

case 4:
    if ( (*res = bool2prim(attribs ->OnOff)) == NULLPE)
	return (m_processingFailure);
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB GET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */
return (m_noError);
}

static CMISerrors Set_C_Threshold(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
C_Threshold * attribs = (C_Threshold*) mo -> attributes;
switch (id)
{
case 2:
    if (parse_MIB_ComparisonLevels(value, 1, NULLIP, NULLVP,
	&attribs -> Levels ) == NOTOK) return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

case 3:
    if ( (attribs -> offset = prim2num(value)) == NOTOK )
	return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

case 4:
    if ( (attribs -> OnOff = prim2flag(value)) == NOTOK)
	return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB SET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */
return (m_noError);
}

static init_G_Threshold(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID;
G_Threshold * at;
if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.3.2")) ) == NULL )
	return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (G_Threshold*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);

mo -> do_get = (IFP) Get_G_Threshold;
mo -> do_set = (IFP) Set_G_Threshold;
mo -> do_add = NULLIFP;
mo -> do_remove = NULLIFP;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_G_Threshold(mo)
struct ManagedObject * mo;
{
free(mo -> Class.oid_elements);
free(mo -> attributes);
return (0);
}

static CMISerrors Get_G_Threshold(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
G_Threshold * attribs = (G_Threshold*) mo -> attributes;
switch (id)
{
case 2:
    if (build_MIB_ComparisonLevels(res, 1, 0, NULLCP,
	&attribs -> Levels ) == NOTOK) return (m_processingFailure);
    break;

case 3:
    if ( (*res = int2prim(attribs ->hysteresis))
	== NULLPE) return (m_processingFailure);
    break;

case 4:
    if ( (*res = bool2prim(attribs ->OnOff)) == NULLPE)
	return (m_processingFailure);
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB GET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */
return (m_noError);
}

static CMISerrors Set_G_Threshold(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
G_Threshold * attribs = (G_Threshold*) mo -> attributes;
switch (id)
{
case 2:
    if (parse_MIB_ComparisonLevels(value, 1, NULLIP, NULLVP,
	&attribs -> Levels ) == NOTOK) return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

case 3:
    if ( (attribs -> hysteresis = prim2num(value)) == NOTOK )
	return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

case 4:
    if ( (attribs -> OnOff = prim2flag(value)) == NOTOK)
	return (m_invalidAttributeValue);
    *res = pe_cpy(value);
    break;

default:
#ifdef DEBUG
    fprintf(stderr, "MIB SET: Bad Attribute Id: %d\n", id);
#endif
    return (m_noSuchAttribute);
} /* close switch */
return (m_noError);
}

static init_ReportControl(mo)
struct ManagedObject * mo;
{
static OID MyClass = NULLOID;
ReportControl * at;
if (MyClass == NULLOID)
    if ( ( MyClass = oid_cpy(str2oid("2.37.3.3")) ) == NULL )
	return (0);
if ( ( oid_copy(MyClass, &mo -> Class) ) == NULL ) return (0);
if ( ( at = (ReportControl*) calloc(1, sizeof (*at)) ) == NULL)
    return (0);

mo -> do_get = (IFP) Get_ReportControl;
mo -> do_set = NULLIFP;
mo -> do_add = (IFP) Add_ReportControl;
mo -> do_remove = (IFP) Remove_ReportControl;
mo -> do_action = NULLIFP;
mo -> attributes = (caddr_t) at;
return (1);
}

static del_ReportControl(mo)
struct ManagedObject * mo;
{
struct ReportControl * at;
destinations * d, * d2;
free(mo -> Class.oid_elements);
at = (ReportControl*)mo -> attributes;
for(d = at -> listofdests; d;)
    {
    d2 = d -> Next;
    free(d);
    d = d2;
    }
free(at);
return (0);
}

static CMISerrors Get_ReportControl(res, mo, id)
PE * res;
struct ManagedObject * mo;
int id;
{
ReportControl * attribs = (ReportControl*) mo -> attributes;
if (id != 2) return (m_noSuchAttribute);
if (build_MIB_ReportDestinationList(res, 1, 0, NULLCP,
    &attribs -> listofdests) == NOTOK) return (m_processingFailure);
return (m_noError);
}

reportdest_cmp(p, q)
struct destinations * p, * q;
{
if (p -> type != q -> type) return (0);
switch (p -> type)
{
case RCI_DEST_PSAP:
    if (bcmp((char*) &p -> Psap_dest, (char*) &q -> Psap_dest,
		sizeof(struct PSAPaddr)) == 0)
	return (1);
    else return (0);

case RCI_DEST_FD:
    return (p -> Fd_dest == q -> Fd_dest);

default:
#ifdef DEBUG
    fprintf(stderr, "Unknown report destination type %d\n", p -> type);
#endif
    return (0);
} /* close switch */
}

static CMISerrors Add_ReportControl(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
struct destinations * newdest, ** d;
ReportControl * attribs = (ReportControl*) mo -> attributes;
if (id != 2) return (m_noSuchAttribute);
if ( (newdest = (destinations*)calloc(1, sizeof (*newdest) )) == NULL)
    return (m_processingFailure);
if (parse_MIB_ReportDestination(value, 0, NULLIP, NULLVP, newdest)
    == NOTOK) return (m_invalidAttributeValue);
for (d = &attribs -> listofdests; *d; d = &(*d) -> Next)
    if (reportdest_cmp(*d, newdest))
	{
	free(newdest);
	if (build_MIB_ReportDestinationList(res, 1, 0, NULLCP,
	    &attribs -> listofdests) == NOTOK) return (m_processingFailure);
	return (m_noError);
	}
*d = newdest;
if (build_MIB_ReportDestinationList(res, 1, 0, NULLCP,
    &attribs -> listofdests) == NOTOK) return (m_processingFailure);
return (m_noError);
}

static CMISerrors Remove_ReportControl(res, mo, id, value)
PE * res, value;
struct ManagedObject * mo;
int id;
{
struct destinations * remdest, ** d;
ReportControl * attribs = (ReportControl*) mo -> attributes;
if (id != 2) return (m_noSuchAttribute);
if ( (remdest = (destinations*)calloc(1, sizeof (*remdest) )) == NULL)
    return (m_processingFailure);
if (parse_MIB_ReportDestination(value, 0, NULLIP, NULLVP, remdest)
    == NOTOK) return (m_invalidAttributeValue);
for (d = &attribs -> listofdests; *d; d = &(*d) -> Next)
    if (reportdest_cmp(*d, remdest))
	{
	destinations * o;
	*d = (o = (*d)) -> Next;
	free (o);
	break;
	}
free(remdest);
if (build_MIB_ReportDestinationList(res, 1, 0, NULLCP,
    &attribs -> listofdests) == NOTOK) return (m_processingFailure);
return (m_noError);
}

/* ARGSUSED */
static Make_Report1(pe, mo, eventype)
PE * pe;
struct ManagedObject * mo;
OID eventype;
{
return (build_Reports_ManagedSystemReport(pe, 1, 0, NULLCP,
    (ManagedSystem*)mo -> attributes));
}

/* ARGSUSED */
static Make_Report2(pe, mo, eventype)
PE * pe;
struct ManagedObject * mo;
OID eventype;
{
return (build_Reports_TEinvReport(pe, 1, 0, NULLCP,
    (T_EntityInvocation*)mo -> attributes));
}

/* ARGSUSED */
static Make_Report3(pe, mo, eventype)
PE * pe;
struct ManagedObject * mo;
OID eventype;
{
return (build_Reports_TCeptReport(pe, 1, 0, NULLCP, mo));
}

/* ARGSUSED */
static Make_Report4(pe, mo, eventype)
PE * pe;
struct ManagedObject * mo;
OID eventype;
{
return (build_Reports_TEntityReport(pe, 1, 0, NULLCP,
    (T_LayerEntity*) mo -> parent -> parent -> attributes));
}

void DefinedEvent_free(e)
DefinedEvent * e;
{
struct MO_ID ** r;
free(e -> eventype.oid_elements);
for(r = e -> rcis; r < &e -> rcis[3]; r++)
    if (*r) moid_free(*r);
}