summaryrefslogtreecommitdiffstats
path: root/solec.ksy
blob: 82f3bf71061071f645d37f86ddbcfe112850b796 (plain)
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
meta:
  id: solec
  file-extension: hex
  endian: be

enums:
  type:
    0x01: handshake
    0x02: ping
    0x03: pong
    0x04: message
    0xFF: test

seq:
  - id: payload_type
    type: u1
    enum: type
  - id: payload_length
    type: u2
  - id: payload
    type:
      switch-on: payload_type
      cases:
        'type::handshake': handshake
        'type::ping': ping
        'type::pong': pong
#       'type::message': message
        'type::test': test

types:
  string:
    seq:
      - id: len_payload
        type: u2
      - id: payload
        type: str
        size: len_payload
        encoding: UTF-8

  binary:
    seq:
      - id: len_payload
        type: u2
      - id: payload
        size: len_payload

  handshake:
    seq:
      - id: proto_ver_major
        type: u1
      - id: proto_ver_minor
        type: u1

  ping: {}

  pong:
    seq:
      - id: timestamp
        type: u8

  test:
    doc: Test payload, used for parsers testing
    seq:
      - id: num1
        type: u1
      - id: time1
        type: u8
      - id: str1
        type: string
      - id: num2
        type: u2
      - id: bin1
        type: binary
      - id: num3
        type: u4
      - id: str2
        type: string
      - id: num4
        type: u8