demand support is now a compile-time option

Obviously, it requires some wiring to know if there is new activity
on a not-yet established PPP interface with the default route
already set.

I don't think any lwIP user will ever need that, all should know
when to bring the link up and down.
This commit is contained in:
Sylvain Rochet 2012-06-02 00:53:25 +02:00
parent ee5fca7a2b
commit 8b866beaeb
10 changed files with 35 additions and 5 deletions

View File

@ -199,8 +199,10 @@ struct protent ccp_protent = {
ccp_option_list,
NULL,
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
NULL,
NULL
#endif /* DEMAND_SUPPORT */
};
fsm ccp_fsm[NUM_PPP];

View File

@ -669,8 +669,10 @@ struct protent chap_protent = {
chap_option_list,
NULL, /* check_options */
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
NULL,
NULL
#endif /* DEMAND_SUPPORT */
};
#endif /* PPP_SUPPORT && CHAP_SUPPORT */

View File

@ -29,8 +29,7 @@
*/
#include "lwip/opt.h"
#define RCSID "$Id: demand.c,v 1.20 2005/08/25 12:14:18 paulus Exp $"
#if PPP_SUPPORT && DEMAND_SUPPORT /* don't build if not configured for use in lwipopts.h */
#include <stdio.h>
#include <stdlib.h>
@ -466,3 +465,5 @@ active_packet(p, len)
}
return 0; /* not a supported protocol !!?? */
}
#endif /* PPP_SUPPORT && DEMAND_SUPPORT */

View File

@ -122,8 +122,10 @@ struct protent eap_protent = {
eap_option_list, /* list of command-line options */
NULL, /* check requested options; assign defaults */
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
NULL, /* configure interface for demand-dial */
NULL /* say whether to bring up link for this pkt */
#endif /* DEMAND_SUPPORT */
};
#ifdef USE_SRP

View File

@ -118,8 +118,10 @@ struct protent ecp_protent = {
ecp_option_list,
NULL,
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
NULL,
NULL
#endif /* DEMAND_SUPPORT */
};
fsm ecp_fsm[NUM_PPP];

View File

@ -259,8 +259,10 @@ static void ipcp_protrej __P((int));
static int ipcp_printpkt __P((u_char *, int,
void (*) __P((void *, char *, ...)), void *));
static void ip_check_options __P((void));
#if DEMAND_SUPPORT
static int ip_demand_conf __P((int));
static int ip_active_pkt __P((u_char *, int));
#endif /* DEMAND_SUPPORT */
static void create_resolv __P((u_int32_t, u_int32_t));
struct protent ipcp_protent = {
@ -281,8 +283,10 @@ struct protent ipcp_protent = {
ipcp_option_list,
ip_check_options,
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
ip_demand_conf,
ip_active_pkt
#endif /* DEMAND_SUPPORT */
};
static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
@ -1724,6 +1728,7 @@ ip_check_options()
}
#endif /* UNUSED */
#if DEMAND_SUPPORT
/*
* ip_demand_conf - configure the interface as though
* IPCP were up, for use with dial-on-demand.
@ -1765,7 +1770,7 @@ ip_demand_conf(u)
return 1;
}
#endif /* DEMAND_SUPPORT */
/*
* ipcp_up - IPCP has come UP.
@ -1837,6 +1842,7 @@ ipcp_up(f)
/* set tcp compression */
sifvjcomp(f->unit, ho->neg_vj, ho->cflag, ho->maxslotindex);
#if DEMAND_SUPPORT
/*
* If we are doing dial-on-demand, the interface is already
* configured, so we put out any saved-up packets, then set the
@ -1883,7 +1889,9 @@ ipcp_up(f)
demand_rexmit(PPP_IP,go->ouraddr);
sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
} else {
} else
#endif /* DEMAND_SUPPORT */
{
/*
* Set IP addresses and (if specified) netmask.
*/
@ -1978,13 +1986,16 @@ ipcp_down(f)
* because print_link_stats() sets link_stats_valid
* to 0 (zero) */
#if DEMAND_SUPPORT
/*
* If we are doing dial-on-demand, set the interface
* to queue up outgoing packets (for now).
*/
if (demand) {
sifnpmode(f->unit, PPP_IP, NPMODE_QUEUE);
} else {
} else
#endif /* DEMAND_SUPPORT */
{
sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
sifdown(f->unit);
ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
@ -2188,6 +2199,7 @@ ipcp_printpkt(p, plen, printer, arg)
#define TCP_HDRLEN 20
#define TH_FIN 0x01
#if DEMAND_SUPPORT
/*
* We use these macros because the IP header may be at an odd address,
* and some compilers might use word loads to get th_off or ip_hl.
@ -2224,3 +2236,4 @@ ip_active_pkt(pkt, len)
return 0;
return 1;
}
#endif /* DEMAND_SUPPORT */

View File

@ -285,8 +285,10 @@ struct protent lcp_protent = {
lcp_option_list,
NULL,
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
NULL,
NULL
#endif /* DEMAND_SUPPORT */
};
int lcp_loopbackfail = DEFLOOPBACKFAIL;

View File

@ -102,7 +102,9 @@ int maxconnect = 0; /* Maximum connect time */
//char passwd[MAXSECRETLEN]; /* Password for PAP */
bool persist = 0; /* Reopen link after it goes down */
char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
#if DEMAND_SUPPORT
bool demand = 0; /* do dial-on-demand */
#endif /* DEMAND_SUPPORT */
char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
int idle_time_limit = 0; /* Disconnect if idle for this many seconds */
int holdoff = 30; /* # seconds to pause before reconnecting */

View File

@ -436,10 +436,12 @@ struct protent {
/* Check requested options, assign defaults */
void (*check_options) __P((void));
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
/* Configure interface for demand-dial */
int (*demand_conf) __P((int unit));
/* Say whether to bring up link for this pkt */
int (*active_pkt) __P((u_char *pkt, int len));
#endif /* DEMAND_SUPPORT */
};
/* Table of pointers to supported protocols */

View File

@ -105,8 +105,10 @@ struct protent pap_protent = {
pap_option_list,
NULL,
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
NULL,
NULL
#endif /* DEMAND_SUPPORT */
};
upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */