summaryrefslogtreecommitdiff
path: root/include/net-snmp/agent/table_container.h
blob: b34211091ae63bdd92d8df1313a5a3d071d9cacc (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
/*
 * table_container.h
 * $Id$
 */
#ifndef _TABLE_CONTAINER_HANDLER_H_
#define _TABLE_CONTAINER_HANDLER_H_

#ifdef __cplusplus
extern          "C" {
#endif

    /*
     * The table container helper is designed to simplify the task of
     * writing a table handler for the net-snmp agent when the data being
     * accessed is accessible via a netsnmp_container.
     * 
     * Functionally, it is a specialized version of the more
     * generic table helper but easies the burden of GETNEXT processing by
     * retrieving the appropriate row for each index through
     * function calls which should be supplied by the module that wishes
     * help.  The module the table_container helps should, afterwards,
     * never be called for the case of "MODE_GETNEXT" and only for the GET
     * and SET related modes instead.
     */
    
#include <net-snmp/library/container.h>
#include <net-snmp/agent/table.h>
    
#define TABLE_CONTAINER_ROW       "table_container:row"
#define TABLE_CONTAINER_CONTAINER "table_container:container"
    
#define TABLE_CONTAINER_KEY_NETSNMP_INDEX         1 /* default */
#define TABLE_CONTAINER_KEY_VARBIND_INDEX         2
#define TABLE_CONTAINER_KEY_VARBIND_RAW           3

/* ====================================
 * Container Table API: MIB maintenance
 * ==================================== */

    /*
     * get an injectable container table handler
     */
    netsnmp_mib_handler *
    netsnmp_container_table_handler_get(netsnmp_table_registration_info *tabreq,
                                        netsnmp_container *container,
                                        char key_type);
    /*
     * register a container table
     */
    int            
    netsnmp_container_table_register(netsnmp_handler_registration *reginfo,
                                     netsnmp_table_registration_info *tabreq,
                                     netsnmp_container *container,
                                     char key_type);
    int            
    netsnmp_container_table_unregister(netsnmp_handler_registration *reginfo);
    
    /** retrieve the container used by the table_container helper */
    netsnmp_container*
    netsnmp_container_table_container_extract(netsnmp_request_info *request);

    /** find the context data used by the table_container helper */
#ifdef NETSNMP_USE_INLINE
    NETSNMP_STATIC_INLINE void *
    netsnmp_container_table_row_extract(netsnmp_request_info *request)
    {
        /*
         * NOTE: this function must match in table_container.c and table_container.h.
         *       if you change one, change them both!
         */
        return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
    }

    NETSNMP_STATIC_INLINE void *
    netsnmp_container_table_extract_context(netsnmp_request_info *request)
    {
        /*
         * NOTE: this function must match in table_container.c and table_container.h.
         *       if you change one, change them both!
         */
        return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
    }
#else
    void *
    netsnmp_container_table_row_extract(netsnmp_request_info *request);
    void *
    netsnmp_container_table_extract_context(netsnmp_request_info *request);
#endif /* inline */

    void netsnmp_container_table_row_insert(netsnmp_request_info *request,
                                            netsnmp_index *row);
    void netsnmp_container_table_row_remove(netsnmp_request_info *request,
                                            netsnmp_index        *row);

/* ===================================
 * Container Table API: Row operations
 * =================================== */

    void *
    netsnmp_container_table_find_next_row(netsnmp_request_info *request,
                                          netsnmp_table_request_info *tblreq,
                                          netsnmp_container *container,
                                          char key_type );
#ifdef __cplusplus
}
#endif

#endif                          /* _TABLE_CONTAINER_HANDLER_H_ */