Lines Matching defs:pppos
51 #include "netif/ppp/pppos.h"
73 static void pppos_input_free_current_packet(pppos_pcb *pppos);
74 static void pppos_input_drop(pppos_pcb *pppos);
75 static err_t pppos_output_append(pppos_pcb *pppos, err_t err, struct pbuf *nb, u8_t c, u8_t accm, u16_t *fcs);
76 static err_t pppos_output_last(pppos_pcb *pppos, err_t err, struct pbuf *nb, u16_t *fcs);
177 pppos_pcb *pppos;
181 pppos = (pppos_pcb *)LWIP_MEMPOOL_ALLOC(PPPOS_PCB);
182 if (pppos == NULL) {
186 ppp = ppp_new(pppif, &pppos_callbacks, pppos, link_status_cb, ctx_cb);
188 LWIP_MEMPOOL_FREE(PPPOS_PCB, pppos);
192 memset(pppos, 0, sizeof(pppos_pcb));
193 pppos->ppp = ppp;
194 pppos->output_cb = output_cb;
202 pppos_pcb *pppos = (pppos_pcb *)ctx;
229 if ((sys_now() - pppos->last_xmit) >= PPP_MAXIDLEFLAG) {
230 err = pppos_output_append(pppos, err, nb, PPP_FLAG, 0, NULL);
238 err = pppos_output_append(pppos, err, nb, *s++, 1, &fcs_out);
241 err = pppos_output_last(pppos, err, nb, &fcs_out);
255 pppos_pcb *pppos = (pppos_pcb *)ctx;
279 if ((sys_now() - pppos->last_xmit) >= PPP_MAXIDLEFLAG) {
280 err = pppos_output_append(pppos, err, nb, PPP_FLAG, 0, NULL);
284 if (!pppos->accomp) {
285 err = pppos_output_append(pppos, err, nb, PPP_ALLSTATIONS, 1, &fcs_out);
286 err = pppos_output_append(pppos, err, nb, PPP_UI, 1, &fcs_out);
288 if (!pppos->pcomp || protocol > 0xFF) {
289 err = pppos_output_append(pppos, err, nb, (protocol >> 8) & 0xFF, 1, &fcs_out);
291 err = pppos_output_append(pppos, err, nb, protocol & 0xFF, 1, &fcs_out);
299 err = pppos_output_append(pppos, err, nb, *s++, 1, &fcs_out);
303 err = pppos_output_last(pppos, err, nb, &fcs_out);
315 pppos_pcb *pppos = (pppos_pcb *)ctx;
320 pppos_input_free_current_packet(pppos);
324 memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - offsetof(pppos_pcb, last_xmit));
330 pppos->in_accm[15] = 0x60; /* no need to protect since RX is not running */
331 pppos->out_accm[15] = 0x60;
333 pppos->open = 1;
347 pppos_pcb *pppos = (pppos_pcb *)ctx;
352 pppos_input_free_current_packet(pppos);
356 memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - offsetof(pppos_pcb, last_xmit));
362 pppos->in_accm[15] = 0x60; /* no need to protect since RX is not running */
363 pppos->out_accm[15] = 0x60;
365 pppos->open = 1;
379 pppos_pcb *pppos = (pppos_pcb *)ctx;
383 pppos->open = 0;
392 pppos_input_free_current_packet(pppos);
401 pppos_pcb *pppos = (pppos_pcb *)ctx;
406 pppos_input_free_current_packet(pppos);
409 LWIP_MEMPOOL_FREE(PPPOS_PCB, pppos);
480 pppos_pcb *pppos = (pppos_pcb *)ppp->link_ctx_cb;
499 if (!pppos->open) {
503 escaped = ESCAPE_P(pppos->in_accm, cur_char);
513 pppos->in_escaped = 1;
517 if (pppos->in_state <= PDADDRESS) {
520 } else if (pppos->in_state < PDDATA) {
523 ppp->netif->num, pppos->in_state));
525 pppos_input_drop(pppos);
527 } else if (pppos->in_fcs != PPP_GOODFCS) {
530 ppp->netif->num, pppos->in_fcs, pppos->in_protocol));
533 pppos_input_drop(pppos);
538 if(pppos->in_tail->len > 2) {
539 pppos->in_tail->len -= 2;
541 pppos->in_tail->tot_len = pppos->in_tail->len;
542 if (pppos->in_tail != pppos->in_head) {
543 pbuf_cat(pppos->in_head, pppos->in_tail);
546 pppos->in_tail->tot_len = pppos->in_tail->len;
547 if (pppos->in_tail != pppos->in_head) {
548 pbuf_cat(pppos->in_head, pppos->in_tail);
551 pbuf_realloc(pppos->in_head, pppos->in_head->tot_len - 2);
555 inp = pppos->in_head;
557 pppos->in_head = NULL;
558 pppos->in_tail = NULL;
576 pppos->in_fcs = PPP_INITFCS;
577 pppos->in_state = PDADDRESS;
578 pppos->in_escaped = 0;
588 if (pppos->in_escaped) {
589 pppos->in_escaped = 0;
594 switch(pppos->in_state) {
606 pppos->in_fcs = PPP_INITFCS;
612 pppos->in_state = PDCONTROL;
623 pppos->in_state = PDPROTOCOL1;
632 pppos->in_state = PDSTART;
641 pppos->in_protocol = cur_char;
642 pppos->in_state = PDDATA;
644 pppos->in_protocol = (u16_t)cur_char << 8;
645 pppos->in_state = PDPROTOCOL2;
649 pppos->in_protocol |= cur_char;
650 pppos->in_state = PDDATA;
654 if (pppos->in_tail == NULL || pppos->in_tail->len == PBUF_POOL_BUFSIZE) {
656 if (pppos->in_tail != NULL) {
657 pppos->in_tail->tot_len = pppos->in_tail->len;
658 if (pppos->in_tail != pppos->in_head) {
659 pbuf_cat(pppos->in_head, pppos->in_tail);
661 pppos->in_tail = NULL;
671 if (pppos->in_head == NULL) {
682 pppos_input_drop(pppos);
683 pppos->in_state = PDSTART; /* Wait for flag sequence. */
686 if (pppos->in_head == NULL) {
693 next_pbuf->len += sizeof(pppos->in_protocol);
694 *(payload++) = pppos->in_protocol >> 8;
695 *(payload) = pppos->in_protocol & 0xFF;
696 pppos->in_head = next_pbuf;
698 pppos->in_tail = next_pbuf;
701 ((u8_t*)pppos->in_tail->payload)[pppos->in_tail->len++] = cur_char;
708 pppos->in_fcs = PPP_FCS(pppos->in_fcs, cur_char);
741 pppos_pcb *pppos = (pppos_pcb *)ctx;
744 pppos->pcomp = pcomp;
745 pppos->accomp = accomp;
749 pppos->out_accm[i] = (u8_t)((accm >> (8 * i)) & 0xFF);
753 pppos->ppp->netif->num,
754 pppos->out_accm[0], pppos->out_accm[1], pppos->out_accm[2], pppos->out_accm[3]));
761 pppos_pcb *pppos = (pppos_pcb *)ctx;
770 pppos->in_accm[i] = (u8_t)(accm >> (i * 8));
775 pppos->ppp->netif->num,
776 pppos->in_accm[0], pppos->in_accm[1], pppos->in_accm[2], pppos->in_accm[3]));
783 pppos_input_free_current_packet(pppos_pcb *pppos)
785 if (pppos->in_head != NULL) {
786 if (pppos->in_tail && (pppos->in_tail != pppos->in_head)) {
787 pbuf_free(pppos->in_tail);
789 pbuf_free(pppos->in_head);
790 pppos->in_head = NULL;
792 pppos->in_tail = NULL;
799 pppos_input_drop(pppos_pcb *pppos)
801 if (pppos->in_head != NULL) {
803 PPPDEBUG(LOG_INFO, ("pppos_input_drop: %d:%.*H\n", pppos->in_head->len, min(60, pppos->in_head->len * 2), pppos->in_head->payload));
805 PPPDEBUG(LOG_INFO, ("pppos_input_drop: pbuf len=%d, addr %p\n", pppos->in_head->len, (void*)pppos->in_head));
807 pppos_input_free_current_packet(pppos);
809 vj_uncompress_err(&pppos->ppp->vj_comp);
813 MIB2_STATS_NETIF_INC(pppos->ppp->netif, ifindiscards);
823 pppos_output_append(pppos_pcb *pppos, err_t err, struct pbuf *nb, u8_t c, u8_t accm, u16_t *fcs)
833 u32_t l = pppos->output_cb(pppos->ppp, (u8_t*)nb->payload, nb->len, pppos->ppp->ctx_cb);
846 if (accm && ESCAPE_P(pppos->out_accm, c)) {
857 pppos_output_last(pppos_pcb *pppos, err_t err, struct pbuf *nb, u16_t *fcs)
859 ppp_pcb *ppp = pppos->ppp;
862 err = pppos_output_append(pppos, err, nb, ~(*fcs) & 0xFF, 1, NULL);
863 err = pppos_output_append(pppos, err, nb, (~(*fcs) >> 8) & 0xFF, 1, NULL);
864 err = pppos_output_append(pppos, err, nb, PPP_FLAG, 0, NULL);
872 u32_t l = pppos->output_cb(ppp, (u8_t*)nb->payload, nb->len, ppp->ctx_cb);
879 pppos->last_xmit = sys_now();
887 pppos->last_xmit = 0; /* prepend PPP_FLAG to next packet */