/*							-- DO NOT EDIT --
 * This file has been generated by smidump
 * version 0.3.1 for the scli package.
 *
 * Derived from SNMP-NOTIFICATION-MIB:
 *   This MIB module defines MIB objects which provide
 *   mechanisms to remotely configure the parameters
 *   used by an SNMP entity for the generation of
 *   notifications.
 *
 * Revision 1998-08-04 00:00:
 *   Clarifications, published as
 *   RFC2573
 *
 * Revision 1997-07-14 00:00:
 *   The initial revision, published as RFC2273.
 *
 * $Id: snmp-notification-mib.c,v 1.4 2002/03/27 13:48:23 schoenw Exp $
 */

#include "snmp-notification-mib.h"

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyType[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYTYPE_TRAP,   "trap" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYTYPE_INFORM, "inform" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyStorageType[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYSTORAGETYPE_OTHER,       "other" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYSTORAGETYPE_VOLATILE,    "volatile" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYSTORAGETYPE_NONVOLATILE, "nonVolatile" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYSTORAGETYPE_PERMANENT,   "permanent" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYSTORAGETYPE_READONLY,    "readOnly" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyRowStatus[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS_ACTIVE,        "active" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS_NOTINSERVICE,  "notInService" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS_NOTREADY,      "notReady" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS_CREATEANDGO,   "createAndGo" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS_CREATEANDWAIT, "createAndWait" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS_DESTROY,       "destroy" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyFilterProfileStorType[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILESTORTYPE_OTHER,       "other" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILESTORTYPE_VOLATILE,    "volatile" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILESTORTYPE_NONVOLATILE, "nonVolatile" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILESTORTYPE_PERMANENT,   "permanent" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILESTORTYPE_READONLY,    "readOnly" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyFilterProfileRowStatus[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS_ACTIVE,        "active" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS_NOTINSERVICE,  "notInService" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS_NOTREADY,      "notReady" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS_CREATEANDGO,   "createAndGo" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS_CREATEANDWAIT, "createAndWait" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS_DESTROY,       "destroy" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyFilterType[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTYPE_INCLUDED, "included" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTYPE_EXCLUDED, "excluded" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyFilterStorageType[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERSTORAGETYPE_OTHER,       "other" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERSTORAGETYPE_VOLATILE,    "volatile" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERSTORAGETYPE_NONVOLATILE, "nonVolatile" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERSTORAGETYPE_PERMANENT,   "permanent" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERSTORAGETYPE_READONLY,    "readOnly" },
    { 0, NULL }
};

GSnmpEnum const snmp_notification_mib_enums_snmpNotifyFilterRowStatus[] = {
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS_ACTIVE,        "active" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS_NOTINSERVICE,  "notInService" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS_NOTREADY,      "notReady" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS_CREATEANDGO,   "createAndGo" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS_CREATEANDWAIT, "createAndWait" },
    { SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS_DESTROY,       "destroy" },
    { 0, NULL }
};


static guint16 snmpNotifyTag_constraints[] = {0, 255, 0, 0};
static guint16 snmpNotifyFilterProfileName_constraints[] = {1, 32, 0, 0};
static guint16 snmpNotifyFilterMask_constraints[] = {0, 16, 0, 0};


static guint32 const snmpNotifyEntry_oid[] = {1, 3, 6, 1, 6, 3, 13, 1, 1, 1};

static GSnmpAttribute snmpNotifyEntry_attr[] = {
    { 2, G_SNMP_OCTETSTRING,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYTAG, "snmpNotifyTag",
       snmpNotifyTag_constraints,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyEntry_t, snmpNotifyTag),
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyEntry_t, _snmpNotifyTagLength),
      GSNMP_ATTR_FLAG_WRITABLE },
    { 3, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYTYPE, "snmpNotifyType",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyEntry_t, snmpNotifyType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 4, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYSTORAGETYPE, "snmpNotifyStorageType",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyEntry_t, snmpNotifyStorageType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 5, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYROWSTATUS, "snmpNotifyRowStatus",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyEntry_t, snmpNotifyRowStatus),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};

static guint32 const snmpNotifyFilterProfileEntry_oid[] = {1, 3, 6, 1, 6, 3, 13, 1, 2, 1};

static GSnmpAttribute snmpNotifyFilterProfileEntry_attr[] = {
    { 1, G_SNMP_OCTETSTRING,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILENAME, "snmpNotifyFilterProfileName",
       snmpNotifyFilterProfileName_constraints,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterProfileEntry_t, snmpNotifyFilterProfileName),
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterProfileEntry_t, _snmpNotifyFilterProfileNameLength),
      GSNMP_ATTR_FLAG_WRITABLE },
    { 2, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILESTORTYPE, "snmpNotifyFilterProfileStorType",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterProfileEntry_t, snmpNotifyFilterProfileStorType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 3, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERPROFILEROWSTATUS, "snmpNotifyFilterProfileRowStatus",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterProfileEntry_t, snmpNotifyFilterProfileRowStatus),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};

static guint32 const snmpNotifyFilterEntry_oid[] = {1, 3, 6, 1, 6, 3, 13, 1, 3, 1};

static GSnmpAttribute snmpNotifyFilterEntry_attr[] = {
    { 2, G_SNMP_OCTETSTRING,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERMASK, "snmpNotifyFilterMask",
       snmpNotifyFilterMask_constraints,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterEntry_t, snmpNotifyFilterMask),
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterEntry_t, _snmpNotifyFilterMaskLength),
      GSNMP_ATTR_FLAG_WRITABLE },
    { 3, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERTYPE, "snmpNotifyFilterType",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterEntry_t, snmpNotifyFilterType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 4, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERSTORAGETYPE, "snmpNotifyFilterStorageType",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterEntry_t, snmpNotifyFilterStorageType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 5, G_SNMP_INTEGER32,
      SNMP_NOTIFICATION_MIB_SNMPNOTIFYFILTERROWSTATUS, "snmpNotifyFilterRowStatus",
       NULL,
      G_STRUCT_OFFSET(snmp_notification_mib_snmpNotifyFilterEntry_t, snmpNotifyFilterRowStatus),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};


snmp_notification_mib_snmpNotifyEntry_t *
snmp_notification_mib_new_snmpNotifyEntry()
{
    snmp_notification_mib_snmpNotifyEntry_t *snmpNotifyEntry;

    snmpNotifyEntry = (snmp_notification_mib_snmpNotifyEntry_t *) g_malloc0(sizeof(snmp_notification_mib_snmpNotifyEntry_t) + sizeof(gpointer));
    return snmpNotifyEntry;
}

static int
unpack_snmpNotifyEntry(GSnmpVarBind *vb, snmp_notification_mib_snmpNotifyEntry_t *snmpNotifyEntry)
{
    guint8 idx = 11;
    guint16 i, len;

    if (vb->id_len < idx) return -1;
    len = vb->id_len - idx;
    if (len < 1 || len > 32) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        snmpNotifyEntry->snmpNotifyName[i] = vb->id[idx++];
    }
    snmpNotifyEntry->_snmpNotifyNameLength = len;
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_snmpNotifyEntry(guint32 *base, guchar *snmpNotifyName, guint16 _snmpNotifyNameLength)
{
    guint8 idx = 11;
    guint16 i, len;

    len = _snmpNotifyNameLength;
    if (len < 1 || len > 32) return -1;
    for (i = 0; i < len; i++) {
        base[idx++] = snmpNotifyName[i];
        if (idx >= 128) return -1;
    }
    return idx;
}

static snmp_notification_mib_snmpNotifyEntry_t *
assign_snmpNotifyEntry(GSList *vbl)
{
    snmp_notification_mib_snmpNotifyEntry_t *snmpNotifyEntry;
    char *p;

    snmpNotifyEntry = snmp_notification_mib_new_snmpNotifyEntry();
    if (! snmpNotifyEntry) {
        return NULL;
    }

    p = (char *) snmpNotifyEntry + sizeof(snmp_notification_mib_snmpNotifyEntry_t);
    * (GSList **) p = vbl;

    if (unpack_snmpNotifyEntry((GSnmpVarBind *) vbl->data, snmpNotifyEntry) < 0) {
        g_warning("%s: invalid instance identifier", "snmpNotifyEntry");
        g_free(snmpNotifyEntry);
        return NULL;
    }

    gsnmp_attr_assign(vbl, snmpNotifyEntry_oid, sizeof(snmpNotifyEntry_oid)/sizeof(guint32),
                      snmpNotifyEntry_attr, snmpNotifyEntry);

    return snmpNotifyEntry;
}

void
snmp_notification_mib_get_snmpNotifyTable(GSnmpSession *s, snmp_notification_mib_snmpNotifyEntry_t ***snmpNotifyEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 0};

    *snmpNotifyEntry = NULL;

    gsnmp_attr_get(s, &in, base, 11, 10, snmpNotifyEntry_attr, mask);

    out = gsnmp_gettable(s, in);
    /* g_snmp_vbl_free(in); */

    if (out) {
        *snmpNotifyEntry = (snmp_notification_mib_snmpNotifyEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(snmp_notification_mib_snmpNotifyEntry_t *));
        if (! *snmpNotifyEntry) {
            s->error_status = G_SNMP_ERR_INTERNAL;
            g_snmp_vbl_free(out);
            return;
        }
        for (row = out, i = 0; row; row = g_slist_next(row), i++) {
            (*snmpNotifyEntry)[i] = assign_snmpNotifyEntry(row->data);
        }
    }
}

void
snmp_notification_mib_get_snmpNotifyEntry(GSnmpSession *s, snmp_notification_mib_snmpNotifyEntry_t **snmpNotifyEntry, guchar *snmpNotifyName, guint16 _snmpNotifyNameLength, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, snmpNotifyEntry_oid, sizeof(snmpNotifyEntry_oid));
    len = pack_snmpNotifyEntry(base, snmpNotifyName, _snmpNotifyNameLength);
    if (len < 0) {
        g_warning("%s: invalid index values", "snmpNotifyEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *snmpNotifyEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, snmpNotifyEntry_attr, mask);

    out = g_snmp_session_sync_get(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        if (s->error_status != G_SNMP_ERR_NOERROR) {
            g_snmp_vbl_free(out);
            return;
        }
        *snmpNotifyEntry = assign_snmpNotifyEntry(out);
    }
}

void
snmp_notification_mib_set_snmpNotifyEntry(GSnmpSession *s, snmp_notification_mib_snmpNotifyEntry_t *snmpNotifyEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, snmpNotifyEntry_oid, sizeof(snmpNotifyEntry_oid));
    len = pack_snmpNotifyEntry(base, snmpNotifyEntry->snmpNotifyName, snmpNotifyEntry->_snmpNotifyNameLength);
    if (len < 0) {
        g_warning("%s: invalid index values", "snmpNotifyEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    gsnmp_attr_set(s, &in, base, len, 10, snmpNotifyEntry_attr, mask, snmpNotifyEntry);

    out = g_snmp_session_sync_set(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        g_snmp_vbl_free(out);
    }
}

void
snmp_notification_mib_free_snmpNotifyEntry(snmp_notification_mib_snmpNotifyEntry_t *snmpNotifyEntry)
{
    GSList *vbl;
    char *p;

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

void
snmp_notification_mib_free_snmpNotifyTable(snmp_notification_mib_snmpNotifyEntry_t **snmpNotifyEntry)
{
    int i;

    if (snmpNotifyEntry) {
        for (i = 0; snmpNotifyEntry[i]; i++) {
            snmp_notification_mib_free_snmpNotifyEntry(snmpNotifyEntry[i]);
        }
        g_free(snmpNotifyEntry);
    }
}

snmp_notification_mib_snmpNotifyFilterProfileEntry_t *
snmp_notification_mib_new_snmpNotifyFilterProfileEntry()
{
    snmp_notification_mib_snmpNotifyFilterProfileEntry_t *snmpNotifyFilterProfileEntry;

    snmpNotifyFilterProfileEntry = (snmp_notification_mib_snmpNotifyFilterProfileEntry_t *) g_malloc0(sizeof(snmp_notification_mib_snmpNotifyFilterProfileEntry_t) + sizeof(gpointer));
    return snmpNotifyFilterProfileEntry;
}

static int
unpack_snmpNotifyFilterProfileEntry(GSnmpVarBind *vb, snmp_notification_mib_snmpNotifyFilterProfileEntry_t *snmpNotifyFilterProfileEntry)
{
    guint8 idx = 11;
    guint16 i, len;

    if (vb->id_len < idx) return -1;
    len = vb->id_len - idx;
    if (len < 1 || len > 32) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        snmpNotifyFilterProfileEntry->snmpTargetParamsName[i] = vb->id[idx++];
    }
    snmpNotifyFilterProfileEntry->_snmpTargetParamsNameLength = len;
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_snmpNotifyFilterProfileEntry(guint32 *base, guchar *snmpTargetParamsName, guint16 _snmpTargetParamsNameLength)
{
    guint8 idx = 11;
    guint16 i, len;

    len = _snmpTargetParamsNameLength;
    if (len < 1 || len > 32) return -1;
    for (i = 0; i < len; i++) {
        base[idx++] = snmpTargetParamsName[i];
        if (idx >= 128) return -1;
    }
    return idx;
}

static snmp_notification_mib_snmpNotifyFilterProfileEntry_t *
assign_snmpNotifyFilterProfileEntry(GSList *vbl)
{
    snmp_notification_mib_snmpNotifyFilterProfileEntry_t *snmpNotifyFilterProfileEntry;
    char *p;

    snmpNotifyFilterProfileEntry = snmp_notification_mib_new_snmpNotifyFilterProfileEntry();
    if (! snmpNotifyFilterProfileEntry) {
        return NULL;
    }

    p = (char *) snmpNotifyFilterProfileEntry + sizeof(snmp_notification_mib_snmpNotifyFilterProfileEntry_t);
    * (GSList **) p = vbl;

    if (unpack_snmpNotifyFilterProfileEntry((GSnmpVarBind *) vbl->data, snmpNotifyFilterProfileEntry) < 0) {
        g_warning("%s: invalid instance identifier", "snmpNotifyFilterProfileEntry");
        g_free(snmpNotifyFilterProfileEntry);
        return NULL;
    }

    gsnmp_attr_assign(vbl, snmpNotifyFilterProfileEntry_oid, sizeof(snmpNotifyFilterProfileEntry_oid)/sizeof(guint32),
                      snmpNotifyFilterProfileEntry_attr, snmpNotifyFilterProfileEntry);

    return snmpNotifyFilterProfileEntry;
}

void
snmp_notification_mib_get_snmpNotifyFilterProfileTable(GSnmpSession *s, snmp_notification_mib_snmpNotifyFilterProfileEntry_t ***snmpNotifyFilterProfileEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 6, 3, 13, 1, 2, 1, 0};

    *snmpNotifyFilterProfileEntry = NULL;

    gsnmp_attr_get(s, &in, base, 11, 10, snmpNotifyFilterProfileEntry_attr, mask);

    out = gsnmp_gettable(s, in);
    /* g_snmp_vbl_free(in); */

    if (out) {
        *snmpNotifyFilterProfileEntry = (snmp_notification_mib_snmpNotifyFilterProfileEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(snmp_notification_mib_snmpNotifyFilterProfileEntry_t *));
        if (! *snmpNotifyFilterProfileEntry) {
            s->error_status = G_SNMP_ERR_INTERNAL;
            g_snmp_vbl_free(out);
            return;
        }
        for (row = out, i = 0; row; row = g_slist_next(row), i++) {
            (*snmpNotifyFilterProfileEntry)[i] = assign_snmpNotifyFilterProfileEntry(row->data);
        }
    }
}

void
snmp_notification_mib_get_snmpNotifyFilterProfileEntry(GSnmpSession *s, snmp_notification_mib_snmpNotifyFilterProfileEntry_t **snmpNotifyFilterProfileEntry, guchar *snmpTargetParamsName, guint16 _snmpTargetParamsNameLength, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, snmpNotifyFilterProfileEntry_oid, sizeof(snmpNotifyFilterProfileEntry_oid));
    len = pack_snmpNotifyFilterProfileEntry(base, snmpTargetParamsName, _snmpTargetParamsNameLength);
    if (len < 0) {
        g_warning("%s: invalid index values", "snmpNotifyFilterProfileEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *snmpNotifyFilterProfileEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, snmpNotifyFilterProfileEntry_attr, mask);

    out = g_snmp_session_sync_get(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        if (s->error_status != G_SNMP_ERR_NOERROR) {
            g_snmp_vbl_free(out);
            return;
        }
        *snmpNotifyFilterProfileEntry = assign_snmpNotifyFilterProfileEntry(out);
    }
}

void
snmp_notification_mib_set_snmpNotifyFilterProfileEntry(GSnmpSession *s, snmp_notification_mib_snmpNotifyFilterProfileEntry_t *snmpNotifyFilterProfileEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, snmpNotifyFilterProfileEntry_oid, sizeof(snmpNotifyFilterProfileEntry_oid));
    len = pack_snmpNotifyFilterProfileEntry(base, snmpNotifyFilterProfileEntry->snmpTargetParamsName, snmpNotifyFilterProfileEntry->_snmpTargetParamsNameLength);
    if (len < 0) {
        g_warning("%s: invalid index values", "snmpNotifyFilterProfileEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    gsnmp_attr_set(s, &in, base, len, 10, snmpNotifyFilterProfileEntry_attr, mask, snmpNotifyFilterProfileEntry);

    out = g_snmp_session_sync_set(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        g_snmp_vbl_free(out);
    }
}

void
snmp_notification_mib_free_snmpNotifyFilterProfileEntry(snmp_notification_mib_snmpNotifyFilterProfileEntry_t *snmpNotifyFilterProfileEntry)
{
    GSList *vbl;
    char *p;

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

void
snmp_notification_mib_free_snmpNotifyFilterProfileTable(snmp_notification_mib_snmpNotifyFilterProfileEntry_t **snmpNotifyFilterProfileEntry)
{
    int i;

    if (snmpNotifyFilterProfileEntry) {
        for (i = 0; snmpNotifyFilterProfileEntry[i]; i++) {
            snmp_notification_mib_free_snmpNotifyFilterProfileEntry(snmpNotifyFilterProfileEntry[i]);
        }
        g_free(snmpNotifyFilterProfileEntry);
    }
}

snmp_notification_mib_snmpNotifyFilterEntry_t *
snmp_notification_mib_new_snmpNotifyFilterEntry()
{
    snmp_notification_mib_snmpNotifyFilterEntry_t *snmpNotifyFilterEntry;

    snmpNotifyFilterEntry = (snmp_notification_mib_snmpNotifyFilterEntry_t *) g_malloc0(sizeof(snmp_notification_mib_snmpNotifyFilterEntry_t) + sizeof(gpointer));
    return snmpNotifyFilterEntry;
}

static int
unpack_snmpNotifyFilterEntry(GSnmpVarBind *vb, snmp_notification_mib_snmpNotifyFilterEntry_t *snmpNotifyFilterEntry)
{
    guint8 idx = 11;
    guint16 i, len;

    if (vb->id_len < idx) return -1;
    len = vb->id[idx++];
    if (len < 1 || len > 32) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        snmpNotifyFilterEntry->snmpNotifyFilterProfileName[i] = vb->id[idx++];
    }
    snmpNotifyFilterEntry->_snmpNotifyFilterProfileNameLength = len;
    if (vb->id_len < idx) return -1;
    len = vb->id_len - idx;
    if (len > 117) return -1;
    for (i = 0; i < len; i++) {
        snmpNotifyFilterEntry->snmpNotifyFilterSubtree[i] = vb->id[idx++];
    }
    snmpNotifyFilterEntry->_snmpNotifyFilterSubtreeLength = len;
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_snmpNotifyFilterEntry(guint32 *base, guchar *snmpNotifyFilterProfileName, guint16 _snmpNotifyFilterProfileNameLength, guint32 *snmpNotifyFilterSubtree, guint16 _snmpNotifyFilterSubtreeLength)
{
    guint8 idx = 11;
    guint16 i, len;

    len = _snmpNotifyFilterProfileNameLength;
    base[idx++] = len;
    if (len < 1 || len > 32) return -1;
    for (i = 0; i < len; i++) {
        base[idx++] = snmpNotifyFilterProfileName[i];
        if (idx >= 128) return -1;
    }
    len = _snmpNotifyFilterSubtreeLength;
    if (len > 117) return -1;
    for (i = 0; i < len; i++) {
        base[idx++] = snmpNotifyFilterSubtree[i];
        if (idx >= 128) return -1;
    }
    return idx;
}

static snmp_notification_mib_snmpNotifyFilterEntry_t *
assign_snmpNotifyFilterEntry(GSList *vbl)
{
    snmp_notification_mib_snmpNotifyFilterEntry_t *snmpNotifyFilterEntry;
    char *p;

    snmpNotifyFilterEntry = snmp_notification_mib_new_snmpNotifyFilterEntry();
    if (! snmpNotifyFilterEntry) {
        return NULL;
    }

    p = (char *) snmpNotifyFilterEntry + sizeof(snmp_notification_mib_snmpNotifyFilterEntry_t);
    * (GSList **) p = vbl;

    if (unpack_snmpNotifyFilterEntry((GSnmpVarBind *) vbl->data, snmpNotifyFilterEntry) < 0) {
        g_warning("%s: invalid instance identifier", "snmpNotifyFilterEntry");
        g_free(snmpNotifyFilterEntry);
        return NULL;
    }

    gsnmp_attr_assign(vbl, snmpNotifyFilterEntry_oid, sizeof(snmpNotifyFilterEntry_oid)/sizeof(guint32),
                      snmpNotifyFilterEntry_attr, snmpNotifyFilterEntry);

    return snmpNotifyFilterEntry;
}

void
snmp_notification_mib_get_snmpNotifyFilterTable(GSnmpSession *s, snmp_notification_mib_snmpNotifyFilterEntry_t ***snmpNotifyFilterEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 0};

    *snmpNotifyFilterEntry = NULL;

    gsnmp_attr_get(s, &in, base, 11, 10, snmpNotifyFilterEntry_attr, mask);

    out = gsnmp_gettable(s, in);
    /* g_snmp_vbl_free(in); */

    if (out) {
        *snmpNotifyFilterEntry = (snmp_notification_mib_snmpNotifyFilterEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(snmp_notification_mib_snmpNotifyFilterEntry_t *));
        if (! *snmpNotifyFilterEntry) {
            s->error_status = G_SNMP_ERR_INTERNAL;
            g_snmp_vbl_free(out);
            return;
        }
        for (row = out, i = 0; row; row = g_slist_next(row), i++) {
            (*snmpNotifyFilterEntry)[i] = assign_snmpNotifyFilterEntry(row->data);
        }
    }
}

void
snmp_notification_mib_get_snmpNotifyFilterEntry(GSnmpSession *s, snmp_notification_mib_snmpNotifyFilterEntry_t **snmpNotifyFilterEntry, guchar *snmpNotifyFilterProfileName, guint16 _snmpNotifyFilterProfileNameLength, guint32 *snmpNotifyFilterSubtree, guint16 _snmpNotifyFilterSubtreeLength, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, snmpNotifyFilterEntry_oid, sizeof(snmpNotifyFilterEntry_oid));
    len = pack_snmpNotifyFilterEntry(base, snmpNotifyFilterProfileName, _snmpNotifyFilterProfileNameLength, snmpNotifyFilterSubtree, _snmpNotifyFilterSubtreeLength);
    if (len < 0) {
        g_warning("%s: invalid index values", "snmpNotifyFilterEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *snmpNotifyFilterEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, snmpNotifyFilterEntry_attr, mask);

    out = g_snmp_session_sync_get(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        if (s->error_status != G_SNMP_ERR_NOERROR) {
            g_snmp_vbl_free(out);
            return;
        }
        *snmpNotifyFilterEntry = assign_snmpNotifyFilterEntry(out);
    }
}

void
snmp_notification_mib_set_snmpNotifyFilterEntry(GSnmpSession *s, snmp_notification_mib_snmpNotifyFilterEntry_t *snmpNotifyFilterEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, snmpNotifyFilterEntry_oid, sizeof(snmpNotifyFilterEntry_oid));
    len = pack_snmpNotifyFilterEntry(base, snmpNotifyFilterEntry->snmpNotifyFilterProfileName, snmpNotifyFilterEntry->_snmpNotifyFilterProfileNameLength, snmpNotifyFilterEntry->snmpNotifyFilterSubtree, snmpNotifyFilterEntry->_snmpNotifyFilterSubtreeLength);
    if (len < 0) {
        g_warning("%s: invalid index values", "snmpNotifyFilterEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    gsnmp_attr_set(s, &in, base, len, 10, snmpNotifyFilterEntry_attr, mask, snmpNotifyFilterEntry);

    out = g_snmp_session_sync_set(s, in);
    g_snmp_vbl_free(in);
    if (out) {
        g_snmp_vbl_free(out);
    }
}

void
snmp_notification_mib_free_snmpNotifyFilterEntry(snmp_notification_mib_snmpNotifyFilterEntry_t *snmpNotifyFilterEntry)
{
    GSList *vbl;
    char *p;

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

void
snmp_notification_mib_free_snmpNotifyFilterTable(snmp_notification_mib_snmpNotifyFilterEntry_t **snmpNotifyFilterEntry)
{
    int i;

    if (snmpNotifyFilterEntry) {
        for (i = 0; snmpNotifyFilterEntry[i]; i++) {
            snmp_notification_mib_free_snmpNotifyFilterEntry(snmpNotifyFilterEntry[i]);
        }
        g_free(snmpNotifyFilterEntry);
    }
}


