summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-09-16 17:03:46 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-09-16 17:03:46 +0000
commitaebd77f98d9286d9f2b0de098a0102405b00be40 (patch)
treeb86e33798c458b444386d52e07a54eafebf7e058
parent3524ffac447702e2a0f1766ccdd6128fe0fc8f7e (diff)
downloadgnutls-aebd77f98d9286d9f2b0de098a0102405b00be40.tar.gz
replaced gnutls_handshake_get_direction() with gnutls_record_get_direction().
-rw-r--r--lib/gnutls.h.in.in2
-rw-r--r--lib/gnutls_buffers.c8
-rw-r--r--lib/gnutls_handshake.c32
-rw-r--r--lib/gnutls_int.h4
-rw-r--r--lib/gnutls_int_compat.c5
-rw-r--r--lib/gnutls_state.c17
6 files changed, 32 insertions, 36 deletions
diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in
index 28420151c7..7d2bf526ed 100644
--- a/lib/gnutls.h.in.in
+++ b/lib/gnutls.h.in.in
@@ -133,7 +133,7 @@ int gnutls_bye( gnutls_session session, gnutls_close_request how);
int gnutls_handshake( gnutls_session session);
int gnutls_rehandshake( gnutls_session session);
-int gnutls_handshake_get_direction(gnutls_session session);
+int gnutls_record_get_direction(gnutls_session session);
gnutls_alert_description gnutls_alert_get( gnutls_session session);
int gnutls_alert_send( gnutls_session, gnutls_alert_level, gnutls_alert_description);
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c
index 3faa2e6ce0..a6d7df5802 100644
--- a/lib/gnutls_buffers.c
+++ b/lib/gnutls_buffers.c
@@ -205,6 +205,8 @@ static ssize_t _gnutls_read( gnutls_session session, void *iptr, size_t sizeOfPt
#ifdef READ_DEBUG
int j,x, sum=0;
#endif
+ session->internals.direction = 0;
+
gnutls_transport_ptr fd = session->internals.transport_recv_ptr;
left = sizeOfPtr;
@@ -523,7 +525,11 @@ ssize_t _gnutls_io_write_buffered( gnutls_session session, const void *iptr, siz
const opaque * ptr;
int ret;
gnutls_transport_ptr fd = session->internals.transport_send_ptr;
-
+
+ /* to know where the procedure was interrupted.
+ */
+ session->internals.direction = 1;
+
ptr = iptr;
/* In case the previous write was interrupted, check if the
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index 2bf54d9659..77033eebce 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -719,10 +719,6 @@ int _gnutls_send_handshake(gnutls_session session, void *i_data,
uint32 datasize;
int pos = 0;
- /* to know where the procedure was interrupted.
- */
- session->internals.handshake_direction = 1; /* write */
-
if (i_data == NULL && i_datasize == 0) {
/* we are resuming a previously interrupted
* send.
@@ -966,10 +962,6 @@ int _gnutls_recv_handshake(gnutls_session session, uint8 ** data,
opaque *dataptr = NULL;
HandshakeType recv_type;
- /* to know where the procedure was interrupted.
- */
- session->internals.handshake_direction = 0; /* read */
-
ret = _gnutls_recv_handshake_header(session, type, &recv_type);
if (ret < 0) {
if (ret == GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET
@@ -1769,22 +1761,6 @@ int gnutls_rehandshake(gnutls_session session)
return 0;
}
-/**
- * gnutls_handshake_get_direction - This function will return the session of the handshake protocol
- * @session: is a a &gnutls_session 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_get_direction(gnutls_session session) {
- return session->internals.handshake_direction;
-}
-
static int _gnutls_abort_handshake( gnutls_session session, int ret) {
if ( ((ret==GNUTLS_E_WARNING_ALERT_RECEIVED) &&
( gnutls_alert_get(session) == GNUTLS_A_NO_RENEGOTIATION))
@@ -2027,10 +2003,6 @@ static int _gnutls_send_handshake_final(gnutls_session session, int init)
{
int ret = 0;
- /* to know where the procedure was interrupted.
- */
- session->internals.handshake_direction = 1; /* write */
-
/* Send the CHANGE CIPHER SPEC PACKET */
switch (STATE) {
@@ -2087,10 +2059,6 @@ static int _gnutls_recv_handshake_final(gnutls_session session, int init)
int ret = 0;
uint8 ch;
- /* to know where the procedure was interrupted.
- */
- session->internals.handshake_direction = 0; /* recv */
-
switch (STATE) {
case STATE0:
case STATE30:
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index cc97b8c132..ace4ce16ef 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -552,10 +552,10 @@ typedef struct {
* which have 0xFF status.
*/
- /* Holds 0 if the handshake procedure was interrupted while
+ /* Holds 0 if the last called function was interrupted while
* receiving, and non zero otherwise.
*/
- int handshake_direction;
+ int direction;
/* If you add anything here, check _gnutls_handshake_internal_state_clear().
*/
diff --git a/lib/gnutls_int_compat.c b/lib/gnutls_int_compat.c
index 5f338bf1fd..c81cbb98d1 100644
--- a/lib/gnutls_int_compat.c
+++ b/lib/gnutls_int_compat.c
@@ -107,6 +107,11 @@ int gnutls_certificate_allocate_cred( gnutls_certificate_credentials *sc)
return gnutls_certificate_allocate_credentials( sc);
}
+#undef gnutls_handshake_get_direction
+int gnutls_handshake_get_direction(gnutls_session session) {
+ return gnutls_record_get_direction( session);
+}
+
/* nothing here */
#endif /* GNUTLS_BACKWARDS_COMPATIBLE */
diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c
index afa9b56691..cf473fdb63 100644
--- a/lib/gnutls_state.c
+++ b/lib/gnutls_state.c
@@ -740,3 +740,20 @@ void gnutls_session_set_ptr(gnutls_session session, void* ptr)
{
session->internals.user_ptr = ptr;
}
+
+
+/**
+ * gnutls_record_get_direction - This function will return the direction of the last interrupted function call
+ * @session: is a a &gnutls_session structure.
+ *
+ * This function provides information about the internals of the record
+ * protocol and is only useful if any gnutls function call was
+ * interrupted for some reason.
+ *
+ * Returns 0 if the function was interrupted while receiving data, and
+ * 1 otherwise.
+ *
+ **/
+int gnutls_record_get_direction(gnutls_session session) {
+ return session->internals.direction;
+}