4#ifndef PROTOCORE_SMB_CLIENT_H
5#define PROTOCORE_SMB_CLIENT_H
51typedef int (*
SmbSendFn)(
void *ctx,
const uint8_t *data,
size_t len);
53typedef int (*
SmbRecvFn)(
void *ctx, uint8_t *buf,
size_t cap);
83 uint8_t signing_key[16];
161typedef int (*
SmbSendFn)(
void *ctx,
const uint8_t *data,
size_t len);
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
SMB2 client wire codec (MS-SMB2), PROTOCORE_ENABLE_SMB - increment 1: the transport frame,...
#define PROTOCORE_SMB2_MAX_CIPHER_KEY_LEN
Largest cipher key length across the four SMB 3.1.1 ciphers (AES-256), for buffer sizing.
enum PROTO_ENUM_PACKED Smb2SignAlgo
The per-session message-signing algorithm the client selects from the negotiated dialect.
SmbResult protocore_smb_client_smb_open(uint8_t *work, const SmbConfig *cfg, SmbHandle *h, SmbSendFn send, SmbRecvFn recv, void *ctx)
Run NEGOTIATE -> NTLMv2 SESSION_SETUP -> TREE_CONNECT -> CREATE and .
enum PROTO_ENUM_PACKED SmbResult
Result of an SMB client operation. 0 is success; each failure is a distinct code.
int(* SmbRecvFn)(void *ctx, uint8_t *buf, size_t cap)
int(* SmbSendFn)(void *ctx, const uint8_t *data, size_t len)
Transport seam: the engine moves raw bytes only through these, so it runs against a real socket (prot...
uint8_t * protocore_smb_client_span(void)
The PROTOCORE_SMB_CLIENT_BORROW bytes this module's state lives in.
SmbResult protocore_smb_client_smb_write(uint8_t *work, SmbHandle *h, uint64_t offset, const uint8_t *data, size_t len, size_t *written, SmbSendFn send, SmbRecvFn recv, void *ctx)
Write len bytes at offset of the open handle, looping WRITE .
PROTOCORE_NS SmbClientNs SmbClient PROTOCORE_UNUSED
Module namespace.
@ SMB_ERR_ARG
a required field was null/empty
@ SMB_ERR_AUTH
SESSION_SETUP was rejected (bad user/password/domain)
@ SMB_ERR_PROTOCOL
a malformed response, or an unexpected NT status
@ SMB_ERR_OVERFLOW
a message did not fit the work buffer (PROTOCORE_SMB_BUF)
@ SMB_ERR_IO
a send/recv failed, timed out, or the peer closed mid-message
SmbResult protocore_smb_client_smb_close(uint8_t *work, SmbHandle *h, SmbSendFn send, SmbRecvFn recv, void *ctx)
CLOSE the open handle (releases the server-side FileId).
SmbResult protocore_smb_client_smb_read(uint8_t *work, SmbHandle *h, uint64_t offset, uint8_t *out, size_t cap, size_t *out_len, SmbSendFn send, SmbRecvFn recv, void *ctx)
Read up to cap bytes from offset of the open handle, looping READ .
Dispatch table. Addressed by offset, so the layout is asserted below.
SmbResult(* smb_open)(uint8_t *, const SmbConfig *, SmbHandle *, SmbSendFn, SmbRecvFn, void *)
Server credentials + the file to open. Strings are ASCII/UTF-8 (encoded UTF-16LE for you).
const char * path
file name relative to the share root (e.g. PROGRAMS\A.NC)
uint32_t disposition
SMB2_FILE_OPEN / _OPEN_IF / _OVERWRITE_IF / _CREATE.
const char * workstation
client name to announce (null => none)
const char * user
account name
uint32_t desired_access
SMB2_FILE_GENERIC_READ and/or _WRITE.
const char * pass
password
const char * share
the tree path, UNC \\server\share
const char * domain
NTLM domain (null/empty for a local account)
An open file on an authenticated session; the ids thread the follow-up requests.
proto_bool signing_active
the session negotiated SMB signing (server set SigningRequired, not guest/null)
uint64_t enc_nonce
monotonic per-session AEAD nonce counter, persisted across read/write/close
uint64_t next_message_id
the MessageId for the next request on this handle
proto_bool encrypt_active
SMB 3.x transport encryption is in force (server session or share required it)
uint64_t file_size
EndofFile from CREATE (the current size)
Smb2SignAlgo signing_algo
HMAC-SHA256 (SMB 2.x) or AES-CMAC (SMB 3.x), from the negotiated dialect.
uint16_t enc_cipher
negotiated Smb2Cipher id (selects the key + nonce length) when encrypt_active
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS