Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pppos.h Source File

pppos.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * Network Point to Point Protocol over Serial header file.
00004  *
00005  */
00006 
00007 /*
00008  * Redistribution and use in source and binary forms, with or without modification,
00009  * are permitted provided that the following conditions are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright notice,
00012  *    this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright notice,
00014  *    this list of conditions and the following disclaimer in the documentation
00015  *    and/or other materials provided with the distribution.
00016  * 3. The name of the author may not be used to endorse or promote products
00017  *    derived from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00022  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028  * OF SUCH DAMAGE.
00029  *
00030  * This file is part of the lwIP TCP/IP stack.
00031  *
00032  */
00033 
00034 #include "ppp_opts.h"
00035 #if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in ppp_opts.h */
00036 
00037 #ifndef PPPOS_H
00038 #define PPPOS_H
00039 
00040 #include "ppp.h"
00041 #include "vj.h"
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 /* PPP packet parser states.  Current state indicates operation yet to be
00048  * completed. */
00049 enum {
00050   PDIDLE = 0,  /* Idle state - waiting. */
00051   PDSTART,     /* Process start flag. */
00052   PDADDRESS,   /* Process address field. */
00053   PDCONTROL,   /* Process control field. */
00054   PDPROTOCOL1, /* Process protocol field 1. */
00055   PDPROTOCOL2, /* Process protocol field 2. */
00056   PDDATA       /* Process data byte. */
00057 };
00058 
00059 /* PPPoS serial output callback function prototype */
00060 typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx);
00061 
00062 /*
00063  * Extended asyncmap - allows any character to be escaped.
00064  */
00065 typedef u8_t ext_accm[32];
00066 
00067 /*
00068  * PPPoS interface control block.
00069  */
00070 typedef struct pppos_pcb_s pppos_pcb;
00071 struct pppos_pcb_s {
00072   /* -- below are data that will NOT be cleared between two sessions */
00073   ppp_pcb *ppp;                    /* PPP PCB */
00074   pppos_output_cb_fn output_cb;    /* PPP serial output callback */
00075 
00076   /* -- below are data that will be cleared between two sessions
00077    *
00078    * last_xmit must be the first member of cleared members, because it is
00079    * used to know which part must not be cleared.
00080    */
00081   u32_t last_xmit;                 /* Time of last transmission. */
00082   ext_accm out_accm;               /* Async-Ctl-Char-Map for output. */
00083 
00084   /* flags */
00085   unsigned int open            :1; /* Set if PPPoS is open */
00086   unsigned int pcomp           :1; /* Does peer accept protocol compression? */
00087   unsigned int accomp          :1; /* Does peer accept addr/ctl compression? */
00088 
00089   /* PPPoS rx */
00090   ext_accm in_accm;                /* Async-Ctl-Char-Map for input. */
00091   struct pbuf *in_head, *in_tail;  /* The input packet. */
00092   u16_t in_protocol;               /* The input protocol code. */
00093   u16_t in_fcs;                    /* Input Frame Check Sequence value. */
00094   u8_t in_state;                   /* The input process state. */
00095   u8_t in_escaped;                 /* Escape next character. */
00096 };
00097 
00098 /* Create a new PPPoS session. */
00099 ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb,
00100        ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
00101 
00102 #if !NO_SYS && !PPP_INPROC_IRQ_SAFE
00103 /* Pass received raw characters to PPPoS to be decoded through stacks TCPIP thread. */
00104 err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l);
00105 #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
00106 
00107 /* PPP over Serial: this is the input function to be called for received data. */
00108 void pppos_input(ppp_pcb *ppp, u8_t* data, int len);
00109 
00110 
00111 /*
00112  * Functions called from stack
00113  * DO NOT CALL FROM stacks USER APPLICATION.
00114  */
00115 #if !NO_SYS && !PPP_INPROC_IRQ_SAFE
00116 err_t pppos_input_sys(struct pbuf *p, struct netif *inp);
00117 #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
00118 
00119 #ifdef __cplusplus
00120 }
00121 #endif
00122 
00123 #endif /* PPPOS_H */
00124 #endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */