yumapro  20.10-12
YumaPro SDK
agt_audit.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_audit
13 #define _H_agt_audit
14 /* FILE: agt_audit.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
27 /*********************************************************************
28 * *
29 * C H A N G E H I S T O R Y *
30 * *
31 *********************************************************************
32 
33 date init comment
34 ----------------------------------------------------------------------
35 01-sep-18 abb Begun.
36 */
37 
38 
39 #ifndef _H_rpc
40 #include "rpc.h"
41 #endif
42 
43 #ifndef _H_ses
44 #include "ses.h"
45 #endif
46 
47 #ifndef _H_status_enum
48 #include "status_enum.h"
49 #endif
50 
51 #ifndef _H_val
52 #include "val.h"
53 #endif
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 
60 /********************************************************************
61 * *
62 * C O N S T A N T S *
63 * *
64 *********************************************************************/
65 
66 
67 /********************************************************************
68 * *
69 * T Y P E S *
70 * *
71 *********************************************************************/
72 
73 
74 /********************************************************************
75 * *
76 * F U N C T I O N S *
77 * *
78 *********************************************************************/
79 
80 
110 extern void
111  agt_audit_handle_edit_record (op_editop_t editop,
112  ses_cb_t *scb,
113  rpc_msg_t *msg,
114  val_value_t *curnode_clone,
115  val_value_t *newnode,
116  val_value_t *curnode);
117 
118 
127 extern void
128  agt_audit_handle_update_startup (ses_cb_t *scb,
129  rpc_msg_t *msg,
130  const xmlChar *sourcetype,
131  const xmlChar *sourcename);
132 
133 
139 extern void
140  agt_audit_handle_start_session (ses_cb_t *scb);
141 
142 
150 extern void
151  agt_audit_handle_end_session (ses_cb_t *scb,
152  ses_term_reason_t termreason,
153  ses_id_t killedby);
154 
155 
163 extern void
164  agt_audit_handle_acm_write_error (const xmlChar *user,
165  val_value_t *val,
166  op_editop_t editop);
167 
168 
176 extern void
177  agt_audit_handle_acm_exec_error (const xmlChar *user,
178  const xmlChar *modname,
179  const xmlChar *rpcname);
180 
181 
188 extern void
189  agt_audit_handle_rpc_summary (ses_cb_t *scb,
190  rpc_msg_t *msg);
191 
192 
201 extern uint32
202  agt_audit_cvt_log_events (val_value_t *val,
203  status_t *res);
204 
205 
211 extern boolean
213 
214 
220 extern boolean
222 
223 
229 extern boolean
231 
232 
238 extern boolean
240 
241 
247 extern boolean
249 
250 
256 extern boolean
258 
259 
265 extern boolean
267 
268 
274 extern boolean
276 
277 
283 extern boolean
285 
286 
290 #ifdef __cplusplus
291 } /* end extern 'C' */
292 #endif
293 
294 #endif /* _H_agt_audit */
ses.h
NETCONF Session Common definitions module.
agt_audit_log_update_startup
boolean agt_audit_log_update_startup(void)
Check if <startup> update events are being collected.
Definition: agt_audit.c:971
agt_audit_log_client_session
boolean agt_audit_log_client_session(void)
Check if client session events are being collected.
Definition: agt_audit.c:987
agt_util.h
Utility Functions for NCX Server method routines.
ses_get_transport
ses_transport_t ses_get_transport(ses_cb_t *scb)
Get the transport enum for a given session.
Definition: ses.c:3578
ncx_get_protocol_name
const xmlChar * ncx_get_protocol_name(ncx_protocol_t proto)
Get the name string for the protocol.
Definition: ncx.c:10480
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
val.h
Value Node Basic Support.
status_enum.h
global error status code enumerations
val_find_bit
boolean val_find_bit(val_value_t *val, const xmlChar *bitname)
Find the specified bit name in the NCX_BT_BITS value.
Definition: val.c:13690
agt_audit_cvt_log_events
uint32 agt_audit_cvt_log_events(val_value_t *val, status_t *res)
Get the binary bits from the YANG bits value.
Definition: agt_audit.c:881
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
ses_id_t
uint32 ses_id_t
Session ID.
Definition: ses.h:306
log_audit_write
void void void void void void void void void log_audit_write(const char *fstr,...) __attribute__((format(printf
Write an new entry to the audit log file.
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
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.
agt_audit_handle_start_session
void agt_audit_handle_start_session(ses_cb_t *scb)
Generate a start (client or control) session event if enabled.
Definition: agt_audit.c:452
agt_audit_log_nacm_write_error
boolean agt_audit_log_nacm_write_error(void)
Check if NACM write-access errors are being collected.
Definition: agt_audit.c:1019
val_gen_instance_id
status_t val_gen_instance_id(xml_msg_hdr_t *mhdr, const val_value_t *val, ncx_instfmt_t format, xmlChar **buff)
Malloc and Generate the instance ID string for this value node,.
Definition: val_util.c:3424
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
agt_cvt_editop
op_editop_t agt_cvt_editop(op_editop_t editop, const val_value_t *newval, const val_value_t *curval)
Determine the effective edit (if OP_EDITOP_COMMIT)
Definition: agt_util.c:6205
NCX_EL_DASHDASH
#define NCX_EL_DASHDASH
NCX and NETCONF element and attribute names.
Definition: ncxconst.h:600
SES_MY_USERNAME
#define SES_MY_USERNAME(S)
get username
Definition: ses.h:111
DUMP_VAL_AUDIT_LOG
@ DUMP_VAL_AUDIT_LOG
dump val to audit log
Definition: val.h:779
agt_audit.h
NETCONF protocol audit log support.
val_dump_value
void val_dump_value(val_value_t *val, int32 startindent, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5688
agt_cfg_new_auditrec
agt_cfg_audit_rec_t * agt_cfg_new_auditrec(const xmlChar *target, op_editop_t editop)
Malloc and initialize a new agt_cfg_audit_rec_t struct.
Definition: agt_cfg.c:1607
agt_audit_log_rpc_summary
boolean agt_audit_log_rpc_summary(void)
Check if RPC summary events are being collected.
Definition: agt_audit.c:1051
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
ses_get_protocol
ncx_protocol_t ses_get_protocol(const ses_cb_t *scb)
Get the NETCONF protocol set (or unset) for this session.
Definition: ses.c:3854
ses_get_transport_name
const xmlChar * ses_get_transport_name(ses_transport_t transport)
Get the name of the transport for a given enum value.
Definition: ses.c:3598
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
agt_audit_handle_acm_exec_error
void agt_audit_handle_acm_exec_error(const xmlChar *user, const xmlChar *modname, const xmlChar *rpcname)
Generate an acm-exec-error event if enabled.
Definition: agt_audit.c:690
NCX_CFGID_CANDIDATE
@ NCX_CFGID_CANDIDATE
candidate datastore
Definition: ncxtypes.h:385
log_get_log_level
log_debug_t log_get_log_level(void)
Get the main log level.
Definition: log.c:3508
log_debug_append
void void void void void void void void log_debug_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG log entry.
rpc.h
NETCONF protocol remote procedure call common definitions.
agt_audit_handle_rpc_summary
void agt_audit_handle_rpc_summary(ses_cb_t *scb, rpc_msg_t *msg)
Create and store an rpc-summary event audit record, if needed.
Definition: agt_audit.c:746
agt_audit_log_control_session
boolean agt_audit_log_control_session(void)
Check if control session events are being collected.
Definition: agt_audit.c:1003
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
tstamp_time2datetime
void tstamp_time2datetime(time_t *timerec, xmlChar *buff)
Convert the specified time_t to a YANG data-and-time format.
Definition: tstamp.c:457
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.
NCX_CFGID_RUNNING
@ NCX_CFGID_RUNNING
running datastore (no value for not set!)
Definition: ncxtypes.h:384
yangconst.h
Contains YANG constants separated to prevent H file include loops.
agt.h
Multi-Protocol Network Management Server.
AGT_FL_AUDIT_EDIT_DATA
#define AGT_FL_AUDIT_EDIT_DATA
Add edit data to the audit log for an edit transaction log entry.
Definition: agt.h:555
agt_audit_log_edit_running
boolean agt_audit_log_edit_running(void)
Check if <running> edit events are being collected.
Definition: agt_audit.c:955
val_dump_value_max
void val_dump_value_max(val_value_t *val, int32 startindent, int32 indent_amount, val_dumpvalue_mode_t dumpmode, ncx_display_mode_t display_mode, boolean with_meta, boolean configonly, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5859
AGT_FL_AUDIT_NACM_EXEC_ERROR
#define AGT_FL_AUDIT_NACM_EXEC_ERROR
NACM exec violation events.
Definition: agt.h:549
ncx_get_display_mode
ncx_display_mode_t ncx_get_display_mode(void)
Get the current default display mode.
Definition: ncx.c:9816
op_editop_name
const xmlChar * op_editop_name(op_editop_t ed_id)
Get the keyword for the specified op_editop_t enumeration.
Definition: op.c:106
agt_audit_handle_update_startup
void agt_audit_handle_update_startup(ses_cb_t *scb, rpc_msg_t *msg, const xmlChar *sourcetype, const xmlChar *sourcename)
Create and store an update-startup audit record, if needed.
Definition: agt_audit.c:353
AGT_FL_AUDIT_RPC_SUMMARY
#define AGT_FL_AUDIT_RPC_SUMMARY
RPC summary events are generated after every RPC is handled.
Definition: agt.h:552
tstamp_datetime
void tstamp_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:160
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
AGT_FL_AUDIT_NACM_WRITE_ERROR
#define AGT_FL_AUDIT_NACM_WRITE_ERROR
NACM write violation events.
Definition: agt.h:546
agt_audit_handle_edit_record
void agt_audit_handle_edit_record(op_editop_t editop, ses_cb_t *scb, rpc_msg_t *msg, val_value_t *curnode_clone, val_value_t *newnode, val_value_t *curnode)
Create and store a change-audit record, if needed.
Definition: agt_audit.c:82
OP_EDITOP_LOAD
@ OP_EDITOP_LOAD
load, internal enum
Definition: op.h:128
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
log.h
NCX System Logging Manager.
agt_getTermReasonStr
const xmlChar * agt_getTermReasonStr(ses_term_reason_t termreason)
Convert the termination reason enum to a string.
Definition: agt_util.c:6516
SES_PEERADDR
#define SES_PEERADDR(S)
get the session peer address
Definition: ses.h:180
agt_cfg.h
Manage Server configuration edit transactions.
agt_audit_log_edit_candidate
boolean agt_audit_log_edit_candidate(void)
Check if <candidate> edit events are being collected.
Definition: agt_audit.c:939
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
agt_audit_handle_end_session
void agt_audit_handle_end_session(ses_cb_t *scb, ses_term_reason_t termreason, ses_id_t killedby)
Generate an end (client or control) session event if enabled.
Definition: agt_audit.c:531
AGT_FL_AUDIT_CLIENT_SESSION
#define AGT_FL_AUDIT_CLIENT_SESSION
client session start and end events
Definition: agt.h:540
agt_get_profile
agt_profile_t * agt_get_profile(void)
Get the server profile struct.
Definition: agt.c:4118
agt_audit_handle_acm_write_error
void agt_audit_handle_acm_write_error(const xmlChar *user, val_value_t *val, op_editop_t editop)
Generate an acm-write-error event if enabled.
Definition: agt_audit.c:615
VAL_OBJ
#define VAL_OBJ(V)
Access the object template.
Definition: val.h:381
ncx.h
YANG module utility functions.
ses_is_control_session
boolean ses_is_control_session(ses_cb_t *scb)
Check if the specified session is a control session.
Definition: ses.c:4386
TSTAMP_MIN_SIZE
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
SES_MY_SID
#define SES_MY_SID(S)
get session-id
Definition: ses.h:105
LOG_DEBUG_INFO
@ LOG_DEBUG_INFO
all previous + user info trace
Definition: log.h:392
log_audit_is_open
boolean log_audit_is_open(void)
Check if the audit log is open.
Definition: log.c:1190
rpc_msg_get_reply_type
const xmlChar * rpc_msg_get_reply_type(rpc_rpytyp_t rpytyp)
Get the reply type string from the message type.
Definition: rpc.c:235
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
AGT_FL_AUDIT_EDIT_RUNNING
#define AGT_FL_AUDIT_EDIT_RUNNING
edit-running events are generated when an edit or commit to <running> is completed.
Definition: agt.h:532
agt_audit_log_nacm_exec_error
boolean agt_audit_log_nacm_exec_error(void)
Check if NACM exec-access errors are being collected.
Definition: agt_audit.c:1035
agt_audit_log_edit_data
boolean agt_audit_log_edit_data(void)
Check if edit-data events are being collected.
Definition: agt_audit.c:1067
NCX_IFMT_XPATH2
@ NCX_IFMT_XPATH2
double-quote Xpath for error-path
Definition: ncxtypes.h:400
cfg_get_config_name
const xmlChar * cfg_get_config_name(ncx_cfg_t cfgid)
Get the config name from its ID.
Definition: cfg.c:1493
AGT_FL_AUDIT_CONTROL_SESSION
#define AGT_FL_AUDIT_CONTROL_SESSION
YControl session start and end events.
Definition: agt.h:543
obj_get_typestr
const xmlChar * obj_get_typestr(const obj_template_t *obj)
Get the name of the object type.
Definition: obj.c:11392
NCX_PROTO_NETCONF10
@ NCX_PROTO_NETCONF10
RFC 4741 base:1.0
Definition: ncxtypes.h:783
obj_is_root
boolean obj_is_root(const obj_template_t *obj)
Check if object is marked as a root object.
Definition: obj.c:14152
status.h
Global error messages for status code enumerations.
AGT_FL_AUDIT_UPDATE_STARTUP
#define AGT_FL_AUDIT_UPDATE_STARTUP
update-startup events are generated when a copy to <startup> is completed.
Definition: agt.h:537
ncx_transaction_id_t
uint64 ncx_transaction_id_t
transaction is scoped to single session write operation on a config
Definition: ncxtypes.h:548
NCX_DEF_INDENT
#define NCX_DEF_INDENT
default indent amount for nesting XML or other structured output
Definition: ncxconst.h:441