-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing `DhcpV6Client` and `DhcpV6ClientAsync` for DHCPv6. Supporting these types of actions: * `DhcpV6IaType::NonTemporaryAddresses`: Normal DHCPv6 * `DhcpV6IaType::TemporaryAddresses`: Request temporary address * `DhcpV6IaType::PrefixDelegation`: DHCPv6 Prefix delegation Example could could be found at `examples/mozim_dhcpv6_sync.rs`. Integration test case included. Signed-off-by: Gris Ge <[email protected]>
- Loading branch information
Showing
31 changed files
with
2,293 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[target.x86_64-unknown-linux-gnu] | ||
runner = 'sudo -E' | ||
|
||
[env] | ||
RUST_TEST_THREADS = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
## RFC 8415 | ||
|
||
Clients and servers exchange DHCP messages using UDP (see [RFC768] | ||
and BCP 145 [RFC8085]). The client uses a link-local address or | ||
addresses determined through other mechanisms for transmitting and | ||
receiving DHCP messages. | ||
|
||
`All_DHCP_Relay_Agents_and_Servers`: ff02::1:2 | ||
`All_DHCP_Servers`: ff05::1:3 | ||
|
||
Clients listen for DHCP messages on UDP port 546. Servers and relay | ||
agents listen for DHCP messages on UDP port 547. | ||
|
||
|
||
|
||
Server Server | ||
(not selected) Client (selected) | ||
|
||
v v v | ||
| | | | ||
| Begins initialization | | ||
| | | | ||
start of | _____________/|\_____________ | | ||
4-message |/ Solicit | Solicit \| | ||
exchange | | | | ||
Determines | Determines | ||
configuration | configuration | ||
| | | | ||
|\ | ____________/| | ||
| \________ | /Advertise | | ||
| Advertise\ |/ | | ||
| \ | | | ||
| Collects Advertises | | ||
| \ | | | ||
| Selects configuration | | ||
| | | | ||
| _____________/|\_____________ | | ||
|/ Request | Request \| | ||
| | | | ||
| | Commits configuration | ||
| | | | ||
end of | | _____________/| | ||
4-message | |/ Reply | | ||
exchange | | | | ||
| Initialization complete | | ||
| | | | ||
. . . | ||
. . . | ||
| T1 (renewal) timer expires | | ||
| | | | ||
2-message | _____________/|\_____________ | | ||
exchange |/ Renew | Renew \| | ||
| | | | ||
| | Commits extended lease(s) | ||
| | | | ||
| | _____________/| | ||
| |/ Reply | | ||
. . . | ||
. . . | ||
| | | | ||
| Graceful shutdown | | ||
| | | | ||
2-message | _____________/|\_____________ | | ||
exchange |/ Release | Release \| | ||
| | | | ||
| | Discards lease(s) | ||
| | | | ||
| | _____________/| | ||
| |/ Reply | | ||
| | | | ||
v v v | ||
|
||
|
||
The IAID uniquely identifies the IA and MUST be chosen to be unique | ||
among the IAIDs for that IA type on the client (e.g., an IA_NA with | ||
an IAID of 0 and an IA_PD with an IAID of 0 are each considered | ||
unique). The IAID is chosen by the client. For any given use of an | ||
IA by the client, the IAID for that IA MUST be consistent across | ||
restarts of the DHCP client. | ||
|
||
|
||
|
||
0 1 2 3 | ||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | ||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| msg-type | transaction-id | | ||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| | | ||
. options . | ||
. (variable number and length) . | ||
| | | ||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
|
||
Figure 2: Client/Server Message Format | ||
|
||
|
||
16.2. Solicit Message | ||
|
||
Clients MUST discard any received Solicit messages. | ||
|
||
Servers MUST discard any Solicit messages that do not include a | ||
Client Identifier option or that do include a Server Identifier | ||
option. | ||
|
||
16.3. Advertise Message | ||
|
||
Clients MUST discard any received Advertise message that meets any of | ||
the following conditions: | ||
|
||
- the message does not include a Server Identifier option (see | ||
Section 21.3). | ||
|
||
- the message does not include a Client Identifier option (see | ||
Section 21.2). | ||
|
||
- the contents of the Client Identifier option do not match the | ||
client's DUID. | ||
|
||
- the "transaction-id" field value does not match the value the | ||
client used in its Solicit message. | ||
|
||
Servers and relay agents MUST discard any received Advertise | ||
messages. | ||
|
||
|
||
16.4. Request Message | ||
|
||
Clients MUST discard any received Request messages. | ||
|
||
Servers MUST discard any received Request message that meets any of | ||
the following conditions: | ||
|
||
- the message does not include a Server Identifier option (see | ||
Section 21.3). | ||
|
||
- the contents of the Server Identifier option do not match the | ||
server's DUID. | ||
|
||
- the message does not include a Client Identifier option (see | ||
Section 21.2). | ||
|
||
|
||
16.6. Renew Message | ||
|
||
Clients MUST discard any received Renew messages. | ||
|
||
Servers MUST discard any received Renew message that meets any of the | ||
following conditions: | ||
|
||
- the message does not include a Server Identifier option (see | ||
Section 21.3). | ||
|
||
- the contents of the Server Identifier option do not match the | ||
server's identifier. | ||
|
||
- the message does not include a Client Identifier option (see | ||
Section 21.2). | ||
|
||
16.7. Rebind Message | ||
|
||
Clients MUST discard any received Rebind messages. | ||
|
||
Servers MUST discard any received Rebind messages that do not include | ||
a Client Identifier option (see Section 21.2) or that do include a | ||
Server Identifier option (see Section 21.3). |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use mozim::{DhcpV6Client, DhcpV6Config, DhcpV6IaType}; | ||
|
||
const TEST_NIC: &str = "dhcpcli"; | ||
const POLL_WAIT_TIME: u32 = 5; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
enable_log(); | ||
let mut config = | ||
DhcpV6Config::new(TEST_NIC, DhcpV6IaType::NonTemporaryAddresses); | ||
config.set_timeout(60); | ||
let mut cli = DhcpV6Client::init(config, None).unwrap(); | ||
|
||
loop { | ||
for event in cli.poll(POLL_WAIT_TIME)? { | ||
if let Some(lease) = cli.process(event)? { | ||
println!("Got DHCPv6 lease {:?}", lease); | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn enable_log() { | ||
env_logger::Builder::new() | ||
.filter(Some("nispor"), log::LevelFilter::Debug) | ||
.filter(Some("mozim"), log::LevelFilter::Debug) | ||
.init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.