summary refs log tree commit diff
path: root/crypto/src/tls/ContentType.cs
blob: fb0a9777faabd7eaa9b31f3fc2ddcd1ec2796897 (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
39
40
41
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 const short tls12_cid = 25;

        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";
            case tls12_cid:
                return "tls12_cid";
            default:
                return "UNKNOWN";
            }
        }

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