Skip to content

Commit e500a6e

Browse files
authored
Merge branch 'master' into updown
2 parents 9db954f + ef6c268 commit e500a6e

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

.github/workflows/rustfmt.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Rustfmt check
7+
jobs:
8+
fmt:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
toolchain: stable
15+
profile: minimal
16+
components: rustfmt
17+
- name: Check fmt
18+
run: cargo fmt -- --check

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Update `managed` from 0.7 to 0.8 ([442](https://github.com/smoltcp-rs/smoltcp/pull/442))
1111
- udp: Add `close()` method to unbind socket.
1212

13+
## [0.7.5] - 2021-06-28
14+
15+
- dhcpv4: emit DNS servers in repr (#505)
16+
17+
## [0.7.4] - 2021-06-11
18+
19+
- tcp: fix "subtract sequence numbers with underflow" on remote window shrink. (#490)
20+
- tcp: fix substract with overflow when receiving a SYNACK with unincremented ACK number. (#491)
21+
- tcp: use nonzero initial sequence number to workaround misbehaving servers. (#492)
22+
1323
## [0.7.3] - 2021-05-29
1424

1525
- Fix "unused attribute" error in recent nightlies.
@@ -73,6 +83,8 @@ only processed when directed to the 255.255.255.255 address. ([377](https://gith
7383
- Simplify lifetime parameters of sockets, SocketSet, EthernetInterface ([410](https://github.com/smoltcp-rs/smoltcp/pull/410), [413](https://github.com/smoltcp-rs/smoltcp/pull/413))
7484

7585
[Unreleased]: https://github.com/smoltcp-rs/smoltcp/compare/v0.7.0...HEAD
86+
[0.7.5]: https://github.com/smoltcp-rs/smoltcp/compare/v0.7.4...v0.7.5
87+
[0.7.4]: https://github.com/smoltcp-rs/smoltcp/compare/v0.7.3...v0.7.4
7688
[0.7.3]: https://github.com/smoltcp-rs/smoltcp/compare/v0.7.2...v0.7.3
7789
[0.7.2]: https://github.com/smoltcp-rs/smoltcp/compare/v0.7.1...v0.7.2
7890
[0.7.1]: https://github.com/smoltcp-rs/smoltcp/compare/v0.7.0...v0.7.1

src/wire/dhcpv4.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ impl<'a> Repr<'a> {
727727
if self.lease_duration.is_some() {
728728
len += 6;
729729
}
730+
if let Some(dns_servers) = self.dns_servers {
731+
len += 2;
732+
len += dns_servers.iter().flatten().count() * core::mem::size_of::<u32>();
733+
}
730734
if let Some(list) = self.parameter_request_list {
731735
len += list.len() + 2;
732736
}
@@ -892,6 +896,25 @@ impl<'a> Repr<'a> {
892896
if let Some(duration) = self.lease_duration {
893897
options = DhcpOption::IpLeaseTime(duration).emit(options);
894898
}
899+
if let Some(dns_servers) = self.dns_servers {
900+
const IP_SIZE: usize = core::mem::size_of::<u32>();
901+
let mut servers = [0; MAX_DNS_SERVER_COUNT * IP_SIZE];
902+
903+
let data_len = dns_servers
904+
.iter()
905+
.flatten()
906+
.enumerate()
907+
.inspect(|(i, ip)| {
908+
servers[(i * IP_SIZE)..((i + 1) * IP_SIZE)].copy_from_slice(ip.as_bytes());
909+
})
910+
.count()
911+
* IP_SIZE;
912+
let option = DhcpOption::Other {
913+
kind: field::OPT_DOMAIN_NAME_SERVER,
914+
data: &servers[..data_len],
915+
};
916+
options = option.emit(options);
917+
}
895918
if let Some(list) = self.parameter_request_list {
896919
options = DhcpOption::Other {
897920
kind: field::OPT_PARAMETER_REQUEST_LIST,
@@ -1151,6 +1174,34 @@ mod test {
11511174
repr.emit(&mut packet).unwrap();
11521175
}
11531176

1177+
#[test]
1178+
fn test_emit_offer_dns() {
1179+
let repr = {
1180+
let mut repr = offer_repr();
1181+
repr.dns_servers = Some([
1182+
Some(Ipv4Address([163, 1, 74, 6])),
1183+
Some(Ipv4Address([163, 1, 74, 7])),
1184+
Some(Ipv4Address([163, 1, 74, 3])),
1185+
]);
1186+
repr
1187+
};
1188+
let mut bytes = vec![0xa5; repr.buffer_len()];
1189+
let mut packet = Packet::new_unchecked(&mut bytes);
1190+
repr.emit(&mut packet).unwrap();
1191+
1192+
let packet = Packet::new_unchecked(&bytes);
1193+
let repr_parsed = Repr::parse(&packet).unwrap();
1194+
1195+
assert_eq!(
1196+
repr_parsed.dns_servers,
1197+
Some([
1198+
Some(Ipv4Address([163, 1, 74, 6])),
1199+
Some(Ipv4Address([163, 1, 74, 7])),
1200+
Some(Ipv4Address([163, 1, 74, 3]))
1201+
])
1202+
);
1203+
}
1204+
11541205
#[test]
11551206
fn test_emit_dhcp_option() {
11561207
static DATA: &[u8] = &[1, 3, 6];

0 commit comments

Comments
 (0)