1*10465441SEvalZero /** 2*10465441SEvalZero * @file 3*10465441SEvalZero * Network Point to Point Protocol over Serial header file. 4*10465441SEvalZero * 5*10465441SEvalZero */ 6*10465441SEvalZero 7*10465441SEvalZero /* 8*10465441SEvalZero * Redistribution and use in source and binary forms, with or without modification, 9*10465441SEvalZero * are permitted provided that the following conditions are met: 10*10465441SEvalZero * 11*10465441SEvalZero * 1. Redistributions of source code must retain the above copyright notice, 12*10465441SEvalZero * this list of conditions and the following disclaimer. 13*10465441SEvalZero * 2. Redistributions in binary form must reproduce the above copyright notice, 14*10465441SEvalZero * this list of conditions and the following disclaimer in the documentation 15*10465441SEvalZero * and/or other materials provided with the distribution. 16*10465441SEvalZero * 3. The name of the author may not be used to endorse or promote products 17*10465441SEvalZero * derived from this software without specific prior written permission. 18*10465441SEvalZero * 19*10465441SEvalZero * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20*10465441SEvalZero * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21*10465441SEvalZero * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 22*10465441SEvalZero * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23*10465441SEvalZero * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 24*10465441SEvalZero * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*10465441SEvalZero * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*10465441SEvalZero * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27*10465441SEvalZero * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 28*10465441SEvalZero * OF SUCH DAMAGE. 29*10465441SEvalZero * 30*10465441SEvalZero * This file is part of the lwIP TCP/IP stack. 31*10465441SEvalZero * 32*10465441SEvalZero */ 33*10465441SEvalZero 34*10465441SEvalZero #include "netif/ppp/ppp_opts.h" 35*10465441SEvalZero #if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */ 36*10465441SEvalZero 37*10465441SEvalZero #ifndef PPPOS_H 38*10465441SEvalZero #define PPPOS_H 39*10465441SEvalZero 40*10465441SEvalZero #include "lwip/sys.h" 41*10465441SEvalZero 42*10465441SEvalZero #include "ppp.h" 43*10465441SEvalZero #include "vj.h" 44*10465441SEvalZero 45*10465441SEvalZero /* PPP packet parser states. Current state indicates operation yet to be 46*10465441SEvalZero * completed. */ 47*10465441SEvalZero enum { 48*10465441SEvalZero PDIDLE = 0, /* Idle state - waiting. */ 49*10465441SEvalZero PDSTART, /* Process start flag. */ 50*10465441SEvalZero PDADDRESS, /* Process address field. */ 51*10465441SEvalZero PDCONTROL, /* Process control field. */ 52*10465441SEvalZero PDPROTOCOL1, /* Process protocol field 1. */ 53*10465441SEvalZero PDPROTOCOL2, /* Process protocol field 2. */ 54*10465441SEvalZero PDDATA /* Process data byte. */ 55*10465441SEvalZero }; 56*10465441SEvalZero 57*10465441SEvalZero /* PPPoS serial output callback function prototype */ 58*10465441SEvalZero typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx); 59*10465441SEvalZero 60*10465441SEvalZero /* 61*10465441SEvalZero * Extended asyncmap - allows any character to be escaped. 62*10465441SEvalZero */ 63*10465441SEvalZero typedef u8_t ext_accm[32]; 64*10465441SEvalZero 65*10465441SEvalZero /* 66*10465441SEvalZero * PPPoS interface control block. 67*10465441SEvalZero */ 68*10465441SEvalZero typedef struct pppos_pcb_s pppos_pcb; 69*10465441SEvalZero struct pppos_pcb_s { 70*10465441SEvalZero /* -- below are data that will NOT be cleared between two sessions */ 71*10465441SEvalZero ppp_pcb *ppp; /* PPP PCB */ 72*10465441SEvalZero pppos_output_cb_fn output_cb; /* PPP serial output callback */ 73*10465441SEvalZero 74*10465441SEvalZero /* -- below are data that will be cleared between two sessions 75*10465441SEvalZero * 76*10465441SEvalZero * last_xmit must be the first member of cleared members, because it is 77*10465441SEvalZero * used to know which part must not be cleared. 78*10465441SEvalZero */ 79*10465441SEvalZero u32_t last_xmit; /* Time of last transmission. */ 80*10465441SEvalZero ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ 81*10465441SEvalZero 82*10465441SEvalZero /* flags */ 83*10465441SEvalZero unsigned int open :1; /* Set if PPPoS is open */ 84*10465441SEvalZero unsigned int pcomp :1; /* Does peer accept protocol compression? */ 85*10465441SEvalZero unsigned int accomp :1; /* Does peer accept addr/ctl compression? */ 86*10465441SEvalZero 87*10465441SEvalZero /* PPPoS rx */ 88*10465441SEvalZero ext_accm in_accm; /* Async-Ctl-Char-Map for input. */ 89*10465441SEvalZero struct pbuf *in_head, *in_tail; /* The input packet. */ 90*10465441SEvalZero u16_t in_protocol; /* The input protocol code. */ 91*10465441SEvalZero u16_t in_fcs; /* Input Frame Check Sequence value. */ 92*10465441SEvalZero u8_t in_state; /* The input process state. */ 93*10465441SEvalZero u8_t in_escaped; /* Escape next character. */ 94*10465441SEvalZero }; 95*10465441SEvalZero 96*10465441SEvalZero /* Create a new PPPoS session. */ 97*10465441SEvalZero ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, 98*10465441SEvalZero ppp_link_status_cb_fn link_status_cb, void *ctx_cb); 99*10465441SEvalZero 100*10465441SEvalZero #if !NO_SYS && !PPP_INPROC_IRQ_SAFE 101*10465441SEvalZero /* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */ 102*10465441SEvalZero err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l); 103*10465441SEvalZero #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ 104*10465441SEvalZero 105*10465441SEvalZero /* PPP over Serial: this is the input function to be called for received data. */ 106*10465441SEvalZero void pppos_input(ppp_pcb *ppp, u8_t* data, int len); 107*10465441SEvalZero 108*10465441SEvalZero 109*10465441SEvalZero /* 110*10465441SEvalZero * Functions called from lwIP 111*10465441SEvalZero * DO NOT CALL FROM lwIP USER APPLICATION. 112*10465441SEvalZero */ 113*10465441SEvalZero #if !NO_SYS && !PPP_INPROC_IRQ_SAFE 114*10465441SEvalZero err_t pppos_input_sys(struct pbuf *p, struct netif *inp); 115*10465441SEvalZero #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ 116*10465441SEvalZero 117*10465441SEvalZero #endif /* PPPOS_H */ 118*10465441SEvalZero #endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */ 119