@@ -608,15 +608,15 @@ typedef struct tx_transfer_t
608608 /// they contain the values encoded in the P2P header. This is needed to find pending acks (to minimize duplicates),
609609 /// and to report the correct values via the feedback callback for P2P transfers.
610610 /// By default, upon construction, the remote_* fields equal the local ones, which is valid for ordinary messages.
611- uint64_t topic_hash ;
612- uint64_t transfer_id ;
613- uint64_t remote_topic_hash ;
614- uint64_t remote_transfer_id ;
615- udpard_us_t deadline ;
616- bool reliable ;
617- udpard_prio_t priority ;
618- udpard_udpip_ep_t destination [UDPARD_IFACE_COUNT_MAX ];
619- void * user_transfer_reference ;
611+ uint64_t topic_hash ;
612+ uint64_t transfer_id ;
613+ uint64_t remote_topic_hash ;
614+ uint64_t remote_transfer_id ;
615+ udpard_us_t deadline ;
616+ bool reliable ;
617+ udpard_prio_t priority ;
618+ udpard_udpip_ep_t destination [UDPARD_IFACE_COUNT_MAX ];
619+ udpard_user_context_t user ;
620620
621621 void (* feedback )(udpard_tx_t * , udpard_tx_feedback_t );
622622} tx_transfer_t ;
@@ -649,10 +649,12 @@ static void tx_transfer_free_payload(tx_transfer_t* const tr)
649649static void tx_transfer_retire (udpard_tx_t * const tx , tx_transfer_t * const tr , const bool success )
650650{
651651 // Construct the feedback object first before the transfer is destroyed.
652- const udpard_tx_feedback_t fb = { .topic_hash = tr -> remote_topic_hash ,
653- .transfer_id = tr -> remote_transfer_id ,
654- .user_transfer_reference = tr -> user_transfer_reference ,
655- .success = success };
652+ const udpard_tx_feedback_t fb = {
653+ .topic_hash = tr -> remote_topic_hash ,
654+ .transfer_id = tr -> remote_transfer_id ,
655+ .user = tr -> user ,
656+ .success = success ,
657+ };
656658 UDPARD_ASSERT (tr -> reliable == (tr -> feedback != NULL ));
657659 // save the feedback pointer
658660 void (* const feedback )(udpard_tx_t * , udpard_tx_feedback_t ) = tr -> feedback ;
@@ -876,8 +878,8 @@ static uint32_t tx_push(udpard_tx_t* const tx,
876878 const udpard_udpip_ep_t endpoint [UDPARD_IFACE_COUNT_MAX ],
877879 const udpard_bytes_scattered_t payload ,
878880 void (* const feedback )(udpard_tx_t * , udpard_tx_feedback_t ),
879- void * const user_transfer_reference ,
880- tx_transfer_t * * const out_transfer )
881+ const udpard_user_context_t user ,
882+ tx_transfer_t * * const out_transfer )
881883{
882884 UDPARD_ASSERT (now <= deadline );
883885 UDPARD_ASSERT (tx != NULL );
@@ -900,17 +902,17 @@ static uint32_t tx_push(udpard_tx_t* const tx,
900902 return 0 ;
901903 }
902904 mem_zero (sizeof (* tr ), tr );
903- tr -> epoch = 0 ;
904- tr -> staged_until = now ;
905- tr -> topic_hash = meta .topic_hash ;
906- tr -> transfer_id = meta .transfer_id ;
907- tr -> remote_topic_hash = meta .topic_hash ;
908- tr -> remote_transfer_id = meta .transfer_id ;
909- tr -> deadline = deadline ;
910- tr -> reliable = meta .flag_ack ;
911- tr -> priority = meta .priority ;
912- tr -> user_transfer_reference = user_transfer_reference ;
913- tr -> feedback = feedback ;
905+ tr -> epoch = 0 ;
906+ tr -> staged_until = now ;
907+ tr -> topic_hash = meta .topic_hash ;
908+ tr -> transfer_id = meta .transfer_id ;
909+ tr -> remote_topic_hash = meta .topic_hash ;
910+ tr -> remote_transfer_id = meta .transfer_id ;
911+ tr -> deadline = deadline ;
912+ tr -> reliable = meta .flag_ack ;
913+ tr -> priority = meta .priority ;
914+ tr -> user = user ;
915+ tr -> feedback = feedback ;
914916 for (size_t i = 0 ; i < UDPARD_IFACE_COUNT_MAX ; i ++ ) {
915917 tr -> destination [i ] = endpoint [i ];
916918 tr -> head [i ] = tr -> cursor [i ] = NULL ;
@@ -1057,7 +1059,7 @@ static void tx_send_ack(udpard_rx_t* const rx,
10571059 remote .endpoints ,
10581060 (udpard_bytes_scattered_t ){ .bytes = payload , .next = NULL },
10591061 NULL ,
1060- NULL ,
1062+ UDPARD_USER_CONTEXT_NULL ,
10611063 & tr );
10621064 UDPARD_ASSERT (count <= 1 );
10631065 if (count == 1 ) { // ack is always a single-frame transfer, so we get either 0 or 1
@@ -1119,7 +1121,7 @@ uint32_t udpard_tx_push(udpard_tx_t* const self,
11191121 const uint64_t transfer_id ,
11201122 const udpard_bytes_scattered_t payload ,
11211123 void (* const feedback )(udpard_tx_t * , udpard_tx_feedback_t ),
1122- void * const user_transfer_reference )
1124+ const udpard_user_context_t user )
11231125{
11241126 uint32_t out = 0 ;
11251127 const bool ok = (self != NULL ) && (deadline >= now ) && (now >= 0 ) && (self -> local_uid != 0 ) &&
@@ -1136,7 +1138,7 @@ uint32_t udpard_tx_push(udpard_tx_t* const self,
11361138 .sender_uid = self -> local_uid ,
11371139 .topic_hash = topic_hash ,
11381140 };
1139- out = tx_push (self , now , deadline , meta , remote_ep , payload , feedback , user_transfer_reference , NULL );
1141+ out = tx_push (self , now , deadline , meta , remote_ep , payload , feedback , user , NULL );
11401142 }
11411143 return out ;
11421144}
@@ -1150,7 +1152,7 @@ uint32_t udpard_tx_push_p2p(udpard_tx_t* const self,
11501152 const udpard_remote_t remote ,
11511153 const udpard_bytes_scattered_t payload ,
11521154 void (* const feedback )(udpard_tx_t * , udpard_tx_feedback_t ),
1153- void * const user_transfer_reference )
1155+ const udpard_user_context_t user )
11541156{
11551157 uint32_t out = 0 ;
11561158 const bool ok = (self != NULL ) && (deadline >= now ) && (now >= 0 ) && (self -> local_uid != 0 ) &&
@@ -1179,8 +1181,7 @@ uint32_t udpard_tx_push_p2p(udpard_tx_t* const self,
11791181 .topic_hash = remote .uid ,
11801182 };
11811183 tx_transfer_t * tr = NULL ;
1182- out =
1183- tx_push (self , now , deadline , meta , remote .endpoints , full_payload , feedback , user_transfer_reference , & tr );
1184+ out = tx_push (self , now , deadline , meta , remote .endpoints , full_payload , feedback , user , & tr );
11841185 if (out > 0 ) {
11851186 UDPARD_ASSERT (tr != NULL );
11861187 tr -> remote_topic_hash = request_topic_hash ;
@@ -1252,13 +1253,13 @@ static void tx_eject_pending_frames(udpard_tx_t* const self, const udpard_us_t n
12521253 const bool last_attempt = !cavl2_is_inserted (self -> index_staged , & tr -> index_staged );
12531254 const bool last_frame = frame_next == NULL ; // if not last attempt we will have to rewind to head.
12541255 const udpard_tx_ejection_t ejection = {
1255- .now = now ,
1256- .deadline = tr -> deadline ,
1257- .iface_index = ifindex ,
1258- .dscp = self -> dscp_value_per_priority [tr -> priority ],
1259- .destination = tr -> destination [ifindex ],
1260- .datagram = tx_frame_view (frame ),
1261- .user_transfer_reference = tr -> user_transfer_reference ,
1256+ .now = now ,
1257+ .deadline = tr -> deadline ,
1258+ .iface_index = ifindex ,
1259+ .dscp = self -> dscp_value_per_priority [tr -> priority ],
1260+ .destination = tr -> destination [ifindex ],
1261+ .datagram = tx_frame_view (frame ),
1262+ .user = tr -> user ,
12621263 };
12631264 if (!self -> vtable -> eject (self , ejection )) { // The easy case -- no progress was made at this time;
12641265 break ; // don't change anything, just try again later as-is
0 commit comments