summaryrefslogtreecommitdiffstats
path: root/solec.ksy
blob: dcfcc11f82e833f9dcd8b15b3b9bde9d2b639076 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
meta:
  id: solec
  file-extension: hex
  endian: be

doc: SOLEC protocol
doc-ref: https://git.sr.ht/~rctt/solec/blob/main/solec.svg

seq:
  - id: type_payload
    type: u1
    enum: payload_type
  - id: len_payload
    type: u2
  - id: payload
    size: len_payload
    type:
      switch-on: type_payload
      cases:
        'payload_type::success': success
        'payload_type::error': error
        'payload_type::handshake': handshake
        'payload_type::auth': auth
        'payload_type::message': message
        'payload_type::test': test

enums:
  payload_type:
    0x01: success
    0x02: error
    0x03: handshake
    0x04: auth
    0x05: message
    0xFF: test

  error_type:
    0x01: auth_failed

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

  binary:
    doc: Binary data of unspecifed type.
    seq:
      - id: len_payload
        type: u2
      - id: payload
        size: len_payload

  success:
    doc: Send from server if operation succeded.

  error:
    doc: Senf from server if operation failed.
    seq:
      - id: error_code
        type: u1
        enum: error_type

  handshake:
    doc: |
      Handshake is sent by the client during connection initialization.
      If protocol_ver_major is different than version used by the server
      connection will be aborted.
    seq:
      - id: proto_ver_major
        type: u1
      - id: proto_ver_minor
        type: u1

  auth:
    seq:
      - id: name
        type: string
      - id: pass
        type: string

  message:
    doc: |
      Source and target fields are addresses in user@server format.
    seq:
      - id: source
        type: string
      - id: target
        type: string
      - id: timestamp
        doc: Set just before sending the message.
        type: u8
      - id: content
        type: string

  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