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