PPP, PPPoS, moved out_accm from PPP core to PPPoS

Last PPPoS variable in PPP core moved to PPPoS.
This commit is contained in:
Sylvain Rochet 2015-02-17 00:48:33 +01:00
parent baaa2592a6
commit 69469496e2
5 changed files with 43 additions and 42 deletions

View File

@ -300,14 +300,6 @@ struct ppp_addrs {
#endif /* PPP_IPV6_SUPPORT */
};
/* FIXME: find a way to move ppp_dev_states and ppp_pcb_rx_s to ppp_impl.h */
#if PPPOS_SUPPORT
/*
* Extended asyncmap - allows any character to be escaped.
*/
typedef u_char ext_accm[32];
#endif /* PPPOS_SUPPORT */
/*
* PPP interface control block.
*/
@ -367,10 +359,6 @@ struct ppp_pcb_s {
#endif /* VJ_SUPPORT */
unsigned int :5; /* 5 bits of padding to round out to 16 bits */
#if PPPOS_SUPPORT
ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
#endif /* PPPOS_SUPPORT */
u32_t last_xmit; /* Time of last transmission. */
struct ppp_addrs addrs; /* PPP addresses */

View File

@ -401,9 +401,6 @@ struct pbuf * ppp_singlebuf(struct pbuf *p);
*/
void new_phase(ppp_pcb *pcb, int p);
#if PPPOS_SUPPORT
void ppp_set_xaccm(ppp_pcb *pcb, ext_accm *accm);
#endif /* PPPOS_SUPPORT */
int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp);
int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp);

View File

@ -55,6 +55,11 @@ typedef enum {
PDDATA /* Process data byte. */
} pppos_rx_state;
/*
* Extended asyncmap - allows any character to be escaped.
*/
typedef u_char ext_accm[32];
/*
* PPPoS interface control block.
*/
@ -67,9 +72,10 @@ struct pppos_pcb_s {
/* -- below are data that will be cleared between two sessions
*
* in_accm must be the first member of cleared members, because it is
* out_accm must be the first member of cleared members, because it is
* used to know which part must not be cleared.
*/
ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
/* PPPoS rx */
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
@ -91,6 +97,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_out_config(pppos_pcb *pppos, u32_t accm);
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);

View File

@ -882,9 +882,6 @@ void new_phase(ppp_pcb *pcb, int p) {
* the ppp interface.
*/
int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) {
#if PPPOS_SUPPORT
int i;
#endif /* PPPOS_SUPPORT */
LWIP_UNUSED_ARG(mtu);
/* pcb->mtu = mtu; -- set correctly with netif_set_mtu */
@ -892,21 +889,12 @@ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) {
pcb->accomp = accomp;
#if PPPOS_SUPPORT
/* Load the ACCM bits for the 32 control codes. */
for (i = 0; i < 32/8; i++) {
pcb->out_accm[i] = (u_char)((accm >> (8 * i)) & 0xFF);
}
#else
pppos_accm_out_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_send_config[%d]: out_accm=%X %X %X %X\n",
pcb->num,
pcb->out_accm[0], pcb->out_accm[1], pcb->out_accm[2], pcb->out_accm[3]));
#else
PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]\n", pcb->num) );
#endif /* PPPOS_SUPPORT */
return 0;
}

View File

@ -238,14 +238,14 @@ pppos_link_write_callback(void *pcb, struct pbuf *p)
fcs_out = PPP_FCS(fcs_out, c);
/* Copy to output buffer escaping special characters. */
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
}
/* Add FCS and trailing flag. */
c = ~fcs_out & 0xFF;
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
c = (~fcs_out >> 8) & 0xFF;
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
tail = pppos_append(PPP_FLAG, tail, NULL);
/* If we failed to complete the packet, throw it away.
@ -327,18 +327,18 @@ pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol)
ppp->last_xmit = sys_jiffies();
if (!ppp->accomp) {
fcs_out = PPP_FCS(fcs_out, PPP_ALLSTATIONS);
tail = pppos_append(PPP_ALLSTATIONS, tail, &ppp->out_accm);
tail = pppos_append(PPP_ALLSTATIONS, tail, &pppos->out_accm);
fcs_out = PPP_FCS(fcs_out, PPP_UI);
tail = pppos_append(PPP_UI, tail, &ppp->out_accm);
tail = pppos_append(PPP_UI, tail, &pppos->out_accm);
}
if (!ppp->pcomp || protocol > 0xFF) {
c = (protocol >> 8) & 0xFF;
fcs_out = PPP_FCS(fcs_out, c);
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
}
c = protocol & 0xFF;
fcs_out = PPP_FCS(fcs_out, c);
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
/* Load packet. */
for(p = pb; p; p = p->next) {
@ -354,15 +354,15 @@ pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol)
fcs_out = PPP_FCS(fcs_out, c);
/* Copy to output buffer escaping special characters. */
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
}
}
/* Add FCS and trailing flag. */
c = ~fcs_out & 0xFF;
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
c = (~fcs_out >> 8) & 0xFF;
tail = pppos_append(c, tail, &ppp->out_accm);
tail = pppos_append(c, tail, &pppos->out_accm);
tail = pppos_append(PPP_FLAG, tail, NULL);
/* If we failed to complete the packet, throw it away. */
@ -410,7 +410,7 @@ pppos_connect(pppos_pcb *pppos)
ppp_clear(ppp);
/* reset PPPoS control block to its initial state */
memset(&pppos->in_accm, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->in_accm - (char*)0 ) );
memset(&pppos->out_accm, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->out_accm - (char*)0 ) );
#if VJ_SUPPORT
vj_compress_init(&pppos->vj_comp);
@ -430,7 +430,7 @@ pppos_connect(pppos_pcb *pppos)
* are always escaped.
*/
pppos->in_accm[15] = 0x60; /* no need to protect since RX is not running */
ppp->out_accm[15] = 0x60;
pppos->out_accm[15] = 0x60;
/*
* Start the connection and handle incoming events (packet or timeout).
@ -740,6 +740,27 @@ drop:
}
#endif /* PPP_INPROC_MULTITHREADED */
void
pppos_accm_out_config(pppos_pcb *pppos, u32_t accm)
{
ppp_pcb *ppp;
int i;
if (!pppos_exist(pppos)) {
return;
}
ppp = pppos->ppp;
/* Load the ACCM bits for the 32 control codes. */
for (i = 0; i < 32/8; i++) {
pppos->out_accm[i] = (u_char)((accm >> (8 * i)) & 0xFF);
}
PPPDEBUG(LOG_INFO, ("pppos_accm_out_config[%d]: in_accm=%X %X %X %X\n",
ppp->num,
pppos->out_accm[0], pppos->out_accm[1], pppos->out_accm[2], pppos->out_accm[3]));
}
void
pppos_accm_in_config(pppos_pcb *pppos, u32_t accm)
{