yumapro  21.10T-9
YumaPro SDK
agt_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_agt_ses
13 #define _H_agt_ses
14 /* FILE: agt_ses.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
27 /*********************************************************************
28 * *
29 * C H A N G E H I S T O R Y *
30 * *
31 *********************************************************************
32 
33 date init comment
34 ----------------------------------------------------------------------
35 06-jun-06 abb Begun.
36 */
37 
38 #include <sys/select.h>
39 
40 #include <xmlstring.h>
41 
42 #ifndef _H_getcb
43 #include "getcb.h"
44 #endif
45 
46 #ifndef _H_ncxconst
47 #include "ncxconst.h"
48 #endif
49 
50 #ifndef _H_ses
51 #include "ses.h"
52 #endif
53 
54 #ifndef _H_status
55 #include "status.h"
56 #endif
57 
58 #ifndef _H_val
59 #include "val.h"
60 #endif
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 /********************************************************************
67 * *
68 * C O N S T A N T S *
69 * *
70 *********************************************************************/
71 
72 /********************************************************************
73 * *
74 * T Y P E S *
75 * *
76 *********************************************************************/
77 
78 
101 /********************************************************************
102 * *
103 * F U N C T I O N S *
104 * *
105 *********************************************************************/
106 
107 /* what is this hack? */
108 extern const char *term_reason_str (ses_term_reason_t termreason);
109 
110 
117 extern status_t
118  agt_ses_init (void);
119 
120 
126 extern void
127  agt_ses_cleanup (void);
128 
129 
135 extern ses_cb_t *
137 
138 
147 extern status_t
148  agt_ses_set_dummy_session_acm (ses_cb_t *dummy_session,
149  ses_id_t use_sid);
150 
151 
152 
158 extern void
160 
161 
162 #ifdef WITH_COAP
163 
168 extern ses_cb_t *
170 
171 
177 extern void
179 
180 #endif // WITH_COAP
181 
182 
183 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
184 
190 extern ses_cb_t *
192 
193 
199 extern void
201 
202 #endif // WITH_SNMP
203 
204 
214 extern ses_cb_t *
216  int fd);
217 
218 
232 extern ses_cb_t *
234  int fd,
235  const char *client_addr);
236 
237 
243 extern void
245 
246 
254 extern void
256  boolean clear_locks);
257 
258 
265 extern boolean
267 
268 
277 extern boolean
279  ses_id_t killedby,
280  ses_term_reason_t termreason);
281 
282 
283 #ifdef PTHREADS
284 
291 extern void
293  ses_id_t killedby,
294  ses_term_reason_t termreason);
295 #endif // PTHREADS
296 
297 
305 extern void
307  ses_id_t killedby,
308  ses_term_reason_t termreason);
309 
310 
318 extern boolean
320 
321 
330 extern boolean
331  agt_ses_process_first_ready (boolean ycontrol);
332 
333 
334 #ifdef PTHREADS
335 
342 extern void
344 
345 #else
346 
353 extern void
354  agt_ses_check_timeouts (void);
355 
356 #endif // PTHREADS
357 
358 
366 extern boolean
367  agt_ses_ssh_port_allowed (uint16 port);
368 
369 
379 extern void
380  agt_ses_fill_writeset (fd_set *fdset,
381  int *maxfdnum);
382 
383 
396 extern status_t
398  getcb_mode_t cbmode,
399  const val_value_t *virval,
400  val_value_t *dstval);
401 
402 
415 extern status_t
417  getcb_mode_t cbmode,
418  const val_value_t *virval,
419  val_value_t *dstval);
420 
421 
434 extern status_t
436  getcb_mode_t cbmode,
437  const val_value_t *virval,
438  val_value_t *dstval);
439 
440 
453 extern status_t
455  getcb_mode_t cbmode,
456  const val_value_t *virval,
457  val_value_t *dstval);
458 
459 
472 extern status_t
474  getcb_mode_t cbmode,
475  const val_value_t *virval,
476  val_value_t *dstval);
477 
478 
479 
492 extern status_t
494  getcb_mode_t cbmode,
495  const val_value_t *virval,
496  val_value_t *dstval);
497 
498 
511 extern status_t
513  getcb_mode_t cbmode,
514  const val_value_t *virval,
515  val_value_t *dstval);
516 
517 
518 
531 extern status_t
533  getcb_mode_t cbmode,
534  const val_value_t *virval,
535  val_value_t *dstval);
536 
537 
550 extern status_t
552  getcb_mode_t cbmode,
553  const val_value_t *virval,
554  val_value_t *dstval);
555 
556 
569 extern status_t
571  getcb_mode_t cbmode,
572  const val_value_t *virval,
573  val_value_t *dstval);
574 
575 
588 extern status_t
590  getcb_mode_t cbmode,
591  const val_value_t *virval,
592  val_value_t *dstval);
593 
594 
600 extern void
602 
603 
610 extern ses_cb_t*
612 
613 
619 extern uint32
621 
622 
623 
624 #ifdef WITH_YP_HA
625 
631 extern void
632  agt_ses_go_active (void);
633 
634 #endif // WITH_YP_HA
635 
636 
637 #ifdef WITH_YP_HA
638 
644 extern void
645  agt_ses_go_standby (void);
646 
647 
654 extern void
656 
657 #endif // WITH_YP_HA
658 
659 
665 extern boolean
667 
668 
674 extern void
675  agt_ses_set_max_sessions (uint16 val);
676 
677 
683 extern void
684  agt_ses_set_max_cli_sessions (uint16 val);
685 
686 
692 extern void
693  agt_ses_set_hello_timeout (uint32 val);
694 
695 
701 extern void
702  agt_ses_set_idle_timeout (uint32 val);
703 
704 
709 #ifdef __cplusplus
710 } /* end extern 'C' */
711 #endif
712 
713 #endif /* _H_agt_ses */
void agt_ses_free_dummy_session(ses_cb_t *scb)
Free a dummy session control block.
Definition: agt_ses.c:641
void agt_ses_fill_writeset(fd_set *fdset, int *maxfdnum)
Drain the ses_msg outreadyQ and set the specified fdset Used by agt_ncxserver write_fd_set.
Definition: agt_ses.c:1819
status_t agt_ses_get_inSessions(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the inSessions counter
Definition: agt_ses.c:1858
ses_cb_t * agt_ses_get_session_for_id(ses_id_t sid)
get the session for the supplied sid
Definition: agt_ses.c:2252
status_t agt_ses_get_inRpcs(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the inRpcs counter
Definition: agt_ses.c:1918
boolean agt_ses_ssh_port_allowed(uint16 port)
Check if the port number used for SSH connect is okay.
Definition: agt_ses.c:1768
void agt_ses_free_snmp_session(ses_cb_t *scb)
Free a dummy snmp session control block.
Definition: agt_ses.c:782
ses_cb_t * agt_ses_new_session_tls(ses_transport_t transport, int fd, const char *client_addr)
Create a real agent session control block for TLS.
Definition: agt_ses.c:836
void agt_ses_check_timeouts(ses_id_t sid)
Check if any sessions need to be dropped because they have been idle too long.
Definition: agt_ses.c:1631
void agt_ses_cleanup(void)
Cleanup the session manager module data structures.
Definition: agt_ses.c:499
void agt_ses_set_hello_timeout(uint32 val)
Set the hello-timeout parameter.
Definition: agt_ses.c:2482
NETCONF Session Common definitions module.
Contains NCX constants.
void agt_ses_go_active(void)
Activate MGMT sessions because YP-HA mode is active.
Definition: agt_ses.c:2302
uint32 ses_id_t
Session ID.
Definition: ses.h:306
ses_term_reason_t
Session Termination reason.
Definition: ses.h:387
boolean agt_ses_request_close(ses_cb_t *scb, ses_id_t killedby, ses_term_reason_t termreason)
Start the close of the specified session.
Definition: agt_ses.c:1056
void agt_ses_set_idle_timeout(uint32 val)
Set the idle-timeout parameter.
Definition: agt_ses.c:2501
Value Node Basic Support.
boolean agt_ses_process_first_ready(boolean ycontrol)
Check the readyQ and process the first message, if any.
Definition: agt_ses.c:1468
status_t agt_ses_init(void)
INIT 1: Initialize the session manager module data structures.
Definition: agt_ses.c:465
void agt_ses_set_max_cli_sessions(uint16 val)
Set the max-cli-sessions parameter.
Definition: agt_ses.c:2463
void agt_ses_thread_kill_session(ses_cb_t *scb, ses_id_t killedby, ses_term_reason_t termreason)
Kill the specified session; called from session thread.
Definition: agt_ses.c:1118
status_t agt_ses_set_dummy_session_acm(ses_cb_t *dummy_session, ses_id_t use_sid)
Set the session ID and username of the user that will be responsible for the rollback if needed...
Definition: agt_ses.c:576
ses_cb_t * agt_ses_new_session(ses_transport_t transport, int fd)
Create a real server session control block.
Definition: agt_ses.c:811
void agt_ses_free_session2(ses_cb_t *scb, boolean clear_locks)
Free a real session control block but with optional unlocking.
Definition: agt_ses.c:889
uint32 agt_ses_mgmt_session_count(void)
Get number of management sessions open.
Definition: agt_ses.c:2272
boolean agt_ses_max_cli_sessions(void)
Check if max-cli-sessions parameter has been reached.
Definition: agt_ses.c:2399
ses_cb_t * agt_ses_new_snmp_session(void)
Create a dummy SNMP session control block.
Definition: agt_ses.c:737
ses_transport_t
NETCONF Transport Types.
Definition: ses.h:330
status_t agt_ses_get_inBadRpcs(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the inBadRpcs counter
Definition: agt_ses.c:1948
void agt_ses_remove_subsys(ses_id_t sid)
Remove a subsystem session for an HA Standby.
Definition: agt_ses.c:2363
status_t agt_ses_get_session_inRpcs(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the session/inRpcs counter
Definition: agt_ses.c:2068
one value to match one type
Definition: val.h:870
Session Control Block.
Definition: ses.h:542
status_t
global error return code
Definition: status_enum.h:186
status_t agt_ses_get_droppedSessions(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the droppedSessions counter
Definition: agt_ses.c:2038
void agt_ses_free_session(ses_cb_t *scb)
Free a real session control block.
Definition: agt_ses.c:870
ses_cb_t * agt_ses_new_coap_session(void)
Create a dummy CoAP session control block.
Definition: agt_ses.c:666
void agt_ses_kill_session(ses_cb_t *scb, ses_id_t killedby, ses_term_reason_t termreason)
Kill the specified session.
Definition: agt_ses.c:1213
status_t agt_ses_get_session_inBadRpcs(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the inBadRpcs counter
Definition: agt_ses.c:2108
Global error messages for status code enumerations.
void agt_ses_invalidate_session_acm_caches(void)
Invalidate all session ACM caches so they will be rebuilt.
Definition: agt_ses.c:2224
status_t agt_ses_get_outRpcErrors(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the outRpcErrors counter
Definition: agt_ses.c:1978
void agt_ses_set_max_sessions(uint16 val)
Set the max-sessions parameter.
Definition: agt_ses.c:2444
getcb_mode_t
get callback retrieval types; only get2 supports getnext
Definition: getcb.h:246
void agt_ses_free_coap_session(ses_cb_t *scb)
Free a dummy CoAP session control block.
Definition: agt_ses.c:711
boolean agt_ses_process_first_ready_by_sid(ses_id_t sid)
Check the readyQ and process the first message matching session, if any.
Definition: agt_ses.c:1440
void agt_ses_go_standby(void)
Deactivate MGMT sessions because YP-HA mode is standby.
Definition: agt_ses.c:2317
status_t agt_ses_get_outNotifications(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the outNotifications counter
Definition: agt_ses.c:2008
status_t agt_ses_get_inBadHellos(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the inBadHellos counter
Definition: agt_ses.c:1888
ses_cb_t * agt_ses_new_dummy_session(void)
Create a dummy session control block.
Definition: agt_ses.c:535
status_t agt_ses_get_session_outNotifications(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the outNotifications counter
Definition: agt_ses.c:2188
status_t agt_ses_get_session_outRpcErrors(ses_cb_t *scb, getcb_mode_t cbmode, const val_value_t *virval, val_value_t *dstval)
<get> operation handler for the outRpcErrors counter
Definition: agt_ses.c:2148
boolean agt_ses_session_id_valid(ses_id_t sid)
Check if a session-id is for an active session.
Definition: agt_ses.c:1031
GET1 and GET2 Callback Support.