Debian Codegraph @

agent/mibgroup/Rmon/row_api.h

raw
1 /**************************************************************
2 * Copyright (C) 2001 Alex Rozin, Optical Access
3 *
4 * All Rights Reserved
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation for any purpose and without fee is hereby granted,
8 * provided that the above copyright notice appear in all copies and that
9 * both that copyright notice and this permission notice appear in
10 * supporting documentation.
11 *
12 * ALEX ROZIN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
13 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
14 * ALEX ROZIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
15 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
16 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
17 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
18 * SOFTWARE.
19 ******************************************************************/
20
21 #ifndef _row_api_h_included__
22 #define _row_api_h_included__
23
24 /*
25 * control tables API section
26 */
27
28 typedef enum {
29 RMON1_ENTRY_VALID = 1,
30 RMON1_ENTRY_CREATE_REQUEST,
31 RMON1_ENTRY_UNDER_CREATION,
32 RMON1_ENTRY_INVALID
33 } RMON1_ENTRY_STATUS_T;
34
35 #define MAX_OWNERSTRING 128
36
37 /*
38 * structure for entry of all 'control' tables
39 */
40 typedef struct tagEntry {
41 /*
42 * begin of the header
43 */
44 struct tagEntry *next;
45 void *table_ptr; /* do casting to (TABLE_DEFINTION_T*) */
46 RMON1_ENTRY_STATUS_T status;
47 RMON1_ENTRY_STATUS_T new_status;
48 u_long ctrl_index;
49 u_long timer_id;
50 char *owner;
51 char *new_owner;
52 u_char only_just_created;
53
54 /*
55 * end of the header
56 */
57
58 void *body;
59 void *tmp;
60 } RMON_ENTRY_T;
61
62 typedef int (ENTRY_CALLBACK_T) (RMON_ENTRY_T *);
63
64 typedef struct {
65 const char *name;
66 RMON_ENTRY_T *first;
67 u_long max_number_of_entries; /* '<0' means without limit */
68 u_long current_number_of_entries;
69 ENTRY_CALLBACK_T *ClbkCreate;
70 ENTRY_CALLBACK_T *ClbkClone;
71 ENTRY_CALLBACK_T *ClbkValidate;
72 ENTRY_CALLBACK_T *ClbkActivate;
73 ENTRY_CALLBACK_T *ClbkDeactivate;
74 ENTRY_CALLBACK_T *ClbkDelete;
75 ENTRY_CALLBACK_T *ClbkCopy;
76 } TABLE_DEFINTION_T;
77
78 /*
79 * Api prototypes
80 */
81 void ROWAPI_init_table(TABLE_DEFINTION_T * table_ptr,
82 const char *name,
83 u_long max_number_of_entries,
84 ENTRY_CALLBACK_T * ClbkCreate,
85 ENTRY_CALLBACK_T * ClbkClone,
86 ENTRY_CALLBACK_T * ClbkDelete,
87 ENTRY_CALLBACK_T * ClbkValidate,
88 ENTRY_CALLBACK_T * ClbkActivate,
89 ENTRY_CALLBACK_T * ClbkDeactivate,
90 ENTRY_CALLBACK_T * ClbkCopy);
91
92 int ROWAPI_new(TABLE_DEFINTION_T * table_ptr,
93 u_long ctrl_index);
94
95 RMON_ENTRY_T *ROWAPI_get_clone(TABLE_DEFINTION_T * table_ptr,
96 u_long ctrl_index, size_t body_size);
97
98 void ROWAPI_delete_clone(TABLE_DEFINTION_T * table_ptr,
99 u_long ctrl_index);
100
101 RMON_ENTRY_T *ROWAPI_first(TABLE_DEFINTION_T * table_ptr);
102
103 RMON_ENTRY_T *ROWAPI_next(TABLE_DEFINTION_T * table_ptr,
104 u_long prev_index);
105
106 RMON_ENTRY_T *ROWAPI_find(TABLE_DEFINTION_T * table_ptr,
107 u_long ctrl_index);
108
109 int ROWAPI_action_check(TABLE_DEFINTION_T * table_ptr,
110 u_long ctrl_index);
111
112 int ROWAPI_commit(TABLE_DEFINTION_T * table_ptr,
113 u_long ctrl_index);
114
115 RMON_ENTRY_T *ROWAPI_header_ControlEntry(struct variable *vp, oid * name,
116 size_t * length, int exact,
117 size_t * var_len,
118 TABLE_DEFINTION_T * table_ptr,
119 void *entry_ptr,
120 size_t entry_size);
121
122 int ROWAPI_do_another_action(oid * name,
123 int tbl_first_index_begin,
124 int action, int *prev_action,
125 TABLE_DEFINTION_T * table_ptr,
126 size_t entry_size);
127
128 /*
129 * data tables API section
130 */
131
132 typedef int (SCROLLER_ENTRY_DESCRUCTOR_T) (void *);
133
134 typedef struct nexted_void_t {
135 struct nexted_void_t *next;
136 u_long data_index;
137 } NEXTED_PTR_T;
138
139 typedef struct data_scroller {
140 u_long max_number_of_entries;
141 u_long data_requested;
142 u_long data_granted;
143 u_long data_created; /* number of allocated data entries */
144 u_long data_stored; /* number of data, currently stored */
145 u_long data_total_number; /* number of data entries, stored after validation */
146
147 /*
148 * these 3 pointers make casting to private (DATA_ENTRY_T*)
149 */
150 void *first_data_ptr;
151 NEXTED_PTR_T *last_data_ptr;
152 void *current_data_ptr;
153
154 size_t data_size;
155 int (*data_destructor) (struct data_scroller *, void *);
156 } SCROLLER_T;
157
158 int ROWDATAAPI_init(SCROLLER_T * scrlr,
159 u_long max_number_of_entries,
160 u_long data_requested,
161 size_t data_size,
162 int (*data_destructor) (struct
163 data_scroller *,
164 void *));
165
166 void
167 ROWDATAAPI_set_size(SCROLLER_T * scrlr,
168 u_long data_requested,
169 u_char do_allocation);
170
171 void ROWDATAAPI_descructor(SCROLLER_T * scrlr);
172
173 void *ROWDATAAPI_locate_new_data(SCROLLER_T * scrlr);
174
175 u_long ROWDATAAPI_get_total_number(SCROLLER_T * scrlr);
176
177 RMON_ENTRY_T *ROWDATAAPI_header_DataEntry(struct variable *vp,
178 oid * name, size_t * length,
179 int exact, size_t * var_len,
180 TABLE_DEFINTION_T * table_ptr,
181 SCROLLER_T *
182 (*extract_scroller) (void
183 *body),
184 size_t data_size,
185 void *entry_ptr);
186
187 #endif /* _row_api_h_included__ */