summaryrefslogtreecommitdiff
path: root/lib/smb.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-12-13 12:12:45 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-12-13 12:16:36 +0000
commit2ecce667a6bc193ad04a9057412e126681462012 (patch)
tree1cded7167abcf0a131db56d62d0040756a9373e1 /lib/smb.c
parent783b5c3b119cc342e4dda2ddd13e39119f8c2bdf (diff)
downloadcurl-2ecce667a6bc193ad04a9057412e126681462012.tar.gz
smb: Added state change functions to assist with debugging
For debugging purposes, and as per other protocols within curl, added state change functions rather than changing the states directly.
Diffstat (limited to 'lib/smb.c')
-rw-r--r--lib/smb.c57
1 files changed, 52 insertions, 5 deletions
diff --git a/lib/smb.c b/lib/smb.c
index 5e329c154..3ce6e3dd0 100644
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -177,6 +177,53 @@ struct smb_request {
CURLcode result;
};
+static void conn_state(struct connectdata *conn, enum smb_conn_state newstate)
+{
+ struct smb_conn *smb = &conn->proto.smbc;
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ /* For debug purposes */
+ static const char * const names[] = {
+ "SMB_NOT_CONNECTED",
+ "SMB_CONNECTING",
+ "SMB_NEGOTIATE",
+ "SMB_SETUP",
+ "SMB_CONNECTED",
+ /* LAST */
+ };
+
+ if(smb->state != newstate)
+ infof(conn->data, "SMB conn %p state change from %s to %s\n",
+ (void *)smb, names[smb->state], names[newstate]);
+#endif
+
+ smb->state = newstate;
+}
+
+static void request_state(struct connectdata *conn, enum smb_req_state newstate)
+{
+ struct smb_request *req = conn->data->req.protop;
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ /* For debug purposes */
+ static const char * const names[] = {
+ "SMB_REQUESTING",
+ "SMB_TREE_CONNECT",
+ "SMB_OPEN",
+ "SMB_DOWNLOAD",
+ "SMB_UPLOAD",
+ "SMB_CLOSE",
+ "SMB_TREE_DISCONNECT",
+ "SMB_DONE",
+ /* LAST */
+ };
+
+ if(req->state != newstate)
+ infof(conn->data, "SMB request %p state change from %s to %s\n",
+ (void *)req, names[req->state], names[newstate]);
+#endif
+
+ req->state = newstate;
+}
+
static CURLcode smb_setup(struct connectdata *conn)
{
struct smb_request *req;
@@ -592,7 +639,7 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
return result;
}
- smbc->state = SMB_NEGOTIATE;
+ conn_state(conn, SMB_NEGOTIATE);
}
/* Send the previous message and check for a response */
@@ -621,7 +668,7 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
connclose(conn, "SMB: failed to send setup message");
return result;
}
- smbc->state = SMB_SETUP;
+ conn_state(conn, SMB_SETUP);
break;
case SMB_SETUP:
@@ -630,7 +677,7 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
return CURLE_LOGIN_DENIED;
}
smbc->uid = smb_swap16(h->uid);
- smbc->state = SMB_CONNECTED;
+ conn_state(conn, SMB_CONNECTED);
*done = true;
break;
@@ -662,7 +709,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
return result;
}
- req->state = SMB_TREE_CONNECT;
+ request_state(conn, SMB_TREE_CONNECT);
}
/* Send the previous message and check for a response */
@@ -801,7 +848,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
return result;
}
- req->state = next_state;
+ request_state(conn, next_state);
return CURLE_OK;
}