Skip to content

Commit

Permalink
+ Method: PcapHandle.sendPacket(final byte[] bytes, final int len)
Browse files Browse the repository at this point in the history
  • Loading branch information
Irakli Betchvaia committed Feb 22, 2017
1 parent c301599 commit 277d546
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pcap4j-core/src/main/java/org/pcap4j/core/PcapHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,20 @@ public void sendPacket(Packet packet) throws PcapNativeException, NotOpenExcepti
* @throws NotOpenException if this PcapHandle is not open.
* @throws NullPointerException if any of arguments are null.
*/
public void sendPacket(byte[] bytes) throws NotOpenException, PcapNativeException {
public void sendPacket(final byte[] bytes) throws NotOpenException, PcapNativeException {
sendPacket(bytes,
bytes.length);
}

/**
*
* @param bytes raw bytes
* @param len length
* @throws PcapNativeException if an error occurs in the pcap native library.
* @throws NotOpenException if this PcapHandle is not open.
* @throws NullPointerException if any of arguments are null.
*/
public void sendPacket(final byte[] bytes, final int len) throws NotOpenException, PcapNativeException {
if (bytes == null) {
throw new NullPointerException("bytes may not be null");
}
Expand All @@ -1224,7 +1237,7 @@ public void sendPacket(byte[] bytes) throws NotOpenException, PcapNativeExceptio
throw new NotOpenException();
}

int rc = NativeMappings.pcap_sendpacket(handle, bytes, bytes.length);
int rc = NativeMappings.pcap_sendpacket(handle, bytes, len);
if (rc < 0) {
throw new PcapNativeException(
"Error occured in pcap_sendpacket(): " + getError(),
Expand Down

0 comments on commit 277d546

Please sign in to comment.