STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
pppos.h
Go to the documentation of this file.
1 
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 "lwip/opt.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 #include "lwip/sio.h"
42 
43 #include "ppp.h"
44 #include "vj.h"
45 
46 /* PPP packet parser states. Current state indicates operation yet to be
47  * completed. */
48 enum {
49  PDIDLE = 0, /* Idle state - waiting. */
50  PDSTART, /* Process start flag. */
51  PDADDRESS, /* Process address field. */
52  PDCONTROL, /* Process control field. */
53  PDPROTOCOL1, /* Process protocol field 1. */
54  PDPROTOCOL2, /* Process protocol field 2. */
55  PDDATA /* Process data byte. */
56 };
57 
58 /* PPPoS serial output callback function prototype */
59 typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx);
60 
61 /*
62  * Extended asyncmap - allows any character to be escaped.
63  */
64 typedef u8_t ext_accm[32];
65 
66 /*
67  * PPPoS interface control block.
68  */
69 typedef struct pppos_pcb_s pppos_pcb;
70 struct pppos_pcb_s {
71  /* -- below are data that will NOT be cleared between two sessions */
72  ppp_pcb *ppp; /* PPP PCB */
73  pppos_output_cb_fn output_cb; /* PPP serial output callback */
74 
75  /* -- below are data that will be cleared between two sessions
76  *
77  * last_xmit must be the first member of cleared members, because it is
78  * used to know which part must not be cleared.
79  */
80  u32_t last_xmit; /* Time of last transmission. */
81  ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
82 
83  /* flags */
84  unsigned int open :1; /* Set if PPPoS is open */
85  unsigned int pcomp :1; /* Does peer accept protocol compression? */
86  unsigned int accomp :1; /* Does peer accept addr/ctl compression? */
87 
88  /* PPPoS rx */
89  ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
90  struct pbuf *in_head, *in_tail; /* The input packet. */
91  u16_t in_protocol; /* The input protocol code. */
92  u16_t in_fcs; /* Input Frame Check Sequence value. */
93  u8_t in_state; /* The input process state. */
94  u8_t in_escaped; /* Escape next character. */
95 };
96 
97 /* Create a new PPPoS session. */
98 ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb,
99  ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
100 
101 #if !NO_SYS && !PPP_INPROC_IRQ_SAFE
102 /* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */
103 err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l);
104 #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
105 
106 /* PPP over Serial: this is the input function to be called for received data. */
107 void pppos_input(ppp_pcb *ppp, u8_t* data, int len);
108 
109 
110 /*
111  * Functions called from lwIP
112  * DO NOT CALL FROM lwIP USER APPLICATION.
113  */
114 #if !NO_SYS && !PPP_INPROC_IRQ_SAFE
115 err_t pppos_input_sys(struct pbuf *p, struct netif *inp);
116 #endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
117 
118 #endif /* PPPOS_H */
119 #endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
120 
u16_t len
Definition: pbuf.h:125
unsigned long u32_t
Definition: cc.h:42
Definition: pbuf.h:108
s8_t err_t
Definition: err.h:47
Definition: netif.h:182
unsigned char u8_t
Definition: cc.h:38
unsigned short u16_t
Definition: cc.h:40