* @ingroup lwip_os * Call a specific function in the thread context of * tcpip_thread for easy access synchronization. * A function called in that way may access lwIP core code * without fearing concurrent access. * Blocks until the request is posted. * Must not be called from interrupt context! * * @param function the function to call * @param ctx parameter passed to f * @return ERR_OK
| 306 | * @see tcpip_try_callback |
| 307 | */ |
| 308 | err_t |
| 309 | tcpip_callback(tcpip_callback_fn function, void *ctx) |
| 310 | { |
| 311 | struct tcpip_msg *msg; |
| 312 | |
| 313 | LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox)); |
| 314 | |
| 315 | msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API); |
| 316 | if (msg == NULL) { |
| 317 | return ERR_MEM; |
| 318 | } |
| 319 | |
| 320 | msg->type = TCPIP_MSG_CALLBACK; |
| 321 | msg->msg.cb.function = function; |
| 322 | msg->msg.cb.ctx = ctx; |
| 323 | |
| 324 | sys_mbox_post(&tcpip_mbox, msg); |
| 325 | return ERR_OK; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * @ingroup lwip_os |
no test coverage detected