~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/udp-mib/data_access/udp_endpoint_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20070510222023-3fr07xb9i17xvq32
Tags: upstream-5.3.1
ImportĀ upstreamĀ versionĀ 5.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  UDP-MIB endpoint architecture support
 
3
 *
 
4
 * $Id: udp_endpoint_common.c,v 1.2 2005/12/11 17:55:01 rstory Exp $
 
5
 */
 
6
#include <net-snmp/net-snmp-config.h>
 
7
#include <net-snmp/net-snmp-includes.h>
 
8
#include "udp-mib/udpEndpointTable/udpEndpointTable_constants.h"
 
9
 
 
10
#include <net-snmp/agent/net-snmp-agent-includes.h>
 
11
#include <net-snmp/data_access/ipaddress.h>
 
12
#include <net-snmp/data_access/udp_endpoint.h>
 
13
 
 
14
#include "udp_endpoint_private.h"
 
15
 
 
16
/**---------------------------------------------------------------------*/
 
17
/*
 
18
 * local static vars
 
19
 */
 
20
 
 
21
 
 
22
/**---------------------------------------------------------------------*/
 
23
/*
 
24
 * initialization
 
25
 */
 
26
 
 
27
void
 
28
netsnmp_access_udp_endpoint_init(void)
 
29
{
 
30
}
 
31
 
 
32
/**---------------------------------------------------------------------*/
 
33
/*
 
34
 * container functions
 
35
 */
 
36
/**
 
37
 * initialize udp_endpoint container
 
38
 */
 
39
netsnmp_container *
 
40
netsnmp_access_udp_endpoint_container_init(u_int flags)
 
41
{
 
42
    netsnmp_container *container;
 
43
 
 
44
    DEBUGMSGTL(("access:udp_endpoint:container", "init\n"));
 
45
 
 
46
    /*
 
47
     * create the containers.
 
48
     */
 
49
    container = netsnmp_container_find("access_udp_endpoint:table_container");
 
50
    if (NULL == container)
 
51
        return NULL;
 
52
 
 
53
    return container;
 
54
}
 
55
 
 
56
/**
 
57
 * load udp_endpoint information in specified container
 
58
 *
 
59
 * @param container empty container, or NULL to have one created for you
 
60
 * @param load_flags flags to modify behaviour.
 
61
 *
 
62
 * @retval NULL  error
 
63
 * @retval !NULL pointer to container
 
64
 */
 
65
netsnmp_container*
 
66
netsnmp_access_udp_endpoint_container_load(netsnmp_container* container,
 
67
                                           u_int load_flags)
 
68
{
 
69
    int rc;
 
70
 
 
71
    DEBUGMSGTL(("access:udp_endpoint:container", "load\n"));
 
72
 
 
73
    if (NULL == container)
 
74
        container = netsnmp_access_udp_endpoint_container_init(0);
 
75
    if (NULL == container) {
 
76
        snmp_log(LOG_ERR,
 
77
                 "no container specified/found for access_udp_endpoint\n");
 
78
        return NULL;
 
79
    }
 
80
 
 
81
    rc =
 
82
        netsnmp_arch_udp_endpoint_container_load(container, load_flags);
 
83
    if (0 != rc) {
 
84
        netsnmp_access_udp_endpoint_container_free(container, 0);
 
85
        container = NULL;
 
86
    }
 
87
 
 
88
    return container;
 
89
}
 
90
 
 
91
void
 
92
netsnmp_access_udp_endpoint_container_free(netsnmp_container *container,
 
93
                                           u_int free_flags)
 
94
{
 
95
    DEBUGMSGTL(("access:udp_endpoint:container", "free\n"));
 
96
 
 
97
    if (NULL == container) {
 
98
        snmp_log(LOG_ERR,
 
99
                 "invalid container for netsnmp_access_udp_endpoint_free\n");
 
100
        return;
 
101
    }
 
102
 
 
103
    if(! (free_flags & NETSNMP_ACCESS_UDP_ENDPOINT_FREE_DONT_CLEAR)) {
 
104
        /*
 
105
         * free all items.
 
106
         */
 
107
        CONTAINER_CLEAR(container,
 
108
                        (netsnmp_container_obj_func*)free,
 
109
                        NULL);
 
110
    }
 
111
 
 
112
    if(! (free_flags & NETSNMP_ACCESS_UDP_ENDPOINT_FREE_KEEP_CONTAINER))
 
113
        CONTAINER_FREE(container);
 
114
}
 
115
 
 
116
/**---------------------------------------------------------------------*/
 
117
/*
 
118
 * entry functions
 
119
 */
 
120
/**
 
121
 */
 
122
netsnmp_udp_endpoint_entry *
 
123
netsnmp_access_udp_endpoint_entry_create(void)
 
124
{
 
125
    netsnmp_udp_endpoint_entry *entry =
 
126
        SNMP_MALLOC_TYPEDEF(netsnmp_udp_endpoint_entry);
 
127
 
 
128
    DEBUGMSGTL(("access:udp_endpoint:entry", "create\n"));
 
129
 
 
130
    if(NULL == entry)
 
131
        return NULL;
 
132
 
 
133
    entry->oid_index.len = 1;
 
134
    entry->oid_index.oids = (oid *) & entry->index;
 
135
 
 
136
    return entry;
 
137
}
 
138
 
 
139
/**
 
140
 */
 
141
void
 
142
netsnmp_access_udp_endpoint_entry_free(netsnmp_udp_endpoint_entry * entry)
 
143
{
 
144
    DEBUGMSGTL(("access:udp_endpoint:entry", "free\n"));
 
145
 
 
146
    if (NULL == entry)
 
147
        return;
 
148
 
 
149
    /*
 
150
     * SNMP_FREE not needed, for any of these, 
 
151
     * since the whole entry is about to be freed
 
152
     */
 
153
 
 
154
    free(entry);
 
155
}
 
156
 
 
157
 
 
158
/**---------------------------------------------------------------------*/
 
159
/*
 
160
 * Utility routines
 
161
 */
 
162
 
 
163
/**
 
164
 * \internal
 
165
 */
 
166
static void
 
167
_entry_release(netsnmp_udp_endpoint_entry * entry, void *context)
 
168
{
 
169
    netsnmp_access_udp_endpoint_entry_free(entry);
 
170
}
 
171
 
 
172
/**---------------------------------------------------------------------*/
 
173
/*
 
174
 *
 
175
 */