-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventHeaderFieldFormat.cs
166 lines (142 loc) · 5.01 KB
/
EventHeaderFieldFormat.cs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma warning disable CA1720 // Identifier contains type name
namespace Microsoft.LinuxTracepoints
{
/// <summary>
/// <para>
/// Values for the Format byte of a field definition.
/// </para><para>
/// The low 7 bits of the Format byte contain the field's format.
/// In the case of the Struct encoding, the low 7 bits of the Format byte contain
/// the number of logical fields in the struct (which must not be 0).
/// </para><para>
/// The top bit of the field format byte is the ChainFlag. If set, it indicates
/// that a field tag (uint16) is present after the format byte. If not set, the
/// field tag is not present and is assumed to be 0.
/// </para>
/// </summary>
public enum EventHeaderFieldFormat : byte
{
/// <summary>
/// Mask for the base format type (low 7 bits).
/// </summary>
ValueMask = 0x7F,
/// <summary>
/// If present in the field, this flag indicates that a uint16
/// field tag follows the EventHeaderFieldFormat byte.
/// </summary>
ChainFlag = 0x80,
/// <summary>
/// Use the default format of the encoding.
/// </summary>
Default = 0,
/// <summary>
/// unsigned integer, event byte order.
/// Use with Value8..Value64 encodings.
/// </summary>
UnsignedInt,
/// <summary>
/// signed integer, event byte order.
/// Use with Value8..Value64 encodings.
/// </summary>
SignedInt,
/// <summary>
/// hex integer, event byte order.
/// Use with Value8..Value64 encodings.
/// </summary>
HexInt,
/// <summary>
/// errno, event byte order.
/// Use with Value32 encoding.
/// </summary>
Errno,
/// <summary>
/// process id, event byte order.
/// Use with Value32 encoding.
/// </summary>
Pid,
/// <summary>
/// signed integer, event byte order, seconds since 1970.
/// Use with Value32 or Value64 encodings.
/// </summary>
Time,
/// <summary>
/// 0 = false, 1 = true, event byte order.
/// Use with Value8..Value32 encodings.
/// </summary>
Boolean,
/// <summary>
/// floating point, event byte order.
/// Use with Value32..Value64 encodings.
/// </summary>
Float,
/// <summary>
/// binary, decoded as hex dump of bytes.
/// Use with any encoding.
/// </summary>
HexBytes,
/// <summary>
/// 8-bit char string, unspecified character set (usually treated as ISO-8859-1 or CP-1252).
/// Use with Value8 and Char8 encodings.
/// </summary>
String8,
/// <summary>
/// UTF string, event byte order, code unit size based on encoding.
/// Use with Value16..Value32 and Char8..Char32 encodings.
/// </summary>
StringUtf,
/// <summary>
/// UTF string, BOM used if present, otherwise behaves like StringUtf.
/// Use with Char8..Char32 encodings.
/// </summary>
StringUtfBom,
/// <summary>
/// XML string, otherwise behaves like StringUtfBom.
/// Use with Char8..Char32 encodings.
/// </summary>
StringXml,
/// <summary>
/// JSON string, otherwise behaves like StringUtfBom.
/// Use with Char8..Char32 encodings.
/// </summary>
StringJson,
/// <summary>
/// UUID, network byte order (RFC 4122 format).
/// Use with Value128 encoding.
/// </summary>
Uuid,
/// <summary>
/// IP port, network byte order (in_port_t layout).
/// Use with Value16 encoding.
/// </summary>
Port,
/// <summary>
/// IP address, network byte order (in_addr/in6_addr layout).
/// Use with Value32 or Value128 encoding.
/// </summary>
IPAddress,
/// <summary>
/// Deprecated: Alternate format for IPAddress.
/// Do not generate events with this format.
/// Decode this format as IPAddress.
/// </summary>
IPAddressObsolete,
}
/// <summary>
/// Extension methods for <see cref="EventHeaderFieldFormat"/>.
/// </summary>
public static class EventHeaderFieldFormatExtensions
{
/// <summary>
/// Returns the format without any flags (format & ValueMask).
/// </summary>
public static EventHeaderFieldFormat WithoutFlags(this EventHeaderFieldFormat format) =>
format & EventHeaderFieldFormat.ValueMask;
/// <summary>
/// Returns true if ChainFlag is present (tag present in event).
/// </summary>
public static bool HasChainFlag(this EventHeaderFieldFormat format) =>
0 != (format & EventHeaderFieldFormat.ChainFlag);
}
}