X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fauth.c;h=469b0f857411fc2c62ead751e8aed6522ebcdbe7;hb=63e139d8f7c9daa2fed7e5be5f2f6b9abafa5125;hp=727c69d4af8d92bf55924d95eef3edf1c3070b17;hpb=7bb8beb860037a6c18dd0b64b8d542a20aa2c8c0;p=ppp.git diff --git a/pppd/auth.c b/pppd/auth.c index 727c69d..469b0f8 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -32,7 +32,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define RCSID "$Id: auth.c,v 1.77 2002/05/21 17:26:49 dfs Exp $" +#define RCSID "$Id: auth.c,v 1.80 2002/07/16 13:11:43 kad Exp $" #include #include @@ -217,6 +217,10 @@ static int set_noauth_addr __P((char **)); static void check_access __P((FILE *, char *)); static int wordlist_count __P((struct wordlist *)); +#ifdef MAXOCTETS +static void check_maxoctets __P((void *)); +#endif + /* * Authentication-related options. */ @@ -827,6 +831,11 @@ np_up(unit, proto) if (maxconnect > 0) TIMEOUT(connect_time_expired, 0, maxconnect); +#ifdef MAXOCTETS + if (maxoctets > 0) + TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); +#endif + /* * Detach now, if the updetach option was given. */ @@ -846,6 +855,9 @@ np_down(unit, proto) if (--num_np_up == 0) { UNTIMEOUT(check_idle, NULL); UNTIMEOUT(connect_time_expired, NULL); +#ifdef MAXOCTETS + UNTIMEOUT(check_maxoctets, NULL); +#endif new_phase(PHASE_NETWORK); } } @@ -863,6 +875,44 @@ np_finished(unit, proto) } } +#ifdef MAXOCTETS +static void +check_maxoctets(arg) + void *arg; +{ + int diff; + unsigned int used; + + update_link_stats(ifunit); + link_stats_valid=0; + + switch(maxoctets_dir) { + case PPP_OCTETS_DIRECTION_IN: + used = link_stats.bytes_in; + break; + case PPP_OCTETS_DIRECTION_OUT: + used = link_stats.bytes_out; + break; + case PPP_OCTETS_DIRECTION_MAXOVERAL: + case PPP_OCTETS_DIRECTION_MAXSESSION: + used = (link_stats.bytes_in > link_stats.bytes_out) ? link_stats.bytes_in : link_stats.bytes_out; + break; + default: + used = link_stats.bytes_in+link_stats.bytes_out; + break; + } + diff = maxoctets - used; + if(diff < 0) { + notice("Traffic limit reached. Limit: %u Used: %u", maxoctets, used); + lcp_close(0, "Traffic limit"); + need_holdoff = 0; + status = EXIT_TRAFFIC_LIMIT; + } else { + TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); + } +} +#endif + /* * check_idle - check whether the link has been idle for long * enough that we can shut it down.