ReactOS 0.4.16-dev-820-g96aa1ee
ppp_impl.h
Go to the documentation of this file.
1/*****************************************************************************
2* ppp.h - Network Point to Point Protocol header file.
3*
4* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5* portions Copyright (c) 1997 Global Election Systems Inc.
6*
7* The authors hereby grant permission to use, copy, modify, distribute,
8* and license this software and its documentation for any purpose, provided
9* that existing copyright notices are retained in all copies and that this
10* notice and the following disclaimer are included verbatim in any
11* distributions. No written agreement, license, or royalty fee is required
12* for any of the authorized uses.
13*
14* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24*
25******************************************************************************
26* REVISION HISTORY
27*
28* 03-01-01 Marc Boucher <marc@mbsi.ca>
29* Ported to lwIP.
30* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
31* Original derived from BSD codes.
32*****************************************************************************/
33#ifndef LWIP_HDR_PPP_IMPL_H
34#define LWIP_HDR_PPP_IMPL_H
35
36#include "netif/ppp/ppp_opts.h"
37
38#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
39
40#ifdef PPP_INCLUDE_SETTINGS_HEADER
41#include "ppp_settings.h"
42#endif
43
44#include <stdio.h> /* formats */
45#include <stdarg.h>
46#include <string.h>
47#include <stdlib.h> /* strtol() */
48
49#include "lwip/netif.h"
50#include "lwip/def.h"
51#include "lwip/timeouts.h"
52
53#include "ppp.h"
54#include "pppdebug.h"
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60/*
61 * Memory used for control packets.
62 *
63 * PPP_CTRL_PBUF_UNKNOWN_SIZE is the amount of memory we allocate when we
64 * cannot figure out how much we are going to use before filling the buffer.
65 */
66#define PPP_CTRL_PBUF_UNKNOWN_SIZE 512
67
68/*
69 * The basic PPP frame.
70 */
71#define PPP_ADDRESS(p) (((u_char *)(p))[0])
72#define PPP_CONTROL(p) (((u_char *)(p))[1])
73#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
74
75/*
76 * Significant octet values.
77 */
78#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
79#define PPP_UI 0x03 /* Unnumbered Information */
80#define PPP_FLAG 0x7e /* Flag Sequence */
81#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
82#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
83
84/*
85 * PPP_DEFMRU: MRU value used prior negotiation and unless negotiated later.
86 * Must be 1500.
87 */
88#define PPP_DEFMRU 1500
89
90/*
91 * Protocol field values.
92 */
93#if PPP_IPV4_SUPPORT
94#define PPP_IP 0x21 /* Internet Protocol */
95#endif /* PPP_IPV4_SUPPORT */
96#if 0 /* UNUSED */
97#define PPP_AT 0x29 /* AppleTalk Protocol */
98#define PPP_IPX 0x2b /* IPX protocol */
99#endif /* UNUSED */
100#if VJ_SUPPORT
101#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
102#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
103#endif /* VJ_SUPPORT */
104#if PPP_IPV6_SUPPORT
105#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
106#endif /* PPP_IPV6_SUPPORT */
107#if CCP_SUPPORT
108#define PPP_COMP 0xfd /* compressed packet */
109#endif /* CCP_SUPPORT */
110#define PPP_IPCP 0x8021 /* IP Control Protocol */
111#if 0 /* UNUSED */
112#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
113#define PPP_IPXCP 0x802b /* IPX Control Protocol */
114#endif /* UNUSED */
115#if PPP_IPV6_SUPPORT
116#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
117#endif /* PPP_IPV6_SUPPORT */
118#if CCP_SUPPORT
119#define PPP_CCP 0x80fd /* Compression Control Protocol */
120#endif /* CCP_SUPPORT */
121#if ECP_SUPPORT
122#define PPP_ECP 0x8053 /* Encryption Control Protocol */
123#endif /* ECP_SUPPORT */
124#define PPP_LCP 0xc021 /* Link Control Protocol */
125#if PAP_SUPPORT
126#define PPP_PAP 0xc023 /* Password Authentication Protocol */
127#endif /* PAP_SUPPORT */
128#if LQR_SUPPORT
129#define PPP_LQR 0xc025 /* Link Quality Report protocol */
130#endif /* LQR_SUPPORT */
131#if CHAP_SUPPORT
132#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
133#endif /* CHAP_SUPPORT */
134#if CBCP_SUPPORT
135#define PPP_CBCP 0xc029 /* Callback Control Protocol */
136#endif /* CBCP_SUPPORT */
137#if EAP_SUPPORT
138#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
139#endif /* EAP_SUPPORT */
140
141/*
142 * The following struct gives the addresses of procedures to call
143 * for a particular lower link level protocol.
144 */
145struct link_callbacks {
146 /* Start a connection (e.g. Initiate discovery phase) */
147 void (*connect) (ppp_pcb *pcb, void *ctx);
148#if PPP_SERVER
149 /* Listen for an incoming connection (Passive mode) */
150 void (*listen) (ppp_pcb *pcb, void *ctx);
151#endif /* PPP_SERVER */
152 /* End a connection (i.e. initiate disconnect phase) */
153 void (*disconnect) (ppp_pcb *pcb, void *ctx);
154 /* Free lower protocol control block */
155 err_t (*free) (ppp_pcb *pcb, void *ctx);
156 /* Write a pbuf to a ppp link, only used from PPP functions to send PPP packets. */
157 err_t (*write)(ppp_pcb *pcb, void *ctx, struct pbuf *p);
158 /* Send a packet from lwIP core (IPv4 or IPv6) */
159 err_t (*netif_output)(ppp_pcb *pcb, void *ctx, struct pbuf *p, u_short protocol);
160 /* configure the transmit-side characteristics of the PPP interface */
161 void (*send_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp);
162 /* confire the receive-side characteristics of the PPP interface */
163 void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp);
164};
165
166/*
167 * What to do with network protocol (NP) packets.
168 */
169enum NPmode {
170 NPMODE_PASS, /* pass the packet through */
171 NPMODE_DROP, /* silently drop the packet */
172 NPMODE_ERROR, /* return an error */
173 NPMODE_QUEUE /* save it up for later. */
174};
175
176/*
177 * Statistics.
178 */
179#if PPP_STATS_SUPPORT
180struct pppstat {
181 unsigned int ppp_ibytes; /* bytes received */
182 unsigned int ppp_ipackets; /* packets received */
183 unsigned int ppp_ierrors; /* receive errors */
184 unsigned int ppp_obytes; /* bytes sent */
185 unsigned int ppp_opackets; /* packets sent */
186 unsigned int ppp_oerrors; /* transmit errors */
187};
188
189#if VJ_SUPPORT
190struct vjstat {
191 unsigned int vjs_packets; /* outbound packets */
192 unsigned int vjs_compressed; /* outbound compressed packets */
193 unsigned int vjs_searches; /* searches for connection state */
194 unsigned int vjs_misses; /* times couldn't find conn. state */
195 unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
196 unsigned int vjs_compressedin; /* inbound compressed packets */
197 unsigned int vjs_errorin; /* inbound unknown type packets */
198 unsigned int vjs_tossed; /* inbound packets tossed because of error */
199};
200#endif /* VJ_SUPPORT */
201
202struct ppp_stats {
203 struct pppstat p; /* basic PPP statistics */
204#if VJ_SUPPORT
205 struct vjstat vj; /* VJ header compression statistics */
206#endif /* VJ_SUPPORT */
207};
208
209#if CCP_SUPPORT
210struct compstat {
211 unsigned int unc_bytes; /* total uncompressed bytes */
212 unsigned int unc_packets; /* total uncompressed packets */
213 unsigned int comp_bytes; /* compressed bytes */
214 unsigned int comp_packets; /* compressed packets */
215 unsigned int inc_bytes; /* incompressible bytes */
216 unsigned int inc_packets; /* incompressible packets */
217 unsigned int ratio; /* recent compression ratio << 8 */
218};
219
220struct ppp_comp_stats {
221 struct compstat c; /* packet compression statistics */
222 struct compstat d; /* packet decompression statistics */
223};
224#endif /* CCP_SUPPORT */
225
226#endif /* PPP_STATS_SUPPORT */
227
228#if PPP_IDLETIMELIMIT
229/*
230 * The following structure records the time in seconds since
231 * the last NP packet was sent or received.
232 */
233struct ppp_idle {
234 time_t xmit_idle; /* time since last NP packet sent */
235 time_t recv_idle; /* time since last NP packet received */
236};
237#endif /* PPP_IDLETIMELIMIT */
238
239/* values for epdisc.class */
240#define EPD_NULL 0 /* null discriminator, no data */
241#define EPD_LOCAL 1
242#define EPD_IP 2
243#define EPD_MAC 3
244#define EPD_MAGIC 4
245#define EPD_PHONENUM 5
246
247/*
248 * Global variables.
249 */
250#ifdef HAVE_MULTILINK
251extern u8_t multilink; /* enable multilink operation */
252extern u8_t doing_multilink;
253extern u8_t multilink_master;
254extern u8_t bundle_eof;
255extern u8_t bundle_terminating;
256#endif
257
258#ifdef MAXOCTETS
259extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
260extern int maxoctets_dir; /* Direction :
261 0 - in+out (default)
262 1 - in
263 2 - out
264 3 - max(in,out) */
265extern int maxoctets_timeout; /* Timeout for check of octets limit */
266#define PPP_OCTETS_DIRECTION_SUM 0
267#define PPP_OCTETS_DIRECTION_IN 1
268#define PPP_OCTETS_DIRECTION_OUT 2
269#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
270/* same as previous, but little different on RADIUS side */
271#define PPP_OCTETS_DIRECTION_MAXSESSION 4
272#endif
273
274/* Data input may be used by CCP and ECP, remove this entry
275 * from struct protent to save some flash
276 */
277#define PPP_DATAINPUT 0
278
279/*
280 * The following struct gives the addresses of procedures to call
281 * for a particular protocol.
282 */
283struct protent {
284 u_short protocol; /* PPP protocol number */
285 /* Initialization procedure */
286 void (*init) (ppp_pcb *pcb);
287 /* Process a received packet */
288 void (*input) (ppp_pcb *pcb, u_char *pkt, int len);
289 /* Process a received protocol-reject */
290 void (*protrej) (ppp_pcb *pcb);
291 /* Lower layer has come up */
292 void (*lowerup) (ppp_pcb *pcb);
293 /* Lower layer has gone down */
294 void (*lowerdown) (ppp_pcb *pcb);
295 /* Open the protocol */
296 void (*open) (ppp_pcb *pcb);
297 /* Close the protocol */
298 void (*close) (ppp_pcb *pcb, const char *reason);
299#if PRINTPKT_SUPPORT
300 /* Print a packet in readable form */
301 int (*printpkt) (const u_char *pkt, int len,
302 void (*printer) (void *, const char *, ...),
303 void *arg);
304#endif /* PRINTPKT_SUPPORT */
305#if PPP_DATAINPUT
306 /* Process a received data packet */
307 void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len);
308#endif /* PPP_DATAINPUT */
309#if PRINTPKT_SUPPORT
310 const char *name; /* Text name of protocol */
311 const char *data_name; /* Text name of corresponding data protocol */
312#endif /* PRINTPKT_SUPPORT */
313#if PPP_OPTIONS
314 option_t *options; /* List of command-line options */
315 /* Check requested options, assign defaults */
316 void (*check_options) (void);
317#endif /* PPP_OPTIONS */
318#if DEMAND_SUPPORT
319 /* Configure interface for demand-dial */
320 int (*demand_conf) (int unit);
321 /* Say whether to bring up link for this pkt */
322 int (*active_pkt) (u_char *pkt, int len);
323#endif /* DEMAND_SUPPORT */
324};
325
326/* Table of pointers to supported protocols */
327extern const struct protent* const protocols[];
328
329
330/* Values for auth_pending, auth_done */
331#if PAP_SUPPORT
332#define PAP_WITHPEER 0x1
333#define PAP_PEER 0x2
334#endif /* PAP_SUPPORT */
335#if CHAP_SUPPORT
336#define CHAP_WITHPEER 0x4
337#define CHAP_PEER 0x8
338#endif /* CHAP_SUPPORT */
339#if EAP_SUPPORT
340#define EAP_WITHPEER 0x10
341#define EAP_PEER 0x20
342#endif /* EAP_SUPPORT */
343
344/* Values for auth_done only */
345#if CHAP_SUPPORT
346#define CHAP_MD5_WITHPEER 0x40
347#define CHAP_MD5_PEER 0x80
348#if MSCHAP_SUPPORT
349#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
350#define CHAP_MS_WITHPEER 0x100
351#define CHAP_MS_PEER 0x200
352#define CHAP_MS2_WITHPEER 0x400
353#define CHAP_MS2_PEER 0x800
354#endif /* MSCHAP_SUPPORT */
355#endif /* CHAP_SUPPORT */
356
357/* Supported CHAP protocols */
358#if CHAP_SUPPORT
359
360#if MSCHAP_SUPPORT
361#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
362#else /* MSCHAP_SUPPORT */
363#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MD5)
364#endif /* MSCHAP_SUPPORT */
365
366#else /* CHAP_SUPPORT */
367#define CHAP_MDTYPE_SUPPORTED (MDTYPE_NONE)
368#endif /* CHAP_SUPPORT */
369
370#if PPP_STATS_SUPPORT
371/*
372 * PPP statistics structure
373 */
374struct pppd_stats {
375 unsigned int bytes_in;
376 unsigned int bytes_out;
377 unsigned int pkts_in;
378 unsigned int pkts_out;
379};
380#endif /* PPP_STATS_SUPPORT */
381
382
383/*
384 * PPP private functions
385 */
386
387
388/*
389 * Functions called from lwIP core.
390 */
391
392/* initialize the PPP subsystem */
393int ppp_init(void);
394
395/*
396 * Functions called from PPP link protocols.
397 */
398
399/* Create a new PPP control block */
400ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, void *link_ctx_cb,
401 ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
402
403/* Initiate LCP open request */
404void ppp_start(ppp_pcb *pcb);
405
406/* Called when link failed to setup */
407void ppp_link_failed(ppp_pcb *pcb);
408
409/* Called when link is normally down (i.e. it was asked to end) */
410void ppp_link_end(ppp_pcb *pcb);
411
412/* function called to process input packet */
413void ppp_input(ppp_pcb *pcb, struct pbuf *pb);
414
415
416/*
417 * Functions called by PPP protocols.
418 */
419
420/* function called by all PPP subsystems to send packets */
421err_t ppp_write(ppp_pcb *pcb, struct pbuf *p);
422
423/* functions called by auth.c link_terminated() */
424void ppp_link_terminated(ppp_pcb *pcb);
425
426void new_phase(ppp_pcb *pcb, int p);
427
428int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp);
429int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp);
430
431#if PPP_IPV4_SUPPORT
432int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t netmask);
433int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr);
434#if 0 /* UNUSED - PROXY ARP */
435int sifproxyarp(ppp_pcb *pcb, u32_t his_adr);
436int cifproxyarp(ppp_pcb *pcb, u32_t his_adr);
437#endif /* UNUSED - PROXY ARP */
438#if LWIP_DNS
439int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
440int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
441#endif /* LWIP_DNS */
442#if VJ_SUPPORT
443int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid);
444#endif /* VJ_SUPPORT */
445int sifup(ppp_pcb *pcb);
446int sifdown (ppp_pcb *pcb);
447u32_t get_mask(u32_t addr);
448#endif /* PPP_IPV4_SUPPORT */
449
450#if PPP_IPV6_SUPPORT
451int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
452int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
453int sif6up(ppp_pcb *pcb);
454int sif6down (ppp_pcb *pcb);
455#endif /* PPP_IPV6_SUPPORT */
456
457#if DEMAND_SUPPORT
458int sifnpmode(ppp_pcb *pcb, int proto, enum NPmode mode);
459#endif /* DEMAND_SUPPORt */
460
461void ppp_netif_set_mtu(ppp_pcb *pcb, int mtu);
462int ppp_netif_get_mtu(ppp_pcb *pcb);
463
464#if CCP_SUPPORT
465#if 0 /* unused */
466int ccp_test(ppp_pcb *pcb, u_char *opt_ptr, int opt_len, int for_transmit);
467#endif /* unused */
468void ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method);
469void ccp_reset_comp(ppp_pcb *pcb);
470void ccp_reset_decomp(ppp_pcb *pcb);
471#if 0 /* unused */
472int ccp_fatal_error(ppp_pcb *pcb);
473#endif /* unused */
474#endif /* CCP_SUPPORT */
475
476#if PPP_IDLETIMELIMIT
477int get_idle_time(ppp_pcb *pcb, struct ppp_idle *ip);
478#endif /* PPP_IDLETIMELIMIT */
479
480#if DEMAND_SUPPORT
481int get_loop_output(void);
482#endif /* DEMAND_SUPPORT */
483
484/* Optional protocol names list, to make our messages a little more informative. */
485#if PPP_PROTOCOLNAME
486const char * protocol_name(int proto);
487#endif /* PPP_PROTOCOLNAME */
488
489/* Optional stats support, to get some statistics on the PPP interface */
490#if PPP_STATS_SUPPORT
491void print_link_stats(void); /* Print stats, if available */
492void reset_link_stats(int u); /* Reset (init) stats when link goes up */
493void update_link_stats(int u); /* Get stats at link termination */
494#endif /* PPP_STATS_SUPPORT */
495
496
497
498/*
499 * Inline versions of get/put char/short/long.
500 * Pointer is advanced; we assume that both arguments
501 * are lvalues and will already be in registers.
502 * cp MUST be u_char *.
503 */
504#define GETCHAR(c, cp) { \
505 (c) = *(cp)++; \
506}
507#define PUTCHAR(c, cp) { \
508 *(cp)++ = (u_char) (c); \
509}
510#define GETSHORT(s, cp) { \
511 (s) = *(cp)++ << 8; \
512 (s) |= *(cp)++; \
513}
514#define PUTSHORT(s, cp) { \
515 *(cp)++ = (u_char) ((s) >> 8); \
516 *(cp)++ = (u_char) (s); \
517}
518#define GETLONG(l, cp) { \
519 (l) = *(cp)++ << 8; \
520 (l) |= *(cp)++; (l) <<= 8; \
521 (l) |= *(cp)++; (l) <<= 8; \
522 (l) |= *(cp)++; \
523}
524#define PUTLONG(l, cp) { \
525 *(cp)++ = (u_char) ((l) >> 24); \
526 *(cp)++ = (u_char) ((l) >> 16); \
527 *(cp)++ = (u_char) ((l) >> 8); \
528 *(cp)++ = (u_char) (l); \
529}
530
531#define INCPTR(n, cp) ((cp) += (n))
532#define DECPTR(n, cp) ((cp) -= (n))
533
534/*
535 * System dependent definitions for user-level 4.3BSD UNIX implementation.
536 */
537#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
538#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
539#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
540
541#define BZERO(s, n) memset(s, 0, n)
542#define BCMP(s1, s2, l) memcmp(s1, s2, l)
543
544#define PRINTMSG(m, l) { ppp_info(("Remote message: %0.*v", l, m)); }
545
546/*
547 * MAKEHEADER - Add Header fields to a packet.
548 */
549#define MAKEHEADER(p, t) { \
550 PUTCHAR(PPP_ALLSTATIONS, p); \
551 PUTCHAR(PPP_UI, p); \
552 PUTSHORT(t, p); }
553
554/* Procedures exported from auth.c */
555void link_required(ppp_pcb *pcb); /* we are starting to use the link */
556void link_terminated(ppp_pcb *pcb); /* we are finished with the link */
557void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */
558void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */
559void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */
560void start_networks(ppp_pcb *pcb); /* start all the network control protos */
561void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos */
562#if PPP_AUTH_SUPPORT
563#if PPP_SERVER
564int auth_check_passwd(ppp_pcb *pcb, char *auser, unsigned int userlen, char *apasswd, unsigned int passwdlen, const char **msg, int *msglen);
565 /* check the user name and passwd against configuration */
566void auth_peer_fail(ppp_pcb *pcb, int protocol);
567 /* peer failed to authenticate itself */
568void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char *name, int namelen);
569 /* peer successfully authenticated itself */
570#endif /* PPP_SERVER */
571void auth_withpeer_fail(ppp_pcb *pcb, int protocol);
572 /* we failed to authenticate ourselves */
573void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor);
574 /* we successfully authenticated ourselves */
575#endif /* PPP_AUTH_SUPPORT */
576void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */
577void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */
578void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */
579#if PPP_AUTH_SUPPORT
580int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secret, int *secret_len, int am_server);
581 /* get "secret" for chap */
582#endif /* PPP_AUTH_SUPPORT */
583
584/* Procedures exported from ipcp.c */
585/* int parse_dotted_ip (char *, u32_t *); */
586
587/* Procedures exported from demand.c */
588#if DEMAND_SUPPORT
589void demand_conf (void); /* config interface(s) for demand-dial */
590void demand_block (void); /* set all NPs to queue up packets */
591void demand_unblock (void); /* set all NPs to pass packets */
592void demand_discard (void); /* set all NPs to discard packets */
593void demand_rexmit (int, u32_t); /* retransmit saved frames for an NP*/
594int loop_chars (unsigned char *, int); /* process chars from loopback */
595int loop_frame (unsigned char *, int); /* should we bring link up? */
596#endif /* DEMAND_SUPPORT */
597
598/* Procedures exported from multilink.c */
599#ifdef HAVE_MULTILINK
600void mp_check_options (void); /* Check multilink-related options */
601int mp_join_bundle (void); /* join our link to an appropriate bundle */
602void mp_exit_bundle (void); /* have disconnected our link from bundle */
603void mp_bundle_terminated (void);
604char *epdisc_to_str (struct epdisc *); /* string from endpoint discrim. */
605int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
606#else
607#define mp_bundle_terminated() /* nothing */
608#define mp_exit_bundle() /* nothing */
609#define doing_multilink 0
610#define multilink_master 0
611#endif
612
613/* Procedures exported from utils.c. */
614void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */
615int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */
616int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args); /* vsprintf++ */
617size_t ppp_strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */
618size_t ppp_strlcat(char *dest, const char *src, size_t len); /* safe strncpy */
619void ppp_dbglog_impl(const char *fmt, ...); /* log a debug message */
620void ppp_info_impl(const char *fmt, ...); /* log an informational message */
621void ppp_notice_impl(const char *fmt, ...); /* log a notice-level message */
622void ppp_warn_impl(const char *fmt, ...); /* log a warning message */
623void ppp_error_impl(const char *fmt, ...); /* log an error message */
624void ppp_fatal_impl(const char *fmt, ...); /* log an error message and die(1) */
625/* wrap all the above functions so they will only be linked when enabled */
626#define ppp_dbglog(x) do { if (LWIP_DEBUG_ENABLED(LOG_DEBUG)) { ppp_dbglog_impl x; }} while(0)
627#define ppp_info(x) do { if (LWIP_DEBUG_ENABLED(LOG_INFO)) { ppp_info_impl x; }} while(0)
628#define ppp_notice(x) do { if (LWIP_DEBUG_ENABLED(LOG_NOTICE)) { ppp_notice_impl x; }} while(0)
629#define ppp_warn(x) do { if (LWIP_DEBUG_ENABLED(LOG_WARNING)) { ppp_warn_impl x; }} while(0)
630#define ppp_error(x) do { if (LWIP_DEBUG_ENABLED(LOG_ERR)) { ppp_error_impl x; }} while(0)
631#define ppp_fatal(x) do { if (LWIP_DEBUG_ENABLED(LOG_CRITICAL)) { ppp_fatal_impl x; }} while(0)
632#if PRINTPKT_SUPPORT
633void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len);
634 /* dump packet to debug log if interesting */
635#endif /* PRINTPKT_SUPPORT */
636
637/*
638 * Number of necessary timers analysis.
639 *
640 * PPP use at least one timer per each of its protocol, but not all protocols are
641 * active at the same time, thus the number of necessary timeouts is actually
642 * lower than enabled protocols. Here is the actual necessary timeouts based
643 * on code analysis.
644 *
645 * Note that many features analysed here are not working at all and are only
646 * there for a comprehensive analysis of necessary timers in order to prevent
647 * having to redo that each time we add a feature.
648 *
649 * Timer list
650 *
651 * | holdoff timeout
652 * | low level protocol timeout (PPPoE or PPPoL2P)
653 * | LCP delayed UP
654 * | LCP retransmit (FSM)
655 * | LCP Echo timer
656 * .| PAP or CHAP or EAP authentication
657 * . | ECP retransmit (FSM)
658 * . | CCP retransmit (FSM) when MPPE is enabled
659 * . | CCP retransmit (FSM) when MPPE is NOT enabled
660 * . | IPCP retransmit (FSM)
661 * . .| IP6CP retransmit (FSM)
662 * . . | Idle time limit
663 * . . | Max connect time
664 * . . | Max octets
665 * . . | CCP RACK timeout
666 * . . .
667 * PPP_PHASE_DEAD
668 * PPP_PHASE_HOLDOFF
669 * | . . .
670 * PPP_PHASE_INITIALIZE
671 * | . . .
672 * PPP_PHASE_ESTABLISH
673 * | . . .
674 * |. . .
675 * | . .
676 * PPP_PHASE_AUTHENTICATE
677 * || . .
678 * PPP_PHASE_NETWORK
679 * |||| . .
680 * || ||| .
681 * PPP_PHASE_RUNNING
682 * | .|||||
683 * | . ||||
684 * PPP_PHASE_TERMINATE
685 * | . ||||
686 * PPP_PHASE_NETWORK
687 * |. .
688 * PPP_PHASE_ESTABLISH
689 * PPP_PHASE_DISCONNECT
690 * PPP_PHASE_DEAD
691 *
692 * Alright, PPP basic retransmission and LCP Echo consume one timer.
693 * 1
694 *
695 * If authentication is enabled one timer is necessary during authentication.
696 * This timer might still be running up to network phase for any necessary
697 * rechallenge, mostly for PPP server support.
698 * 1 + PPP_AUTH_SUPPORT
699 *
700 * If ECP is enabled one timer is necessary before IPCP and/or IP6CP, one more
701 * is necessary if CCP is enabled (only with MPPE support but we don't care much
702 * up to this detail level).
703 * 1 + PPP_AUTH_SUPPORT + ECP_SUPPORT + CCP_SUPPORT
704 *
705 * If CCP is enabled it might consume a timer during IPCP or IP6CP, thus
706 * we might use AUTH, IPCP, IP6CP and CCP timers simultaneously.
707 * 1 + PPP_AUTH_SUPPORT + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT
708 *
709 * When entering running phase, IPCP or IP6CP is still running. If idle time limit
710 * is enabled one more timer is necessary. Same for max connect time and max
711 * octets features. Furthermore CCP RACK might be used past this point.
712 * 1 + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT -1 + PPP_IDLETIMELIMIT + PPP_MAXCONNECT + MAXOCTETS + CCP_SUPPORT
713 *
714 * Then the maximum number of simultaneously running timers is given by:
715 * 1 + MAX(PPP_AUTH_SUPPORT + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT,
716 * PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT -1 + PPP_IDLETIMELIMIT + PPP_MAXCONNECT + MAXOCTETS + CCP_SUPPORT)
717 *
718 * We don't support ECP_SUPPORT + PPP_IDLETIMELIMIT + PPP_MAXCONNECT + MAXOCTETS features
719 * and adding those defines to ppp_opts.h just for having the value always defined to 0
720 * is not worth it, thus reducing the overall complexity.
721 * 1 + MAX(PPP_AUTH_SUPPORT + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT,
722 * PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT -1 + CCP_SUPPORT)
723 *
724 * PPP_AUTH_SUPPORT is not available in ppp_opts.h because it is defined later in ppp.h,
725 * but we do not need to be that picky about the real number of simultaneously running
726 * timers so we just set the base number of timeouts to 2, thus the following is enough
727 * for now.
728 * 2 + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT
729 */
730
731#ifdef __cplusplus
732}
733#endif
734
735#endif /* PPP_SUPPORT */
736#endif /* LWIP_HDR_PPP_IMPL_H */
static err_t netif_output(struct netif *netif, struct pbuf *p)
char * va_list
Definition: acmsvcex.h:78
#define open
Definition: acwin.h:95
#define close
Definition: acwin.h:98
#define write
Definition: acwin.h:97
#define msg(x)
Definition: auth_time.c:54
void disconnect(int argc, const char *argv[])
Definition: cmds.c:1620
struct protocol * protocols
Definition: dispatch.c:56
#define free
Definition: debug_ros.c:5
unsigned short u_short
Definition: types.h:81
UCHAR u_char
Definition: types.h:80
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_time_t time_t
Definition: linux.h:252
GLenum src
Definition: glext.h:6340
const GLubyte * c
Definition: glext.h:8905
GLint namelen
Definition: glext.h:7232
GLenum mode
Definition: glext.h:6217
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum const GLvoid * addr
Definition: glext.h:9621
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLenum GLenum GLenum input
Definition: glext.h:9031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
s8_t err_t
Definition: err.h:96
#define d
Definition: ke_i.h:81
static DATA_BLOB CRYPTPROTECT_PROMPTSTRUCT DATA_BLOB *static LPWSTR DATA_BLOB CRYPTPROTECT_PROMPTSTRUCT DATA_BLOB *static char secret[]
Definition: protectdata.c:33
static char * dest
Definition: rtl.c:135
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
static FILE * client
Definition: client.c:41
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
Definition: match.c:390
Definition: dsound.c:943
Definition: dhcpd.h:62
Definition: name.c:39
Definition: netif.h:269
Definition: pbuf.h:186
Definition: ecma_167.h:138
static rfbScreenInfoPtr server
Definition: vnc.c:74
void * arg
Definition: msvc.h:10
static int init
Definition: wintirpc.c:33
static int callbacks
Definition: xmllint.c:838