Skip to content

Commit dc96bb9

Browse files
committed
session BUGFIX set callhome session flag
Fixes #414
1 parent a5f2b65 commit dc96bb9

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

src/session.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,21 @@ nc_session_get_data(const struct nc_session *session)
582582
return session->data;
583583
}
584584

585+
API int
586+
nc_session_is_callhome(const struct nc_session *session)
587+
{
588+
if (!session) {
589+
ERRARG("session");
590+
return 0;
591+
}
592+
593+
if (session->flags & NC_SESSION_CALLHOME) {
594+
return 1;
595+
}
596+
597+
return 0;
598+
}
599+
585600
NC_MSG_TYPE
586601
nc_send_msg_io(struct nc_session *session, int io_timeout, struct lyd_node *op)
587602
{

src/session.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/**
22
* @file session.h
33
* @author Radek Krejci <[email protected]>
4+
* @author Michal Vasko <[email protected]>
45
* @brief libnetconf2 session manipulation
56
*
67
* @copyright
7-
* Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
8+
* Copyright (c) 2015 - 2023 CESNET, z.s.p.o.
89
*
910
* This source code is licensed under BSD 3-Clause License (the "License").
1011
* You may not use this file except in compliance with the License.
@@ -216,6 +217,14 @@ void nc_session_set_data(struct nc_session *session, void *data);
216217
*/
217218
void *nc_session_get_data(const struct nc_session *session);
218219

220+
/**
221+
* @brief Learn whether a session was created using Call Home or not.
222+
*
223+
* @param[in] session Session to get the information from.
224+
* @return 0 if a standard session, non-zero if a Call Home session.
225+
*/
226+
int nc_session_is_callhome(const struct nc_session *session);
227+
219228
/**
220229
* @brief Free the NETCONF session object.
221230
*

src/session_server.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,7 +3344,7 @@ nc_connect_ch_endpt(struct nc_ch_endpt *endpt, nc_server_ch_session_acquire_ctx_
33443344
}
33453345
(*session)->status = NC_STATUS_STARTING;
33463346
(*session)->ctx = (struct ly_ctx *)ctx;
3347-
(*session)->flags = NC_SESSION_SHAREDCTX;
3347+
(*session)->flags = NC_SESSION_SHAREDCTX | NC_SESSION_CALLHOME;
33483348
(*session)->host = ip_host;
33493349
(*session)->port = endpt->port;
33503350

@@ -3812,18 +3812,3 @@ nc_session_get_notif_status(const struct nc_session *session)
38123812

38133813
return ntf_status;
38143814
}
3815-
3816-
API int
3817-
nc_session_is_callhome(const struct nc_session *session)
3818-
{
3819-
if (!session || (session->side != NC_SERVER)) {
3820-
ERRARG("session");
3821-
return 0;
3822-
}
3823-
3824-
if (session->flags & NC_SESSION_CALLHOME) {
3825-
return 1;
3826-
}
3827-
3828-
return 0;
3829-
}

src/session_server.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -962,15 +962,6 @@ void nc_session_dec_notif_status(struct nc_session *session);
962962
*/
963963
int nc_session_get_notif_status(const struct nc_session *session);
964964

965-
/**
966-
* @brief Learn whether a session was created using Call Home or not.
967-
* Works only for server sessions.
968-
*
969-
* @param[in] session Session to get the information from.
970-
* @return 0 if a standard session, non-zero if a Call Home session.
971-
*/
972-
int nc_session_is_callhome(const struct nc_session *session);
973-
974965
/** @} Server Session */
975966

976967
#ifdef __cplusplus

0 commit comments

Comments
 (0)