Skip to content

Commit 0c0a4b4

Browse files
authored
Address Discovery and Server Initiated Connection Migration and NAT Traversal (#3)
1 parent 55591c3 commit 0c0a4b4

68 files changed

Lines changed: 7959 additions & 727 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ include = [
7979
path = "src/rs/lib.rs"
8080

8181
[features]
82-
default = ["src"]
82+
default = ["src", "preview-api"]
8383
# Build c code from source
8484
src = [ "dep:cmake" ]
8585
# Find prebuilt msquic. Use vcpkg installed location on Windows,

docs/Settings.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ The following settings are available via registry as well as via [QUIC_SETTINGS]
6767
| Stream Multi Receive | uint8_t | StreamMultiReceiveEnabled | 0 (FALSE) | Enable multi receive support |
6868
| XDP | uint8_t | XdpEnabled | 0 (FALSE) | Enable XDP. |
6969
| QTIP | uint8_t | QTIPEnabled | 0 (FALSE) | Enable QTIP. XDP must be used. Clients will only send/recv QTIP xor UDP traffic, listeners accept both. [More info](./QTIP.md)|
70+
| Server Initiated Migration | uint8_t | ServerMigrationEnabled | 0 (FALSE) | Enable Server Initiated Migration. |
71+
| ADD_ADDRESS handling mode | uint8_t | AddAddressMode | 0 (AUTO) | Control handling of ADD_ADDRESS Frame |
72+
| IgnoreUnreachable | uint8_t | IgnoreUnreachable | 0 (FALSE) | Ignore Unreachable during the Handshake |
7073

7174
The types map to registry types as follows:
7275
- `uint64_t` is a `REG_QWORD`.
@@ -207,6 +210,15 @@ These parameters are accessed by calling [GetParam](./api/GetParam.md) or [SetPa
207210
| `QUIC_PARAM_CONN_SEND_DSCP` <br> 25 | uint8_t | Both | The DiffServ Code Point put in the DiffServ field (formerly TypeOfService/TrafficClass) on packets sent from this connection. |
208211
| `QUIC_PARAM_CONN_NETWORK_STATISTICS` <br> 32 | QUIC_NETWORK_STATISTICS | Get-only | Returns Connection level network statistics |
209212
| `QUIC_PARAM_CONN_CLOSE_ASYNC` <br> 26 | uint8_t (BOOLEAN) | Both | The desired connection close behavior. Defaults to false (synchronous). |
213+
| `QUIC_PARAM_CONN_ADD_BOUND_ADDRESS` <br> 27 | QUIC_ADDR | Set-only | Add a bound address. Server only. |
214+
| `QUIC_PARAM_CONN_ADD_OBSERVED_ADDRESS` <br> 28 | QUIC_ADD_OBSERVED_ADDRESS | Set-only | Set an observed address for a bound address. Server only. |
215+
| `QUIC_PARAM_CONN_REMOVE_BOUND_ADDRESS` <br> 29 | QUIC_ADDR | Set-only | Remove a bound address. Server only. |
216+
| `QUIC_PARAM_CONN_ADD_PATH` <br> 30 | QUIC_PATH_PARAM | Set-only | Add a path. Client only. |
217+
| `QUIC_PARAM_CONN_ACTIVATE_PATH` <br> 31 | QUIC_PATH_PARAM | Set-only | Activate a path. Client only. |
218+
| `QUIC_PARAM_CONN_REMOVE_PATH` <br> 32 | QUIC_PATH_PARAM | Set-only | Remove a path. Client only. |
219+
| `QUIC_PARAM_CONN_ADD_CANDIDATE_ADDRESS` <br> 33 | QUIC_CANDIDATE_ADDRESS | Set-only | Add a candidate address. Client only. |
220+
| `QUIC_PARAM_CONN_REMOVE_CANDIDATE_ADDRESS` <br> 34| QUIC_CANDIDATE_ADDRESS | Set-only | Remove a candidate address. Client only. |
221+
210222

211223
### QUIC_PARAM_CONN_STATISTICS_V2
212224

docs/api/QUIC_CONNECTION_EVENT.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ typedef enum QUIC_CONNECTION_EVENT_TYPE {
2828
QUIC_CONNECTION_EVENT_RELIABLE_RESET_NEGOTIATED = 16, // Only indicated if QUIC_SETTINGS.ReliableResetEnabled is TRUE.
2929
QUIC_CONNECTION_EVENT_ONE_WAY_DELAY_NEGOTIATED = 17, // Only indicated if QUIC_SETTINGS.OneWayDelayEnabled is TRUE.
3030
QUIC_CONNECTION_EVENT_NETWORK_STATISTICS = 18, // Only indicated if QUIC_SETTINGS.EnableNetStatsEvent is TRUE.
31+
QUIC_CONNECTION_EVENT_NOTIFY_OBSERVED_ADDRESS = 19,
32+
QUIC_CONNECTION_EVENT_NOTIFY_REMOTE_ADDRESS_ADDED = 20, // Only indicated if QUIC_SETTINGS.AddAddressMode is MANUAL
33+
QUIC_CONNECTION_EVENT_PATH_VALIDATED = 21,
34+
QUIC_CONNECTION_EVENT_NOTIFY_REMOTE_ADDRESS_REMOVED = 22, // Only indicated if QUIC_SETTINGS.AddAddressMode is MANUAL
3135
#endif
3236

3337
} QUIC_CONNECTION_EVENT_TYPE;
@@ -113,6 +117,21 @@ typedef struct QUIC_CONNECTION_EVENT {
113117
BOOLEAN ReceiveNegotiated; // TRUE if receiving one-way delay timestamps is negotiated.
114118
} ONE_WAY_DELAY_NEGOTIATED;
115119
QUIC_NETWORK_STATISTICS NETWORK_STATISTICS;
120+
struct {
121+
QUIC_ADDR *LocalAddress;
122+
QUIC_ADDR *ObservedAddress;
123+
} NOTIFY_OBSERVED_ADDRESS;
124+
struct {
125+
QUIC_ADDR *Address;
126+
QUIC_UINT62 SequenceNumber;
127+
} NOTIFY_REMOTE_ADDRESS_ADDED;
128+
struct {
129+
QUIC_ADDR *LocalAddress;
130+
QUIC_ADDR *RemoteAddress;
131+
} PATH_VALIDATED;
132+
struct {
133+
QUIC_UINT62 SequenceNumber;
134+
} NOTIFY_REMOTE_ADDRESS_REMOVED;
116135
#endif
117136

118137
};
@@ -469,6 +488,70 @@ Congestion Window
469488

470489
Estimated bandwidth
471490

491+
# QUIC_CONNECTION_EVENT_NOTIFY_OBSERVED_ADDRESS
492+
493+
**Preview feature**: This event is in [preview](../PreviewFeatures.md). It should be considered unstable and can be subject to breaking changes.
494+
495+
This event indicates the content of an OBSERVED_ADDRESS frame.
496+
497+
## NOTIFY_OBSERVED_ADDRESS
498+
Both Observed address and local address are passed in the `NOTIFY_OBSERVED_ADDRESS` struct/union.
499+
500+
`LocalAddress`
501+
502+
The local IP address.
503+
504+
`ObservedAddress`
505+
506+
The observed IP address.
507+
508+
# QUIC_CONNECTION_EVENT_NOTIFY_REMOTE_ADDRESS_ADDED
509+
510+
**Preview feature**: This event is in [preview](../PreviewFeatures.md). It should be considered unstable and can be subject to breaking changes.
511+
512+
This event is only indicated if QUIC_SETTINGS.AddAddressMode is MANUAL. This event indicates the content of an ADD_ADDRESS frame.
513+
514+
## NOTIFY_REMOTE_ADDRESS_ADDED
515+
The contents of ADD_ADDRESS frame are passed in the `NOTIFY_REMOTE_ADDRESS_ADDED` struct/union.
516+
517+
`Address`
518+
519+
The new Remote IP address.
520+
521+
`SequenceNumber`
522+
523+
The Sequence Number of the added address.
524+
525+
# QUIC_CONNECTION_EVENT_PATH_VALIDATED
526+
527+
**Preview feature**: This event is in [preview](../PreviewFeatures.md). It should be considered unstable and can be subject to breaking changes.
528+
529+
This event is delivered when a path has been validated.
530+
531+
## PATH_VALIDATED
532+
Both the Local IP address and the Remote IP address are passed in the `PATH_VALIDATED` struct/union.
533+
534+
`LocalAddress`
535+
536+
The Local IP address of a path.
537+
538+
`RemoteAddress`
539+
540+
The Remote IP address of a path.
541+
542+
# QUIC_CONNECTION_EVENT_NOTIFY_REMOTE_ADDRESS_REMOVED
543+
544+
**Preview feature**: This event is in [preview](../PreviewFeatures.md). It should be considered unstable and can be subject to breaking changes.
545+
546+
This event is only indicated if QUIC_SETTINGS.AddAddressMode is MANUAL. This event indicates the content of a REMOVE_ADDRESS frame.
547+
548+
## NOTIFY_REMOTE_ADDRESS_REMOVED
549+
The content of REMOVE_ADDRESS frame is passed in the `NOTIFY_REMOTE_ADDRESS_REMOVED` struct/union.
550+
551+
`SequenceNumber`
552+
553+
The Sequence Number of the removed address.
554+
472555

473556
# See Also
474557

src/core/binding.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,34 @@ QuicBindingCreateConnection(
13621362
BindingRefAdded = TRUE;
13631363
NewConnection->Paths[0].Binding = Binding;
13641364

1365+
// Add the local address to the connection's list of bound addresses.
1366+
QUIC_BOUND_ADDRESS_LIST_ENTRY* Bound =
1367+
(QUIC_BOUND_ADDRESS_LIST_ENTRY*)
1368+
CXPLAT_ALLOC_NONPAGED(
1369+
sizeof(QUIC_BOUND_ADDRESS_LIST_ENTRY),
1370+
QUIC_POOL_BOUND_ADDRESS_LIST);
1371+
if (Bound == NULL) {
1372+
QuicPacketLogDrop(Binding, Packet, "Failed to allocate local address");
1373+
goto Exit;
1374+
}
1375+
1376+
if (!QuicLibraryTryAddRefBinding(Binding)) {
1377+
QuicPacketLogDrop(Binding, Packet, "Clean up in progress");
1378+
CXPLAT_FREE(Bound, QUIC_POOL_BOUND_ADDRESS_LIST);
1379+
goto Exit;
1380+
}
1381+
1382+
CxPlatCopyMemory(&Bound->Address, &Packet->Route->LocalAddress, sizeof(QUIC_ADDR));
1383+
Bound->SequenceNumber = QUIC_VAR_INT_MAX;
1384+
Bound->SequenceNumberValid = FALSE;
1385+
Bound->ObservedAddressSet = FALSE;
1386+
Bound->SendAddAddress = FALSE;
1387+
Bound->Removing = FALSE;
1388+
Bound->SendRemoveAddress = FALSE;
1389+
Bound->Binding = Binding;
1390+
1391+
CxPlatListInsertTail(&NewConnection->BoundAddresses, &Bound->Link);
1392+
13651393
if (!QuicLookupAddRemoteHash(
13661394
&Binding->Lookup,
13671395
NewConnection,

0 commit comments

Comments
 (0)