PPP, PPPoS, moved ppp.rx to pppos.rx

PPP rx control block moved to PPPoS
This commit is contained in:
Sylvain Rochet 2015-02-17 00:05:45 +01:00
parent 7132893863
commit 34210901bf
4 changed files with 69 additions and 60 deletions

View File

@ -306,37 +306,6 @@ struct ppp_addrs {
* Extended asyncmap - allows any character to be escaped.
*/
typedef u_char ext_accm[32];
/* PPP packet parser states. Current state indicates operation yet to be
* completed. */
typedef enum {
PDIDLE = 0, /* Idle state - waiting. */
PDSTART, /* Process start flag. */
PDADDRESS, /* Process address field. */
PDCONTROL, /* Process control field. */
PDPROTOCOL1, /* Process protocol field 1. */
PDPROTOCOL2, /* Process protocol field 2. */
PDDATA /* Process data byte. */
} ppp_dev_states;
/*
* PPP interface RX control block.
*/
typedef struct ppp_pcb_rx_s {
/** ppp descriptor */
ppp_pcb *pcb;
/** the rx file descriptor */
sio_fd_t fd;
/* The input packet. */
struct pbuf *in_head, *in_tail;
u16_t in_protocol; /* The input protocol code. */
u16_t in_fcs; /* Input Frame Check Sequence value. */
ppp_dev_states in_state; /* The input process state. */
char in_escaped; /* Escape next character. */
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
} ppp_pcb_rx;
#endif /* PPPOS_SUPPORT */
/*
@ -402,7 +371,6 @@ struct ppp_pcb_s {
/* FIXME: there is probably one superfluous */
ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
ext_accm xmit_accm; /* extended transmit ACCM */
ppp_pcb_rx rx;
#endif /* PPPOS_SUPPORT */
u32_t last_xmit; /* Time of last transmission. */

View File

@ -43,6 +43,37 @@
#include "ppp.h"
#include "vj.h"
/* PPP packet parser states. Current state indicates operation yet to be
* completed. */
typedef enum {
PDIDLE = 0, /* Idle state - waiting. */
PDSTART, /* Process start flag. */
PDADDRESS, /* Process address field. */
PDCONTROL, /* Process control field. */
PDPROTOCOL1, /* Process protocol field 1. */
PDPROTOCOL2, /* Process protocol field 2. */
PDDATA /* Process data byte. */
} pppos_rx_state;
/*
* PPP interface RX control block.
*/
typedef struct ppp_pcb_rx_s {
/** ppp descriptor */
ppp_pcb *pcb;
/** the rx file descriptor */
sio_fd_t fd;
/* The input packet. */
struct pbuf *in_head, *in_tail;
u16_t in_protocol; /* The input protocol code. */
u16_t in_fcs; /* Input Frame Check Sequence value. */
pppos_rx_state in_state; /* The input process state. */
char in_escaped; /* Escape next character. */
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
} ppp_pcb_rx;
/*
* PPPoS interface control block.
*/
@ -51,6 +82,7 @@ struct pppos_pcb_s {
pppos_pcb *next;
ppp_pcb *ppp; /* PPP PCB */
sio_fd_t fd; /* File device ID of port. */
ppp_pcb_rx rx;
#if VJ_SUPPORT
struct vjcompress vj_comp; /* Van Jacobson compression header. */
#endif /* VJ_SUPPORT */
@ -64,6 +96,7 @@ ppp_pcb *ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
void pppos_input(ppp_pcb *ppp, u_char* data, int len);
void pppos_accm_in_config(pppos_pcb *pppos, u32_t accm);
sio_fd_t pppos_get_fd(pppos_pcb *pppos);
void pppos_vjc_config(pppos_pcb *pppos, int vjcomp, int cidcomp, int maxcid);
int pppos_vjc_comp(pppos_pcb *pppos, struct pbuf *pb);

View File

@ -931,34 +931,17 @@ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) {
* the ppp interface.
*/
int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp) {
#if PPPOS_SUPPORT
int i;
SYS_ARCH_DECL_PROTECT(lev);
#endif /* PPPOS_SUPPORT */
LWIP_UNUSED_ARG(accomp);
LWIP_UNUSED_ARG(pcomp);
LWIP_UNUSED_ARG(mru);
/* Load the ACCM bits for the 32 control codes. */
#if PPPOS_SUPPORT
SYS_ARCH_PROTECT(lev);
for (i = 0; i < 32 / 8; i++) {
/* @todo: does this work? ext_accm has been modified from pppd! */
pcb->rx.in_accm[i] = (u_char)(accm >> (i * 8));
}
SYS_ARCH_UNPROTECT(lev);
#else
pppos_accm_in_config((pppos_pcb*)pcb->link_ctx_cb, accm);
#else /* PPPOS_SUPPORT */
LWIP_UNUSED_ARG(accm);
#endif /* PPPOS_SUPPORT */
#if PPPOS_SUPPORT
PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]: in_accm=%X %X %X %X\n",
pcb->num,
pcb->rx.in_accm[0], pcb->rx.in_accm[1], pcb->rx.in_accm[2], pcb->rx.in_accm[3]));
#else
PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]\n", pcb->num) );
#endif /* PPPOS_SUPPORT */
PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]\n", pcb->num));
return 0;
}

View File

@ -406,12 +406,14 @@ pppos_connect(pppos_pcb *pppos)
#endif /* !VJ_SUPPORT */
/* input pbuf left over from last session? */
pppos_free_current_input_packet(&ppp->rx);
pppos_free_current_input_packet(&pppos->rx);
ppp_clear(ppp);
/* reset PPPoS control block to its initial state */
memset(&pppos->rx, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->rx - (char*)0 ) );
ppp->rx.pcb = ppp;
ppp->rx.fd = pppos->fd;
pppos->rx.pcb = ppp;
pppos->rx.fd = pppos->fd;
#if VJ_SUPPORT
vj_compress_init(&pppos->vj_comp);
@ -430,7 +432,7 @@ pppos_connect(pppos_pcb *pppos)
* Default the in and out accm so that escape and flag characters
* are always escaped.
*/
ppp->rx.in_accm[15] = 0x60; /* no need to protect since RX is not running */
pppos->rx.in_accm[15] = 0x60; /* no need to protect since RX is not running */
ppp->out_accm[15] = 0x60;
/*
@ -454,7 +456,6 @@ pppos_disconnect(pppos_pcb *pppos)
static err_t
pppos_destroy(pppos_pcb *pppos)
{
ppp_pcb *ppp = pppos->ppp;
pppos_pcb **copp, *freep;
/* remove interface from list */
@ -466,7 +467,7 @@ pppos_destroy(pppos_pcb *pppos)
}
/* input pbuf left ? */
pppos_free_current_input_packet(&ppp->rx);
pppos_free_current_input_packet(&pppos->rx);
memp_free(MEMP_PPPOS_PCB, pppos);
return ERR_OK;
@ -498,8 +499,8 @@ PACK_STRUCT_END
void
pppos_input(ppp_pcb *ppp, u_char *s, int l)
{
ppp_pcb_rx *pcrx = &ppp->rx;
pppos_pcb *pppos = (pppos_pcb *)ppp->link_ctx_cb;
ppp_pcb_rx *pcrx = &pppos->rx;
struct pbuf *next_pbuf;
u_char cur_char;
u_char escaped;
@ -743,6 +744,30 @@ drop:
}
#endif /* PPP_INPROC_MULTITHREADED */
void
pppos_accm_in_config(pppos_pcb *pppos, u32_t accm)
{
ppp_pcb *ppp;
int i;
SYS_ARCH_DECL_PROTECT(lev);
if (!pppos_exist(pppos)) {
return;
}
ppp = pppos->ppp;
/* Load the ACCM bits for the 32 control codes. */
SYS_ARCH_PROTECT(lev);
for (i = 0; i < 32 / 8; i++) {
pppos->rx.in_accm[i] = (u_char)(accm >> (i * 8));
}
SYS_ARCH_UNPROTECT(lev);
PPPDEBUG(LOG_INFO, ("pppos_accm_in_config[%d]: in_accm=%X %X %X %X\n",
ppp->num,
pppos->rx.in_accm[0], pppos->rx.in_accm[1], pppos->rx.in_accm[2], pppos->rx.in_accm[3]));
}
sio_fd_t
pppos_get_fd(pppos_pcb *pppos)
{
@ -900,7 +925,7 @@ pppos_append(u_char c, struct pbuf *nb, ext_accm *out_accm)
static void
pppos_drop(pppos_pcb *pppos)
{
ppp_pcb_rx *pcrx = &pppos->ppp->rx;
ppp_pcb_rx *pcrx = &pppos->rx;
#if LWIP_SNMP
ppp_pcb *ppp = pppos->ppp;
#endif /* LWIP_SNMP || VJ_SUPPORT */