Skip to content

Commit c6f28d9

Browse files
committed
bidirectional requests and requested_extensions addition
1 parent 64bb625 commit c6f28d9

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

extensions/extensions-negotiation.md

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
This document defines a Stratum V2 extension to negotiate support for other protocol extensions between clients and servers.
66

7-
The mechanism allows clients to request support for a list of extensions immediately after the `SetupConnection` message exchange. The server responds with either:
7+
The mechanism allows either clients or servers to initiate a request for extension support immediately after the `SetupConnection` message exchange. The receiving party responds with either:
88
- `RequestExtensions.Success`, listing the supported extensions.
9-
- `RequestExtensions.Error`, listing the unsupported extensions.
9+
- `RequestExtensions.Error`, listing the unsupported extensions and extensions required by the receiver.
1010

1111
This negotiation ensures that both parties can establish a common set of features before exchanging further protocol messages.
1212

@@ -18,34 +18,43 @@ Terms like "MUST," "MUST NOT," "REQUIRED," etc., follow RFC2119 standards.
1818

1919
### 1.1 Negotiating Extensions
2020

21-
After the successful `SetupConnection` exchange, clients MUST send a `RequestExtensions` message to indicate the extensions they wish to use. The server responds with:
21+
After the successful SetupConnection exchange, either party (client or server) MAY send a RequestExtensions message to indicate the extensions they wish to use. The receiving party responds with:
2222
- `RequestExtensions.Success`, confirming which extensions are supported.
23-
- `RequestExtensions.Error`, identifying unsupported extensions.
23+
- `RequestExtensions.Error`, identifying unsupported extensions and required extensions from the responder.
2424

25-
Clients MUST NOT use any features from extensions that are not confirmed as supported by the server.
25+
Initiators MUST NOT use any features from extensions that are not confirmed as supported by the receiver.
2626

2727
#### Message Exchange Example
2828

29-
1. **Connection Setup**:
29+
- **Connection Setup**:
3030
```
3131
Client --- SetupConnection (connection details) ---> Server
3232
Client <--- SetupConnection.Success (connection accepted) ---- Server
3333
```
3434
35-
2. **Extension Negotiation**:
35+
- **Extension Negotiation (Client-Initiated)**:
3636
```
3737
Client --- RequestExtensions (list of requested U16) ---> Server
38+
39+
Server Response:
40+
If successful:
41+
Client <--- RequestExtensions.Success (list of supported U16) ---- Server
42+
43+
If an error occurs:
44+
Client <--- RequestExtensions.Error (unsupported U16, requested U16) ---- Server
3845
```
3946
40-
3. **Server Response**:
41-
- If successful:
42-
```
43-
Client <--- RequestExtensions.Success (list of supported U16) ---- Server
44-
```
45-
- If an error occurs:
46-
```
47-
Client <--- RequestExtensions.Error (list of unsupported U16) ---- Server
48-
```
47+
- **Extension Negotiation (Server-Initiated)**:
48+
```
49+
Server --- RequestExtensions (list of requested U16) ---> Client
50+
51+
Client Response:
52+
If successful:
53+
Server <--- RequestExtensions.Success (list of supported U16) ---- Client
54+
55+
If an error occurs:
56+
Server <--- RequestExtensions.Error (unsupported U16, requested U16) ---- Client
57+
```
4958
5059
---
5160
@@ -67,10 +76,11 @@ Clients MUST NOT use any features from extensions that are not confirmed as supp
6776
6877
### `RequestExtensions.Error` (Server -> Client)
6978
70-
| Field Name | Data Type | Description |
71-
|------------------------|--------------|-----------------------------------------------|
72-
| request_id | U16 | Unique identifier for pairing the response. |
73-
| unsupported_extensions | SEQ0_64K[U16]| List of unsupported extension identifiers. |
79+
| Field Name | Data Type | Description |
80+
|------------------------|--------------|-------------------------------------------------------------------------------------------|
81+
| request_id | U16 | Unique identifier for pairing the response. |
82+
| unsupported_extensions | SEQ0_64K[U16]| List of unsupported extension identifiers. |
83+
| requested_extensions | SEQ0_64K[U16]| List of extension identifiers the receiver requires but were not requested by the sender. |
7484
7585
---
7686
@@ -87,11 +97,12 @@ Clients MUST NOT use any features from extensions that are not confirmed as supp
8797
## 4. Implementation Notes
8898
8999
1. **Error Handling**:
90-
- Servers MUST respond with `RequestExtensions.Error` if none of the requested extensions are supported.
91-
- Servers MAY include an empty `unsupported_extensions` field in the error message if no extensions are explicitly unsupported.
100+
- Receivers MUST respond with `RequestExtensions.Error` if none of the requested extensions are supported.
101+
- If the receiver **requires** certain extensions but they were not included in the request, it MUST list them in the `requested_extensions` field of `RequestExtensions.Error`.
92102
93103
2. **Ordering**:
94104
- The `RequestExtensions` message MUST be sent immediately after `SetupConnection.Success` and before any other protocol-specific messages.
105+
- The response to `RequestExtensions` MUST be received before proceeding with any further protocol-specific messages.
95106
96107
#### 3. **Backward Compatibility**:
97108
- **Server Behavior**:
@@ -110,3 +121,12 @@ This ensures clients can handle servers that do not implement extensions negotia
110121
Client <--- RequestExtensions.Success [0x0002] ---- Server
111122
```
112123
The client now knows that extension `0x0003` is not supported and must adapt its behavior accordingly.
124+
125+
126+
5. **Example Use Case with Server Requesting Extensions**:
127+
A server requiring extension `0x0005`, but the client did not include it in its request:
128+
```
129+
Client --- RequestExtensions [0x0002, 0x0003] ---> Server
130+
Client <--- RequestExtensions.Error [unsupported: 0x0003, requested: 0x0005] ---- Server
131+
```
132+
The client now knows that the server requires extension `0x0005` and MAY choose to retry with a modified request.

0 commit comments

Comments
 (0)