Explorar o código

Adds a an API for checking whether the session is supported a specific feature. Currently only for extended security

Julien 'Lta' BALLET %!s(int64=11) %!d(string=hai) anos
pai
achega
4b50da24fe
Modificáronse 3 ficheiros con 40 adicións e 0 borrados
  1. 16 0
      include/bdsm/smb_defs.h
  2. 10 0
      include/bdsm/smb_session.h
  3. 14 0
      src/smb_session.c

+ 16 - 0
include/bdsm/smb_defs.h

@@ -65,6 +65,10 @@ enum
   SMB_SEEK_CUR                = 1
 };
 
+enum smb_session_supports_what
+{
+  SMB_SESSION_EXT_SEC         = 0,
+};
 
 //-----------------------------------------------------------------------------/
 // File access rights (used when smb_open() files)
@@ -206,6 +210,18 @@ enum
 #define SMB_FLAG_SIGN_SUPPORT   (1 << (2 + 8))
 #define SMB_FLAG_EXT_ATTR       (1 << (1 + 8))
 #define SMB_FLAG_LONG_NAMES_OK  (1 << (0 + 8))
+
+// Negotiated server capabilities
+#define SMB_CAPS_RAW            (1 << 0)
+#define SMB_CAPS_MPX            (1 << 1)
+#define SMB_CAPS_UNICODE        (1 << 2)
+#define SMB_CAPS_LARGE          (1 << 3)
+#define SMB_CAPS_NTSMB          (1 << 4)
+#define SMB_CAPS_RPC            (1 << 5)
+#define SMB_CAPS_NTSTATUS       (1 << 6)
+#define SMB_CAPS_NTFIND         (1 << 9)
+#define SMB_CAPS_EXT_SEC        (1 << 31)
+
 // File creation/open flags
 #define SMB_CREATE_OPLOCK       (1 << 1)
 #define SMB_CREATE_BATCH_OPLOCK (1 << 2)

+ 10 - 0
include/bdsm/smb_session.h

@@ -147,4 +147,14 @@ int             smb_session_is_guest(smb_session *s);
  */
 const char      *smb_session_server_name(smb_session *s);
 
+/**
+ * @brief Check if a feature is supported/has been negociated with the server
+ *
+ * @param s The session object
+ * @param what Which features to check ? @see smb_session_supports_what
+ *
+ * @return 0 if the feature is not supported, something else otherwise
+ */
+int             smb_session_supports(smb_session *s, int what);
+
 #endif

+ 14 - 0
src/smb_session.c

@@ -310,3 +310,17 @@ const char      *smb_session_server_name(smb_session *s)
   else
     return (s->srv.name);
 }
+
+int             smb_session_supports(smb_session *s, int what)
+{
+  if (s == NULL)
+    return (0);
+
+  switch (what)
+  {
+    case SMB_SESSION_EXT_SEC:
+      return (s->srv.caps & SMB_CAPS_EXT_SEC);
+    default:
+      return (0);
+  }
+}