summaryrefslogtreecommitdiff
path: root/agent/mibgroup/udp-mib/data_access/udp_endpoint_common.c
blob: 63f85494f64ee2e656a3fb4e716a7ed00e459491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
 *  UDP-MIB endpoint architecture support
 *
 * $Id$
 */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include "udp-mib/udpEndpointTable/udpEndpointTable_constants.h"

#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/data_access/ipaddress.h>
#include <net-snmp/data_access/udp_endpoint.h>

#include "udp_endpoint_private.h"

netsnmp_feature_child_of(udp_endpoint_common, libnetsnmpmibs)

netsnmp_feature_child_of(udp_endpoint_entry_create, udp_endpoint_common)

/**---------------------------------------------------------------------*/
/*
 * local static vars
 */


/**---------------------------------------------------------------------*/
/*
 * initialization
 */

/**---------------------------------------------------------------------*/
/*
 * container functions
 */
/**
 * initialize udp_endpoint container
 */
netsnmp_container *
netsnmp_access_udp_endpoint_container_init(u_int flags)
{
    netsnmp_container *container;

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

    /*
     * create the containers.
     */
    container = netsnmp_container_find("access_udp_endpoint:table_container");
    if (NULL == container)
        return NULL;

    return container;
}

/**
 * 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;
}

void
netsnmp_access_udp_endpoint_container_free(netsnmp_container *container,
                                           u_int free_flags)
{
    DEBUGMSGTL(("access:udp_endpoint:container", "free\n"));

    if (NULL == container) {
        snmp_log(LOG_ERR,
                 "invalid container for netsnmp_access_udp_endpoint_free\n");
        return;
    }

    if(! (free_flags & NETSNMP_ACCESS_UDP_ENDPOINT_FREE_DONT_CLEAR)) {
        /*
         * free all items.
         */
        CONTAINER_CLEAR(container,
                        (netsnmp_container_obj_func*)
                        netsnmp_access_udp_endpoint_entry_free,
                        NULL);
    }

    if(! (free_flags & NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER))
        CONTAINER_FREE(container);
}

/**---------------------------------------------------------------------*/
/*
 * entry functions
 */
/**
 */
#ifndef NETSNMP_FEATURE_REMOVE_UDP_ENDPOINT_ENTRY_CREATE
netsnmp_udp_endpoint_entry *
netsnmp_access_udp_endpoint_entry_create(void)
{
    netsnmp_udp_endpoint_entry *entry =
        SNMP_MALLOC_TYPEDEF(netsnmp_udp_endpoint_entry);

    DEBUGMSGTL(("access:udp_endpoint:entry", "create\n"));

    if(NULL == entry)
        return NULL;

    entry->oid_index.len = 1;
    entry->oid_index.oids = (oid *) & entry->index;

    return entry;
}
#endif /* NETSNMP_FEATURE_REMOVE_UDP_ENDPOINT_ENTRY_CREATE */

/**
 */
void
netsnmp_access_udp_endpoint_entry_free(netsnmp_udp_endpoint_entry * entry)
{
    DEBUGMSGTL(("access:udp_endpoint:entry", "free\n"));

    if (NULL == entry)
        return;

    /*
     * SNMP_FREE not needed, for any of these, 
     * since the whole entry is about to be freed
     */

    free(entry);
}