add calls to user callback and adjust formating

pull/4589/head
Jacob Barthelmeh 2021-11-29 15:56:00 -07:00
parent 7e2fab6f4a
commit f7c34d22e6
3 changed files with 23 additions and 11 deletions

View File

@ -2567,8 +2567,7 @@ int LwIPNativeSend(WOLFSSL* ssl, char* buf, int sz, void* ctx)
}
int LwIPNativeReceive(WOLFSSL* ssl, char* buf, int sz,
void* ctx)
int LwIPNativeReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx)
{
struct pbuf *current, *head;
WOLFSSL_LWIP_NATIVE_STATE* nlwip;
@ -2660,6 +2659,10 @@ static err_t LwIPNativeReceiveCB(void* cb, struct tcp_pcb* pcb,
}
}
if (nlwip->recv_fn) {
return nlwip->recv_fn(nlwip->arg, pcb, pbuf, err);
}
WOLFSSL_LEAVE("LwIPNativeReceiveCB", nlwip->pbuf->tot_len);
return ERR_OK;
}
@ -2667,9 +2670,17 @@ static err_t LwIPNativeReceiveCB(void* cb, struct tcp_pcb* pcb,
static err_t LwIPNativeSentCB(void* cb, struct tcp_pcb* pcb, u16_t len)
{
(void)cb;
(void)pcb;
(void)len;
WOLFSSL_LWIP_NATIVE_STATE* nlwip;
if (cb == NULL || pcb == NULL) {
WOLFSSL_MSG("Expected callback was null, abort");
return ERR_ABRT;
}
nlwip = (WOLFSSL_LWIP_NATIVE_STATE*)cb;
if (nlwip->sent_fn) {
return nlwip->sent_fn(nlwip->arg, pcb, len);
}
return ERR_OK;
}
@ -2691,7 +2702,7 @@ int wolfSSL_SetIO_LwIP(WOLFSSL* ssl, void* pcb,
/* wolfSSL_LwIP_recv/sent_cb invokes recv/sent user callback in them. */
tcp_recv(pcb, LwIPNativeReceiveCB);
tcp_sent(pcb, LwIPNativeSentCB);
tcp_arg (pcb, (void *)&(ssl->lwipCtx));
tcp_arg (pcb, (void *)&ssl->lwipCtx);
wolfSSL_SetIOReadCtx(ssl, &ssl->lwipCtx);
wolfSSL_SetIOWriteCtx(ssl, &ssl->lwipCtx);

View File

@ -2485,7 +2485,8 @@ time_t stm32_hal_time(time_t *t1)
RTC_TimeTypeDef time;
RTC_DateTypeDef date;
/* must get time and date here due to STM32 HW bug */
/* order of GetTime followed by GetDate required here due to STM32 HW
* requirement */
HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN);