Skip to content

Commit

Permalink
Sync Latest Code (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Nov 8, 2019
1 parent e2e012f commit fa7c13d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ MsQuic
MsQuic is an implementation of the [IETF QUIC](https://tools.ietf.org/html/draft-ietf-quic-transport)
protocol by Microsoft. It is a cross platform, general purpose QUIC library written in C.

[![Build Status](https://microsoft.visualstudio.com/OS/_apis/build/status/microsoft.msquic?branchName=master)](https://microsoft.visualstudio.com/OS/_build/latest?definitionId=45975&branchName=master)

## Protocol Features

QUIC has many benefits when compared to existing TLS over TCP scenarios:
Expand Down
5 changes: 5 additions & 0 deletions core/packet_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ QuicPacketBuilderPrepare(
DatagramSize = (uint16_t)Connection->Send.Allowance;
}
QUIC_DBG_ASSERT(!IsPathMtuDiscovery || !IsTailLossProbe); // Never both.
QUIC_DBG_ASSERT(NewPacketKey != NULL);

//
// Next, make sure the current QUIC packet matches the new packet type. If
Expand Down Expand Up @@ -513,6 +514,8 @@ QuicPacketBuilderFinalizeHeaderProtection(
_Inout_ QUIC_PACKET_BUILDER* Builder
)
{
QUIC_DBG_ASSERT(Builder->Key != NULL);

QUIC_STATUS Status;
if (QUIC_FAILED(
Status =
Expand Down Expand Up @@ -589,6 +592,7 @@ QuicPacketBuilderFinalize(
QUIC_DBG_ASSERT(Builder->Datagram->Length >= Builder->MinimumDatagramLength);
QUIC_DBG_ASSERT(Builder->Datagram->Length >= (uint32_t)(Builder->DatagramLength + Builder->EncryptionOverhead));
QUIC_DBG_ASSERT(Builder->Metadata->FrameCount != 0);
QUIC_DBG_ASSERT(Builder->Key != NULL);

uint8_t* Header =
(uint8_t*)Builder->Datagram->Buffer + Builder->PacketStart;
Expand Down Expand Up @@ -774,6 +778,7 @@ QuicPacketBuilderFinalize(
//
// Update the packet key in use by the send builder.
//
QUIC_DBG_ASSERT(Connection->Crypto.TlsState.WriteKeys[QUIC_PACKET_KEY_1_RTT] != NULL);
Builder->Key = Connection->Crypto.TlsState.WriteKeys[QUIC_PACKET_KEY_1_RTT];
}
}
Expand Down
28 changes: 10 additions & 18 deletions core/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,16 @@ QuicSendWriteFrames(
}

if (Send->SendFlags & (QUIC_CONN_SEND_FLAG_CONNECTION_CLOSE | QUIC_CONN_SEND_FLAG_APPLICATION_CLOSE)) {
BOOLEAN IsApplicationClose = !!(Send->SendFlags & QUIC_CONN_SEND_FLAG_APPLICATION_CLOSE);
BOOLEAN IsApplicationClose =
!!(Send->SendFlags & QUIC_CONN_SEND_FLAG_APPLICATION_CLOSE);
if (Connection->State.ClosedRemotely) {
//
// Application closed should only be the origination of the
// connection close. If we're closed remotely already, we should
// just acknowledge the close with a connection close frame.
//
IsApplicationClose = FALSE;
}

QUIC_CONNECTION_CLOSE_EX Frame = {
IsApplicationClose,
Expand All @@ -459,23 +468,6 @@ QuicSendWriteFrames(
Connection->CloseReasonPhrase
};

if (Connection->State.ClosedRemotely) {
//
// If we are already closed remotely, then that means we are just
// responding to (acknowledging in a sense) a received close frame.
// In that case, we just send an error code value of 0. Otherwise,
// we send whatever error code we have cached.
//
Frame.ErrorCode = 0;
//
// Application closed should always be the origination of the
// connection close. In other words, if the peer closed the
// connection first, then we should be responding with a connection
// close frame, instead of an app close frame.
//
QUIC_DBG_ASSERT(!IsApplicationClose);
}

if (QuicConnCloseFrameEncode(
&Frame,
&Builder->DatagramLength,
Expand Down

0 comments on commit fa7c13d

Please sign in to comment.