yumapro  23.10T-6
YumaPro SDK
Loading...
Searching...
No Matches
General NCX Utilities

General utlities to support the server implementation. More...

Collaboration diagram for General NCX Utilities:

Functions

xmlChar * ncx_get_source_ex (const xmlChar *fspec, boolean expand_cwd, status_t *res)
 Expand a filespec into an absolute path. More...
 
xmlChar * ncx_get_source (const xmlChar *fspec, status_t *res)
 Expand a filespec into an absolute path. More...
 
boolean ncx_prefix_different (const xmlChar *prefix1, const xmlChar *prefix2, const xmlChar *modprefix)
 Check if the specified prefix pair reference different modules. More...
 
status_t ncx_get_version (xmlChar *buffer, uint32 buffsize)
 Get the the Yuma version ID string. More...
 
status_t ncx_get_semver (xmlChar *buffer, uint32 buffsize)
 Get the the Yuma SEMVER version ID string. More...
 
status_t ncx_get_full_version (xmlChar *buffer, uint32 buffsize)
 Get the the Yuma version ID string and SEMVER added. More...
 
const char * ncx_get_build_date (void)
 Get the build date string encoded into this C file. More...
 
status_t ncx_get_feature_code (xmlChar *buffer, uint32 buffsize)
 Get the the Feature Code String. More...
 
int32 ncx_compare_base_uris (const xmlChar *str1, const xmlChar *str2)
 Compare the base part of 2 URI strings. More...
 
boolean ncx_val_protocol_enabled (ncx_protocol_t proto, uint16 flags)
 Check if the specified protocol version is enabled. More...
 
void ncx_set_val_protocol_enabled (ncx_protocol_t proto, uint16 *flags)
 Set the specified protocol version to be enabled in a uint16 bits val. More...
 
void ncx_set_val_protocol_disabled (ncx_protocol_t proto, uint16 *flags)
 Set the specified protocol version to be disabled in a uint16 bits val. More...
 
boolean ncx_protocol_is_netconf (ncx_protocol_t proto)
 Check if the protocol is a NETCONF protocol. More...
 
void ncx_write_tracefile (const char *buff, uint32 count)
 Write a byte to the tracefile. More...
 
status_t ncx_decode_url_string (const xmlChar *urlstr, uint32 urlstrlen, xmlChar *buffer, uint32 *cnt)
 Fill buffer with a plain string from a URL string. More...
 
status_t ncx_create_pidfile (const xmlChar *progname, boolean fileloc_fhs)
 Create the pidfile for the specified program. More...
 
status_t ncx_add_ydtrace (const xmlChar *fspec)
 Add the filespec of a yangdump file being processed. More...
 
boolean ncx_find_ydtrace (const xmlChar *fspec)
 Find the filespec of a yangdump file being processed. More...
 
ncx_result_format_t ncx_get_file_result_format (const xmlChar *filespec)
 Check the filespec string for a file assignment statement to see if it is text, XML, or JSON. More...
 
boolean ncx_library_mode_ok (const xmlChar *modname, const xmlChar *rpcname)
 Check if RPC OK to use in library mode. More...
 
const char * ncx_get_progname (void)
 Get the progname buffer. More...
 
boolean ncx_ok_for_inline_data (obj_template_t *obj)
 Check if the object is OK for inline data. More...
 
boolean ncx_check_inline_data_state (const xmlChar *line, boolean curstate)
 Check the input line for Start or End of data tags. More...
 
void ncx_set_use_return_status (void)
 Enable the return_status parameter. More...
 
boolean ncx_use_return_status (void)
 Check if the return_status should be returned. More...
 
ncx_bad_reply_enum ncx_get_handle_badreply_enum (const xmlChar *valstr)
 Check if the specified string matches an ncx_bad_reply_enum enum. More...
 
const xmlChar * ncx_get_handle_badreply_string (ncx_bad_reply_enum badreply)
 Get the string for the specified enum value. More...
 
void ncx_set_handle_badreply (ncx_bad_reply_enum enumval)
 Set the enum value for the Bad Reply handling option. More...
 
ncx_bad_reply_enum ncx_get_handle_badreply (void)
 Get the enum for the Bad Reply Handling option. More...
 
boolean ncx_conf_env_vars_enabled (void)
 Get the Config Environment Variable Replacement flag. More...
 
ncx_etag_t ncx_txid2etag (ncx_transaction_id_t txid)
 Cast ncx_txid_t to ncx_etag_t. More...
 
const xmlChar * ncx_get_xpath_type_str (ncx_xpath_type_t xpath_typ)
 Get the string for the ncx_xpath_type_t enum. More...
 
uint16 ncx_get_curQ_mod_count (void)
 Get the total count of the currently fully loaded modules in the ncx_curQ. More...
 
dlq_hdr_t * ncx_get_rootQ (void)
 Get the Root control block queue. More...
 
ncx_sm_rootcb_tncx_first_rootcb (void)
 Get the first Mount Point Control Block Entry in the rootcbQ. More...
 
ncx_sm_rootcb_tncx_next_rootcb (ncx_sm_rootcb_t *rootcb)
 Get the next Mount Point Entry in the rootcbQ. More...
 
boolean ncx_is_sm_mode (void)
 Check if the Schema Mount mode is enabled. More...
 
void ncx_set_sm_mode (boolean val)
 Set the Schema Mount mode. More...
 
ncx_sm_rootcb_tncx_get_cur_rootcb (void)
 Gte the current root control block value. More...
 
void ncx_set_cur_rootcb (ncx_sm_rootcb_t *rootcb)
 Set the current root control block. More...
 
obj_template_tncx_get_cur_rootcb_obj (void)
 Get the current root control block object. More...
 
boolean ncx_get_sm_enabled (void)
 Get schema mount enabled flag. More...
 
void ncx_set_sm_enabled (boolean val)
 Set schema mount enabled flag. More...
 
boolean ncx_yang_cbor_enabled (void)
 Get the YANG to CBOR Code enabled flag. More...
 
unsigned short ncx_get_tcp_connect_timeout (void)
 Get the configured TCP connect timeout value. More...
 
void ncx_set_tcp_connect_timeout (unsigned short timeout_sec)
 Set the configured TCP connect timeout value. More...
 
ncx_module_tncx_find_module_que_all (dlq_hdr_t *modQ, const xmlChar *modname, const xmlChar *revision)
 Find a ncx_module_t in the specified Q and check the namespace ID check submodules, not just modules. More...
 
void ncx_invoke_load_callbacks (ncx_module_t *mod)
 ncx_invoke_load_callbacks More...
 
void ncx_redo_loadmod_all (void)
 Set the redo_loadmod flag for all modules. More...
 
status_t send_buff (int fd, const char *buffer, size_t cnt)
 Send the buffer to the network peer. More...
 

Detailed Description

General utlities to support the server implementation.

Convert the filespec to an absolute path.

Function Documentation

◆ ncx_add_ydtrace()

status_t ncx_add_ydtrace ( const xmlChar *  fspec)

Add the filespec of a yangdump file being processed.

Parameters
fspecfilespec to save
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_check_inline_data_state()

boolean ncx_check_inline_data_state ( const xmlChar *  line,
boolean  curstate 
)

Check the input line for Start or End of data tags.

Parameters
lineline buffer to check
curstateFALSE if not inline; TRUE if in inline
Returns
new inline state
Here is the caller graph for this function:

◆ ncx_compare_base_uris()

int32 ncx_compare_base_uris ( const xmlChar *  str1,
const xmlChar *  str2 
)

Compare the base part of 2 URI strings.

Parameters
str1URI string 1
str2URI string 2
Returns
compare of base parts (up to '?'); -1, 0 or 1
Here is the call graph for this function:

◆ ncx_conf_env_vars_enabled()

boolean ncx_conf_env_vars_enabled ( void  )

Get the Config Environment Variable Replacement flag.

Placeholder: no configuration option to turn this off

Returns
TRUE if .conf file env-var replacement enabled
FALSE if .conf file env-var replacement disabled

◆ ncx_create_pidfile()

status_t ncx_create_pidfile ( const xmlChar *  progname,
boolean  fileloc_fhs 
)

Create the pidfile for the specified program.

Check if the file already exists. If so, then print an error message and return an error

Parameters
prognameprogram name
fileloc_fhsTRUE if FHS locations; FALSE if yumadir location
Returns
status
Here is the call graph for this function:

◆ ncx_decode_url_string()

status_t ncx_decode_url_string ( const xmlChar *  urlstr,
uint32  urlstrlen,
xmlChar *  buffer,
uint32 *  cnt 
)

Fill buffer with a plain string from a URL string.

Parameters
urlstrstring to convert
urlstrlennumber of bytes to check
bufferbuffer to fill; may be NULL to get count
[out]cntaddress of return cnt
  • *cnt number bytes required, if non-NULL inputs
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_find_module_que_all()

ncx_module_t * ncx_find_module_que_all ( dlq_hdr_t *  modQ,
const xmlChar *  modname,
const xmlChar *  revision 
)

Find a ncx_module_t in the specified Q and check the namespace ID check submodules, not just modules.

Parameters
modQmodule Q to search
modnamemodule name
revisionmodule revision date
Returns
module pointer if found or NULL if not
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_find_ydtrace()

boolean ncx_find_ydtrace ( const xmlChar *  fspec)

Find the filespec of a yangdump file being processed.

Parameters
fspecfilespec to find
Returns
TRUE if found, FALSE if not
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_first_rootcb()

ncx_sm_rootcb_t * ncx_first_rootcb ( void  )

Get the first Mount Point Control Block Entry in the rootcbQ.

Returns
Mount Point Entry if found or NULL if not
Here is the caller graph for this function:

◆ ncx_get_build_date()

const char * ncx_get_build_date ( void  )

Get the build date string encoded into this C file.

YPW-1908: add get-server-version RPC to yumaworks-system

Returns
const pointer to the date string

◆ ncx_get_cur_rootcb()

ncx_sm_rootcb_t * ncx_get_cur_rootcb ( void  )

Gte the current root control block value.

Get the current root control block value

Returns
rootcb if any
Here is the caller graph for this function:

◆ ncx_get_cur_rootcb_obj()

obj_template_t * ncx_get_cur_rootcb_obj ( void  )

Get the current root control block object.

Get the current root control block object

Returns
rootcb object if any

◆ ncx_get_curQ_mod_count()

uint16 ncx_get_curQ_mod_count ( void  )

Get the total count of the currently fully loaded modules in the ncx_curQ.

Returns
total number of fully loaded modules
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_feature_code()

status_t ncx_get_feature_code ( xmlChar *  buffer,
uint32  buffsize 
)

Get the the Feature Code String.

Parameters
bufferbuffer to hold the feature code string
buffsizenumber of bytes in buffer
Returns
status
Here is the call graph for this function:

◆ ncx_get_file_result_format()

ncx_result_format_t ncx_get_file_result_format ( const xmlChar *  filespec)

Check the filespec string for a file assignment statement to see if it is text, XML, or JSON.

Parameters
filespecstring to check
Returns
result format enumeration; RF_NONE if some error
Here is the call graph for this function:

◆ ncx_get_full_version()

status_t ncx_get_full_version ( xmlChar *  buffer,
uint32  buffsize 
)

Get the the Yuma version ID string and SEMVER added.

buffer should use NCX_FULL_VERSION_BUFFSIZE constant

Parameters
bufferbuffer to hold the version string
buffsizenumber of bytes in buffer
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_handle_badreply()

ncx_bad_reply_enum ncx_get_handle_badreply ( void  )

Get the enum for the Bad Reply Handling option.

Returns
Configured bad reply enum value

◆ ncx_get_handle_badreply_enum()

ncx_bad_reply_enum ncx_get_handle_badreply_enum ( const xmlChar *  valstr)

Check if the specified string matches an ncx_bad_reply_enum enum.

Parameters
valstrto use for convertion
Returns
enum value if OK
Here is the call graph for this function:

◆ ncx_get_handle_badreply_string()

const xmlChar * ncx_get_handle_badreply_string ( ncx_bad_reply_enum  badreply)

Get the string for the specified enum value.

Parameters
badreplyenum value to check
Returns
string pointer if OK

◆ ncx_get_progname()

const char * ncx_get_progname ( void  )

Get the progname buffer.

Returns
progname buffer
Here is the caller graph for this function:

◆ ncx_get_rootQ()

dlq_hdr_t * ncx_get_rootQ ( void  )

Get the Root control block queue.

Returns
Queue of root control blocks or NULL
Here is the caller graph for this function:

◆ ncx_get_semver()

status_t ncx_get_semver ( xmlChar *  buffer,
uint32  buffsize 
)

Get the the Yuma SEMVER version ID string.

buffer should use NCX_SEMVER_BUFFSIZE constant

Parameters
bufferbuffer to hold the version string
buffsizenumber of bytes in buffer
Returns
status

◆ ncx_get_sm_enabled()

boolean ncx_get_sm_enabled ( void  )

Get schema mount enabled flag.

On the server this flag will be set to false if there is no sm-config provided. This will save time and memory by ignoring mount-points that have no chance of being used.

Returns
TRUE ifr schema mount is enabled
Here is the caller graph for this function:

◆ ncx_get_source()

xmlChar * ncx_get_source ( const xmlChar *  fspec,
status_t res 
)

Expand a filespec into an absolute path.

Get a malloced buffer containing the complete filespec for the given input string. If this is a complete dirspec, this this will just strdup the value.

This is just a best effort to get the full spec. If the full spec is greater than 1500 bytes, then a NULL value (error) will be returned

This will expand the cwd!

  • Change ./ --> cwd/
  • Remove ~/ --> $HOME
  • add trailing '/' if not present
Parameters
fspecinput filespec
[out]resaddress of return status
  • *res return status, NO_ERR if return is non-NULL
Returns
malloced buffer containing possibly expanded full filespec
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_source_ex()

xmlChar * ncx_get_source_ex ( const xmlChar *  fspec,
boolean  expand_cwd,
status_t res 
)

Expand a filespec into an absolute path.

Get a malloced buffer containing the complete filespec for the given input string. If this is a complete dirspec, this this will just strdup the value.

This is just a best effort to get the full spec. If the full spec is greater than 1500 bytes, then a NULL value (error) will be returned

  • Change ./ --> cwd/
  • Remove ~/ --> $HOME
  • add trailing '/' if not present
Parameters
fspecinput filespec
expand_cwdTRUE if foo should be expanded to /cur/dir/foo; FALSE if not
[out]resaddress of return status
  • *res return status, NO_ERR if return is non-NULL
Returns
malloced buffer containing possibly expanded full filespec
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_tcp_connect_timeout()

unsigned short ncx_get_tcp_connect_timeout ( void  )

Get the configured TCP connect timeout value.

Returns
timeout value in seconds; 0 == use blocking mode
Here is the caller graph for this function:

◆ ncx_get_version()

status_t ncx_get_version ( xmlChar *  buffer,
uint32  buffsize 
)

Get the the Yuma version ID string.

buffer should use NCX_VERSION_BUFFSIZE constant

Parameters
bufferbuffer to hold the version string
buffsizenumber of bytes in buffer
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_xpath_type_str()

const xmlChar * ncx_get_xpath_type_str ( ncx_xpath_type_t  xpath_typ)

Get the string for the ncx_xpath_type_t enum.

Parameters
xpath_typxpath_typ enum to convert to str
Returns
string for the xpath_type
Here is the caller graph for this function:

◆ ncx_invoke_load_callbacks()

void ncx_invoke_load_callbacks ( ncx_module_t mod)

ncx_invoke_load_callbacks

INTERNAL API: Needed in sil-sa-app to invoke the module load callback even if the module is already loaded

@parm mod module being loaded; will be main module only

Here is the caller graph for this function:

◆ ncx_is_sm_mode()

boolean ncx_is_sm_mode ( void  )

Check if the Schema Mount mode is enabled.

FIXME: WHAT IS sm_mode and where is it documented???

Check if the Schema Mount mode have been set yet

Returns
TRUE if SM mode is enabled FALSE if SM mode is disabled
Here is the caller graph for this function:

◆ ncx_library_mode_ok()

boolean ncx_library_mode_ok ( const xmlChar *  modname,
const xmlChar *  rpcname 
)

Check if RPC OK to use in library mode.

Hardwired list of RPCs OK for library mode Only used by the server if –library-mode=true

HACK: this should be in the server, not libncx

Parameters
modnamemodule name containing the RPC method
rpcnameRPC name to check
Returns
true if OK for library mode; false if OK for library mode
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_next_rootcb()

ncx_sm_rootcb_t * ncx_next_rootcb ( ncx_sm_rootcb_t rootcb)

Get the next Mount Point Entry in the rootcbQ.

Parameters
rootcbcurrent Mount Point Entry
Returns
Mount Point Control Block Entry if found or NULL if not
Here is the caller graph for this function:

◆ ncx_ok_for_inline_data()

boolean ncx_ok_for_inline_data ( obj_template_t obj)

Check if the object is OK for inline data.

Parameters
objobject to check
Returns
TRUE if OK; FALSE if not
Here is the call graph for this function:

◆ ncx_prefix_different()

boolean ncx_prefix_different ( const xmlChar *  prefix1,
const xmlChar *  prefix2,
const xmlChar *  modprefix 
)

Check if the specified prefix pair reference different modules.

Parameters
prefix11st prefix to check (may be NULL)
prefix22nd prefix to check (may be NULL)
modprefixmodule prefix to check (may be NULL)
Returns
TRUE if prefix1 and prefix2 reference different modules' FALSE if prefix1 and prefix2 reference the same modules
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_protocol_is_netconf()

boolean ncx_protocol_is_netconf ( ncx_protocol_t  proto)

Check if the protocol is a NETCONF protocol.

Parameters
protoprotocol version to check
Returns
true if a NETCONF protocol; false if not

◆ ncx_redo_loadmod_all()

void ncx_redo_loadmod_all ( void  )

Set the redo_loadmod flag for all modules.

If the same module is used in multiple bundles then there will only be a load-module callback once. This flag will get set to FALSE when the load-module callback is attempted

◆ ncx_set_cur_rootcb()

void ncx_set_cur_rootcb ( ncx_sm_rootcb_t rootcb)

Set the current root control block.

Set the current root control block value

Parameters
rootcbRoot control block to set as current
Here is the caller graph for this function:

◆ ncx_set_handle_badreply()

void ncx_set_handle_badreply ( ncx_bad_reply_enum  enumval)

Set the enum value for the Bad Reply handling option.

Parameters
enumvalenum value to use

◆ ncx_set_sm_enabled()

void ncx_set_sm_enabled ( boolean  val)

Set schema mount enabled flag.

Parameters
valTRUE ifr schema mount is enabled

◆ ncx_set_sm_mode()

void ncx_set_sm_mode ( boolean  val)

Set the Schema Mount mode.

Set the sm_mode value

FIXME: WHAT IS sm_mode and where is it documented???

Parameters
valTRUE if schema mount mode should be used FALSE if schema mount mode should not ne used
Here is the caller graph for this function:

◆ ncx_set_tcp_connect_timeout()

void ncx_set_tcp_connect_timeout ( unsigned short  timeout_sec)

Set the configured TCP connect timeout value.

Parameters
timeout_sectimeout value in seconds; 0 == use blocking mode
Here is the caller graph for this function:

◆ ncx_set_use_return_status()

void ncx_set_use_return_status ( void  )

Enable the return_status parameter.

◆ ncx_set_val_protocol_disabled()

void ncx_set_val_protocol_disabled ( ncx_protocol_t  proto,
uint16 *  flags 
)

Set the specified protocol version to be disabled in a uint16 bits val.

Parameters
protoprotocol version to enable
[out]flagsaddress of bitmask to set
*flags is set with the bit for the protocol

◆ ncx_set_val_protocol_enabled()

void ncx_set_val_protocol_enabled ( ncx_protocol_t  proto,
uint16 *  flags 
)

Set the specified protocol version to be enabled in a uint16 bits val.

Parameters
protoprotocol version to enable
[out]flagsaddress of bitmask to set
*flags is set with the bit for the protocol
See also
ncx_val_protocol_enabled

◆ ncx_txid2etag()

ncx_etag_t ncx_txid2etag ( ncx_transaction_id_t  txid)

Cast ncx_txid_t to ncx_etag_t.

This is a utility function to convert uint64 txid to uint32 etag so that it is more alignment-safe when cast

Parameters
txiduint64 ncx_transaction_id_t object
Returns
etag is returned with value txid & 0xffffffff
Here is the caller graph for this function:

◆ ncx_use_return_status()

boolean ncx_use_return_status ( void  )

Check if the return_status should be returned.

Returns
TRUE if shell wants return status; FALSE to return zero

◆ ncx_val_protocol_enabled()

boolean ncx_val_protocol_enabled ( ncx_protocol_t  proto,
uint16  flags 
)

Check if the specified protocol version is enabled.

Parameters
protoprotocol enum to check
flagsbitmask to check if proto is set
Returns
TRUE if protocol enabled; FALSE if protocol not enabled or error
See also
ncx_set_val_protocol_enabled

◆ ncx_write_tracefile()

void ncx_write_tracefile ( const char *  buff,
uint32  count 
)

Write a byte to the tracefile.

Internal function only

Parameters
buffbuffer to write
countnumber of chars to write
Here is the caller graph for this function:

◆ ncx_yang_cbor_enabled()

boolean ncx_yang_cbor_enabled ( void  )

Get the YANG to CBOR Code enabled flag.

Returns
TRUE if YANG to CBOR binary encoding enabled
Here is the caller graph for this function:

◆ send_buff()

status_t send_buff ( int  fd,
const char *  buffer,
size_t  cnt 
)

Send the buffer to the network peer.

This function is used by applications which do not select for write_fds, and may not block (if fnctl used)

Parameters
fdthe socket to write to
bufferthe buffer to write
cntthe number of bytes to write
Returns
status
Here is the caller graph for this function: