diff --git a/libipm/libipm.h b/libipm/libipm.h index bd491107..f74d967d 100644 --- a/libipm/libipm.h +++ b/libipm/libipm.h @@ -219,6 +219,12 @@ libipm_msg_out_erase(struct trans *trans); * @param trans libipm transport * @param[out] available != 0 if a complete message is available * @return != 0 for error + * + * When 'available' becomes set, the buffer is guaranteed to + * be in a parseable state. + * + * The results of calling this function after starting to parse a message + * and before calling libipm_msg_in_reset() are undefined. */ enum libipm_status libipm_msg_in_check_available(struct trans *trans, int *available); @@ -233,6 +239,9 @@ libipm_msg_in_check_available(struct trans *trans, int *available); * While the call is active, data-in callbacks for the transport are * disabled. * + * The results of calling this function after starting to parse a message + * and before calling libipm_msg_in_reset() are undefined. + * * Only use this call if you have nothing to do until a message * arrives on the transport. If you have other transports to service, use * libipm_msg_in_check_available() @@ -241,7 +250,7 @@ enum libipm_status libipm_msg_in_wait_available(struct trans *trans); /** - * Start parsing a message + * Get the message number for a message in the input buffer. * * @param trans libipm transport * @return message number in the buffer @@ -250,12 +259,9 @@ libipm_msg_in_wait_available(struct trans *trans); * libipm_msg_in_reset() and before a successful call to * libipm_msg_in_check_available() (or libipm_msg_wait_available()) * are undefined. - * - * Calling this function resets the message parsing pointer to the start - * of the message */ unsigned short -libipm_msg_in_start(struct trans *trans); +libipm_msg_in_get_msgno(const struct trans *trans); /** * Returns a letter corresponding to the next available type in the diff --git a/libipm/libipm_recv.c b/libipm/libipm_recv.c index 3d09d21a..4f907a03 100644 --- a/libipm/libipm_recv.c +++ b/libipm/libipm_recv.c @@ -187,11 +187,10 @@ libipm_msg_in_wait_available(struct trans *trans) /*****************************************************************************/ unsigned short -libipm_msg_in_start(struct trans *trans) +libipm_msg_in_get_msgno(const struct trans *trans) { struct libipm_priv *priv = (struct libipm_priv *)trans->extra_data; - trans->in_s->p = trans->in_s->data + HEADER_SIZE; return (priv == NULL) ? 0 : priv->in_msgno; } diff --git a/libipm/scp.c b/libipm/scp.c index 5cca6edc..149eccf9 100644 --- a/libipm/scp.c +++ b/libipm/scp.c @@ -212,18 +212,18 @@ scp_msg_in_wait_available(struct trans *trans) /*****************************************************************************/ -void -scp_msg_in_reset(struct trans *trans) +enum scp_msg_code +scp_msg_in_get_msgno(const struct trans *trans) { - libipm_msg_in_reset(trans); + return (enum scp_msg_code)libipm_msg_in_get_msgno(trans); } /*****************************************************************************/ -enum scp_msg_code -scp_msg_in_start(struct trans *trans) +void +scp_msg_in_reset(struct trans *trans) { - return (enum scp_msg_code)libipm_msg_in_start(trans); + libipm_msg_in_reset(trans); } /*****************************************************************************/ diff --git a/libipm/scp.h b/libipm/scp.h index 95e8168d..edb51536 100644 --- a/libipm/scp.h +++ b/libipm/scp.h @@ -164,19 +164,16 @@ scp_msg_in_wait_available(struct trans *trans); /** - * Start parsing an SCP message + * Gets the SCP message number of an incoming message * * @param trans SCP transport * @return message in the buffer * * The results of calling this routine before scp_msg_in_check_available() * states a message is available are undefined. - * - * Calling this function rests the message parsing pointer to the start - * of the message */ enum scp_msg_code -scp_msg_in_start(struct trans *trans); +scp_msg_in_get_msgno(const struct trans *trans); /** * Resets an SCP message buffer ready to receive the next message diff --git a/sesman/scp_process.c b/sesman/scp_process.c index 73363671..75dd2ee1 100644 --- a/sesman/scp_process.c +++ b/sesman/scp_process.c @@ -536,7 +536,7 @@ scp_process(struct sesman_con *sc) enum scp_msg_code msgno; int rv = 0; - switch ((msgno = scp_msg_in_start(sc->t))) + switch ((msgno = scp_msg_in_get_msgno(sc->t))) { case E_SCP_SET_PEERNAME_REQUEST: rv = process_set_peername_request(sc); diff --git a/sesman/tools/tools_common.c b/sesman/tools/tools_common.c index 442a79a9..3dd82c4a 100644 --- a/sesman/tools/tools_common.c +++ b/sesman/tools/tools_common.c @@ -50,7 +50,7 @@ wait_for_sesman_reply(struct trans *t, enum scp_msg_code wait_msgno) } else { - enum scp_msg_code reply_msgno = scp_msg_in_start(t); + enum scp_msg_code reply_msgno = scp_msg_in_get_msgno(t); available = 1; if (reply_msgno != wait_msgno) diff --git a/tests/libipm/test_libipm_recv_calls.c b/tests/libipm/test_libipm_recv_calls.c index 67ba5e0f..dc7f135c 100644 --- a/tests/libipm/test_libipm_recv_calls.c +++ b/tests/libipm/test_libipm_recv_calls.c @@ -116,7 +116,7 @@ check_for_incoming_message(unsigned short expected_msgno) status = libipm_msg_in_wait_available(g_t_in); ck_assert_int_eq(status, E_LI_SUCCESS); - msgno = libipm_msg_in_start(g_t_in); + msgno = libipm_msg_in_get_msgno(g_t_in); ck_assert_int_eq(msgno, expected_msgno); } diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 19093e19..c6dee2a8 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -2145,7 +2145,7 @@ xrdp_mm_scp_data_in(struct trans *trans) struct xrdp_mm *self = (struct xrdp_mm *)(trans->callback_data); enum scp_msg_code msgno; - switch ((msgno = scp_msg_in_start(trans))) + switch ((msgno = scp_msg_in_get_msgno(trans))) { case E_SCP_LOGIN_RESPONSE: rv = xrdp_mm_process_login_response(self);