mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-06-16 09:53:45 +08:00
PPP, PPPoS, replaced static sio_write() calls to a user defined callback
The overall lwIP design on data flows (netif,udp,tcp) is to use a user defined callback to get data from stack and a static function to send data to stack, which makes perfect sense. The SIO port was an exception, the PPP stack never really used the SIO port by only using the sio_send() function (and the ignominious sio_read_abort() function a while back). The way the SIO port is currently designed adds a tight coupling between the lwIP port and the user code if the user need to do specific user code if the current uart used is the PPPoS uart, which is not nice, especially because all the lwIP stack is quite clean at this subject. While we are at stabilizing the PPP API, change this behavior before it's too late by replacing the static sio_write() calls to a user defined callback.
This commit is contained in:
22
doc/ppp.txt
22
doc/ppp.txt
@@ -183,17 +183,30 @@ static void status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
|
||||
|
||||
#include "netif/ppp/pppos.h"
|
||||
|
||||
/*
|
||||
* PPPoS serial output callback
|
||||
*
|
||||
* ppp_pcb, PPP control block
|
||||
* data, buffer to write to serial port
|
||||
* len, length of the data buffer
|
||||
* ctx, optional user-provided callback context pointer
|
||||
*
|
||||
* Return value: len if write succeed
|
||||
*/
|
||||
static u32_t output_cb(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx) {
|
||||
return uart_write(UART, data, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new PPPoS interface
|
||||
*
|
||||
* ppp_netif, netif to use for this PPP link, i.e. PPP IP interface
|
||||
* ppp_sio, handler to your SIO port (see include/lwip/sio.h)
|
||||
* output_cb, PPPoS serial output callback
|
||||
* status_cb, PPP status callback, called on PPP status change (up, down, …)
|
||||
* ctx_cb, optional user-provided callback context pointer
|
||||
*/
|
||||
ppp = pppos_create(&ppp_netif,
|
||||
ppp_sio,
|
||||
status_cb, ctx_cb);
|
||||
output_cb, status_cb, ctx_cb);
|
||||
|
||||
|
||||
/*
|
||||
@@ -304,7 +317,6 @@ ppp_free(ppp);
|
||||
3 PPPoS input path (raw API, IRQ safe API, TCPIP API)
|
||||
=====================================================
|
||||
|
||||
PPPoS requires a serial I/O SIO port (see include/lwip/sio.h).
|
||||
Received data on serial port should be sent to lwIP using the pppos_input()
|
||||
function or the pppos_input_sys() function.
|
||||
|
||||
@@ -405,3 +417,5 @@ from previous lwIP version is pretty easy:
|
||||
unconditionally registering them, which is probably the wanted behavior in
|
||||
almost all cases. If you need it conditional contact us and we will made it
|
||||
conditional.
|
||||
|
||||
* PPPoS now requires a serial output callback
|
||||
|
||||
Reference in New Issue
Block a user