cddl 0.8.4 → 0.8.5
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 +4 -4
- data/cddl.gemspec +1 -1
- data/lib/cddl.rb +31 -10
- data/test-data/badaddr.cddl +1 -0
- data/test-data/grasp-09.cddl +108 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7338cde62dc12f53d0ebdef50710108d03570241
|
|
4
|
+
data.tar.gz: 6ab3c6679a1553bd36ad614dcd406855be6d3bd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d87a121c7ad9489dc74de6e6a09d05b4d303a1e6739ad887dcf142f03857079ddac3442add743916ffc580558aac800ef13f52685c68a28c54bc17206f65c93
|
|
7
|
+
data.tar.gz: 2ddc22986f4f623dff1d5bc793654a2c1f3482172fd1a4f90d30c172160d89cbc21c497ec5c48014968060e09f5ac378aaf58d24628aec7d1d8aea12a4cedd6c
|
data/cddl.gemspec
CHANGED
data/lib/cddl.rb
CHANGED
|
@@ -4,6 +4,7 @@ require 'pathname'
|
|
|
4
4
|
require 'cbor-pure' unless defined?(CBOR::Tagged)
|
|
5
5
|
require 'regexp-examples'
|
|
6
6
|
require 'colorize'
|
|
7
|
+
require 'base64'
|
|
7
8
|
|
|
8
9
|
module CDDL
|
|
9
10
|
|
|
@@ -348,7 +349,7 @@ module CDDL
|
|
|
348
349
|
fail BackTrack.new("Need #{where[1]}..#{where[2]} of these: #{[kr, vr].inspect}") unless where[1] == 0
|
|
349
350
|
[]
|
|
350
351
|
end
|
|
351
|
-
when :text, :int, :float
|
|
352
|
+
when :text, :int, :float, :bytes
|
|
352
353
|
where[1]
|
|
353
354
|
when :range
|
|
354
355
|
rand(where[1])
|
|
@@ -735,7 +736,7 @@ module CDDL
|
|
|
735
736
|
idx, ann = validate_forward(d, 0, where)
|
|
736
737
|
ann if validate_result(idx == d.size) { "#{validate_diag.inspect} -- cannot complete (#{idx}, #{d.size}) array #{d} for #{where}" }
|
|
737
738
|
end
|
|
738
|
-
when :text, :int, :float
|
|
739
|
+
when :text, :int, :float, :bytes
|
|
739
740
|
_, v = extract_value(where)
|
|
740
741
|
[] if d == v
|
|
741
742
|
when :range
|
|
@@ -942,14 +943,34 @@ module CDDL
|
|
|
942
943
|
def value(n)
|
|
943
944
|
# cheat:
|
|
944
945
|
# warn n
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
946
|
+
s = n.to_s
|
|
947
|
+
if s[-1] == "'"
|
|
948
|
+
parts = s.split("'", 3)
|
|
949
|
+
if parts[2] != "" || parts[1] =~ /\\/
|
|
950
|
+
warn "*** Can't handle backslashes in #{s.inspect} yet"
|
|
951
|
+
end
|
|
952
|
+
[:bytes,
|
|
953
|
+
case parts[0]
|
|
954
|
+
when ""
|
|
955
|
+
parts[1].b
|
|
956
|
+
when "h"
|
|
957
|
+
parts[1].gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join
|
|
958
|
+
when "b64"
|
|
959
|
+
Base64.urlsafe_decode64(parts[1])
|
|
960
|
+
else
|
|
961
|
+
warn "*** Can't handle byte string type #{parts[0].inspect} yet"
|
|
962
|
+
end
|
|
963
|
+
]
|
|
964
|
+
else
|
|
965
|
+
val = eval(n.to_s)
|
|
966
|
+
# warn val
|
|
967
|
+
[case val
|
|
968
|
+
when Integer; :int
|
|
969
|
+
when Numeric; :float
|
|
970
|
+
when String; :text
|
|
971
|
+
else fail "huh? value #{val.inspect}"
|
|
972
|
+
end, val]
|
|
973
|
+
end
|
|
953
974
|
end
|
|
954
975
|
|
|
955
976
|
def workaround1(n)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
badaddr = text .regexp "[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]"
|
|
@@ -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
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cddl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carsten Bormann
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cbor-diag
|
|
@@ -99,6 +99,7 @@ files:
|
|
|
99
99
|
- test-data/7071-verbose.cddl
|
|
100
100
|
- test-data/a.cddl
|
|
101
101
|
- test-data/b.cddl
|
|
102
|
+
- test-data/badaddr.cddl
|
|
102
103
|
- test-data/basic_syntax_example.cddl
|
|
103
104
|
- test-data/cdni-ct.cddl
|
|
104
105
|
- test-data/cose.cddl
|
|
@@ -108,6 +109,7 @@ files:
|
|
|
108
109
|
- test-data/grasp-01-extract.cddl
|
|
109
110
|
- test-data/grasp-01-test.cddl
|
|
110
111
|
- test-data/grasp-01.cddl
|
|
112
|
+
- test-data/grasp-09.cddl
|
|
111
113
|
- test-data/grasp-v1.cddl
|
|
112
114
|
- test-data/grasp-v2X.cddl
|
|
113
115
|
- test-data/ifmap-base-2.0v17.cddl
|
|
@@ -146,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
146
148
|
version: '0'
|
|
147
149
|
requirements: []
|
|
148
150
|
rubyforge_project:
|
|
149
|
-
rubygems_version: 2.6.
|
|
151
|
+
rubygems_version: 2.6.8
|
|
150
152
|
signing_key:
|
|
151
153
|
specification_version: 4
|
|
152
154
|
summary: CDDL generator and validator.
|