/*							-- DO NOT EDIT --
 * This file has been generated by smidump
 * version 0.3.1 for the scli package.
 *
 * Derived from OLD-CISCO-IP-MIB:
 *
 * $Id: old-cisco-ip-mib.c,v 1.5 2002/03/27 13:48:21 schoenw Exp $
 */

#include "old-cisco-ip-mib.h"

static guint16 locIPWho_constraints[] = {4, 4, 0, 0};
static guint16 locIPHelper_constraints[] = {4, 4, 0, 0};
static guint16 locRtMask_constraints[] = {4, 4, 0, 0};


static guint32 const lip_oid[] = {1, 3, 6, 1, 4, 1, 9, 2, 4};

static GSnmpAttribute lip_attr[] = {
    { 4, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTTHRESH, "actThresh",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, actThresh),
      0,
      0 },
    { 5, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTLOSTPKTS, "actLostPkts",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, actLostPkts),
      0,
      0 },
    { 6, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTLOSTBYTS, "actLostByts",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, actLostByts),
      0,
      0 },
    { 8, G_SNMP_TIMETICKS,
      OLD_CISCO_IP_MIB_ACTAGE, "actAge",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, actAge),
      0,
      0 },
    { 10, G_SNMP_TIMETICKS,
      OLD_CISCO_IP_MIB_CKACTAGE, "ckactAge",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, ckactAge),
      0,
      0 },
    { 11, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTCHECKPOINT, "actCheckPoint",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, actCheckPoint),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 12, G_SNMP_COUNTER32,
      OLD_CISCO_IP_MIB_IPNOACCESS, "ipNoaccess",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lip_t, ipNoaccess),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const lipAddrEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 1, 1};

static GSnmpAttribute lipAddrEntry_attr[] = {
    { 1, G_SNMP_OCTETSTRING,
      OLD_CISCO_IP_MIB_LOCIPHOW, "locIPHow",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, locIPHow),
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, _locIPHowLength),
      0 },
    { 2, G_SNMP_IPADDRESS,
      OLD_CISCO_IP_MIB_LOCIPWHO, "locIPWho",
       locIPWho_constraints,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, locIPWho),
      0,
      0 },
    { 3, G_SNMP_IPADDRESS,
      OLD_CISCO_IP_MIB_LOCIPHELPER, "locIPHelper",
       locIPHelper_constraints,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, locIPHelper),
      0,
      0 },
    { 4, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_LOCIPSECURITY, "locIPSecurity",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, locIPSecurity),
      0,
      0 },
    { 5, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_LOCIPREDIRECTS, "locIPRedirects",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, locIPRedirects),
      0,
      0 },
    { 6, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_LOCIPUNREACH, "locIPUnreach",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAddrEntry_t, locIPUnreach),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const lipRouteEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 2, 1};

static GSnmpAttribute lipRouteEntry_attr[] = {
    { 1, G_SNMP_IPADDRESS,
      OLD_CISCO_IP_MIB_LOCRTMASK, "locRtMask",
       locRtMask_constraints,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipRouteEntry_t, locRtMask),
      0,
      0 },
    { 2, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_LOCRTCOUNT, "locRtCount",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipRouteEntry_t, locRtCount),
      0,
      0 },
    { 3, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_LOCRTUSES, "locRtUses",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipRouteEntry_t, locRtUses),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const lipAccountEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 7, 1};

static GSnmpAttribute lipAccountEntry_attr[] = {
    { 3, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTPKTS, "actPkts",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAccountEntry_t, actPkts),
      0,
      0 },
    { 4, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTBYTS, "actByts",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAccountEntry_t, actByts),
      0,
      0 },
    { 5, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_ACTVIOLATION, "actViolation",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipAccountEntry_t, actViolation),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const lipCkAccountEntry_oid[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 9, 1};

static GSnmpAttribute lipCkAccountEntry_attr[] = {
    { 3, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_CKACTPKTS, "ckactPkts",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipCkAccountEntry_t, ckactPkts),
      0,
      0 },
    { 4, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_CKACTBYTS, "ckactByts",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipCkAccountEntry_t, ckactByts),
      0,
      0 },
    { 5, G_SNMP_INTEGER32,
      OLD_CISCO_IP_MIB_CKACTVIOLATION, "ckactViolation",
       NULL,
      G_STRUCT_OFFSET(old_cisco_ip_mib_lipCkAccountEntry_t, ckactViolation),
      0,
      0 },
    { 0, 0, 0, NULL }
};


old_cisco_ip_mib_lip_t *
old_cisco_ip_mib_new_lip()
{
    old_cisco_ip_mib_lip_t *lip;

    lip = (old_cisco_ip_mib_lip_t *) g_malloc0(sizeof(old_cisco_ip_mib_lip_t) + sizeof(gpointer));
    return lip;
}

static old_cisco_ip_mib_lip_t *
assign_lip(GSList *vbl)
{
    old_cisco_ip_mib_lip_t *lip;
    char *p;

    lip = old_cisco_ip_mib_new_lip();
    if (! lip) {
        return NULL;
    }

    p = (char *) lip + sizeof(old_cisco_ip_mib_lip_t);
    * (GSList **) p = vbl;

    gsnmp_attr_assign(vbl, lip_oid, sizeof(lip_oid)/sizeof(guint32),
                      lip_attr, lip);

    return lip;
}

void
old_cisco_ip_mib_get_lip(GSnmpSession *s, old_cisco_ip_mib_lip_t **lip, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 0};

    *lip = NULL;

    gsnmp_attr_get(s, &in, base, 10, 9, lip_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;
        }
        *lip = assign_lip(out);
    }
}

void
old_cisco_ip_mib_set_lip(GSnmpSession *s, old_cisco_ip_mib_lip_t *lip, gint mask)
{
    GSList *in = NULL, *out = NULL;
    static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 0, 0};

    gsnmp_attr_set(s, &in, base, 11, 9, lip_attr, mask, lip);

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

void
old_cisco_ip_mib_free_lip(old_cisco_ip_mib_lip_t *lip)
{
    GSList *vbl;
    char *p;

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

old_cisco_ip_mib_lipAddrEntry_t *
old_cisco_ip_mib_new_lipAddrEntry()
{
    old_cisco_ip_mib_lipAddrEntry_t *lipAddrEntry;

    lipAddrEntry = (old_cisco_ip_mib_lipAddrEntry_t *) g_malloc0(sizeof(old_cisco_ip_mib_lipAddrEntry_t) + sizeof(gpointer));
    return lipAddrEntry;
}

static int
unpack_lipAddrEntry(GSnmpVarBind *vb, old_cisco_ip_mib_lipAddrEntry_t *lipAddrEntry)
{
    guint8 idx = 12;
    guint16 i, len;

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

static int
pack_lipAddrEntry(guint32 *base, guchar *ipAdEntAddr)
{
    guint8 idx = 12;
    guint16 i, len;

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

static old_cisco_ip_mib_lipAddrEntry_t *
assign_lipAddrEntry(GSList *vbl)
{
    old_cisco_ip_mib_lipAddrEntry_t *lipAddrEntry;
    char *p;

    lipAddrEntry = old_cisco_ip_mib_new_lipAddrEntry();
    if (! lipAddrEntry) {
        return NULL;
    }

    p = (char *) lipAddrEntry + sizeof(old_cisco_ip_mib_lipAddrEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, lipAddrEntry_oid, sizeof(lipAddrEntry_oid)/sizeof(guint32),
                      lipAddrEntry_attr, lipAddrEntry);

    return lipAddrEntry;
}

void
old_cisco_ip_mib_get_lipAddrTable(GSnmpSession *s, old_cisco_ip_mib_lipAddrEntry_t ***lipAddrEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 1, 1, 0};

    *lipAddrEntry = NULL;

    gsnmp_attr_get(s, &in, base, 12, 11, lipAddrEntry_attr, mask);

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

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

void
old_cisco_ip_mib_get_lipAddrEntry(GSnmpSession *s, old_cisco_ip_mib_lipAddrEntry_t **lipAddrEntry, guchar *ipAdEntAddr, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, lipAddrEntry_oid, sizeof(lipAddrEntry_oid));
    len = pack_lipAddrEntry(base, ipAdEntAddr);
    if (len < 0) {
        g_warning("%s: invalid index values", "lipAddrEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *lipAddrEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 11, lipAddrEntry_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;
        }
        *lipAddrEntry = assign_lipAddrEntry(out);
    }
}

void
old_cisco_ip_mib_free_lipAddrEntry(old_cisco_ip_mib_lipAddrEntry_t *lipAddrEntry)
{
    GSList *vbl;
    char *p;

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

void
old_cisco_ip_mib_free_lipAddrTable(old_cisco_ip_mib_lipAddrEntry_t **lipAddrEntry)
{
    int i;

    if (lipAddrEntry) {
        for (i = 0; lipAddrEntry[i]; i++) {
            old_cisco_ip_mib_free_lipAddrEntry(lipAddrEntry[i]);
        }
        g_free(lipAddrEntry);
    }
}

old_cisco_ip_mib_lipRouteEntry_t *
old_cisco_ip_mib_new_lipRouteEntry()
{
    old_cisco_ip_mib_lipRouteEntry_t *lipRouteEntry;

    lipRouteEntry = (old_cisco_ip_mib_lipRouteEntry_t *) g_malloc0(sizeof(old_cisco_ip_mib_lipRouteEntry_t) + sizeof(gpointer));
    return lipRouteEntry;
}

static int
unpack_lipRouteEntry(GSnmpVarBind *vb, old_cisco_ip_mib_lipRouteEntry_t *lipRouteEntry)
{
    guint8 idx = 12;
    guint16 i, len;

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

static int
pack_lipRouteEntry(guint32 *base, guchar *ipRouteDest)
{
    guint8 idx = 12;
    guint16 i, len;

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

static old_cisco_ip_mib_lipRouteEntry_t *
assign_lipRouteEntry(GSList *vbl)
{
    old_cisco_ip_mib_lipRouteEntry_t *lipRouteEntry;
    char *p;

    lipRouteEntry = old_cisco_ip_mib_new_lipRouteEntry();
    if (! lipRouteEntry) {
        return NULL;
    }

    p = (char *) lipRouteEntry + sizeof(old_cisco_ip_mib_lipRouteEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, lipRouteEntry_oid, sizeof(lipRouteEntry_oid)/sizeof(guint32),
                      lipRouteEntry_attr, lipRouteEntry);

    return lipRouteEntry;
}

void
old_cisco_ip_mib_get_lipRouteTable(GSnmpSession *s, old_cisco_ip_mib_lipRouteEntry_t ***lipRouteEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 2, 1, 0};

    *lipRouteEntry = NULL;

    gsnmp_attr_get(s, &in, base, 12, 11, lipRouteEntry_attr, mask);

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

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

void
old_cisco_ip_mib_get_lipRouteEntry(GSnmpSession *s, old_cisco_ip_mib_lipRouteEntry_t **lipRouteEntry, guchar *ipRouteDest, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, lipRouteEntry_oid, sizeof(lipRouteEntry_oid));
    len = pack_lipRouteEntry(base, ipRouteDest);
    if (len < 0) {
        g_warning("%s: invalid index values", "lipRouteEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *lipRouteEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 11, lipRouteEntry_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;
        }
        *lipRouteEntry = assign_lipRouteEntry(out);
    }
}

void
old_cisco_ip_mib_free_lipRouteEntry(old_cisco_ip_mib_lipRouteEntry_t *lipRouteEntry)
{
    GSList *vbl;
    char *p;

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

void
old_cisco_ip_mib_free_lipRouteTable(old_cisco_ip_mib_lipRouteEntry_t **lipRouteEntry)
{
    int i;

    if (lipRouteEntry) {
        for (i = 0; lipRouteEntry[i]; i++) {
            old_cisco_ip_mib_free_lipRouteEntry(lipRouteEntry[i]);
        }
        g_free(lipRouteEntry);
    }
}

old_cisco_ip_mib_lipAccountEntry_t *
old_cisco_ip_mib_new_lipAccountEntry()
{
    old_cisco_ip_mib_lipAccountEntry_t *lipAccountEntry;

    lipAccountEntry = (old_cisco_ip_mib_lipAccountEntry_t *) g_malloc0(sizeof(old_cisco_ip_mib_lipAccountEntry_t) + sizeof(gpointer));
    return lipAccountEntry;
}

static int
unpack_lipAccountEntry(GSnmpVarBind *vb, old_cisco_ip_mib_lipAccountEntry_t *lipAccountEntry)
{
    guint8 idx = 12;
    guint16 i, len;

    len = 4;
    if (vb->id_len < idx + len) return -1;
    if (len != 4) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        lipAccountEntry->actSrc[i] = vb->id[idx++];
    }
    len = 4;
    if (vb->id_len < idx + len) return -1;
    if (len != 4) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        lipAccountEntry->actDst[i] = vb->id[idx++];
    }
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_lipAccountEntry(guint32 *base, guchar *actSrc, guchar *actDst)
{
    guint8 idx = 12;
    guint16 i, len;

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

static old_cisco_ip_mib_lipAccountEntry_t *
assign_lipAccountEntry(GSList *vbl)
{
    old_cisco_ip_mib_lipAccountEntry_t *lipAccountEntry;
    char *p;

    lipAccountEntry = old_cisco_ip_mib_new_lipAccountEntry();
    if (! lipAccountEntry) {
        return NULL;
    }

    p = (char *) lipAccountEntry + sizeof(old_cisco_ip_mib_lipAccountEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, lipAccountEntry_oid, sizeof(lipAccountEntry_oid)/sizeof(guint32),
                      lipAccountEntry_attr, lipAccountEntry);

    return lipAccountEntry;
}

void
old_cisco_ip_mib_get_lipAccountingTable(GSnmpSession *s, old_cisco_ip_mib_lipAccountEntry_t ***lipAccountEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 7, 1, 0};

    *lipAccountEntry = NULL;

    gsnmp_attr_get(s, &in, base, 12, 11, lipAccountEntry_attr, mask);

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

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

void
old_cisco_ip_mib_get_lipAccountEntry(GSnmpSession *s, old_cisco_ip_mib_lipAccountEntry_t **lipAccountEntry, guchar *actSrc, guchar *actDst, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, lipAccountEntry_oid, sizeof(lipAccountEntry_oid));
    len = pack_lipAccountEntry(base, actSrc, actDst);
    if (len < 0) {
        g_warning("%s: invalid index values", "lipAccountEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *lipAccountEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 11, lipAccountEntry_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;
        }
        *lipAccountEntry = assign_lipAccountEntry(out);
    }
}

void
old_cisco_ip_mib_free_lipAccountEntry(old_cisco_ip_mib_lipAccountEntry_t *lipAccountEntry)
{
    GSList *vbl;
    char *p;

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

void
old_cisco_ip_mib_free_lipAccountingTable(old_cisco_ip_mib_lipAccountEntry_t **lipAccountEntry)
{
    int i;

    if (lipAccountEntry) {
        for (i = 0; lipAccountEntry[i]; i++) {
            old_cisco_ip_mib_free_lipAccountEntry(lipAccountEntry[i]);
        }
        g_free(lipAccountEntry);
    }
}

old_cisco_ip_mib_lipCkAccountEntry_t *
old_cisco_ip_mib_new_lipCkAccountEntry()
{
    old_cisco_ip_mib_lipCkAccountEntry_t *lipCkAccountEntry;

    lipCkAccountEntry = (old_cisco_ip_mib_lipCkAccountEntry_t *) g_malloc0(sizeof(old_cisco_ip_mib_lipCkAccountEntry_t) + sizeof(gpointer));
    return lipCkAccountEntry;
}

static int
unpack_lipCkAccountEntry(GSnmpVarBind *vb, old_cisco_ip_mib_lipCkAccountEntry_t *lipCkAccountEntry)
{
    guint8 idx = 12;
    guint16 i, len;

    len = 4;
    if (vb->id_len < idx + len) return -1;
    if (len != 4) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        lipCkAccountEntry->ckactSrc[i] = vb->id[idx++];
    }
    len = 4;
    if (vb->id_len < idx + len) return -1;
    if (len != 4) return -1;
    if (vb->id_len < idx + len) return -1;
    for (i = 0; i < len; i++) {
        lipCkAccountEntry->ckactDst[i] = vb->id[idx++];
    }
    if (vb->id_len > idx) return -1;
    return 0;
}

static int
pack_lipCkAccountEntry(guint32 *base, guchar *ckactSrc, guchar *ckactDst)
{
    guint8 idx = 12;
    guint16 i, len;

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

static old_cisco_ip_mib_lipCkAccountEntry_t *
assign_lipCkAccountEntry(GSList *vbl)
{
    old_cisco_ip_mib_lipCkAccountEntry_t *lipCkAccountEntry;
    char *p;

    lipCkAccountEntry = old_cisco_ip_mib_new_lipCkAccountEntry();
    if (! lipCkAccountEntry) {
        return NULL;
    }

    p = (char *) lipCkAccountEntry + sizeof(old_cisco_ip_mib_lipCkAccountEntry_t);
    * (GSList **) p = vbl;

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

    gsnmp_attr_assign(vbl, lipCkAccountEntry_oid, sizeof(lipCkAccountEntry_oid)/sizeof(guint32),
                      lipCkAccountEntry_attr, lipCkAccountEntry);

    return lipCkAccountEntry;
}

void
old_cisco_ip_mib_get_lipCkAccountingTable(GSnmpSession *s, old_cisco_ip_mib_lipCkAccountEntry_t ***lipCkAccountEntry, gint mask)
{
    GSList *in = NULL, *out = NULL;
    GSList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 4, 1, 9, 2, 4, 9, 1, 0};

    *lipCkAccountEntry = NULL;

    gsnmp_attr_get(s, &in, base, 12, 11, lipCkAccountEntry_attr, mask);

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

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

void
old_cisco_ip_mib_get_lipCkAccountEntry(GSnmpSession *s, old_cisco_ip_mib_lipCkAccountEntry_t **lipCkAccountEntry, guchar *ckactSrc, guchar *ckactDst, gint mask)
{
    GSList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memset(base, 0, sizeof(base));
    memcpy(base, lipCkAccountEntry_oid, sizeof(lipCkAccountEntry_oid));
    len = pack_lipCkAccountEntry(base, ckactSrc, ckactDst);
    if (len < 0) {
        g_warning("%s: invalid index values", "lipCkAccountEntry");
        s->error_status = G_SNMP_ERR_INTERNAL;
        return;
    }

    *lipCkAccountEntry = NULL;

    gsnmp_attr_get(s, &in, base, len, 11, lipCkAccountEntry_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;
        }
        *lipCkAccountEntry = assign_lipCkAccountEntry(out);
    }
}

void
old_cisco_ip_mib_free_lipCkAccountEntry(old_cisco_ip_mib_lipCkAccountEntry_t *lipCkAccountEntry)
{
    GSList *vbl;
    char *p;

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

void
old_cisco_ip_mib_free_lipCkAccountingTable(old_cisco_ip_mib_lipCkAccountEntry_t **lipCkAccountEntry)
{
    int i;

    if (lipCkAccountEntry) {
        for (i = 0; lipCkAccountEntry[i]; i++) {
            old_cisco_ip_mib_free_lipCkAccountEntry(lipCkAccountEntry[i]);
        }
        g_free(lipCkAccountEntry);
    }
}


