yumapro  24.10-1
YumaPro SDK
Loading...
Searching...
No Matches
ses.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2024, 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
32date init comment
33----------------------------------------------------------------------
3430-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
73extern "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_PEERPORT(S) (S)->peerport
184
186#define SES_TRANSPORT(S) (S)->transport
187
189#define SES_PROTOCOL(S) (S)->protocol
190
192#define SES_IS_IPV6(S) (S)->is_ipv6
193
195#define SES_IS_CALLHOME(S) (S)->is_callhome
196
198#define SES_TYPE(S) (S)->type
199
201#define SES_GET_COOKIE(S) (S)->get_cookie
202
204#define SES_BREADCRUMBQ(S) &(S)->breadcrumbQ
205
207#define SES_CURMSG(S) (S)->curmsg
208
210#define SES_START_TLS(S) (S)->start_tls
211
213#define SES_WILDCARD_OK(S) (S)->wildcard_ok
214
216#define SES_MGRCB(S) (S)->mgrcb
217
219#define SES_NOTIF_ACTIVE(S) (S)->notif_active
220
222#define SES_RFC8639_NOTIF_COUNT(S) (S)->rfc8639_notif_cnt
223
224
228#define SES_BINARY_NOTIFS(S) (S)->binary_notifs
229
233#define BINLOG (const xmlChar *)"***binary***"
234
235
240#define SES_CALLHOME_NAME(S) (S)->callhome_name
241
242
248#define SES_FREE_PENDING(S) (S)->free_pending
249
251#define SES_NULL_SID 0
252
261#define SES_MSG_BUFFSIZE 1000
262
267#define SES_MAX_BUFFERS 500000
268
270#ifdef WITH_COAP
271#define SES_MAX_FREE_BUFFERS 4
272#else
273#define SES_MAX_FREE_BUFFERS 32
274#endif // WITH_COAP
275
277#define SES_MAX_BUFFSEND 32
278
280#define SES_MAX_BYTESEND 0xffff
281
283#define SES_DEF_LINESIZE 72
284
286#define SES_MAX_STARTCHUNK_SIZE 13
287
289#define SES_MAX_CHUNKNUM_SIZE 10
290
302#define SES_STARTCHUNK_PAD 10
303
307#define SES_ENDCHUNK_PAD 8
308
310#define SES_READBUFF_SIZE 1000
311
313#define SES_GET_YPMODE(S) (S)->yp_mode
314
316#define SES_SET_YPMODE(S,V) (S)->yp_mode = V
317
319#define SES_REMOTE_WAIT(S) (S)->remote_wait
320
322#define SES_NEED_FILE_OVERRIDE(S) ((S)->file_override && (S)->fp)
323
325#define SES_SYSTEM_USERNAME NCX_EL_SYSTEM
326
327
328/********************************************************************
329* *
330* T Y P E S *
331* *
332*********************************************************************/
333
335typedef uint32 ses_id_t;
336
338typedef enum ses_ypmode_t_ {
344
345
347typedef enum ses_type_t_ {
356
357
359typedef enum ses_transport_t_ {
373 SES_TRANSPORT_COAP_DTLS, /* CoAP DTLS/UDP socket */
378
379
381typedef enum ses_state_t_ {
392
393
395typedef enum ses_instate_t_ {
403
404
406typedef enum ses_mode_t_ {
413} ses_mode_t;
414
415
417typedef enum ses_term_reason_t_ {
427
428
430typedef enum ses_prolog_state_t_ {
435
436
444typedef struct ses_stats_t_ {
446 uint32 in_bytes;
447
449 uint32 out_bytes;
450
452 uint32 out_line;
453
455 uint32 inRpcs;
456
458 uint32 inBadRpcs;
459
462
465
467 uint32 requests;
469
470
472typedef struct ses_total_stats_t_ {
475
478
481
484
487
490
493
495 xmlChar startTime[TSTAMP_MIN_SIZE];
497
498
500typedef struct ses_msg_buff_t_ {
501 dlq_hdr_t qhdr;
502 size_t buffstart;
503 size_t bufflen;
504 size_t buffpos;
505 boolean islast;
506 boolean isbinary;
512 xmlChar buff[SES_MSG_BUFFSIZE+1];
514
515
519typedef struct ses_ready_t_ {
521 dlq_hdr_t hdr;
522
525
527 boolean inq;
528
530 boolean ycontrol;
532
533
535typedef struct ses_msg_t_ {
536 dlq_hdr_t qhdr;
537 boolean ready;
538 boolean dispatched;
540 dlq_hdr_t buffQ;
544} ses_msg_t;
545
546
557typedef ssize_t (*ses_read_fn_t) (void *s,
558 char *buff,
559 size_t bufflen,
560 bool *erragain);
561
562
569typedef status_t (*ses_write_fn_t) (void *s);
570
571
573typedef struct ses_cb_t_ {
574 dlq_hdr_t qhdr;
586 time_t hello_time;
588 xmlChar *start_time;
589 xmlChar *username;
590 xmlChar *peeraddr;
591 uint16 peerport;
594 xmlChar *subsys_id;
596 int tid;
597 void *tcb;
600 boolean conn_closed;
601 boolean active;
602 boolean notif_active;
604 boolean noxmlns;
605 boolean framing11;
606 boolean keep_xmlns;
607 boolean warn_xml;
608 boolean rawxml_mode;
609 boolean direct_mode;
610 boolean msg_mode;
611 boolean ycontrol;
612 boolean dbapi;
613 boolean dbapi_system;
614 boolean sse_mode;
615 boolean ypgnmi;
620 boolean json_1line;
622 boolean http_waitrn;
623 boolean json_attrs;
626 boolean is_ipv6;
627 boolean is_callhome;
628 boolean dropped;
629 boolean free_pending;
630 boolean start_tls;
632 uint32 last_ch;
633 struct val_value_t_ *leaflist;
639
644
645 xmlTextReaderPtr reader;
646 FILE *fp;
647 int fd;
650 uint32 inendpos;
652 uint32 buffcnt;
653 uint32 freecnt;
654 dlq_hdr_t msgQ;
655 dlq_hdr_t freeQ;
656 dlq_hdr_t outQ;
661 void *mgrcb;
662 struct rpc_msg_t_ *cur_rpc_msg;
664 struct yangapi_cb_t_ *rcb;
665 xmlChar *entry_point;
671 xmlChar startchunk[SES_MAX_STARTCHUNK_SIZE+1];
672
674 xmlChar *readbuff;
677 /*** user preferences ***/
678 int8 indent;
680 uint32 linesize;
691 struct agt_acm_cache_t_ *acm_cache;
692
694 xmlChar *service_name;
699 boolean chunk_based;
703 boolean use_traceid;
704
711
717
725
730 boolean remote_wait;
731
736 dlq_hdr_t breadcrumbQ;
740
745 boolean wildcard_ok;
746
752
754 struct cfg_template_t_ *fake_candidate;
755
758
760 uint32 checksum;
774
776 struct obj_template_t_ *snmp_table_obj;
777
778 boolean ypgrpc;
785
790
797
798} ses_cb_t;
799
800
804/********************************************************************
805* *
806* F U N C T I O N S *
807* *
808*********************************************************************/
809
826extern ses_cb_t *
827 ses_new_scb (void);
828
829
835extern ses_cb_t *
836 ses_new_dummy_scb (void);
837
838
839#ifdef WITH_COAP
845extern ses_cb_t *
846 ses_new_coap_scb (void);
847
848
854extern void
856
857#endif // WITH_COAP
858
859
860#if defined(WITH_SNMP) && defined(WITH_RESTCONF)
866extern ses_cb_t *
867 ses_new_snmp_scb (void);
868
869#endif // WITH_SNMP
870
871
877extern void
878 ses_free_scb (ses_cb_t *scb);
879
880
894extern void
895 ses_putchar (ses_cb_t *scb,
896 uint32 ch);
897
898
912extern void
914 uint32 ch);
915
916
923extern void
924 ses_putstr (ses_cb_t *scb,
925 const xmlChar *str);
926
927
935extern void
937 const xmlChar *str,
938 uint32 len);
939
940
954extern void
956 const xmlChar *str,
957 int32 indent);
958
959
970extern void
971 ses_putcstr (ses_cb_t *scb,
972 const xmlChar *str,
973 int32 indent);
974
975
985extern void
986 ses_puthstr (ses_cb_t *scb,
987 const xmlChar *str);
988
989
996extern void
998 uint32 ch);
999
1000
1011extern void
1012 ses_putastr (ses_cb_t *scb,
1013 const xmlChar *str,
1014 int32 indent);
1015
1016
1027extern void
1028 ses_putjstr (ses_cb_t *scb,
1029 const xmlChar *str,
1030 int32 indent);
1031
1032
1043extern void
1044 ses_indent (ses_cb_t *scb,
1045 int32 indent);
1046
1047
1054extern int32
1055 ses_indent_count (const ses_cb_t *scb);
1056
1057
1064extern int32
1066
1067
1074extern void
1076 int32 indent);
1077
1078
1085extern void
1086 ses_set_message_indent (ses_cb_t *scb, int32 indent);
1087
1088
1095extern void
1096 ses_set_mode (ses_cb_t *scb,
1097 ses_mode_t mode);
1098
1099
1106extern ses_mode_t
1107 ses_get_mode (ses_cb_t *scb);
1108
1109
1115extern void ses_start_msg_mode (ses_cb_t *scb);
1116
1117
1123extern void ses_stop_msg_mode (ses_cb_t *scb);
1124
1125
1132extern status_t
1133 ses_start_msg (ses_cb_t *scb);
1134
1135
1141extern void
1142 ses_finish_msg (ses_cb_t *scb);
1143
1144
1165extern int
1166 ses_read_cb (void *context,
1167 char *buffer,
1168 int len);
1169
1170
1185extern status_t
1187
1188
1195extern const xmlChar *
1197
1198
1205extern ncx_withdefaults_t
1206 ses_withdef (const ses_cb_t *scb);
1207
1208
1216extern uint32
1217 ses_line_left (const ses_cb_t *scb);
1218
1219
1229extern void
1231 const xmlChar *fname);
1232
1233
1241extern status_t
1243 const xmlChar *fname);
1244
1245
1253extern status_t
1255 const xmlChar *fname);
1256
1257
1258
1264extern ses_total_stats_t *
1265 ses_get_total_stats (void);
1266
1267
1276extern ses_transport_t
1278
1279
1286extern ses_transport_t
1287 ses_get_transport_enum (const xmlChar *str);
1288
1289
1296extern const xmlChar *
1298
1299
1308extern const xmlChar *
1310
1311
1317extern void
1319
1320
1329extern boolean
1330 ses_get_xml_nons (const ses_cb_t *scb);
1331
1332
1340extern status_t
1342 ncx_protocol_t proto);
1343
1344
1352extern ncx_protocol_t
1353 ses_get_protocol (const ses_cb_t *scb);
1354
1355
1362extern void
1364 ncx_protocol_t proto);
1365
1366
1374extern boolean
1376 ncx_protocol_t proto);
1377
1378
1389extern void
1391 boolean rawxml_mode);
1392
1393
1405extern void
1407 boolean rawxml_mode,
1408 boolean keep_xmlns);
1409
1410
1422extern void
1424 boolean rawxml_mode);
1425
1426
1438extern void
1440 boolean rawxml_mode,
1441 boolean keep_xmlns);
1442
1443
1450extern void
1452 ncx_display_mode_t encoding);
1453
1454
1461extern void
1463
1464
1471extern ncx_display_mode_t
1473
1474
1483extern int32
1484 ses_new_indent_count (boolean indent_in,
1485 int32 indent,
1486 int32 indent_amount);
1487
1488
1496extern void
1498
1499
1513extern status_t
1514 ses_getline_cb (xmlChar *fillbuff,
1515 uint32 fillbuffsize,
1516 void *cookie);
1517
1518
1525extern status_t
1527
1528
1535extern boolean
1537
1538
1544extern void
1546
1547
1554extern boolean
1556
1557
1564extern void
1566
1567
1575extern boolean
1577
1578
1584extern void
1586
1587
1594extern boolean
1596
1597
1605extern int32
1607 int32 indent);
1608
1609
1617extern int32
1619 int32 indent);
1620
1621
1628extern ncx_msg_encoding_t
1629 ses_get_msg_encoding (const ses_cb_t *scb);
1630
1631
1638extern status_t
1640
1641
1648extern const xmlChar *
1650
1651
1659extern status_t
1661 const xmlChar *point);
1662
1663
1670extern boolean
1672
1673
1674#ifdef WITH_GNMI
1681extern status_t
1683
1684
1691extern boolean
1693
1694
1700extern void
1702
1703
1710extern boolean
1712
1713#endif //WITH_GNMI
1714
1715
1723extern status_t
1725 struct obj_template_t_ *obj);
1726
1727
1733extern void
1735
1736
1743extern boolean
1744 ses_dropped (const ses_cb_t *scb);
1745
1746
1755extern status_t
1757 const xmlChar *filespec,
1758 boolean is_binary);
1759
1760
1767extern void
1769
1770
1776extern void
1778
1779
1791extern uint32
1793 uint32 *checksum_cnt);
1794
1795
1805extern boolean
1806 ses_dropped_ex (ses_cb_t *scb);
1807
1808
1809#ifdef WITH_GRPC
1816extern status_t
1818
1819
1826extern boolean
1828
1829
1835extern void
1837
1838
1845extern boolean
1847
1848#endif //WITH_GRPC
1849
1850
1857extern void
1858 ses_dump_binary_buff (const xmlChar *buff,
1859 size_t bufflen);
1860
1868extern boolean
1869 ses_poll_ready (ses_cb_t *scb);
1870
1871
1878extern const xmlChar *
1880
1881
1889const xmlChar *
1891
1892
1896#ifdef __cplusplus
1897} /* end extern 'C' */
1898#endif
1899
1900#endif /* _H_ses */
dlq provides general double-linked list and queue support:
status_t
global error return code
Definition: status_enum.h:210
const xmlChar * ses_get_scb_client_addr(ses_cb_t *scb)
Get the client addr to use from an SCB.
Definition: ses.c:5733
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:2958
void ses_set_out_encoding(ses_cb_t *scb, ncx_display_mode_t encoding)
Set the output encoding.
Definition: ses.c:4470
void ses_free_scb(ses_cb_t *scb)
Free a session control block.
Definition: ses.c:2391
int32 ses_indent_count(const ses_cb_t *scb)
Get the logging indent count for this session.
Definition: ses.c:3059
void ses_start_checksum(ses_cb_t *scb)
Clear the checksum field and start checksum mode.
Definition: ses.c:5391
void ses_start_msg_mode(ses_cb_t *scb)
Set the message output mode to active.
Definition: ses.c:3199
boolean ses_protocol_requested(ses_cb_t *scb, ncx_protocol_t proto)
check if the NETCONF protocol version was requested
Definition: ses.c:4295
void ses_set_grpc_session(ses_cb_t *scb)
Set the specified session as a gRPC session.
Definition: ses.c:5559
void ses_set_gnmi_session(ses_cb_t *scb)
Set the specified session as a gNMI session.
Definition: ses.c:5180
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:3809
void ses_set_mode(ses_cb_t *scb, ses_mode_t mode)
Set the output mode for the specified session.
Definition: ses.c:3155
void ses_put_extern(ses_cb_t *scb, const xmlChar *fname)
write the contents of a file to the session
Definition: ses.c:3831
boolean ses_is_control_session(ses_cb_t *scb)
Check if the specified session is a control session.
Definition: ses.c:4782
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:4382
boolean ses_is_dbapi_session(ses_cb_t *scb)
Check if the specified session is a DB-API control session.
Definition: ses.c:4825
void ses_finish_msg(ses_cb_t *scb)
Finish an outbound message on the specified session.
Definition: ses.c:3291
void ses_put_binstr(ses_cb_t *scb, const xmlChar *str, uint32 len)
Write a binary string to the session.
Definition: ses.c:2710
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:2824
void ses_clear_extern_xml_mode(ses_cb_t *scb, boolean rawxml_mode)
Clear the scb from external XML parsing.
Definition: ses.c:4417
ncx_withdefaults_t ses_withdef(const ses_cb_t *scb)
Get the with-defaults value for this session.
Definition: ses.c:3785
ncx_display_mode_t ses_get_out_encoding(ses_cb_t *scb)
Get the output encoding.
Definition: ses.c:4518
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:2744
status_t ses_start_msg(ses_cb_t *scb)
Start a new outbound message on the specified session.
Definition: ses.c:3241
status_t ses_set_protocol(ses_cb_t *scb, ncx_protocol_t proto)
set the NETCONF protocol version in use
Definition: ses.c:4150
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:4575
void ses_clear_dbapi_system_session(ses_cb_t *scb)
Clear a session of the DB-API system status.
Definition: ses.c:4908
const xmlChar * ses_state_name(ses_state_t state)
Get the name of a session state from the enum value.
Definition: ses.c:3743
const xmlChar * ses_get_entry_point(ses_cb_t *scb)
Get the RESTCONF entry_point.
Definition: ses.c:5069
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:5329
ncx_protocol_t ses_get_protocol(const ses_cb_t *scb)
Get the NETCONF protocol set (or unset) for this session.
Definition: ses.c:4226
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:4543
ses_cb_t * ses_new_snmp_scb(void)
Create a new global SNMP session control block.
Definition: ses.c:2355
int32 ses_message_indent_count(const ses_cb_t *scb)
Get the message indent count for this session.
Definition: ses.c:3080
const xmlChar * ses_get_scb_username(ses_cb_t *scb)
Get the username to use from an SCB.
Definition: ses.c:5710
status_t ses_set_gnmi_control_session(ses_cb_t *scb)
Set the specified session as a gNMI control session.
Definition: ses.c:5131
ses_transport_t ses_get_transport_enum(const xmlChar *str)
Get the enum value for the yumaworks-types:transport-type.
Definition: ses.c:4069
void ses_stop_msg_mode(ses_cb_t *scb)
Set the message output mode to inactive.
Definition: ses.c:3219
void ses_putstr(ses_cb_t *scb, const xmlChar *str)
Write a zero-terminated string to the session.
Definition: ses.c:2687
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:3890
void ses_indent(ses_cb_t *scb, int32 indent)
Write the proper newline + indentation to the specified session.
Definition: ses.c:3026
status_t ses_set_entry_point(ses_cb_t *scb, const xmlChar *point)
Set the RESTCONF entry_point.
Definition: ses.c:5097
boolean ses_notifications_active(const ses_cb_t *scb)
Check if the session has notifications active.
Definition: ses.c:5224
ses_total_stats_t * ses_get_total_stats(void)
Get a r/w pointer to the the session totals stats.
Definition: ses.c:3927
void ses_init_coap_scb(ses_cb_t *scb)
Initialize a CoAP session control block.
Definition: ses.c:2320
void ses_set_indent(ses_cb_t *scb, int32 indent)
Set the logging indent count for this session.
Definition: ses.c:3098
const xmlChar * ses_get_transport_name(ses_transport_t transport)
Get the name of the transport for a given enum value.
Definition: ses.c:3965
boolean ses_poll_ready(ses_cb_t *scb)
Check if the specified session is ready to read bytes.
Definition: ses.c:5660
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:4867
boolean ses_is_grpc_control_session(ses_cb_t *scb)
Check if the specified session is a gRPC control session.
Definition: ses.c:5534
void ses_clean_breadcrumbQ(ses_cb_t *scb)
Clean the breadcrumbQ.
Definition: ses.c:5285
status_t ses_accept_input(ses_cb_t *scb)
The IO input handler for the ncxserver loop.
Definition: ses.c:3498
boolean ses_dropped(const ses_cb_t *scb)
Check if the session has been dropped by the client.
Definition: ses.c:5307
status_t ses_set_control_session(ses_cb_t *scb)
Set the specified session as a control session.
Definition: ses.c:4760
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:2780
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:2904
ses_cb_t * ses_new_coap_scb(void)
Create a new global CoAP session control block.
Definition: ses.c:2299
status_t ses_add_breadcrumb_obj(ses_cb_t *scb, struct obj_template_t_ *obj)
Add an object to the breadcrumbQ.
void ses_putchar(ses_cb_t *scb, uint32 ch)
Write one char to the session, without any translation.
Definition: ses.c:2634
boolean ses_get_xml_nons(const ses_cb_t *scb)
force xmlns attributes to be skipped in XML mode
Definition: ses.c:4131
void ses_set_protocols_requested(ses_cb_t *scb, ncx_protocol_t proto)
set the NETCONF protocol versions requested
Definition: ses.c:4249
void ses_set_message_indent(ses_cb_t *scb, int32 indent)
Set the message indent count for this session.
Definition: ses.c:3127
void ses_putcchar(ses_cb_t *scb, uint32 ch)
Write one content char to the session, with translation as needed.
Definition: ses.c:2862
status_t ses_start_http_chunk_mode(ses_cb_t *scb)
Start outputting buffers in HTTP 1.1 chunk mode.
Definition: ses.c:5030
ncx_msg_encoding_t ses_get_msg_encoding(const ses_cb_t *scb)
Get the message encoding for the HTTP session.
Definition: ses.c:5008
int32 ses_add_indent(ses_cb_t *scb, int32 indent)
Add in the new indent amount.
Definition: ses.c:4932
ses_transport_t ses_get_transport(ses_cb_t *scb)
Get the transport enum for a given session.
Definition: ses.c:3945
int ses_read_cb(void *context, char *buffer, int len)
The IO input front-end for the xmlTextReader parser read fn.
Definition: ses.c:3376
void ses_set_xml_nons(ses_cb_t *scb)
force xmlns attributes to be skipped in XML mode
Definition: ses.c:4111
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:4441
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:4492
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:4889
int32 ses_dec_indent(ses_cb_t *scb, int32 indent)
Remove the specified indent amount.
Definition: ses.c:4969
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:4610
void ses_set_dbapi_session(ses_cb_t *scb)
Set the specified session as a DB-API control session.
Definition: ses.c:4803
boolean ses_is_gnmi_control_session(ses_cb_t *scb)
Check if the specified session is a gNMI control session.
Definition: ses.c:5155
ses_cb_t * ses_new_dummy_scb(void)
Create a new dummy session control block.
Definition: ses.c:2267
uint32 ses_finish_checksum(ses_cb_t *scb, uint32 *checksum_cnt)
Stop checksum mode and return the final checksum.
Definition: ses.c:5421
boolean ses_is_grpc_session(ses_cb_t *scb)
Check if the specified session is a gRPC session.
Definition: ses.c:5581
boolean ses_is_system_session(ses_cb_t *scb)
Check if the specified session is an internal system session.
Definition: ses.c:4846
void ses_set_extern_xml_mode(ses_cb_t *scb, boolean rawxml_mode)
Setup the scb for external XML parsing.
Definition: ses.c:4359
boolean ses_dropped_ex(ses_cb_t *scb)
Check if the session has been dropped by the client.
Definition: ses.c:5461
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:4023
status_t ses_set_grpc_control_session(ses_cb_t *scb)
Set the specified session as a gRPC control session.
Definition: ses.c:5510
status_t ses_put_extern2(ses_cb_t *scb, const xmlChar *fname)
write the contents of a file to the session
Definition: ses.c:3854
void ses_dump_binary_buff(const xmlChar *buff, size_t bufflen)
Dump some bytes from the binary buffer (max 256)
Definition: ses.c:5605
ses_cb_t * ses_new_scb(void)
Create a new session control block.
Definition: ses.c:2192
ses_mode_t ses_get_mode(ses_cb_t *scb)
Get the output mode for the specified session.
Definition: ses.c:3176
boolean ses_is_gnmi_session(ses_cb_t *scb)
Check if the specified session is a gNMI session.
Definition: ses.c:5202
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:5365
void ses_put_binchar(ses_cb_t *scb, uint32 ch)
Write one binary char to the session, without any translation.
Definition: ses.c:2660
status_t(* ses_write_fn_t)(void *s)
optional write function for the session
Definition: ses.h:569
ses_transport_t
NETCONF Transport Types.
Definition: ses.h:359
ses_ypmode_t
YANG-PATCH Mode.
Definition: ses.h:338
ses_state_t
Session States.
Definition: ses.h:381
ses_mode_t
Session Output Mode.
Definition: ses.h:406
ses_term_reason_t
Session Termination reason.
Definition: ses.h:417
ses_type_t
Session Types.
Definition: ses.h:347
ses_instate_t
Session Input Handler States for base:1.0 EOM processing.
Definition: ses.h:395
uint32 ses_id_t
Session ID.
Definition: ses.h:335
#define SES_MSG_BUFFSIZE
controls the size of each buffer chunk
Definition: ses.h:261
#define SES_MAX_STARTCHUNK_SIZE
max size of a valid base:1.1 chunk header start tag
Definition: ses.h:286
ses_prolog_state_t
prolog parsing state
Definition: ses.h:430
ssize_t(* ses_read_fn_t)(void *s, char *buff, size_t bufflen, bool *erragain)
optional read function for the session
Definition: ses.h:557
@ SES_TRANSPORT_TCP_TAILF
tail-f NETCONF over TCP
Definition: ses.h:366
@ SES_TRANSPORT_BEEP
not used
Definition: ses.h:362
@ SES_TRANSPORT_COAP
CoAP UDP socket.
Definition: ses.h:372
@ SES_TRANSPORT_CLI
YumaPro CLI hook (ncxconnect, NETCONF framing)
Definition: ses.h:369
@ SES_TRANSPORT_NETCONF_TLS
NETCONF over TLS.
Definition: ses.h:375
@ SES_TRANSPORT_WEBUI
not used YumaPro WEBui (ncxconnect, no framing)
Definition: ses.h:370
@ SES_TRANSPORT_SOAP
not used
Definition: ses.h:363
@ SES_TRANSPORT_SNMP
SNMP UDP socket.
Definition: ses.h:374
@ SES_TRANSPORT_NONE
not set
Definition: ses.h:360
@ SES_TRANSPORT_SSH
NETCONF over SSH (RFC 4742 and 6242)
Definition: ses.h:361
@ SES_TRANSPORT_TLS
YANGAPI/RESTCONF over TLS.
Definition: ses.h:365
@ SES_TRANSPORT_AFLOCAL
ncxserver.sock AF_LOCAL socket – control msg
Definition: ses.h:371
@ SES_TRANSPORT_GNMI
GNMI Internal processing over RESTCONF.
Definition: ses.h:376
@ SES_TRANSPORT_HTTP
YumaPro REST API ncxconnect, no framing.
Definition: ses.h:368
@ SES_TRANSPORT_SOAPBEEP
not used
Definition: ses.h:364
@ SES_TRANSPORT_TCP_NCX
YumaWorks NETCONF over TCP.
Definition: ses.h:367
@ SES_YPMODE_RESTCONF
RESTCONF mode.
Definition: ses.h:341
@ SES_YPMODE_HA
YP-HA mode.
Definition: ses.h:340
@ SES_YPMODE_NONE
not set
Definition: ses.h:339
@ SES_YPMODE_NETCONF
NETCONF mode.
Definition: ses.h:342
@ SES_ST_IN_MSG
processing a request
Definition: ses.h:388
@ SES_ST_HELLO_WAIT
waiting for peer <hello>
Definition: ses.h:384
@ SES_ST_INIT
initialization state
Definition: ses.h:383
@ SES_ST_IDLE
adble to accept requests
Definition: ses.h:387
@ SES_ST_NONE
not set
Definition: ses.h:382
@ SES_ST_SHUTDOWN_REQ
session shutdown requested
Definition: ses.h:389
@ SES_ST_SHUTDOWN
session shutting down
Definition: ses.h:390
@ SES_ST_XRD_WAIT
RESTCONF Entry point processing.
Definition: ses.h:385
@ SES_ST_RESTCAPS_WAIT
RESTCONF Capabilities processing.
Definition: ses.h:386
@ SES_MODE_TEXT
text mode
Definition: ses.h:411
@ SES_MODE_BINARY
binary mode
Definition: ses.h:412
@ SES_MODE_HTML
HTML mode.
Definition: ses.h:410
@ SES_MODE_XMLDOC
XML documentation mode.
Definition: ses.h:409
@ SES_MODE_NONE
not set
Definition: ses.h:407
@ SES_MODE_XML
XML mode.
Definition: ses.h:408
@ SES_TR_CLOSED
close-session
Definition: ses.h:419
@ SES_TR_NONE
not set
Definition: ses.h:418
@ SES_TR_BAD_START
bad session start
Definition: ses.h:424
@ SES_TR_KILLED
kill-session
Definition: ses.h:420
@ SES_TR_TIMEOUT
inactivity timeout
Definition: ses.h:422
@ SES_TR_DROPPED
dropped by remote peer
Definition: ses.h:421
@ SES_TR_OTHER
other
Definition: ses.h:423
@ SES_TR_BAD_HELLO
bad <hello> received
Definition: ses.h:425
@ SES_TYP_NONE
not set
Definition: ses.h:348
@ SES_TYP_NETCONF
any network configuration protocol
Definition: ses.h:349
@ SES_TYP_COAP
RESTCONF over CoAP; static socket, libcoap.
Definition: ses.h:352
@ SES_TYP_GNMI
RESTCONF over GNMI.
Definition: ses.h:354
@ SES_TYP_YCONTROL
internal YControl session w/ subsystem
Definition: ses.h:351
@ SES_TYP_DUMMY
internal session for rollback, etc.
Definition: ses.h:350
@ SES_TYP_SNMP
RESTCONF over SNMP.
Definition: ses.h:353
@ SES_INST_INMSG
in message body
Definition: ses.h:398
@ SES_INST_NONE
not set
Definition: ses.h:396
@ SES_INST_INSTART
starting in the EOM field
Definition: ses.h:399
@ SES_INST_IDLE
idle state
Definition: ses.h:397
@ SES_INST_INEND
ending the EOM field
Definition: ses.h:401
@ SES_INST_INBETWEEN
in between 2 messages
Definition: ses.h:400
@ SES_PRST_WAITING
waiting
Definition: ses.h:432
@ SES_PRST_DONE
done
Definition: ses.h:433
@ SES_PRST_NONE
not set
Definition: ses.h:431
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:71
ncx_msg_encoding_t
enumeration for message encoding formats
Definition: ncxtypes.h:647
ncx_protocol_t
NCX session protocol versions supported.
Definition: ncxtypes.h:1001
ncx_display_mode_t
enumeration of val_dump_value display modes Some RESTCONF code uses this field incorrectly for messag...
Definition: ncxtypes.h:617
ncx_withdefaults_t
enum for with-defaults enum values
Definition: ncxtypes.h:1278
YANG module data structures Many internal representations of YANG module constructs.
Global error messages for status code enumerations.
Session Control Block.
Definition: ses.h:573
boolean content_length_based
content len based msg body
Definition: ses.h:698
boolean rawxml_mode
T: expand_anyxml, F: normal.
Definition: ses.h:608
ses_read_fn_t rdfn
set if external write fn
Definition: ses.h:648
boolean framing11
T: base:1.1, F: base:1.0.
Definition: ses.h:605
xmlChar * readbuff
input buffer for session
Definition: ses.h:674
uint32 checksum
running checksum for YANG Push Simulated Operational mode
Definition: ses.h:760
uint32 freecnt
current freeQ count
Definition: ses.h:653
boolean http_chunk_mode
T: send HTTP chunks, F: normal.
Definition: ses.h:621
boolean locks_released
Signal release point in kill.
Definition: ses.h:598
boolean binary_notifs
Flag to indicate Binary Notification Messages are expected to be received on this session.
Definition: ses.h:784
uint32 linesize
TERM line length.
Definition: ses.h:680
ses_msg_t * curmsg
pointer to current message to read set by agt only
Definition: ses.h:739
xmlChar * callhome_name
set for server NETCONF over TLS callhome sessions so the callhome reconnect can be checked when the s...
Definition: ses.h:796
void * openssl_ssl
malloced with SSL_new
Definition: ses.h:719
xmlChar * username
user ID
Definition: ses.h:589
boolean direct_mode
T: yp-shell, F: normal.
Definition: ses.h:609
boolean is_ipv6
T: using IPv6 address, F: IPv4.
Definition: ses.h:626
boolean sse_mode
T: Server Sent Events, F: normal.
Definition: ses.h:614
struct rpc_msg_t_ * cur_rpc_msg
for SIL-SA get callback
Definition: ses.h:662
uint32 readbuffsize
input buffer size
Definition: ses.h:675
dlq_hdr_t breadcrumbQ
Queue of breadcrumb object back pointers used in XPath GET2 processing of when-stmts in operational s...
Definition: ses.h:736
dlq_hdr_t freeQ
Q of ses_msg_buff_t.
Definition: ses.h:655
uint32 checksum_cnt
byte count
Definition: ses.h:761
boolean stream_output
buffer/stream svr
Definition: ses.h:603
boolean msg_mode
T:msg-indent F:indent.
Definition: ses.h:610
boolean ypgnmi
T: is gNMI ycontrol session.
Definition: ses.h:615
boolean active
<hello> completed ok
Definition: ses.h:601
ses_id_t sid
session ID
Definition: ses.h:582
boolean json_1line
T: output JSON leaf-list on 1 line.
Definition: ses.h:620
uint32 cache_timeout
vir-val cache tmr in sec
Definition: ses.h:682
ses_stats_t stats
per-session statistics
Definition: ses.h:660
ses_ready_t outready
header for outreadyQ
Definition: ses.h:659
boolean reading_header
variables for SSL sessions; used by yangcli-pro
Definition: ses.h:697
boolean dbapi_system
T: is DB-API system session.
Definition: ses.h:613
boolean skip_modnames
YPW-888: new restconf cli parameter to turn strict JSON YANG enconding off, do not include module nam...
Definition: ses.h:716
boolean start_tls
T: need to start TLS session first.
Definition: ses.h:630
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:745
uint32 inendpos
inside framing directive
Definition: ses.h:650
int32 total_length
total length
Definition: ses.h:700
boolean use_traceid
TRUE if OK to use Trace ID attr in the RPC calls.
Definition: ses.h:703
struct agt_acm_cache_t_ * acm_cache
agent access control for database reads and writes; for incoming agent <rpc> requests,...
Definition: ses.h:691
ses_ready_t inready
header for inreadyQ
Definition: ses.h:658
ncx_withdefaults_t withdef
with-defaults default
Definition: ses.h:681
ses_msg_buff_t * outbuff
current output buffer
Definition: ses.h:657
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:724
dlq_hdr_t qhdr
queued by manager only
Definition: ses.h:574
boolean http_waitrn
T: wait for EOchunk, F: no wait.
Definition: ses.h:622
ses_write_fn_t wrfn
set if external read fn
Definition: ses.h:649
int8 indent
indent N spaces (0..9)
Definition: ses.h:678
ses_mode_t mode
session mode
Definition: ses.h:581
int fd
set if output to a socket
Definition: ses.h:647
int8 msg_indent
indent N spaces (-1..9)
Definition: ses.h:679
boolean ycontrol
T: is ycontrol session.
Definition: ses.h:611
boolean checksum_mode
T: add out byte to checksum.
Definition: ses.h:631
dlq_hdr_t snmp_getnext_listQ
SNMP pointers Q of malloced val_value struct Q of list entries with only keys in it.
Definition: ses.h:773
uint32 yang_sid_tree
SID Tree Assignment for this session.
Definition: ses.h:789
struct cfg_template_t_ * fake_candidate
a fake candidate config for target=running YANG-PATCH
Definition: ses.h:754
boolean warn_xml
T: xml warns, F: no warn.
Definition: ses.h:607
uint32 buffcnt
current buffer count
Definition: ses.h:652
boolean restconf_sse_mode
T: RESTCONF SSE mode.
Definition: ses.h:617
uint32 protocols_requested
bitmask
Definition: ses.h:576
uint16 rfc8639_notif_cnt
New subscriptions allow more than 1 per session.
Definition: ses.h:757
int tid
Thread ID representing session.
Definition: ses.h:596
xmlChar * service_name
variables for ycontrol sessions
Definition: ses.h:694
ncx_protocol_t protocol
protocol version in use
Definition: ses.h:577
boolean is_callhome
T: callhome session.
Definition: ses.h:627
FILE * fp
set if output to a file
Definition: ses.h:646
uint32 last_ch
save in case cr/lf in SSE mode
Definition: ses.h:632
boolean any_leaflist_attrs
T: leaf-list has attrs.
Definition: ses.h:624
dlq_hdr_t outQ
Q of ses_msg_buff_t.
Definition: ses.h:656
boolean chunk_based
chunked based msg body
Definition: ses.h:699
ses_id_t rollback_sid
session ID for rollback
Definition: ses.h:584
ses_instate_t instate
input state enum
Definition: ses.h:651
dlq_hdr_t msgQ
Q of ses_msg_t input.
Definition: ses.h:654
boolean dbapi
T: is DB-API session.
Definition: ses.h:612
struct obj_template_t_ * snmp_table_obj
Current SNMP walk table.
Definition: ses.h:776
ses_state_t state
session state
Definition: ses.h:580
ncx_display_mode_t in_encoding
input encoding can be different in RESTCONF, set by the Content-Type header
Definition: ses.h:638
xmlChar * start_time
dateTime start time
Definition: ses.h:588
boolean restconf_notif
REST SSE notifications in progress.
Definition: ses.h:618
ses_transport_t transport
transport type
Definition: ses.h:578
void * openssl_ctx
backptr to TLS context
Definition: ses.h:718
uint16 peerport
Inet TCP port number.
Definition: ses.h:591
struct val_value_t_ * leaflist
JSON attrs backptr.
Definition: ses.h:633
boolean keep_xmlns
T: parse extern, F: msg
Definition: ses.h:606
ses_ypmode_t yp_mode
YANG-PATCH mode:
Definition: ses.h:710
xmlTextReaderPtr reader
input stream reader
Definition: ses.h:645
void * tcb
Thread control block.
Definition: ses.h:597
ses_type_t type
session type
Definition: ses.h:575
boolean notif_active
subscription active
Definition: ses.h:602
boolean file_override
set by server DB-API session to capture <rpc-reply> output to a file.
Definition: ses.h:751
void * mgrcb
if manager session, mgr_scb_t
Definition: ses.h:661
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:730
time_t last_rpc_time
used for idle timeout
Definition: ses.h:587
ses_term_reason_t termreason
termination reason
Definition: ses.h:585
boolean is_ycontrol_scb
T: is ycontrol_scb for HA.
Definition: ses.h:625
boolean free_pending
T: dropped SUBSYS waiting free.
Definition: ses.h:629
boolean noxmlns
xml-nons display-mode
Definition: ses.h:604
xmlChar * subsys_id
used for YCONTROL session only
Definition: ses.h:594
boolean dropped
T: session dropped in a msg.
Definition: ses.h:628
boolean conn_closed
T: scb IO closed last buffer.
Definition: ses.h:600
xmlChar * peeraddr
Inet address string.
Definition: ses.h:590
time_t hello_time
used for hello timeout
Definition: ses.h:586
boolean json_attrs
T: use JSON attributes.
Definition: ses.h:623
ncx_msg_encoding_t encoding
HTTP msg encoding.
Definition: ses.h:579
ncx_display_mode_t out_encoding
output encoding can be different in RESTCONF, set by the Accept header
Definition: ses.h:643
boolean ypgrpc
T: is gRPC ycontrol session.
Definition: ses.h:778
xmlChar * entry_point
REST-API entry point.
Definition: ses.h:665
ses_id_t killedbysid
killed-by session ID
Definition: ses.h:583
struct yangapi_cb_t_ * rcb
REST-API control block.
Definition: ses.h:664
Session Message Buffer.
Definition: ses.h:500
size_t buffstart
buff start pos
Definition: ses.h:502
boolean isbinary
T: CBOR, F: XML.
Definition: ses.h:506
dlq_hdr_t qhdr
not set
Definition: ses.h:501
size_t buffpos
buff cur position
Definition: ses.h:504
boolean islast
T: last buff in msg.
Definition: ses.h:505
size_t bufflen
buff actual size
Definition: ses.h:503
Session Message.
Definition: ses.h:535
dlq_hdr_t buffQ
Q of ses_msg_buff_t.
Definition: ses.h:540
size_t curchunksize
cur chunk rcvd
Definition: ses.h:542
size_t expchunksize
expected chunk size
Definition: ses.h:543
boolean dispatched
in processing
Definition: ses.h:538
dlq_hdr_t qhdr
Q header for buffcb->msgQ.
Definition: ses.h:536
boolean ready
ready for parsing
Definition: ses.h:537
ses_prolog_state_t prolog_state
for insert prolog
Definition: ses.h:541
ses_msg_buff_t * curbuff
cur position in buffQ
Definition: ses.h:539
embedded Q header for the message ready Q The 'inq' flag is used to prevent queue corruption
Definition: ses.h:519
boolean inq
flag that already in the ready Q
Definition: ses.h:527
dlq_hdr_t hdr
< embedded queue header threaded into ready Q
Definition: ses.h:521
ses_id_t sid
session ID of this session
Definition: ses.h:524
boolean ycontrol
flag YControl session for priority processing
Definition: ses.h:530
Per Session Statistics.
Definition: ses.h:444
uint32 inRpcs
netconf-state in-rpcs counter
Definition: ses.h:455
uint32 in_bytes
extra original internal in byte counter
Definition: ses.h:446
uint32 requests
internal request counters for EVAL tracking
Definition: ses.h:467
uint32 outNotifications
netconf-state out-notifications counter
Definition: ses.h:464
uint32 out_line
hack: bytes since ' ', pretty-print
Definition: ses.h:452
uint32 outRpcErrors
netconf-state out-rpc-errors counter
Definition: ses.h:461
uint32 inBadRpcs
netconf-state in-bad-rpcs counter
Definition: ses.h:458
uint32 out_bytes
extra original internal out byte counter
Definition: ses.h:449
Session Total Statistics.
Definition: ses.h:472
uint32 closed_sessions
total closed sessions
Definition: ses.h:477
uint32 inBadHellos
total in bad hello messages
Definition: ses.h:483
ses_stats_t stats
per-session stats added up for all sessions
Definition: ses.h:492
uint32 droppedSessions
total dropped sessions
Definition: ses.h:489
uint32 inSessions
total inbound sessions
Definition: ses.h:486
uint32 failed_sessions
total failed sessions
Definition: ses.h:480
uint32 active_sessions
total active sessions
Definition: ses.h:474
Timestamp utilities.