static int getLen(Pointer p) { return p.getInt(LEN_OFFSET); } }
static int getBsCapt(Pointer p) { return p.getInt(BS_CAPT_OFFSET); } };
static int getPsIfdrop(Pointer p) { return p.getInt(PS_IFDROP_OFFSET); } };
static int getCaplen(Pointer p) { return p.getInt(CAPLEN_OFFSET); }
static int getPsRecv(Pointer p) { return p.getInt(PS_RECV_OFFSET); }
static int getPsDrop(Pointer p) { return p.getInt(PS_DROP_OFFSET); }
static int getFdFromPcapT(Pointer p) { if (Platform.isWindows()) { return -1; } return p.getInt(0); }
/** * Indirect the native pointer to <code>malloc</code> space, a la * <code>Pointer.getInt</code>. But this method performs a bounds * checks to ensure that the indirection does not cause memory outside the * <code>malloc</code>ed space to be accessed. * * @see Pointer#getInt(long) */ @Override public int getInt(long offset) { boundsCheck(offset, 4); return super.getInt(offset); }
public int getValue() { return getPointer().getInt(0); } }
/** * Indirect the native pointer as a pointer to <code>long</code>. This is * equivalent to the expression * <code>*((long *)((char *)Pointer + offset))</code>. * * @param offset byte offset from pointer to perform the indirection * @return the <code>long</code> value being pointed to */ public NativeLong getNativeLong(long offset) { return new NativeLong(NativeLong.SIZE == 8 ? getLong(offset) : getInt(offset)); }
result = Function.valueOf(getInt(offset) != 0); } else if (type == byte.class || type == Byte.class) { result = Byte.valueOf(getByte(offset)); result = Character.valueOf(getChar(offset)); } else if (type == int.class || type == Integer.class) { result = Integer.valueOf(getInt(offset)); } else if (type == long.class || type == Long.class) { result = Long.valueOf(getLong(offset));
private MacAddress getMacAddress(String nifName) { Pointer lpAdapter = NativePacketDllMappings.PacketOpenAdapter(nifName); long hFile = -1; if (lpAdapter != null) { if (Native.POINTER_SIZE == 4) { hFile = lpAdapter.getInt(0); } else { hFile = lpAdapter.getLong(0); } } if (hFile == -1L) { int err = Native.getLastError(); logger.error("Unable to open the NIF {}, Error Code: {}", nifName, err); return null; } Memory mem = new Memory(NativePacketDllMappings.PACKET_OID_DATA_SIZE); mem.clear(); PACKET_OID_DATA oidData = new PACKET_OID_DATA(mem); oidData.Length = new NativeLong(6L); oidData.Oid = new NativeLong(0x01010102L); int status = NativePacketDllMappings.PacketRequest(lpAdapter, 0, oidData); NativePacketDllMappings.PacketCloseAdapter(lpAdapter); if (status == 0) { logger.error("Failed to retrieve the link layer address of the NIF: {}", nifName); return null; } else { return MacAddress.getByAddress(oidData.Data); } }
throw new PcapNativeException( "SBIOCSTIME: " + NativeMappings.pcap_strerror(NativeMappings.ERRNO_P.getInt(0)).getString(0));
public String getValue() { try { Pointer pointer = this.getPointer(); if(pointer == null) { return ""; } int stringLength = pointer.getInt(-4); return new String(pointer.getByteArray(0, stringLength), "UTF-16LE"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException("UTF-16LE charset is not supported", ex); } }
/** * Gets the value. * @return the value */ public MC_DISPLAY_TECHNOLOGY_TYPE getValue() { return EnumUtils.fromInteger(getPointer().getInt(0), MC_DISPLAY_TECHNOLOGY_TYPE.class); } }
/** * Gets the value. * @return the value */ public MC_COLOR_TEMPERATURE getValue() { return EnumUtils.fromInteger(getPointer().getInt(0), MC_COLOR_TEMPERATURE.class); } }
/** * Gets the value. * * @return the value */ public UINT getValue() { return new UINT(getPointer().getInt(0)); } }
/** * Gets the value. * * @return the value */ public BOOL getValue() { return new BOOL(getPointer().getInt(0)); } }
/** * Gets the value. * * @return the value */ public LONG getValue() { return new LONG(getPointer().getInt(0)); } }