-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathStream.asn
191 lines (148 loc) · 4.09 KB
/
Stream.asn
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
Stream
DEFINITIONS
AUTOMATIC TAGS ::=
BEGIN
IMPORTS
UInt8,
UInt96,
UInt128,
VarUInt,
VarBytes
FROM GenericTypes
Address
FROM InterledgerTypes
Receipt
FROM StreamReceipt
;
StreamEncryptionEnvelope ::= SEQUENCE {
-- Random nonce
initializationVector UInt96,
-- Authentication tag (output of AES-GCM encryption)
authenticationTag UInt128,
-- Encrypted STREAM Packet
-- Note: This is NOT encoded as a variable length (length-prefixed)
-- octet string. The size is constrained by the length of the data
-- field in the InterledgerPrepare, InterledgerFulfill, or InterledgerReject
-- packet containing this StreamEncryptionEnvelope
cipherText OCTET STRING (SIZE (0..32739))
}
StreamPacket ::= SEQUENCE {
-- Always 1 for now
version UInt8,
-- ILP Packet type this STREAM packet must be carried upon
ilpPacketType UInt8,
-- Packet ID
sequence VarUInt,
-- If attached to a Prepare packet, minimum amount that the receiver should accept
-- If attached to a Fulfill or Reject packet, amount that arrived at the receiver
prepareAmount VarUInt,
-- Array of Frames
frames SEQUENCE OF StreamFrame
}
FRAME ::= CLASS {
&typeId UInt8 UNIQUE,
&Type
} WITH SYNTAX {&typeId &Type}
FrameSet FRAME ::= {
{1 ConnectionError} |
{2 ConnectionNewAddress} |
{3 ConnectionMaxData} |
{4 ConnectionDataBlocked} |
{5 ConnectionMaxStreamId} |
{6 ConnectionStreamIdBlocked} |
{16 StreamClose} |
{17 StreamMoney} |
{18 StreamMaxMoney} |
{19 StreamMoneyBlocked} |
{20 StreamData} |
{21 StreamMaxData} |
{22 StreamDataBlocked} |
{23 StreamReceipt}
}
StreamFrame ::= SEQUENCE {
type FRAME.&typeId ({FrameSet}),
data FRAME.&Type ({FrameSet}{@type})
}
ConnectionError ::= SEQUENCE {
-- Numeric error code
code UInt8,
-- Human-readable error message
message UTF8String
}
ConnectionNewAddress ::= SEQUENCE {
-- ILP Address of the party that sends the frame
address Address
}
ConnectionMaxData ::= SEQUENCE {
maxOffset VarUInt
}
ConnectionDataBlocked ::= SEQUENCE {
maxOffset VarUInt
}
ConnectionMaxStreamId ::= SEQUENCE {
maxStreamId VarUInt
}
ConnectionStreamIdBlocked ::= SEQUENCE {
maxStreamId VarUInt
}
StreamClose ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- Numeric error code
code UInt8,
-- Human-readable error message
message UTF8String
}
StreamMoney ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- The proportion of the Prepare amount that should go to this stream
-- i.e. the amount for a given stream = prepare amount * shares / (sum of shares from all StreamMoney frames in the packet)
shares VarUInt
}
StreamMaxMoney ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- Maximum amount the stream can receive
receiveMax VarUInt,
-- Total amount the stream has received so far
totalReceived VarUInt
}
StreamMoneyBlocked ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- Maximum amount the stream can send
sendMax VarUInt,
-- Total amount the stream has sent so far
totalSent VarUInt
}
StreamData ::= SEQUENCE {
-- Identifier of the DataStream
streamId VarUInt,
-- Byte number of the first byte in this frame within the whole DataStream
-- (the first StreamData frame sent for a given DataStream will have an offset of 0)
offset VarUInt,
-- Application data
data VarBytes
}
StreamMaxData ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- Maximum number of bytes the endpoint is willing to receive on this stream
maxOffset VarUInt
}
StreamDataBlocked ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- Maximum number of bytes the endpoint wants to send on this stream
maxOffset VarUInt
}
StreamReceipt ::= SEQUENCE {
-- Identifier of the stream
streamId VarUInt,
-- Length-prefixed Receipt for verifying the total amount received on this stream
-- The sender is not expected to decode the Receipt fields but must be able to decode the
-- receipt string in the frame, even if it represents an unsupported Receipt version
receipt Receipt
}
END