cddl 0.8.8 → 0.12.14

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cddl +51 -15
  3. data/cddl.gemspec +11 -7
  4. data/data/cddl.abnf +30 -13
  5. data/lib/cbor-pp-play.rb +1 -0
  6. data/lib/cddl.rb +726 -74
  7. data/test/test-cddl.rb +53 -2
  8. data/test-data/7807.cddl +14 -0
  9. data/test-data/abignum.cddl +1 -0
  10. data/test-data/abnf1.cddl +3 -0
  11. data/test-data/abnf2.cddl +37 -0
  12. data/test-data/abnf3.cddl +32 -0
  13. data/test-data/b64c-sloppy.cddl +1 -0
  14. data/test-data/b64c.cddl +1 -0
  15. data/test-data/b64u-strict.cddl +12 -0
  16. data/test-data/b64u.cddl +1 -0
  17. data/test-data/base32.cddl +1 -0
  18. data/test-data/base32hex.cddl +1 -0
  19. data/test-data/bat.cddl +16 -0
  20. data/test-data/bpv7.cddl +136 -0
  21. data/test-data/bpv7a.cddl +181 -0
  22. data/test-data/bpv7b.cddl +167 -0
  23. data/test-data/cat-re.cddl +4 -0
  24. data/test-data/catb64.cddl +8 -0
  25. data/test-data/complex-occ.cddl +11 -0
  26. data/test-data/coral.cddl +10 -0
  27. data/test-data/coral1.cddl +5 -0
  28. data/test-data/coral2.cddl +7 -0
  29. data/test-data/coral3.cddl +7 -0
  30. data/test-data/decimal-warn.cddl +1 -0
  31. data/test-data/decimal.cddl +1 -0
  32. data/test-data/decimal2.cddl +1 -0
  33. data/test-data/det1.cddl +12 -0
  34. data/test-data/dotplus1.cddl +3 -0
  35. data/test-data/dotplus2.cddl +3 -0
  36. data/test-data/dotplus3.cddl +3 -0
  37. data/test-data/dotplus4.cddl +3 -0
  38. data/test-data/enum.cddl +14 -0
  39. data/test-data/enum1.cddl +12 -0
  40. data/test-data/feat1.cddl +4 -0
  41. data/test-data/feature-controller.cddl +6 -0
  42. data/test-data/feature-detail.cddl +5 -0
  43. data/test-data/foo.cddl +1 -0
  44. data/test-data/hex.cddl +1 -0
  45. data/test-data/hexlc.cddl +1 -0
  46. data/test-data/hexuc.cddl +1 -0
  47. data/test-data/homenet-de.cddl +12 -0
  48. data/test-data/homenet-fe.cddl +12 -0
  49. data/test-data/jim-cut-2.cddl +11 -0
  50. data/test-data/jim-cut.cddl +12 -0
  51. data/test-data/join.cddl +1 -0
  52. data/test-data/joini.cddl +1 -0
  53. data/test-data/joinx.cddl +1 -0
  54. data/test-data/json.cddl +1 -0
  55. data/test-data/json1.cddl +15 -0
  56. data/test-data/json2.cddl +1 -0
  57. data/test-data/jsoniodef.cddl +719 -0
  58. data/test-data/jwt.cddl +15 -0
  59. data/test-data/lint1.cddl +9 -0
  60. data/test-data/mdl-ble.cddl +9 -0
  61. data/test-data/mdl-deve.cddl +54 -0
  62. data/test-data/mdl-dp.cddl +11 -0
  63. data/test-data/mdl-mso.cddl +20 -0
  64. data/test-data/mdl-request.cddl +26 -0
  65. data/test-data/mdl-response.cddl +66 -0
  66. data/test-data/mdl.cddl +11 -0
  67. data/test-data/mon-val.cddl +1 -0
  68. data/test-data/multipart-ct.cddl +2 -0
  69. data/test-data/named-group.cddl +7 -0
  70. data/test-data/non-empty.cddl +5 -0
  71. data/test-data/oid.cddl +8 -0
  72. data/test-data/oidbat.cddl +8 -0
  73. data/test-data/plus.cddl +3 -0
  74. data/test-data/prim.cddl +7 -0
  75. data/test-data/printf.cddl +2 -0
  76. data/test-data/printf0.cddl +1 -0
  77. data/test-data/printf1.cddl +2 -0
  78. data/test-data/printf2.cddl +2 -0
  79. data/test-data/printf3.cddl +2 -0
  80. data/test-data/sasl.cddl +24 -0
  81. data/test-data/sequence.cddl +1 -0
  82. data/test-data/sipos.cddl +8 -0
  83. data/test-data/star-edited.cddl +98 -0
  84. data/test-data/star.cddl +95 -0
  85. data/test-data/test-gen.cddl +3 -0
  86. data/test-data/time.cddl +11 -0
  87. data/test-data/valemb.cddl +16 -0
  88. data/test-data/yangid.cddl +1 -0
  89. data/test-data/yaron1.cddl +95 -0
  90. metadata +148 -14
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]
@@ -224,7 +275,7 @@ b = (
224
275
  (x: int // y: int), z: int
225
276
  )
226
277
  HERE
227
- assert parser.validate_for_test({})
278
+ refute parser.validate_for_test({}, false)
228
279
  assert parser.validate_for_test({"x" => 2, "z" => 1})
229
280
  assert parser.validate_for_test({"y" => 1, "z" => 2})
230
281
  refute parser.validate_for_test({"z" => 1}, false)
@@ -242,7 +293,7 @@ b = ( z: int
242
293
  (x: int // y: int)
243
294
  )
244
295
  HERE
245
- assert parser.validate_for_test({})
296
+ refute parser.validate_for_test({}, false)
246
297
  assert parser.validate_for_test({"x" => 2, "z" => 1})
247
298
  assert parser.validate_for_test({"y" => 1, "z" => 2})
248
299
  refute parser.validate_for_test({"z" => 1}, false)
@@ -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,3 @@
1
+ foo = text .abnf '4DIGIT
2
+ DIGIT = %x30-39 ; 0-9
3
+ '
@@ -0,0 +1,37 @@
1
+ start = [Tag0, Tag1004]
2
+
3
+ ; for draft-ietf-cbor-date-tag
4
+ Tag1004 = #6.1004(text .abnf full-date)
5
+ ; for RFC 7049
6
+ Tag0 = #6.0(text .abnf date-time)
7
+
8
+ full-date = "full-date" .cat rfc3339
9
+ date-time = "date-time" .cat rfc3339
10
+
11
+ ; Note the trick of idiomatically starting with a newline, separating
12
+ ; off the element in the .cat from the rule-list
13
+ rfc3339 = '
14
+ date-fullyear = 4DIGIT
15
+ date-month = 2DIGIT ; 01-12
16
+ date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
17
+ ; month/year
18
+ time-hour = 2DIGIT ; 00-23
19
+ time-minute = 2DIGIT ; 00-59
20
+ time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap sec
21
+ ; rules
22
+ time-secfrac = "." 1*DIGIT
23
+ time-numoffset = ("+" / "-") time-hour ":" time-minute
24
+ time-offset = "Z" / time-numoffset
25
+
26
+ partial-time = time-hour ":" time-minute ":" time-second
27
+ [time-secfrac]
28
+ full-date = date-fullyear "-" date-month "-" date-mday
29
+ full-time = partial-time time-offset
30
+
31
+ date-time = full-date "T" full-time
32
+ ' .cat rfc5234-core
33
+
34
+ rfc5234-core = '
35
+ DIGIT = %x30-39 ; 0-9
36
+ ; abbreviated here
37
+ '
@@ -0,0 +1,32 @@
1
+ start = [tt, tb, bt, bb]
2
+
3
+
4
+ tt = text .abnf '4DIGIT 1FOO
5
+ DIGIT = %x30-39 ; 0-9
6
+ FOO = %xc0-cf
7
+ '
8
+ tb = text .abnfb '4DIGIT 1FOO
9
+ DIGIT = %x30-39 ; 0-9
10
+ FOO = %xc0-cf
11
+ '
12
+ bt = bytes .abnf '4DIGIT 1FOO
13
+ DIGIT = %x30-39 ; 0-9
14
+ FOO = %xc0-cf
15
+ '
16
+ bb = bytes .abnfb '4DIGIT 1FOO
17
+ DIGIT = %x30-39 ; 0-9
18
+ FOO = %xc0-cf
19
+ '
20
+
21
+ ; ["7408\xC6", "7073\xC3", h'30383131CD', h'32363738CD']
22
+ ; ["5892\u00ca", "2145\u00c6", h'33333338C38B', h'31343033C388']
23
+
24
+
25
+ ; ** ENCOED UTF-8
26
+ ; ** ENCOED UTF-8
27
+ ; ** ENCOED UTF-8
28
+ ; ** ENCOED UTF-8
29
+ ; ["5845\u00c6", "9329\u00cb", h'38393538C389', h'33343230C386']
30
+
31
+
32
+ ; ["1066\u00cc", "9253\xC9", h'38333533C38A', h'32373337C4']
@@ -0,0 +1 @@
1
+ a = text .b64c-sloppy 'mnoabcdue=='
@@ -0,0 +1 @@
1
+ a = text .b64c 'mnoabcd'
@@ -0,0 +1,12 @@
1
+ a = text .b64u bytes
2
+
3
+ ;;gp 10
4
+
5
+ ;;vp "AAAA"
6
+ ;;vp "AAA-"
7
+ ;;vp "AAA_"
8
+ ; fail with 0.11.5:
9
+ ;;vp "AAA+"
10
+ ;;vp "AAA/"
11
+ ;;vp "AAA="
12
+ ;;vp "+kd8"
@@ -0,0 +1 @@
1
+ a = text .b64u 'mnoabcd'
@@ -0,0 +1 @@
1
+ a = text .b32 'mnoabcd'
@@ -0,0 +1 @@
1
+ a = text .h32 'mnoabcd'
@@ -0,0 +1,16 @@
1
+ start = [v1, v2, v3, v4]
2
+
3
+ v1 = "a" .bat "b"
4
+
5
+ v2 = "a" .bat " b"
6
+
7
+ v3 = "a" .bat '
8
+ oid = 1*arc
9
+ roid = *arc
10
+ arc = [nlsb] %x00-7f
11
+ nlsb = %x81-ff *%x80-ff
12
+ '
13
+
14
+ bbat<v1, v2> = ("" .bat v1) .bat v2
15
+
16
+ v4 = bbat<" a", " b">
@@ -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,4 @@
1
+ foo = text .regexp myregexp
2
+ myregexp = "A" .cat "B"
3
+
4
+ ;;gp 10