1 /*
2 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
262
263 if (fragmenter != null) {
264 return fragmenter.acquireCiphertext(destination);
265 }
266
267 return null;
268 }
269
270 @Override
271 boolean isEmpty() {
272 return ((fragmenter == null) || fragmenter.isEmpty()) &&
273 ((alertMemos == null) || alertMemos.isEmpty());
274 }
275
276 @Override
277 void initHandshaker() {
278 // clean up
279 fragmenter = null;
280 }
281
282 // buffered record fragment
283 private static class RecordMemo {
284 byte contentType;
285 byte majorVersion;
286 byte minorVersion;
287 int encodeEpoch;
288 CipherBox encodeCipher;
289 Authenticator encodeAuthenticator;
290
291 byte[] fragment;
292 }
293
294 private static class HandshakeMemo extends RecordMemo {
295 byte handshakeType;
296 int messageSequence;
297 int acquireOffset;
298 }
299
300 private final class DTLSFragmenter {
301 private LinkedList<RecordMemo> handshakeMemos = new LinkedList<>();
|
1 /*
2 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
262
263 if (fragmenter != null) {
264 return fragmenter.acquireCiphertext(destination);
265 }
266
267 return null;
268 }
269
270 @Override
271 boolean isEmpty() {
272 return ((fragmenter == null) || fragmenter.isEmpty()) &&
273 ((alertMemos == null) || alertMemos.isEmpty());
274 }
275
276 @Override
277 void initHandshaker() {
278 // clean up
279 fragmenter = null;
280 }
281
282 @Override
283 void launchRetransmission() {
284 // Note: Please don't retransmit if there are handshake messages
285 // or alerts waiting in the queue.
286 if (((alertMemos == null) || alertMemos.isEmpty()) &&
287 (fragmenter != null) && fragmenter.isRetransmittable()) {
288 fragmenter.setRetransmission();
289 }
290 }
291
292 // buffered record fragment
293 private static class RecordMemo {
294 byte contentType;
295 byte majorVersion;
296 byte minorVersion;
297 int encodeEpoch;
298 CipherBox encodeCipher;
299 Authenticator encodeAuthenticator;
300
301 byte[] fragment;
302 }
303
304 private static class HandshakeMemo extends RecordMemo {
305 byte handshakeType;
306 int messageSequence;
307 int acquireOffset;
308 }
309
310 private final class DTLSFragmenter {
311 private LinkedList<RecordMemo> handshakeMemos = new LinkedList<>();
|