java.lang.Object
org.codelibs.jcifs.smb.dcerpc.ndr.NdrBuffer
NDR (Network Data Representation) buffer for encoding and decoding DCE/RPC messages.
This class provides methods for reading and writing primitive types and strings
in NDR format for DCE/RPC communication.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNdrBuffer(byte[] buf, int start) Constructs an NdrBuffer with the specified byte array and starting position. -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance(int n) Advances the buffer index by the specified number of bytes.intalign(int boundary) Aligns the buffer index to the specified boundary.intalign(int boundary, byte value) Aligns the buffer index to the specified boundary with a fill value.longDecodes a hyper integer (8 bytes) from NDR format.intDecodes a long integer (4 bytes) from NDR format.intDecodes a short integer (2 bytes) from NDR format.intDecodes a small integer (1 byte) from NDR format.Decodes a string from NDR format.derive(int idx) Creates a derived NdrBuffer at the specified index position.voidenc_ndr_hyper(long h) Encodes a hyper integer (8 bytes) in NDR format.voidenc_ndr_long(int l) Encodes a long integer (4 bytes) in NDR format.voidenc_ndr_referent(Object obj, int type) Encodes an NDR referent pointer.voidenc_ndr_short(int s) Encodes a short integer (2 bytes) in NDR format.voidenc_ndr_small(int s) Encodes a small integer (1 byte) in NDR format.voidEncodes a string in NDR format.byte[]Returns the underlying byte buffer.intReturns the capacity of the buffer.intgetIndex()Returns the current index position in the buffer.intReturns the length of data in the buffer.intReturns the available space at the tail of the buffer.voidreadOctetArray(byte[] b, int i, int l) Reads an octet array from the buffer.voidreset()Resets the buffer position to the start.voidsetIndex(int index) Sets the current index position in the buffer.voidsetLength(int length) Sets the length of data in the buffer.toString()voidwriteOctetArray(byte[] b, int i, int l) Writes an octet array to the buffer.
-
Field Details
-
buf
public byte[] bufThe underlying byte buffer containing the NDR data. -
start
public int startThe starting position in the buffer. -
index
public int indexThe current position in the buffer. -
length
public int lengthThe length of data in the buffer. -
deferred
Buffer for deferred data processing.
-
-
Constructor Details
-
NdrBuffer
public NdrBuffer(byte[] buf, int start) Constructs an NdrBuffer with the specified byte array and starting position.- Parameters:
buf- the byte array to use as the bufferstart- the starting position in the buffer
-
-
Method Details
-
derive
Creates a derived NdrBuffer at the specified index position.- Parameters:
idx- the index position for the derived buffer- Returns:
- the derived NdrBuffer
-
reset
public void reset()Resets the buffer position to the start. -
getIndex
public int getIndex()Returns the current index position in the buffer.- Returns:
- the current index
-
setIndex
public void setIndex(int index) Sets the current index position in the buffer.- Parameters:
index- the new index position
-
getCapacity
public int getCapacity()Returns the capacity of the buffer.- Returns:
- the buffer capacity
-
getTailSpace
public int getTailSpace()Returns the available space at the tail of the buffer.- Returns:
- the available tail space
-
getBuffer
public byte[] getBuffer()Returns the underlying byte buffer.- Returns:
- the byte buffer
-
align
public int align(int boundary, byte value) Aligns the buffer index to the specified boundary with a fill value.- Parameters:
boundary- the alignment boundaryvalue- the fill value for padding- Returns:
- the number of bytes added for alignment
-
writeOctetArray
public void writeOctetArray(byte[] b, int i, int l) Writes an octet array to the buffer.- Parameters:
b- the byte array to writei- the starting index in the arrayl- the number of bytes to write
-
readOctetArray
public void readOctetArray(byte[] b, int i, int l) Reads an octet array from the buffer.- Parameters:
b- the byte array to read intoi- the starting index in the arrayl- the number of bytes to read
-
getLength
public int getLength()Returns the length of data in the buffer.- Returns:
- the data length
-
setLength
public void setLength(int length) Sets the length of data in the buffer.- Parameters:
length- the new data length
-
advance
public void advance(int n) Advances the buffer index by the specified number of bytes.- Parameters:
n- the number of bytes to advance
-
align
public int align(int boundary) Aligns the buffer index to the specified boundary.- Parameters:
boundary- the alignment boundary- Returns:
- the number of bytes added for alignment
-
enc_ndr_small
public void enc_ndr_small(int s) Encodes a small integer (1 byte) in NDR format.- Parameters:
s- the small integer value to encode
-
dec_ndr_small
public int dec_ndr_small()Decodes a small integer (1 byte) from NDR format.- Returns:
- the decoded small integer value
-
enc_ndr_short
public void enc_ndr_short(int s) Encodes a short integer (2 bytes) in NDR format.- Parameters:
s- the short integer value to encode
-
dec_ndr_short
public int dec_ndr_short()Decodes a short integer (2 bytes) from NDR format.- Returns:
- the decoded short integer value
-
enc_ndr_long
public void enc_ndr_long(int l) Encodes a long integer (4 bytes) in NDR format.- Parameters:
l- the long integer value to encode
-
dec_ndr_long
public int dec_ndr_long()Decodes a long integer (4 bytes) from NDR format.- Returns:
- the decoded long integer value
-
enc_ndr_hyper
public void enc_ndr_hyper(long h) Encodes a hyper integer (8 bytes) in NDR format.- Parameters:
h- the hyper integer value to encode
-
dec_ndr_hyper
public long dec_ndr_hyper()Decodes a hyper integer (8 bytes) from NDR format.- Returns:
- the decoded hyper integer value
-
enc_ndr_string
Encodes a string in NDR format.- Parameters:
s- the string to encode
-
dec_ndr_string
Decodes a string from NDR format.- Returns:
- the decoded string
- Throws:
NdrException- if decoding fails
-
enc_ndr_referent
Encodes an NDR referent pointer.- Parameters:
obj- the object to encode as a referenttype- the referent type
-
toString
-