feat: Adds another utility method.
This commit is contained in:
parent
c25288460d
commit
f6e3deb9a5
@ -36,12 +36,23 @@ public class DTLSDatagramFilter
|
|||||||
*/
|
*/
|
||||||
public static boolean isDTLS(DatagramPacket p)
|
public static boolean isDTLS(DatagramPacket p)
|
||||||
{
|
{
|
||||||
int len = p.getLength();
|
return p != null && isDTLS(p.getData(), p.getOffset(), p.getLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the buffer represented by {@code data}, {@code off}
|
||||||
|
* and {@code len} looks like a DTLS packet.
|
||||||
|
*
|
||||||
|
* @param data the array that contains the data.
|
||||||
|
* @param off the offset.
|
||||||
|
* @param len the length.
|
||||||
|
* @return {@code true} if the buffer looks like a DTLS packet; otherwise,
|
||||||
|
* {@code false}.
|
||||||
|
*/
|
||||||
|
public static boolean isDTLS(byte[] data, int off, int len)
|
||||||
|
{
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
byte[] data = p.getData();
|
|
||||||
int off = p.getOffset();
|
|
||||||
int fb = data[off] & 0xff;
|
int fb = data[off] & 0xff;
|
||||||
|
|
||||||
return 19 < fb && fb < 64;
|
return 19 < fb && fb < 64;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user