mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 13:34:38 +08:00
added PPP Sequential API module, based from the Network Interface Sequential API module
This commit is contained in:
parent
f31b905847
commit
d92c462466
278
src/api/pppapi.c
Normal file
278
src/api/pppapi.c
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Point To Point Protocol Sequential API module
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
|
#if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
|
#include "lwip/pppapi.h"
|
||||||
|
#include "lwip/tcpip.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_new() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_new(struct pppapi_msg_msg *msg) {
|
||||||
|
msg->ppp = ppp_new();
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_new() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
ppp_pcb *pppapi_new(void) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_new;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
return msg.msg.ppp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_set_auth() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_set_auth(struct pppapi_msg_msg *msg) {
|
||||||
|
ppp_set_auth(msg->ppp, msg->msg.setauth.authtype,
|
||||||
|
msg->msg.setauth.user, msg->msg.setauth.passwd);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_set_auth() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_set_auth;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.setauth.authtype = authtype;
|
||||||
|
msg.msg.msg.setauth.user = user;
|
||||||
|
msg.msg.msg.setauth.passwd = passwd;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if PPPOS_SUPPORT
|
||||||
|
/**
|
||||||
|
* Call ppp_over_serial_open() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_over_serial_open(struct pppapi_msg_msg *msg) {
|
||||||
|
msg->err = ppp_over_serial_open(msg->ppp, msg->msg.serialopen.fd,
|
||||||
|
msg->msg.serialopen.link_status_cb, msg->msg.serialopen.link_status_ctx);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_over_serial_open() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
int pppapi_over_serial_open(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_over_serial_open;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.serialopen.fd = fd;
|
||||||
|
msg.msg.msg.serialopen.link_status_cb = link_status_cb;
|
||||||
|
msg.msg.msg.serialopen.link_status_ctx = link_status_ctx;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
return msg.msg.err;
|
||||||
|
}
|
||||||
|
#endif /* PPPOS_SUPPORT */
|
||||||
|
|
||||||
|
|
||||||
|
#if PPPOE_SUPPORT
|
||||||
|
/**
|
||||||
|
* Call ppp_over_ethernet_open() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_over_ethernet_open(struct pppapi_msg_msg *msg) {
|
||||||
|
|
||||||
|
msg->err = ppp_over_ethernet_open(msg->ppp, msg->msg.ethernetopen.ethif,
|
||||||
|
msg->msg.ethernetopen.service_name, msg->msg.ethernetopen.concentrator_name,
|
||||||
|
msg->msg.ethernetopen.link_status_cb, msg->msg.ethernetopen.link_status_ctx);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_over_ethernet_open() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
int pppapi_over_ethernet_open(ppp_pcb *pcb, struct netif *ethif, const char *service_name,
|
||||||
|
const char *concentrator_name, ppp_link_status_cb_fn link_status_cb,
|
||||||
|
void *link_status_ctx) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_over_ethernet_open;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.ethernetopen.ethif = ethif;
|
||||||
|
msg.msg.msg.ethernetopen.service_name = service_name;
|
||||||
|
msg.msg.msg.ethernetopen.concentrator_name = concentrator_name;
|
||||||
|
msg.msg.msg.ethernetopen.link_status_cb = link_status_cb;
|
||||||
|
msg.msg.msg.ethernetopen.link_status_ctx = link_status_ctx;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
return msg.msg.err;
|
||||||
|
}
|
||||||
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_close() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_close(struct pppapi_msg_msg *msg) {
|
||||||
|
msg->err = ppp_close(msg->ppp);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_close() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
int pppapi_close(ppp_pcb *pcb) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_close;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
return msg.msg.err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_sighup() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_sighup(struct pppapi_msg_msg *msg) {
|
||||||
|
ppp_sighup(msg->ppp);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_sighup() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
void pppapi_sighup(ppp_pcb *pcb) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_sighup;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_ioctl() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_ioctl(struct pppapi_msg_msg *msg) {
|
||||||
|
msg->err = ppp_ioctl(msg->ppp, msg->msg.ioctl.cmd, msg->msg.ioctl.arg);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_ioctl() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
int pppapi_ioctl(ppp_pcb *pcb, int cmd, void *arg) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_ioctl;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.ioctl.cmd = cmd;
|
||||||
|
msg.msg.msg.ioctl.arg = arg;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
return msg.msg.err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
|
||||||
|
/**
|
||||||
|
* Call pppos_input() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_pppos_input(struct pppapi_msg_msg *msg) {
|
||||||
|
pppos_input(msg->ppp, msg->msg.ppposinput.data, msg->msg.ppposinput.len);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call pppos_input() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
void ppposapi_input(ppp_pcb *pcb, u_char* data, int len) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_pppos_input;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.ppposinput.data = data;
|
||||||
|
msg.msg.msg.ppposinput.len = len;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
}
|
||||||
|
#endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
|
||||||
|
|
||||||
|
|
||||||
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
|
/**
|
||||||
|
* Call ppp_set_netif_statuscallback() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_set_netif_statuscallback(struct pppapi_msg_msg *msg) {
|
||||||
|
ppp_set_netif_statuscallback(msg->ppp, msg->msg.netifstatuscallback.status_callback);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_set_netif_statuscallback() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
void pppapi_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_set_netif_statuscallback;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.netifstatuscallback.status_callback = status_callback;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
}
|
||||||
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
|
||||||
|
|
||||||
|
#if LWIP_NETIF_LINK_CALLBACK
|
||||||
|
/**
|
||||||
|
* Call ppp_set_netif_linkcallback() inside the tcpip_thread context.
|
||||||
|
*/
|
||||||
|
static void pppapi_do_ppp_set_netif_linkcallback(struct pppapi_msg_msg *msg) {
|
||||||
|
ppp_set_netif_linkcallback(msg->ppp, msg->msg.netiflinkcallback.link_callback);
|
||||||
|
TCPIP_PPPAPI_ACK(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call ppp_set_netif_linkcallback() in a thread-safe way by running that function inside the
|
||||||
|
* tcpip_thread context.
|
||||||
|
*/
|
||||||
|
void pppapi_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback) {
|
||||||
|
struct pppapi_msg msg;
|
||||||
|
msg.function = pppapi_do_ppp_set_netif_linkcallback;
|
||||||
|
msg.msg.ppp = pcb;
|
||||||
|
msg.msg.msg.netiflinkcallback.link_callback = link_callback;
|
||||||
|
TCPIP_PPPAPI(&msg);
|
||||||
|
}
|
||||||
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||||
|
|
||||||
|
#endif /* LWIP_PPP_API */
|
@ -122,6 +122,13 @@ tcpip_thread(void *arg)
|
|||||||
break;
|
break;
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
|
||||||
|
#if LWIP_PPP_API
|
||||||
|
case TCPIP_MSG_PPPAPI:
|
||||||
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PPP API message %p\n", (void *)msg));
|
||||||
|
msg->msg.pppapimsg->function(&(msg->msg.pppapimsg->msg));
|
||||||
|
break;
|
||||||
|
#endif /* LWIP_PPP_API */
|
||||||
|
|
||||||
#if LWIP_TCPIP_TIMEOUT
|
#if LWIP_TCPIP_TIMEOUT
|
||||||
case TCPIP_MSG_TIMEOUT:
|
case TCPIP_MSG_TIMEOUT:
|
||||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg));
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg));
|
||||||
@ -378,6 +385,56 @@ tcpip_netifapi_lock(struct netifapi_msg* netifapimsg)
|
|||||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
|
||||||
|
#if LWIP_PPP_API
|
||||||
|
#if !LWIP_TCPIP_CORE_LOCKING
|
||||||
|
/**
|
||||||
|
* Much like tcpip_apimsg, but calls the lower part of a pppapi_*
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
* @param pppapimsg a struct containing the function to call and its parameters
|
||||||
|
* @return error code given back by the function that was called
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
tcpip_pppapi(struct pppapi_msg* pppapimsg)
|
||||||
|
{
|
||||||
|
struct tcpip_msg msg;
|
||||||
|
|
||||||
|
if (sys_mbox_valid(&mbox)) {
|
||||||
|
err_t err = sys_sem_new(&pppapimsg->msg.sem, 0);
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
pppapimsg->msg.err = err;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.type = TCPIP_MSG_PPPAPI;
|
||||||
|
msg.msg.pppapimsg = pppapimsg;
|
||||||
|
sys_mbox_post(&mbox, &msg);
|
||||||
|
sys_sem_wait(&pppapimsg->msg.sem);
|
||||||
|
sys_sem_free(&pppapimsg->msg.sem);
|
||||||
|
return pppapimsg->msg.err;
|
||||||
|
}
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
#else /* !LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
/**
|
||||||
|
* Call the lower part of a pppapi_* function
|
||||||
|
* This function has exclusive access to lwIP core code by locking it
|
||||||
|
* before the function is called.
|
||||||
|
*
|
||||||
|
* @param pppapimsg a struct containing the function to call and its parameters
|
||||||
|
* @return ERR_OK (only for compatibility fo tcpip_pppapi())
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
tcpip_pppapi_lock(struct pppapi_msg* pppapimsg)
|
||||||
|
{
|
||||||
|
LOCK_TCPIP_CORE();
|
||||||
|
pppapimsg->function(&(pppapimsg->msg));
|
||||||
|
UNLOCK_TCPIP_CORE();
|
||||||
|
return pppapimsg->msg.err;
|
||||||
|
}
|
||||||
|
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
#endif /* LWIP_PPP_API */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a structure for a static callback message and initialize it.
|
* Allocate a structure for a static callback message and initialize it.
|
||||||
* This is intended to be used to send "static" messages from interrupt context.
|
* This is intended to be used to send "static" messages from interrupt context.
|
||||||
|
@ -1703,6 +1703,13 @@
|
|||||||
|
|
||||||
#if PPP_SUPPORT
|
#if PPP_SUPPORT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LWIP_PPP_API==1: Support PPP API (in pppapi.c)
|
||||||
|
*/
|
||||||
|
#ifndef LWIP_PPP_API
|
||||||
|
#define LWIP_PPP_API 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation
|
* PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation
|
||||||
*/
|
*/
|
||||||
|
128
src/include/lwip/pppapi.h
Normal file
128
src/include/lwip/pppapi.h
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LWIP_PPPAPI_H__
|
||||||
|
#define __LWIP_PPPAPI_H__
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
|
#if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
#include "ppp.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct pppapi_msg_msg {
|
||||||
|
#if !LWIP_TCPIP_CORE_LOCKING
|
||||||
|
sys_sem_t sem;
|
||||||
|
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
int err;
|
||||||
|
ppp_pcb *ppp;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
u8_t authtype;
|
||||||
|
char *user;
|
||||||
|
char *passwd;
|
||||||
|
} setauth;
|
||||||
|
#if PPPOS_SUPPORT
|
||||||
|
struct {
|
||||||
|
sio_fd_t fd;
|
||||||
|
ppp_link_status_cb_fn link_status_cb;
|
||||||
|
void *link_status_ctx;
|
||||||
|
} serialopen;
|
||||||
|
#endif /* PPPOS_SUPPORT */
|
||||||
|
#if PPPOE_SUPPORT
|
||||||
|
struct {
|
||||||
|
struct netif *ethif;
|
||||||
|
const char *service_name;
|
||||||
|
const char *concentrator_name;
|
||||||
|
ppp_link_status_cb_fn link_status_cb;
|
||||||
|
void *link_status_ctx;
|
||||||
|
} ethernetopen;
|
||||||
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
struct {
|
||||||
|
int cmd;
|
||||||
|
void *arg;
|
||||||
|
} ioctl;
|
||||||
|
#if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
|
||||||
|
struct {
|
||||||
|
u_char *data;
|
||||||
|
int len;
|
||||||
|
} ppposinput;
|
||||||
|
#endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
|
||||||
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
|
struct {
|
||||||
|
netif_status_callback_fn status_callback;
|
||||||
|
} netifstatuscallback;
|
||||||
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
#if LWIP_NETIF_LINK_CALLBACK
|
||||||
|
struct {
|
||||||
|
netif_status_callback_fn link_callback;
|
||||||
|
} netiflinkcallback;
|
||||||
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||||
|
} msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pppapi_msg {
|
||||||
|
void (* function)(struct pppapi_msg_msg *msg);
|
||||||
|
struct pppapi_msg_msg msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* API for application */
|
||||||
|
ppp_pcb *pppapi_new(void);
|
||||||
|
void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd);
|
||||||
|
#if PPPOS_SUPPORT
|
||||||
|
int pppapi_over_serial_open(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx);
|
||||||
|
#endif /* PPPOS_SUPPORT */
|
||||||
|
#if PPPOE_SUPPORT
|
||||||
|
int pppapi_over_ethernet_open(ppp_pcb *pcb, struct netif *ethif, const char *service_name,
|
||||||
|
const char *concentrator_name, ppp_link_status_cb_fn link_status_cb,
|
||||||
|
void *link_status_ctx);
|
||||||
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
int pppapi_close(ppp_pcb *pcb);
|
||||||
|
void pppapi_sighup(ppp_pcb *pcb);
|
||||||
|
int pppapi_ioctl(ppp_pcb *pcb, int cmd, void *arg);
|
||||||
|
#if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
|
||||||
|
void ppposapi_input(ppp_pcb *pcb, u_char* data, int len);
|
||||||
|
#endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
|
||||||
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
|
void pppapi_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback);
|
||||||
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
#if LWIP_NETIF_LINK_CALLBACK
|
||||||
|
void pppapi_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback);
|
||||||
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LWIP_PPP_API */
|
||||||
|
|
||||||
|
#endif /* __LWIP_PPPAPI_H__ */
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "lwip/api_msg.h"
|
#include "lwip/api_msg.h"
|
||||||
#include "lwip/netifapi.h"
|
#include "lwip/netifapi.h"
|
||||||
|
#include "lwip/pppapi.h"
|
||||||
#include "lwip/pbuf.h"
|
#include "lwip/pbuf.h"
|
||||||
#include "lwip/api.h"
|
#include "lwip/api.h"
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
@ -77,6 +78,8 @@ extern sys_mutex_t lock_tcpip_core;
|
|||||||
#define TCPIP_APIMSG_ACK(m)
|
#define TCPIP_APIMSG_ACK(m)
|
||||||
#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
|
#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
|
||||||
#define TCPIP_NETIFAPI_ACK(m)
|
#define TCPIP_NETIFAPI_ACK(m)
|
||||||
|
#define TCPIP_PPPAPI(m) tcpip_pppapi_lock(m)
|
||||||
|
#define TCPIP_PPPAPI_ACK(m)
|
||||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
#define LOCK_TCPIP_CORE()
|
#define LOCK_TCPIP_CORE()
|
||||||
#define UNLOCK_TCPIP_CORE()
|
#define UNLOCK_TCPIP_CORE()
|
||||||
@ -85,6 +88,8 @@ extern sys_mutex_t lock_tcpip_core;
|
|||||||
#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
|
#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
|
||||||
#define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
|
#define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
|
||||||
#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
|
#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
|
||||||
|
#define TCPIP_PPPAPI(m) tcpip_pppapi(m)
|
||||||
|
#define TCPIP_PPPAPI_ACK(m) sys_sem_signal(&m->sem)
|
||||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
|
||||||
/** Function prototype for the init_done function passed to tcpip_init */
|
/** Function prototype for the init_done function passed to tcpip_init */
|
||||||
@ -110,6 +115,13 @@ err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
|
|||||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
|
||||||
|
#if LWIP_PPP_API
|
||||||
|
err_t tcpip_pppapi(struct pppapi_msg *pppapimsg);
|
||||||
|
#if LWIP_TCPIP_CORE_LOCKING
|
||||||
|
err_t tcpip_pppapi_lock(struct pppapi_msg *pppapimsg);
|
||||||
|
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
|
#endif /* LWIP_PPP_API */
|
||||||
|
|
||||||
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
|
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
|
||||||
#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
|
#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
|
||||||
|
|
||||||
@ -134,6 +146,9 @@ enum tcpip_msg_type {
|
|||||||
#if LWIP_NETIF_API
|
#if LWIP_NETIF_API
|
||||||
TCPIP_MSG_NETIFAPI,
|
TCPIP_MSG_NETIFAPI,
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
#if LWIP_PPP_API
|
||||||
|
TCPIP_MSG_PPPAPI,
|
||||||
|
#endif /* LWIP_PPP_API */
|
||||||
#if LWIP_TCPIP_TIMEOUT
|
#if LWIP_TCPIP_TIMEOUT
|
||||||
TCPIP_MSG_TIMEOUT,
|
TCPIP_MSG_TIMEOUT,
|
||||||
TCPIP_MSG_UNTIMEOUT,
|
TCPIP_MSG_UNTIMEOUT,
|
||||||
@ -152,6 +167,9 @@ struct tcpip_msg {
|
|||||||
#if LWIP_NETIF_API
|
#if LWIP_NETIF_API
|
||||||
struct netifapi_msg *netifapimsg;
|
struct netifapi_msg *netifapimsg;
|
||||||
#endif /* LWIP_NETIF_API */
|
#endif /* LWIP_NETIF_API */
|
||||||
|
#if LWIP_PPP_API
|
||||||
|
struct pppapi_msg *pppapimsg;
|
||||||
|
#endif /* LWIP_PPP_API */
|
||||||
struct {
|
struct {
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
|
@ -1738,7 +1738,7 @@ static void ppp_destroy(ppp_pcb *pcb) {
|
|||||||
void
|
void
|
||||||
ppp_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback)
|
ppp_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback)
|
||||||
{
|
{
|
||||||
netif_set_status_callback(pcb->netif, status_callback);
|
netif_set_status_callback(&pcb->netif, status_callback);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
|
||||||
@ -1753,7 +1753,7 @@ ppp_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callb
|
|||||||
void
|
void
|
||||||
ppp_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback)
|
ppp_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback)
|
||||||
{
|
{
|
||||||
netif_set_link_callback(pcb->netif, link_callback);
|
netif_set_link_callback(&pcb->netif, link_callback);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user