Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/bouncycastle/crypto/tls/UDPTransport.java')
-rw-r--r--src/main/java/org/bouncycastle/crypto/tls/UDPTransport.java32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/main/java/org/bouncycastle/crypto/tls/UDPTransport.java b/src/main/java/org/bouncycastle/crypto/tls/UDPTransport.java
index 98de5db8..82c98aaa 100644
--- a/src/main/java/org/bouncycastle/crypto/tls/UDPTransport.java
+++ b/src/main/java/org/bouncycastle/crypto/tls/UDPTransport.java
@@ -4,7 +4,9 @@ import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
-public class UDPTransport implements DatagramTransport {
+public class UDPTransport
+ implements DatagramTransport
+{
private final static int MIN_IP_OVERHEAD = 20;
private final static int MAX_IP_OVERHEAD = MIN_IP_OVERHEAD + 64;
@@ -13,9 +15,12 @@ public class UDPTransport implements DatagramTransport {
private final DatagramSocket socket;
private final int receiveLimit, sendLimit;
- public UDPTransport(DatagramSocket socket, int mtu) throws IOException {
+ public UDPTransport(DatagramSocket socket, int mtu)
+ throws IOException
+ {
- if (!socket.isBound() || !socket.isConnected()) {
+ if (!socket.isBound() || !socket.isConnected())
+ {
throw new IllegalArgumentException("'socket' must be bound and connected");
}
@@ -27,24 +32,31 @@ public class UDPTransport implements DatagramTransport {
this.sendLimit = mtu - MAX_IP_OVERHEAD - UDP_OVERHEAD;
}
- public int getReceiveLimit() {
+ public int getReceiveLimit()
+ {
return receiveLimit;
}
- public int getSendLimit() {
+ public int getSendLimit()
+ {
// TODO[DTLS] Implement Path-MTU discovery?
return sendLimit;
}
- public int receive(byte[] buf, int off, int len, int waitMillis) throws IOException {
+ public int receive(byte[] buf, int off, int len, int waitMillis)
+ throws IOException
+ {
socket.setSoTimeout(waitMillis);
DatagramPacket packet = new DatagramPacket(buf, off, len);
socket.receive(packet);
return packet.getLength();
}
- public void send(byte[] buf, int off, int len) throws IOException {
- if (len > getSendLimit()) {
+ public void send(byte[] buf, int off, int len)
+ throws IOException
+ {
+ if (len > getSendLimit())
+ {
/*
* RFC 4347 4.1.1. "If the application attempts to send a record larger than the MTU,
* the DTLS implementation SHOULD generate an error, thus avoiding sending a packet
@@ -57,7 +69,9 @@ public class UDPTransport implements DatagramTransport {
socket.send(packet);
}
- public void close() throws IOException {
+ public void close()
+ throws IOException
+ {
socket.close();
}
}