public class SMBSrvSession extends SrvSession implements Runnable
The SMB server creates a server session object for each incoming session request.
The server session holds the context of a particular session, including the list of open files and active searches.
Modifier and Type | Field and Description |
---|---|
static int |
DBG_BENCHMARK |
static int |
DBG_DCERPC |
static int |
DBG_DUMPDATA |
static int |
DBG_ECHO |
static int |
DBG_ERROR |
static int |
DBG_FILE |
static int |
DBG_FILEIO |
static int |
DBG_INFO |
static int |
DBG_IPC |
static int |
DBG_LOCK |
static int |
DBG_NEGOTIATE |
static int |
DBG_NETBIOS |
static int |
DBG_NOTIFY |
static int |
DBG_OPLOCK |
static int |
DBG_PKTALLOC |
static int |
DBG_PKTPOOL |
static int |
DBG_PKTSTATS |
static int |
DBG_PKTTYPE |
static int |
DBG_RXDATA |
static int |
DBG_SEARCH |
static int |
DBG_SOCKET |
static int |
DBG_STATE |
static int |
DBG_STATECACHE |
static int |
DBG_STREAMS |
static int |
DBG_THREADPOOL |
static int |
DBG_TIMING |
static int |
DBG_TRAN |
static int |
DBG_TREE |
static int |
DBG_TXDATA |
static int |
DefaultBufferSize |
static int |
LanManBufferSize |
static int |
LanManMaxMultiplexed |
static int |
NTMaxMultiplexed |
Modifier | Constructor and Description |
---|---|
protected |
SMBSrvSession(PacketHandler handler,
SMBServer srv,
int maxVC)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addNotifyRequest(NotifyRequest req,
DiskDeviceContext ctx)
Add a change notification request
|
int |
addVirtualCircuit(VirtualCircuit vc)
Add a new virtual circuit, return the allocated UID
|
protected void |
cleanupSession()
Cleanup any resources owned by this session, close virtual circuits and change notification
requests.
|
void |
closeSession()
Close the session
|
protected void |
closeSocket()
Close the session socket
|
static SMBSrvSession |
createSession(PacketHandler handler,
SMBServer server,
int sessId)
Create a new server session instance
|
int |
disconnectClientSessions()
Disconnect other client sessions from the same address/client
|
void |
finalize()
Finalize, object is about to be garbage collected.
|
NotifyRequest |
findNotifyRequest(int mid,
int tid,
int uid,
int pid)
Find the notify request with the specified ids
|
NotifyRequest |
findNotifyRequest(NetworkFile dir,
int filter,
boolean watchTree)
Find an existing notify request for the specified directory and filter
|
TreeConnection |
findTreeConnection(SMBSrvPacket smbPkt)
Find the tree connection for the request
|
VirtualCircuit |
findVirtualCircuit(int uid)
Find a virtual circuit with the allocated UID
|
int |
getClientCapabilities()
Return the client capability flags
|
int |
getClientMaximumBufferSize()
Return the client maximum buffer size
|
int |
getClientMaximumMultiplex()
Return the client maximum muliplexed requests
|
int |
getDefaultFlags()
Return the default flags SMB header value
|
int |
getDefaultFlags2()
Return the default flags2 SMB header value
|
static SrvSessionFactory |
getFactory()
Return the server session object factory
|
int |
getMaximumVirtualCircuits()
Return the maximum virtual circuits allowed on this session
|
int |
getNegotiatedSMBDialect()
Return the SMB dialect type that the server/client have negotiated.
|
int |
getNotifyChangeCount()
Return the count of active change notification requests
|
PacketHandler |
getPacketHandler()
Return the packet handler used by the session
|
CIFSPacketPool |
getPacketPool()
Return the CIFS packet pool from the packet handler
|
InetAddress |
getRemoteAddress()
Return the client network address
|
String |
getRemoteNetBIOSName()
Return the remote NetBIOS name that was used to create the session.
|
String |
getServerName()
Return the server name that this session is associated with.
|
Object |
getSetupObject(int pid)
Return the session setup object for the specified PID
|
String |
getShareHostName()
Get the hostname the client used to mount a network drive
|
SMBServer |
getSMBServer()
Return the server that this session is associated with.
|
int |
getState()
Return the session state
|
String |
getTargetNetBIOSName()
Return the target NetBIOS name that was used to create the session
|
ThreadRequestPool |
getThreadPool()
Return the thread pool
|
void |
hangupSession(String reason)
Hangup the session.
|
boolean |
hasAsyncResponseQueued()
Check if this session has any asynchrnous responses queued
|
boolean |
hasClientCapability(int cap)
Determine if the client has the specified capability enabled
|
boolean |
hasMacintoshExtensions()
Check if the Macintosh exteniosn SMBs are enabled
|
boolean |
hasNotifyPending()
Check if there is a change notification update pending
|
boolean |
hasReadInProgress()
Check if an asynchronous read is queued/being processed by this session
|
boolean |
hasRemoteAddress()
Cehck if the clients remote address is available
|
boolean |
hasSetupObject(int pid)
Determine if the session has a setup object for the specified PID
|
boolean |
hasTargetNetBIOSName()
Check if the session has a target NetBIOS name
|
int |
isProtocol()
Return the session protocol type
|
boolean |
isPseudoFilesEnabled()
Are pseudo files enabled for this session?
|
int |
numberOfVirtualCircuits()
Return the active virtual circuit count
|
void |
processPacket(SMBSrvPacket smbPkt)
Process a CIFS request packet
|
protected void |
procNetBIOSSessionRequest(SMBSrvPacket smbPkt)
Process the NetBIOS session request message, either accept the session request and send back
a NetBIOS accept or reject the session and send back a NetBIOS reject and hangup the session.
|
protected void |
procSMBNegotiate(SMBSrvPacket smbPkt)
Process an SMB dialect negotiate request.
|
protected void |
queueAsynchResponseSMB(SMBSrvPacket pkt)
Queue an asynchronous response SMB for sending when current SMB requests have been processed.
|
protected SMBSrvPacket |
removeFirstAsynchResponse()
Remove an asynchronous response packet from the head of the list
|
void |
removeNotifyRequest(NotifyRequest req)
Remove a change notification request
|
Object |
removeSetupObject(int pid)
Remove the session setup object for the specified PID
|
void |
removeVirtualCircuit(int uid)
Remove a virtual circuit
|
void |
run()
Start the SMB server session in a seperate thread.
|
protected void |
runHandler(SMBSrvPacket smbPkt)
Handle a session message, receive all data and run the SMB protocol handler.
|
boolean |
sendAsyncErrorResponseSMB(SMBSrvPacket smbPkt,
int errCode,
int errClass)
Send an asynchonous error response SMB.
|
boolean |
sendAsynchResponseSMB(SMBSrvPacket pkt,
int len)
Send, or queue, an asynchronous response SMB
|
void |
sendErrorResponseSMB(SMBSrvPacket smbPkt,
int errCode,
int errClass)
Send an error response SMB.
|
void |
sendErrorResponseSMB(SMBSrvPacket smbPkt,
int ntCode,
int stdCode,
int stdClass)
Send an error response SMB.
|
int |
sendQueuedAsyncResponses()
Send queued asynchronous responses
|
void |
sendResponseSMB(SMBSrvPacket pkt)
Send an SMB response
|
void |
sendResponseSMB(SMBSrvPacket pkt,
int len)
Send an SMB response
|
void |
sendSuccessResponseSMB(SMBSrvPacket smbPkt)
Send a success response SMB
|
void |
setClientCapabilities(int flags)
Set the client capability flags
|
void |
setClientMaximumBufferSize(int maxBuf)
Set the client maximum buffer size
|
void |
setClientMaximumMultiplex(int maxMpx)
Set the client maximum multiplexed
|
void |
setDefaultFlags(int flags)
Set the default flags value to be ORed with outgoing response packet flags
|
void |
setDefaultFlags2(int flags)
Set the default flags2 value to be ORed with outgoing response packet flags2 field
|
static void |
setFactory(SrvSessionFactory factory)
Set the server session object factory
|
void |
setMaximumVirtualCircuits(int maxVC)
Set the maximum virtual circuits allowed for this session
|
void |
setNotifyPending(boolean pend)
Set the change notify pending flag
|
void |
setReadInProgress(boolean inProgress)
Set/clear the read in progress flag
|
void |
setSetupObject(int pid,
Object obj)
Store the setup object for the specified PID
|
void |
setShareHostName(String hostName)
Set the hostname the client used to mount a network drive
|
protected void |
setState(int state)
Set the session state.
|
boolean |
useCaseSensitiveSearch()
Indicate that CIFS filesystem searches are not case sensitive
|
addDynamicShare, clearTransaction, debugPrint, debugPrintln, debugPrintln, endTransaction, getAuthenticationContext, getClientInformation, getDriverState, getDynamicShareList, getLastIOTime, getNextPostProcessor, getProcessId, getProtocolName, getRemoteName, getServer, getSessionId, getTransactionObject, getUniqueId, hasAuthenticationContext, hasClientInformation, hasDebug, hasDynamicShares, hasPostProcessorRequests, hasProtocolName, hasRemoteName, hasTransaction, initializeTransactionObject, isLoggedOn, isShutdown, setAuthenticationContext, setClientInformation, setDebug, setDebugPrefix, setDriverState, setLastIOTime, setLoggedOn, setProcessId, setProtocolName, setRemoteName, setSessionId, setShutdown, setTransaction, setTransaction, setUniqueId, toString
public static final int DefaultBufferSize
public static final int LanManBufferSize
public static final int LanManMaxMultiplexed
public static final int NTMaxMultiplexed
public static final int DBG_NETBIOS
public static final int DBG_STATE
public static final int DBG_RXDATA
public static final int DBG_TXDATA
public static final int DBG_DUMPDATA
public static final int DBG_NEGOTIATE
public static final int DBG_TREE
public static final int DBG_SEARCH
public static final int DBG_INFO
public static final int DBG_FILE
public static final int DBG_FILEIO
public static final int DBG_TRAN
public static final int DBG_ECHO
public static final int DBG_ERROR
public static final int DBG_IPC
public static final int DBG_LOCK
public static final int DBG_PKTTYPE
public static final int DBG_DCERPC
public static final int DBG_STATECACHE
public static final int DBG_TIMING
public static final int DBG_NOTIFY
public static final int DBG_STREAMS
public static final int DBG_SOCKET
public static final int DBG_PKTPOOL
public static final int DBG_PKTSTATS
public static final int DBG_THREADPOOL
public static final int DBG_BENCHMARK
public static final int DBG_OPLOCK
public static final int DBG_PKTALLOC
protected SMBSrvSession(PacketHandler handler, SMBServer srv, int maxVC)
handler
- Packet handler used to send/receive SMBssrv
- Server that this session is associated with.maxVC
- Maximum virtual circuits allowed on this session.public final int isProtocol()
public final TreeConnection findTreeConnection(SMBSrvPacket smbPkt)
smbPkt
- SMBSrvPacketpublic final int addVirtualCircuit(VirtualCircuit vc)
vc
- VirtualCircuitpublic final VirtualCircuit findVirtualCircuit(int uid)
uid
- intpublic final void removeVirtualCircuit(int uid)
uid
- intpublic final int numberOfVirtualCircuits()
protected final void cleanupSession()
protected final void closeSocket()
public final void closeSession()
closeSession
in class SrvSession
public void finalize()
public final int getDefaultFlags()
public final int getDefaultFlags2()
public final int getNotifyChangeCount()
public final int getClientMaximumBufferSize()
public final int getClientMaximumMultiplex()
public final int getClientCapabilities()
public final boolean hasClientCapability(int cap)
cap
- intpublic final int getNegotiatedSMBDialect()
public final PacketHandler getPacketHandler()
public final CIFSPacketPool getPacketPool()
public final ThreadRequestPool getThreadPool()
public final String getRemoteNetBIOSName()
public final boolean hasTargetNetBIOSName()
public final String getTargetNetBIOSName()
public final boolean hasRemoteAddress()
public final InetAddress getRemoteAddress()
getRemoteAddress
in class SrvSession
public final SMBServer getSMBServer()
public final String getServerName()
public final int getState()
public final int getMaximumVirtualCircuits()
public void hangupSession(String reason)
reason
- java.lang.String Reason the session is being closed.public final boolean hasMacintoshExtensions()
public final boolean hasNotifyPending()
public final boolean hasSetupObject(int pid)
pid
- intpublic final Object getSetupObject(int pid)
pid
- intpublic final void setSetupObject(int pid, Object obj)
pid
- intobj
- Objectpublic final Object removeSetupObject(int pid)
pid
- intpublic final void setNotifyPending(boolean pend)
pend
- booleanpublic final void setClientMaximumBufferSize(int maxBuf)
maxBuf
- intpublic final void setClientMaximumMultiplex(int maxMpx)
maxMpx
- intpublic final void setClientCapabilities(int flags)
flags
- intpublic final void setDefaultFlags(int flags)
flags
- intpublic final void setDefaultFlags2(int flags)
flags
- intprotected void setState(int state)
state
- intpublic final void setMaximumVirtualCircuits(int maxVC)
maxVC
- intprotected void procNetBIOSSessionRequest(SMBSrvPacket smbPkt) throws IOException, NetBIOSException
IOException
NetBIOSException
protected void procSMBNegotiate(SMBSrvPacket smbPkt) throws SMBSrvException, IOException
smbPkt
- SMBSrvPacketSMBSrvException
IOException
public void run()
protected final void runHandler(SMBSrvPacket smbPkt) throws IOException, SMBSrvException, TooManyConnectionsException
smbPkt
- SMBSrvPacketIOException
SMBSrvException
TooManyConnectionsException
public final void processPacket(SMBSrvPacket smbPkt)
smbPkt
- SMBSrvPacketpublic final void sendResponseSMB(SMBSrvPacket pkt) throws IOException
pkt
- SMBSrvPacketIOException
public final void sendResponseSMB(SMBSrvPacket pkt, int len) throws IOException
pkt
- SMBSrvPacketlen
- intIOException
public final void sendSuccessResponseSMB(SMBSrvPacket smbPkt) throws IOException
smbPkt
- SMBSrvPacketIOException
- If a network error occurspublic final void sendErrorResponseSMB(SMBSrvPacket smbPkt, int ntCode, int stdCode, int stdClass) throws IOException
smbPkt
- SMBSrvPacketntCode
- 32bit error codestdCode
- Standard error codestdClass
- Standard error classIOException
public final void sendErrorResponseSMB(SMBSrvPacket smbPkt, int errCode, int errClass) throws IOException
smbPkt
- SMBSrvPacketerrCode
- int Error code.errClass
- int Error class.IOException
public final boolean sendAsyncErrorResponseSMB(SMBSrvPacket smbPkt, int errCode, int errClass) throws IOException
smbPkt
- SMBSrvPacketerrCode
- int Error code.errClass
- int Error class.IOException
public final boolean sendAsynchResponseSMB(SMBSrvPacket pkt, int len) throws IOException
pkt
- SMBSrvPacketlen
- intIOException
- If an I/O error occursprotected final void queueAsynchResponseSMB(SMBSrvPacket pkt)
pkt
- SMBSrvPacketprotected final SMBSrvPacket removeFirstAsynchResponse()
public final boolean hasAsyncResponseQueued()
public final int sendQueuedAsyncResponses()
public final NotifyRequest findNotifyRequest(int mid, int tid, int uid, int pid)
mid
- inttid
- intuid
- intpid
- intpublic final NotifyRequest findNotifyRequest(NetworkFile dir, int filter, boolean watchTree)
dir
- NetworkFilefilter
- intwatchTree
- booleanpublic final void addNotifyRequest(NotifyRequest req, DiskDeviceContext ctx)
req
- NotifyRequestctx
- DiskDeviceContextpublic final void removeNotifyRequest(NotifyRequest req)
req
- NotifyRequestpublic static final SrvSessionFactory getFactory()
public static final void setFactory(SrvSessionFactory factory)
factory
- SrvSessionFactorypublic static final SMBSrvSession createSession(PacketHandler handler, SMBServer server, int sessId)
handler
- PacketHandlerserver
- SMBServersessId
- intpublic final boolean hasReadInProgress()
public final void setReadInProgress(boolean inProgress)
inProgress
- booleanpublic boolean useCaseSensitiveSearch()
useCaseSensitiveSearch
in class SrvSession
public boolean isPseudoFilesEnabled()
isPseudoFilesEnabled
in class SrvSession
public final int disconnectClientSessions()
public void setShareHostName(String hostName)
hostName
- Stringpublic String getShareHostName()
Copyright © 2005–2017 Alfresco Software. All rights reserved.