diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-08-15 21:49:59 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-08-15 21:49:59 +0000 |
commit | 98e0f921646894db0bae91574ebdd5cbadcfdaba (patch) | |
tree | 3d6df7010d1ce22518feabdd88cccfb1f0a00fcc | |
parent | 1e7d930a72b85f8f3428dfad7c2066a6d3b0511a (diff) | |
download | gnutls-98e0f921646894db0bae91574ebdd5cbadcfdaba.tar.gz |
Added new function gnutls_handshake_check_direction(), which returns the state where the handshake function was interrupted.
-rw-r--r-- | lib/gnutls.h.in.in | 1 | ||||
-rw-r--r-- | lib/gnutls_handshake.c | 24 | ||||
-rw-r--r-- | lib/gnutls_int.h | 6 |
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in index a1d1119056..f2473bfaf1 100644 --- a/lib/gnutls.h.in.in +++ b/lib/gnutls.h.in.in @@ -120,6 +120,7 @@ int gnutls_bye( GNUTLS_STATE state, GNUTLS_CloseRequest how); int gnutls_handshake( GNUTLS_STATE state); int gnutls_rehandshake( GNUTLS_STATE state); +int gnutls_handshake_check_direction(GNUTLS_STATE state); GNUTLS_AlertDescription gnutls_alert_get( GNUTLS_STATE state); int gnutls_alert_send( GNUTLS_STATE, GNUTLS_AlertLevel, GNUTLS_AlertDescription); diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index da9aca5581..b9acc18c7c 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -717,6 +717,10 @@ int _gnutls_send_handshake(GNUTLS_STATE state, void *i_data, uint32 datasize; int pos = 0; + /* to know where the procedure was interrupted. + */ + state->gnutls_internals.handshake_direction = 1; /* write */ + if (i_data == NULL && i_datasize == 0) { /* we are resuming a previously interrupted * send. @@ -960,6 +964,10 @@ int _gnutls_recv_handshake(GNUTLS_STATE state, uint8 ** data, opaque *dataptr = NULL; HandshakeType recv_type; + /* to know where the procedure was interrupted. + */ + state->gnutls_internals.handshake_direction = 0; /* read */ + ret = _gnutls_recv_handshake_header(state, type, &recv_type); if (ret < 0) { if (ret == GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET @@ -1767,6 +1775,22 @@ int gnutls_rehandshake(GNUTLS_STATE state) return 0; } +/** + * gnutls_handshake_check_direction - This function will return the state of the handshake protocol + * @state: is a a &GNUTLS_STATE structure. + * + * This function provides information about the handshake procedure, and + * is only useful if the gnutls_handshake() call was interrupted for some + * reason. + * + * Returns 0 if the function was interrupted while receiving data, and + * 1 otherwise. + * + **/ +int gnutls_handshake_check_direction(GNUTLS_STATE state) { + return state->gnutls_internals.handshake_direction; +} + static int _gnutls_abort_handshake( GNUTLS_STATE state, int ret) { if ( ((ret==GNUTLS_E_WARNING_ALERT_RECEIVED) && ( gnutls_alert_get(state) == GNUTLS_A_NO_RENEGOTIATION)) diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index e6e44144b5..e4d0546897 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -569,6 +569,12 @@ typedef struct { * enable cipher suites * which have 0xFF status. */ + + /* Holds 0 if the handshake procedure was interrupted while + * receiving, and non zero otherwise. + */ + int handshake_direction; + /* If you add anything here, check _gnutls_handshake_internal_state_clear(). */ } GNUTLS_INTERNALS; |