bolt-enums.h 4.41 KB
Newer Older
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
/*
 * Copyright © 2017 Red Hat, Inc
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Christian J. Kellner <christian@kellner.me>
 */

#pragma once

#include "bolt-dbus.h"
#include "bolt-enum-types.h"

/**
 * BoltStatus
 * @BOLT_STATUS_DISCONNECTED: Device is not connected.
 * @BOLT_STATUS_CONNECTED: Device is connected, but not authorized.
 * @BOLT_STATUS_AUTHORIZING: Device is currently authorizing.
 * @BOLT_STATUS_AUTH_ERROR: Failed to authorize a device via a key.
 * @BOLT_STATUS_AUTHORIZED: Device connected and authorized.
 * @BOLT_STATUS_AUTHORIZED_SECURE: Device connected and securely authorized via a key.
 * @BOLT_STATUS_AUTHORIZED_NEWKEY: Device connected and authorized via a new key.
 *
 * The current status of the device.
 */
typedef enum {

  BOLT_STATUS_DISCONNECTED = 0,
  BOLT_STATUS_CONNECTED,
  BOLT_STATUS_AUTHORIZING,
  BOLT_STATUS_AUTH_ERROR,
  BOLT_STATUS_AUTHORIZED,
  BOLT_STATUS_AUTHORIZED_SECURE,
  BOLT_STATUS_AUTHORIZED_NEWKEY,

48
49
  BOLT_STATUS_LAST,
  BOLT_STATUS_INVALID = BOLT_STATUS_LAST
50
51
52

} BoltStatus;

53
const char *     bolt_status_to_string (BoltStatus status);
54
gboolean         bolt_status_is_authorized (BoltStatus status);
55
gboolean         bolt_status_is_connected (BoltStatus status);
56
gboolean         bolt_status_validate (BoltStatus status);
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
 * BoltKeyState:
 * @BOLT_KEY_MISSING: no key
 * @BOLT_KEY_HAVE: key exists
 * @BOLT_KEY_NEW: key is new
 *
 * The state of the key.
 */

typedef enum {

  BOLT_KEY_MISSING = 0,
  BOLT_KEY_HAVE = 1,
  BOLT_KEY_NEW = 2

} BoltKeyState;

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
 * BoltSecurity:
 * @BOLT_SECURITY_UNKNOWN : Unknown security.
 * @BOLT_SECURITY_NONE    : No security, all devices are automatically connected.
 * @BOLT_SECURITY_DPONLY  : Display Port only devices only.
 * @BOLT_SECURITY_USER    : User needs to authorize devices.
 * @BOLT_SECURITY_SECURE  : User needs to authorize devices. Authorization can
 *     be done via key exchange to verify the device identity.
 *
 * The security level of the thunderbolt domain.
 */
typedef enum {

  BOLT_SECURITY_NONE = 0,
  BOLT_SECURITY_DPONLY = 1,
  BOLT_SECURITY_USER = '1',
91
92
93
94
  BOLT_SECURITY_SECURE = '2',

  BOLT_SECURITY_LAST,
  BOLT_SECURITY_INVALID = BOLT_SECURITY_LAST
95
96
97
98
99
100

} BoltSecurity;


BoltSecurity     bolt_security_from_string (const char *str);
const char *     bolt_security_to_string (BoltSecurity security);
101
gboolean         bolt_security_validate (BoltSecurity security);
102
103
104
105

/**
 * BoltPolicy:
 * @BOLT_POLICY_DEFAULT: Default policy.
106
 * @BOLT_POLICY_MANUAL: Manual authorization of the device.
107
108
109
110
111
112
113
114
115
 * @BOLT_POLICY_AUTO: Connect the device automatically,
 *   with the best possible security level supported
 *   by the domain controller.
 *
 * What do to for connected devices.
 */
typedef enum {

  BOLT_POLICY_DEFAULT = 0,
116
117
  BOLT_POLICY_MANUAL = 1,
  BOLT_POLICY_AUTO = 2,
118

119
120
  BOLT_POLICY_LAST,
  BOLT_POLICY_INVALID = BOLT_POLICY_LAST
121
122
123
124
125
126

} BoltPolicy;


BoltPolicy       bolt_policy_from_string (const char *str);
const char *     bolt_policy_to_string (BoltPolicy policy);
127
gboolean         bolt_policy_validate (BoltPolicy policy);
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

/**
 * BoltAuthFlags:
 * @BOLT_AUTH_NONE: No flags set.
 *
 * Control authorization.
 */
typedef enum {

  BOLT_AUTH_NONE,

  BOLT_AUTH_FLAGS_LAST,
  BOLT_AUTH_FLAGS_INVALID = BOLT_AUTH_FLAGS_LAST

} BoltAuthFlags;
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

/**
 * BoltDeviceType:
 * @BOLT_DEVICE_HOST: The device representing the host
 * @BOLT_DEVICE_PERIPHERAL: A generic thunderbolt peripheral
 *
 * The type of the device.
 */
typedef enum {

  BOLT_DEVICE_HOST,
  BOLT_DEVICE_PERIPHERAL,

  BOLT_DEVICE_TYPE_LAST,
  BOLT_DEVICE_TYPE_INVALID = BOLT_DEVICE_TYPE_LAST

} BoltDeviceType;

BoltDeviceType   bolt_device_type_from_string (const char *str);
const char *     bolt_device_type_to_string (BoltDeviceType type);
gboolean         bolt_device_type_validate (BoltDeviceType type);
gboolean         bolt_device_type_is_host (BoltDeviceType type);