51 #define PPP_ADDITIONAL_CALLBACKS 0
55 #error "CBCP is not supported in lwIP PPP"
58 #error "CCP is not supported in lwIP PPP"
107 #define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
108 #define UNTIMEOUT(f, a) sys_untimeout((f), (a))
111 #ifndef __u_char_defined
114 typedef unsigned long u_long;
115 typedef unsigned int u_int;
116 typedef unsigned short u_short;
117 typedef unsigned char u_char;
136 #define PPP_ALLSTATIONS 0xff
138 #define PPP_FLAG 0x7e
139 #define PPP_ESCAPE 0x7d
140 #define PPP_TRANS 0x20
147 #define PPP_VJC_COMP 0x2d
148 #define PPP_VJC_UNCOMP 0x2f
149 #define PPP_COMP 0xfd
150 #define PPP_IPCP 0x8021
151 #define PPP_ATCP 0x8029
152 #define PPP_CCP 0x80fd
153 #define PPP_LCP 0xc021
154 #define PPP_PAP 0xc023
155 #define PPP_LQR 0xc025
156 #define PPP_CHAP 0xc223
157 #define PPP_CBCP 0xc029
162 #define PPP_INITFCS 0xffff
163 #define PPP_GOODFCS 0xf0b8
164 #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
169 typedef u_char ext_accm[32];
187 #define GETCHAR(c, cp) { \
190 #define PUTCHAR(c, cp) { \
191 *(cp)++ = (u_char) (c); \
195 #define GETSHORT(s, cp) { \
196 (s) = *(cp); (cp)++; (s) <<= 8; \
197 (s) |= *(cp); (cp)++; \
199 #define PUTSHORT(s, cp) { \
200 *(cp)++ = (u_char) ((s) >> 8); \
201 *(cp)++ = (u_char) (s & 0xff); \
204 #define GETLONG(l, cp) { \
205 (l) = *(cp); (cp)++; (l) <<= 8; \
206 (l) |= *(cp); (cp)++; (l) <<= 8; \
207 (l) |= *(cp); (cp)++; (l) <<= 8; \
208 (l) |= *(cp); (cp)++; \
210 #define PUTLONG(l, cp) { \
211 *(cp)++ = (u_char) ((l) >> 24); \
212 *(cp)++ = (u_char) ((l) >> 16); \
213 *(cp)++ = (u_char) ((l) >> 8); \
214 *(cp)++ = (u_char) (l); \
218 #define INCPTR(n, cp) ((cp) += (n))
219 #define DECPTR(n, cp) ((cp) -= (n))
221 #define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l))
222 #define BCOPY(s, d, l) MEMCPY((d), (s), (l))
223 #define BZERO(s, n) memset(s, 0, n)
226 #define PRINTMSG(m, l) { m[l] = '\0'; LWIP_DEBUGF(LOG_INFO, ("Remote message: %s\n", m)); }
228 #define PRINTMSG(m, l)
234 #define MAKEHEADER(p, t) { \
235 PUTCHAR(PPP_ALLSTATIONS, p); \
236 PUTCHAR(PPP_UI, p); \
244 #define PPPERR_NONE 0
245 #define PPPERR_PARAM -1
246 #define PPPERR_OPEN -2
247 #define PPPERR_DEVICE -3
248 #define PPPERR_ALLOC -4
249 #define PPPERR_USER -5
250 #define PPPERR_CONNECT -6
251 #define PPPERR_AUTHFAIL -7
252 #define PPPERR_PROTOCOL -8
261 #define PPPCTLG_UPSTATUS 100
262 #define PPPCTLS_ERRCODE 101
263 #define PPPCTLG_ERRCODE 102
264 #define PPPCTLG_FD 103
277 void (*init) (
int unit);
279 void (*input) (
int unit, u_char *pkt,
int len);
281 void (*protrej) (
int unit);
283 void (*lowerup) (
int unit);
285 void (*lowerdown) (
int unit);
287 void (*
open) (
int unit);
289 void (*
close) (
int unit,
char *reason);
290 #if PPP_ADDITIONAL_CALLBACKS
292 int (*printpkt) (u_char *pkt,
int len,
293 void (*printer) (
void *,
char *, ...),
296 void (*datainput) (
int unit, u_char *pkt,
int len);
300 #if PPP_ADDITIONAL_CALLBACKS
302 void (*check_options) (u_long);
304 int (*demand_conf) (
int unit);
306 int (*active_pkt) (u_char *pkt,
int len);
319 struct ppp_settings {
321 u_int disable_defaultip : 1;
322 u_int auth_required : 1;
323 u_int explicit_remote : 1;
324 u_int refuse_pap : 1;
325 u_int refuse_chap : 1;
326 u_int usehostname : 1;
327 u_int usepeerdns : 1;
329 u_short idle_time_limit;
332 char user [MAXNAMELEN + 1];
333 char passwd [MAXSECRETLEN + 1];
334 char our_name [MAXNAMELEN + 1];
335 char remote_name[MAXNAMELEN + 1];
339 ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
347 extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN];
349 extern struct ppp_settings ppp_settings;
351 extern struct protent *ppp_protocols[];
387 void pppSetAuth(
enum pppAuthType authType,
const char *user,
const char *passwd);
396 int pppOverSerialOpen(
sio_fd_t fd,
void (*linkStatusCB)(
void *ctx,
int errCode,
void *arg),
void *linkStatusCtx);
401 int pppOverEthernetOpen(
struct netif *ethif,
const char *service_name,
const char *concentrator_name,
void (*linkStatusCB)(
void *ctx,
int errCode,
void *arg),
void *linkStatusCtx);
404 #define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
411 int pppClose(
int pd);
416 void pppSigHUP(
int pd);
422 int pppIOCtl(
int pd,
int cmd,
void *arg);
427 u_short pppMTU(
int pd);
433 int pppWrite(
int pd,
const u_char *s,
int n);
435 void pppInProcOverEthernet(
int pd,
struct pbuf *pb);
437 struct pbuf *pppSingleBuf(
struct pbuf *p);
439 void pppLinkTerminated(
int pd);
441 void pppLinkDown(
int pd);
443 void pppos_input(
int pd, u_char* data,
int len);
446 void ppp_send_config (
int,
u16_t,
u32_t,
int,
int);
448 void ppp_set_xaccm (
int, ext_accm *);
450 void ppp_recv_config (
int,
int,
u32_t,
int,
int);
452 int get_idle_time (
int,
struct ppp_idle *);
455 int sifvjcomp (
int,
int,
u8_t,
u8_t);
459 int sifnpmode (
int u,
int proto,
enum NPmode mode);
474 #if LWIP_NETIF_STATUS_CALLBACK
477 #if LWIP_NETIF_LINK_CALLBACK