yumapro  20.10-12
YumaPro SDK
smioid_tree.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 - 2021, YumaWorks, Inc., All Rights Reserved.
3  *
4  * Unless required by applicable law or agreed to in writing,
5  * software distributed under the License is distributed on an
6  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7  * KIND, either express or implied. See the License for the
8  * specific language governing permissions and limitations
9  * under the License.
10  */
11 
12 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
13 #ifndef _H_smioid_tree
14 #define _H_smioid_tree
15 
16 /* FILE: smioid_tree.h
17 *********************************************************************
18 * *
19 * P U R P O S E *
20 * *
21 *********************************************************************/
22 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ---------------------------------------------------------------------
36 19-sep-16 rmb Begun
37 
38 */
39 
40 #ifndef _H_dict
41 #include "dict.h"
42 #endif
43 
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 
50 /********************************************************************
51 * *
52 * T Y P E S *
53 * *
54 *********************************************************************/
55 
66 typedef struct smioid_node_t_ {
67  const obj_oid_t *oid;
68  obj_template_t *obj;
69  struct smioid_node_t_ *next;
70 } smioid_node_t;
71 
72 
73 
74 /********************************************************************
75 * *
76 * F U N C T I O N S *
77 * *
78 *********************************************************************/
79 
88 extern boolean
89  smioid_extract_integers (const xmlChar *oid,
90  obj_oid_t *oid_obj);
91 
92 
98 extern obj_oid_t *
99  smioid_new_object_oid (void);
100 
101 
107 extern void
108  smioid_free_object_oid (obj_oid_t *oid);
109 
110 
120 extern obj_oid_t *
122  uint32 oid_len,
123  uint32 start_pos);
124 
125 
132 extern status_t
133  smioid_tree_init (void);
134 
135 
140 extern void
141  smioid_tree_cleanup (void);
142 
143 
151 extern void
152  smioid_tree_insert (obj_template_t *obj,
153  obj_oid_t *oid_obj);
154 
155 
162 extern boolean
163  smioid_tree_remove (obj_template_t *obj);
164 
165 
172 extern obj_template_t *
173  smioid_tree_find (obj_oid_t *oid_obj);
174 
175 
182 extern status_t
183  smioid_tree_dump(void);
184 
185 
194 extern obj_oid_t *
195  smioid_tree_getnext_oid (obj_oid_t *oid_obj,
196  boolean *found);
197 
198 
208 extern obj_template_t *
209  smioid_tree_getnext_oid_obj (obj_oid_t *oid_obj,
210  boolean *ignored_index);
211 
212 
219 extern obj_oid_t *
220  smioid_tree_find_oid (obj_template_t *obj);
221 
222 
228 extern void
229  smioid_dump_oid_string (const obj_oid_t *oid_obj);
230 
231 
237 extern void
238  smioid_dump_oid_string_obj (obj_template_t *obj);
239 
240 
250 extern obj_oid_t *
252  uint32 oid_len1,
253  oid_t *name2,
254  uint32 oid_len2);
255 
256 
263 extern obj_oid_t *
264  smioid_dup_object_oid (obj_oid_t *copyfrom);
265 
266 
272 extern obj_oid_t *
274 
275 
281 extern hb_tree *
282  smioid_tree_get (void);
283 
284 
288 #ifdef __cplusplus
289 } /* end extern 'C' */
290 #endif
291 
292 #endif /* _H_smioid_tree */
293 #endif // defined(WITH_SNMP) && defined(WITH_RESTCONF)
smioid_tree_dump
status_t smioid_tree_dump(void)
Traverses the SMI OID tree and prints the OID string and info on the obj_template_t instance.
Definition: smioid_tree.c:562
log_info_append
void void void void void void log_info_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_INFO log entry.
smioid_new_scalar_object_oid
obj_oid_t * smioid_new_scalar_object_oid(void)
Malloc a scalar index OID: '.0'.
Definition: smioid_tree.c:982
smioid_new_object_oid_ex
obj_oid_t * smioid_new_object_oid_ex(oid_t *name, uint32 oid_len, uint32 start_pos)
Malloc and init a new obj_oid_t control block.
Definition: smioid_tree.c:317
smioid_tree_init
status_t smioid_tree_init(void)
initialize the tree used for managing the SMI OID and the associated obj_template_t reference
Definition: smioid_tree.c:381
smioid_new_object_oid
obj_oid_t * smioid_new_object_oid(void)
Malloc and init a new obj_oid_t control block.
Definition: smioid_tree.c:288
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
smioid_tree_insert
void smioid_tree_insert(obj_template_t *obj, obj_oid_t *oid_obj)
Add a list entry to the oid tree.
Definition: smioid_tree.c:427
smioid_tree_find
obj_template_t * smioid_tree_find(obj_oid_t *oid_obj)
Find a object template node from the specified SMI OID string.
Definition: smioid_tree.c:536
smioid_tree_cleanup
void smioid_tree_cleanup(void)
Clean and free the oid tree.
Definition: smioid_tree.c:401
status_enum.h
global error status code enumerations
smioid_tree_getnext_oid_obj
obj_template_t * smioid_tree_getnext_oid_obj(obj_oid_t *oid_obj, boolean *ignored_index)
Returns the next or closest oid's object template for the specified oid as per the lexicographical or...
Definition: smioid_tree.c:716
smioid_node_t_::oid
const obj_oid_t * oid
OID for obj.
Definition: smioid_tree.h:67
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
smioid_tree_remove
boolean smioid_tree_remove(obj_template_t *obj)
Remove a entity from the specified tree.
Definition: smioid_tree.c:488
smioid_free_object_oid
void smioid_free_object_oid(obj_oid_t *oid)
Clean and free a malloced get2 control block.
Definition: smioid_tree.c:358
smioid_tree_find_oid
obj_oid_t * smioid_tree_find_oid(obj_template_t *obj)
Find the OID value of the corresponding OBJ template.
Definition: smioid_tree.c:772
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
smioid_node_t_::obj
obj_template_t * obj
object for entry
Definition: smioid_tree.h:68
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
obj_get_name
const xmlChar * obj_get_name(const obj_template_t *obj)
Get the name field for this obj.
Definition: obj.c:10511
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
smioid_concat_object_oid
obj_oid_t * smioid_concat_object_oid(oid_t *name1, uint32 oid_len1, oid_t *name2, uint32 oid_len2)
Concatenate 2 OIDs into one OID.
Definition: smioid_tree.c:885
obj_gen_object_id_oid
status_t obj_gen_object_id_oid(ncx_module_t *mod, const obj_template_t *obj, xmlChar **buff)
Malloc and Generate the object ID for an object node Used for canonical ID string comparison to gener...
Definition: obj.c:10085
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
smioid_dump_oid_string_obj
void smioid_dump_oid_string_obj(obj_template_t *obj)
Logs the given obj_template->oid object as a string.
Definition: smioid_tree.c:857
smioid_extract_integers
boolean smioid_extract_integers(const xmlChar *oid, obj_oid_t *oid_obj)
Split SMI oid string into integers using '.
Definition: smioid_tree.c:209
oid_t
unsigned long oid_t
data type used in SNMP
Definition: obj.h:1037
LOGINFO
#define LOGINFO
Check if at least log-level=info.
Definition: log.h:279
smioid_dump_oid_string
void smioid_dump_oid_string(const obj_oid_t *oid_obj)
Logs the given oid object as a string.
Definition: smioid_tree.c:815
smioid_node_t_
represents a pair of OID and associated object instance
Definition: smioid_tree.h:66
smioid_dup_object_oid
obj_oid_t * smioid_dup_object_oid(obj_oid_t *copyfrom)
Duplicate OID.
Definition: smioid_tree.c:940
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
obj_is_leaf
boolean obj_is_leaf(const obj_template_t *obj)
Check if object is a proper leaf.
Definition: obj.c:13323
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
smioid_node_t_::next
struct smioid_node_t_ * next
SMI get-next OID.
Definition: smioid_tree.h:69
ncx.h
YANG module utility functions.
obj.h
Data Object Support.
smioid_tree.h
AVL Tree storage of SMI OID data.
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
smioid_tree_getnext_oid
obj_oid_t * smioid_tree_getnext_oid(obj_oid_t *oid_obj, boolean *found)
Returns the next or closest OID for the specified oid as per the lexicographical order.
Definition: smioid_tree.c:640
smioid_tree_get
hb_tree * smioid_tree_get(void)
Get the SMI OID tree.
Definition: smioid_tree.c:1016