PPP, PPPoS, add pppos_input_tcpip() input helper function for !NO_SYS users

This commit is contained in:
Sylvain Rochet 2015-03-11 09:28:35 +01:00
parent 4b035b9902
commit 77f7d99048
2 changed files with 33 additions and 1 deletions

View File

@ -103,6 +103,11 @@ struct pppos_pcb_s {
ppp_pcb *pppos_create(struct netif *pppif, sio_fd_t fd,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#if !NO_SYS
/* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */
err_t pppos_input_tcpip(ppp_pcb *ppp, u_char *s, int l);
#endif /* !NO_SYS */
/* PPP over Serial: this is the input function to be called for received data. */
void pppos_input(ppp_pcb *ppp, u_char* data, int len);

View File

@ -528,6 +528,33 @@ pppos_destroy(ppp_pcb *ppp, void *ctx)
}
#if !NO_SYS
/** Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread.
*
* @param pcb PPP descriptor index, returned by pppos_create()
* @param data received data
* @param len length of received data
*/
err_t
pppos_input_tcpip(ppp_pcb *ppp, u_char *s, int l)
{
struct pbuf *p, *n;
u8_t *cur;
p = pbuf_alloc(PBUF_RAW, l, PBUF_POOL);
if (!p) {
return ERR_MEM;
}
cur = s;
for (n = p; n; n = n->next) {
MEMCPY(n->payload, cur, n->len);
cur += n->len;
}
return tcpip_input(p, ppp_netif(ppp));
}
/* called from TCPIP thread */
static err_t pppos_input_sys(struct pbuf *p, struct netif *inp) {
ppp_pcb *ppp = (ppp_pcb*)inp->state;
struct pbuf *n;
@ -565,7 +592,7 @@ PACK_STRUCT_END
* thread safe. You should also avoid calling pppos_input() if PPPoS session
* is not started yet.
*
* @param pcb PPP descriptor index, returned by ppp_new()
* @param pcb PPP descriptor index, returned by pppos_create()
* @param data received data
* @param len length of received data
*/