cddl 0.8.8 → 0.8.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c877883cb125426e061f527ba4375c0f021d70dfef060336fe0bb0f5e2ca3d4
4
- data.tar.gz: 7a3dc4065f3616bf57c229b410782b35140018ecada4418c0ef45056c62aef0b
3
+ metadata.gz: 3c83003981d07eae336683b02bebaa0340f56941724ed6f91d89c6b8baf8f234
4
+ data.tar.gz: bf5e14489fd50c0b14bd27a99f11c3a35c046ed8113764094d8fc6a7ef4ff0d8
5
5
  SHA512:
6
- metadata.gz: b3987fbe82e80dddba2f650b1a12941ed6092708297302cf1a78dfe45b20b79d08e85901cb8739b5fc79eab8cde70ca8efb88698f4340da72c722a7a461565c6
7
- data.tar.gz: 68c35688bac9b30411ee419e171860c463df28c3452bce1741399274e51295b609e0acc8df54e9876037f9d96ba02e369fd9465c2fe7c38bb9682d5ec19018cd
6
+ metadata.gz: 74f3d9b8cb2f1c188aff29fe9e8dcc3496cb978063e67e7a84932cbe7045163529586547836747237f8f5451b2ffaeaf550165df5aea3003ee9a31c882408488
7
+ data.tar.gz: b021259524e95100b668a5b335adf85c714f73fbf4b22fd2cd7a84dcc9ea35c227401339c8a40a06f8e46e77d77fa19d2d0240fef60f89703eb66cff0f31ebf1
data/cddl.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'cddl'
3
- s.version = '0.8.8'
3
+ s.version = '0.8.10'
4
4
  s.summary = "CDDL generator and validator."
5
5
  s.description = %{A parser, generator, and validator for CDDL}
6
6
  s.add_dependency('cbor-diag')
@@ -19,3 +19,4 @@ spec = Gem::Specification.new do |s|
19
19
  s.homepage = "http://github.com/cabo/cddl"
20
20
  s.license = 'MIT'
21
21
  end
22
+
data/lib/cddl.rb CHANGED
@@ -329,8 +329,12 @@ module CDDL
329
329
  unless kr
330
330
  case vr[0]
331
331
  when :grpent
332
- fail "grpent in map #{vr.inspect}" unless vr.size == 2
333
- g = Array.new(st) { generate1(vr[1], true) }.flatten(1)
332
+ # fail "grpent in map #{vr.inspect}" unless vr.size == 2
333
+ g = Array.new(st) {
334
+ vr[1..-1].map{ |vrx|
335
+ generate1(vrx, true)
336
+ }.flatten(1)
337
+ }.flatten(1)
334
338
  # warn "GGG #{g.inspect}"
335
339
  return g
336
340
  when :grpchoice
@@ -523,7 +527,7 @@ module CDDL
523
527
  end
524
528
  end
525
529
 
526
- VALUE_TYPE = {text: String, int: Integer, float: Float}
530
+ VALUE_TYPE = {text: String, bytes: String, int: Integer, float: Float}
527
531
  SIMPLE_VALUE = {
528
532
  [:prim, 7, 20] => [true, false, :bool],
529
533
  [:prim, 7, 21] => [true, true, :bool],
@@ -552,6 +556,7 @@ module CDDL
552
556
  if warn
553
557
  warn "CDDL validation failure (#{result.inspect} for #{d.inspect}):"
554
558
  PP::pp(validate_diag, STDERR)
559
+ puts(validate_diag.cbor_diagnostic)
555
560
  end
556
561
  end
557
562
  result
@@ -741,9 +746,12 @@ module CDDL
741
746
  idx, ann = validate_forward(d, 0, where)
742
747
  ann if validate_result(idx == d.size) { "#{validate_diag.inspect} -- cannot complete (#{idx}, #{d.size}) array #{d} for #{where}" }
743
748
  end
744
- when :text, :int, :float, :bytes
749
+ when :int, :float
745
750
  _, v = extract_value(where)
746
751
  [] if d == v
752
+ when :text, :bytes
753
+ _, v = extract_value(where)
754
+ [] if d == v && ((d.encoding == Encoding::BINARY) == (v.encoding == Encoding::BINARY))
747
755
  when :range
748
756
  [] if where[2] === d && where[1].include?(d)
749
757
  when :anno
@@ -837,6 +845,14 @@ module CDDL
837
845
  when 3
838
846
  String === d && d.encoding != Encoding::BINARY # cheat
839
847
  when 6
848
+ if Integer === d
849
+ t = 2 # assuming only 2/3 match an Integer
850
+ if d < 0
851
+ d = ~d
852
+ t = 3
853
+ end
854
+ d = CBOR::Tagged.new(t, d == 0 ? "".b : d.digits(256).reverse!.pack("C*"))
855
+ end
840
856
  CBOR::Tagged === d && d.tag == where[2] && validate1a(d.data, where[3])
841
857
  when 7
842
858
  t, v = extract_value(where)
@@ -959,7 +975,7 @@ module CDDL
959
975
  when ""
960
976
  parts[1].b
961
977
  when "h"
962
- parts[1].gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join
978
+ parts[1].gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join.b
963
979
  when "b64"
964
980
  Base64.urlsafe_decode64(parts[1])
965
981
  else
@@ -1142,7 +1158,7 @@ module CDDL
1142
1158
  end
1143
1159
  when :recurse_grpent # XXX we don't have the entry yet
1144
1160
  when :member
1145
- fail "map entry without member key given: #{member}" unless member[3] || member[4][0] == :grpent || member[4][0] == :grpchoice
1161
+ fail "map entry #{member.inspect} without member key given: #{member}" unless member[3] || member[4][0] == :grpent || member[4][0] == :grpchoice
1146
1162
  else
1147
1163
  fail ["type1 member", member].inspect unless member[0] == :member
1148
1164
  end
data/test/test-cddl.rb CHANGED
@@ -171,6 +171,57 @@ HERE
171
171
  assert parser.validate_for_test(true)
172
172
  end
173
173
 
174
+ def test_validate_bignum
175
+ parser = CDDL::Parser.new <<HERE
176
+ test = bigint
177
+ HERE
178
+ assert parser.validate_for_test(2**4711)
179
+ assert parser.validate_for_test(-2**815)
180
+ assert parser.validate_for_test(1)
181
+ assert parser.validate_for_test(0)
182
+ assert parser.validate_for_test(-11)
183
+ end
184
+
185
+ def test_aaaaaaaa_invalidate_bignum
186
+ parser = CDDL::Parser.new <<HERE
187
+ test = bignint
188
+ HERE
189
+ refute parser.validate_for_test(2**4711, false)
190
+ assert parser.validate_for_test(-2**815)
191
+ refute parser.validate_for_test(1, false)
192
+ refute parser.validate_for_test(0, false)
193
+ assert parser.validate_for_test(-11)
194
+ end
195
+
196
+
197
+ def test_aaaaaaaa_validate_bignum0b
198
+ parser = CDDL::Parser.new <<HERE
199
+ test = #6.2("")
200
+ HERE
201
+ refute parser.validate_for_test(1, false)
202
+ refute parser.validate_for_test(0, false)
203
+ end
204
+
205
+
206
+ def test_aaaaaaaa_validate_bignum0
207
+ parser = CDDL::Parser.new <<HERE
208
+ test = #6.2(h'')
209
+ HERE
210
+ assert parser.validate_for_test(0)
211
+ refute parser.validate_for_test(1, false)
212
+ end
213
+
214
+
215
+ def test_aaaaaaaa_validate_bignum1
216
+ parser = CDDL::Parser.new <<HERE
217
+ test = #6.2(h'01')
218
+ HERE
219
+ assert parser.validate_for_test(1)
220
+ refute parser.validate_for_test(0, false)
221
+ refute parser.validate_for_test(2, false)
222
+ end
223
+
224
+
174
225
  def test_validate_a
175
226
  parser = CDDL::Parser.new <<HERE
176
227
  test = [* one: 1]
@@ -0,0 +1,14 @@
1
+ coap-problem-details = {
2
+ type => uint,
3
+ ? title => text,
4
+ ? response-code => bstr .size 1,
5
+ ? detail => text,
6
+ ? instance => uri,
7
+ * $$coap-problem-details-extension,
8
+ }
9
+
10
+ type = 0
11
+ title = 1
12
+ response-code = 2
13
+ detail = 3
14
+ instance = 4
@@ -0,0 +1 @@
1
+ abignum = unsigned
@@ -0,0 +1,136 @@
1
+ start = bundle
2
+
3
+ dtn-time = uint
4
+
5
+ creation-timestamp = [dtn-time, sequence: uint]
6
+
7
+ eid-generic = [uri-code, SSP: any]
8
+
9
+ uri-code = uint
10
+
11
+ eid = eid-choice .within eid-generic
12
+
13
+ eid-choice /= [dtn-code, SSP: (text / 0)]
14
+
15
+ dtn-code = 1 ; TBD
16
+
17
+ eid-choice /= [ipn-code, SSP: [nodenum: uint, servicenum: uint]]
18
+
19
+ ipn-code = 2 ; TBD
20
+
21
+ bundle-control-flags = uint .bits bundleflagbits
22
+
23
+ bundleflagbits = &(
24
+
25
+ reserved: 15
26
+
27
+ reserved: 14
28
+
29
+ reserved: 13
30
+
31
+ bundle-deletion-status-reports-are-requested: 12
32
+
33
+ bundle-delivery-status-reports-are-requested: 11
34
+
35
+ bundle-forwarding-status-reports-are-requested: 10
36
+
37
+ reserved: 9
38
+
39
+ bundle-reception-status-reports-are-requested: 8
40
+
41
+ bundle-contains-a-Manifest-block: 7
42
+
43
+ status-time-is-requested-in-all-status-reports: 6
44
+
45
+ user-application-acknowledgement-is-requested: 5
46
+
47
+ reserved: 4
48
+
49
+ reserved: 3
50
+
51
+ bundle-must-not-be-fragmented: 2
52
+
53
+ payload-is-an-administrative-record: 1
54
+
55
+ bundle-is-a-fragment: 0
56
+
57
+ )
58
+
59
+ crc = bytes
60
+
61
+ block-control-flags = uint .bits blockflagbits
62
+
63
+ blockflagbits = &(
64
+
65
+ reserved: 7
66
+
67
+ reserved: 6
68
+
69
+ reserved: 5
70
+
71
+ reserved: 4
72
+
73
+ bundle-must-be-deleted-if-block-cannot-be-processed: 3
74
+
75
+ status-report-must-be-transmitted-if-block-cannot-be-processed: 2
76
+
77
+ block-must-be-removed-from-bundle-if-it-cannot-be-processed: 1
78
+
79
+ block-must-be-replicated-in-every-fragment: 0
80
+
81
+ )
82
+
83
+ bundle = [primary-block, *extension-block, payload-block]
84
+
85
+ primary-block = [
86
+
87
+ version: 7,
88
+
89
+ bundle-control-flags,
90
+
91
+ crc-type: uint,
92
+
93
+ destination: eid,
94
+
95
+ source-node: eid,
96
+
97
+ report-to: eid,
98
+
99
+ creation-timestamp,
100
+
101
+ lifetime: uint,
102
+
103
+ ? fragment-offset: uint,
104
+
105
+ ? total-application-data-length: uint,
106
+
107
+ ? crc,
108
+
109
+ ]
110
+
111
+ canonical-block = [
112
+
113
+ block-type-code: uint,
114
+
115
+ canonical-block-common,
116
+
117
+ ? crc
118
+
119
+ ]
120
+
121
+ canonical-block-common = (
122
+
123
+ block-number: uint,
124
+
125
+ block-control-flags,
126
+
127
+ crc-type: uint,
128
+
129
+ block-type-specific-data: bytes
130
+
131
+ )
132
+
133
+
134
+ payload-block = ([block-type-code: 1, canonical-block-common, ?crc]) .within canonical-block
135
+
136
+ extension-block = ([block-type-code: (uint .ne 1), canonical-block-common, ?crc]) .within canonical-block
@@ -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 @@
1
+ foo=bar=int