@@ -81,8 +81,6 @@ impl MmdsNetworkStack {
8181 mac_addr : MacAddr ,
8282 ipv4_addr : Ipv4Addr ,
8383 tcp_port : u16 ,
84- max_connections : NonZeroUsize ,
85- max_pending_resets : NonZeroUsize ,
8684 mmds : Arc < Mutex < Mmds > > ,
8785 ) -> Self {
8886 MmdsNetworkStack {
@@ -93,8 +91,8 @@ impl MmdsNetworkStack {
9391 tcp_handler : TcpIPv4Handler :: new (
9492 ipv4_addr,
9593 tcp_port,
96- max_connections ,
97- max_pending_resets ,
94+ NonZeroUsize :: new ( DEFAULT_MAX_CONNECTIONS ) . unwrap ( ) ,
95+ NonZeroUsize :: new ( DEFAULT_MAX_PENDING_RESETS ) . unwrap ( ) ,
9896 ) ,
9997 mmds,
10098 }
@@ -105,14 +103,7 @@ impl MmdsNetworkStack {
105103 let ipv4_addr = mmds_ipv4_addr. unwrap_or_else ( || Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ) ;
106104
107105 // The unwrap()s are safe because the given literals are greater than 0.
108- Self :: new (
109- mac_addr,
110- ipv4_addr,
111- DEFAULT_TCP_PORT ,
112- NonZeroUsize :: new ( DEFAULT_MAX_CONNECTIONS ) . unwrap ( ) ,
113- NonZeroUsize :: new ( DEFAULT_MAX_PENDING_RESETS ) . unwrap ( ) ,
114- mmds,
115- )
106+ Self :: new ( mac_addr, ipv4_addr, DEFAULT_TCP_PORT , mmds)
116107 }
117108
118109 pub fn set_ipv4_addr ( & mut self , ipv4_addr : Ipv4Addr ) {
@@ -562,14 +553,8 @@ mod tests {
562553 let ip = Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ;
563554 let other_ip = Ipv4Addr :: new ( 5 , 6 , 7 , 8 ) ;
564555 let mac = MacAddr :: from_bytes_unchecked ( & [ 0 ; 6 ] ) ;
565- let mut ns = MmdsNetworkStack :: new (
566- mac,
567- ip,
568- DEFAULT_TCP_PORT ,
569- NonZeroUsize :: new ( DEFAULT_MAX_CONNECTIONS ) . unwrap ( ) ,
570- NonZeroUsize :: new ( DEFAULT_MAX_PENDING_RESETS ) . unwrap ( ) ,
571- Arc :: new ( Mutex :: new ( Mmds :: default ( ) ) ) ,
572- ) ;
556+ let mut ns =
557+ MmdsNetworkStack :: new_with_defaults ( Some ( ip) , Arc :: new ( Mutex :: new ( Mmds :: default ( ) ) ) ) ;
573558
574559 let mut eth =
575560 EthernetFrame :: write_incomplete ( buf. as_mut ( ) , mac, mac, ETHERTYPE_ARP ) . unwrap ( ) ;
@@ -589,14 +574,8 @@ mod tests {
589574 let ip = Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ;
590575 let other_ip = Ipv4Addr :: new ( 5 , 6 , 7 , 8 ) ;
591576 let mac = MacAddr :: from_bytes_unchecked ( & [ 0 ; 6 ] ) ;
592- let ns = MmdsNetworkStack :: new (
593- mac,
594- ip,
595- DEFAULT_TCP_PORT ,
596- NonZeroUsize :: new ( DEFAULT_MAX_CONNECTIONS ) . unwrap ( ) ,
597- NonZeroUsize :: new ( DEFAULT_MAX_PENDING_RESETS ) . unwrap ( ) ,
598- Arc :: new ( Mutex :: new ( Mmds :: default ( ) ) ) ,
599- ) ;
577+ let ns =
578+ MmdsNetworkStack :: new_with_defaults ( Some ( ip) , Arc :: new ( Mutex :: new ( Mmds :: default ( ) ) ) ) ;
600579
601580 let mut eth =
602581 EthernetFrame :: write_incomplete ( buf. as_mut ( ) , mac, mac, ETHERTYPE_IPV4 ) . unwrap ( ) ;
@@ -615,14 +594,8 @@ mod tests {
615594 let ip = Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ;
616595 let other_ip = Ipv4Addr :: new ( 5 , 6 , 7 , 8 ) ;
617596 let mac = MacAddr :: from_bytes_unchecked ( & [ 0 ; 6 ] ) ;
618- let mut ns = MmdsNetworkStack :: new (
619- mac,
620- ip,
621- DEFAULT_TCP_PORT ,
622- NonZeroUsize :: new ( DEFAULT_MAX_CONNECTIONS ) . unwrap ( ) ,
623- NonZeroUsize :: new ( DEFAULT_MAX_PENDING_RESETS ) . unwrap ( ) ,
624- Arc :: new ( Mutex :: new ( Mmds :: default ( ) ) ) ,
625- ) ;
597+ let mut ns =
598+ MmdsNetworkStack :: new_with_defaults ( Some ( ip) , Arc :: new ( Mutex :: new ( Mmds :: default ( ) ) ) ) ;
626599
627600 // try IPv4 with detour_arp
628601 let mut eth =
0 commit comments