/*							-- DO NOT EDIT --
 * This file has been generated by smidump
 * version 0.3.1 for the scli package.
 *
 * Derived from BRIDGE-MIB:
 *
 * $Id: bridge-mib.c,v 1.21 2002/03/27 13:48:21 schoenw Exp $
 */

#include "bridge-mib.h"

GSnmpEnum const bridge_mib_enums_dot1dBaseType[] = {
    { BRIDGE_MIB_DOT1DBASETYPE_UNKNOWN,          "unknown" },
    { BRIDGE_MIB_DOT1DBASETYPE_TRANSPARENT_ONLY, "transparent-only" },
    { BRIDGE_MIB_DOT1DBASETYPE_SOURCEROUTE_ONLY, "sourceroute-only" },
    { BRIDGE_MIB_DOT1DBASETYPE_SRT,              "srt" },
    { 0, NULL }
};

GSnmpEnum const bridge_mib_enums_dot1dStpProtocolSpecification[] = {
    { BRIDGE_MIB_DOT1DSTPPROTOCOLSPECIFICATION_UNKNOWN,   "unknown" },
    { BRIDGE_MIB_DOT1DSTPPROTOCOLSPECIFICATION_DECLB100,  "decLb100" },
    { BRIDGE_MIB_DOT1DSTPPROTOCOLSPECIFICATION_IEEE8021D, "ieee8021d" },
    { 0, NULL }
};

GSnmpEnum const bridge_mib_enums_dot1dStpPortState[] = {
    { BRIDGE_MIB_DOT1DSTPPORTSTATE_DISABLED,   "disabled" },
    { BRIDGE_MIB_DOT1DSTPPORTSTATE_BLOCKING,   "blocking" },
    { BRIDGE_MIB_DOT1DSTPPORTSTATE_LISTENING,  "listening" },
    { BRIDGE_MIB_DOT1DSTPPORTSTATE_LEARNING,   "learning" },
    { BRIDGE_MIB_DOT1DSTPPORTSTATE_FORWARDING, "forwarding" },
    { BRIDGE_MIB_DOT1DSTPPORTSTATE_BROKEN,     "broken" },
    { 0, NULL }
};

GSnmpEnum const bridge_mib_enums_dot1dStpPortEnable[] = {
    { BRIDGE_MIB_DOT1DSTPPORTENABLE_ENABLED,  "enabled" },
    { BRIDGE_MIB_DOT1DSTPPORTENABLE_DISABLED, "disabled" },
    { 0, NULL }
};

GSnmpEnum const bridge_mib_enums_dot1dTpFdbStatus[] = {
    { BRIDGE_MIB_DOT1DTPFDBSTATUS_OTHER,   "other" },
    { BRIDGE_MIB_DOT1DTPFDBSTATUS_INVALID, "invalid" },
    { BRIDGE_MIB_DOT1DTPFDBSTATUS_LEARNED, "learned" },
    { BRIDGE_MIB_DOT1DTPFDBSTATUS_SELF,    "self" },
    { BRIDGE_MIB_DOT1DTPFDBSTATUS_MGMT,    "mgmt" },
    { 0, NULL }
};

GSnmpEnum const bridge_mib_enums_dot1dStaticStatus[] = {
    { BRIDGE_MIB_DOT1DSTATICSTATUS_OTHER,           "other" },
    { BRIDGE_MIB_DOT1DSTATICSTATUS_INVALID,         "invalid" },
    { BRIDGE_MIB_DOT1DSTATICSTATUS_PERMANENT,       "permanent" },
    { BRIDGE_MIB_DOT1DSTATICSTATUS_DELETEONRESET,   "deleteOnReset" },
    { BRIDGE_MIB_DOT1DSTATICSTATUS_DELETEONTIMEOUT, "deleteOnTimeout" },
    { 0, NULL }
};


static guint16 dot1dBaseBridgeAddress_constraints[] = {6, 6, 0, 0};
static guint32 dot1dStpPriority_constraints[] = {0L, 65535L, 0, 0};
static guint16 dot1dStpDesignatedRoot_constraints[] = {8, 8, 0, 0};
static guint32 dot1dStpBridgeMaxAge_constraints[] = {600L, 4000L, 0, 0};
static guint32 dot1dStpBridgeHelloTime_constraints[] = {100L, 1000L, 0, 0};
static guint32 dot1dStpBridgeForwardDelay_constraints[] = {400L, 3000L, 0, 0};
static guint32 dot1dStpPortPriority_constraints[] = {0L, 255L, 0, 0};
static guint32 dot1dStpPortPathCost_constraints[] = {1L, 65535L, 0, 0};
static guint16 dot1dStpPortDesignatedRoot_constraints[] = {8, 8, 0, 0};
static guint16 dot1dStpPortDesignatedBridge_constraints[] = {8, 8, 0, 0};
static guint16 dot1dStpPortDesignatedPort_constraints[] = {2, 2, 0, 0};
static guint32 dot1dTpAgingTime_constraints[] = {10L, 1000000L, 0, 0};


static guint32 const dot1dBase_oid[] = {1, 3, 6, 1, 2, 1, 17, 1};

static GSnmpAttribute dot1dBase_attr[] = {
    { 1, G_SNMP_OCTETSTRING,
      BRIDGE_MIB_DOT1DBASEBRIDGEADDRESS, "dot1dBaseBridgeAddress",
       dot1dBaseBridgeAddress_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dBase_t, dot1dBaseBridgeAddress),
      0,
      0 },
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DBASENUMPORTS, "dot1dBaseNumPorts",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dBase_t, dot1dBaseNumPorts),
      0,
      0 },
    { 3, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DBASETYPE, "dot1dBaseType",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dBase_t, dot1dBaseType),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dBasePortEntry_oid[] = {1, 3, 6, 1, 2, 1, 17, 1, 4, 1};

static GSnmpAttribute dot1dBasePortEntry_attr[] = {
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DBASEPORTIFINDEX, "dot1dBasePortIfIndex",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dBasePortEntry_t, dot1dBasePortIfIndex),
      0,
      0 },
    { 3, G_SNMP_OBJECTID,
      BRIDGE_MIB_DOT1DBASEPORTCIRCUIT, "dot1dBasePortCircuit",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dBasePortEntry_t, dot1dBasePortCircuit),
      G_STRUCT_OFFSET(bridge_mib_dot1dBasePortEntry_t, _dot1dBasePortCircuitLength),
      0 },
    { 4, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DBASEPORTDELAYEXCEEDEDDISCARDS, "dot1dBasePortDelayExceededDiscards",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dBasePortEntry_t, dot1dBasePortDelayExceededDiscards),
      0,
      0 },
    { 5, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DBASEPORTMTUEXCEEDEDDISCARDS, "dot1dBasePortMtuExceededDiscards",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dBasePortEntry_t, dot1dBasePortMtuExceededDiscards),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dStp_oid[] = {1, 3, 6, 1, 2, 1, 17, 2};

static GSnmpAttribute dot1dStp_attr[] = {
    { 1, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPROTOCOLSPECIFICATION, "dot1dStpProtocolSpecification",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpProtocolSpecification),
      0,
      0 },
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPRIORITY, "dot1dStpPriority",
       dot1dStpPriority_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpPriority),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 3, G_SNMP_TIMETICKS,
      BRIDGE_MIB_DOT1DSTPTIMESINCETOPOLOGYCHANGE, "dot1dStpTimeSinceTopologyChange",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpTimeSinceTopologyChange),
      0,
      0 },
    { 4, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DSTPTOPCHANGES, "dot1dStpTopChanges",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpTopChanges),
      0,
      0 },
    { 5, G_SNMP_OCTETSTRING,
      BRIDGE_MIB_DOT1DSTPDESIGNATEDROOT, "dot1dStpDesignatedRoot",
       dot1dStpDesignatedRoot_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpDesignatedRoot),
      0,
      0 },
    { 6, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPROOTCOST, "dot1dStpRootCost",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpRootCost),
      0,
      0 },
    { 7, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPROOTPORT, "dot1dStpRootPort",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpRootPort),
      0,
      0 },
    { 8, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPMAXAGE, "dot1dStpMaxAge",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpMaxAge),
      0,
      0 },
    { 9, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPHELLOTIME, "dot1dStpHelloTime",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpHelloTime),
      0,
      0 },
    { 10, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPHOLDTIME, "dot1dStpHoldTime",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpHoldTime),
      0,
      0 },
    { 11, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPFORWARDDELAY, "dot1dStpForwardDelay",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpForwardDelay),
      0,
      0 },
    { 12, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPBRIDGEMAXAGE, "dot1dStpBridgeMaxAge",
       dot1dStpBridgeMaxAge_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpBridgeMaxAge),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 13, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPBRIDGEHELLOTIME, "dot1dStpBridgeHelloTime",
       dot1dStpBridgeHelloTime_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpBridgeHelloTime),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 14, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPBRIDGEFORWARDDELAY, "dot1dStpBridgeForwardDelay",
       dot1dStpBridgeForwardDelay_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStp_t, dot1dStpBridgeForwardDelay),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dStpPortEntry_oid[] = {1, 3, 6, 1, 2, 1, 17, 2, 15, 1};

static GSnmpAttribute dot1dStpPortEntry_attr[] = {
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPORTPRIORITY, "dot1dStpPortPriority",
       dot1dStpPortPriority_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortPriority),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 3, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPORTSTATE, "dot1dStpPortState",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortState),
      0,
      0 },
    { 4, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPORTENABLE, "dot1dStpPortEnable",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortEnable),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 5, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPORTPATHCOST, "dot1dStpPortPathCost",
       dot1dStpPortPathCost_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortPathCost),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 6, G_SNMP_OCTETSTRING,
      BRIDGE_MIB_DOT1DSTPPORTDESIGNATEDROOT, "dot1dStpPortDesignatedRoot",
       dot1dStpPortDesignatedRoot_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortDesignatedRoot),
      0,
      0 },
    { 7, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTPPORTDESIGNATEDCOST, "dot1dStpPortDesignatedCost",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortDesignatedCost),
      0,
      0 },
    { 8, G_SNMP_OCTETSTRING,
      BRIDGE_MIB_DOT1DSTPPORTDESIGNATEDBRIDGE, "dot1dStpPortDesignatedBridge",
       dot1dStpPortDesignatedBridge_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortDesignatedBridge),
      0,
      0 },
    { 9, G_SNMP_OCTETSTRING,
      BRIDGE_MIB_DOT1DSTPPORTDESIGNATEDPORT, "dot1dStpPortDesignatedPort",
       dot1dStpPortDesignatedPort_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortDesignatedPort),
      0,
      0 },
    { 10, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DSTPPORTFORWARDTRANSITIONS, "dot1dStpPortForwardTransitions",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStpPortEntry_t, dot1dStpPortForwardTransitions),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dTp_oid[] = {1, 3, 6, 1, 2, 1, 17, 4};

static GSnmpAttribute dot1dTp_attr[] = {
    { 1, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DTPLEARNEDENTRYDISCARDS, "dot1dTpLearnedEntryDiscards",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTp_t, dot1dTpLearnedEntryDiscards),
      0,
      0 },
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DTPAGINGTIME, "dot1dTpAgingTime",
       dot1dTpAgingTime_constraints,
      G_STRUCT_OFFSET(bridge_mib_dot1dTp_t, dot1dTpAgingTime),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dTpFdbEntry_oid[] = {1, 3, 6, 1, 2, 1, 17, 4, 3, 1};

static GSnmpAttribute dot1dTpFdbEntry_attr[] = {
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DTPFDBPORT, "dot1dTpFdbPort",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTpFdbEntry_t, dot1dTpFdbPort),
      0,
      0 },
    { 3, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DTPFDBSTATUS, "dot1dTpFdbStatus",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTpFdbEntry_t, dot1dTpFdbStatus),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dTpPortEntry_oid[] = {1, 3, 6, 1, 2, 1, 17, 4, 4, 1};

static GSnmpAttribute dot1dTpPortEntry_attr[] = {
    { 2, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DTPPORTMAXINFO, "dot1dTpPortMaxInfo",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTpPortEntry_t, dot1dTpPortMaxInfo),
      0,
      0 },
    { 3, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DTPPORTINFRAMES, "dot1dTpPortInFrames",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTpPortEntry_t, dot1dTpPortInFrames),
      0,
      0 },
    { 4, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DTPPORTOUTFRAMES, "dot1dTpPortOutFrames",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTpPortEntry_t, dot1dTpPortOutFrames),
      0,
      0 },
    { 5, G_SNMP_COUNTER32,
      BRIDGE_MIB_DOT1DTPPORTINDISCARDS, "dot1dTpPortInDiscards",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dTpPortEntry_t, dot1dTpPortInDiscards),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const dot1dStaticEntry_oid[] = {1, 3, 6, 1, 2, 1, 17, 5, 1, 1};

static GSnmpAttribute dot1dStaticEntry_attr[] = {
    { 3, G_SNMP_OCTETSTRING,
      BRIDGE_MIB_DOT1DSTATICALLOWEDTOGOTO, "dot1dStaticAllowedToGoTo",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStaticEntry_t, dot1dStaticAllowedToGoTo),
      G_STRUCT_OFFSET(bridge_mib_dot1dStaticEntry_t, _dot1dStaticAllowedToGoToLength),
      GSNMP_ATTR_FLAG_WRITABLE },
    { 4, G_SNMP_INTEGER32,
      BRIDGE_MIB_DOT1DSTATICSTATUS, "dot1dStaticStatus",
       NULL,
      G_STRUCT_OFFSET(bridge_mib_dot1dStaticEntry_t, dot1dStaticStatus),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};


bridge_mib_dot1dBase_t *
bridge_mib_new_dot1dBase()
{
    bridge_mib_dot1dBase_t *dot1dBase;

    dot1dBase = (bridge_mib_dot1dBase_t *) g_malloc0(sizeof(bridge_mib_dot1dBase_t) + sizeof(gpointer));
    return dot1dBase;
}

static bridge_mib_dot1dBase_t *
assign_dot1dBase(GSList *vbl)
{
    bridge_mib_dot1dBase_t *dot1dBase;
    char *p;

    dot1dBase = bridge_mib_new_dot1dBase();
    if (! dot1dBase) {
        return NULL;
    }

    p = (char *) dot1dBase + sizeof(bridge_mib_dot1dBase_t);
    * (GSList **) p = vbl;

    gsnmp_attr_assign(vbl, dot1dBase_oid, sizeof(dot1dBase_oid)/sizeof(guint32),
                      dot1dBase_attr, dot1dBase);

    return dot1dBase;
}

void
bridge_mib_get_dot1dBase(GSnmpSession *s, bridge_mib_dot1dBase_t **dot1dBase, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 1, 0};

    *dot1dBase = NULL;

    gsnmp_attr_get(s, &in, base, 9, 8, dot1dBase_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;
        }
        *dot1dBase = assign_dot1dBase(out);
    }
}

void
bridge_mib_free_dot1dBase(bridge_mib_dot1dBase_t *dot1dBase)
{
    GSList *vbl;
    char *p;

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

bridge_mib_dot1dBasePortEntry_t *
bridge_mib_new_dot1dBasePortEntry()
{
    bridge_mib_dot1dBasePortEntry_t *dot1dBasePortEntry;

    dot1dBasePortEntry = (bridge_mib_dot1dBasePortEntry_t *) g_malloc0(sizeof(bridge_mib_dot1dBasePortEntry_t) + sizeof(gpointer));
    return dot1dBasePortEntry;
}

static int
unpack_dot1dBasePortEntry(GSnmpVarBind *vb, bridge_mib_dot1dBasePortEntry_t *dot1dBasePortEntry)
{
    guint8 idx = 11;

    if (vb->id_len < idx) return -1;
    dot1dBasePortEntry->dot1dBasePort = vb->id[idx++];
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_dot1dBasePortEntry(guint32 *base, gint32 dot1dBasePort)
{
    guint8 idx = 11;

    base[idx++] = dot1dBasePort;
    return idx;
}

static bridge_mib_dot1dBasePortEntry_t *
assign_dot1dBasePortEntry(GSList *vbl)
{
    bridge_mib_dot1dBasePortEntry_t *dot1dBasePortEntry;
    char *p;

    dot1dBasePortEntry = bridge_mib_new_dot1dBasePortEntry();
    if (! dot1dBasePortEntry) {
        return NULL;
    }

    p = (char *) dot1dBasePortEntry + sizeof(bridge_mib_dot1dBasePortEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, dot1dBasePortEntry_oid, sizeof(dot1dBasePortEntry_oid)/sizeof(guint32),
                      dot1dBasePortEntry_attr, dot1dBasePortEntry);

    return dot1dBasePortEntry;
}

void
bridge_mib_get_dot1dBasePortTable(GSnmpSession *s, bridge_mib_dot1dBasePortEntry_t ***dot1dBasePortEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 1, 4, 1, 0};

    *dot1dBasePortEntry = NULL;

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

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

    if (out) {
        *dot1dBasePortEntry = (bridge_mib_dot1dBasePortEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(bridge_mib_dot1dBasePortEntry_t *));
        if (! *dot1dBasePortEntry) {
            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++) {
            (*dot1dBasePortEntry)[i] = assign_dot1dBasePortEntry(row->data);
        }
    }
}

void
bridge_mib_get_dot1dBasePortEntry(GSnmpSession *s, bridge_mib_dot1dBasePortEntry_t **dot1dBasePortEntry, gint32 dot1dBasePort, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dBasePortEntry_oid, sizeof(dot1dBasePortEntry_oid));
    len = pack_dot1dBasePortEntry(base, dot1dBasePort);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dBasePortEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *dot1dBasePortEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, dot1dBasePortEntry_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;
        }
        *dot1dBasePortEntry = assign_dot1dBasePortEntry(out);
    }
}

void
bridge_mib_free_dot1dBasePortEntry(bridge_mib_dot1dBasePortEntry_t *dot1dBasePortEntry)
{
    GSList *vbl;
    char *p;

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

void
bridge_mib_free_dot1dBasePortTable(bridge_mib_dot1dBasePortEntry_t **dot1dBasePortEntry)
{
    int i;

    if (dot1dBasePortEntry) {
        for (i = 0; dot1dBasePortEntry[i]; i++) {
            bridge_mib_free_dot1dBasePortEntry(dot1dBasePortEntry[i]);
        }
        g_free(dot1dBasePortEntry);
    }
}

bridge_mib_dot1dStp_t *
bridge_mib_new_dot1dStp()
{
    bridge_mib_dot1dStp_t *dot1dStp;

    dot1dStp = (bridge_mib_dot1dStp_t *) g_malloc0(sizeof(bridge_mib_dot1dStp_t) + sizeof(gpointer));
    return dot1dStp;
}

static bridge_mib_dot1dStp_t *
assign_dot1dStp(GSList *vbl)
{
    bridge_mib_dot1dStp_t *dot1dStp;
    char *p;

    dot1dStp = bridge_mib_new_dot1dStp();
    if (! dot1dStp) {
        return NULL;
    }

    p = (char *) dot1dStp + sizeof(bridge_mib_dot1dStp_t);
    * (GSList **) p = vbl;

    gsnmp_attr_assign(vbl, dot1dStp_oid, sizeof(dot1dStp_oid)/sizeof(guint32),
                      dot1dStp_attr, dot1dStp);

    return dot1dStp;
}

void
bridge_mib_get_dot1dStp(GSnmpSession *s, bridge_mib_dot1dStp_t **dot1dStp, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 2, 0};

    *dot1dStp = NULL;

    gsnmp_attr_get(s, &in, base, 9, 8, dot1dStp_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;
        }
        *dot1dStp = assign_dot1dStp(out);
    }
}

void
bridge_mib_set_dot1dStp(GSnmpSession *s, bridge_mib_dot1dStp_t *dot1dStp, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 2, 0, 0};

    gsnmp_attr_set(s, &in, base, 10, 8, dot1dStp_attr, mask, dot1dStp);

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

void
bridge_mib_free_dot1dStp(bridge_mib_dot1dStp_t *dot1dStp)
{
    GSList *vbl;
    char *p;

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

bridge_mib_dot1dStpPortEntry_t *
bridge_mib_new_dot1dStpPortEntry()
{
    bridge_mib_dot1dStpPortEntry_t *dot1dStpPortEntry;

    dot1dStpPortEntry = (bridge_mib_dot1dStpPortEntry_t *) g_malloc0(sizeof(bridge_mib_dot1dStpPortEntry_t) + sizeof(gpointer));
    return dot1dStpPortEntry;
}

static int
unpack_dot1dStpPortEntry(GSnmpVarBind *vb, bridge_mib_dot1dStpPortEntry_t *dot1dStpPortEntry)
{
    guint8 idx = 11;

    if (vb->id_len < idx) return -1;
    dot1dStpPortEntry->dot1dStpPort = vb->id[idx++];
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_dot1dStpPortEntry(guint32 *base, gint32 dot1dStpPort)
{
    guint8 idx = 11;

    base[idx++] = dot1dStpPort;
    return idx;
}

static bridge_mib_dot1dStpPortEntry_t *
assign_dot1dStpPortEntry(GSList *vbl)
{
    bridge_mib_dot1dStpPortEntry_t *dot1dStpPortEntry;
    char *p;

    dot1dStpPortEntry = bridge_mib_new_dot1dStpPortEntry();
    if (! dot1dStpPortEntry) {
        return NULL;
    }

    p = (char *) dot1dStpPortEntry + sizeof(bridge_mib_dot1dStpPortEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, dot1dStpPortEntry_oid, sizeof(dot1dStpPortEntry_oid)/sizeof(guint32),
                      dot1dStpPortEntry_attr, dot1dStpPortEntry);

    return dot1dStpPortEntry;
}

void
bridge_mib_get_dot1dStpPortTable(GSnmpSession *s, bridge_mib_dot1dStpPortEntry_t ***dot1dStpPortEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 2, 15, 1, 0};

    *dot1dStpPortEntry = NULL;

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

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

    if (out) {
        *dot1dStpPortEntry = (bridge_mib_dot1dStpPortEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(bridge_mib_dot1dStpPortEntry_t *));
        if (! *dot1dStpPortEntry) {
            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++) {
            (*dot1dStpPortEntry)[i] = assign_dot1dStpPortEntry(row->data);
        }
    }
}

void
bridge_mib_get_dot1dStpPortEntry(GSnmpSession *s, bridge_mib_dot1dStpPortEntry_t **dot1dStpPortEntry, gint32 dot1dStpPort, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dStpPortEntry_oid, sizeof(dot1dStpPortEntry_oid));
    len = pack_dot1dStpPortEntry(base, dot1dStpPort);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dStpPortEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *dot1dStpPortEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, dot1dStpPortEntry_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;
        }
        *dot1dStpPortEntry = assign_dot1dStpPortEntry(out);
    }
}

void
bridge_mib_set_dot1dStpPortEntry(GSnmpSession *s, bridge_mib_dot1dStpPortEntry_t *dot1dStpPortEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dStpPortEntry_oid, sizeof(dot1dStpPortEntry_oid));
    len = pack_dot1dStpPortEntry(base, dot1dStpPortEntry->dot1dStpPort);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dStpPortEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    gsnmp_attr_set(s, &in, base, len, 10, dot1dStpPortEntry_attr, mask, dot1dStpPortEntry);

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

void
bridge_mib_free_dot1dStpPortEntry(bridge_mib_dot1dStpPortEntry_t *dot1dStpPortEntry)
{
    GSList *vbl;
    char *p;

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

void
bridge_mib_free_dot1dStpPortTable(bridge_mib_dot1dStpPortEntry_t **dot1dStpPortEntry)
{
    int i;

    if (dot1dStpPortEntry) {
        for (i = 0; dot1dStpPortEntry[i]; i++) {
            bridge_mib_free_dot1dStpPortEntry(dot1dStpPortEntry[i]);
        }
        g_free(dot1dStpPortEntry);
    }
}

bridge_mib_dot1dTp_t *
bridge_mib_new_dot1dTp()
{
    bridge_mib_dot1dTp_t *dot1dTp;

    dot1dTp = (bridge_mib_dot1dTp_t *) g_malloc0(sizeof(bridge_mib_dot1dTp_t) + sizeof(gpointer));
    return dot1dTp;
}

static bridge_mib_dot1dTp_t *
assign_dot1dTp(GSList *vbl)
{
    bridge_mib_dot1dTp_t *dot1dTp;
    char *p;

    dot1dTp = bridge_mib_new_dot1dTp();
    if (! dot1dTp) {
        return NULL;
    }

    p = (char *) dot1dTp + sizeof(bridge_mib_dot1dTp_t);
    * (GSList **) p = vbl;

    gsnmp_attr_assign(vbl, dot1dTp_oid, sizeof(dot1dTp_oid)/sizeof(guint32),
                      dot1dTp_attr, dot1dTp);

    return dot1dTp;
}

void
bridge_mib_get_dot1dTp(GSnmpSession *s, bridge_mib_dot1dTp_t **dot1dTp, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 4, 0};

    *dot1dTp = NULL;

    gsnmp_attr_get(s, &in, base, 9, 8, dot1dTp_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;
        }
        *dot1dTp = assign_dot1dTp(out);
    }
}

void
bridge_mib_set_dot1dTp(GSnmpSession *s, bridge_mib_dot1dTp_t *dot1dTp, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 4, 0, 0};

    gsnmp_attr_set(s, &in, base, 10, 8, dot1dTp_attr, mask, dot1dTp);

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

void
bridge_mib_free_dot1dTp(bridge_mib_dot1dTp_t *dot1dTp)
{
    GSList *vbl;
    char *p;

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

bridge_mib_dot1dTpFdbEntry_t *
bridge_mib_new_dot1dTpFdbEntry()
{
    bridge_mib_dot1dTpFdbEntry_t *dot1dTpFdbEntry;

    dot1dTpFdbEntry = (bridge_mib_dot1dTpFdbEntry_t *) g_malloc0(sizeof(bridge_mib_dot1dTpFdbEntry_t) + sizeof(gpointer));
    return dot1dTpFdbEntry;
}

static int
unpack_dot1dTpFdbEntry(GSnmpVarBind *vb, bridge_mib_dot1dTpFdbEntry_t *dot1dTpFdbEntry)
{
    guint8 idx = 11;
    guint16 i, len;

    len = 6;
    if (vb->id_len < idx + len) return -1;
    if (len != 6) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        dot1dTpFdbEntry->dot1dTpFdbAddress[i] = vb->id[idx++];
    }
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_dot1dTpFdbEntry(guint32 *base, guchar *dot1dTpFdbAddress)
{
    guint8 idx = 11;
    guint16 i, len;

    len = 6;
    if (len != 6) return -1;
    for (i = 0; i < len; i++) {
        base[idx++] = dot1dTpFdbAddress[i];
        if (idx >= 128) return -1;
    }
    return idx;
}

static bridge_mib_dot1dTpFdbEntry_t *
assign_dot1dTpFdbEntry(GSList *vbl)
{
    bridge_mib_dot1dTpFdbEntry_t *dot1dTpFdbEntry;
    char *p;

    dot1dTpFdbEntry = bridge_mib_new_dot1dTpFdbEntry();
    if (! dot1dTpFdbEntry) {
        return NULL;
    }

    p = (char *) dot1dTpFdbEntry + sizeof(bridge_mib_dot1dTpFdbEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, dot1dTpFdbEntry_oid, sizeof(dot1dTpFdbEntry_oid)/sizeof(guint32),
                      dot1dTpFdbEntry_attr, dot1dTpFdbEntry);

    return dot1dTpFdbEntry;
}

void
bridge_mib_get_dot1dTpFdbTable(GSnmpSession *s, bridge_mib_dot1dTpFdbEntry_t ***dot1dTpFdbEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 4, 3, 1, 0};

    *dot1dTpFdbEntry = NULL;

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

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

    if (out) {
        *dot1dTpFdbEntry = (bridge_mib_dot1dTpFdbEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(bridge_mib_dot1dTpFdbEntry_t *));
        if (! *dot1dTpFdbEntry) {
            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++) {
            (*dot1dTpFdbEntry)[i] = assign_dot1dTpFdbEntry(row->data);
        }
    }
}

void
bridge_mib_get_dot1dTpFdbEntry(GSnmpSession *s, bridge_mib_dot1dTpFdbEntry_t **dot1dTpFdbEntry, guchar *dot1dTpFdbAddress, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dTpFdbEntry_oid, sizeof(dot1dTpFdbEntry_oid));
    len = pack_dot1dTpFdbEntry(base, dot1dTpFdbAddress);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dTpFdbEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *dot1dTpFdbEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, dot1dTpFdbEntry_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;
        }
        *dot1dTpFdbEntry = assign_dot1dTpFdbEntry(out);
    }
}

void
bridge_mib_free_dot1dTpFdbEntry(bridge_mib_dot1dTpFdbEntry_t *dot1dTpFdbEntry)
{
    GSList *vbl;
    char *p;

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

void
bridge_mib_free_dot1dTpFdbTable(bridge_mib_dot1dTpFdbEntry_t **dot1dTpFdbEntry)
{
    int i;

    if (dot1dTpFdbEntry) {
        for (i = 0; dot1dTpFdbEntry[i]; i++) {
            bridge_mib_free_dot1dTpFdbEntry(dot1dTpFdbEntry[i]);
        }
        g_free(dot1dTpFdbEntry);
    }
}

bridge_mib_dot1dTpPortEntry_t *
bridge_mib_new_dot1dTpPortEntry()
{
    bridge_mib_dot1dTpPortEntry_t *dot1dTpPortEntry;

    dot1dTpPortEntry = (bridge_mib_dot1dTpPortEntry_t *) g_malloc0(sizeof(bridge_mib_dot1dTpPortEntry_t) + sizeof(gpointer));
    return dot1dTpPortEntry;
}

static int
unpack_dot1dTpPortEntry(GSnmpVarBind *vb, bridge_mib_dot1dTpPortEntry_t *dot1dTpPortEntry)
{
    guint8 idx = 11;

    if (vb->id_len < idx) return -1;
    dot1dTpPortEntry->dot1dTpPort = vb->id[idx++];
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_dot1dTpPortEntry(guint32 *base, gint32 dot1dTpPort)
{
    guint8 idx = 11;

    base[idx++] = dot1dTpPort;
    return idx;
}

static bridge_mib_dot1dTpPortEntry_t *
assign_dot1dTpPortEntry(GSList *vbl)
{
    bridge_mib_dot1dTpPortEntry_t *dot1dTpPortEntry;
    char *p;

    dot1dTpPortEntry = bridge_mib_new_dot1dTpPortEntry();
    if (! dot1dTpPortEntry) {
        return NULL;
    }

    p = (char *) dot1dTpPortEntry + sizeof(bridge_mib_dot1dTpPortEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, dot1dTpPortEntry_oid, sizeof(dot1dTpPortEntry_oid)/sizeof(guint32),
                      dot1dTpPortEntry_attr, dot1dTpPortEntry);

    return dot1dTpPortEntry;
}

void
bridge_mib_get_dot1dTpPortTable(GSnmpSession *s, bridge_mib_dot1dTpPortEntry_t ***dot1dTpPortEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 4, 4, 1, 0};

    *dot1dTpPortEntry = NULL;

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

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

    if (out) {
        *dot1dTpPortEntry = (bridge_mib_dot1dTpPortEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(bridge_mib_dot1dTpPortEntry_t *));
        if (! *dot1dTpPortEntry) {
            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++) {
            (*dot1dTpPortEntry)[i] = assign_dot1dTpPortEntry(row->data);
        }
    }
}

void
bridge_mib_get_dot1dTpPortEntry(GSnmpSession *s, bridge_mib_dot1dTpPortEntry_t **dot1dTpPortEntry, gint32 dot1dTpPort, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dTpPortEntry_oid, sizeof(dot1dTpPortEntry_oid));
    len = pack_dot1dTpPortEntry(base, dot1dTpPort);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dTpPortEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *dot1dTpPortEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, dot1dTpPortEntry_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;
        }
        *dot1dTpPortEntry = assign_dot1dTpPortEntry(out);
    }
}

void
bridge_mib_free_dot1dTpPortEntry(bridge_mib_dot1dTpPortEntry_t *dot1dTpPortEntry)
{
    GSList *vbl;
    char *p;

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

void
bridge_mib_free_dot1dTpPortTable(bridge_mib_dot1dTpPortEntry_t **dot1dTpPortEntry)
{
    int i;

    if (dot1dTpPortEntry) {
        for (i = 0; dot1dTpPortEntry[i]; i++) {
            bridge_mib_free_dot1dTpPortEntry(dot1dTpPortEntry[i]);
        }
        g_free(dot1dTpPortEntry);
    }
}

bridge_mib_dot1dStaticEntry_t *
bridge_mib_new_dot1dStaticEntry()
{
    bridge_mib_dot1dStaticEntry_t *dot1dStaticEntry;

    dot1dStaticEntry = (bridge_mib_dot1dStaticEntry_t *) g_malloc0(sizeof(bridge_mib_dot1dStaticEntry_t) + sizeof(gpointer));
    return dot1dStaticEntry;
}

static int
unpack_dot1dStaticEntry(GSnmpVarBind *vb, bridge_mib_dot1dStaticEntry_t *dot1dStaticEntry)
{
    guint8 idx = 11;
    guint16 i, len;

    len = 6;
    if (vb->id_len < idx + len) return -1;
    if (len != 6) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        dot1dStaticEntry->dot1dStaticAddress[i] = vb->id[idx++];
    }
    if (vb->id_len < idx) return -1;
    dot1dStaticEntry->dot1dStaticReceivePort = vb->id[idx++];
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_dot1dStaticEntry(guint32 *base, guchar *dot1dStaticAddress, gint32 dot1dStaticReceivePort)
{
    guint8 idx = 11;
    guint16 i, len;

    len = 6;
    if (len != 6) return -1;
    for (i = 0; i < len; i++) {
        base[idx++] = dot1dStaticAddress[i];
        if (idx >= 128) return -1;
    }
    base[idx++] = dot1dStaticReceivePort;
    return idx;
}

static bridge_mib_dot1dStaticEntry_t *
assign_dot1dStaticEntry(GSList *vbl)
{
    bridge_mib_dot1dStaticEntry_t *dot1dStaticEntry;
    char *p;

    dot1dStaticEntry = bridge_mib_new_dot1dStaticEntry();
    if (! dot1dStaticEntry) {
        return NULL;
    }

    p = (char *) dot1dStaticEntry + sizeof(bridge_mib_dot1dStaticEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, dot1dStaticEntry_oid, sizeof(dot1dStaticEntry_oid)/sizeof(guint32),
                      dot1dStaticEntry_attr, dot1dStaticEntry);

    return dot1dStaticEntry;
}

void
bridge_mib_get_dot1dStaticTable(GSnmpSession *s, bridge_mib_dot1dStaticEntry_t ***dot1dStaticEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 17, 5, 1, 1, 0};

    *dot1dStaticEntry = NULL;

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

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

    if (out) {
        *dot1dStaticEntry = (bridge_mib_dot1dStaticEntry_t **) g_malloc0((g_slist_length(out) + 1) * sizeof(bridge_mib_dot1dStaticEntry_t *));
        if (! *dot1dStaticEntry) {
            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++) {
            (*dot1dStaticEntry)[i] = assign_dot1dStaticEntry(row->data);
        }
    }
}

void
bridge_mib_get_dot1dStaticEntry(GSnmpSession *s, bridge_mib_dot1dStaticEntry_t **dot1dStaticEntry, guchar *dot1dStaticAddress, gint32 dot1dStaticReceivePort, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dStaticEntry_oid, sizeof(dot1dStaticEntry_oid));
    len = pack_dot1dStaticEntry(base, dot1dStaticAddress, dot1dStaticReceivePort);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dStaticEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *dot1dStaticEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 10, dot1dStaticEntry_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;
        }
        *dot1dStaticEntry = assign_dot1dStaticEntry(out);
    }
}

void
bridge_mib_set_dot1dStaticEntry(GSnmpSession *s, bridge_mib_dot1dStaticEntry_t *dot1dStaticEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, dot1dStaticEntry_oid, sizeof(dot1dStaticEntry_oid));
    len = pack_dot1dStaticEntry(base, dot1dStaticEntry->dot1dStaticAddress, dot1dStaticEntry->dot1dStaticReceivePort);
    if (len < 0) {
        g_warning("%s: invalid index values", "dot1dStaticEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    gsnmp_attr_set(s, &in, base, len, 10, dot1dStaticEntry_attr, mask, dot1dStaticEntry);

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

void
bridge_mib_free_dot1dStaticEntry(bridge_mib_dot1dStaticEntry_t *dot1dStaticEntry)
{
    GSList *vbl;
    char *p;

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

void
bridge_mib_free_dot1dStaticTable(bridge_mib_dot1dStaticEntry_t **dot1dStaticEntry)
{
    int i;

    if (dot1dStaticEntry) {
        for (i = 0; dot1dStaticEntry[i]; i++) {
            bridge_mib_free_dot1dStaticEntry(dot1dStaticEntry[i]);
        }
        g_free(dot1dStaticEntry);
    }
}


