The Pedigree Project  0.1
pppapi.h
1 /*
2  * Redistribution and use in source and binary forms, with or without modification,
3  * are permitted provided that the following conditions are met:
4  *
5  * 1. Redistributions of source code must retain the above copyright notice,
6  * this list of conditions and the following disclaimer.
7  * 2. Redistributions in binary form must reproduce the above copyright notice,
8  * this list of conditions and the following disclaimer in the documentation
9  * and/or other materials provided with the distribution.
10  * 3. The name of the author may not be used to endorse or promote products
11  * derived from this software without specific prior written permission.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
14  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
16  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
18  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
21  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
22  * OF SUCH DAMAGE.
23  *
24  * This file is part of the lwIP TCP/IP stack.
25  *
26  */
27 
28 #ifndef LWIP_PPPAPI_H
29 #define LWIP_PPPAPI_H
30 
31 #include "netif/ppp/ppp_opts.h"
32 
33 #if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */
34 
35 #include "lwip/sys.h"
36 #include "lwip/netif.h"
37 #include "lwip/priv/tcpip_priv.h"
38 #include "netif/ppp/ppp.h"
39 #if PPPOS_SUPPORT
40 #include "netif/ppp/pppos.h"
41 #endif /* PPPOS_SUPPORT */
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 struct pppapi_msg_msg {
48  ppp_pcb *ppp;
49  union {
50 #if PPP_NOTIFY_PHASE
51  struct {
52  ppp_notify_phase_cb_fn notify_phase_cb;
53  } setnotifyphasecb;
54 #endif /* PPP_NOTIFY_PHASE */
55 #if PPPOS_SUPPORT
56  struct {
57  struct netif *pppif;
58  pppos_output_cb_fn output_cb;
59  ppp_link_status_cb_fn link_status_cb;
60  void *ctx_cb;
61  } serialcreate;
62 #endif /* PPPOS_SUPPORT */
63 #if PPPOE_SUPPORT
64  struct {
65  struct netif *pppif;
66  struct netif *ethif;
67  const char *service_name;
68  const char *concentrator_name;
69  ppp_link_status_cb_fn link_status_cb;
70  void *ctx_cb;
71  } ethernetcreate;
72 #endif /* PPPOE_SUPPORT */
73 #if PPPOL2TP_SUPPORT
74  struct {
75  struct netif *pppif;
76  struct netif *netif;
77  API_MSG_M_DEF_C(ip_addr_t, ipaddr);
78  u16_t port;
79 #if PPPOL2TP_AUTH_SUPPORT
80  const u8_t *secret;
81  u8_t secret_len;
82 #endif /* PPPOL2TP_AUTH_SUPPORT */
83  ppp_link_status_cb_fn link_status_cb;
84  void *ctx_cb;
85  } l2tpcreate;
86 #endif /* PPPOL2TP_SUPPORT */
87  struct {
88  u16_t holdoff;
89  } connect;
90  struct {
91  u8_t nocarrier;
92  } close;
93  struct {
94  u8_t cmd;
95  void *arg;
96  } ioctl;
97  } msg;
98 };
99 
100 struct pppapi_msg {
101  struct tcpip_api_call_data call;
102  struct pppapi_msg_msg msg;
103 };
104 
105 /* API for application */
106 err_t pppapi_set_default(ppp_pcb *pcb);
107 #if PPP_NOTIFY_PHASE
108 err_t pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
109 #endif /* PPP_NOTIFY_PHASE */
110 #if PPPOS_SUPPORT
111 ppp_pcb *pppapi_pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
112 #endif /* PPPOS_SUPPORT */
113 #if PPPOE_SUPPORT
114 ppp_pcb *pppapi_pppoe_create(struct netif *pppif, struct netif *ethif, const char *service_name,
115  const char *concentrator_name, ppp_link_status_cb_fn link_status_cb,
116  void *ctx_cb);
117 #endif /* PPPOE_SUPPORT */
118 #if PPPOL2TP_SUPPORT
119 ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
120  const u8_t *secret, u8_t secret_len,
121  ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
122 #endif /* PPPOL2TP_SUPPORT */
123 err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff);
124 #if PPP_SERVER
125 err_t pppapi_listen(ppp_pcb *pcb);
126 #endif /* PPP_SERVER */
127 err_t pppapi_close(ppp_pcb *pcb, u8_t nocarrier);
128 err_t pppapi_free(ppp_pcb *pcb);
129 err_t pppapi_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* LWIP_PPP_API */
136 
137 #endif /* LWIP_PPPAPI_H */
Definition: cmd.h:30
Definition: netif.h:244
s8_t err_t
Definition: err.h:76