summary refs log tree commit diff
path: root/crypto/src/tls/ContentType.cs
blob: cf89539c74ffe01fcf4a9541eab37d0f7a8d17a5 (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
35
36
37
38
using System;

namespace Org.BouncyCastle.Tls
{
    /// <summary>RFC 2246 6.2.1</summary>
    public abstract class ContentType
    {
        public const short change_cipher_spec = 20;
        public const short alert = 21;
        public const short handshake = 22;
        public const short application_data = 23;
        public const short heartbeat = 24;

        public static string GetName(short contentType)
        {
            switch (contentType)
            {
            case alert:
                return "alert";
            case application_data:
                return "application_data";
            case change_cipher_spec:
                return "change_cipher_spec";
            case handshake:
                return "handshake";
            case heartbeat:
                return "heartbeat";
            default:
                return "UNKNOWN";
            }
        }

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