35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using EonaCat.Quic.Helpers;
|
|
using EonaCat.Quic.Infrastructure.Frames;
|
|
using EonaCat.Quic.Infrastructure.Packets;
|
|
using EonaCat.Quic.Infrastructure.Settings;
|
|
|
|
namespace EonaCat.Quic.Infrastructure.PacketProcessing
|
|
{
|
|
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
|
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
|
|
|
public class InitialPacketCreator
|
|
{
|
|
public InitialPacket CreateInitialPacket(IntegerParts sourceConnectionId, IntegerParts destinationConnectionId)
|
|
{
|
|
InitialPacket packet = new InitialPacket(destinationConnectionId, sourceConnectionId);
|
|
packet.PacketNumber = 0;
|
|
packet.SourceConnectionId = sourceConnectionId;
|
|
packet.DestinationConnectionId = destinationConnectionId;
|
|
packet.Version = QuicVersion.CurrentVersion;
|
|
|
|
int length = packet.Encode().Length;
|
|
int padding = QuicSettings.PMTU - length;
|
|
|
|
for (int i = 0; i < padding; i++)
|
|
packet.AttachFrame(new PaddingFrame());
|
|
|
|
return packet;
|
|
}
|
|
|
|
public VersionNegotiationPacket CreateVersionNegotiationPacket()
|
|
{
|
|
return new VersionNegotiationPacket();
|
|
}
|
|
}
|
|
} |