Skip to main content

Smb2Conn

Struct Smb2Conn 

Source
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: u64

Current session id (0 = none).

§authenticated: bool

True once credentials were accepted.

§challenge: [u8; 8]

NTLM challenge used during authentication.

§user: String

Authenticated principal (nobody for guests).

§guest: bool

True 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: u16

Negotiated 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: u32

Capabilities word advertised in our NEGOTIATE response — echoed verbatim in FSCTL_VALIDATE_NEGOTIATE_INFO ([MS-SMB2] §3.3.5.15).

§client_credits: u32

Credits 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: bool

True once every subsequent message for this session must be wrapped in a transform header (SMB2_SESSION_FLAG_ENCRYPT_DATA).

§peer_encrypts: bool

True 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: bool

True 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: u64

Next 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: bool

Set when the peer advertised SMB2_COMPRESSION_CAPABILITIES_FLAG_CHAINED ([MS-SMB2] §2.2.3.1.3): compressed responses use the chained transform.

§compress_response: bool

Set 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: u16

Client SecurityMode from NEGOTIATE (signing enabled/required bits).

§client_capabilities: u32

Client Capabilities flags from NEGOTIATE.

§supports_notifications: bool

Connection.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: bool

Set 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: bool

Force-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: bool

True 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: bool

True 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

Source

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.

Source

pub fn outbound(&self) -> Sender<Vec<u8>>

Clone the outbound frame sender for a background/async task.

Source

pub(crate) fn tree_name(&self, tid: u32) -> Option<String>

Share name bound to tid in the session’s tree table, if any.

Source

pub(crate) fn tree_exists(&self, tid: u32) -> bool

True when tid names a tree in the session’s tree table.

Source

pub(crate) fn tree_insert(&self, tid: u32, name: String)

Bind tid to name in the session’s tree table.

Source

pub(crate) fn tree_remove(&self, tid: u32)

Remove tid from the session’s tree table.

Source

pub(crate) fn handle_exists(&self, fid: &[u8; 16]) -> bool

True when fid names an open handle in the session’s open table.

Source

pub(crate) fn handle_insert(&self, fid: [u8; 16], open: Box<OpenFile>)

Insert an open handle into the session’s open table.

Source

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.

Source

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).

Source

pub fn alloc_async_id(&mut self) -> u64

Allocate a fresh per-connection async id for a STATUS_PENDING op.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more