@@ -81,8 +81,6 @@ impl MmdsNetworkStack {
81
81
mac_addr : MacAddr ,
82
82
ipv4_addr : Ipv4Addr ,
83
83
tcp_port : u16 ,
84
- max_connections : NonZeroUsize ,
85
- max_pending_resets : NonZeroUsize ,
86
84
mmds : Arc < Mutex < Mmds > > ,
87
85
) -> Self {
88
86
MmdsNetworkStack {
@@ -93,8 +91,8 @@ impl MmdsNetworkStack {
93
91
tcp_handler : TcpIPv4Handler :: new (
94
92
ipv4_addr,
95
93
tcp_port,
96
- max_connections ,
97
- max_pending_resets ,
94
+ NonZeroUsize :: new ( DEFAULT_MAX_CONNECTIONS ) . unwrap ( ) ,
95
+ NonZeroUsize :: new ( DEFAULT_MAX_PENDING_RESETS ) . unwrap ( ) ,
98
96
) ,
99
97
mmds,
100
98
}
@@ -105,14 +103,7 @@ impl MmdsNetworkStack {
105
103
let ipv4_addr = mmds_ipv4_addr. unwrap_or_else ( || Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ) ;
106
104
107
105
// 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)
116
107
}
117
108
118
109
pub fn set_ipv4_addr ( & mut self , ipv4_addr : Ipv4Addr ) {
@@ -562,14 +553,8 @@ mod tests {
562
553
let ip = Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ;
563
554
let other_ip = Ipv4Addr :: new ( 5 , 6 , 7 , 8 ) ;
564
555
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 ( ) ) ) ) ;
573
558
574
559
let mut eth =
575
560
EthernetFrame :: write_incomplete ( buf. as_mut ( ) , mac, mac, ETHERTYPE_ARP ) . unwrap ( ) ;
@@ -589,14 +574,8 @@ mod tests {
589
574
let ip = Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ;
590
575
let other_ip = Ipv4Addr :: new ( 5 , 6 , 7 , 8 ) ;
591
576
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 ( ) ) ) ) ;
600
579
601
580
let mut eth =
602
581
EthernetFrame :: write_incomplete ( buf. as_mut ( ) , mac, mac, ETHERTYPE_IPV4 ) . unwrap ( ) ;
@@ -615,14 +594,8 @@ mod tests {
615
594
let ip = Ipv4Addr :: from ( DEFAULT_IPV4_ADDR ) ;
616
595
let other_ip = Ipv4Addr :: new ( 5 , 6 , 7 , 8 ) ;
617
596
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 ( ) ) ) ) ;
626
599
627
600
// try IPv4 with detour_arp
628
601
let mut eth =
0 commit comments