yumapro  21.10T-9
YumaPro SDK
ses.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_ses
13 #define _H_ses
14 /* FILE: ses.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
26 /*********************************************************************
27 * *
28 * C H A N G E H I S T O R Y *
29 * *
30 *********************************************************************
31 
32 date init comment
33 ----------------------------------------------------------------------
34 30-dec-05 abb Begun.
35 */
36 
37 /* used by applications to generate FILE output */
38 #include <stdio.h>
39 
40 /* used for timestamps and time deltas */
41 #include <time.h>
42 
43 /* used by the agent for the xmlTextReader interface */
44 #include <xmlreader.h>
45 
46 #ifndef _H_dlq
47 #include "dlq.h"
48 #endif
49 
50 #ifndef _H_ncxtypes
51 #include "ncxtypes.h"
52 #endif
53 
54 #ifndef _H_status
55 #include "status.h"
56 #endif
57 
58 #ifndef _H_tstamp
59 #include "tstamp.h"
60 #endif
61 
62 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
63 #include <net-snmp/net-snmp-config.h>
64 
65 #ifndef UCLINUX
66 #include <net-snmp/net-snmp-features.h>
67 #endif
68 
69 #include <net-snmp/net-snmp-includes.h>
70 #endif
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 /********************************************************************
77 * *
78 * C O N S T A N T S *
79 * *
80 *********************************************************************/
81 
105 #define SES_MY_SID(S) ((S)->sid)
106 
108 #define SES_MY_FD(S) ((S)->fd)
109 
111 #define SES_MY_USERNAME(S) ((S)->username)
112 
114 #define SES_KILLREQ_SET(S) ((S)->state >= SES_ST_SHUTDOWN_REQ)
115 
117 #define SES_ACK_KILLREQ(S) ((S)->state = SES_ST_SHUTDOWN)
118 
120 #define SES_OUT_BYTES(S) (S)->stats.out_bytes
121 
123 #define SES_LINELEN(S) (S)->stats.out_line
124 
126 #define SES_LINESIZE(S) (S)->linesize
127 
129 #define SES_IN_ENCODING(S) (S)->in_encoding
130 
132 #define SES_OUT_ENCODING(S) (S)->out_encoding
133 
135 #define SES_IS_DUMMY(S) ((S)->sid == 0)
136 
138 #define SES_IS_YCONTROL(S) ((S)->ycontrol)
139 
141 #define SES_CONN_CLOSED(S) (S)->conn_closed
142 
144 #define SES_SET_CUR_RPC_MSG(S,MSG) (S)->cur_rpc_msg = MSG
145 
147 #define SES_GET_CUR_RPC_MSG(S) (S)->cur_rpc_msg
148 
150 #define SES_GET_JSON_1LINE(S) (S)->json_1line
151 
153 #define SES_USE_JSON_ATTRS(S) (S)->json_attrs
154 
156 #define SES_SET_JSON_ATTRS(S) (S)->json_attrs = TRUE
157 
159 #define SES_SET_LEAFLIST_PTR(S,V) (S)->leaflist = V
160 
162 #define SES_GET_LEAFLIST_PTR(S) (S)->leaflist
163 
165 #define SES_SET_LEAFLIST_ATTRS(S,A) (S)->any_leaflist_attrs = A
166 
168 #define SES_GET_LEAFLIST_ATTRS(S) (S)->any_leaflist_attrs
169 
171 #define SES_KEEP_XMLNS(S) (S)->keep_xmlns
172 
174 #define SES_RAWXML_MODE(S) (S)->rawxml_mode
175 
177 #define SES_STATE(S) (S)->state
178 
180 #define SES_PEERADDR(S) (S)->peeraddr
181 
183 #define SES_TRANSPORT(S) (S)->transport
184 
186 #define SES_PROTOCOL(S) (S)->protocol
187 
189 #define SES_IS_IPV6(S) (S)->is_ipv6
190 
192 #define SES_IS_CALLHOME(S) (S)->is_callhome
193 
195 #define SES_TYPE(S) (S)->type
196 
198 #define SES_GET_COOKIE(S) (S)->get_cookie
199 
201 #define SES_BREADCRUMBQ(S) &(S)->breadcrumbQ
202 
204 #define SES_CURMSG(S) (S)->curmsg
205 
207 #define SES_START_TLS(S) (S)->start_tls
208 
210 #define SES_WILDCARD_OK(S) (S)->wildcard_ok
211 
213 #define SES_MGRCB(S) (S)->mgrcb
214 
216 #define SES_NOTIF_ACTIVE(S) (S)->notif_active
217 
219 #define SES_RFC8639_NOTIF_COUNT(S) (S)->rfc8639_notif_cnt
220 
222 #define SES_NULL_SID 0
223 
232 #define SES_MSG_BUFFSIZE 1000
233 
238 #define SES_MAX_BUFFERS 500000
239 
241 #ifdef WITH_COAP
242 #define SES_MAX_FREE_BUFFERS 4
243 #else
244 #define SES_MAX_FREE_BUFFERS 32
245 #endif // WITH_COAP
246 
248 #define SES_MAX_BUFFSEND 32
249 
251 #define SES_MAX_BYTESEND 0xffff
252 
254 #define SES_DEF_LINESIZE 72
255 
257 #define SES_MAX_STARTCHUNK_SIZE 13
258 
260 #define SES_MAX_CHUNKNUM_SIZE 10
261 
273 #define SES_STARTCHUNK_PAD 10
274 
278 #define SES_ENDCHUNK_PAD 8
279 
281 #define SES_READBUFF_SIZE 1000
282 
284 #define SES_GET_YPMODE(S) (S)->yp_mode
285 
287 #define SES_SET_YPMODE(S,V) (S)->yp_mode = V
288 
290 #define SES_REMOTE_WAIT(S) (S)->remote_wait
291 
293 #define SES_NEED_FILE_OVERRIDE(S) ((S)->file_override && (S)->fp)
294 
296 #define SES_SYSTEM_USERNAME NCX_EL_SYSTEM
297 
298 
299 /********************************************************************
300 * *
301 * T Y P E S *
302 * *
303 *********************************************************************/
304 
306 typedef uint32 ses_id_t;
307 
309 typedef enum ses_ypmode_t_ {
314 } ses_ypmode_t;
315 
316 
318 typedef enum ses_type_t_ {
326 } ses_type_t;
327 
328 
330 typedef enum ses_transport_t_ {
344  SES_TRANSPORT_COAP_DTLS, /* CoAP DTLS/UDP socket */
349 
350 
352 typedef enum ses_state_t_ {
362 } ses_state_t;
363 
364 
366 typedef enum ses_instate_t_ {
373 } ses_instate_t;
374 
375 
377 typedef enum ses_mode_t_ {
383 } ses_mode_t;
384 
385 
387 typedef enum ses_term_reason_t_ {
397 
398 
400 typedef enum ses_prolog_state_t_ {
405 
406 
414 typedef struct ses_stats_t_ {
416  uint32 in_bytes;
417 
419  uint32 out_bytes;
420 
422  uint32 out_line;
423 
425  uint32 inRpcs;
426 
428  uint32 inBadRpcs;
429 
431  uint32 outRpcErrors;
432 
435 
437  uint32 requests;
438 } ses_stats_t;
439 
440 
442 typedef struct ses_total_stats_t_ {
445 
448 
451 
453  uint32 inBadHellos;
454 
456  uint32 inSessions;
457 
460 
463 
465  xmlChar startTime[TSTAMP_MIN_SIZE];
467 
468 
470 typedef struct ses_msg_buff_t_ {
471  dlq_hdr_t qhdr;
472  size_t buffstart;
473  size_t bufflen;
474  size_t buffpos;
475  boolean islast;
481  xmlChar buff[SES_MSG_BUFFSIZE+1];
483 
484 
488 typedef struct ses_ready_t_ {
490  dlq_hdr_t hdr;
491 
493  ses_id_t sid;
494 
496  boolean inq;
497 
499  boolean ycontrol;
500 } ses_ready_t;
501 
502 
504 typedef struct ses_msg_t_ {
505  dlq_hdr_t qhdr;
506  boolean ready;
507  boolean dispatched;
509  dlq_hdr_t buffQ;
510  ses_prolog_state_t prolog_state;
511  size_t curchunksize;
512  size_t expchunksize;
513 } ses_msg_t;
514 
515 
526 typedef ssize_t (*ses_read_fn_t) (void *s,
527  char *buff,
528  size_t bufflen,
529  bool *erragain);
530 
531 
538 typedef status_t (*ses_write_fn_t) (void *s);
539 
540 
542 typedef struct ses_cb_t_ {
543  dlq_hdr_t qhdr;
544  ses_type_t type;
547  ses_transport_t transport;
549  ses_state_t state;
550  ses_mode_t mode;
551  ses_id_t sid;
552  ses_id_t killedbysid;
553  ses_id_t rollback_sid;
554  ses_term_reason_t termreason;
555  time_t hello_time;
556  time_t last_rpc_time;
557  xmlChar *start_time;
558  xmlChar *username;
559  xmlChar *peeraddr;
562  xmlChar *subsys_id;
564  int tid;
565  void *tcb;
566  boolean locks_released;
568  boolean conn_closed;
569  boolean active;
570  boolean notif_active;
571  boolean stream_output;
572  boolean noxmlns;
573  boolean framing11;
574  boolean keep_xmlns;
575  boolean warn_xml;
576  boolean rawxml_mode;
577  boolean direct_mode;
578  boolean msg_mode;
579  boolean ycontrol;
580  boolean dbapi;
581  boolean dbapi_system;
582  boolean sse_mode;
583  boolean ypgnmi;
586  boolean restconf_notif;
588  boolean json_1line;
589  boolean http_chunk_mode;
590  boolean http_waitrn;
591  boolean json_attrs;
593  boolean is_ycontrol_scb;
594  boolean is_ipv6;
595  boolean is_callhome;
596  boolean dropped;
597  boolean start_tls;
598  boolean checksum_mode;
599  uint32 last_ch;
600  struct val_value_t_ *leaflist;
606 
611 
612  xmlTextReaderPtr reader;
613  FILE *fp;
614  int fd;
617  uint32 inendpos;
618  ses_instate_t instate;
619  uint32 buffcnt;
620  uint32 freecnt;
621  dlq_hdr_t msgQ;
622  dlq_hdr_t freeQ;
623  dlq_hdr_t outQ;
628  void *mgrcb;
629  struct rpc_msg_t_ *cur_rpc_msg;
631  struct yangapi_cb_t_ *rcb;
632  xmlChar *entry_point;
638  xmlChar startchunk[SES_MAX_STARTCHUNK_SIZE+1];
639 
641  xmlChar *readbuff;
642  uint32 readbuffsize;
644  /*** user preferences ***/
645  int8 indent;
646  int8 msg_indent;
647  uint32 linesize;
649  uint32 cache_timeout;
658  struct agt_acm_cache_t_ *acm_cache;
659 
661  xmlChar *service_name;
664  boolean reading_header;
666  boolean chunk_based;
667  int32 total_length;
670  boolean use_traceid;
671 
677  ses_ypmode_t yp_mode;
678 
683  boolean skip_modnames;
684 
685  void *openssl_ctx;
686  void *openssl_ssl;
691  void *get_cookie;
692 
697  boolean remote_wait;
698 
703  dlq_hdr_t breadcrumbQ;
707 
712  boolean wildcard_ok;
713 
718  boolean file_override;
719 
721  struct cfg_template_t_ *fake_candidate;
722 
725 
727  uint32 checksum;
728  uint32 checksum_cnt;
740  dlq_hdr_t snmp_getnext_listQ;
741 
743  struct obj_template_t_ *snmp_table_obj;
744 
745  boolean ypgrpc;
747 } ses_cb_t;
748 
749 
753 /********************************************************************
754 * *
755 * F U N C T I O N S *
756 * *
757 *********************************************************************/
758 
775 extern ses_cb_t *
776  ses_new_scb (void);
777 
778 
784 extern ses_cb_t *
785  ses_new_dummy_scb (void);
786 
787 
788 #ifdef WITH_COAP
789 
794 extern ses_cb_t *
795  ses_new_coap_scb (void);
796 
797 
803 extern void
805 
806 #endif // WITH_COAP
807 
808 
809 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
810 
815 extern ses_cb_t *
816  ses_new_snmp_scb (void);
817 
818 #endif // WITH_SNMP
819 
820 
826 extern void
827  ses_free_scb (ses_cb_t *scb);
828 
829 
843 extern void
844  ses_putchar (ses_cb_t *scb,
845  uint32 ch);
846 
847 
854 extern void
855  ses_putstr (ses_cb_t *scb,
856  const xmlChar *str);
857 
858 
872 extern void
874  const xmlChar *str,
875  int32 indent);
876 
877 
888 extern void
889  ses_putcstr (ses_cb_t *scb,
890  const xmlChar *str,
891  int32 indent);
892 
893 
903 extern void
904  ses_puthstr (ses_cb_t *scb,
905  const xmlChar *str);
906 
907 
914 extern void
915  ses_putcchar (ses_cb_t *scb,
916  uint32 ch);
917 
918 
929 extern void
930  ses_putastr (ses_cb_t *scb,
931  const xmlChar *str,
932  int32 indent);
933 
934 
945 extern void
946  ses_putjstr (ses_cb_t *scb,
947  const xmlChar *str,
948  int32 indent);
949 
950 
961 extern void
962  ses_indent (ses_cb_t *scb,
963  int32 indent);
964 
965 
972 extern int32
973  ses_indent_count (const ses_cb_t *scb);
974 
975 
982 extern int32
983  ses_message_indent_count (const ses_cb_t *scb);
984 
985 
992 extern void
993  ses_set_indent (ses_cb_t *scb,
994  int32 indent);
995 
996 
1003 extern void
1004  ses_set_message_indent (ses_cb_t *scb, int32 indent);
1005 
1006 
1013 extern void
1014  ses_set_mode (ses_cb_t *scb,
1015  ses_mode_t mode);
1016 
1017 
1024 extern ses_mode_t
1025  ses_get_mode (ses_cb_t *scb);
1026 
1027 
1033 extern void ses_start_msg_mode (ses_cb_t *scb);
1034 
1035 
1041 extern void ses_stop_msg_mode (ses_cb_t *scb);
1042 
1043 
1050 extern status_t
1051  ses_start_msg (ses_cb_t *scb);
1052 
1053 
1059 extern void
1060  ses_finish_msg (ses_cb_t *scb);
1061 
1062 
1083 extern int
1084  ses_read_cb (void *context,
1085  char *buffer,
1086  int len);
1087 
1088 
1103 extern status_t
1104  ses_accept_input (ses_cb_t *scb);
1105 
1106 
1113 extern const xmlChar *
1114  ses_state_name (ses_state_t state);
1115 
1116 
1123 extern ncx_withdefaults_t
1124  ses_withdef (const ses_cb_t *scb);
1125 
1126 
1134 extern uint32
1135  ses_line_left (const ses_cb_t *scb);
1136 
1137 
1148 extern void
1149  ses_put_extern (ses_cb_t *scb,
1150  const xmlChar *fname);
1151 
1152 
1160 extern status_t
1161  ses_put_extern2 (ses_cb_t *scb,
1162  const xmlChar *fname);
1163 
1164 
1165 
1171 extern ses_total_stats_t *
1172  ses_get_total_stats (void);
1173 
1174 
1183 extern ses_transport_t
1184  ses_get_transport (ses_cb_t *scb);
1185 
1186 
1193 extern ses_transport_t
1194  ses_get_transport_enum (const xmlChar *str);
1195 
1196 
1203 extern const xmlChar *
1204  ses_get_transport_name (ses_transport_t transport);
1205 
1206 
1215 extern const xmlChar *
1216  ses_get_transport_yang_name (ses_transport_t transport);
1217 
1218 
1224 extern void
1225  ses_set_xml_nons (ses_cb_t *scb);
1226 
1227 
1236 extern boolean
1237  ses_get_xml_nons (const ses_cb_t *scb);
1238 
1239 
1247 extern status_t
1248  ses_set_protocol (ses_cb_t *scb,
1249  ncx_protocol_t proto);
1250 
1251 
1259 extern ncx_protocol_t
1260  ses_get_protocol (const ses_cb_t *scb);
1261 
1262 
1269 extern void
1271  ncx_protocol_t proto);
1272 
1273 
1281 extern boolean
1283  ncx_protocol_t proto);
1284 
1285 
1296 extern void
1298  boolean rawxml_mode);
1299 
1300 
1312 extern void
1314  boolean rawxml_mode,
1315  boolean keep_xmlns);
1316 
1317 
1329 extern void
1331  boolean rawxml_mode);
1332 
1333 
1345 extern void
1347  boolean rawxml_mode,
1348  boolean keep_xmlns);
1349 
1350 
1357 extern void
1359  ncx_display_mode_t encoding);
1360 
1361 
1368 extern void
1370 
1371 
1378 extern ncx_display_mode_t
1380 
1381 
1390 extern int32
1391  ses_new_indent_count (boolean indent_in,
1392  int32 indent,
1393  int32 indent_amount);
1394 
1395 
1403 extern void
1405 
1406 
1420 extern status_t
1421  ses_getline_cb (xmlChar *fillbuff,
1422  uint32 fillbuffsize,
1423  void *cookie);
1424 
1425 
1432 extern status_t
1434 
1435 
1442 extern boolean
1444 
1445 
1451 extern void
1453 
1454 
1461 extern boolean
1463 
1464 
1471 extern void
1473 
1474 
1482 extern boolean
1484 
1485 
1491 extern void
1493 
1494 
1501 extern boolean
1503 
1504 
1512 extern int32
1513  ses_add_indent (ses_cb_t *scb,
1514  int32 indent);
1515 
1516 
1524 extern int32
1525  ses_dec_indent (ses_cb_t *scb,
1526  int32 indent);
1527 
1528 
1535 extern ncx_msg_encoding_t
1536  ses_get_msg_encoding (const ses_cb_t *scb);
1537 
1538 
1545 extern status_t
1547 
1548 
1555 extern const xmlChar *
1557 
1558 
1566 extern status_t
1568  const xmlChar *point);
1569 
1570 
1577 extern boolean
1578  ses_notifications_active (const ses_cb_t *scb);
1579 
1580 
1581 #ifdef WITH_GNMI
1582 
1588 extern status_t
1590 
1591 
1598 extern boolean
1600 
1601 
1607 extern void
1609 
1610 
1617 extern boolean
1619 
1620 #endif //WITH_GNMI
1621 
1622 
1630 extern status_t
1632  struct obj_template_t_ *obj);
1633 
1634 
1640 extern void
1642 
1643 
1650 extern boolean
1651  ses_dropped (const ses_cb_t *scb);
1652 
1653 
1661 extern status_t
1663  const xmlChar *filespec);
1664 
1665 
1672 extern void
1674 
1675 
1681 extern void
1683 
1684 
1696 extern uint32
1698  uint32 *checksum_cnt);
1699 
1700 
1710 extern boolean
1711  ses_dropped_ex (ses_cb_t *scb);
1712 
1713 
1714 #ifdef WITH_GRPC
1715 
1721 extern status_t
1723 
1724 
1731 extern boolean
1733 
1734 
1740 extern void
1742 
1743 
1750 extern boolean
1752 
1753 #endif //WITH_GRPC
1754 
1758 #ifdef __cplusplus
1759 } /* end extern 'C' */
1760 #endif
1761 
1762 #endif /* _H_ses */
YumaWorks NETCONF over TCP.
Definition: ses.h:338
void ses_putchar(ses_cb_t *scb, uint32 ch)
Write one char to the session, without any translation.
Definition: ses.c:2375
status_t ses_set_control_session(ses_cb_t *scb)
Set the specified session as a control session.
Definition: ses.c:4419
boolean dispatched
in processing
Definition: ses.h:507
uint32 readbuffsize
input buffer size
Definition: ses.h:642
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! ...
Definition: ses.c:4969
dlq provides general double-linked list and queue support:
boolean ses_is_grpc_control_session(ses_cb_t *scb)
Check if the specified session is a gRPC control session.
Definition: ses.c:5131
ses_id_t sid
session ID of this session
Definition: ses.h:493
uint32 cache_timeout
vir-val cache tmr in sec
Definition: ses.h:649
void ses_put_extern(ses_cb_t *scb, const xmlChar *fname)
write the contents of a file to the session
Definition: ses.c:3558
ses_mode_t
Session Output Mode.
Definition: ses.h:377
ses_id_t rollback_sid
session ID for rollback
Definition: ses.h:553
Session Message.
Definition: ses.h:504
boolean ses_notifications_active(const ses_cb_t *scb)
Check if the session has notifications active.
Definition: ses.c:4838
boolean ycontrol
flag YControl session for priority processing
Definition: ses.h:499
ses_ypmode_t
YANG-PATCH Mode.
Definition: ses.h:309
boolean http_waitrn
T: wait for EOchunk, F: no wait.
Definition: ses.h:590
void ses_indent(ses_cb_t *scb, int32 indent)
Write the proper newline + indentation to the specified session.
Definition: ses.c:2790
struct yangapi_cb_t_ * rcb
REST-API control block.
Definition: ses.h:631
ses_total_stats_t * ses_get_total_stats(void)
Get a r/w pointer to the the session totals stats.
Definition: ses.c:3614
boolean restconf_notif
REST SSE notifications in progress.
Definition: ses.h:586
boolean active
<hello> completed ok
Definition: ses.h:569
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 ...
Definition: ses.c:2588
uint32 linesize
TERM line length.
Definition: ses.h:647
YumaPro CLI hook (ncxconnect, NETCONF framing)
Definition: ses.h:340
initialization state
Definition: ses.h:354
RESTCONF over SNMP.
Definition: ses.h:324
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 ...
Definition: ses.c:2544
boolean any_leaflist_attrs
T: leaf-list has attrs.
Definition: ses.h:592
xmlChar * entry_point
REST-API entry point.
Definition: ses.h:632
not set
Definition: ses.h:388
status_t ses_set_file_override(ses_cb_t *scb, const xmlChar *filespec)
Setup the session in file write override mode.
Definition: ses.c:4935
RESTCONF Capabilities processing.
Definition: ses.h:357
void ses_set_out_encoding(ses_cb_t *scb, ncx_display_mode_t encoding)
Set the output encoding.
Definition: ses.c:4138
size_t buffpos
buff cur position
Definition: ses.h:474
xmlTextReaderPtr reader
input stream reader
Definition: ses.h:612
uint32 inendpos
inside framing directive
Definition: ses.h:617
boolean restconf_sse_mode
T: RESTCONF SSE mode.
Definition: ses.h:585
ses_id_t killedbysid
killed-by session ID
Definition: ses.h:552
status_t ses_set_entry_point(ses_cb_t *scb, const xmlChar *point)
Set the RESTCONF entry_point.
Definition: ses.c:4721
struct val_value_t_ * leaflist
JSON attrs backptr.
Definition: ses.h:600
ncx_msg_encoding_t encoding
HTTP msg encoding.
Definition: ses.h:548
boolean ready
ready for parsing
Definition: ses.h:506
ses_stats_t stats
per-session stats added up for all sessions
Definition: ses.h:462
void * openssl_ssl
malloced with SSL_new
Definition: ses.h:686
boolean use_traceid
TRUE if OK to use Trace ID attr in the RPC calls.
Definition: ses.h:670
xmlChar * subsys_id
used for YCONTROL session only
Definition: ses.h:562
boolean sse_mode
T: Server Sent Events, F: normal.
Definition: ses.h:582
boolean stream_output
buffer/stream svr
Definition: ses.h:571
ses_cb_t * ses_new_dummy_scb(void)
Create a new dummy session control block.
Definition: ses.c:2121
ses_state_t
Session States.
Definition: ses.h:352
boolean ses_is_system_session(ses_cb_t *scb)
Check if the specified session is an internal system session.
Definition: ses.c:4495
size_t bufflen
buff actual size
Definition: ses.h:473
boolean dropped
T: session dropped in a msg.
Definition: ses.h:596
boolean dbapi
T: is DB-API session.
Definition: ses.h:580
void ses_clear_extern_xml_mode_ex(ses_cb_t *scb, boolean rawxml_mode, boolean keep_xmlns)
Clear the scb from external XML parsing.
Definition: ses.c:4112
internal YControl session w/ subsystem
Definition: ses.h:322
void ses_free_xml_reader(ses_cb_t *scb)
Free the xmlTextReader for the session The encoding is switching from XML to something else...
Definition: ses.c:4234
status_t ses_accept_input(ses_cb_t *scb)
The IO input handler for the ncxserver loop.
Definition: ses.c:3237
boolean ses_is_gnmi_session(ses_cb_t *scb)
Check if the specified session is a gNMI session.
Definition: ses.c:4819
boolean ycontrol
T: is ycontrol session.
Definition: ses.h:579
uint32 out_line
hack: bytes since &#39; &#39;, pretty-print
Definition: ses.h:422
ses_term_reason_t termreason
termination reason
Definition: ses.h:554
boolean json_attrs
T: use JSON attributes.
Definition: ses.h:591
ncx_display_mode_t out_encoding
output encoding can be different in RESTCONF, set by the Accept header
Definition: ses.h:610
ses_state_t state
session state
Definition: ses.h:549
Per Session Statistics.
Definition: ses.h:414
idle state
Definition: ses.h:368
boolean content_length_based
content len based msg body
Definition: ses.h:665
boolean reading_header
variables for SSL sessions; used by yangcli-pro
Definition: ses.h:664
dropped by remote peer
Definition: ses.h:391
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 sessi...
Definition: ses.c:2668
starting in the EOM field
Definition: ses.h:370
boolean chunk_based
chunked based msg body
Definition: ses.h:666
uint32 ses_id_t
Session ID.
Definition: ses.h:306
void ses_putcchar(ses_cb_t *scb, uint32 ch)
Write one content char to the session, with translation as needed.
Definition: ses.c:2626
ncx_display_mode_t ses_get_out_encoding(ses_cb_t *scb)
Get the output encoding.
Definition: ses.c:4180
uint16 rfc8639_notif_cnt
New subscriptions allow more than 1 per session.
Definition: ses.h:724
not set
Definition: ses.h:378
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 RESTC...
Definition: ses.c:4157
ncx_protocol_t ses_get_protocol(const ses_cb_t *scb)
Get the NETCONF protocol set (or unset) for this session.
Definition: ses.c:3908
ses_term_reason_t
Session Termination reason.
Definition: ses.h:387
boolean rawxml_mode
T: expand_anyxml, F: normal.
Definition: ses.h:576
int32 ses_add_indent(ses_cb_t *scb, int32 indent)
Add in the new indent amount.
Definition: ses.c:4569
boolean ses_is_control_session(ses_cb_t *scb)
Check if the specified session is a control session.
Definition: ses.c:4440
ses_prolog_state_t prolog_state
for insert prolog
Definition: ses.h:510
NETCONF over TLS.
Definition: ses.h:346
YANGAPI/RESTCONF over TLS.
Definition: ses.h:336
status_t ses_set_protocol(ses_cb_t *scb, ncx_protocol_t proto)
set the NETCONF protocol version in use
Definition: ses.c:3834
ses_transport_t ses_get_transport_enum(const xmlChar *str)
Get the enum value for the yumaworks-types:transport-type.
Definition: ses.c:3756
uint32 active_sessions
total active sessions
Definition: ses.h:444
boolean keep_xmlns
T: parse extern, F: msg.
Definition: ses.h:574
bad session start
Definition: ses.h:394
uint32 outNotifications
netconf-state out-notifications counter
Definition: ses.h:434
text mode
Definition: ses.h:382
ses_ready_t outready
header for outreadyQ
Definition: ses.h:626
CoAP UDP socket.
Definition: ses.h:343
internal session for rollback, etc.
Definition: ses.h:321
ses_cb_t * ses_new_scb(void)
Create a new session control block.
Definition: ses.c:2046
boolean ses_is_dbapi_system_session(ses_cb_t *scb)
Check if the specified session is a DB-API control session for system edits.
Definition: ses.c:4532
void ses_free_scb(ses_cb_t *scb)
Free a session control block.
Definition: ses.c:2242
boolean ses_protocol_requested(ses_cb_t *scb, ncx_protocol_t proto)
check if the NETCONF protocol version was requested
Definition: ses.c:3972
Timestamp utilities.
uint32 checksum_cnt
byte count
Definition: ses.h:728
status_t ses_getline_cb(xmlChar *fillbuff, uint32 fillbuffsize, void *cookie)
The IO input front-end for the tk_parse_json_buffs function.
Definition: ses.c:4269
int8 indent
indent N spaces (0..9)
Definition: ses.h:645
session shutdown requested
Definition: ses.h:360
boolean ypgrpc
T: is gRPC ycontrol session.
Definition: ses.h:745
ses_mode_t mode
session mode
Definition: ses.h:550
struct agt_acm_cache_t_ * acm_cache
agent access control for database reads and writes; for incoming agent <rpc> requests, the access control cache is used to minimize data structure processing during authorization procedures in agt/agt_acm.c there is a back-ptr embedded in the XML header so it can be easily passed to the agt_val and xml_wr functions
Definition: ses.h:658
boolean json_1line
T: output JSON leaf-list on 1 line.
Definition: ses.h:588
boolean is_ipv6
T: using IPv6 address, F: IPv4.
Definition: ses.h:594
boolean islast
T: last buff in msg.
Definition: ses.h:475
int32 ses_dec_indent(ses_cb_t *scb, int32 indent)
Remove the specified indent amount.
Definition: ses.c:4603
void ses_set_protocols_requested(ses_cb_t *scb, ncx_protocol_t proto)
set the NETCONF protocol versions requested
Definition: ses.c:3929
size_t expchunksize
expected chunk size
Definition: ses.h:512
int ses_read_cb(void *context, char *buffer, int len)
The IO input front-end for the xmlTextReader parser read fn.
Definition: ses.c:3115
YANG module data structures Many internal representations of YANG module constructs.
const xmlChar * ses_get_entry_point(ses_cb_t *scb)
Get the RESTCONF entry_point.
Definition: ses.c:4696
boolean notif_active
subscription active
Definition: ses.h:570
ses_mode_t ses_get_mode(ses_cb_t *scb)
Get the output mode for the specified session.
Definition: ses.c:2936
int tid
Thread ID representing session.
Definition: ses.h:564
int8 msg_indent
indent N spaces (-1..9)
Definition: ses.h:646
boolean ses_dropped_ex(ses_cb_t *scb)
Check if the session has been dropped by the client.
Definition: ses.c:5059
boolean checksum_mode
T: add out byte to checksum.
Definition: ses.h:598
embedded Q header for the message ready Q The &#39;inq&#39; flag is used to prevent queue corruption ...
Definition: ses.h:488
xmlChar * username
user ID
Definition: ses.h:558
uint32 inBadHellos
total in bad hello messages
Definition: ses.h:453
int32 ses_message_indent_count(const ses_cb_t *scb)
Get the message indent count for this session.
Definition: ses.c:2844
not used
Definition: ses.h:335
not set
Definition: ses.h:367
ssize_t(* ses_read_fn_t)(void *s, char *buff, size_t bufflen, bool *erragain)
optional read function for the session
Definition: ses.h:526
int32 total_length
total length
Definition: ses.h:667
boolean is_callhome
T: callhome session.
Definition: ses.h:595
ses_stats_t stats
per-session statistics
Definition: ses.h:627
boolean conn_closed
T: scb IO closed last buffer.
Definition: ses.h:568
struct obj_template_t_ * snmp_table_obj
Current SNMP walk table.
Definition: ses.h:743
ses_msg_buff_t * curbuff
cur position in buffQ
Definition: ses.h:508
adble to accept requests
Definition: ses.h:358
ses_transport_t
NETCONF Transport Types.
Definition: ses.h:330
time_t hello_time
used for hello timeout
Definition: ses.h:555
boolean noxmlns
xml-nons display-mode
Definition: ses.h:572
boolean ses_is_gnmi_control_session(ses_cb_t *scb)
Check if the specified session is a gNMI control session.
Definition: ses.c:4777
xmlChar * readbuff
input buffer for session
Definition: ses.h:641
size_t curchunksize
cur chunk rcvd
Definition: ses.h:511
boolean start_tls
T: need to start TLS session first.
Definition: ses.h:597
boolean remote_wait
if there is a remote operation in progress then this flag will be set so new input can be held off on...
Definition: ses.h:697
boolean ses_is_grpc_session(ses_cb_t *scb)
Check if the specified session is a gRPC session.
Definition: ses.c:5173
ses_cb_t * ses_new_coap_scb(void)
Create a new global CoAP session control block.
Definition: ses.c:2153
session shutting down
Definition: ses.h:361
uint32 inSessions
total inbound sessions
Definition: ses.h:456
void ses_set_xml_nons(ses_cb_t *scb)
force xmlns attributes to be skipped in XML mode
Definition: ses.c:3795
SNMP UDP socket.
Definition: ses.h:345
void ses_set_mode(ses_cb_t *scb, ses_mode_t mode)
Set the output mode for the specified session.
Definition: ses.c:2917
XML mode.
Definition: ses.h:379
void ses_start_msg_mode(ses_cb_t *scb)
Set the message output mode to active.
Definition: ses.c:2954
void * mgrcb
if manager session, mgr_scb_t
Definition: ses.h:628
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:4202
status_t(* ses_write_fn_t)(void *s)
optional write function for the session
Definition: ses.h:538
RESTCONF Entry point processing.
Definition: ses.h:356
void ses_start_checksum(ses_cb_t *scb)
Clear the checksum field and start checksum mode.
Definition: ses.c:4993
boolean locks_released
Signal release point in kill.
Definition: ses.h:566
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
void ses_set_grpc_session(ses_cb_t *scb)
Set the specified session as a gRPC session.
Definition: ses.c:5154
struct rpc_msg_t_ * cur_rpc_msg
for SIL-SA get callback
Definition: ses.h:629
XML documentation mode.
Definition: ses.h:380
int fd
set if output to a socket
Definition: ses.h:614
uint32 outRpcErrors
netconf-state out-rpc-errors counter
Definition: ses.h:431
ses_transport_t ses_get_transport(ses_cb_t *scb)
Get the transport enum for a given session.
Definition: ses.c:3632
Session Control Block.
Definition: ses.h:542
HTML mode.
Definition: ses.h:381
any network configuration protocol
Definition: ses.h:320
ncx_display_mode_t
enumeration of val_dump_value display modes
Definition: ncxtypes.h:599
status_t
global error return code
Definition: status_enum.h:186
boolean dbapi_system
T: is DB-API system session.
Definition: ses.h:581
void ses_stop_msg_mode(ses_cb_t *scb)
Set the message output mode to inactive.
Definition: ses.c:2972
uint32 out_bytes
extra original internal out byte counter
Definition: ses.h:419
void ses_set_indent(ses_cb_t *scb, int32 indent)
Set the logging indent count for this session.
Definition: ses.c:2862
boolean inq
flag that already in the ready Q
Definition: ses.h:496
RESTCONF mode.
Definition: ses.h:312
kill-session
Definition: ses.h:390
ses_read_fn_t rdfn
set if external write fn
Definition: ses.h:615
ses_prolog_state_t
prolog parsing state
Definition: ses.h:400
ncx_withdefaults_t ses_withdef(const ses_cb_t *scb)
Get the with-defaults value for this session.
Definition: ses.c:3515
boolean wildcard_ok
set by yangcli when parsing an XML file and wildcard strings are allowed; read by mgr_val_parse check...
Definition: ses.h:712
void ses_set_dbapi_system_session(ses_cb_t *scb)
Set the specified session as a DB-API control session for system edits.
Definition: ses.c:4513
boolean ses_get_xml_nons(const ses_cb_t *scb)
force xmlns attributes to be skipped in XML mode
Definition: ses.c:3815
uint32 inBadRpcs
netconf-state in-bad-rpcs counter
Definition: ses.h:428
size_t buffstart
buff start pos
Definition: ses.h:472
uint32 inRpcs
netconf-state in-rpcs counter
Definition: ses.h:425
void ses_set_gnmi_session(ses_cb_t *scb)
Set the specified session as a gNMI session.
Definition: ses.c:4800
#define SES_MAX_STARTCHUNK_SIZE
max size of a valid base:1.1 chunk header start tag
Definition: ses.h:257
GNMI Internal processing over RESTCONF.
Definition: ses.h:347
waiting
Definition: ses.h:402
Global error messages for status code enumerations.
not set
Definition: ses.h:310
uint32 protocols_requested
bitmask
Definition: ses.h:545
void ses_set_message_indent(ses_cb_t *scb, int32 indent)
Set the message indent count for this session.
Definition: ses.c:2889
waiting for peer <hello>
Definition: ses.h:355
void * get_cookie
this pointer available to pass a cookie to a GET1 callback will not be freed when the scb is deleted ...
Definition: ses.h:691
ses_msg_buff_t * outbuff
current output buffer
Definition: ses.h:624
boolean ses_dropped(const ses_cb_t *scb)
Check if the session has been dropped by the client.
Definition: ses.c:4914
ncx_protocol_t protocol
protocol version in use
Definition: ses.h:546
not set
Definition: ses.h:353
ses_cb_t * ses_new_snmp_scb(void)
Create a new global SNMP session control block.
Definition: ses.c:2206
void * openssl_ctx
backptr to TLS context
Definition: ses.h:685
void ses_finish_msg(ses_cb_t *scb)
Finish an outbound message on the specified session.
Definition: ses.c:3035
ncx_display_mode_t in_encoding
input encoding can be different in RESTCONF, set by the Content-Type header
Definition: ses.h:605
void ses_set_dbapi_session(ses_cb_t *scb)
Set the specified session as a DB-API control session.
Definition: ses.c:4458
in between 2 messages
Definition: ses.h:371
NETCONF over SSH (RFC 4742 and 6242)
Definition: ses.h:332
status_t ses_start_msg(ses_cb_t *scb)
Start a new outbound message on the specified session.
Definition: ses.c:2992
uint32 checksum
running checksum for YANG Push Simulated Operational mode
Definition: ses.h:727
bad <hello> received
Definition: ses.h:395
not used
Definition: ses.h:333
uint32 buffcnt
current buffer count
Definition: ses.h:619
void ses_set_extern_xml_mode_ex(ses_cb_t *scb, boolean rawxml_mode, boolean keep_xmlns)
Setup the scb for external XML parsing.
Definition: ses.c:4056
Session Total Statistics.
Definition: ses.h:442
uint32 failed_sessions
total failed sessions
Definition: ses.h:450
boolean skip_modnames
YPW-888: new restconf cli parameter to turn strict JSON YANG enconding off, do not include module nam...
Definition: ses.h:683
void ses_init_coap_scb(ses_cb_t *scb)
Initialize a CoAP session control block.
Definition: ses.c:2174
processing a request
Definition: ses.h:359
const xmlChar * ses_state_name(ses_state_t state)
Get the name of a session state from the enum value.
Definition: ses.c:3473
ses_type_t
Session Types.
Definition: ses.h:318
boolean ypgnmi
T: is gNMI ycontrol session.
Definition: ses.h:583
ses_write_fn_t wrfn
set if external read fn
Definition: ses.h:616
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 re...
Definition: ses.c:3536
ses_instate_t
Session Input Handler States for base:1.0 EOM processing.
Definition: ses.h:366
status_t ses_set_gnmi_control_session(ses_cb_t *scb)
Set the specified session as a gNMI control session.
Definition: ses.c:4754
boolean http_chunk_mode
T: send HTTP chunks, F: normal.
Definition: ses.h:589
status_t ses_put_extern2(ses_cb_t *scb, const xmlChar *fname)
write the contents of a file to the session
Definition: ses.c:3581
ses_transport_t transport
transport type
Definition: ses.h:547
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 ...
Definition: ses.c:2722
inactivity timeout
Definition: ses.h:392
ncx_msg_encoding_t
enumeration for message encoding formats
Definition: ncxtypes.h:625
xmlChar * service_name
variables for ycontrol sessions
Definition: ses.h:661
void * tcb
Thread control block.
Definition: ses.h:565
RESTCONF over CoAP; static socket, libcoap.
Definition: ses.h:323
boolean file_override
set by server DB-API session to capture <rpc-reply> output to a file.
Definition: ses.h:718
NETCONF mode.
Definition: ses.h:313
boolean is_ycontrol_scb
T: is ycontrol_scb for HA.
Definition: ses.h:593
FILE * fp
set if output to a file
Definition: ses.h:613
ncx_protocol_t
NCX session protocol versions supported.
Definition: ncxtypes.h:935
uint32 in_bytes
extra original internal in byte counter
Definition: ses.h:416
not set
Definition: ses.h:331
ses_instate_t instate
input state enum
Definition: ses.h:618
xmlChar * start_time
dateTime start time
Definition: ses.h:557
other
Definition: ses.h:393
void ses_clear_extern_xml_mode(ses_cb_t *scb, boolean rawxml_mode)
Clear the scb from external XML parsing.
Definition: ses.c:4088
not set
Definition: ses.h:319
not used
Definition: ses.h:334
struct cfg_template_t_ * fake_candidate
a fake candidate config for target=running YANG-PATCH
Definition: ses.h:721
RESTCONF over GNMI.
Definition: ses.h:325
ses_ypmode_t yp_mode
YANG-PATCH mode:
Definition: ses.h:677
ending the EOM field
Definition: ses.h:372
void ses_clear_dbapi_system_session(ses_cb_t *scb)
Clear a session of the DB-API system status.
Definition: ses.c:4548
void ses_clean_breadcrumbQ(ses_cb_t *scb)
Clean the breadcrumbQ.
Definition: ses.c:4895
not used YumaPro WEBui (ncxconnect, no framing)
Definition: ses.h:341
uint32 droppedSessions
total dropped sessions
Definition: ses.h:459
const xmlChar * ses_get_transport_name(ses_transport_t transport)
Get the name of the transport for a given enum value.
Definition: ses.c:3652
ncxserver.sock AF_LOCAL socket – control msg
Definition: ses.h:342
ncx_withdefaults_t
enum for with-defaults enum values
Definition: ncxtypes.h:1164
in message body
Definition: ses.h:369
boolean framing11
T: base:1.1, F: base:1.0.
Definition: ses.h:573
boolean warn_xml
T: xml warns, F: no warn.
Definition: ses.h:575
void ses_putstr_indent(ses_cb_t *scb, const xmlChar *str, int32 indent)
Write a zero-terminated content string to the session with indentation.
Definition: ses.c:2508
close-session
Definition: ses.h:389
not set
Definition: ses.h:401
uint32 last_ch
save in case cr/lf in SSE mode
Definition: ses.h:599
boolean ses_is_dbapi_session(ses_cb_t *scb)
Check if the specified session is a DB-API control session.
Definition: ses.c:4477
void ses_set_extern_xml_mode(ses_cb_t *scb, boolean rawxml_mode)
Setup the scb for external XML parsing.
Definition: ses.c:4033
#define SES_MSG_BUFFSIZE
controls the size of each buffer chunk
Definition: ses.h:232
ses_id_t sid
session ID
Definition: ses.h:551
xmlChar * peeraddr
Inet address string.
Definition: ses.h:559
uint32 freecnt
current freeQ count
Definition: ses.h:620
boolean direct_mode
T: yp-shell, F: normal.
Definition: ses.h:577
status_t ses_start_http_chunk_mode(ses_cb_t *scb)
Start outputting buffers in HTTP 1.1 chunk mode.
Definition: ses.c:4659
uint32 ses_finish_checksum(ses_cb_t *scb, uint32 *checksum_cnt)
Stop checksum mode and return the final checksum.
Definition: ses.c:5020
ncx_msg_encoding_t ses_get_msg_encoding(const ses_cb_t *scb)
Get the message encoding for the HTTP session.
Definition: ses.c:4639
uint32 closed_sessions
total closed sessions
Definition: ses.h:447
time_t last_rpc_time
used for idle timeout
Definition: ses.h:556
YumaPro REST API ncxconnect, no framing.
Definition: ses.h:339
Session Message Buffer.
Definition: ses.h:470
status_t ses_add_breadcrumb_obj(ses_cb_t *scb, struct obj_template_t_ *obj)
Add an object to the breadcrumbQ.
ncx_withdefaults_t withdef
with-defaults default
Definition: ses.h:648
tail-f NETCONF over TCP
Definition: ses.h:337
int32 ses_indent_count(const ses_cb_t *scb)
Get the logging indent count for this session.
Definition: ses.c:2823
ses_ready_t inready
header for inreadyQ
Definition: ses.h:625
status_t ses_set_grpc_control_session(ses_cb_t *scb)
Set the specified session as a gRPC control session.
Definition: ses.c:5108
ses_msg_t * curmsg
pointer to current message to read set by agt only
Definition: ses.h:706
boolean msg_mode
T:msg-indent F:indent.
Definition: ses.h:578
ses_type_t type
session type
Definition: ses.h:544
uint32 requests
internal request counters for EVAL tracking
Definition: ses.h:437
YP-HA mode.
Definition: ses.h:311
void ses_putstr(ses_cb_t *scb, const xmlChar *str)
Write a zero-terminated string to the session.
Definition: ses.c:2482
done
Definition: ses.h:403
const xmlChar * ses_get_transport_yang_name(ses_transport_t transport)
Get the name of the transport for a given enum value.
Definition: ses.c:3710