smbd: Add conn_protocol()
authorVolker Lendecke <vl@samba.org>
Tue, 13 Feb 2024 11:26:22 +0000 (12:26 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 12 Mar 2024 13:31:31 +0000 (13:31 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/conn.c
source3/smbd/proto.h

index 27a4d27c695b157a3ab9dfc9b11a8195f1284dad..e6c1fa72dcbfc728b92c13e51b1ebf69cd6f0908 100644 (file)
@@ -70,6 +70,20 @@ bool conn_snum_used(struct smbd_server_connection *sconn,
        return false;
 }
 
+enum protocol_types conn_protocol(struct smbd_server_connection *sconn)
+{
+       if ((sconn != NULL) &&
+           (sconn->client != NULL) &&
+           (sconn->client->connections != NULL)) {
+               return sconn->client->connections->protocol;
+       }
+       /*
+        * Default to what source3/lib/util.c has as default for the
+        * static Protocol variable to not change behaviour.
+        */
+       return PROTOCOL_COREPLUS;
+}
+
 /****************************************************************************
  Find first available connection slot, starting from a random position.
  The randomisation stops problems with the server dying and clients
index d18afe3e9966d1ae2c3cfc6bd4cb0a21e814d362..e2b7ddc3e64e63196b8be8836868c8a2dbe27c30 100644 (file)
@@ -142,6 +142,7 @@ bool has_other_nonposix_opens(struct share_mode_lock *lck,
 
 int conn_num_open(struct smbd_server_connection *sconn);
 bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
+enum protocol_types conn_protocol(struct smbd_server_connection *sconn);
 connection_struct *conn_new(struct smbd_server_connection *sconn);
 bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
 void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint64_t vuid);