pub struct Smb2Conn {Show 47 fields
pub dialect: Option<u16>,
pub session_id: u64,
pub authenticated: bool,
pub challenge: [u8; 8],
pub user: String,
pub guest: bool,
pub session_key: Option<[u8; 16]>,
pub signing_key: Option<[u8; 16]>,
pub signing_algo: u16,
pub advertised_caps: u32,
pub client_credits: u32,
pub preauth_hash: [u8; 64],
pub cipher: Option<u16>,
pub enc_keys: Option<([u8; 32], [u8; 32])>,
pub encrypt_data: bool,
pub peer_encrypts: bool,
pub ntlm_blobs: Option<(Vec<u8>, Vec<u8>)>,
pub ntlm_targ: Option<Vec<u8>>,
pub raw_ntlm: bool,
pub lease_keys: HashMap<[u8; 16], [u8; 16]>,
pub pipes: HashMap<[u8; 16], Pipe>,
pub searches: HashMap<[u8; 16], VecDeque<FindEntry>>,
pub integrity: HashMap<[u8; 16], (u16, u32)>,
pub outbound: Sender<Vec<u8>>,
pub next_async_id: u64,
pub async_cancels: HashMap<u64, Sender<Status>>,
pub async_msgids: HashMap<u64, u64>,
pub async_by_file: HashMap<[u8; 16], Vec<u64>>,
pub resume_keys: HashMap<[u8; 24], [u8; 16]>,
pub offload_tokens: HashMap<[u8; 16], Vec<u8>>,
pub durable: HashMap<[u8; 16], DurableEntry>,
pub compress_algo: Option<u16>,
pub compress_chained: bool,
pub compress_response: bool,
pub client_guid: [u8; 16],
pub client_security_mode: u16,
pub client_capabilities: u32,
pub supports_notifications: bool,
pub client_dialects: Vec<u16>,
pub disconnect: bool,
pub chain_fid: Option<[u8; 16]>,
pub symlink_error: Option<Vec<u8>>,
pub resp_tree_id: Option<u32>,
pub seal_current: bool,
pub req_encrypted: bool,
pub binding: bool,
pub scope: Option<ScopeRef>,
}Expand description
Per-connection SMB2 state.
Fields§
§dialect: Option<u16>Negotiated dialect revision (set after successful NEGOTIATE).
session_id: u64Current session id (0 = none).
authenticated: boolTrue once credentials were accepted.
challenge: [u8; 8]NTLM challenge used during authentication.
user: StringAuthenticated principal (nobody for guests).
guest: boolTrue when mapped to guest.
session_key: Option<[u8; 16]>Exported NTLM session key; enables SMB2 signing for this session ([MS-SMB2] §3.2.5.3).
signing_key: Option<[u8; 16]>Derived signing key (dialect-specific); None disables signing.
signing_algo: u16Negotiated 3.1.1 signing algorithm ([MS-SMB2] §2.2.3.1.7): HMAC-SHA256, AES-128-CMAC, or AES-128-GMAC. Unused for 2.x (always HMAC-SHA256).
advertised_caps: u32Capabilities word advertised in our NEGOTIATE response — echoed verbatim in FSCTL_VALIDATE_NEGOTIATE_INFO ([MS-SMB2] §3.3.5.15).
client_credits: u32Credits the client currently holds (granted minus spent, [MS-SMB2] §3.3.1.1).
preauth_hash: [u8; 64]Pre-authentication integrity hash (3.1.1 only).
cipher: Option<u16>Chosen encryption cipher (from negotiate ENCRYPTION_CAPABILITIES).
enc_keys: Option<([u8; 32], [u8; 32])>(client-to-server, server-to-client) cipher keys; None until the
session enables encryption ([MS-SMB2] §3.1.4.1 labels). AES-128 uses the
first 16 bytes; AES-256 uses all 32.
encrypt_data: boolTrue once every subsequent message for this session must be wrapped in a transform header (SMB2_SESSION_FLAG_ENCRYPT_DATA).
peer_encrypts: boolTrue once the peer has sent at least one encrypted (transform) frame, so async replies must be sealed even when the server does not force encryption on the session.
ntlm_blobs: Option<(Vec<u8>, Vec<u8>)>SPNEGO exchange blobs: (init request, authenticate request).
ntlm_targ: Option<Vec<u8>>Challenge token sent during leg 1 (for the mechListMIC input).
raw_ntlm: boolTrue when the client’s SESSION_SETUP carries bare NTLMSSP messages with no SPNEGO envelope (leg 1’s blob starts with the NTLMSSP signature directly, not a negTokenInit/negTokenResp tag); the response must then echo bare NTLMSSP too, with no mechListMIC (an SPNEGO-only concept).
lease_keys: HashMap<[u8; 16], [u8; 16]>Raw challenge token sent during leg 1 (for mechListMIC). Lease key each open handle joined, so a write/open from a co-holder of the same lease does not break it ([MS-SMB2] §3.3.4.7).
pipes: HashMap<[u8; 16], Pipe>Virtual named pipes opened on IPC$ (srvsvc, …) keyed by file id.
searches: HashMap<[u8; 16], VecDeque<FindEntry>>Directory-enumeration continuation queues keyed by directory FileId.
integrity: HashMap<[u8; 16], (u16, u32)>Per-open integrity state (ChecksumAlgorithm, Flags) set/queried by FSCTL_SET/GET_INTEGRITY_INFORMATION ([MS-FSCC] §2.3.55/57), keyed by FileId.
outbound: Sender<Vec<u8>>Outbound frame queue drained by the per-connection writer task. Async handlers and background tasks (CHANGE_NOTIFY, oplock/lease breaks) clone this to emit unsolicited frames without blocking the reader.
next_async_id: u64Next async id to hand out for a STATUS_PENDING operation ([MS-SMB2] §3.3.4.2).
async_cancels: HashMap<u64, Sender<Status>>In-flight async operations keyed by async id; sending on the channel completes the background task with the given status (CANCELLED for a CANCEL, NOTIFY_CLEANUP when the watched handle is closed).
async_msgids: HashMap<u64, u64>Maps a pending operation’s MessageId to its async id, so a CANCEL that correlates by MessageId (rather than AsyncId) can find it ([MS-SMB2] §3.2.4.24).
async_by_file: HashMap<[u8; 16], Vec<u64>>Pending CHANGE_NOTIFY async ids per watched FileId, so closing the handle can complete them with STATUS_NOTIFY_CLEANUP ([MS-SMB2] §3.3.5.10).
resume_keys: HashMap<[u8; 24], [u8; 16]>Server-side-copy resume keys → source FileId ([MS-SMB2] §2.2.32.3); handed out by FSCTL_SRV_REQUEST_RESUME_KEY and consumed by COPYCHUNK.
offload_tokens: HashMap<[u8; 16], Vec<u8>>Offload (ODX) tokens → the source bytes they represent ([MS-FSCC] §2.3.77/79); issued by FSCTL_OFFLOAD_READ and consumed by FSCTL_OFFLOAD_WRITE, keyed by the 16-byte id embedded in the token.
durable: HashMap<[u8; 16], DurableEntry>Durable handles granted on this connection, keyed by FileId, preserved into the server table when the connection drops ([MS-SMB2] §3.3.1.10).
compress_algo: Option<u16>Negotiated outbound compression algorithm ([MS-SMB2] §2.2.42), if the
client and server share one; None disables compressed responses.
compress_chained: boolSet when the peer advertised SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED ([MS-SMB2] §2.2.3.1.3): compressed responses use the chained transform.
compress_response: boolSet when the current request is a READ carrying SMB2_READFLAG_REQUEST_COMPRESSED ([MS-SMB2] §2.2.19): the response MUST be compressed if that shrinks it, regardless of size heuristics.
client_guid: [u8; 16]Client’s NEGOTIATE parameters, retained to validate a later FSCTL_VALIDATE_NEGOTIATE_INFO request ([MS-SMB2] §3.3.5.15.12).
client_security_mode: u16Client SecurityMode from NEGOTIATE (signing enabled/required bits).
client_capabilities: u32Client Capabilities flags from NEGOTIATE.
supports_notifications: boolConnection.SupportsNotifications ([MS-SMB2] §3.3.5.4): true once the server has echoed GLOBAL_CAP_NOTIFICATIONS in the NEGOTIATE response (dialect 3.1.1 and the client requested it too).
client_dialects: Vec<u16>Dialects the client offered in NEGOTIATE.
disconnect: boolSet to terminate the transport connection after the current frame (e.g. a failed VALIDATE_NEGOTIATE_INFO downgrade check).
chain_fid: Option<[u8; 16]>FileId generated by the most recent CREATE in the current compound chain, used to resolve the wildcard FileId (0xFF..FF) that a related follow-up request carries ([MS-SMB2] §3.3.5.2.7.2). Reset per frame.
symlink_error: Option<Vec<u8>>Symbolic Link Error Response body built by the last CREATE that stopped on a symlink ([MS-SMB2] §2.2.2.2.1), consumed when framing the error.
resp_tree_id: Option<u32>TreeId a successful TREE_CONNECT installs into its response header ([MS-SMB2] §3.3.5.7), set by the handler and consumed once when the reply is framed.
seal_current: boolForce-seal the response to the current frame regardless of session encryption — set when TREE_CONNECT resolves to an encrypted share so the tree-connect reply itself is sealed ([MS-SMB2] §3.3.5.7). Reset per frame.
req_encrypted: boolTrue when the current request arrived inside a transform (encrypted). Its AEAD tag is the integrity check, so the inner SMB2 signature is not verified ([MS-SMB2] §3.3.5.2.4). Reset per frame.
binding: boolTrue while handling a channel-binding SESSION_SETUP ([MS-SMB2] §3.3.5.5.3): the connection derives its own Channel.SigningKey but MUST NOT overwrite the shared session’s stored crypto material.
scope: Option<ScopeRef>Per-session shared state (Session.TreeConnectTable + Session.OpenTable)
this channel is bound to ([MS-SMB2] §3.3.5.5.3); None until a session
is established. Channels bound to one session share the same scope.
Implementations§
Source§impl Smb2Conn
impl Smb2Conn
Sourcepub fn new(challenge: [u8; 8], outbound: Sender<Vec<u8>>) -> Self
pub fn new(challenge: [u8; 8], outbound: Sender<Vec<u8>>) -> Self
Create SMB2 connection state with the given NTLM challenge and the outbound queue its writer task drains.
Sourcepub fn outbound(&self) -> Sender<Vec<u8>>
pub fn outbound(&self) -> Sender<Vec<u8>>
Clone the outbound frame sender for a background/async task.
Sourcepub(crate) fn tree_name(&self, tid: u32) -> Option<String>
pub(crate) fn tree_name(&self, tid: u32) -> Option<String>
Share name bound to tid in the session’s tree table, if any.
Sourcepub(crate) fn tree_exists(&self, tid: u32) -> bool
pub(crate) fn tree_exists(&self, tid: u32) -> bool
True when tid names a tree in the session’s tree table.
Sourcepub(crate) fn tree_insert(&self, tid: u32, name: String)
pub(crate) fn tree_insert(&self, tid: u32, name: String)
Bind tid to name in the session’s tree table.
Sourcepub(crate) fn tree_remove(&self, tid: u32)
pub(crate) fn tree_remove(&self, tid: u32)
Remove tid from the session’s tree table.
Sourcepub(crate) fn handle_exists(&self, fid: &[u8; 16]) -> bool
pub(crate) fn handle_exists(&self, fid: &[u8; 16]) -> bool
True when fid names an open handle in the session’s open table.
Sourcepub(crate) fn handle_insert(&self, fid: [u8; 16], open: Box<OpenFile>)
pub(crate) fn handle_insert(&self, fid: [u8; 16], open: Box<OpenFile>)
Insert an open handle into the session’s open table.
Sourcepub(crate) fn handle_take(&self, fid: &[u8; 16]) -> Option<Box<OpenFile>>
pub(crate) fn handle_take(&self, fid: &[u8; 16]) -> Option<Box<OpenFile>>
Remove and return an open handle from the session’s open table. Used both
to close a handle and to check one out for an async VFS call (reinsert
with Self::handle_insert afterwards) so no RefCell borrow is ever
held across an .await.
Sourcepub(crate) fn with_handle<R>(
&self,
fid: &[u8; 16],
f: impl FnOnce(&OpenFile) -> R,
) -> Option<R>
pub(crate) fn with_handle<R>( &self, fid: &[u8; 16], f: impl FnOnce(&OpenFile) -> R, ) -> Option<R>
Run f against a shared handle reference (no .await inside).
Sourcepub fn alloc_async_id(&mut self) -> u64
pub fn alloc_async_id(&mut self) -> u64
Allocate a fresh per-connection async id for a STATUS_PENDING op.