From 602f3b495b37f761d3172c55ed172e05fe215549 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:36:54 +0100 Subject: [PATCH] Add session connect to libipm sesexec interfaces --- libipm/eicp.h | 1 - libipm/ercp.c | 29 ++++++++++++++++++++++++++--- libipm/ercp.h | 45 ++++++++++++++++++++++++++++++++++++--------- 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/libipm/eicp.h b/libipm/eicp.h index 63ca37dd..392a6907 100644 --- a/libipm/eicp.h +++ b/libipm/eicp.h @@ -362,5 +362,4 @@ eicp_get_create_session_response(struct trans *trans, enum scp_screate_status *status, struct guid *guid); - #endif /* EICP_H */ diff --git a/libipm/ercp.c b/libipm/ercp.c index 5fa82827..6602c570 100644 --- a/libipm/ercp.c +++ b/libipm/ercp.c @@ -41,7 +41,8 @@ msgno_to_str(unsigned short n) (n == E_ERCP_SESSION_ANNOUNCE_EVENT) ? "ERCP_SESSION_ANNOUNCE_EVENT" : (n == E_ERCP_SESSION_FINISHED_EVENT) ? "ERCP_SESSION_FINISHED_EVENT" : - (n == E_ERCP_SESSION_RECONNECT_EVENT) ? "ERCP_SESSION_RECONNECT_EVENT" : + (n == E_ERCP_CONNECT_SESSION_REQUEST) ? "ERCP_CONNECT_SESSION_REQUEST" : + NULL; } @@ -234,8 +235,30 @@ ercp_send_session_finished_event(struct trans *trans) /*****************************************************************************/ int -ercp_send_session_reconnect_event(struct trans *trans) +ercp_send_connect_session_request(struct trans *trans, + int scp_fd, + unsigned int scp_flags) { return libipm_msg_out_simple_send( - trans, (int)E_ERCP_SESSION_RECONNECT_EVENT, NULL); + trans, (int)E_ERCP_CONNECT_SESSION_REQUEST, + "hu", scp_fd, scp_flags); +} + +/*****************************************************************************/ + +int +ercp_get_connect_session_request(struct trans *trans, + int *scp_fd, + unsigned int *scp_flags) +{ + /* Intermediate values */ + uint32_t i_flags; + + int rv = libipm_msg_in_parse(trans, "hu", scp_fd, &i_flags); + if (rv == 0) + { + *scp_flags = i_flags; + } + + return rv; } diff --git a/libipm/ercp.h b/libipm/ercp.h index 97417ebc..0d8e6a08 100644 --- a/libipm/ercp.h +++ b/libipm/ercp.h @@ -47,7 +47,8 @@ enum ercp_msg_code E_ERCP_SESSION_ANNOUNCE_EVENT, // sesexec -> sesman E_ERCP_SESSION_FINISHED_EVENT, // sesexec -> sesman - E_ERCP_SESSION_RECONNECT_EVENT // sesman -> sesexec + E_ERCP_CONNECT_SESSION_REQUEST // sesman -> sesexec + // No E_EICP_CONNECT_SESSION_RESPONSE - response sent over SCP }; /* Common facilities */ @@ -156,7 +157,7 @@ ercp_msg_in_reset(struct trans *trans); * * This event contains all the information known about a session * - * @param trans EICP transport + * @param trans ERCP transport * @param display Display used by session * @param uid UID of user logged in to session * @param type Session type @@ -186,7 +187,7 @@ ercp_send_session_announce_event(struct trans *trans, * * This event contains all the information known about a session * - * @param trans EICP transport + * @param trans ERCP transport * @param[out] display Display used by session. * @param[out] uid UID of user logged in to session * @param[out] type Session type @@ -219,25 +220,51 @@ ercp_get_session_announce_event(struct trans *trans, * This event simply states the attached session has finished and can be * removed from any data structures held by sesman * - * @param trans EICP transport + * @param trans ERCP transport * @return != 0 for error */ int ercp_send_session_finished_event(struct trans *trans); /** - * Send an E_ERCP_SESSION_RECONNECT_EVENT + * Send an E_ERCP_CONNECT_SESSION_REQUEST * * Direction : sesman -> sesexec * - * This event tells sesexec that a reconnection is about to occur, and - * sesexec should run the reconnect script. + * This request tells sesexec to handle a session connection * - * @param trans EICP transport + * A response is sent directly to the SCP client, rather than back + * to sesman + * + * @param trans EiCP transport + * @param scp_fd SCP file descriptor for a response + * @param scp_flags Flags from scp_send_connect_session_request() * @return != 0 for error */ int -ercp_send_session_reconnect_event(struct trans *trans); +ercp_send_connect_session_request(struct trans *trans, + int scp_fd, + unsigned int scp_flags); + +/** + * Get an E_ERCP_CONNECT_SESSION_REQUEST + * + * Direction : sesman -> sesexec + * + * This request tells sesexec to handle a session connection + * + * A response is sent directly to the SCP client, rather than back + * to sesman + * + * @param trans ERCP transport + * @param[out] scp_fd SCP file descriptor for a response + * @param[out] scp_flags Flags from scp_send_connect_session_request() + * @return != 0 for error + */ +int +ercp_get_connect_session_request(struct trans *trans, + int *scp_fd, + unsigned int *scp_flags); #endif /* ERCP_H */