summary refs log tree commit diff
path: root/crypto/src/tls/HeartbeatMessageType.cs
blob: 18f86b1abeefe4aaf4ee67c4a11fd3d323f7624c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;

namespace Org.BouncyCastle.Tls
{
    /// <summary>RFC 6520 3.</summary>
    public abstract class HeartbeatMessageType
    {
        public const short heartbeat_request = 1;
        public const short heartbeat_response = 2;

        public static string GetName(short heartbeatMessageType)
        {
            switch (heartbeatMessageType)
            {
            case heartbeat_request:
                return "heartbeat_request";
            case heartbeat_response:
                return "heartbeat_response";
            default:
                return "UNKNOWN";
            }
        }

        public static string GetText(short heartbeatMessageType)
        {
            return GetName(heartbeatMessageType) + "(" + heartbeatMessageType + ")";
        }

        public static bool IsValid(short heartbeatMessageType)
        {
            return heartbeatMessageType >= heartbeat_request && heartbeatMessageType <= heartbeat_response;
        }
    }
}