X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fipcp.c;h=3fc5f27f1736bdc9c1f1c597cabd777c4d653cf7;hp=5236244ac35627786277be4bae209d954076e9ff;hb=05c09ae62d0b4ff67fb26c37a01e6a07bb593c0c;hpb=37a8acc7ee2527693d0c8ba82b2eaea249abde34 diff --git a/pppd/ipcp.c b/pppd/ipcp.c index 5236244..3fc5f27 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -17,7 +17,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define RCSID "$Id: ipcp.c,v 1.57 2001/03/08 05:11:12 paulus Exp $" +#define RCSID "$Id: ipcp.c,v 1.60 2002/01/22 16:02:58 dfs Exp $" /* * TODO: @@ -59,6 +59,10 @@ void (*ip_down_hook) __P((void)) = NULL; /* Hook for a plugin to choose the remote IP address */ void (*ip_choose_hook) __P((u_int32_t *)) = NULL; +/* Notifiers for when IPCP goes up and down */ +struct notifier *ip_up_notifier = NULL; +struct notifier *ip_down_notifier = NULL; + /* local vars */ static int default_route_set[NUM_PPP]; /* Have set up a default route */ static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ @@ -109,7 +113,7 @@ static int setvjslots __P((char **)); static int setdnsaddr __P((char **)); static int setwinsaddr __P((char **)); static int setnetmask __P((char **)); -static int setipaddr __P((char *, char **, int)); +int setipaddr __P((char *, char **, int)); static void printipaddr __P((option_t *, void (*)(void *, char *,...),void *)); static option_t ipcp_option_list[] = { @@ -367,8 +371,9 @@ setwinsaddr(argv) * setipaddr - Set the IP address * If doit is 0, the call is to check whether this option is * potentially an IP address specification. + * Not static so that plugins can call it to set the addresses */ -static int +int setipaddr(arg, argv, doit) char *arg; char **argv; @@ -651,8 +656,12 @@ ipcp_resetci(f) *go = *wo; if (!ask_for_local) go->ouraddr = 0; - if (ip_choose_hook) + if (ip_choose_hook) { ip_choose_hook(&wo->hisaddr); + if (wo->hisaddr) { + wo->accept_remote = 0; + } + } } @@ -1709,6 +1718,7 @@ ipcp_up(f) np_up(f->unit, PPP_IP); ipcp_is_up = 1; + notify(ip_up_notifier, 0); if (ip_up_hook) ip_up_hook(); @@ -1737,6 +1747,7 @@ ipcp_down(f) /* XXX a bit IPv4-centric here, we only need to get the stats * before the interface is marked down. */ update_link_stats(f->unit); + notify(ip_down_notifier, 0); if (ip_down_hook) ip_down_hook(); if (ipcp_is_up) { @@ -2012,7 +2023,9 @@ ipcp_printpkt(p, plen, printer, arg) */ #define IP_HDRLEN 20 /* bytes */ #define IP_OFFMASK 0x1fff +#ifndef IPPROTO_TCP #define IPPROTO_TCP 6 +#endif #define TCP_HDRLEN 20 #define TH_FIN 0x01