PPP, PPPoS moved fd from ppp_pcb to pppos_pcb

Moved fd from ppp_pcb to pppos_pcb.

However PPP ioctl PPPCTLG_FD is temporarily disabled until I found a
better solution.
This commit is contained in:
Sylvain Rochet 2015-02-15 22:56:28 +01:00
parent 1ac4d1b793
commit 4aa9244b92
4 changed files with 16 additions and 17 deletions

View File

@ -352,9 +352,6 @@ struct ppp_pcb_s {
u8_t num; /* Interface number - only useful for debugging */ u8_t num; /* Interface number - only useful for debugging */
#endif /* PPP_DEBUG */ #endif /* PPP_DEBUG */
ppp_settings settings; ppp_settings settings;
#if PPPOS_SUPPORT
sio_fd_t fd; /* File device ID of port. */
#endif /* PPPOS_SUPPORT */
link_command_cb_fn link_command_cb; link_command_cb_fn link_command_cb;
link_write_cb_fn link_write_cb; link_write_cb_fn link_write_cb;
link_netif_output_cb_fn link_netif_output_cb; link_netif_output_cb_fn link_netif_output_cb;

View File

@ -44,7 +44,8 @@
*/ */
typedef struct pppos_pcb_s pppos_pcb; typedef struct pppos_pcb_s pppos_pcb;
struct pppos_pcb_s { struct pppos_pcb_s {
ppp_pcb *ppp; /* PPP PCB */ ppp_pcb *ppp; /* PPP PCB */
sio_fd_t fd; /* File device ID of port. */
}; };
/* Create a new PPPoS session. */ /* Create a new PPPoS session. */

View File

@ -783,7 +783,7 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg)
return PPPERR_PARAM; return PPPERR_PARAM;
break; break;
#if PPPOS_SUPPORT #if 0/*PPPOS_SUPPORT*/
case PPPCTLG_FD: /* Get the fd associated with the ppp */ case PPPCTLG_FD: /* Get the fd associated with the ppp */
if (arg) { if (arg) {
*(sio_fd_t *)arg = pcb->fd; *(sio_fd_t *)arg = pcb->fd;

View File

@ -61,7 +61,7 @@ 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 */
static void pppos_xmit(ppp_pcb *pcb, struct pbuf *nb); static void pppos_xmit(pppos_pcb *sc, struct pbuf *nb);
static void pppos_free_current_input_packet(ppp_pcb_rx *pcrx); static void pppos_free_current_input_packet(ppp_pcb_rx *pcrx);
static struct pbuf *pppos_append(u_char c, struct pbuf *nb, ext_accm *out_accm); static struct pbuf *pppos_append(u_char c, struct pbuf *nb, ext_accm *out_accm);
static void pppos_drop(ppp_pcb_rx *pcrx); static void pppos_drop(ppp_pcb_rx *pcrx);
@ -112,7 +112,7 @@ ppp_over_serial_create(struct netif *pppif, sio_fd_t fd,
} }
sc->ppp = ppp; sc->ppp = ppp;
ppp->fd = fd; sc->fd = fd;
ppp_link_set_callbacks(ppp, pppos_link_command_callback, pppos_link_write_callback, pppos_link_netif_output_callback, sc); ppp_link_set_callbacks(ppp, pppos_link_command_callback, pppos_link_write_callback, pppos_link_netif_output_callback, sc);
return ppp; return ppp;
} }
@ -205,7 +205,7 @@ pppos_link_write_callback(void *pcb, struct pbuf *p)
PPPDEBUG(LOG_INFO, ("ppp_write[%d]: len=%d\n", ppp->num, head->len)); PPPDEBUG(LOG_INFO, ("ppp_write[%d]: len=%d\n", ppp->num, head->len));
/* "ppp_write[%d]: %d:%.*H", pd, head->len, LWIP_MIN(head->len * 2, 40), head->payload)); */ /* "ppp_write[%d]: %d:%.*H", pd, head->len, LWIP_MIN(head->len * 2, 40), head->payload)); */
pppos_xmit(ppp, head); pppos_xmit(sc, head);
pbuf_free(p); pbuf_free(p);
return PPPERR_NONE; return PPPERR_NONE;
} }
@ -321,7 +321,7 @@ pppos_link_netif_output_callback(void *pcb, struct pbuf *pb, u_short protocol)
/* Send it. */ /* Send it. */
PPPDEBUG(LOG_INFO, ("ppp_netif_output[%d]: proto=0x%"X16_F"\n", ppp->num, protocol)); PPPDEBUG(LOG_INFO, ("ppp_netif_output[%d]: proto=0x%"X16_F"\n", ppp->num, protocol));
pppos_xmit(ppp, head); pppos_xmit(sc, head);
return ERR_OK; return ERR_OK;
} }
@ -336,7 +336,7 @@ pppos_connect(pppos_pcb *pcb)
ppp_clear(ppp); ppp_clear(ppp);
ppp->rx.pcb = ppp; ppp->rx.pcb = ppp;
ppp->rx.fd = ppp->fd; ppp->rx.fd = pcb->fd;
#if VJ_SUPPORT #if VJ_SUPPORT
vj_compress_init(&ppp->vj_comp); vj_compress_init(&ppp->vj_comp);
@ -650,26 +650,27 @@ drop:
#endif /* PPP_INPROC_MULTITHREADED */ #endif /* PPP_INPROC_MULTITHREADED */
static void static void
pppos_xmit(ppp_pcb *pcb, struct pbuf *nb) pppos_xmit(pppos_pcb *sc, struct pbuf *nb)
{ {
ppp_pcb *ppp = sc->ppp;
struct pbuf *b; struct pbuf *b;
int c; int c;
for(b = nb; b != NULL; b = b->next) { for(b = nb; b != NULL; b = b->next) {
c = sio_write(pcb->fd, (u8_t*)b->payload, b->len); c = sio_write(sc->fd, (u8_t*)b->payload, b->len);
if(c != b->len) { if(c != b->len) {
PPPDEBUG(LOG_WARNING, PPPDEBUG(LOG_WARNING,
("PPP pppos_xmit: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (size_t)pcb->fd, b->len, c, c)); ("PPP pppos_xmit: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (size_t)sc->fd, b->len, c, c));
LINK_STATS_INC(link.err); LINK_STATS_INC(link.err);
pcb->last_xmit = 0; /* prepend PPP_FLAG to next packet */ ppp->last_xmit = 0; /* prepend PPP_FLAG to next packet */
snmp_inc_ifoutdiscards(pcb->netif); snmp_inc_ifoutdiscards(ppp->netif);
pbuf_free(nb); pbuf_free(nb);
return; return;
} }
} }
snmp_add_ifoutoctets(pcb->netif, nb->tot_len); snmp_add_ifoutoctets(ppp->netif, nb->tot_len);
snmp_inc_ifoutucastpkts(pcb->netif); snmp_inc_ifoutucastpkts(ppp->netif);
pbuf_free(nb); pbuf_free(nb);
LINK_STATS_INC(link.xmit); LINK_STATS_INC(link.xmit);
} }