FileDocCategorySizeDatePackage
DcerpcMessage.javaAPI DocJCIFS 1.3.17 API4458Tue Oct 18 15:26:24 BST 2011jcifs.dcerpc

DcerpcMessage

public abstract class DcerpcMessage extends NdrObject implements DcerpcConstants

Fields Summary
protected int
ptype
protected int
flags
protected int
length
protected int
call_id
protected int
alloc_hint
protected int
result
Constructors Summary
Methods Summary
public voiddecode(NdrBuffer buf)

        decode_header(buf);

        if (ptype != 12 && ptype != 2 && ptype != 3 && ptype != 13)
            throw new NdrException("Unexpected ptype: " + ptype);

        if (ptype == 2 || ptype == 3) { /* Response or Fault */
            alloc_hint = buf.dec_ndr_long();
            buf.dec_ndr_short();        /* context id */
            buf.dec_ndr_short();        /* cancel count */
        }
        if (ptype == 3 || ptype == 13) {               /* Fault */
            result = buf.dec_ndr_long();
        } else {                        /* Bind_ack or Response */
            decode_out(buf);
        }
    
voiddecode_header(NdrBuffer buf)

         /* RPC major / minor version */
        if (buf.dec_ndr_small() != 5 || buf.dec_ndr_small() != 0)
            throw new NdrException("DCERPC version not supported");
        ptype = buf.dec_ndr_small();
        flags = buf.dec_ndr_small();
        if (buf.dec_ndr_long() != 0x00000010) /* Little-endian / ASCII / IEEE */
            throw new NdrException("Data representation not supported");
        length = buf.dec_ndr_short();
        if (buf.dec_ndr_short() != 0)
            throw new NdrException("DCERPC authentication not supported");
        call_id = buf.dec_ndr_long();
    
public abstract voiddecode_out(NdrBuffer buf)

public voidencode(NdrBuffer buf)

        int start = buf.getIndex();
        int alloc_hint_index = 0;

        buf.advance(16); /* momentarily skip header */
        if (ptype == 0) { /* Request */
            alloc_hint_index = buf.getIndex();
            buf.enc_ndr_long(0); /* momentarily skip alloc hint */
            buf.enc_ndr_short(0); /* context id */
            buf.enc_ndr_short(getOpnum());
        }

        encode_in(buf);
        length = buf.getIndex() - start;

        if (ptype == 0) {
            buf.setIndex(alloc_hint_index);
            alloc_hint = length - alloc_hint_index;
            buf.enc_ndr_long(alloc_hint);
        }

        buf.setIndex(start);
        encode_header(buf);
        buf.setIndex(start + length);
    
voidencode_header(NdrBuffer buf)

        buf.enc_ndr_small(5); /* RPC version */
        buf.enc_ndr_small(0); /* minor version */
        buf.enc_ndr_small(ptype);
        buf.enc_ndr_small(flags);
        buf.enc_ndr_long(0x00000010); /* Little-endian / ASCII / IEEE */
        buf.enc_ndr_short(length);
        buf.enc_ndr_short(0); /* length of auth_value */
        buf.enc_ndr_long(call_id);
    
public abstract voidencode_in(NdrBuffer buf)

public abstract intgetOpnum()

public DcerpcExceptiongetResult()

        if (result != 0)
            return new DcerpcException(result);
        return null;
    
public booleanisFlagSet(int flag)


        
        return (flags & flag) == flag;
    
public voidsetFlag(int flag)

        flags |= flag;
    
public voidunsetFlag(int flag)

        flags &= ~flag;