Sfoglia il codice sorgente

Merge pull request #632 from paullouisageneau/fix-gnutls-handshake-dscp

Fix DSCP of DTLS handshake packets with GnuTLS
Paul-Louis Ageneau 3 anni fa
parent
commit
4a8fb5f582
1 ha cambiato i file con 11 aggiunte e 4 eliminazioni
  1. 11 4
      src/impl/dtlstransport.cpp

+ 11 - 4
src/impl/dtlstransport.cpp

@@ -151,9 +151,16 @@ void DtlsTransport::incoming(message_ptr message) {
 }
 
 bool DtlsTransport::outgoing(message_ptr message) {
-	if (message->dscp == 0)
-		message->dscp = mCurrentDscp;
-
+	if (message->dscp == 0) {
+		// DTLS handshake packet
+		if (state() == State::Connecting) {
+			// Set recommended high-priority DSCP value
+			// See https://www.rfc-editor.org/rfc/rfc8837.html#section-5
+			message->dscp = 18; // AF21(18), Assured Forwarding class 2, low drop probability
+		} else {
+			message->dscp = mCurrentDscp;
+		}
+	}
 	return Transport::outgoing(std::move(message));
 }
 
@@ -501,7 +508,7 @@ void DtlsTransport::incoming(message_ptr message) {
 bool DtlsTransport::outgoing(message_ptr message) {
 	if (message->dscp == 0) {
 		// DTLS handshake packet
-		if (state() != DtlsTransport::State::Connected) {
+		if (state() == State::Connecting) {
 			// Set recommended high-priority DSCP value
 			// See https://www.rfc-editor.org/rfc/rfc8837.html#section-5
 			message->dscp = 18; // AF21(18), Assured Forwarding class 2, low drop probability