mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-13 07:14:31 +00:00
PPP, add PPPoS CB for PPPoS private data
Created a new PPPoS CB going to have PPPoS private data, so allocating a PPPoE or a PPPoL2TP interface does not allocate as well PPPoS variables.
This commit is contained in:
parent
9c15ffbb74
commit
ea205f2fcd
@ -60,6 +60,7 @@
|
|||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
#include "lwip/netdb.h"
|
#include "lwip/netdb.h"
|
||||||
#include "netif/ppp/ppp.h"
|
#include "netif/ppp/ppp.h"
|
||||||
|
#include "netif/ppp/pppos.h"
|
||||||
#include "netif/ppp/pppoe.h"
|
#include "netif/ppp/pppoe.h"
|
||||||
#include "netif/ppp/pppol2tp.h"
|
#include "netif/ppp/pppol2tp.h"
|
||||||
#include "lwip/nd6.h"
|
#include "lwip/nd6.h"
|
||||||
|
@ -102,6 +102,9 @@ LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE,
|
|||||||
|
|
||||||
#if PPP_SUPPORT
|
#if PPP_SUPPORT
|
||||||
LWIP_MEMPOOL(PPP_PCB, MEMP_NUM_PPP_PCB, sizeof(ppp_pcb), "PPP_PCB")
|
LWIP_MEMPOOL(PPP_PCB, MEMP_NUM_PPP_PCB, sizeof(ppp_pcb), "PPP_PCB")
|
||||||
|
#if PPPOS_SUPPORT
|
||||||
|
LWIP_MEMPOOL(PPPOS_PCB, MEMP_NUM_PPPOS_INTERFACES, sizeof(pppos_pcb), "PPPOS_PCB")
|
||||||
|
#endif /* PPPOS_SUPPORT */
|
||||||
#if PPPOE_SUPPORT
|
#if PPPOE_SUPPORT
|
||||||
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||||
#endif /* PPPOE_SUPPORT */
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
@ -416,6 +416,14 @@
|
|||||||
#define MEMP_NUM_PPP_PCB 1
|
#define MEMP_NUM_PPP_PCB 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS
|
||||||
|
* interfaces (only used with PPPOS_SUPPORT==1)
|
||||||
|
*/
|
||||||
|
#ifndef MEMP_NUM_PPPOS_INTERFACES
|
||||||
|
#define MEMP_NUM_PPPOS_INTERFACES MEMP_NUM_PPP_PCB
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
|
* MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
|
||||||
* interfaces (only used with PPPOE_SUPPORT==1)
|
* interfaces (only used with PPPOE_SUPPORT==1)
|
||||||
|
@ -39,6 +39,14 @@
|
|||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PPPoS interface control block.
|
||||||
|
*/
|
||||||
|
typedef struct pppos_pcb_s pppos_pcb;
|
||||||
|
struct pppos_pcb_s {
|
||||||
|
ppp_pcb *ppp; /* PPP PCB */
|
||||||
|
};
|
||||||
|
|
||||||
/* Create a new PPPoS session. */
|
/* Create a new PPPoS session. */
|
||||||
ppp_pcb *ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
|
ppp_pcb *ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
|
||||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||||
|
@ -54,9 +54,9 @@ static int pppos_link_write_callback(void *pcb, struct pbuf *p);
|
|||||||
static err_t pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol);
|
static err_t pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol);
|
||||||
|
|
||||||
/* Prototypes for procedures local to this file. */
|
/* Prototypes for procedures local to this file. */
|
||||||
static void pppos_connect(ppp_pcb *pcb);
|
static void pppos_connect(pppos_pcb *pcb);
|
||||||
static void pppos_disconnect(ppp_pcb *pcb);
|
static void pppos_disconnect(pppos_pcb *pcb);
|
||||||
static err_t pppos_destroy(ppp_pcb *sc);
|
static err_t pppos_destroy(pppos_pcb *sc);
|
||||||
#if PPP_INPROC_MULTITHREADED
|
#if PPP_INPROC_MULTITHREADED
|
||||||
static void pppos_input_callback(void *arg);
|
static void pppos_input_callback(void *arg);
|
||||||
#endif /* PPP_INPROC_MULTITHREADED */
|
#endif /* PPP_INPROC_MULTITHREADED */
|
||||||
@ -96,6 +96,7 @@ ppp_pcb *
|
|||||||
ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
|
ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
|
||||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb)
|
ppp_link_status_cb_fn link_status_cb, void *ctx_cb)
|
||||||
{
|
{
|
||||||
|
pppos_pcb *sc;
|
||||||
ppp_pcb *ppp;
|
ppp_pcb *ppp;
|
||||||
|
|
||||||
ppp = ppp_new(pppif, link_status_cb, ctx_cb);
|
ppp = ppp_new(pppif, link_status_cb, ctx_cb);
|
||||||
@ -103,8 +104,15 @@ ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sc = (pppos_pcb *)memp_malloc(MEMP_PPPOS_PCB);
|
||||||
|
if (sc == NULL) {
|
||||||
|
ppp_free(ppp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sc->ppp = ppp;
|
||||||
ppp->fd = fd;
|
ppp->fd = fd;
|
||||||
ppp_link_set_callbacks(ppp, pppos_link_command_callback, pppos_link_write_callback, pppos_link_netif_output_callback, ppp);
|
ppp_link_set_callbacks(ppp, pppos_link_command_callback, pppos_link_write_callback, pppos_link_netif_output_callback, sc);
|
||||||
return ppp;
|
return ppp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,19 +120,19 @@ ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
|
|||||||
static void
|
static void
|
||||||
pppos_link_command_callback(void *pcb, u8_t command)
|
pppos_link_command_callback(void *pcb, u8_t command)
|
||||||
{
|
{
|
||||||
ppp_pcb *ppp = (ppp_pcb *)pcb;
|
pppos_pcb *sc = (pppos_pcb *)pcb;
|
||||||
|
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case PPP_LINK_COMMAND_CONNECT:
|
case PPP_LINK_COMMAND_CONNECT:
|
||||||
pppos_connect(ppp);
|
pppos_connect(sc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_LINK_COMMAND_DISCONNECT:
|
case PPP_LINK_COMMAND_DISCONNECT:
|
||||||
pppos_disconnect(ppp);
|
pppos_disconnect(sc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_LINK_COMMAND_FREE:
|
case PPP_LINK_COMMAND_FREE:
|
||||||
pppos_destroy(ppp);
|
pppos_destroy(sc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: ;
|
default: ;
|
||||||
@ -135,7 +143,8 @@ pppos_link_command_callback(void *pcb, u8_t command)
|
|||||||
static int
|
static int
|
||||||
pppos_link_write_callback(void *pcb, struct pbuf *p)
|
pppos_link_write_callback(void *pcb, struct pbuf *p)
|
||||||
{
|
{
|
||||||
ppp_pcb *ppp = (ppp_pcb *)pcb;
|
pppos_pcb *sc = (pppos_pcb *)pcb;
|
||||||
|
ppp_pcb *ppp = sc->ppp;
|
||||||
u_char *s = (u_char*)p->payload;
|
u_char *s = (u_char*)p->payload;
|
||||||
int n = p->len;
|
int n = p->len;
|
||||||
u_char c;
|
u_char c;
|
||||||
@ -204,7 +213,8 @@ pppos_link_write_callback(void *pcb, struct pbuf *p)
|
|||||||
static err_t
|
static err_t
|
||||||
pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol)
|
pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol)
|
||||||
{
|
{
|
||||||
ppp_pcb *ppp = (ppp_pcb *)pcb;
|
pppos_pcb *sc = (pppos_pcb *)pcb;
|
||||||
|
ppp_pcb *ppp = sc->ppp;
|
||||||
u_int fcs_out = PPP_INITFCS;
|
u_int fcs_out = PPP_INITFCS;
|
||||||
struct pbuf *head = NULL, *tail = NULL, *p;
|
struct pbuf *head = NULL, *tail = NULL, *p;
|
||||||
u_char c;
|
u_char c;
|
||||||
@ -315,49 +325,56 @@ pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pppos_connect(ppp_pcb *pcb)
|
pppos_connect(pppos_pcb *pcb)
|
||||||
{
|
{
|
||||||
|
ppp_pcb *ppp = pcb->ppp;
|
||||||
|
|
||||||
/* input pbuf left over from last session? */
|
/* input pbuf left over from last session? */
|
||||||
pppos_free_current_input_packet(&pcb->rx);
|
pppos_free_current_input_packet(&ppp->rx);
|
||||||
|
|
||||||
ppp_clear(pcb);
|
ppp_clear(ppp);
|
||||||
|
|
||||||
pcb->rx.pcb = pcb;
|
ppp->rx.pcb = ppp;
|
||||||
pcb->rx.fd = pcb->fd;
|
ppp->rx.fd = ppp->fd;
|
||||||
|
|
||||||
#if VJ_SUPPORT
|
#if VJ_SUPPORT
|
||||||
vj_compress_init(&pcb->vj_comp);
|
vj_compress_init(&ppp->vj_comp);
|
||||||
#endif /* VJ_SUPPORT */
|
#endif /* VJ_SUPPORT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default the in and out accm so that escape and flag characters
|
* Default the in and out accm so that escape and flag characters
|
||||||
* are always escaped.
|
* are always escaped.
|
||||||
*/
|
*/
|
||||||
pcb->rx.in_accm[15] = 0x60; /* no need to protect since RX is not running */
|
ppp->rx.in_accm[15] = 0x60; /* no need to protect since RX is not running */
|
||||||
pcb->out_accm[15] = 0x60;
|
ppp->out_accm[15] = 0x60;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the connection and handle incoming events (packet or timeout).
|
* Start the connection and handle incoming events (packet or timeout).
|
||||||
*/
|
*/
|
||||||
PPPDEBUG(LOG_INFO, ("pppos_connect: unit %d: connecting\n", pcb->num));
|
PPPDEBUG(LOG_INFO, ("pppos_connect: unit %d: connecting\n", ppp->num));
|
||||||
ppp_start(pcb); /* notify upper layers */
|
ppp_start(ppp); /* notify upper layers */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pppos_disconnect(ppp_pcb *pcb)
|
pppos_disconnect(pppos_pcb *pcb)
|
||||||
{
|
{
|
||||||
|
ppp_pcb *ppp = pcb->ppp;
|
||||||
|
|
||||||
/* We cannot call ppp_free_current_input_packet() here because
|
/* We cannot call ppp_free_current_input_packet() here because
|
||||||
* rx thread might still call pppos_input()
|
* rx thread might still call pppos_input()
|
||||||
*/
|
*/
|
||||||
ppp_link_end(pcb); /* notify upper layers */
|
ppp_link_end(ppp); /* notify upper layers */
|
||||||
}
|
}
|
||||||
|
|
||||||
static err_t
|
static err_t
|
||||||
pppos_destroy(ppp_pcb *pcb)
|
pppos_destroy(pppos_pcb *sc)
|
||||||
{
|
{
|
||||||
|
ppp_pcb *ppp = sc->ppp;
|
||||||
|
|
||||||
/* input pbuf left ? */
|
/* input pbuf left ? */
|
||||||
pppos_free_current_input_packet(&pcb->rx);
|
pppos_free_current_input_packet(&ppp->rx);
|
||||||
|
|
||||||
|
memp_free(MEMP_PPPOS_PCB, sc);
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user