cddl 0.8.1 → 0.8.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,181 @@
1
+ start = bundle / #6.55799(bundle)
2
+
3
+ ; Times before 2000 are invalid
4
+ dtn-time = uint
5
+
6
+ ; CRC enumerated type
7
+ crc-type = 0 / 1 / 2
8
+ ; Either 16-bit or 32-bit
9
+ crc-value = (bstr .size 2) / (bstr .size 4)
10
+
11
+ creation-timestamp = [dtn-time, sequence: uint]
12
+
13
+ eid = $eid-choice .within eid-structure
14
+ eid-structure = [
15
+ uri-code: uint,
16
+ SSP: any
17
+ ]
18
+ $eid-choice /= [
19
+ uri-code: 1,
20
+ SSP: (tstr / 0)
21
+ ]
22
+ $eid-choice /= [
23
+ uri-code: 2,
24
+ SSP: [
25
+ nodenum: uint,
26
+ servicenum: uint
27
+ ]
28
+ ]
29
+
30
+ bundle-control-flags = uint .bits bundleflagbits
31
+ bundleflagbits = &(
32
+ reserved: 15
33
+ reserved: 14
34
+ reserved: 13
35
+ bundle-deletion-status-reports-are-requested: 12
36
+ bundle-delivery-status-reports-are-requested: 11
37
+ bundle-forwarding-status-reports-are-requested: 10
38
+ reserved: 9
39
+ bundle-reception-status-reports-are-requested: 8
40
+ bundle-contains-a-Manifest-block: 7
41
+ status-time-is-requested-in-all-status-reports: 6
42
+ user-application-acknowledgement-is-requested: 5
43
+ reserved: 4
44
+ reserved: 3
45
+ bundle-must-not-be-fragmented: 2
46
+ payload-is-an-administrative-record: 1
47
+ bundle-is-a-fragment: 0
48
+ )
49
+
50
+ block-control-flags = uint .bits blockflagbits
51
+ blockflagbits = &(
52
+ reserved: 7
53
+ reserved: 6
54
+ reserved: 5
55
+ reserved: 4
56
+ bundle-must-be-deleted-if-block-cannot-be-processed: 3
57
+ status-report-must-be-transmitted-if-block-cannot-be-processed: 2
58
+ block-must-be-removed-from-bundle-if-it-cannot-be-processed: 1
59
+ block-must-be-replicated-in-every-fragment: 0
60
+ )
61
+
62
+ bundle = [primary-block, *extension-block, payload-block]
63
+
64
+ primary-block = [
65
+ version: 7,
66
+ bundle-control-flags,
67
+ crc-type,
68
+ destination: eid,
69
+ source-node: eid,
70
+ report-to: eid,
71
+ creation-timestamp,
72
+ lifetime: uint,
73
+ ? (
74
+ fragment-offset: uint,
75
+ ; total-application-data-length: uint,
76
+ )
77
+ ? crc-value,
78
+ ]
79
+
80
+ ; Abstract shared structure of all non-primary blocks
81
+ canonical-block-structure = [
82
+ block-type-code: uint,
83
+ block-number: uint,
84
+ block-control-flags,
85
+ crc-type,
86
+ ; Each block type defines the content within the bytestring
87
+ block-type-specific-data,
88
+ ? crc-value
89
+ ]
90
+ block-type-specific-data = bstr / #6.24(bstr)
91
+ ; Extension block type, which does not specialize any more than the code/number
92
+ extension-block = $extension-block-structure .within canonical-block-structure
93
+ $extension-block-structure = [
94
+ block-type-code: (uint .gt 1),
95
+ extension-block-number,
96
+ block-control-flags,
97
+ crc-type,
98
+ ($extension-block-data .within block-type-specific-data)
99
+ ? crc-value
100
+ ]
101
+ extension-block-number = (uint .ne 0)
102
+ ; Payload block type
103
+ payload-block = payload-block-structure .within canonical-block-structure
104
+ payload-block-structure = [
105
+ block-type-code: 1,
106
+ block-number: 0,
107
+ block-control-flags,
108
+ crc-type,
109
+ ($payload-block-data .within block-type-specific-data)
110
+ ? crc-value
111
+ ]
112
+
113
+ ; Arbitrary payload data
114
+ $payload-block-data /= bstr
115
+
116
+
117
+ ; Administrative record as a payload data specialization
118
+ $payload-block-data /= block-type-specific-data .cbor admin-record
119
+ admin-record = $admin-record .within admin-record-structure
120
+ admin-record-structure = [
121
+ record-type-code: uint,
122
+ record-content: any
123
+ ]
124
+ ; Only one defined record type
125
+ $admin-record /= [1, status-record-content]
126
+ status-record-content = [
127
+ bundle-status-information,
128
+ status-report-reason-code: uint,
129
+ source-node-eid: eid,
130
+ subject-creation-timestamp: creation-timestamp,
131
+ ? (
132
+ subject-payload-offset: uint,
133
+ subject-payload-length: uint
134
+ )
135
+ ]
136
+ bundle-status-information = [
137
+ reporting-node-received-bundle: status-info-content,
138
+ reporting-node-forwarded-bundle: status-info-content,
139
+ reporting-node-delivered-bundle: status-info-content,
140
+ reporting-node-deleted-bundle: status-info-content
141
+ ]
142
+ status-info-content = [
143
+ status-indicator: bool,
144
+ ? timestamp: dtn-time
145
+ ]
146
+
147
+ ; Previous Node extension block
148
+ $extension-block-structure /= [
149
+ block-type-code: 7,
150
+ extension-block-number,
151
+ block-control-flags,
152
+ crc-type,
153
+ (block-type-specific-data .cbor ext-data-previous-node)
154
+ ? crc-value
155
+ ]
156
+ ext-data-previous-node = eid
157
+
158
+ ; Bundle Age extension block
159
+ $extension-block-structure /= [
160
+ block-type-code: 8,
161
+ extension-block-number,
162
+ block-control-flags,
163
+ crc-type,
164
+ (block-type-specific-data .cbor ext-data-bundle-age)
165
+ ? crc-value
166
+ ]
167
+ ext-data-bundle-age = uint
168
+
169
+ ; Hop Count extension block
170
+ $extension-block-structure /= [
171
+ block-type-code: 9,
172
+ extension-block-number,
173
+ block-control-flags,
174
+ crc-type,
175
+ (block-type-specific-data .cbor ext-data-hop-count)
176
+ ? crc-value
177
+ ]
178
+ ext-data-hop-count = [
179
+ hop-limit: uint,
180
+ hop-count: uint
181
+ ]
@@ -0,0 +1,167 @@
1
+ start = bundle / #6.55799(bundle)
2
+
3
+ ; Times before 2000 are invalid
4
+ dtn-time = uint
5
+
6
+ ; CRC enumerated type
7
+ crc-type = 0 / 1 / 2
8
+ ; Either 16-bit or 32-bit
9
+ crc-value = (bstr .size 2) / (bstr .size 4)
10
+
11
+ creation-timestamp = [dtn-time, sequence: uint]
12
+
13
+ eid = $eid-choice .within eid-structure
14
+ eid-structure = [
15
+ uri-code: uint,
16
+ SSP: any
17
+ ]
18
+ $eid-choice /= [
19
+ uri-code: 1,
20
+ SSP: (tstr / 0)
21
+ ]
22
+ $eid-choice /= [
23
+ uri-code: 2,
24
+ SSP: [
25
+ nodenum: uint,
26
+ servicenum: uint
27
+ ]
28
+ ]
29
+
30
+ ; The root bundle array
31
+ bundle = [primary-block, *extension-block, payload-block]
32
+
33
+ primary-block = [
34
+ version: 7,
35
+ bundle-control-flags,
36
+ crc-type,
37
+ destination: eid,
38
+ source-node: eid,
39
+ report-to: eid,
40
+ creation-timestamp,
41
+ lifetime: uint,
42
+ ? (
43
+ fragment-offset: uint,
44
+ total-application-data-length: uint,
45
+ )
46
+ ? crc-value,
47
+ ]
48
+ bundle-control-flags = uint .bits bundleflagbits
49
+ bundleflagbits = &(
50
+ reserved: 15,
51
+ reserved: 14,
52
+ reserved: 13,
53
+ bundle-deletion-status-reports-are-requested: 12,
54
+ bundle-delivery-status-reports-are-requested: 11,
55
+ bundle-forwarding-status-reports-are-requested: 10,
56
+ reserved: 9,
57
+ bundle-reception-status-reports-are-requested: 8,
58
+ bundle-contains-a-Manifest-block: 7,
59
+ status-time-is-requested-in-all-status-reports: 6,
60
+ user-application-acknowledgement-is-requested: 5,
61
+ reserved: 4,
62
+ reserved: 3,
63
+ bundle-must-not-be-fragmented: 2,
64
+ payload-is-an-administrative-record: 1,
65
+ bundle-is-a-fragment: 0
66
+ )
67
+
68
+ ; Abstract shared structure of all non-primary blocks
69
+ canonical-block-structure = [
70
+ block-type-code: uint,
71
+ block-number: uint,
72
+ block-control-flags,
73
+ crc-type,
74
+ ; Each block type defines the content within the bytestring
75
+ block-type-specific-data,
76
+ ? crc-value
77
+ ]
78
+ block-control-flags = uint .bits blockflagbits
79
+ blockflagbits = &(
80
+ reserved: 7,
81
+ reserved: 6,
82
+ reserved: 5,
83
+ reserved: 4,
84
+ bundle-must-be-deleted-if-block-cannot-be-processed: 3,
85
+ status-report-must-be-transmitted-if-block-cannot-be-processed: 2,
86
+ block-must-be-removed-from-bundle-if-it-cannot-be-processed: 1,
87
+ block-must-be-replicated-in-every-fragment: 0
88
+ )
89
+ block-type-specific-data = bstr / #6.24(bstr)
90
+ ; Actual CBOR data embedded in a bytestring, with optional tag to indicate so
91
+ embedded-cbor<Item> = (bstr .cbor Item) / #6.24(bstr .cbor Item)
92
+
93
+ ; Extension block type, which does not specialize other than the code/number
94
+ extension-block = $extension-block-structure .within canonical-block-structure
95
+ ; Generic shared structure of all non-primary blocks
96
+ extension-block-use<CodeValue, BlockData> = [
97
+ block-type-code: CodeValue,
98
+ block-number: (uint .ne 0),
99
+ block-control-flags,
100
+ crc-type,
101
+ BlockData,
102
+ ? crc-value
103
+ ]
104
+
105
+ ; Payload block type
106
+ payload-block = payload-block-structure .within canonical-block-structure
107
+ payload-block-structure = [
108
+ block-type-code: 1,
109
+ block-number: 0,
110
+ block-control-flags,
111
+ crc-type,
112
+ $payload-block-data,
113
+ ? crc-value
114
+ ]
115
+
116
+ ; Arbitrary payload data, including non-CBOR bytestring
117
+ $payload-block-data /= block-type-specific-data
118
+
119
+
120
+ ; Administrative record as a payload data specialization
121
+ $payload-block-data /= embedded-cbor<admin-record>
122
+ admin-record = $admin-record .within admin-record-structure
123
+ admin-record-structure = [
124
+ record-type-code: uint,
125
+ record-content: any
126
+ ]
127
+ ; Only one defined record type
128
+ $admin-record /= [1, status-record-content]
129
+ status-record-content = [
130
+ bundle-status-information,
131
+ status-report-reason-code: uint,
132
+ source-node-eid: eid,
133
+ subject-creation-timestamp: creation-timestamp,
134
+ ? (
135
+ subject-payload-offset: uint,
136
+ subject-payload-length: uint
137
+ )
138
+ ]
139
+ bundle-status-information = [
140
+ reporting-node-received-bundle: status-info-content,
141
+ reporting-node-forwarded-bundle: status-info-content,
142
+ reporting-node-delivered-bundle: status-info-content,
143
+ reporting-node-deleted-bundle: status-info-content
144
+ ]
145
+ status-info-content = [
146
+ status-indicator: bool,
147
+ ? timestamp: dtn-time
148
+ ]
149
+
150
+
151
+ ; Previous Node extension block
152
+ $extension-block-structure /=
153
+ extension-block-use<7, embedded-cbor<ext-data-previous-node>>
154
+ ext-data-previous-node = eid
155
+
156
+ ; Bundle Age extension block
157
+ $extension-block-structure /=
158
+ extension-block-use<8, embedded-cbor<ext-data-bundle-age>>
159
+ ext-data-bundle-age = uint
160
+
161
+ ; Hop Count extension block
162
+ $extension-block-structure /=
163
+ extension-block-use<9, embedded-cbor<ext-data-hop-count>>
164
+ ext-data-hop-count = [
165
+ hop-limit: uint,
166
+ hop-count: uint
167
+ ]
@@ -0,0 +1,10 @@
1
+ coral = [+ s-exp]
2
+ s-exp = ((text, value, ?coral) // directive)
3
+ value = ctext / cbytes / cint / cfloat / cboolean / cdatetime / null / {"_link": tstr} / {"_form": tstr}
4
+ ctext = text / {"_text": text}
5
+ cint = {"_int": int}
6
+ cfloat = float / {"_float": float}
7
+ cboolean = bool / {"_bool": bool}
8
+ cdatetime = {"_datetime": text}
9
+ cbytes = {"_bytes": text} ; base64url no padding
10
+ directive = (("_using", {* text => text}) // ("_base", text))
@@ -0,0 +1,5 @@
1
+ document = {*element}
2
+ element = (relation => value / [2*value])
3
+
4
+ relation = text
5
+ value = text
@@ -0,0 +1,7 @@
1
+ document = {*element}
2
+ element = (text => value / [2*value])
3
+ value = text / float / bool / tagged
4
+ tagged = {"_int":int,*element} / {"_float":float,*element} / {"_text":text,*element} / {"_bytes":bytes,*element} / {"_datetime":text,*element} / {"_bool":bool,*element} / {"_link":ciri,*element} / {"_form":ciri,*element}
5
+ ciri = text ; full IRI given
6
+ / [text] ; suffix for default prefix
7
+ / [text, text] ; prefix, suffix for that prefix
@@ -0,0 +1,7 @@
1
+ document = {? ("_using" => {* text => text}), *element}
2
+ element = (text => value / [2*value])
3
+ value = text / float / bool / tagged / {*element}
4
+ tagged = {"_int": int, *element} / {"_float": float, *element} / {"_text": text, *element} / {"_bytes": bytes, *element} / {"_datetime": text, *element} / {"_bool": bool, *element} / {"_link": ciri, *element} / {"_form": ciri, *element}
5
+ ciri = text ; full IRI given
6
+ / [text] ; suffix for default prefix
7
+ / [text, text] ; prefix, suffix for that prefix
@@ -0,0 +1,7 @@
1
+ foo = [a, b, c]
2
+
3
+ a = uint .size 4
4
+
5
+ b = bytes .size 4
6
+
7
+ c = text .size (0..30)
@@ -0,0 +1,4 @@
1
+ bla = {
2
+ a: int
3
+ ? ("b" .feature "foo") => float
4
+ }
@@ -0,0 +1 @@
1
+ foo=bar=int
@@ -0,0 +1,108 @@
1
+ grasp-message = (message .within message-structure) / noop-message
2
+
3
+ message-structure = [MESSAGE_TYPE, session-id, ?initiator,
4
+ *grasp-option]
5
+
6
+ MESSAGE_TYPE = 0..255
7
+ session-id = 0..4294967295 ;up to 32 bits
8
+ grasp-option = any
9
+
10
+ message /= discovery-message
11
+ discovery-message = [M_DISCOVERY, session-id, initiator, objective]
12
+
13
+ message /= response-message ;response to Discovery
14
+ response-message = [M_RESPONSE, session-id, initiator, ttl,
15
+ (+locator-option // divert-option), ?objective]
16
+
17
+ message /= synch-message ;response to Synchronization request
18
+ synch-message = [M_SYNCH, session-id, objective]
19
+
20
+ message /= flood-message
21
+ flood-message = [M_FLOOD, session-id, initiator, ttl,
22
+ +[objective, (locator-option / [])]]
23
+
24
+ message /= request-negotiation-message
25
+ request-negotiation-message = [M_REQ_NEG, session-id, objective]
26
+
27
+ message /= request-synchronization-message
28
+ request-synchronization-message = [M_REQ_SYN, session-id, objective]
29
+
30
+ message /= negotiation-message
31
+ negotiation-message = [M_NEGOTIATE, session-id, objective]
32
+
33
+ message /= end-message
34
+ end-message = [M_END, session-id, accept-option / decline-option ]
35
+
36
+ message /= wait-message
37
+ wait-message = [M_WAIT, session-id, waiting-time]
38
+
39
+ message /= invalid-message
40
+ invalid-message = [M_INVALID, session-id, ?any]
41
+
42
+ noop-message = [M_NOOP]
43
+
44
+ divert-option = [O_DIVERT, +locator-option]
45
+
46
+ accept-option = [O_ACCEPT]
47
+
48
+ decline-option = [O_DECLINE, ?reason]
49
+ reason = text ;optional error message
50
+
51
+ waiting-time = 0..4294967295 ; in milliseconds
52
+ ttl = 0..4294967295 ; in milliseconds
53
+
54
+ locator-option /= [O_IPv4_LOCATOR, ipv4-address,
55
+ transport-proto, port-number]
56
+ ipv4-address = bytes .size 4
57
+
58
+ locator-option /= [O_IPv6_LOCATOR, ipv6-address,
59
+ transport-proto, port-number]
60
+ ipv6-address = bytes .size 16
61
+
62
+ locator-option /= [O_FQDN_LOCATOR, text, transport-proto, port-number]
63
+
64
+ transport-proto = IPPROTO_TCP / IPPROTO_UDP
65
+ IPPROTO_TCP = 6
66
+ IPPROTO_UDP = 17
67
+ port-number = 0..65535
68
+
69
+ locator-option /= [O_URI_LOCATOR, text]
70
+
71
+ initiator = ipv4-address / ipv6-address
72
+
73
+ objective-flags = uint .bits objective-flag
74
+
75
+ objective-flag = &(
76
+ F_DISC: 0 ; valid for discovery
77
+ F_NEG: 1 ; valid for negotiation
78
+ F_SYNCH: 2 ; valid for synchronization
79
+ F_NEG_DRY: 3 ; negotiation is dry-run
80
+ )
81
+
82
+ objective = [objective-name, objective-flags, loop-count, ?any]
83
+
84
+ objective-name = text ;see specification for uniqueness rules
85
+
86
+ loop-count = 0..255
87
+
88
+ ; Constants for message types and option types
89
+
90
+ M_NOOP = 0
91
+ M_DISCOVERY = 1
92
+ M_RESPONSE = 2
93
+ M_REQ_NEG = 3
94
+ M_REQ_SYN = 4
95
+ M_NEGOTIATE = 5
96
+ M_END = 6
97
+ M_WAIT = 7
98
+ M_SYNCH = 8
99
+ M_FLOOD = 9
100
+ M_INVALID = 99
101
+
102
+ O_DIVERT = 100
103
+ O_ACCEPT = 101
104
+ O_DECLINE = 102
105
+ O_IPv6_LOCATOR = 103
106
+ O_IPv4_LOCATOR = 104
107
+ O_FQDN_LOCATOR = 105
108
+ O_URI_LOCATOR = 106
@@ -0,0 +1,11 @@
1
+
2
+ map-example = {
3
+ ? optional-key : int,
4
+ * map-example-extension,
5
+ * tstr => any
6
+ }
7
+
8
+ map-example-extension = ()
9
+
10
+ map-example-extension //= (another-optional-key : tstr,)
11
+ map-example-extension //= ("and a third" : bstr,)
@@ -0,0 +1,12 @@
1
+ map-example = {
2
+ ? "optional-key" : int,
3
+ map-example-extensions,
4
+ * tstr => any
5
+ }
6
+
7
+ map-example-extensions = ()
8
+
9
+ map-example-extensions //= (
10
+ "another-optional-key" : tstr,
11
+ "and a third": bstr
12
+ )