public int align(int boundary) { int m = boundary - 1; int i = index - start; int n = ((i + m) & ~m) - i; advance(n); return n; }
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) { int padding = dst.align(4, (byte) 0); dst.enc_ndr_small(authenticationService); dst.enc_ndr_small(protectionLevel); dst.enc_ndr_small(padding); dst.enc_ndr_small(0); // Reserved dst.enc_ndr_long(contextId); System.arraycopy(body, 0, dst.getBuffer(), dst.getIndex(), body.length); // dst.index += body.length; dst.advance(body.length); }
public String dec_ndr_string() throws NdrException { align(4); int i = index; String val = null; int len = Encdec.dec_uint32le(buf, i); i += 12; if (len != 0) { len--; int size = len * 2; try { if (size < 0 || size > 0xFFFF) throw new NdrException(NdrException.INVALID_CONFORMANCE); val = new String(buf, i, size, "UnicodeLittle"); i += size + 2; } catch (UnsupportedEncodingException uee) { } } advance(i - index); return val; }
/* double */ public void enc_ndr_string(String s) { align(4); int i = index; int len = s.length(); Encdec.enc_uint32le(len + 1, buf, i); i += 4; Encdec.enc_uint32le(0, buf, i); i += 4; Encdec.enc_uint32le(len + 1, buf, i); i += 4; try { System.arraycopy(s.getBytes("UnicodeLittleUnmarked"), 0, buf, i, len * 2); } catch (UnsupportedEncodingException uee) { } i += len * 2; buf[i++] = (byte) '\0'; buf[i++] = (byte) '\0'; advance(i - index); }
public void enc_ndr_small(int s) { buf[index] = (byte) (s & 0xFF); advance(1); }
public void readOctetArray(byte[] b, int i, int l) { System.arraycopy(buf, index, b, i, l); advance(l); }
public void writeOctetArray(byte[] b, int i, int l) { System.arraycopy(b, i, buf, index, l); advance(l); }
public int dec_ndr_long() { align(4); int val = Encdec.dec_uint32le(buf, index); advance(4); return val; }
public void enc_ndr_long(int l) { align(4); Encdec.enc_uint32le(l, buf, index); advance(4); }
public int dec_ndr_short() { align(2); int val = Encdec.dec_uint16le(buf, index); advance(2); return val; }
public void enc_ndr_short(int s) { align(2); Encdec.enc_uint16le((short) s, buf, index); advance(2); }
public int dec_ndr_small() { int val = buf[index] & 0xFF; advance(1); return val; }