From acde76c0f47011b83fc2dcbf58ec962842971784 Mon Sep 17 00:00:00 2001 From: Raine Date: Wed, 8 Nov 2023 00:04:44 +0100 Subject: [PATCH] feat: changes to proto (read commit msg) - remove sizes from command data; these can be inferenced from data size. - refactored errors to be more logical - reworded minor things --- doc/proto.md | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/doc/proto.md b/doc/proto.md index be7950b..be71967 100644 --- a/doc/proto.md +++ b/doc/proto.md @@ -5,7 +5,6 @@ # Prelude Version 1 has zero security on itself. -This can be changed with something like TLS but that's up to the implementer. # Structure @@ -146,26 +145,27 @@ Send a packet to state an error occurred. #### Command data -| offset | size | name | description | example | -| ------ | ----------------------------- | ----------------- | ------------------------------- | -------- | -| `0x14` | 1 byte | `error_code` | error code; check 'Error codes' | `0x00` | -| `0x15` | 2 bytes | `metadata_length` | metadata length | `0x0000` | -| `0x17` | `<0x14-0x15:metadata_length>` | `metadata` | metadata | | +| offset | size | name | description | example | +| ------ | ----------------------------- | ------------ | ------------------------------- | ------- | +| `0x14` | 1 byte | `error_code` | error code; check 'Error codes' | `0x00` | +| `0x15` | `<0x14-0x15:metadata_length>` | `metadata` | metadata | | #### Error codes -| `status_code` | name | description | recoverable | -| ------------- | ---------------------- | -------------------------------------------------------------------------------------------- | --------------------------------- | -| `0x1*` | `net_*` | **Network errors** | | -| `0x00` | `net_duplicate_packet` | `reply_to` packet is invalid because another packet was sent recently with same `packet_id`. | resend with different `packet_id` | -| `0x01` | `net_broken_packet` | recent packet was broken. | resend packet | -| `0x02` | `net_invalid_packet` | the packet sent is not valid | send packet with proper values | -| `0x03` | `net_addr_in_use` | the addr requested is in use already | register with another id or `0` | -| `0x04` | `net_dest_unreachable` | the destination could not be reached | no | -| `0x1*` | `errc_*` | **Client errors** | | -| `0x10` | `errc_not_registered` | client is not registered | register client | -| `0x2*` | `errs_*` | **Server errors** | | -| `0x20` | `errs_not_delivered` | server could not deliver packet. | depends on situation | +| `status_code` | name | description | recoverable | +| ------------- | ----------------------- | --------------------------------------------------------------------- | --------------------------------- | +| `0x0*` | `net_*` | **Network errors** | | +| `0x00` | `net_broken_packet` | recent packet was broken; this packet's data did not arrive properly. | resend packet | +| `0x01` | `net_invalid_packet` | the packet sent is not valid; this packet's data does not make sense. | send packet with proper values | +| `0x02` | `net_dest_unreachable` | the destination could not be reached | no | +| `0x1*` | `mgmt_*` | **Management errors** | | +| `0x10` | `mgmt_duplicate_packet` | `packet_id` was used recently. | resend with different `packet_id` | +| `0x11` | `mgmt_addr_in_use` | the addr requested is in use already | register with another id or `0` | +| `0x12` | `mgmt_not_registered` | the src addr is not registered with the master node | register with another id or `0` | +| `0x13` | `mgmt_not_delivered` | the sent packet could not be delivered | register with another id or `0` | +| `0x2*` | `node_*` | **Node errors** | | +| `0x20` | `node_invalid_property` | the property specified is invalid | no | +| `0x21` | `node_failed_request` | the request could not be completed. | consult metadata | ## `0x1*` - Properties control @@ -238,5 +238,4 @@ The `sequence_number` is added for redundancy, all data sent will always reply t | offset | size | name | description | example | | ------ | -------- | ----------------- | ------------------------------- | ------------ | | `0x14` | 4 bytes | `sequence_number` | the sequence number of the data | `0x00000000` | -| `0x18` | 4 bytes | `size` | size of this slice of data | `0x00000000` | -| `0x1c` | `` | `data` | the data | | \ No newline at end of file +| `0x18` | `` | `data` | the data | |