forked from scionproto/scion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
225 lines (185 loc) · 5.26 KB
/
types.py
File metadata and controls
225 lines (185 loc) · 5.26 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Copyright 2015 ETH Zurich
# Copyright 2018 ETH Zurich, Anapaya Systems
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
:mod:`types` --- SCION types
============================
For all type classes that are used in multiple parts of the infrastructure.
"""
class TypeBase(object): # pragma: no cover
@classmethod
def to_str(cls, type_, error=False):
for attr in dir(cls):
if getattr(cls, attr) == type_:
return attr
if not error:
return "UNKNOWN (%s)" % type_
raise IndexError
@classmethod
def all(cls):
return [getattr(cls, attr) for attr in dir(cls) if
not attr.startswith("__") and
not callable(getattr(cls, attr))]
############################
# Basic types
############################
class AddrType(TypeBase):
NONE = 0
IPV4 = 1
IPV6 = 2
SVC = 3
############################
# Service types
############################
class ServiceType(TypeBase):
# these values must be kept in sync with the common.capnp ServiceType enum
#: Unset
UNSET = "unset"
#: Beacon service
BS = "bs"
#: Path service
PS = "ps"
#: Certificate service
CS = "cs"
#: SIBRA service
SIBRA = "sb"
#: Discovery service
DS = "ds"
#: Border router
BR = "br"
#: SCION-IP gateway
SIG = "sig"
class ExtensionClass(TypeBase):
"""
Constants for two types of extensions. These values are shared with L4
protocol values, and an appropriate value is placed in next_hdr type.
"""
HOP_BY_HOP = 0
END_TO_END = 222 # (Expected:-) number for SCION end2end extensions.
class ExtHopByHopType(TypeBase):
SCMP = 0
ONE_HOP_PATH = 1
SIBRA = 2
class ExtEndToEndType(TypeBase):
PATH_TRANSPORT = 0
PATH_PROBE = 1
SPSE = 2
class ASMExtType(TypeBase):
ROUTING_POLICY = 0
class RoutingPolType(TypeBase):
ALLOW_AS = 0
DENY_AS = 1
ALLOW_IF = 2
DENY_IF = 3
class L4Proto(TypeBase):
NONE = 0
SCMP = 1
TCP = 6
UDP = 17
L4 = SCMP, TCP, UDP
############################
# Payload class/types
############################
class PayloadClass(object):
ACK = "ack"
PCB = "pcb"
IFID = "ifid"
CERT = "certMgmt"
PATH = "pathMgmt"
SIBRA = "sibra"
DRKEY = "drkeyMgmt"
class CertMgmtType(object):
CERT_CHAIN_REQ = "certChainReq"
CERT_CHAIN_REPLY = "certChain"
TRC_REQ = "trcReq"
TRC_REPLY = "trc"
class PathMgmtType(object):
REQUEST = "segReq"
REPLY = "segReply"
# Path registration (sent by Beacon Server).
REG = "segReg"
# For records synchronization purposes (used by Path Servers).
SYNC = "segSync"
REVOCATION = "sRevInfo"
IFSTATE_REQ = "ifStateReq"
IFSTATE_INFOS = "ifStateInfos"
class PathSegmentType(TypeBase):
"""
PathSegmentType class, indicates a type of path request/reply.
"""
# XXX(kormat): these strings must match the values in the capnp enum.
UP = "up" # Request/Reply for up-paths
DOWN = "down" # Request/Reply for down-paths
CORE = "core" # Request/Reply for core-paths
class DRKeyMgmtType(object):
FIRST_ORDER_REQUEST = "drkeyReq"
FIRST_ORDER_REPLY = "drkeyRep"
############################
# Router types
############################
class RouterFlag(TypeBase):
ERROR = 0
NO_PROCESS = 1
# Process this locally
PROCESS_LOCAL = 2
# Forward packet to supplied IFID
FORWARD = 3
# Packet has reached its destination ISD-AS
DELIVER = 4
# Deliver packet even if it hasn't reached its destination ISD-AS
FORCE_DELIVER = 5
############################
# SIBRA types
############################
class SIBRAPathType(TypeBase):
STEADY = 0
EPHEMERAL = 1
############################
# Link types
############################
class LinkType(TypeBase):
# XXX(worxli): these values must be kept in sync with the capnp Linktype enum
UNSET = "unset"
#: Link to child AS
CHILD = "child"
#: Link to parent AS
PARENT = "parent"
#: Link to peer AS
PEER = "peer"
#: Link to other core AS
CORE = "core"
###########################
# SCIOND message types
###########################
class SCIONDMsgType(TypeBase):
UNSET = "unset"
PATH_REQUEST = "pathReq"
PATH_REPLY = "pathReply"
AS_REQUEST = "asInfoReq"
AS_REPLY = "asInfoReply"
REVOCATION = "revNotification"
REVOCATIONREPLY = "revReply"
IF_REQUEST = "ifInfoRequest"
IF_REPLY = "ifInfoReply"
SERVICE_REQUEST = "serviceInfoRequest"
SERVICE_REPLY = "serviceInfoReply"
DRKEY_REQUEST = "drkeyRequest"
DRKEY_REPLY = "drkeyReply"
SEGTYPEHOP_REQUEST = "segTypeHopReq"
SEGTYPEHOP_REPLY = "segTypeHopReply"
#######################
# Hash function types
#######################
class HashType(TypeBase):
SHA256 = 0