File tree Expand file tree Collapse file tree 1 file changed +21
-12
lines changed Expand file tree Collapse file tree 1 file changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -532,20 +532,12 @@ impl<D: Driver> Stack<D> {
532
532
_ => { }
533
533
}
534
534
535
- // Form name together with domain name.
536
535
#[ cfg( feature = "dhcpv4-domainname" ) ]
537
- let name = & {
538
- use core:: str:: FromStr ;
539
-
540
- let mut name = String :: < MAX_DNS_QUERY_LEN > :: from_str ( name) . map_err ( |_| dns:: Error :: NameTooLong ) ?;
541
-
542
- if let Some ( Some ( domain_name) ) = & self . inner . borrow ( ) . static_v4 . as_ref ( ) . map ( |c| & c. domain_name ) {
543
- if !domain_name. is_empty ( ) {
544
- name. push ( '.' ) . map_err ( |_| dns:: Error :: NameTooLong ) ?;
545
- name. push_str ( & domain_name) . map_err ( |_| dns:: Error :: NameTooLong ) ?;
546
- }
547
- }
536
+ let name = if name. contains ( "." ) {
537
+ // Already a FQDN.
548
538
name
539
+ } else {
540
+ & self . create_fqdn ( name) ?
549
541
} ;
550
542
551
543
let query = poll_fn ( |cx| {
@@ -623,6 +615,23 @@ impl<D: Driver> Stack<D> {
623
615
624
616
res
625
617
}
618
+
619
+ #[ cfg( feature = "dhcpv4-domainname" ) ]
620
+ fn create_fqdn ( & self , name : & str ) -> Result < String < MAX_DNS_QUERY_LEN > , dns:: Error > {
621
+ use core:: str:: FromStr ;
622
+
623
+ // Form name together with domain name.
624
+ let mut name = String :: < MAX_DNS_QUERY_LEN > :: from_str ( name) . map_err ( |_| dns:: Error :: NameTooLong ) ?;
625
+
626
+ if let Some ( Some ( domain_name) ) = & self . inner . borrow ( ) . static_v4 . as_ref ( ) . map ( |c| & c. domain_name ) {
627
+ if !domain_name. is_empty ( ) {
628
+ name. push ( '.' ) . map_err ( |_| dns:: Error :: NameTooLong ) ?;
629
+ name. push_str ( & domain_name) . map_err ( |_| dns:: Error :: NameTooLong ) ?;
630
+ }
631
+ }
632
+
633
+ Ok ( name)
634
+ }
626
635
}
627
636
628
637
#[ cfg( feature = "igmp" ) ]
You can’t perform that action at this time.
0 commit comments