diff -x .git -Nur curl-7.38.0-orig/configure.ac curl-7.38.0/configure.ac
--- curl-7.38.0-orig/configure.ac	2014-09-04 07:21:53.000000000 -0400
+++ curl-7.38.0/configure.ac	2014-09-29 16:56:17.233329503 -0400
@@ -573,6 +573,21 @@
        AC_MSG_RESULT(yes)
 )
 
+AC_MSG_CHECKING([whether to support smb])
+AC_ARG_ENABLE(smb,
+AC_HELP_STRING([--enable-smb],[Enable SMB/CIFS support])
+AC_HELP_STRING([--disable-smb],[Disable SMB/CIFS support]),
+[ case "$enableval" in
+  no)
+       AC_MSG_RESULT(no)
+       AC_DEFINE(CURL_DISABLE_SMB, 1, [to disable SMB/CIFS])
+       AC_SUBST(CURL_DISABLE_SMB, [1])
+       ;;
+  *)   AC_MSG_RESULT(yes)
+       ;;
+  esac ],
+       AC_MSG_RESULT(yes)
+)
 
 AC_MSG_CHECKING([whether to support smtp])
 AC_ARG_ENABLE(smtp,
@@ -3441,6 +3456,12 @@
     SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAPS"
   fi
 fi
+if test "x$CURL_DISABLE_SMB" != "x1"; then
+  SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMB"
+  if test "x$SSL_ENABLED" = "x1"; then
+    SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMBS"
+  fi
+fi
 if test "x$CURL_DISABLE_SMTP" != "x1"; then
   SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTP"
   if test "x$SSL_ENABLED" = "x1"; then
diff -x .git -Nur curl-7.38.0-orig/include/curl/curl.h curl-7.38.0/include/curl/curl.h
--- curl-7.38.0-orig/include/curl/curl.h	2014-08-26 17:37:44.000000000 -0400
+++ curl-7.38.0/include/curl/curl.h	2014-09-29 17:09:00.884245985 -0400
@@ -803,6 +803,8 @@
 #define CURLPROTO_RTMPS  (1<<23)
 #define CURLPROTO_RTMPTS (1<<24)
 #define CURLPROTO_GOPHER (1<<25)
+#define CURLPROTO_SMB    (1<<26)
+#define CURLPROTO_SMBS   (1<<27)
 #define CURLPROTO_ALL    (~0) /* enable everything */
 
 /* long may be 32 or 64 bits, but we should never depend on anything else
diff -x .git -Nur curl-7.38.0-orig/lib/curl_ntlm_core.c curl-7.38.0/lib/curl_ntlm_core.c
--- curl-7.38.0-orig/lib/curl_ntlm_core.c	2014-08-25 17:45:11.000000000 -0400
+++ curl-7.38.0/lib/curl_ntlm_core.c	2014-09-29 17:02:19.803256007 -0400
@@ -22,7 +22,7 @@
 
 #include "curl_setup.h"
 
-#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)
+#if (defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)) || !defined(CURL_DISABLE_SMB)
 
 /*
  * NTLM details:
@@ -648,4 +648,4 @@
 
 #endif /* USE_NTRESPONSES */
 
-#endif /* USE_NTLM && !USE_WINDOWS_SSPI */
+#endif /* (USE_NTLM && !USE_WINDOWS_SSPI) || !CURL_DISABLE_SMB */
diff -x .git -Nur curl-7.38.0-orig/lib/curl_ntlm_core.h curl-7.38.0/lib/curl_ntlm_core.h
--- curl-7.38.0-orig/lib/curl_ntlm_core.h	2014-06-11 13:52:29.000000000 -0400
+++ curl-7.38.0/lib/curl_ntlm_core.h	2014-09-29 17:02:22.499209789 -0400
@@ -24,7 +24,7 @@
 
 #include "curl_setup.h"
 
-#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)
+#if (defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)) || !defined(CURL_DISABLE_SMB)
 
 #ifdef USE_SSLEAY
 #  if !defined(OPENSSL_VERSION_NUMBER) && \
@@ -84,6 +84,6 @@
 
 #endif
 
-#endif /* USE_NTLM && !USE_WINDOWS_SSPI */
+#endif /* (USE_NTLM && !USE_WINDOWS_SSPI) || !CURL_DISABLE_SMB */
 
 #endif /* HEADER_CURL_NTLM_CORE_H */
diff -x .git -Nur curl-7.38.0-orig/lib/Makefile.inc curl-7.38.0/lib/Makefile.inc
--- curl-7.38.0-orig/lib/Makefile.inc	2014-08-25 17:45:11.000000000 -0400
+++ curl-7.38.0/lib/Makefile.inc	2014-09-29 17:00:19.209308722 -0400
@@ -45,7 +45,7 @@
   asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c		\
   curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c	\
   hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c	\
-  http2.c curl_sasl_sspi.c
+  http2.c curl_sasl_sspi.c smb.c
 
 LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h	\
   formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h		\
@@ -63,7 +63,7 @@
   curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h		\
   curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h bundles.h	\
   conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h	\
-  dotdot.h x509asn1.h http2.h sigpipe.h
+  dotdot.h x509asn1.h http2.h sigpipe.h smb.h smb_data.h
 
 LIB_RCFILES = libcurl.rc
 
diff -x .git -Nur curl-7.38.0-orig/lib/smb.c curl-7.38.0/lib/smb.c
--- curl-7.38.0-orig/lib/smb.c	1969-12-31 19:00:00.000000000 -0500
+++ curl-7.38.0/lib/smb.c	2014-09-29 17:00:42.748910374 -0400
@@ -0,0 +1,631 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
+ * Copyright (C) 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include "smb.h"
+#include "smb_data.h"
+#include "urldata.h"
+#include "sendf.h"
+#include "multiif.h"
+#include "connect.h"
+#include "progress.h"
+#include "transfer.h"
+#include "vtls/vtls.h"
+#include "curl_ntlm_core.h"
+
+static CURLcode smb_setup(struct connectdata *conn);
+static CURLcode smb_connect(struct connectdata *conn, bool *done);
+static CURLcode smb_connection_state(struct connectdata *conn, bool *done);
+static CURLcode smb_request_state(struct connectdata *conn, bool *done);
+static CURLcode smb_done(struct connectdata *conn, CURLcode status, bool premature);
+static CURLcode smb_disconnect(struct connectdata *conn, bool dead);
+static int smb_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks);
+
+const struct Curl_handler Curl_handler_smb = {
+  "SMB",                                /* scheme */
+  smb_setup,                            /* setup_connection */
+  ZERO_NULL,                            /* do_it */
+  smb_done,                             /* done */
+  ZERO_NULL,                            /* do_more */
+  smb_connect,                          /* connect_it */
+  smb_connection_state,                 /* connecting */
+  smb_request_state,                    /* doing */
+  smb_getsock,                          /* proto_getsock */
+  smb_getsock,                          /* doing_getsock */
+  ZERO_NULL,                            /* domore_getsock */
+  ZERO_NULL,                            /* perform_getsock */
+  smb_disconnect,                       /* disconnect */
+  ZERO_NULL,                            /* readwrite */
+  PORT_SMB,                             /* defport */
+  CURLPROTO_SMB,                        /* protocol */
+  PROTOPT_NONE                          /* flags */
+};
+
+#ifdef USE_SSL
+const struct Curl_handler Curl_handler_smbs = {
+  "SMBS",                               /* scheme */
+  smb_setup,                            /* setup_connection */
+  ZERO_NULL,                            /* do_it */
+  smb_done,                             /* done */
+  ZERO_NULL,                            /* do_more */
+  smb_connect,                          /* connect_it */
+  smb_connection_state,                 /* connecting */
+  smb_request_state,                    /* doing */
+  smb_getsock,                          /* proto_getsock */
+  smb_getsock,                          /* doing_getsock */
+  ZERO_NULL,                            /* domore_getsock */
+  ZERO_NULL,                            /* perform_getsock */
+  smb_disconnect,                       /* disconnect */
+  ZERO_NULL,                            /* readwrite */
+  PORT_SMBS,                            /* defport */
+  CURLPROTO_SMBS,                       /* protocol */
+  PROTOPT_SSL                           /* flags */
+};
+#endif
+
+enum smb_req_state {
+  SMB_REQUESTING,
+  SMB_TREE_CONNECT,
+  SMB_OPEN,
+  SMB_DOWNLOAD,
+  SMB_UPLOAD,
+  SMB_CLOSE,
+  SMB_TREE_DISCONNECT,
+  SMB_DONE,
+};
+
+struct smb_request {
+  enum smb_req_state state;
+  char *share;
+  char *path;
+  uint16_t tid; /* even if we connect to same tree as another request, tid will be different */
+  uint16_t fid;
+  CURLcode result;
+};
+
+static CURLcode smb_setup(struct connectdata *conn)
+{
+  struct smb_request *req;
+  char *slash, *path;
+  
+  /* initialize the request state */
+  conn->data->req.protop = req = calloc(1, sizeof(struct smb_request));
+  if(!req) return CURLE_OUT_OF_MEMORY;
+  req->state = SMB_REQUESTING;
+  req->result = CURLE_OK;
+  
+  /* parse the share and path */
+  path = conn->data->state.path;
+  req->share = (*path == '/' || *path == '\\') ? strdup(path + 1) : strdup(path);
+  if(!req->share) return CURLE_OUT_OF_MEMORY;
+  if(!(slash = strchr(req->share, '/')) && !(slash = strchr(req->share, '\\'))) {
+    return CURLE_URL_MALFORMAT;
+  }
+  *slash++ = 0;
+  req->path = slash;
+  for(; *slash; slash++) {
+    if(*slash == '/') *slash = '\\';
+  }
+  
+  return CURLE_OK;
+}
+
+static CURLcode smb_connect(struct connectdata *conn, bool *done)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  char *slash;
+  
+  /* initialize connection state */
+  memset(smbc, 0, sizeof(*smbc));
+  smbc->state = SMB_CONNECTING;
+  smbc->send_buf = malloc(0x11000);
+  smbc->recv_buf = malloc(0x11000);
+  if(!smbc->send_buf || !smbc->recv_buf) {
+    return CURLE_OUT_OF_MEMORY;
+  }
+  
+  /* multiple requests are allow with this connection */
+  connkeep(conn, "SMB default");
+  
+  /* parse the username, domain, and password */
+  if((slash = strchr(conn->user, '/')) || (slash = strchr(conn->user, '\\'))) {
+    smbc->user = slash + 1;
+    smbc->domain = strdup(conn->user);
+    if(!smbc->domain) {
+      return CURLE_OUT_OF_MEMORY;
+    }
+    smbc->domain[slash - conn->user] = 0;
+  }
+  else {
+    smbc->user = conn->user;
+    smbc->domain = strdup(conn->host.name);
+    if(!smbc->domain) {
+      return CURLE_OUT_OF_MEMORY;
+    }
+  }
+  
+  return CURLE_OK;
+}
+
+static CURLcode smb_recv_message(struct connectdata *conn, void **msg)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  char *buf = smbc->recv_buf;
+  ssize_t bytes_read, nbt_size, msg_size;
+  ssize_t len = 0x11000 - smbc->got;
+  CURLcode result = Curl_read(conn, FIRSTSOCKET, buf + smbc->got, len, &bytes_read);
+  if(result) return result;
+  if(bytes_read == 0) return CURLE_OK;
+  smbc->got += bytes_read;
+  if(smbc->got < 4) return CURLE_OK;
+  nbt_size = ntohs(*(uint16_t*)(buf + 2)) + 4;
+  if(smbc->got < nbt_size) return CURLE_OK;
+  msg_size = sizeof(struct smb_header);
+  if(nbt_size >= msg_size + 1) {
+    msg_size += 1 + buf[msg_size] * 2; /* add word count */
+    if(nbt_size >= msg_size + 2) {
+      msg_size += 2 + buf[msg_size] + (buf[msg_size+1] << 8); /* add byte count */
+      if(nbt_size < msg_size) return CURLE_READ_ERROR;
+    }
+  }
+  *msg = buf;
+  return CURLE_OK;
+}
+
+static void pop_message(struct connectdata *conn)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  smbc->got = 0;
+}
+
+static void format_message(struct connectdata *conn, struct smb_header *h, uint8_t cmd, int len)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  struct smb_request *req = conn->data->req.protop;
+  memset(h, 0, sizeof(*h));
+  h->nbt_length = htons(sizeof(*h) - 4 + len);
+  strncpy((char*)h->magic, "\xffSMB", 4);
+  h->command = cmd;
+  h->flags = SMB_FLAGS_CANONICAL_PATHNAMES | SMB_FLAGS_CASELESS_PATHNAMES;
+  h->flags2 = SMB_FLAGS2_IS_LONG_NAME | SMB_FLAGS2_KNOWS_LONG_NAME;
+  h->uid = smbc->uid;
+  h->tid = req->tid;
+  uint32_t pid = getpid();
+  h->pid_high = pid >> 16;
+  h->pid = pid;
+}
+
+static CURLcode smb_send(struct connectdata *conn, ssize_t len)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  ssize_t bytes_written;
+  CURLcode result = Curl_write(conn, FIRSTSOCKET, smbc->send_buf, len, &bytes_written);
+  if(result) return result;
+  if(bytes_written != len) {
+    smbc->send_size = len;
+    smbc->sent = bytes_written;
+  }
+  return CURLE_OK;
+}
+
+static CURLcode smb_flush(struct connectdata *conn)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  ssize_t bytes_written;
+  ssize_t len = smbc->send_size - smbc->sent;
+  CURLcode result;
+  if(!smbc->send_size) return CURLE_OK;
+  result = Curl_write(conn, FIRSTSOCKET, smbc->send_buf + smbc->sent, len, &bytes_written);
+  if(result) return result;
+  if(bytes_written != len) {
+    smbc->sent += bytes_written;
+  }
+  else {
+    smbc->send_size = 0;
+  }
+  return CURLE_OK;
+}
+
+static CURLcode smb_send_message(struct connectdata *conn, uint8_t cmd, const void *msg, int msg_len)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  format_message(conn, (struct smb_header*)smbc->send_buf, cmd, msg_len);
+  memcpy(smbc->send_buf + sizeof(struct smb_header), msg, msg_len);
+  return smb_send(conn, sizeof(struct smb_header) + msg_len);
+}
+
+static CURLcode smb_send_negotiate(struct connectdata *conn)
+{
+  const char *msg = "\x00\x0c\x00\x02NT LM 0.12";
+  return smb_send_message(conn, 0x72, msg, 15);
+};
+
+static CURLcode smb_send_setup(struct connectdata *conn)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  struct smb_setup setup;
+  char *p = setup.bytes;
+  unsigned char lm_hash[21], lm[24];
+  unsigned char nt_hash[21], nt[24];
+  
+  Curl_ntlm_core_mk_lm_hash(conn->data, conn->passwd, lm_hash);
+  Curl_ntlm_core_lm_resp(lm_hash, smbc->challenge, lm);
+#if USE_NTRESPONSES
+  Curl_ntlm_core_mk_nt_hash(conn->data, conn->passwd, nt_hash);
+  Curl_ntlm_core_lm_resp(nt_hash, smbc->challenge, nt);
+#else
+  memset(nt, 0, sizeof(nt));
+#endif
+  
+  memset(&setup, 0, sizeof(setup));
+  setup.word_count = 13;
+  setup.andx.command = 0xff;
+  setup.max_buffer_size = 4096;
+  setup.max_mpx_count = 1;
+  setup.vc_number = 1;
+  setup.session_key = smbc->session_key;
+  setup.capabilities = 0x18; /* large file support */
+  setup.lengths[0] = 24;
+  setup.lengths[1] = 24;
+  memcpy(p, lm, 24); p += 24;
+  memcpy(p, nt, 24); p += 24;
+  strcpy(p, smbc->user); p += strlen(smbc->user) + 1;
+  strcpy(p, smbc->domain); p += strlen(smbc->domain) + 1;
+  strcpy(p, "Linux"); p += 6;
+  strcpy(p, "curl_"); p += 6;
+  setup.byte_count = p - setup.bytes;
+  return smb_send_message(conn, 0x73, &setup, sizeof(setup) - sizeof(setup.bytes) + setup.byte_count);
+}
+
+static CURLcode smb_send_tree_connect(struct connectdata *conn)
+{
+  struct smb_request *req = conn->data->req.protop;
+  struct smb_tree_connect tree;
+  char *p = tree.bytes;  
+  memset(&tree, 0, sizeof(tree));
+  tree.word_count = 4;
+  tree.andx.command = 0xff;
+  tree.pw_len = 0;
+  strcpy(p, "\\\\"); p += 2;
+  strcpy(p, conn->host.name); p += strlen(conn->host.name);
+  *p++ = '\\';
+  strcpy(p, req->share); p += strlen(req->share) + 1;
+  strcpy(p, "?????"); p += 6;
+  tree.byte_count = p - tree.bytes;
+  return smb_send_message(conn, 0x75, &tree, sizeof(tree) - sizeof(tree.bytes) + tree.byte_count);
+}
+
+static CURLcode smb_send_open(struct connectdata *conn)
+{
+  struct smb_request *req = conn->data->req.protop;
+  struct smb_nt_create open;
+  memset(&open, 0, sizeof(open));
+  open.word_count = 0x18;
+  open.andx.command = 0xff;  
+  open.name_length = strlen(req->path);
+  open.share_access = 7;
+  if(conn->data->set.upload) {
+    open.access = 0xc0000000;
+    open.create_disposition = 5;
+  }
+  else {
+    open.access = 0x80000000;
+    open.create_disposition = 1;
+  }
+  open.byte_count = open.name_length + 1;
+  strcpy(open.bytes, req->path);
+  return smb_send_message(conn, 0xa2, &open, sizeof(open) - sizeof(open.bytes) + open.byte_count);
+}
+
+static CURLcode smb_send_close(struct connectdata *conn)
+{
+  struct smb_request *req = conn->data->req.protop;
+  struct smb_close close;
+  memset(&close, 0, sizeof(close));
+  close.word_count = 3;
+  close.fid = req->fid;
+  return smb_send_message(conn, 0x04, &close, sizeof(close));
+}
+
+static CURLcode smb_send_tree_disconnect(struct connectdata *conn)
+{
+  struct smb_tree_disconnect tree;
+  memset(&tree, 0, sizeof(tree));
+  return smb_send_message(conn, 0x71, &tree, sizeof(tree));
+}
+
+static CURLcode smb_send_read(struct connectdata *conn)
+{
+  struct smb_request *req = conn->data->req.protop;
+  curl_off_t offset = conn->data->req.offset;
+  struct smb_read read;
+  memset(&read, 0, sizeof(read));
+  read.word_count = 0xc;
+  read.andx.command = 0xff;
+  read.fid = req->fid;
+  read.offset = offset;
+  read.offset_high = offset >> 32;
+  read.min_bytes = 0x8000;
+  read.max_bytes = 0x8000;
+  return smb_send_message(conn, 0x2e, &read, sizeof(read));
+}
+
+static CURLcode smb_send_write(struct connectdata *conn)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  struct smb_write *write = (struct smb_write*)smbc->send_buf;
+  struct smb_request *req = conn->data->req.protop;
+  curl_off_t offset = conn->data->req.offset;
+  CURLcode result;
+  int nread;
+  
+  conn->data->req.upload_fromhere = smbc->send_buf + sizeof(*write);
+  result = Curl_fillreadbuffer(conn, 0x8000, &nread);
+  if(result && result != CURLE_AGAIN) return result;
+  if(nread == 0) return CURLE_OK;
+  
+  memset(write, 0, sizeof(*write));
+  write->word_count = 0xe;
+  write->andx.command = 0xff;
+  write->fid = req->fid;
+  write->offset = offset;
+  write->offset_high = offset >> 32;
+  write->data_length = nread;
+  write->data_offset = sizeof(*write) - 4;
+  format_message(conn, &write->h, 0x2f, sizeof(*write) - sizeof(write->h) + nread);
+  return smb_send(conn, sizeof(*write) + nread);
+}
+
+static CURLcode smb_send_and_recv(struct connectdata *conn, void **msg)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  CURLcode result;
+  
+  /* check if there is still data to send */
+  if(smbc->send_size) {
+    result = smb_flush(conn);
+    if(result) return result;
+  }
+  
+  /* some data was sent, but not all */
+  if(smbc->send_size) return CURLE_AGAIN;
+  
+  return smb_recv_message(conn, msg);
+}
+
+static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  struct smb_negotiate_response *nrsp;
+  struct smb_header *h;
+  CURLcode result;
+  void *msg = NULL;
+  
+  if(smbc->state == SMB_CONNECTING) {
+#ifdef USE_SSL
+    if((conn->handler->flags & PROTOPT_SSL)) {
+      bool ssl_done;
+      result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &ssl_done);
+      if(result && result != CURLE_AGAIN) return result;
+      if(!ssl_done) return CURLE_OK;
+    }
+#endif
+    result = smb_send_negotiate(conn);
+    if(result) {
+      connclose(conn, "SMB: failed to send negotiate message");
+      return result;
+    }
+    smbc->state = SMB_NEGOTIATE;
+  }
+  
+  /* send previous message and check for response */
+  result = smb_send_and_recv(conn, &msg);
+  if(result && result != CURLE_AGAIN) {
+    connclose(conn, "SMB: failed to communicate");
+    return result;
+  }
+  if(!msg) return CURLE_OK;  
+  h = msg;
+  
+  switch(smbc->state) {
+  case SMB_NEGOTIATE:
+    if(h->status) {
+      connclose(conn, "SMB: negotiation failed");
+      return CURLE_COULDNT_CONNECT;
+    }
+    nrsp = msg;
+    memcpy(smbc->challenge, nrsp->bytes, 8);
+    smbc->session_key = nrsp->session_key;
+    result = smb_send_setup(conn);
+    if(result) {
+      connclose(conn, "SMB: failed to send setup message");
+      return result;
+    }
+    smbc->state = SMB_SETUP;
+    break;
+  case SMB_SETUP:
+    if(h->status) {
+      connclose(conn, "SMB: authentication failed");
+      return CURLE_LOGIN_DENIED;
+    }
+    smbc->uid = h->uid;
+    smbc->state = SMB_CONNECTED;
+    *done = true;
+    break;
+  default:
+    pop_message(conn);
+    return CURLE_OK; /* ignore */
+  }
+  pop_message(conn);
+  return CURLE_OK;
+}
+
+static CURLcode smb_request_state(struct connectdata *conn, bool *done)
+{
+  struct smb_request *req = conn->data->req.protop;
+  struct smb_header *h;
+  enum smb_req_state next_state = SMB_DONE;
+  uint16_t len, off;
+  CURLcode result;
+  void *msg = NULL;
+  
+  /* start request */
+  if(req->state == SMB_REQUESTING) {
+    result = smb_send_tree_connect(conn);
+    if(result) {
+      connclose(conn, "SMB: failed to send tree connect message");
+      return result;
+    }
+    req->state = SMB_TREE_CONNECT;
+  }
+  
+  /* send previous message and check for response */
+  result = smb_send_and_recv(conn, &msg);
+  if(result && result != CURLE_AGAIN) {
+    connclose(conn, "SMB: failed to communicate");
+    return result;
+  }
+  if(!msg) return CURLE_OK;
+  h = msg;
+  
+  switch(req->state) {
+  case SMB_TREE_CONNECT:
+    if(h->status) {
+      req->result = CURLE_REMOTE_FILE_NOT_FOUND;
+      if(h->status == SMB_ERR_NOACCESS) {
+        req->result = CURLE_REMOTE_ACCESS_DENIED;
+      }
+      break;
+    }
+    req->tid = h->tid;
+    next_state = SMB_OPEN;
+    break;
+  case SMB_OPEN:
+    if(h->status) {
+      req->result = CURLE_REMOTE_FILE_NOT_FOUND;
+      next_state = SMB_TREE_DISCONNECT;
+      break;
+    }
+    req->fid = ((struct smb_nt_create_response*)msg)->fid;
+    conn->data->req.offset = 0;
+    if(conn->data->set.upload) {
+      conn->data->req.size = conn->data->state.infilesize;
+      Curl_pgrsSetUploadSize(conn->data, conn->data->req.size);
+      next_state = SMB_UPLOAD;
+    }
+    else {
+      conn->data->req.size = ((struct smb_nt_create_response*)msg)->end_of_file;
+      Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size);
+      next_state = SMB_DOWNLOAD;
+    }
+    break;
+  case SMB_DOWNLOAD:
+    if(h->status) {
+      req->result = CURLE_RECV_ERROR;
+      next_state = SMB_CLOSE;
+      break;
+    }
+    len = *(uint16_t*)((char*)msg + sizeof(struct smb_header) + 11);
+    off = *(uint16_t*)((char*)msg + sizeof(struct smb_header) + 13);
+    if(len > 0) {
+      Curl_client_write(conn, CLIENTWRITE_BODY, (char*)msg + off + 4, len);
+    }
+    conn->data->req.bytecount += len;
+    conn->data->req.offset += len;
+    Curl_pgrsSetDownloadCounter(conn->data, conn->data->req.bytecount);
+    next_state = (len < 0x1000) ? SMB_CLOSE : SMB_DOWNLOAD;
+    break;
+  case SMB_UPLOAD:
+    if(h->status) {
+      req->result = CURLE_UPLOAD_FAILED;
+      next_state = SMB_CLOSE;
+      break;
+    }
+    len = *(uint16_t*)((char*)msg + sizeof(struct smb_header) + 5);
+    conn->data->req.bytecount += len;
+    conn->data->req.offset += len;
+    Curl_pgrsSetUploadCounter(conn->data, conn->data->req.bytecount);
+    next_state = (conn->data->req.bytecount >= conn->data->req.size) ? SMB_CLOSE : SMB_UPLOAD;
+    break;
+  case SMB_CLOSE:
+    /* don't care if close failed, proceed to tree disconnect anyway */
+    next_state = SMB_TREE_DISCONNECT;
+    break;
+  case SMB_TREE_DISCONNECT:
+    next_state = SMB_DONE;
+    break;
+  default:
+    pop_message(conn);
+    return CURLE_OK; /* ignore */
+  }
+  
+  pop_message(conn);
+  switch(next_state) {
+  case SMB_OPEN: result = smb_send_open(conn); break;
+  case SMB_DOWNLOAD: result = smb_send_read(conn); break;
+  case SMB_UPLOAD: result = smb_send_write(conn); break;
+  case SMB_CLOSE: result = smb_send_close(conn); break;
+  case SMB_TREE_DISCONNECT: result = smb_send_tree_disconnect(conn); break;
+  case SMB_DONE:
+    result = req->result;
+    *done = true;
+    break;
+  default:
+    break;
+  }
+  
+  if(result) {
+    connclose(conn, "SMB: failed to send message");
+    return result;
+  }
+  req->state = next_state;
+  return CURLE_OK;
+}
+
+static CURLcode smb_done(struct connectdata *conn, CURLcode status, bool premature)
+{
+  struct smb_request *req = conn->data->req.protop;
+  if(req && req->share) free(req->share);
+  return status;
+}
+
+static CURLcode smb_disconnect(struct connectdata *conn, bool dead)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  if(smbc->domain) free(smbc->domain);
+  if(smbc->send_buf) free(smbc->send_buf);
+  if(smbc->recv_buf) free(smbc->recv_buf);
+  return CURLE_OK;
+}
+
+static int smb_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks)
+{
+  struct smb_conn *smbc = &conn->proto.smbc;
+  if(!numsocks) return GETSOCK_BLANK;
+  socks[0] = conn->sock[FIRSTSOCKET];
+  if(smbc->send_size) {
+    return GETSOCK_WRITESOCK(0);
+  }
+  return GETSOCK_READSOCK(0);
+}
diff -x .git -Nur curl-7.38.0-orig/lib/smb_data.h curl-7.38.0/lib/smb_data.h
--- curl-7.38.0-orig/lib/smb_data.h	1969-12-31 19:00:00.000000000 -0500
+++ curl-7.38.0/lib/smb_data.h	2014-09-29 17:00:52.444745958 -0400
@@ -0,0 +1,186 @@
+#ifndef HEADER_CURL_SMB_DATA_H
+#define HEADER_CURL_SMB_DATA_H
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
+ * Copyright (C) 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifdef __GNUC__
+#  define PACK __attribute__((packed))
+#elif defined(_MSC_VER)
+#  define PACK
+#  pragma pack(1)
+#else
+#  define PACK
+#endif
+
+#define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
+#define SMB_FLAGS_CASELESS_PATHNAMES  0x08
+#define SMB_FLAGS2_UNICODE_STRINGS    0x8000
+#define SMB_FLAGS2_IS_LONG_NAME       0x0040
+#define SMB_FLAGS2_KNOWS_LONG_NAME    0x0001
+
+#define SMB_ERR_NOACCESS              0x00050001
+
+struct smb_header {
+  uint8_t nbt_type;
+  uint8_t nbt_flags;
+  uint16_t nbt_length;
+  uint8_t magic[4];
+  uint8_t command;
+  uint32_t status;
+  uint8_t flags;
+  uint16_t flags2;
+  uint16_t pid_high;
+  uint8_t signature[8];
+  uint16_t pad;
+  uint16_t tid;
+  uint16_t pid;
+  uint16_t uid;
+  uint16_t mid;
+} PACK;
+
+struct smb_negotiate_response {
+  struct smb_header h;
+  uint8_t word_count;
+  uint16_t dialect_index;
+  uint8_t security_mode;
+  uint16_t max_mpx_count;
+  uint16_t max_number_vcs;
+  uint32_t max_buffer_size;
+  uint32_t max_raw_size;
+  uint32_t session_key;
+  uint32_t capabilities;
+  uint32_t system_time_low;
+  uint32_t system_time_high;
+  uint16_t server_time_zone;
+  uint8_t encryption_key_length;
+  uint16_t byte_count;
+  char bytes[1];
+} PACK;
+
+struct andx {
+  uint8_t command;
+  uint8_t pad;
+  uint16_t offset;
+} PACK;
+
+struct smb_setup {
+  uint8_t word_count;
+  struct andx andx;
+  uint16_t max_buffer_size;
+  uint16_t max_mpx_count;
+  uint16_t vc_number;
+  uint32_t session_key;
+  uint16_t lengths[2];
+  uint32_t pad;
+  uint32_t capabilities;
+  uint16_t byte_count;
+  char bytes[1024];
+} PACK;
+
+struct smb_tree_connect {
+  uint8_t word_count;
+  struct andx andx;
+  uint16_t flags;
+  uint16_t pw_len;
+  uint16_t byte_count;
+  char bytes[1024];
+} PACK;
+
+struct smb_nt_create {
+  uint8_t word_count;
+  struct andx andx;
+  uint8_t pad;
+  uint16_t name_length;
+  uint32_t flags;
+  uint32_t root_fid;
+  uint32_t access;
+  uint64_t allocation_size;
+  uint32_t ext_file_attributes;
+  uint32_t share_access;
+  uint32_t create_disposition;
+  uint32_t create_options;
+  uint32_t impersonation_level;
+  uint8_t security_flags;
+  uint16_t byte_count;
+  char bytes[1024];
+} PACK;
+
+struct smb_nt_create_response {
+  struct smb_header h;
+  uint8_t word_count;
+  struct andx andx;
+  uint8_t op_lock_level;
+  uint16_t fid;
+  uint32_t create_disposition;
+  uint64_t create_time;
+  uint64_t last_access_time;
+  uint64_t last_write_time;
+  uint64_t last_change_time;
+  uint32_t ext_file_attributes;
+  uint64_t allocation_size;
+  uint64_t end_of_file;
+} PACK;
+
+struct smb_read {
+  uint8_t word_count;
+  struct andx andx;
+  uint16_t fid;
+  uint32_t offset;
+  uint16_t max_bytes;
+  uint16_t min_bytes;
+  uint32_t timeout;
+  uint16_t remaining;
+  uint32_t offset_high;
+  uint16_t byte_count;
+} PACK;
+
+struct smb_write {
+  struct smb_header h;
+  uint8_t word_count;
+  struct andx andx;
+  uint16_t fid;
+  uint32_t offset;
+  uint32_t timeout;
+  uint16_t write_mode;
+  uint16_t remaining;
+  uint16_t pad;
+  uint16_t data_length;
+  uint16_t data_offset;
+  uint32_t offset_high;
+  uint16_t byte_count;
+  uint8_t pad2;
+} PACK;
+
+struct smb_close {
+  uint8_t word_count;
+  uint16_t fid;
+  uint32_t last_mtime;
+  uint16_t byte_count;
+} PACK;
+
+struct smb_tree_disconnect {
+  uint8_t word_count;
+  uint16_t byte_count;
+} PACK;
+
+#endif /* HEADER_CURL_SMB_DATA_H */
diff -x .git -Nur curl-7.38.0-orig/lib/smb.h curl-7.38.0/lib/smb.h
--- curl-7.38.0-orig/lib/smb.h	1969-12-31 19:00:00.000000000 -0500
+++ curl-7.38.0/lib/smb.h	2014-09-29 17:00:50.316782059 -0400
@@ -0,0 +1,52 @@
+#ifndef HEADER_CURL_SMB_H
+#define HEADER_CURL_SMB_H
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
+ * Copyright (C) 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+enum smb_conn_state {
+  SMB_NOT_CONNECTED = 0,
+  SMB_CONNECTING,
+  SMB_NEGOTIATE,
+  SMB_SETUP,
+  SMB_CONNECTED,
+};
+
+struct smb_conn
+{
+  enum smb_conn_state state;
+  char *user;
+  char *domain;
+  unsigned char challenge[8];
+  uint32_t session_key;
+  uint16_t uid;
+  char *send_buf;
+  char *recv_buf;
+  size_t send_size;
+  size_t sent;
+  size_t got;
+};
+
+extern const struct Curl_handler Curl_handler_smb;
+extern const struct Curl_handler Curl_handler_smbs;
+
+#endif /* HEADER_CURL_SMB_H */
diff -x .git -Nur curl-7.38.0-orig/lib/url.c curl-7.38.0/lib/url.c
--- curl-7.38.0-orig/lib/url.c	2014-09-07 17:50:41.000000000 -0400
+++ curl-7.38.0/lib/url.c	2014-09-29 17:02:02.451553148 -0400
@@ -215,6 +215,13 @@
 #endif
 #endif
 
+#ifndef CURL_DISABLE_SMB
+  &Curl_handler_smb,
+#ifdef USE_SSL
+  &Curl_handler_smbs,
+#endif
+#endif
+
 #ifndef CURL_DISABLE_SMTP
   &Curl_handler_smtp,
 #ifdef USE_SSL
diff -x .git -Nur curl-7.38.0-orig/lib/urldata.h curl-7.38.0/lib/urldata.h
--- curl-7.38.0-orig/lib/urldata.h	2014-09-03 09:22:36.000000000 -0400
+++ curl-7.38.0/lib/urldata.h	2014-09-29 17:01:30.652096179 -0400
@@ -40,6 +40,8 @@
 #define PORT_IMAPS 993
 #define PORT_POP3 110
 #define PORT_POP3S 995
+#define PORT_SMB 445
+#define PORT_SMBS 445
 #define PORT_SMTP 25
 #define PORT_SMTPS 465 /* sometimes called SSMTP */
 #define PORT_RTSP 554
@@ -65,6 +67,7 @@
 #define PROTO_FAMILY_FTP  (CURLPROTO_FTP|CURLPROTO_FTPS)
 #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
 #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
+#define PROTO_FAMILY_SMB  (CURLPROTO_SMB|CURLPROTO_SMBS)
 
 #define DEFAULT_CONNCACHE_SIZE 5
 
@@ -189,6 +192,7 @@
 
 #include "imap.h"
 #include "pop3.h"
+#include "smb.h"
 #include "smtp.h"
 #include "ftp.h"
 #include "file.h"
@@ -1049,6 +1053,7 @@
     struct tftp_state_data *tftpc;
     struct imap_conn imapc;
     struct pop3_conn pop3c;
+    struct smb_conn smbc;
     struct smtp_conn smtpc;
     struct rtsp_conn rtspc;
     void *generic; /* RTMP and LDAP use this */
diff -x .git -Nur curl-7.38.0-orig/lib/version.c curl-7.38.0/lib/version.c
--- curl-7.38.0-orig/lib/version.c	2014-08-25 17:45:11.000000000 -0400
+++ curl-7.38.0/lib/version.c	2014-09-29 17:02:36.130975878 -0400
@@ -216,6 +216,12 @@
 #ifdef USE_LIBSSH2
   "sftp",
 #endif
+#ifndef CURL_DISABLE_SMB
+  "smb",
+#endif
+#if defined(USE_SSL) && !defined(CURL_DISABLE_SMB)
+  "smbs",
+#endif
 #ifndef CURL_DISABLE_SMTP
   "smtp",
 #endif
diff -x .git -Nur curl-7.38.0-orig/src/tool_libinfo.c curl-7.38.0/src/tool_libinfo.c
--- curl-7.38.0-orig/src/tool_libinfo.c	2014-06-11 13:52:29.000000000 -0400
+++ curl-7.38.0/src/tool_libinfo.c	2014-09-29 17:04:30.996991475 -0400
@@ -67,6 +67,8 @@
     { "rtsp",   CURLPROTO_RTSP   },
     { "scp",    CURLPROTO_SCP    },
     { "sftp",   CURLPROTO_SFTP   },
+    { "smb",    CURLPROTO_SMB    },
+    { "smbs",   CURLPROTO_SMBS   },
     { "smtp",   CURLPROTO_SMTP   },
     { "smtps",  CURLPROTO_SMTPS  },
     { "telnet", CURLPROTO_TELNET },
diff -x .git -Nur curl-7.38.0-orig/src/tool_paramhlp.c curl-7.38.0/src/tool_paramhlp.c
--- curl-7.38.0-orig/src/tool_paramhlp.c	2014-06-11 13:52:29.000000000 -0400
+++ curl-7.38.0/src/tool_paramhlp.c	2014-09-29 17:04:56.348550438 -0400
@@ -268,6 +268,8 @@
     { "imaps", CURLPROTO_IMAPS },
     { "pop3", CURLPROTO_POP3 },
     { "pop3s", CURLPROTO_POP3S },
+    { "smb", CURLPROTO_SMB },
+    { "smbs", CURLPROTO_SMBS },
     { "smtp", CURLPROTO_SMTP },
     { "smtps", CURLPROTO_SMTPS },
     { "rtsp", CURLPROTO_RTSP },
diff -x .git -Nur curl-7.38.0-orig/src/tool_setopt.c curl-7.38.0/src/tool_setopt.c
--- curl-7.38.0-orig/src/tool_setopt.c	2014-06-11 13:52:29.000000000 -0400
+++ curl-7.38.0/src/tool_setopt.c	2014-09-29 17:05:04.492408537 -0400
@@ -134,6 +134,8 @@
   NV(CURLPROTO_RTSP),
   NV(CURLPROTO_SCP),
   NV(CURLPROTO_SFTP),
+  NV(CURLPROTO_SMB),
+  NV(CURLPROTO_SMBS),
   NV(CURLPROTO_SMTP),
   NV(CURLPROTO_SMTPS),
   NV(CURLPROTO_TELNET),
