@@ -68,7 +68,7 @@ namespace net {
6868 // Report to application layer that got an ICMP error message of type and code (reason and subreason)
6969
7070 // Find callback with this destination address and port, and call it with the incoming err
71- auto it = error_callbacks_.find (std::make_pair ( dest.address (), dest.port ()) );
71+ auto it = error_callbacks_.find (Socket{ dest.address (), dest.port ()} );
7272
7373 if (it != error_callbacks_.end ()) {
7474 it->second .callback (err);
@@ -143,10 +143,8 @@ namespace net {
143143 INFO (" UDP" , " Flushing expired error callbacks" );
144144
145145 for (auto & err : error_callbacks_) {
146- if (err.second .expired ()) {
147- // error_callbacks_.second.callback(ICMP_error{});
146+ if (err.second .expired ())
148147 error_callbacks_.erase (err.first );
149- }
150148 }
151149
152150 if (not error_callbacks_.empty ())
@@ -164,10 +162,13 @@ namespace net {
164162 num--;
165163
166164 if (buffer.done ()) {
167- if (buffer.callback != nullptr ) {
165+ if (buffer.send_callback != nullptr )
166+ buffer.send_callback ();
167+
168+ if (buffer.error_callback != nullptr ) {
168169 error_callbacks_.emplace (std::piecewise_construct,
169- std::forward_as_tuple (std::make_pair ( buffer.d_addr , buffer.d_port ) ),
170- std::forward_as_tuple (Error_entry{buffer.callback }));
170+ std::forward_as_tuple (Socket{ buffer.d_addr , buffer.d_port } ),
171+ std::forward_as_tuple (Error_entry{buffer.error_callback }));
171172
172173 if (UNLIKELY (not flush_timer_.is_running ()))
173174 flush_timer_.start (flush_interval_);
@@ -194,9 +195,9 @@ namespace net {
194195 return P;
195196 }
196197
197- UDP::WriteBuffer::WriteBuffer (const uint8_t * data, size_t length, sendto_handler cb,
198+ UDP::WriteBuffer::WriteBuffer (const uint8_t * data, size_t length, sendto_handler cb, error_handler ecb,
198199 UDP& stack, addr_t LA, port_t LP, addr_t DA, port_t DP)
199- : len(length), offset(0 ), callback (cb), udp(stack),
200+ : len(length), offset(0 ), send_callback (cb), error_callback(ecb ), udp(stack),
200201 l_addr (LA), l_port(LP), d_port(DP), d_addr(DA)
201202 {
202203 // create a copy of the data,
0 commit comments