java.lang.Object
org.codelibs.jcifs.smb.internal.util.SMBUtil
SMB protocol utility class providing low-level data encoding and decoding operations.
Contains methods for reading and writing various data types (integers, strings, timestamps)
in SMB protocol format, handling endianness and data type conversions.
- Author:
- mbechler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]SMB1 protocol header template with magic number 0xFF 'SMB'static final byte[]SMB2 protocol header template with magic number 0xFE 'SMB' -
Method Summary
Modifier and TypeMethodDescriptionstatic intreadInt2(byte[] src, int srcIndex) Reads a 16-bit integer value from a byte array in little-endian formatstatic intreadInt4(byte[] src, int srcIndex) Reads a 32-bit integer value from a byte array in little-endian formatstatic longreadInt8(byte[] src, int srcIndex) Reads a 64-bit integer value from a byte array in little-endian formatstatic longreadTime(byte[] src, int srcIndex) Reads a Windows FILETIME value and converts it to Java time in millisecondsstatic longreadUTime(byte[] buffer, int bufferIndex) Reads a Unix time value (32-bit seconds) and converts it to Java time in millisecondsstatic voidwriteInt2(long val, byte[] dst, int dstIndex) Writes a 16-bit integer value to a byte array in little-endian formatstatic voidwriteInt4(long val, byte[] dst, int dstIndex) Writes a 32-bit integer value to a byte array in little-endian formatstatic voidwriteInt8(long val, byte[] dst, int dstIndex) Writes a 64-bit integer value to a byte array in little-endian formatstatic voidwriteTime(long t, byte[] dst, int dstIndex) Writes a Java time value as a Windows FILETIMEstatic voidwriteUTime(long t, byte[] dst, int dstIndex) Writes a Java time value as a Unix time (32-bit seconds)
-
Field Details
-
SMB_HEADER
public static final byte[] SMB_HEADERSMB1 protocol header template with magic number 0xFF 'SMB' -
SMB2_HEADER
public static final byte[] SMB2_HEADERSMB2 protocol header template with magic number 0xFE 'SMB'
-
-
Method Details
-
writeInt2
public static void writeInt2(long val, byte[] dst, int dstIndex) Writes a 16-bit integer value to a byte array in little-endian format- Parameters:
val- the value to writedst- the destination byte arraydstIndex- the starting index in the destination array
-
writeInt4
public static void writeInt4(long val, byte[] dst, int dstIndex) Writes a 32-bit integer value to a byte array in little-endian format- Parameters:
val- the value to writedst- the destination byte arraydstIndex- the starting index in the destination array
-
readInt2
public static int readInt2(byte[] src, int srcIndex) Reads a 16-bit integer value from a byte array in little-endian format- Parameters:
src- the source byte arraysrcIndex- the starting index in the source array- Returns:
- the 16-bit integer value
-
readInt4
public static int readInt4(byte[] src, int srcIndex) Reads a 32-bit integer value from a byte array in little-endian format- Parameters:
src- the source byte arraysrcIndex- the starting index in the source array- Returns:
- the 32-bit integer value
-
readInt8
public static long readInt8(byte[] src, int srcIndex) Reads a 64-bit integer value from a byte array in little-endian format- Parameters:
src- the source byte arraysrcIndex- the starting index in the source array- Returns:
- the 64-bit integer value
-
writeInt8
public static void writeInt8(long val, byte[] dst, int dstIndex) Writes a 64-bit integer value to a byte array in little-endian format- Parameters:
val- the value to writedst- the destination byte arraydstIndex- the starting index in the destination array
-
readTime
public static long readTime(byte[] src, int srcIndex) Reads a Windows FILETIME value and converts it to Java time in milliseconds- Parameters:
src- the source byte arraysrcIndex- the starting index in the source array- Returns:
- the time value in milliseconds since January 1, 1970 UTC
-
writeTime
public static void writeTime(long t, byte[] dst, int dstIndex) Writes a Java time value as a Windows FILETIME- Parameters:
t- the time value in milliseconds since January 1, 1970 UTCdst- the destination byte arraydstIndex- the starting index in the destination array
-
readUTime
public static long readUTime(byte[] buffer, int bufferIndex) Reads a Unix time value (32-bit seconds) and converts it to Java time in milliseconds- Parameters:
buffer- the source byte arraybufferIndex- the starting index in the source array- Returns:
- the time value in milliseconds since January 1, 1970 UTC
-
writeUTime
public static void writeUTime(long t, byte[] dst, int dstIndex) Writes a Java time value as a Unix time (32-bit seconds)- Parameters:
t- the time value in milliseconds since January 1, 1970 UTCdst- the destination byte arraydstIndex- the starting index in the destination array
-