yumapro  22.10T-2
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 
224 #define SES_BINARY_NOTIFS(S) (S)->binary_notifs
225 
229 #define BINLOG (const xmlChar *)"***binary***"
230 
231 
233 #define SES_NULL_SID 0
234 
243 #define SES_MSG_BUFFSIZE 1000
244 
249 #define SES_MAX_BUFFERS 500000
250 
252 #ifdef WITH_COAP
253 #define SES_MAX_FREE_BUFFERS 4
254 #else
255 #define SES_MAX_FREE_BUFFERS 32
256 #endif // WITH_COAP
257 
259 #define SES_MAX_BUFFSEND 32
260 
262 #define SES_MAX_BYTESEND 0xffff
263 
265 #define SES_DEF_LINESIZE 72
266 
268 #define SES_MAX_STARTCHUNK_SIZE 13
269 
271 #define SES_MAX_CHUNKNUM_SIZE 10
272 
284 #define SES_STARTCHUNK_PAD 10
285 
289 #define SES_ENDCHUNK_PAD 8
290 
292 #define SES_READBUFF_SIZE 1000
293 
295 #define SES_GET_YPMODE(S) (S)->yp_mode
296 
298 #define SES_SET_YPMODE(S,V) (S)->yp_mode = V
299 
301 #define SES_REMOTE_WAIT(S) (S)->remote_wait
302 
304 #define SES_NEED_FILE_OVERRIDE(S) ((S)->file_override && (S)->fp)
305 
307 #define SES_SYSTEM_USERNAME NCX_EL_SYSTEM
308 
309 
310 /********************************************************************
311 * *
312 * T Y P E S *
313 * *
314 *********************************************************************/
315 
317 typedef uint32 ses_id_t;
318 
320 typedef enum ses_ypmode_t_ {
325 } ses_ypmode_t;
326 
327 
329 typedef enum ses_type_t_ {
337 } ses_type_t;
338 
339 
341 typedef enum ses_transport_t_ {
355  SES_TRANSPORT_COAP_DTLS, /* CoAP DTLS/UDP socket */
360 
361 
363 typedef enum ses_state_t_ {
373 } ses_state_t;
374 
375 
377 typedef enum ses_instate_t_ {
384 } ses_instate_t;
385 
386 
388 typedef enum ses_mode_t_ {
395 } ses_mode_t;
396 
397 
399 typedef enum ses_term_reason_t_ {
409 
410 
412 typedef enum ses_prolog_state_t_ {
417 
418 
426 typedef struct ses_stats_t_ {
428  uint32 in_bytes;
429 
431  uint32 out_bytes;
432 
434  uint32 out_line;
435 
437  uint32 inRpcs;
438 
440  uint32 inBadRpcs;
441 
443  uint32 outRpcErrors;
444 
447 
449  uint32 requests;
450 } ses_stats_t;
451 
452 
454 typedef struct ses_total_stats_t_ {
457 
460 
463 
465  uint32 inBadHellos;
466 
468  uint32 inSessions;
469 
472 
475 
477  xmlChar startTime[TSTAMP_MIN_SIZE];
479 
480 
482 typedef struct ses_msg_buff_t_ {
483  dlq_hdr_t qhdr;
484  size_t buffstart;
485  size_t bufflen;
486  size_t buffpos;
487  boolean islast;
488  boolean isbinary;
494  xmlChar buff[SES_MSG_BUFFSIZE+1];
496 
497 
501 typedef struct ses_ready_t_ {
503  dlq_hdr_t hdr;
504 
506  ses_id_t sid;
507 
509  boolean inq;
510 
512  boolean ycontrol;
513 } ses_ready_t;
514 
515 
517 typedef struct ses_msg_t_ {
518  dlq_hdr_t qhdr;
519  boolean ready;
520  boolean dispatched;
522  dlq_hdr_t buffQ;
523  ses_prolog_state_t prolog_state;
524  size_t curchunksize;
525  size_t expchunksize;
526 } ses_msg_t;
527 
528 
539 typedef ssize_t (*ses_read_fn_t) (void *s,
540  char *buff,
541  size_t bufflen,
542  bool *erragain);
543 
544 
551 typedef status_t (*ses_write_fn_t) (void *s);
552 
553 
555 typedef struct ses_cb_t_ {
556  dlq_hdr_t qhdr;
557  ses_type_t type;
560  ses_transport_t transport;
562  ses_state_t state;
563  ses_mode_t mode;
564  ses_id_t sid;
565  ses_id_t killedbysid;
566  ses_id_t rollback_sid;
567  ses_term_reason_t termreason;
568  time_t hello_time;
569  time_t last_rpc_time;
570  xmlChar *start_time;
571  xmlChar *username;
572  xmlChar *peeraddr;
575  xmlChar *subsys_id;
577  int tid;
578  void *tcb;
579  boolean locks_released;
581  boolean conn_closed;
582  boolean active;
583  boolean notif_active;
584  boolean stream_output;
585  boolean noxmlns;
586  boolean framing11;
587  boolean keep_xmlns;
588  boolean warn_xml;
589  boolean rawxml_mode;
590  boolean direct_mode;
591  boolean msg_mode;
592  boolean ycontrol;
593  boolean dbapi;
594  boolean dbapi_system;
595  boolean sse_mode;
596  boolean ypgnmi;
599  boolean restconf_notif;
601  boolean json_1line;
602  boolean http_chunk_mode;
603  boolean http_waitrn;
604  boolean json_attrs;
606  boolean is_ycontrol_scb;
607  boolean is_ipv6;
608  boolean is_callhome;
609  boolean dropped;
610  boolean start_tls;
611  boolean checksum_mode;
612  uint32 last_ch;
613  struct val_value_t_ *leaflist;
619 
624 
625  xmlTextReaderPtr reader;
626  FILE *fp;
627  int fd;
630  uint32 inendpos;
631  ses_instate_t instate;
632  uint32 buffcnt;
633  uint32 freecnt;
634  dlq_hdr_t msgQ;
635  dlq_hdr_t freeQ;
636  dlq_hdr_t outQ;
641  void *mgrcb;
642  struct rpc_msg_t_ *cur_rpc_msg;
644  struct yangapi_cb_t_ *rcb;
645  xmlChar *entry_point;
651  xmlChar startchunk[SES_MAX_STARTCHUNK_SIZE+1];
652 
654  xmlChar *readbuff;
655  uint32 readbuffsize;
657  /*** user preferences ***/
658  int8 indent;
659  int8 msg_indent;
660  uint32 linesize;
662  uint32 cache_timeout;
671  struct agt_acm_cache_t_ *acm_cache;
672 
674  xmlChar *service_name;
677  boolean reading_header;
679  boolean chunk_based;
680  int32 total_length;
683  boolean use_traceid;
684 
690  ses_ypmode_t yp_mode;
691 
696  boolean skip_modnames;
697 
698  void *openssl_ctx;
699  void *openssl_ssl;
704  void *get_cookie;
705 
710  boolean remote_wait;
711 
716  dlq_hdr_t breadcrumbQ;
720 
725  boolean wildcard_ok;
726 
731  boolean file_override;
732 
734  struct cfg_template_t_ *fake_candidate;
735 
738 
740  uint32 checksum;
741  uint32 checksum_cnt;
753  dlq_hdr_t snmp_getnext_listQ;
754 
756  struct obj_template_t_ *snmp_table_obj;
757 
758  boolean ypgrpc;
764  boolean binary_notifs;
765 
770 
771 } ses_cb_t;
772 
773 
777 /********************************************************************
778 * *
779 * F U N C T I O N S *
780 * *
781 *********************************************************************/
782 
799 extern ses_cb_t *
800  ses_new_scb (void);
801 
802 
808 extern ses_cb_t *
809  ses_new_dummy_scb (void);
810 
811 
812 #ifdef WITH_COAP
813 
818 extern ses_cb_t *
819  ses_new_coap_scb (void);
820 
821 
827 extern void
829 
830 #endif // WITH_COAP
831 
832 
833 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
834 
839 extern ses_cb_t *
840  ses_new_snmp_scb (void);
841 
842 #endif // WITH_SNMP
843 
844 
850 extern void
851  ses_free_scb (ses_cb_t *scb);
852 
853 
867 extern void
868  ses_putchar (ses_cb_t *scb,
869  uint32 ch);
870 
871 
885 extern void
887  uint32 ch);
888 
889 
896 extern void
897  ses_putstr (ses_cb_t *scb,
898  const xmlChar *str);
899 
900 
908 extern void
909  ses_put_binstr (ses_cb_t *scb,
910  const xmlChar *str,
911  uint32 len);
912 
913 
927 extern void
929  const xmlChar *str,
930  int32 indent);
931 
932 
943 extern void
944  ses_putcstr (ses_cb_t *scb,
945  const xmlChar *str,
946  int32 indent);
947 
948 
958 extern void
959  ses_puthstr (ses_cb_t *scb,
960  const xmlChar *str);
961 
962 
969 extern void
970  ses_putcchar (ses_cb_t *scb,
971  uint32 ch);
972 
973 
984 extern void
985  ses_putastr (ses_cb_t *scb,
986  const xmlChar *str,
987  int32 indent);
988 
989 
1000 extern void
1001  ses_putjstr (ses_cb_t *scb,
1002  const xmlChar *str,
1003  int32 indent);
1004 
1005 
1016 extern void
1017  ses_indent (ses_cb_t *scb,
1018  int32 indent);
1019 
1020 
1027 extern int32
1028  ses_indent_count (const ses_cb_t *scb);
1029 
1030 
1037 extern int32
1038  ses_message_indent_count (const ses_cb_t *scb);
1039 
1040 
1047 extern void
1048  ses_set_indent (ses_cb_t *scb,
1049  int32 indent);
1050 
1051 
1058 extern void
1059  ses_set_message_indent (ses_cb_t *scb, int32 indent);
1060 
1061 
1068 extern void
1069  ses_set_mode (ses_cb_t *scb,
1070  ses_mode_t mode);
1071 
1072 
1079 extern ses_mode_t
1080  ses_get_mode (ses_cb_t *scb);
1081 
1082 
1088 extern void ses_start_msg_mode (ses_cb_t *scb);
1089 
1090 
1096 extern void ses_stop_msg_mode (ses_cb_t *scb);
1097 
1098 
1105 extern status_t
1106  ses_start_msg (ses_cb_t *scb);
1107 
1108 
1114 extern void
1115  ses_finish_msg (ses_cb_t *scb);
1116 
1117 
1138 extern int
1139  ses_read_cb (void *context,
1140  char *buffer,
1141  int len);
1142 
1143 
1158 extern status_t
1159  ses_accept_input (ses_cb_t *scb);
1160 
1161 
1168 extern const xmlChar *
1169  ses_state_name (ses_state_t state);
1170 
1171 
1178 extern ncx_withdefaults_t
1179  ses_withdef (const ses_cb_t *scb);
1180 
1181 
1189 extern uint32
1190  ses_line_left (const ses_cb_t *scb);
1191 
1192 
1203 extern void
1204  ses_put_extern (ses_cb_t *scb,
1205  const xmlChar *fname);
1206 
1207 
1215 extern status_t
1216  ses_put_extern2 (ses_cb_t *scb,
1217  const xmlChar *fname);
1218 
1219 
1227 extern status_t
1229  const xmlChar *fname);
1230 
1231 
1232 
1238 extern ses_total_stats_t *
1239  ses_get_total_stats (void);
1240 
1241 
1250 extern ses_transport_t
1251  ses_get_transport (ses_cb_t *scb);
1252 
1253 
1260 extern ses_transport_t
1261  ses_get_transport_enum (const xmlChar *str);
1262 
1263 
1270 extern const xmlChar *
1271  ses_get_transport_name (ses_transport_t transport);
1272 
1273 
1282 extern const xmlChar *
1283  ses_get_transport_yang_name (ses_transport_t transport);
1284 
1285 
1291 extern void
1292  ses_set_xml_nons (ses_cb_t *scb);
1293 
1294 
1303 extern boolean
1304  ses_get_xml_nons (const ses_cb_t *scb);
1305 
1306 
1314 extern status_t
1315  ses_set_protocol (ses_cb_t *scb,
1316  ncx_protocol_t proto);
1317 
1318 
1326 extern ncx_protocol_t
1327  ses_get_protocol (const ses_cb_t *scb);
1328 
1329 
1336 extern void
1338  ncx_protocol_t proto);
1339 
1340 
1348 extern boolean
1350  ncx_protocol_t proto);
1351 
1352 
1363 extern void
1365  boolean rawxml_mode);
1366 
1367 
1379 extern void
1381  boolean rawxml_mode,
1382  boolean keep_xmlns);
1383 
1384 
1396 extern void
1398  boolean rawxml_mode);
1399 
1400 
1412 extern void
1414  boolean rawxml_mode,
1415  boolean keep_xmlns);
1416 
1417 
1424 extern void
1426  ncx_display_mode_t encoding);
1427 
1428 
1435 extern void
1437 
1438 
1445 extern ncx_display_mode_t
1447 
1448 
1457 extern int32
1458  ses_new_indent_count (boolean indent_in,
1459  int32 indent,
1460  int32 indent_amount);
1461 
1462 
1470 extern void
1472 
1473 
1487 extern status_t
1488  ses_getline_cb (xmlChar *fillbuff,
1489  uint32 fillbuffsize,
1490  void *cookie);
1491 
1492 
1499 extern status_t
1501 
1502 
1509 extern boolean
1511 
1512 
1518 extern void
1520 
1521 
1528 extern boolean
1530 
1531 
1538 extern void
1540 
1541 
1549 extern boolean
1551 
1552 
1558 extern void
1560 
1561 
1568 extern boolean
1570 
1571 
1579 extern int32
1580  ses_add_indent (ses_cb_t *scb,
1581  int32 indent);
1582 
1583 
1591 extern int32
1592  ses_dec_indent (ses_cb_t *scb,
1593  int32 indent);
1594 
1595 
1602 extern ncx_msg_encoding_t
1603  ses_get_msg_encoding (const ses_cb_t *scb);
1604 
1605 
1612 extern status_t
1614 
1615 
1622 extern const xmlChar *
1624 
1625 
1633 extern status_t
1635  const xmlChar *point);
1636 
1637 
1644 extern boolean
1645  ses_notifications_active (const ses_cb_t *scb);
1646 
1647 
1648 #ifdef WITH_GNMI
1649 
1655 extern status_t
1657 
1658 
1665 extern boolean
1667 
1668 
1674 extern void
1676 
1677 
1684 extern boolean
1686 
1687 #endif //WITH_GNMI
1688 
1689 
1697 extern status_t
1699  struct obj_template_t_ *obj);
1700 
1701 
1707 extern void
1709 
1710 
1717 extern boolean
1718  ses_dropped (const ses_cb_t *scb);
1719 
1720 
1729 extern status_t
1731  const xmlChar *filespec,
1732  boolean is_binary);
1733 
1734 
1741 extern void
1743 
1744 
1750 extern void
1752 
1753 
1765 extern uint32
1767  uint32 *checksum_cnt);
1768 
1769 
1779 extern boolean
1780  ses_dropped_ex (ses_cb_t *scb);
1781 
1782 
1783 #ifdef WITH_GRPC
1784 
1790 extern status_t
1792 
1793 
1800 extern boolean
1802 
1803 
1809 extern void
1811 
1812 
1819 extern boolean
1821 
1822 #endif //WITH_GRPC
1823 
1824 
1831 extern void
1832  ses_dump_binary_buff (const xmlChar *buff,
1833  size_t bufflen);
1834 
1838 #ifdef __cplusplus
1839 } /* end extern 'C' */
1840 #endif
1841 
1842 #endif /* _H_ses */
YumaWorks NETCONF over TCP.
Definition: ses.h:349
void ses_putchar(ses_cb_t *scb, uint32 ch)
Write one char to the session, without any translation.
Definition: ses.c:2594
status_t ses_set_control_session(ses_cb_t *scb)
Set the specified session as a control session.
Definition: ses.c:4664
status_t ses_set_file_override(ses_cb_t *scb, const xmlChar *filespec, boolean is_binary)
Setup the session in file write override mode.
Definition: ses.c:5181
boolean dispatched
in processing
Definition: ses.h:520
uint32 readbuffsize
input buffer size
Definition: ses.h:655
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:5217
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:5379
ses_id_t sid
session ID of this session
Definition: ses.h:506
uint32 cache_timeout
vir-val cache tmr in sec
Definition: ses.h:662
void ses_put_extern(ses_cb_t *scb, const xmlChar *fname)
write the contents of a file to the session
Definition: ses.c:3763
ses_mode_t
Session Output Mode.
Definition: ses.h:388
ses_id_t rollback_sid
session ID for rollback
Definition: ses.h:566
Session Message.
Definition: ses.h:517
boolean ses_notifications_active(const ses_cb_t *scb)
Check if the session has notifications active.
Definition: ses.c:5083
boolean ycontrol
flag YControl session for priority processing
Definition: ses.h:512
ses_ypmode_t
YANG-PATCH Mode.
Definition: ses.h:320
boolean http_waitrn
T: wait for EOchunk, F: no wait.
Definition: ses.h:603
void ses_indent(ses_cb_t *scb, int32 indent)
Write the proper newline + indentation to the specified session.
Definition: ses.c:2986
struct yangapi_cb_t_ * rcb
REST-API control block.
Definition: ses.h:644
ses_total_stats_t * ses_get_total_stats(void)
Get a r/w pointer to the the session totals stats.
Definition: ses.c:3859
boolean restconf_notif
REST SSE notifications in progress.
Definition: ses.h:599
boolean active
<hello> completed ok
Definition: ses.h:582
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:2784
uint32 linesize
TERM line length.
Definition: ses.h:660
YumaPro CLI hook (ncxconnect, NETCONF framing)
Definition: ses.h:351
initialization state
Definition: ses.h:365
RESTCONF over SNMP.
Definition: ses.h:335
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:2740
boolean any_leaflist_attrs
T: leaf-list has attrs.
Definition: ses.h:605
xmlChar * entry_point
REST-API entry point.
Definition: ses.h:645
not set
Definition: ses.h:400
RESTCONF Capabilities processing.
Definition: ses.h:368
void ses_set_out_encoding(ses_cb_t *scb, ncx_display_mode_t encoding)
Set the output encoding.
Definition: ses.c:4383
size_t buffpos
buff cur position
Definition: ses.h:486
xmlTextReaderPtr reader
input stream reader
Definition: ses.h:625
uint32 inendpos
inside framing directive
Definition: ses.h:630
boolean restconf_sse_mode
T: RESTCONF SSE mode.
Definition: ses.h:598
ses_id_t killedbysid
killed-by session ID
Definition: ses.h:565
status_t ses_set_entry_point(ses_cb_t *scb, const xmlChar *point)
Set the RESTCONF entry_point.
Definition: ses.c:4966
struct val_value_t_ * leaflist
JSON attrs backptr.
Definition: ses.h:613
ncx_msg_encoding_t encoding
HTTP msg encoding.
Definition: ses.h:561
boolean ready
ready for parsing
Definition: ses.h:519
ses_stats_t stats
per-session stats added up for all sessions
Definition: ses.h:474
void * openssl_ssl
malloced with SSL_new
Definition: ses.h:699
boolean use_traceid
TRUE if OK to use Trace ID attr in the RPC calls.
Definition: ses.h:683
xmlChar * subsys_id
used for YCONTROL session only
Definition: ses.h:575
boolean sse_mode
T: Server Sent Events, F: normal.
Definition: ses.h:595
boolean stream_output
buffer/stream svr
Definition: ses.h:584
boolean isbinary
T: CBOR, F: XML.
Definition: ses.h:488
ses_cb_t * ses_new_dummy_scb(void)
Create a new dummy session control block.
Definition: ses.c:2232
ses_state_t
Session States.
Definition: ses.h:363
boolean ses_is_system_session(ses_cb_t *scb)
Check if the specified session is an internal system session.
Definition: ses.c:4740
size_t bufflen
buff actual size
Definition: ses.h:485
boolean dropped
T: session dropped in a msg.
Definition: ses.h:609
boolean dbapi
T: is DB-API session.
Definition: ses.h:593
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:4357
internal YControl session w/ subsystem
Definition: ses.h:333
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:4479
status_t ses_accept_input(ses_cb_t *scb)
The IO input handler for the ncxserver loop.
Definition: ses.c:3442
boolean ses_is_gnmi_session(ses_cb_t *scb)
Check if the specified session is a gNMI session.
Definition: ses.c:5064
boolean ycontrol
T: is ycontrol session.
Definition: ses.h:592
uint32 out_line
hack: bytes since &#39; &#39;, pretty-print
Definition: ses.h:434
ses_term_reason_t termreason
termination reason
Definition: ses.h:567
boolean json_attrs
T: use JSON attributes.
Definition: ses.h:604
ncx_display_mode_t out_encoding
output encoding can be different in RESTCONF, set by the Accept header
Definition: ses.h:623
ses_state_t state
session state
Definition: ses.h:562
Per Session Statistics.
Definition: ses.h:426
idle state
Definition: ses.h:379
boolean content_length_based
content len based msg body
Definition: ses.h:678
boolean reading_header
variables for SSL sessions; used by yangcli-pro
Definition: ses.h:677
dropped by remote peer
Definition: ses.h:403
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:2864
starting in the EOM field
Definition: ses.h:381
boolean chunk_based
chunked based msg body
Definition: ses.h:679
uint32 ses_id_t
Session ID.
Definition: ses.h:317
void ses_putcchar(ses_cb_t *scb, uint32 ch)
Write one content char to the session, with translation as needed.
Definition: ses.c:2822
ncx_display_mode_t ses_get_out_encoding(ses_cb_t *scb)
Get the output encoding.
Definition: ses.c:4425
uint16 rfc8639_notif_cnt
New subscriptions allow more than 1 per session.
Definition: ses.h:737
not set
Definition: ses.h:389
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:4402
ncx_protocol_t ses_get_protocol(const ses_cb_t *scb)
Get the NETCONF protocol set (or unset) for this session.
Definition: ses.c:4153
ses_term_reason_t
Session Termination reason.
Definition: ses.h:399
boolean rawxml_mode
T: expand_anyxml, F: normal.
Definition: ses.h:589
int32 ses_add_indent(ses_cb_t *scb, int32 indent)
Add in the new indent amount.
Definition: ses.c:4814
boolean ses_is_control_session(ses_cb_t *scb)
Check if the specified session is a control session.
Definition: ses.c:4685
ses_prolog_state_t prolog_state
for insert prolog
Definition: ses.h:523
NETCONF over TLS.
Definition: ses.h:357
YANGAPI/RESTCONF over TLS.
Definition: ses.h:347
status_t ses_set_protocol(ses_cb_t *scb, ncx_protocol_t proto)
set the NETCONF protocol version in use
Definition: ses.c:4079
ses_transport_t ses_get_transport_enum(const xmlChar *str)
Get the enum value for the yumaworks-types:transport-type.
Definition: ses.c:4001
uint32 active_sessions
total active sessions
Definition: ses.h:456
boolean keep_xmlns
T: parse extern, F: msg.
Definition: ses.h:587
bad session start
Definition: ses.h:406
uint32 outNotifications
netconf-state out-notifications counter
Definition: ses.h:446
text mode
Definition: ses.h:393
ses_ready_t outready
header for outreadyQ
Definition: ses.h:639
CoAP UDP socket.
Definition: ses.h:354
internal session for rollback, etc.
Definition: ses.h:332
ses_cb_t * ses_new_scb(void)
Create a new session control block.
Definition: ses.c:2157
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:4777
void ses_free_scb(ses_cb_t *scb)
Free a session control block.
Definition: ses.c:2353
boolean ses_protocol_requested(ses_cb_t *scb, ncx_protocol_t proto)
check if the NETCONF protocol version was requested
Definition: ses.c:4217
void ses_put_binstr(ses_cb_t *scb, const xmlChar *str, uint32 len)
Write a binary string to the session.
Definition: ses.c:2670
Timestamp utilities.
uint32 checksum_cnt
byte count
Definition: ses.h:741
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:4514
int8 indent
indent N spaces (0..9)
Definition: ses.h:658
session shutdown requested
Definition: ses.h:371
boolean ypgrpc
T: is gRPC ycontrol session.
Definition: ses.h:758
ses_mode_t mode
session mode
Definition: ses.h:563
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:671
boolean json_1line
T: output JSON leaf-list on 1 line.
Definition: ses.h:601
boolean is_ipv6
T: using IPv6 address, F: IPv4.
Definition: ses.h:607
boolean islast
T: last buff in msg.
Definition: ses.h:487
int32 ses_dec_indent(ses_cb_t *scb, int32 indent)
Remove the specified indent amount.
Definition: ses.c:4848
void ses_set_protocols_requested(ses_cb_t *scb, ncx_protocol_t proto)
set the NETCONF protocol versions requested
Definition: ses.c:4174
size_t expchunksize
expected chunk size
Definition: ses.h:525
int ses_read_cb(void *context, char *buffer, int len)
The IO input front-end for the xmlTextReader parser read fn.
Definition: ses.c:3320
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:4941
boolean notif_active
subscription active
Definition: ses.h:583
ses_mode_t ses_get_mode(ses_cb_t *scb)
Get the output mode for the specified session.
Definition: ses.c:3132
int tid
Thread ID representing session.
Definition: ses.h:577
int8 msg_indent
indent N spaces (-1..9)
Definition: ses.h:659
boolean ses_dropped_ex(ses_cb_t *scb)
Check if the session has been dropped by the client.
Definition: ses.c:5307
boolean checksum_mode
T: add out byte to checksum.
Definition: ses.h:611
embedded Q header for the message ready Q The &#39;inq&#39; flag is used to prevent queue corruption ...
Definition: ses.h:501
xmlChar * username
user ID
Definition: ses.h:571
uint32 inBadHellos
total in bad hello messages
Definition: ses.h:465
int32 ses_message_indent_count(const ses_cb_t *scb)
Get the message indent count for this session.
Definition: ses.c:3040
not used
Definition: ses.h:346
not set
Definition: ses.h:378
ssize_t(* ses_read_fn_t)(void *s, char *buff, size_t bufflen, bool *erragain)
optional read function for the session
Definition: ses.h:539
int32 total_length
total length
Definition: ses.h:680
boolean is_callhome
T: callhome session.
Definition: ses.h:608
ses_stats_t stats
per-session statistics
Definition: ses.h:640
boolean conn_closed
T: scb IO closed last buffer.
Definition: ses.h:581
struct obj_template_t_ * snmp_table_obj
Current SNMP walk table.
Definition: ses.h:756
ses_msg_buff_t * curbuff
cur position in buffQ
Definition: ses.h:521
adble to accept requests
Definition: ses.h:369
ses_transport_t
NETCONF Transport Types.
Definition: ses.h:341
time_t hello_time
used for hello timeout
Definition: ses.h:568
boolean noxmlns
xml-nons display-mode
Definition: ses.h:585
boolean ses_is_gnmi_control_session(ses_cb_t *scb)
Check if the specified session is a gNMI control session.
Definition: ses.c:5022
xmlChar * readbuff
input buffer for session
Definition: ses.h:654
size_t curchunksize
cur chunk rcvd
Definition: ses.h:524
boolean start_tls
T: need to start TLS session first.
Definition: ses.h:610
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:710
uint32 yang_sid_tree
SID Tree Assignment for this session.
Definition: ses.h:769
boolean ses_is_grpc_session(ses_cb_t *scb)
Check if the specified session is a gRPC session.
Definition: ses.c:5421
ses_cb_t * ses_new_coap_scb(void)
Create a new global CoAP session control block.
Definition: ses.c:2264
session shutting down
Definition: ses.h:372
uint32 inSessions
total inbound sessions
Definition: ses.h:468
void ses_set_xml_nons(ses_cb_t *scb)
force xmlns attributes to be skipped in XML mode
Definition: ses.c:4040
SNMP UDP socket.
Definition: ses.h:356
void ses_set_mode(ses_cb_t *scb, ses_mode_t mode)
Set the output mode for the specified session.
Definition: ses.c:3113
XML mode.
Definition: ses.h:390
void ses_start_msg_mode(ses_cb_t *scb)
Set the message output mode to active.
Definition: ses.c:3152
void * mgrcb
if manager session, mgr_scb_t
Definition: ses.h:641
status_t ses_put_extern_bin(ses_cb_t *scb, const xmlChar *fname)
write the contents of a binary file to the session
Definition: ses.c:3822
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:4447
status_t(* ses_write_fn_t)(void *s)
optional write function for the session
Definition: ses.h:551
RESTCONF Entry point processing.
Definition: ses.h:367
void ses_start_checksum(ses_cb_t *scb)
Clear the checksum field and start checksum mode.
Definition: ses.c:5241
boolean locks_released
Signal release point in kill.
Definition: ses.h:579
binary mode
Definition: ses.h:394
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:71
void ses_set_grpc_session(ses_cb_t *scb)
Set the specified session as a gRPC session.
Definition: ses.c:5402
struct rpc_msg_t_ * cur_rpc_msg
for SIL-SA get callback
Definition: ses.h:642
XML documentation mode.
Definition: ses.h:391
int fd
set if output to a socket
Definition: ses.h:627
uint32 outRpcErrors
netconf-state out-rpc-errors counter
Definition: ses.h:443
ses_transport_t ses_get_transport(ses_cb_t *scb)
Get the transport enum for a given session.
Definition: ses.c:3877
Session Control Block.
Definition: ses.h:555
HTML mode.
Definition: ses.h:392
any network configuration protocol
Definition: ses.h:331
ncx_display_mode_t
enumeration of val_dump_value display modes Some RESTCONF code uses this field incorrectly for messag...
Definition: ncxtypes.h:617
status_t
global error return code
Definition: status_enum.h:186
boolean dbapi_system
T: is DB-API system session.
Definition: ses.h:594
void ses_stop_msg_mode(ses_cb_t *scb)
Set the message output mode to inactive.
Definition: ses.c:3170
uint32 out_bytes
extra original internal out byte counter
Definition: ses.h:431
void ses_set_indent(ses_cb_t *scb, int32 indent)
Set the logging indent count for this session.
Definition: ses.c:3058
boolean inq
flag that already in the ready Q
Definition: ses.h:509
void ses_put_binchar(ses_cb_t *scb, uint32 ch)
Write one binary char to the session, without any translation.
Definition: ses.c:2620
RESTCONF mode.
Definition: ses.h:323
kill-session
Definition: ses.h:402
ses_read_fn_t rdfn
set if external write fn
Definition: ses.h:628
ses_prolog_state_t
prolog parsing state
Definition: ses.h:412
ncx_withdefaults_t ses_withdef(const ses_cb_t *scb)
Get the with-defaults value for this session.
Definition: ses.c:3720
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:725
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:4758
boolean ses_get_xml_nons(const ses_cb_t *scb)
force xmlns attributes to be skipped in XML mode
Definition: ses.c:4060
uint32 inBadRpcs
netconf-state in-bad-rpcs counter
Definition: ses.h:440
size_t buffstart
buff start pos
Definition: ses.h:484
boolean binary_notifs
Flag to indicate Binary Notification Messages are expected to be received on this session...
Definition: ses.h:764
uint32 inRpcs
netconf-state in-rpcs counter
Definition: ses.h:437
void ses_set_gnmi_session(ses_cb_t *scb)
Set the specified session as a gNMI session.
Definition: ses.c:5045
#define SES_MAX_STARTCHUNK_SIZE
max size of a valid base:1.1 chunk header start tag
Definition: ses.h:268
GNMI Internal processing over RESTCONF.
Definition: ses.h:358
waiting
Definition: ses.h:414
Global error messages for status code enumerations.
not set
Definition: ses.h:321
uint32 protocols_requested
bitmask
Definition: ses.h:558
void ses_set_message_indent(ses_cb_t *scb, int32 indent)
Set the message indent count for this session.
Definition: ses.c:3085
waiting for peer <hello>
Definition: ses.h:366
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:704
ses_msg_buff_t * outbuff
current output buffer
Definition: ses.h:637
boolean ses_dropped(const ses_cb_t *scb)
Check if the session has been dropped by the client.
Definition: ses.c:5159
ncx_protocol_t protocol
protocol version in use
Definition: ses.h:559
not set
Definition: ses.h:364
ses_cb_t * ses_new_snmp_scb(void)
Create a new global SNMP session control block.
Definition: ses.c:2317
void * openssl_ctx
backptr to TLS context
Definition: ses.h:698
void ses_finish_msg(ses_cb_t *scb)
Finish an outbound message on the specified session.
Definition: ses.c:3238
ncx_display_mode_t in_encoding
input encoding can be different in RESTCONF, set by the Content-Type header
Definition: ses.h:618
void ses_set_dbapi_session(ses_cb_t *scb)
Set the specified session as a DB-API control session.
Definition: ses.c:4703
in between 2 messages
Definition: ses.h:382
NETCONF over SSH (RFC 4742 and 6242)
Definition: ses.h:343
status_t ses_start_msg(ses_cb_t *scb)
Start a new outbound message on the specified session.
Definition: ses.c:3190
uint32 checksum
running checksum for YANG Push Simulated Operational mode
Definition: ses.h:740
bad <hello> received
Definition: ses.h:407
not used
Definition: ses.h:344
uint32 buffcnt
current buffer count
Definition: ses.h:632
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:4301
Session Total Statistics.
Definition: ses.h:454
uint32 failed_sessions
total failed sessions
Definition: ses.h:462
boolean skip_modnames
YPW-888: new restconf cli parameter to turn strict JSON YANG enconding off, do not include module nam...
Definition: ses.h:696
void ses_init_coap_scb(ses_cb_t *scb)
Initialize a CoAP session control block.
Definition: ses.c:2285
processing a request
Definition: ses.h:370
const xmlChar * ses_state_name(ses_state_t state)
Get the name of a session state from the enum value.
Definition: ses.c:3678
ses_type_t
Session Types.
Definition: ses.h:329
boolean ypgnmi
T: is gNMI ycontrol session.
Definition: ses.h:596
ses_write_fn_t wrfn
set if external read fn
Definition: ses.h:629
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:3741
ses_instate_t
Session Input Handler States for base:1.0 EOM processing.
Definition: ses.h:377
status_t ses_set_gnmi_control_session(ses_cb_t *scb)
Set the specified session as a gNMI control session.
Definition: ses.c:4999
boolean http_chunk_mode
T: send HTTP chunks, F: normal.
Definition: ses.h:602
status_t ses_put_extern2(ses_cb_t *scb, const xmlChar *fname)
write the contents of a file to the session
Definition: ses.c:3786
ses_transport_t transport
transport type
Definition: ses.h:560
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:2918
inactivity timeout
Definition: ses.h:404
ncx_msg_encoding_t
enumeration for message encoding formats
Definition: ncxtypes.h:647
xmlChar * service_name
variables for ycontrol sessions
Definition: ses.h:674
void * tcb
Thread control block.
Definition: ses.h:578
RESTCONF over CoAP; static socket, libcoap.
Definition: ses.h:334
boolean file_override
set by server DB-API session to capture <rpc-reply> output to a file.
Definition: ses.h:731
NETCONF mode.
Definition: ses.h:324
boolean is_ycontrol_scb
T: is ycontrol_scb for HA.
Definition: ses.h:606
FILE * fp
set if output to a file
Definition: ses.h:626
ncx_protocol_t
NCX session protocol versions supported.
Definition: ncxtypes.h:988
uint32 in_bytes
extra original internal in byte counter
Definition: ses.h:428
not set
Definition: ses.h:342
ses_instate_t instate
input state enum
Definition: ses.h:631
xmlChar * start_time
dateTime start time
Definition: ses.h:570
other
Definition: ses.h:405
void ses_clear_extern_xml_mode(ses_cb_t *scb, boolean rawxml_mode)
Clear the scb from external XML parsing.
Definition: ses.c:4333
not set
Definition: ses.h:330
not used
Definition: ses.h:345
struct cfg_template_t_ * fake_candidate
a fake candidate config for target=running YANG-PATCH
Definition: ses.h:734
RESTCONF over GNMI.
Definition: ses.h:336
ses_ypmode_t yp_mode
YANG-PATCH mode:
Definition: ses.h:690
ending the EOM field
Definition: ses.h:383
void ses_clear_dbapi_system_session(ses_cb_t *scb)
Clear a session of the DB-API system status.
Definition: ses.c:4793
void ses_clean_breadcrumbQ(ses_cb_t *scb)
Clean the breadcrumbQ.
Definition: ses.c:5140
not used YumaPro WEBui (ncxconnect, no framing)
Definition: ses.h:352
uint32 droppedSessions
total dropped sessions
Definition: ses.h:471
const xmlChar * ses_get_transport_name(ses_transport_t transport)
Get the name of the transport for a given enum value.
Definition: ses.c:3897
ncxserver.sock AF_LOCAL socket – control msg
Definition: ses.h:353
ncx_withdefaults_t
enum for with-defaults enum values
Definition: ncxtypes.h:1259
in message body
Definition: ses.h:380
boolean framing11
T: base:1.1, F: base:1.0.
Definition: ses.h:586
boolean warn_xml
T: xml warns, F: no warn.
Definition: ses.h:588
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:2704
close-session
Definition: ses.h:401
not set
Definition: ses.h:413
uint32 last_ch
save in case cr/lf in SSE mode
Definition: ses.h:612
boolean ses_is_dbapi_session(ses_cb_t *scb)
Check if the specified session is a DB-API control session.
Definition: ses.c:4722
void ses_set_extern_xml_mode(ses_cb_t *scb, boolean rawxml_mode)
Setup the scb for external XML parsing.
Definition: ses.c:4278
#define SES_MSG_BUFFSIZE
controls the size of each buffer chunk
Definition: ses.h:243
ses_id_t sid
session ID
Definition: ses.h:564
xmlChar * peeraddr
Inet address string.
Definition: ses.h:572
uint32 freecnt
current freeQ count
Definition: ses.h:633
boolean direct_mode
T: yp-shell, F: normal.
Definition: ses.h:590
status_t ses_start_http_chunk_mode(ses_cb_t *scb)
Start outputting buffers in HTTP 1.1 chunk mode.
Definition: ses.c:4904
uint32 ses_finish_checksum(ses_cb_t *scb, uint32 *checksum_cnt)
Stop checksum mode and return the final checksum.
Definition: ses.c:5268
ncx_msg_encoding_t ses_get_msg_encoding(const ses_cb_t *scb)
Get the message encoding for the HTTP session.
Definition: ses.c:4884
uint32 closed_sessions
total closed sessions
Definition: ses.h:459
time_t last_rpc_time
used for idle timeout
Definition: ses.h:569
YumaPro REST API ncxconnect, no framing.
Definition: ses.h:350
Session Message Buffer.
Definition: ses.h:482
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:661
tail-f NETCONF over TCP
Definition: ses.h:348
int32 ses_indent_count(const ses_cb_t *scb)
Get the logging indent count for this session.
Definition: ses.c:3019
ses_ready_t inready
header for inreadyQ
Definition: ses.h:638
status_t ses_set_grpc_control_session(ses_cb_t *scb)
Set the specified session as a gRPC control session.
Definition: ses.c:5356
ses_msg_t * curmsg
pointer to current message to read set by agt only
Definition: ses.h:719
boolean msg_mode
T:msg-indent F:indent.
Definition: ses.h:591
void ses_dump_binary_buff(const xmlChar *buff, size_t bufflen)
Dump some bytes from the binary buffer (max 256)
Definition: ses.c:5442
ses_type_t type
session type
Definition: ses.h:557
uint32 requests
internal request counters for EVAL tracking
Definition: ses.h:449
YP-HA mode.
Definition: ses.h:322
void ses_putstr(ses_cb_t *scb, const xmlChar *str)
Write a zero-terminated string to the session.
Definition: ses.c:2647
done
Definition: ses.h:415
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:3955