yumapro  20.10-12
YumaPro SDK
agt_sil_lib.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4  *
5  * Unless required by applicable law or agreed to in writing,
6  * software distributed under the License is distributed on an
7  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations
10  * under the License.
11  */
12 #ifndef _H_agt_sil_lib
13 #define _H_agt_sil_lib
14 
15 /* FILE: agt_sil_lib.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
22 
29 /*********************************************************************
30 * *
31 * C H A N G E H I S T O R Y *
32 * *
33 *********************************************************************
34 
35 date init comment
36 ----------------------------------------------------------------------
37 00-may-14 abb Begun; split out from agt.h
38 */
39 
40 #include <xmlstring.h>
41 
42 #ifndef _H_dlq
43 #include "dlq.h"
44 #endif
45 
46 #ifndef _H_ncxtypes
47 #include "ncxtypes.h"
48 #endif
49 
50 #ifndef _H_ses
51 #include "ses.h"
52 #endif
53 
54 #ifndef _H_status_enum
55 #include "status_enum.h"
56 #endif
57 
58 #ifndef _H_xml_msg
59 #include "xml_msg.h"
60 #endif
61 
62 #ifndef _H_xmlns
63 #include "xmlns.h"
64 #endif
65 
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 
88 /********************************************************************
89 * *
90 * C O N S T A N T S *
91 * *
92 *********************************************************************/
93 #define SA_NAME_EXT (const xmlChar *)"_sa"
94 
95 /********************************************************************
96 * *
97 * T Y P E S *
98 * *
99 *********************************************************************/
100 
102 typedef enum agt_siltype_t_ {
106 } agt_siltype_t;
107 
108 
109 /********* Server Instrumentation Library Callbacks ***********/
110 
111 
121 typedef status_t (*agt_sil_init_fn_t)(const xmlChar *modname,
122  const xmlChar *revision);
123 
124 
125 
133 typedef status_t (*agt_sil_init2_fn_t)(void);
134 
135 
141 typedef void (*agt_sil_cleanup_fn_t)(void);
142 
143 
144 
145 /* Example: N=test2
146 extern status_t y_test2_init(const xmlChar *modname, const xmlChar *revision);
147 extern status_t y_test2_init2(void);
148 extern void y_test2_cleanup(void);
149 */
150 
151 #define AGT_SIL_LIB_EXTERN(N) \
152  extern status_t y_##N##_init (const xmlChar *modname, const xmlChar *revision);\
153  extern status_t y_##N##_init2 (void);\
154  extern void y_##N##_cleanup (void);
155 
156 
157 /********************************************************************
158 * *
159 * F U N C T I O N S *
160 * *
161 *********************************************************************/
162 
163 
175 extern status_t
176  agt_load_sil_code (const xmlChar *modname,
177  const xmlChar *revision,
178  boolean cfgloaded,
179  agt_siltype_t siltyp,
180  boolean is_sil_sa);
181 
182 
195 extern status_t
196  agt_unload_sil_code (const xmlChar *modname);
197 
198 
205 extern boolean
206  agt_dynlib_loaded (const xmlChar *name);
207 
208 
214 extern void
215  agt_sil_lib_init (void);
216 
217 
223 extern void
224  agt_sil_lib_cleanup (void);
225 
226 
236 extern status_t load_SIL (const xmlChar *modname,
237  const xmlChar *revision,
238  agt_siltype_t siltyp,
239  boolean is_sil_sa);
240 
241 
253 extern status_t
254  load_SIL_loadpath (const xmlChar *modname,
255  const xmlChar *revision,
256  agt_siltype_t siltyp,
257  boolean is_sil_sa,
258  boolean is_loadpath);
259 
260 
266 extern status_t
267  agt_sil_lib_call_init2 (void);
268 
269 
281 extern void
282  agt_sil_lib_support_save (ses_cb_t *scb,
283  xml_msg_hdr_t *mhdr,
284  xmlns_id_t parent_nsid,
285  int32 indent,
286  int32 startindent);
287 
288 
301 extern status_t
302  agt_sil_lib_register_statlib (const xmlChar *modname,
303  agt_sil_init_fn_t init_fn,
304  agt_sil_init2_fn_t init2_fn,
305  agt_sil_cleanup_fn_t cleanup_fn);
306 
307 
308 
312 #ifdef __cplusplus
313 } /* end extern 'C' */
314 #endif
315 
316 #endif /* _H_agt */
ncx_str.h
NCX Module Library String Utility Functions.
ses.h
NETCONF Session Common definitions module.
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
ncxmod_find_sil_file
xmlChar * ncxmod_find_sil_file(const xmlChar *fname, boolean generrors, status_t *res)
Determine the location of the specified server instrumentation library file.
Definition: ncxmod.c:5351
AGT_SILTYP_MODULE
@ AGT_SILTYP_MODULE
SIL is a module.
Definition: agt_sil_lib.h:108
ses_new_indent_count
int32 ses_new_indent_count(boolean indent_in, int32 indent, int32 indent_amount)
Get the new indent count from the current and indent_amount.
Definition: ses.c:4148
agt_sil_lib_call_init2
status_t agt_sil_lib_call_init2(void)
Call the available SIL init2 callbacks.
Definition: agt_sil_lib.c:844
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
status_enum.h
global error status code enumerations
xml_wr.h
XML Write functions.
agt_sil_lib_cleanup
void agt_sil_lib_cleanup(void)
Cleanup the module.
Definition: agt_sil_lib.c:785
AGT_SILTYP_BUNDLE
@ AGT_SILTYP_BUNDLE
SIL is a bundle.
Definition: agt_sil_lib.h:109
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
agt_siltype_t_
agt_siltype_t_
SIL types.
Definition: agt_sil_lib.h:102
xml_wr_begin_elem
void xml_wr_begin_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write a start XML tag to the specified session without attributes.
Definition: xml_wr.c:3040
agt_unload_sil_code
status_t agt_unload_sil_code(const xmlChar *modname)
Unload the Server Instrumentation Library for the specified module.
Definition: agt_sil_lib.c:681
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
SET_MOD_SIL_LOADED
#define SET_MOD_SIL_LOADED(M)
set flag used by agt_sil_lib to make sure modules loaded by import do not get skipped when they are e...
Definition: ncxtypes.h:76
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
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.
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
dlq_remove
void dlq_remove(void *nodeP)
remove the queue entry from its queue list entry MUST have been enqueued somehow before this function...
Definition: dlq.c:519
ncxmod_load_module_loadpath
status_t ncxmod_load_module_loadpath(const xmlChar *modname, const xmlChar *revision, dlq_hdr_t *savedevQ, boolean is_loadpath, ncx_module_t **retmod)
Determine the location of the specified module and then load it into the system, if not already loade...
Definition: ncxmod.c:4388
agt_get_savedevQ
dlq_hdr_t * agt_get_savedevQ(void)
Get the agt_savedevQ pointer.
Definition: agt.c:4747
agt_dynlib_loaded
boolean agt_dynlib_loaded(const xmlChar *name)
Check a module of bundle name is in the dynlibQ.
Definition: agt_sil_lib.c:745
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
agt_sil_lib.h
Server Instrumentation Library Support.
agt_sil_lib_support_save
void agt_sil_lib_support_save(ses_cb_t *scb, xml_msg_hdr_t *mhdr, xmlns_id_t parent_nsid, int32 indent, int32 startindent)
Dump the XML support-save info for the <sils> container.
Definition: agt_sil_lib.c:900
ncx_copy_c_safe_str
uint32 ncx_copy_c_safe_str(xmlChar *buffer, const xmlChar *strval)
Copy the string to the buffer, changing legal YANG identifier chars that cannot be used in C function...
Definition: ncx_str.c:231
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
xml_strncmp
int xml_strncmp(const xmlChar *s1, const xmlChar *s2, uint32 maxlen)
String compare for xmlChar for at most 'maxlen' xmlChars.
Definition: xml_util.c:1824
xml_wr_end_elem
void xml_wr_end_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write an end tag to the specified session.
Definition: xml_wr.c:3114
ERR_INTERNAL_INIT_SEQ
@ ERR_INTERNAL_INIT_SEQ
007
Definition: status_enum.h:197
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
agt_sil_lib_init
void agt_sil_lib_init(void)
Initialize the module.
Definition: agt_sil_lib.c:768
agt_sil_lib_register_statlib
status_t agt_sil_lib_register_statlib(const xmlChar *modname, agt_sil_init_fn_t init_fn, agt_sil_init2_fn_t init2_fn, agt_sil_cleanup_fn_t cleanup_fn)
Register a static SIL or SIL-SA library for a module or a bundle.
Definition: agt_sil_lib.c:1001
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.
load_SIL
status_t load_SIL(const xmlChar *modname, const xmlChar *revision, agt_siltype_t siltyp, boolean is_sil_sa)
Load the SIL code or load the YANG module.
Definition: agt_sil_lib.c:260
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
agt.h
Multi-Protocol Network Management Server.
agt_sil_init_fn_t
status_t(* agt_sil_init_fn_t)(const xmlChar *modname, const xmlChar *revision)
SIL init function template.
Definition: agt_sil_lib.h:121
agt_sil_cleanup_fn_t
void(* agt_sil_cleanup_fn_t)(void)
SIL cleanup function template.
Definition: agt_sil_lib.h:141
xml_msg.h
XML and JSON Message send and receive support.
xml_wr_string_elem
void xml_wr_string_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *str, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent)
Write a start tag, simple string content, and an end tag to the specified session.
Definition: xml_wr.c:3235
agt_sil_init2_fn_t
status_t(* agt_sil_init2_fn_t)(void)
SIL init2 function template.
Definition: agt_sil_lib.h:133
AGT_SILTYP_NONE
@ AGT_SILTYP_NONE
not set
Definition: agt_sil_lib.h:107
SET_MOD_NO_SIL_CODE
#define SET_MOD_NO_SIL_CODE(M)
set flag used by SIL-SA to know fi register-request really needed Only register if this bit is not se...
Definition: ncxtypes.h:84
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
log.h
NCX System Logging Manager.
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
ERR_NCX_VALUE_NOT_SUPPORTED
@ ERR_NCX_VALUE_NOT_SUPPORTED
358
Definition: status_enum.h:401
xml_wr_empty_elem
void xml_wr_empty_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write an empty XML tag to the specified session without attributes.
Definition: xml_wr.c:3076
load_SIL_loadpath
status_t load_SIL_loadpath(const xmlChar *modname, const xmlChar *revision, agt_siltype_t siltyp, boolean is_sil_sa, boolean is_loadpath)
Load the SIL code or load the YANG module.
Definition: agt_sil_lib.c:288
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
agt_get_profile
agt_profile_t * agt_get_profile(void)
Get the server profile struct.
Definition: agt.c:4118
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
ncx.h
YANG module utility functions.
dlq_enque
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
ncx_find_module
ncx_module_t * ncx_find_module(const xmlChar *modname, const xmlChar *revision)
Find a ncx_module_t in the ncx_sesmodQ.
Definition: ncx.c:3227
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
agt_load_sil_code
status_t agt_load_sil_code(const xmlChar *modname, const xmlChar *revision, boolean cfgloaded, agt_siltype_t siltyp, boolean is_sil_sa)
Load the Server Instrumentation Library for the specified module.
Definition: agt_sil_lib.c:435
xmlns.h
XML namespace support.
status.h
Global error messages for status code enumerations.
dlq.h
dlq provides general double-linked list and queue support:
ncx_set_mod_unloadable
void ncx_set_mod_unloadable(ncx_module_t *mod)
Set this module so it can be unloaded.
Definition: ncx.c:12100