yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches
ses.h File Reference

NETCONF Session Common definitions module. More...

#include <stdio.h>
#include <time.h>
#include <xmlreader.h>
#include "dlq.h"
#include "ncxtypes.h"
#include "status.h"
#include "tstamp.h"
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
Include dependency graph for ses.h:

Go to the source code of this file.

Data Structures

struct  ses_stats_t
 Per Session Statistics. More...
 
struct  ses_total_stats_t
 Session Total Statistics. More...
 
struct  ses_msg_buff_t
 Session Message Buffer. More...
 
struct  ses_ready_t
 embedded Q header for the message ready Q The 'inq' flag is used to prevent queue corruption More...
 
struct  ses_msg_t
 Session Message. More...
 
struct  ses_cb_t
 Session Control Block. More...
 

Macros

#define SES_MY_SID(S)   ((S)->sid)
 get session-id
 
#define SES_MY_FD(S)   ((S)->fd)
 get file descriptor
 
#define SES_MY_USERNAME(S)   ((S)->username)
 get username
 
#define SES_KILLREQ_SET(S)   ((S)->state >= SES_ST_SHUTDOWN_REQ)
 check if a kill request is set
 
#define SES_ACK_KILLREQ(S)   ((S)->state = SES_ST_SHUTDOWN)
 ack a kill request
 
#define SES_OUT_BYTES(S)   (S)->stats.out_bytes
 get session out bytes
 
#define SES_LINELEN(S)   (S)->stats.out_line
 get current out line number
 
#define SES_LINESIZE(S)   (S)->linesize
 get current line size
 
#define SES_IN_ENCODING(S)   (S)->in_encoding
 get the inbound message encoding
 
#define SES_OUT_ENCODING(S)   (S)->out_encoding
 get the outbound message encoding
 
#define SES_IS_DUMMY(S)   ((S)->sid == 0)
 test if this is a dummy session
 
#define SES_IS_YCONTROL(S)   ((S)->ycontrol)
 test if this is a YControl session
 
#define SES_CONN_CLOSED(S)   (S)->conn_closed
 check if the connection is closed
 
#define SES_SET_CUR_RPC_MSG(S, MSG)   (S)->cur_rpc_msg = MSG
 set the current RPC message
 
#define SES_GET_CUR_RPC_MSG(S)   (S)->cur_rpc_msg
 get the current RPC message
 
#define SES_GET_JSON_1LINE(S)   (S)->json_1line
 get the JSON 1 line state
 
#define SES_USE_JSON_ATTRS(S)   (S)->json_attrs
 get the JSON use attributes flag
 
#define SES_SET_JSON_ATTRS(S)   (S)->json_attrs = TRUE
 set the JSON attributes flag
 
#define SES_SET_LEAFLIST_PTR(S, V)   (S)->leaflist = V
 set the session leaf-list pointer
 
#define SES_GET_LEAFLIST_PTR(S)   (S)->leaflist
 get the session leaf-list pointer
 
#define SES_SET_LEAFLIST_ATTRS(S, A)   (S)->any_leaflist_attrs = A
 set the leaf-list attributes
 
#define SES_GET_LEAFLIST_ATTRS(S)   (S)->any_leaflist_attrs
 get the leaf-list attributes
 
#define SES_KEEP_XMLNS(S)   (S)->keep_xmlns
 get keep xmlns attributes flag
 
#define SES_RAWXML_MODE(S)   (S)->rawxml_mode
 get the raw XML mode
 
#define SES_STATE(S)   (S)->state
 get the session state
 
#define SES_PEERADDR(S)   (S)->peeraddr
 get the session peer address
 
#define SES_PEERPORT(S)   (S)->peerport
 get the session peer port number
 
#define SES_TRANSPORT(S)   (S)->transport
 get the session transport enum
 
#define SES_PROTOCOL(S)   (S)->protocol
 get the session protocol enum
 
#define SES_IS_IPV6(S)   (S)->is_ipv6
 check if the session is using IPv6
 
#define SES_IS_CALLHOME(S)   (S)->is_callhome
 check if this is a callhome session
 
#define SES_TYPE(S)   (S)->type
 get the session type
 
#define SES_GET_COOKIE(S)   (S)->get_cookie
 get the session cookie
 
#define SES_BREADCRUMBQ(S)   &(S)->breadcrumbQ
 get the session breadcrumb Q
 
#define SES_CURMSG(S)   (S)->curmsg
 get the session current message
 
#define SES_START_TLS(S)   (S)->start_tls
 get the start TLS flag
 
#define SES_WILDCARD_OK(S)   (S)->wildcard_ok
 check if wildcard OK in XML filters
 
#define SES_MGRCB(S)   (S)->mgrcb
 get the manager session control block
 
#define SES_NOTIF_ACTIVE(S)   (S)->notif_active
 check if notifications are active
 
#define SES_RFC8639_NOTIF_COUNT(S)   (S)->rfc8639_notif_cnt
 get the notification count
 
#define SES_BINARY_NOTIFS(S)   (S)->binary_notifs
 establish-subscription used with encode-yang-cbor used on the session S
 
#define BINLOG   (const xmlChar *)"***binary***"
 If binary encoding then this message will be printed instead of showing binary characters in the log files.
 
#define SES_CALLHOME_NAME(S)   (S)->callhome_name
 agt only: Get the name of the callhome server that this session was started for so it can be reconnected only applies to NETCONF over TLS sessions
 
#define SES_FREE_PENDING(S)   (S)->free_pending
 agt only: Set this flag in agt_ses to delay freeing a subsystem session that is in progress with a remote transaction This will cause agt_top to clean up the session
 
#define SES_NULL_SID   0
 session ID zero not used
 
#define SES_MSG_BUFFSIZE   1000
 controls the size of each buffer chunk More...
 
#define SES_MAX_BUFFERS   500000
 max number of buffer chunks a session can have allocated at once This is an arbitrary limit – no static memory is allocated based on this constant
 
#define SES_MAX_FREE_BUFFERS   4
 max number of buffers a session is allowed to cache in its freeQ
 
#define SES_MAX_BUFFSEND   32
 max number of buffers to try to send in one call to the write fn
 
#define SES_MAX_BYTESEND   0xffff
 max number of bytes to try to send in one call to the write_fn
 
#define SES_DEF_LINESIZE   72
 max desired lines size; not a hard limit
 
#define SES_MAX_STARTCHUNK_SIZE   13
 max size of a valid base:1.1 chunk header start tag
 
#define SES_MAX_CHUNKNUM_SIZE   10
 max size of the chunk size number in the chunk start tag
 
#define SES_STARTCHUNK_PAD   10
 padding at start of buffer for chunk tagging More...
 
#define SES_ENDCHUNK_PAD   8
 leave enough room at the end for EOChunks for framing11 or http_chunk_mode
 
#define SES_READBUFF_SIZE   1000
 default read buffer size
 
#define SES_GET_YPMODE(S)   (S)->yp_mode
 get internal YP mode flag
 
#define SES_SET_YPMODE(S, V)   (S)->yp_mode = V
 set internal YP mode flag
 
#define SES_REMOTE_WAIT(S)   (S)->remote_wait
 get remote wait flag
 
#define SES_NEED_FILE_OVERRIDE(S)   ((S)->file_override && (S)->fp)
 get file override flag (used in client)
 
#define SES_SYSTEM_USERNAME   NCX_EL_SYSTEM
 system username used in agt_state to report session state
 

Typedefs

typedef uint32 ses_id_t
 Session ID.
 
typedef ssize_t(* ses_read_fn_t) (void *s, char *buff, size_t bufflen, bool *erragain)
 optional read function for the session More...
 
typedef status_t(* ses_write_fn_t) (void *s)
 optional write function for the session More...
 

Enumerations

enum  ses_ypmode_t {
  SES_YPMODE_NONE ,
  SES_YPMODE_HA ,
  SES_YPMODE_RESTCONF ,
  SES_YPMODE_NETCONF
}
 YANG-PATCH Mode. More...
 
enum  ses_type_t {
  SES_TYP_NONE ,
  SES_TYP_NETCONF ,
  SES_TYP_DUMMY ,
  SES_TYP_YCONTROL ,
  SES_TYP_COAP ,
  SES_TYP_SNMP ,
  SES_TYP_GNMI
}
 Session Types. More...
 
enum  ses_transport_t {
  SES_TRANSPORT_NONE ,
  SES_TRANSPORT_SSH ,
  SES_TRANSPORT_BEEP ,
  SES_TRANSPORT_SOAP ,
  SES_TRANSPORT_SOAPBEEP ,
  SES_TRANSPORT_TLS ,
  SES_TRANSPORT_TCP_TAILF ,
  SES_TRANSPORT_TCP_NCX ,
  SES_TRANSPORT_HTTP ,
  SES_TRANSPORT_CLI ,
  SES_TRANSPORT_WEBUI ,
  SES_TRANSPORT_AFLOCAL ,
  SES_TRANSPORT_COAP ,
  SES_TRANSPORT_COAP_DTLS ,
  SES_TRANSPORT_SNMP ,
  SES_TRANSPORT_NETCONF_TLS ,
  SES_TRANSPORT_GNMI
}
 NETCONF Transport Types. More...
 
enum  ses_state_t {
  SES_ST_NONE ,
  SES_ST_INIT ,
  SES_ST_HELLO_WAIT ,
  SES_ST_XRD_WAIT ,
  SES_ST_RESTCAPS_WAIT ,
  SES_ST_IDLE ,
  SES_ST_IN_MSG ,
  SES_ST_SHUTDOWN_REQ ,
  SES_ST_SHUTDOWN
}
 Session States. More...
 
enum  ses_instate_t {
  SES_INST_NONE ,
  SES_INST_IDLE ,
  SES_INST_INMSG ,
  SES_INST_INSTART ,
  SES_INST_INBETWEEN ,
  SES_INST_INEND
}
 Session Input Handler States for base:1.0 EOM processing. More...
 
enum  ses_mode_t {
  SES_MODE_NONE ,
  SES_MODE_XML ,
  SES_MODE_XMLDOC ,
  SES_MODE_HTML ,
  SES_MODE_TEXT ,
  SES_MODE_BINARY
}
 Session Output Mode. More...
 
enum  ses_term_reason_t {
  SES_TR_NONE ,
  SES_TR_CLOSED ,
  SES_TR_KILLED ,
  SES_TR_DROPPED ,
  SES_TR_TIMEOUT ,
  SES_TR_OTHER ,
  SES_TR_BAD_START ,
  SES_TR_BAD_HELLO
}
 Session Termination reason. More...
 
enum  ses_prolog_state_t {
  SES_PRST_NONE ,
  SES_PRST_WAITING ,
  SES_PRST_DONE
}
 prolog parsing state More...
 

Functions

ses_cb_tses_new_scb (void)
 Create a new session control block. More...
 
ses_cb_tses_new_dummy_scb (void)
 Create a new dummy session control block. More...
 
ses_cb_tses_new_coap_scb (void)
 Create a new global CoAP session control block. More...
 
void ses_init_coap_scb (ses_cb_t *scb)
 Initialize a CoAP session control block. More...
 
ses_cb_tses_new_snmp_scb (void)
 Create a new global SNMP session control block. More...
 
void ses_free_scb (ses_cb_t *scb)
 Free a session control block. More...
 
void ses_putchar (ses_cb_t *scb, uint32 ch)
 Write one char to the session, without any translation. More...
 
void ses_put_binchar (ses_cb_t *scb, uint32 ch)
 Write one binary char to the session, without any translation. More...
 
void ses_putstr (ses_cb_t *scb, const xmlChar *str)
 Write a zero-terminated string to the session. More...
 
void ses_put_binstr (ses_cb_t *scb, const xmlChar *str, uint32 len)
 Write a binary string to the session. More...
 
void ses_putstr_indent (ses_cb_t *scb, const xmlChar *str, int32 indent)
 Write a zero-terminated content string to the session with indentation. More...
 
void ses_putcstr (ses_cb_t *scb, const xmlChar *str, int32 indent)
 write XML element safe content string Write a zero-terminated element content string to the session More...
 
void ses_puthstr (ses_cb_t *scb, const xmlChar *str)
 write HTML element safe content string Write a zero-terminated element content string to the session More...
 
void ses_putcchar (ses_cb_t *scb, uint32 ch)
 Write one content char to the session, with translation as needed. More...
 
void ses_putastr (ses_cb_t *scb, const xmlChar *str, int32 indent)
 write XML attribute safe content string Write a zero-terminated attribute content string to the session More...
 
void ses_putjstr (ses_cb_t *scb, const xmlChar *str, int32 indent)
 write JSON safe content string Write a zero-terminated element content string to the session More...
 
void ses_indent (ses_cb_t *scb, int32 indent)
 Write the proper newline + indentation to the specified session. More...
 
int32 ses_indent_count (const ses_cb_t *scb)
 Get the logging indent count for this session. More...
 
int32 ses_message_indent_count (const ses_cb_t *scb)
 Get the message indent count for this session. More...
 
void ses_set_indent (ses_cb_t *scb, int32 indent)
 Set the logging indent count for this session. More...
 
void ses_set_message_indent (ses_cb_t *scb, int32 indent)
 Set the message indent count for this session. More...
 
void ses_set_mode (ses_cb_t *scb, ses_mode_t mode)
 Set the output mode for the specified session. More...
 
ses_mode_t ses_get_mode (ses_cb_t *scb)
 Get the output mode for the specified session. More...
 
void ses_start_msg_mode (ses_cb_t *scb)
 Set the message output mode to active. More...
 
void ses_stop_msg_mode (ses_cb_t *scb)
 Set the message output mode to inactive. More...
 
status_t ses_start_msg (ses_cb_t *scb)
 Start a new outbound message on the specified session. More...
 
void ses_finish_msg (ses_cb_t *scb)
 Finish an outbound message on the specified session. More...
 
int ses_read_cb (void *context, char *buffer, int len)
 The IO input front-end for the xmlTextReader parser read fn. More...
 
status_t ses_accept_input (ses_cb_t *scb)
 The IO input handler for the ncxserver loop. More...
 
const xmlChar * ses_state_name (ses_state_t state)
 Get the name of a session state from the enum value. More...
 
ncx_withdefaults_t ses_withdef (const ses_cb_t *scb)
 Get the with-defaults value for this session. More...
 
uint32 ses_line_left (const ses_cb_t *scb)
 Get the number of bytes that can be added to the current line before the session linesize limit is reached. More...
 
void ses_put_extern (ses_cb_t *scb, const xmlChar *fname)
 write the contents of a file to the session More...
 
status_t ses_put_extern2 (ses_cb_t *scb, const xmlChar *fname)
 write the contents of a file to the session More...
 
status_t ses_put_extern_bin (ses_cb_t *scb, const xmlChar *fname)
 write the contents of a binary file to the session More...
 
ses_total_stats_tses_get_total_stats (void)
 Get a r/w pointer to the the session totals stats. More...
 
ses_transport_t ses_get_transport (ses_cb_t *scb)
 Get the transport enum for a given session. More...
 
ses_transport_t ses_get_transport_enum (const xmlChar *str)
 Get the enum value for the yumaworks-types:transport-type. More...
 
const xmlChar * ses_get_transport_name (ses_transport_t transport)
 Get the name of the transport for a given enum value. More...
 
const xmlChar * ses_get_transport_yang_name (ses_transport_t transport)
 Get the name of the transport for a given enum value. More...
 
void ses_set_xml_nons (ses_cb_t *scb)
 force xmlns attributes to be skipped in XML mode More...
 
boolean ses_get_xml_nons (const ses_cb_t *scb)
 force xmlns attributes to be skipped in XML mode More...
 
status_t ses_set_protocol (ses_cb_t *scb, ncx_protocol_t proto)
 set the NETCONF protocol version in use More...
 
ncx_protocol_t ses_get_protocol (const ses_cb_t *scb)
 Get the NETCONF protocol set (or unset) for this session. More...
 
void ses_set_protocols_requested (ses_cb_t *scb, ncx_protocol_t proto)
 set the NETCONF protocol versions requested More...
 
boolean ses_protocol_requested (ses_cb_t *scb, ncx_protocol_t proto)
 check if the NETCONF protocol version was requested More...
 
void ses_set_extern_xml_mode (ses_cb_t *scb, boolean rawxml_mode)
 Setup the scb for external XML parsing. More...
 
void ses_set_extern_xml_mode_ex (ses_cb_t *scb, boolean rawxml_mode, boolean keep_xmlns)
 Setup the scb for external XML parsing. More...
 
void ses_clear_extern_xml_mode (ses_cb_t *scb, boolean rawxml_mode)
 Clear the scb from external XML parsing. More...
 
void ses_clear_extern_xml_mode_ex (ses_cb_t *scb, boolean rawxml_mode, boolean keep_xmlns)
 Clear the scb from external XML parsing. More...
 
void ses_set_out_encoding (ses_cb_t *scb, ncx_display_mode_t encoding)
 Set the output encoding. More...
 
void ses_set_SSE_encoding (ses_cb_t *scb)
 Set the output encoding to have a Server Sent Events filter Used for notification delivery over RESTCONF/HTTP. More...
 
ncx_display_mode_t ses_get_out_encoding (ses_cb_t *scb)
 Get the output encoding. More...
 
int32 ses_new_indent_count (boolean indent_in, int32 indent, int32 indent_amount)
 Get the new indent count from the current and indent_amount. More...
 
void ses_free_xml_reader (ses_cb_t *scb)
 Free the xmlTextReader for the session The encoding is switching from XML to something else. More...
 
status_t ses_getline_cb (xmlChar *fillbuff, uint32 fillbuffsize, void *cookie)
 The IO input front-end for the tk_parse_json_buffs function. More...
 
status_t ses_set_control_session (ses_cb_t *scb)
 Set the specified session as a control session. More...
 
boolean ses_is_control_session (ses_cb_t *scb)
 Check if the specified session is a control session. More...
 
void ses_set_dbapi_session (ses_cb_t *scb)
 Set the specified session as a DB-API control session. More...
 
boolean ses_is_dbapi_session (ses_cb_t *scb)
 Check if the specified session is a DB-API control session. More...
 
void ses_set_dbapi_system_session (ses_cb_t *scb)
 Set the specified session as a DB-API control session for system edits. More...
 
boolean ses_is_dbapi_system_session (ses_cb_t *scb)
 Check if the specified session is a DB-API control session for system edits. More...
 
void ses_clear_dbapi_system_session (ses_cb_t *scb)
 Clear a session of the DB-API system status. More...
 
boolean ses_is_system_session (ses_cb_t *scb)
 Check if the specified session is an internal system session. More...
 
int32 ses_add_indent (ses_cb_t *scb, int32 indent)
 Add in the new indent amount. More...
 
int32 ses_dec_indent (ses_cb_t *scb, int32 indent)
 Remove the specified indent amount. More...
 
ncx_msg_encoding_t ses_get_msg_encoding (const ses_cb_t *scb)
 Get the message encoding for the HTTP session. More...
 
status_t ses_start_http_chunk_mode (ses_cb_t *scb)
 Start outputting buffers in HTTP 1.1 chunk mode. More...
 
const xmlChar * ses_get_entry_point (ses_cb_t *scb)
 Get the RESTCONF entry_point. More...
 
status_t ses_set_entry_point (ses_cb_t *scb, const xmlChar *point)
 Set the RESTCONF entry_point. More...
 
boolean ses_notifications_active (const ses_cb_t *scb)
 Check if the session has notifications active. More...
 
status_t ses_set_gnmi_control_session (ses_cb_t *scb)
 Set the specified session as a gNMI control session. More...
 
boolean ses_is_gnmi_control_session (ses_cb_t *scb)
 Check if the specified session is a gNMI control session. More...
 
void ses_set_gnmi_session (ses_cb_t *scb)
 Set the specified session as a gNMI session. More...
 
boolean ses_is_gnmi_session (ses_cb_t *scb)
 Check if the specified session is a gNMI session. More...
 
status_t ses_add_breadcrumb_obj (ses_cb_t *scb, struct obj_template_t_ *obj)
 Add an object to the breadcrumbQ. More...
 
void ses_clean_breadcrumbQ (ses_cb_t *scb)
 Clean the breadcrumbQ. More...
 
boolean ses_dropped (const ses_cb_t *scb)
 Check if the session has been dropped by the client. More...
 
status_t ses_set_file_override (ses_cb_t *scb, const xmlChar *filespec, boolean is_binary)
 Setup the session in file write override mode. More...
 
void ses_clear_file_override (ses_cb_t *scb)
 Cleanup the session in file write override mode Does not delete the file, just closes it! More...
 
void ses_start_checksum (ses_cb_t *scb)
 Clear the checksum field and start checksum mode. More...
 
uint32 ses_finish_checksum (ses_cb_t *scb, uint32 *checksum_cnt)
 Stop checksum mode and return the final checksum. More...
 
boolean ses_dropped_ex (ses_cb_t *scb)
 Check if the session has been dropped by the client. More...
 
status_t ses_set_grpc_control_session (ses_cb_t *scb)
 Set the specified session as a gRPC control session. More...
 
boolean ses_is_grpc_control_session (ses_cb_t *scb)
 Check if the specified session is a gRPC control session. More...
 
void ses_set_grpc_session (ses_cb_t *scb)
 Set the specified session as a gRPC session. More...
 
boolean ses_is_grpc_session (ses_cb_t *scb)
 Check if the specified session is a gRPC session. More...
 
void ses_dump_binary_buff (const xmlChar *buff, size_t bufflen)
 Dump some bytes from the binary buffer (max 256) More...
 
boolean ses_poll_ready (ses_cb_t *scb)
 Check if the specified session is ready to read bytes. More...
 
const xmlChar * ses_get_scb_username (ses_cb_t *scb)
 Get the username to use from an SCB. More...
 
const xmlChar * ses_get_scb_client_addr (ses_cb_t *scb)
 Get the client addr to use from an SCB. More...
 

Detailed Description

NETCONF Session Common definitions module.