/*							-- DO NOT EDIT --
 * This file has been generated by smidump
 * version 0.3.1 for the scli package.
 *
 * Derived from SNMP-FRAMEWORK-MIB:
 *   The SNMP Management Architecture MIB
 *
 * Revision 1999-01-19 00:00:
 *   Updated editors' addresses, fixed typos.
 *   Published as RFC2571.
 *   
 *
 * Revision 1997-11-20 00:00:
 *   The initial version, published in RFC 2271.
 *   
 *
 * $Id: snmp-framework-mib.c,v 1.17 2002/03/27 13:48:22 schoenw Exp $
 */

#include "snmp-framework-mib.h"

static guint32 const snmpAuthProtocols[]
	= { SNMP_FRAMEWORK_MIB_SNMPAUTHPROTOCOLS };
static guint32 const snmpPrivProtocols[]
	= { SNMP_FRAMEWORK_MIB_SNMPPRIVPROTOCOLS };

GSnmpIdentity const snmp_framework_mib_identities[] = {
    { snmpAuthProtocols,
      sizeof(snmpAuthProtocols)/sizeof(guint32),
      "snmpAuthProtocols" },
    { snmpPrivProtocols,
      sizeof(snmpPrivProtocols)/sizeof(guint32),
      "snmpPrivProtocols" },
    { 0, 0, NULL }
};


static guint16 snmpEngineID_constraints[] = {5, 32, 0, 0};
static guint32 snmpEngineBoots_constraints[] = {1L, 2147483647L, 0, 0};
static guint32 snmpEngineTime_constraints[] = {0L, 2147483647L, 0, 0};
static guint32 snmpEngineMaxMessageSize_constraints[] = {484L, 2147483647L, 0, 0};


static guint32 const snmpEngine_oid[] = {1, 3, 6, 1, 6, 3, 10, 2, 1};

static GSnmpAttribute snmpEngine_attr[] = {
    { 1, G_SNMP_OCTETSTRING,
      SNMP_FRAMEWORK_MIB_SNMPENGINEID, "snmpEngineID",
       snmpEngineID_constraints,
      G_STRUCT_OFFSET(snmp_framework_mib_snmpEngine_t, snmpEngineID),
      G_STRUCT_OFFSET(snmp_framework_mib_snmpEngine_t, _snmpEngineIDLength),
      0 },
    { 2, G_SNMP_INTEGER32,
      SNMP_FRAMEWORK_MIB_SNMPENGINEBOOTS, "snmpEngineBoots",
       snmpEngineBoots_constraints,
      G_STRUCT_OFFSET(snmp_framework_mib_snmpEngine_t, snmpEngineBoots),
      0,
      0 },
    { 3, G_SNMP_INTEGER32,
      SNMP_FRAMEWORK_MIB_SNMPENGINETIME, "snmpEngineTime",
       snmpEngineTime_constraints,
      G_STRUCT_OFFSET(snmp_framework_mib_snmpEngine_t, snmpEngineTime),
      0,
      0 },
    { 4, G_SNMP_INTEGER32,
      SNMP_FRAMEWORK_MIB_SNMPENGINEMAXMESSAGESIZE, "snmpEngineMaxMessageSize",
       snmpEngineMaxMessageSize_constraints,
      G_STRUCT_OFFSET(snmp_framework_mib_snmpEngine_t, snmpEngineMaxMessageSize),
      0,
      0 },
    { 0, 0, 0, NULL }
};


snmp_framework_mib_snmpEngine_t *
snmp_framework_mib_new_snmpEngine()
{
    snmp_framework_mib_snmpEngine_t *snmpEngine;

    snmpEngine = (snmp_framework_mib_snmpEngine_t *) g_malloc0(sizeof(snmp_framework_mib_snmpEngine_t) + sizeof(gpointer));
    return snmpEngine;
}

static snmp_framework_mib_snmpEngine_t *
assign_snmpEngine(GSList *vbl)
{
    snmp_framework_mib_snmpEngine_t *snmpEngine;
    char *p;

    snmpEngine = snmp_framework_mib_new_snmpEngine();
    if (! snmpEngine) {
        return NULL;
    }

    p = (char *) snmpEngine + sizeof(snmp_framework_mib_snmpEngine_t);
    * (GSList **) p = vbl;

    gsnmp_attr_assign(vbl, snmpEngine_oid, sizeof(snmpEngine_oid)/sizeof(guint32),
                      snmpEngine_attr, snmpEngine);

    return snmpEngine;
}

void
snmp_framework_mib_get_snmpEngine(GSnmpSession *s, snmp_framework_mib_snmpEngine_t **snmpEngine, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 6, 3, 10, 2, 1, 0};

    *snmpEngine = NULL;

    gsnmp_attr_get(s, &in, base, 10, 9, snmpEngine_attr, mask);

    out = g_snmp_session_sync_getnext(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        if (s->error_status != G_SNMP_ERR_NOERROR) {
            g_snmp_vbl_free(out);
            return;
        }
        *snmpEngine = assign_snmpEngine(out);
    }
}

void
snmp_framework_mib_free_snmpEngine(snmp_framework_mib_snmpEngine_t *snmpEngine)
{
    GSList *vbl;
    char *p;

    if (snmpEngine) {
        p = (char *) snmpEngine + sizeof(snmp_framework_mib_snmpEngine_t);
        vbl = * (GSList **) p;
        g_snmp_vbl_free(vbl);
        g_free(snmpEngine);
    }
}


