@@ -189,21 +189,21 @@ impl Packet {
189
189
}
190
190
191
191
/// shows packet/message contents as pretty string for debug
192
- pub async fn pkt_debug ( payload : & [ u8 ] ) -> Result < ( ) > {
192
+ pub async fn pkt_debug ( pkt : & Packet ) -> Result < ( ) > {
193
193
// don't run further if we are not in Debug mode
194
194
if !log_enabled ! ( Level :: Debug ) {
195
195
return Ok ( ( ) ) ;
196
196
}
197
197
198
198
// message_id is the first 2 bytes of payload
199
- let message_id: i32 = u16:: from_be_bytes ( payload[ 0 ..=1 ] . try_into ( ) ?) . into ( ) ;
199
+ let message_id: i32 = u16:: from_be_bytes ( pkt . payload [ 0 ..=1 ] . try_into ( ) ?) . into ( ) ;
200
200
201
201
// trying to obtain an Enum from message_id
202
202
let control = protos:: ControlMessageType :: from_i32 ( message_id) ;
203
203
debug ! ( "message_id = {:04X}, {:?}" , message_id, control) ;
204
204
205
205
// parsing data
206
- let data = & payload[ 2 ..] ; // start of message data
206
+ let data = & pkt . payload [ 2 ..] ; // start of message data
207
207
let message: & dyn MessageDyn = match control. unwrap_or ( MESSAGE_UNEXPECTED_MESSAGE ) {
208
208
MESSAGE_AUTH_COMPLETE => & AuthResponse :: parse_from_bytes ( data) ?,
209
209
MESSAGE_SERVICE_DISCOVERY_REQUEST => & ServiceDiscoveryRequest :: parse_from_bytes ( data) ?,
@@ -466,7 +466,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
466
466
if proxy_type == ProxyType :: HeadUnit {
467
467
// waiting for initial version frame (HU is starting transmission)
468
468
let pkt = rxr. recv ( ) . await . ok_or ( "reader channel hung up" ) ?;
469
- let _ = pkt_debug ( & pkt. payload ) . await ;
469
+ let _ = pkt_debug ( & pkt) . await ;
470
470
// sending to the MD
471
471
tx. send ( pkt) . await ?;
472
472
// waiting for MD reply
@@ -496,7 +496,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
496
496
pkt. transmit ( & mut device) . await ?;
497
497
// waiting for MD reply
498
498
let pkt = rxr. recv ( ) . await . ok_or ( "reader channel hung up" ) ?;
499
- let _ = pkt_debug ( & pkt. payload ) . await ;
499
+ let _ = pkt_debug ( & pkt) . await ;
500
500
// sending reply back to the HU
501
501
tx. send ( pkt) . await ?;
502
502
@@ -546,7 +546,7 @@ pub async fn proxy<A: Endpoint<A> + 'static>(
546
546
if let Ok ( mut pkt) = rxr. try_recv ( ) {
547
547
match pkt. decrypt_payload ( & mut mem_buf, & mut server) . await {
548
548
Ok ( _) => {
549
- let _ = pkt_debug ( & pkt. payload ) . await ;
549
+ let _ = pkt_debug ( & pkt) . await ;
550
550
tx. send ( pkt) . await ?;
551
551
}
552
552
Err ( e) => error ! ( "decrypt_payload: {:?}" , e) ,
0 commit comments