Skip to content

Commit f6e3deb

Browse files
committed
feat: Adds another utility method.
1 parent c252884 commit f6e3deb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/main/java/org/ice4j/socket/DTLSDatagramFilter.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,23 @@ public class DTLSDatagramFilter
3636
*/
3737
public static boolean isDTLS(DatagramPacket p)
3838
{
39-
int len = p.getLength();
39+
return p != null && isDTLS(p.getData(), p.getOffset(), p.getLength());
40+
}
4041

42+
/**
43+
* Determines whether the buffer represented by {@code data}, {@code off}
44+
* and {@code len} looks like a DTLS packet.
45+
*
46+
* @param data the array that contains the data.
47+
* @param off the offset.
48+
* @param len the length.
49+
* @return {@code true} if the buffer looks like a DTLS packet; otherwise,
50+
* {@code false}.
51+
*/
52+
public static boolean isDTLS(byte[] data, int off, int len)
53+
{
4154
if (len > 0)
4255
{
43-
byte[] data = p.getData();
44-
int off = p.getOffset();
4556
int fb = data[off] & 0xff;
4657

4758
return 19 < fb && fb < 64;

0 commit comments

Comments
 (0)