~ubuntu-branches/ubuntu/intrepid/net-snmp/intrepid-proposed

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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**************************************************************
 * Copyright (C) 2001 Alex Rozin, Optical Access 
 *
 *                     All Rights Reserved
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation.
 * 
 * ALEX ROZIN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * ALEX ROZIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 ******************************************************************/

#ifndef _row_api_h_included__
#define _row_api_h_included__

/*
 * control tables API section 
 */

typedef enum {
    RMON1_ENTRY_VALID = 1,
    RMON1_ENTRY_CREATE_REQUEST,
    RMON1_ENTRY_UNDER_CREATION,
    RMON1_ENTRY_INVALID
} RMON1_ENTRY_STATUS_T;

#define MAX_OWNERSTRING		128

/*
 * structure for entry of all 'control' tables 
 */
typedef struct tagEntry {
    /*
     * begin of the header 
     */
    struct tagEntry *next;
    void           *table_ptr;  /* do casting to (TABLE_DEFINTION_T*) */
    RMON1_ENTRY_STATUS_T status;
    RMON1_ENTRY_STATUS_T new_status;
    u_long          ctrl_index;
    u_long          timer_id;
    char           *owner;
    char           *new_owner;
    u_char          only_just_created;

    /*
     * end of the header 
     */

    void           *body;
    void           *tmp;
} RMON_ENTRY_T;

typedef int     (ENTRY_CALLBACK_T) (RMON_ENTRY_T *);

typedef struct {
    char           *name;
    RMON_ENTRY_T   *first;
    u_long          max_number_of_entries;      /* '<0' means without limit */
    u_long          current_number_of_entries;
    ENTRY_CALLBACK_T *ClbkCreate;
    ENTRY_CALLBACK_T *ClbkClone;
    ENTRY_CALLBACK_T *ClbkValidate;
    ENTRY_CALLBACK_T *ClbkActivate;
    ENTRY_CALLBACK_T *ClbkDeactivate;
    ENTRY_CALLBACK_T *ClbkDelete;
    ENTRY_CALLBACK_T *ClbkCopy;
} TABLE_DEFINTION_T;

/*
 * Api prototypes 
 */
void            ROWAPI_init_table(TABLE_DEFINTION_T * table_ptr,
                                  char *name,
                                  u_long max_number_of_entries,
                                  ENTRY_CALLBACK_T * ClbkCreate,
                                  ENTRY_CALLBACK_T * ClbkClone,
                                  ENTRY_CALLBACK_T * ClbkDelete,
                                  ENTRY_CALLBACK_T * ClbkValidate,
                                  ENTRY_CALLBACK_T * ClbkActivate,
                                  ENTRY_CALLBACK_T * ClbkDeactivate,
                                  ENTRY_CALLBACK_T * ClbkCopy);

int             ROWAPI_new(TABLE_DEFINTION_T * table_ptr,
                           u_long ctrl_index);

RMON_ENTRY_T   *ROWAPI_get_clone(TABLE_DEFINTION_T * table_ptr,
                                 u_long ctrl_index, size_t body_size);

void            ROWAPI_delete_clone(TABLE_DEFINTION_T * table_ptr,
                                    u_long ctrl_index);

RMON_ENTRY_T   *ROWAPI_first(TABLE_DEFINTION_T * table_ptr);

RMON_ENTRY_T   *ROWAPI_next(TABLE_DEFINTION_T * table_ptr,
                            u_long prev_index);

RMON_ENTRY_T   *ROWAPI_find(TABLE_DEFINTION_T * table_ptr,
                            u_long ctrl_index);

int             ROWAPI_action_check(TABLE_DEFINTION_T * table_ptr,
                                    u_long ctrl_index);

int             ROWAPI_commit(TABLE_DEFINTION_T * table_ptr,
                              u_long ctrl_index);

RMON_ENTRY_T   *ROWAPI_header_ControlEntry(struct variable *vp, oid * name,
                                           size_t * length, int exact,
                                           size_t * var_len,
                                           TABLE_DEFINTION_T * table_ptr,
                                           void *entry_ptr,
                                           size_t entry_size);

int             ROWAPI_do_another_action(oid * name,
                                         int tbl_first_index_begin,
                                         int action, int *prev_action,
                                         TABLE_DEFINTION_T * table_ptr,
                                         size_t entry_size);

/*
 * data tables API section 
 */

typedef int     (SCROLLER_ENTRY_DESCRUCTOR_T) (void *);

typedef struct nexted_void_t {
    struct nexted_void_t *next;
    u_long          data_index;
} NEXTED_PTR_T;

typedef struct data_scroller {
    u_long          max_number_of_entries;
    u_long          data_requested;
    u_long          data_granted;
    u_long          data_created;       /* number of allocated data entries */
    u_long          data_stored;        /* number of data, currently stored */
    u_long          data_total_number;  /* number of data entries, stored after validation */

    /*
     * these 3 pointers make casting to private (DATA_ENTRY_T*) 
     */
    void           *first_data_ptr;
    NEXTED_PTR_T   *last_data_ptr;
    void           *current_data_ptr;

    size_t          data_size;
    int             (*data_destructor) (struct data_scroller *, void *);
} SCROLLER_T;

int             ROWDATAAPI_init(SCROLLER_T * scrlr,
                                u_long max_number_of_entries,
                                u_long data_requested,
                                size_t data_size,
                                int (*data_destructor) (struct
                                                        data_scroller *,
                                                        void *));

void
                ROWDATAAPI_set_size(SCROLLER_T * scrlr,
                                    u_long data_requested,
                                    u_char do_allocation);

void            ROWDATAAPI_descructor(SCROLLER_T * scrlr);

void           *ROWDATAAPI_locate_new_data(SCROLLER_T * scrlr);

u_long          ROWDATAAPI_get_total_number(SCROLLER_T * scrlr);

RMON_ENTRY_T   *ROWDATAAPI_header_DataEntry(struct variable *vp,
                                            oid * name, size_t * length,
                                            int exact, size_t * var_len,
                                            TABLE_DEFINTION_T * table_ptr,
                                            SCROLLER_T *
                                            (*extract_scroller) (void
                                                                 *body),
                                            size_t data_size,
                                            void *entry_ptr);

#endif                          /* _row_api_h_included__ */