Esempio n. 1
0
/**
 *
 * @retval  0 no errors
 * @retval !0 errors
 */
int
netsnmp_arch_udp_endpoint_container_load(netsnmp_container *container,
                                    u_int load_flags )
{
    int rc = 0;

    /* Setup the pid_from_inode table, and fill it.*/
    netsnmp_get_pid_from_inode_init();

    rc = _load4(container, load_flags);
    if(rc < 0) {
        u_int flags = NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER;
        netsnmp_access_udp_endpoint_container_free(container, flags);
        return rc;
    }

#if defined (NETSNMP_ENABLE_IPV6)
    rc = _load6(container, load_flags);
    if(rc < 0) {
        u_int flags = NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER;
        netsnmp_access_udp_endpoint_container_free(container, flags);
        return rc;
    }
#endif

    return 0;
}
Esempio n. 2
0
/**
 * load udp_endpoint information in specified container
 *
 * @param container empty container, or NULL to have one created for you
 * @param load_flags flags to modify behaviour.
 *
 * @retval NULL  error
 * @retval !NULL pointer to container
 */
netsnmp_container*
netsnmp_access_udp_endpoint_container_load(netsnmp_container* container,
                                           u_int load_flags)
{
    int rc;

    DEBUGMSGTL(("access:udp_endpoint:container", "load\n"));

    if (NULL == container)
        container = netsnmp_access_udp_endpoint_container_init(0);
    if (NULL == container) {
        snmp_log(LOG_ERR,
                 "no container specified/found for access_udp_endpoint\n");
        return NULL;
    }

    rc =
        netsnmp_arch_udp_endpoint_container_load(container, load_flags);
    if (0 != rc) {
        netsnmp_access_udp_endpoint_container_free(container, 0);
        container = NULL;
    }

    return container;
}
int 
netsnmp_arch_udp_endpoint_container_load(netsnmp_container * container, 
                    u_int load_flag)
{
    int rc;

    if ((rc = _load_udp_endpoint_table_v4(container, load_flag)) != 0) {
        u_int flag = NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER;
        netsnmp_access_udp_endpoint_container_free(container, flag);
        return (rc);
    }
#if defined(NETSNMP_ENABLE_IPV6) && defined(SOLARIS_HAVE_IPV6_MIB_SUPPORT)
    if ((rc = _load_udp_endpoint_table_v6(container, load_flag)) != 0) {
        u_int flag = NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER;
        netsnmp_access_udp_endpoint_container_free(container, flag);
        return (rc);
    }
#endif
    return (0);
}
/**
 *
 * @retval  0 no errors
 * @retval !0 errors
 */
int
netsnmp_arch_udp_endpoint_container_load(netsnmp_container *container,
        u_int load_flags )
{
    int rc = 0;

    rc = _load4(container, load_flags);
    if(rc < 0) {
        u_int flags = NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER;
        netsnmp_access_udp_endpoint_container_free(container, flags);
        return rc;
    }

#if defined (NETSNMP_ENABLE_IPV6)
    rc = _load6(container, load_flags);
    if(rc < 0) {
        u_int flags = NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER;
        netsnmp_access_udp_endpoint_container_free(container, flags);
        return rc;
    }
#endif

    return 0;
}
int
udpEndpointTable_container_load(netsnmp_container *container)
{
    udpEndpointTable_rowreq_ctx *rowreq_ctx;
    netsnmp_container *ep_c;
    netsnmp_iterator *ep_it;
    netsnmp_udp_endpoint_entry *ep;

    /*
     * temporary storage for index values
     */
    u_long	udpEndpointLocalAddressType;
    u_long	udpEndpointRemoteAddressType;

    DEBUGMSGTL(("verbose:udpEndpointTable:udpEndpointTable_container_load",
                "called\n"));

    /*
     * TODO:351:M: |-> Load/update data in the udpEndpointTable container.
     * loop over your udpEndpointTable data, allocate a rowreq context,
     * set the index(es) [and data, optionally] and insert into
     * the container.
     */
    ep_c = netsnmp_access_udp_endpoint_container_load(NULL, 0);
    if (NULL == ep_c)
        return MFD_RESOURCE_UNAVAILABLE;
    ep_it = CONTAINER_ITERATOR(ep_c);
    if (NULL == ep_c) {
        netsnmp_access_udp_endpoint_container_free(ep_c, 0);
        return MFD_RESOURCE_UNAVAILABLE;
    }
    for (ep = (netsnmp_udp_endpoint_entry*)ITERATOR_FIRST(ep_it); ep;
         ep = (netsnmp_udp_endpoint_entry*)ITERATOR_NEXT (ep_it)) {

        /*
         * TODO:352:M: |   |-> set indexes in new udpEndpointTable rowreq context.
         */
        rowreq_ctx = udpEndpointTable_allocate_rowreq_ctx();
        if (NULL == rowreq_ctx) {
            snmp_log(LOG_ERR, "memory allocation failed\n");
            return MFD_RESOURCE_UNAVAILABLE;
        }
        udpEndpointLocalAddressType = _address_type_from_len(ep->loc_addr_len);
	udpEndpointRemoteAddressType = _address_type_from_len(ep->rmt_addr_len);
        if (MFD_SUCCESS !=
            udpEndpointTable_indexes_set(rowreq_ctx,
                                         udpEndpointLocalAddressType,
                                         (char *) ep->loc_addr,
                                         ep->loc_addr_len,
                                         ep->loc_port,
                                         udpEndpointRemoteAddressType,
                                         (char *) ep->rmt_addr,
                                         ep->rmt_addr_len,
                                         ep->rmt_port,
                                         ep->instance,
                                         ep->pid)) {
            snmp_log(LOG_ERR,
                     "error setting index while loading "
                     "udpEndpointTable data.\n");
            udpEndpointTable_release_rowreq_ctx(rowreq_ctx);
            continue;
        }

        /*
         * TODO:352:r: |   |-> populate udpEndpointTable data context.
         * Populate data context here. (optionally, delay until row prep)
         */
        /*
         * non-TRANSIENT data: no need to copy. set pointer to data 
         */

        /*
         * insert into table container
         */
        CONTAINER_INSERT(container, rowreq_ctx);
    }

    ITERATOR_RELEASE(ep_it);

    netsnmp_access_udp_endpoint_container_free(ep_c, 0);


    DEBUGMSGT(("verbose:udpEndpointTable:udpEndpointTable_container_load",
               "inserted %d records\n", (int)CONTAINER_SIZE(container)));

    return MFD_SUCCESS;
}                               /* udpEndpointTable_container_load */