mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-23 19:20:52 +00:00
PPP statistics optional (non working) compile time option added
This commit is contained in:
parent
4158222e86
commit
922d3716ff
@ -643,7 +643,9 @@ link_terminated(unit)
|
||||
|
||||
if (!doing_multilink) {
|
||||
notice("Connection terminated.");
|
||||
#if PPP_STATS_SUPPORT
|
||||
print_link_stats();
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
} else
|
||||
notice("Link terminated.");
|
||||
|
||||
@ -1242,11 +1244,12 @@ static void
|
||||
check_maxoctets(arg)
|
||||
void *arg;
|
||||
{
|
||||
#if PPP_STATS_SUPPORT
|
||||
unsigned int used;
|
||||
|
||||
update_link_stats(ifunit);
|
||||
link_stats_valid=0;
|
||||
|
||||
|
||||
switch(maxoctets_dir) {
|
||||
case PPP_OCTETS_DIRECTION_IN:
|
||||
used = link_stats.bytes_in;
|
||||
@ -1270,8 +1273,9 @@ check_maxoctets(arg)
|
||||
} else {
|
||||
TIMEOUT(check_maxoctets, NULL, maxoctets_timeout);
|
||||
}
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
}
|
||||
#endif
|
||||
#endif /* MAXOCTETS */
|
||||
|
||||
/*
|
||||
* check_idle - check whether the link has been idle for long
|
||||
|
@ -1958,7 +1958,9 @@ ipcp_up(f)
|
||||
notice("secondary DNS address %I", go->dnsaddr[1]);
|
||||
}
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
reset_link_stats(f->unit);
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
np_up(f->unit, PPP_IP);
|
||||
ipcp_is_up = 1;
|
||||
@ -1982,11 +1984,13 @@ ipcp_down(f)
|
||||
fsm *f;
|
||||
{
|
||||
IPCPDEBUG(("ipcp: down"));
|
||||
#if PPP_STATS_SUPPORT
|
||||
/* XXX a bit IPv4-centric here, we only need to get the stats
|
||||
* before the interface is marked down. */
|
||||
/* XXX more correct: we must get the stats before running the notifiers,
|
||||
* at least for the radius plugin */
|
||||
update_link_stats(f->unit);
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
#if PPP_NOTIFY
|
||||
notify(ip_down_notifier, 0);
|
||||
#endif /* PPP_NOTIFY */
|
||||
@ -1998,9 +2002,11 @@ ipcp_down(f)
|
||||
}
|
||||
sifvjcomp(f->unit, 0, 0, 0);
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
print_link_stats(); /* _after_ running the notifiers and ip_down_hook(),
|
||||
* because print_link_stats() sets link_stats_valid
|
||||
* to 0 (zero) */
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
#if DEMAND_SUPPORT
|
||||
/*
|
||||
|
@ -2629,8 +2629,10 @@ LcpSendEchoRequest (f)
|
||||
if (lcp_echo_adaptive) {
|
||||
static unsigned int last_pkts_in = 0;
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
update_link_stats(f->unit);
|
||||
link_stats_valid = 0;
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
if (link_stats.pkts_in != last_pkts_in) {
|
||||
last_pkts_in = link_stats.pkts_in;
|
||||
|
@ -279,7 +279,9 @@ void mp_bundle_terminated()
|
||||
bundle_terminating = 1;
|
||||
upper_layers_down(0);
|
||||
notice("Connection terminated.");
|
||||
#if PPP_STATS_SUPPORT
|
||||
print_link_stats();
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
if (!demand) {
|
||||
remove_pidfiles();
|
||||
script_unsetenv("IFNAME");
|
||||
|
@ -198,12 +198,12 @@ GIDSET_TYPE groups[NGROUPS_MAX];/* groups the user is in */
|
||||
int ngroups; /* How many groups valid in groups */
|
||||
#endif /* UNUSED */
|
||||
|
||||
static struct timeval start_time; /* Time when link was started. */
|
||||
//static struct timeval start_time; /* Time when link was started. */
|
||||
|
||||
static struct pppd_stats old_link_stats;
|
||||
struct pppd_stats link_stats;
|
||||
unsigned link_connect_time;
|
||||
int link_stats_valid;
|
||||
//static struct pppd_stats old_link_stats;
|
||||
//struct pppd_stats link_stats;
|
||||
//unsigned link_connect_time;
|
||||
//int link_stats_valid;
|
||||
|
||||
int error_count;
|
||||
|
||||
@ -249,7 +249,9 @@ static void childwait_end __P((void *));
|
||||
|
||||
static void handle_events __P((void));
|
||||
#endif
|
||||
#if 0
|
||||
void print_link_stats __P((void));
|
||||
#endif
|
||||
|
||||
extern char *ttyname __P((int));
|
||||
extern char *getlogin __P((void));
|
||||
@ -794,6 +796,7 @@ detach()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* reopen_log - (re)open our connection to syslog.
|
||||
*/
|
||||
@ -803,6 +806,7 @@ reopen_log()
|
||||
openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
|
||||
setlogmask(LOG_UPTO(LOG_INFO));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
@ -1066,6 +1070,7 @@ cleanup()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void
|
||||
print_link_stats()
|
||||
{
|
||||
@ -1127,7 +1132,7 @@ update_link_stats(u)
|
||||
script_setenv("BYTES_RCVD", numbuf, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct callout {
|
||||
struct timeval c_time; /* time at which to call routine */
|
||||
|
@ -86,7 +86,9 @@
|
||||
* Option descriptor structure.
|
||||
*/
|
||||
|
||||
#ifndef bool
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
enum opt_type {
|
||||
@ -166,6 +168,7 @@ struct permitted_ip {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Unfortunately, the linux kernel driver uses a different structure
|
||||
* for statistics from the rest of the ports.
|
||||
@ -178,6 +181,7 @@ struct pppd_stats {
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Used for storing a sequence of words. Usually malloced. */
|
||||
struct wordlist {
|
||||
@ -236,9 +240,11 @@ extern int detached; /* Have detached from controlling tty */
|
||||
extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
|
||||
#endif
|
||||
extern int ngroups; /* How many groups valid in groups */
|
||||
#if PPP_STATS_SUPPORT
|
||||
extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
|
||||
extern int link_stats_valid; /* set if link_stats is valid */
|
||||
extern unsigned link_connect_time; /* time the link was up for */
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
extern int using_pty; /* using pty as device (notty or pty opt.) */
|
||||
extern int log_to_fd; /* logging to this fd as well as syslog */
|
||||
extern bool log_default; /* log_to_fd is default (stdout) */
|
||||
@ -522,10 +528,14 @@ pid_t safe_fork __P((int, int, int)); /* Fork & close stuff in child */
|
||||
|
||||
//int device_script __P((char *cmd, int in, int out, int dont_wait));
|
||||
/* Run `cmd' with given stdin and stdout */
|
||||
#if 0
|
||||
void reopen_log __P((void)); /* (re)open the connection to syslog */
|
||||
#endif
|
||||
#if 0
|
||||
void print_link_stats __P((void)); /* Print stats, if available */
|
||||
void reset_link_stats __P((int)); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats __P((int)); /* Get stats at link termination */
|
||||
#endif
|
||||
#if 0 /* UNUSED */
|
||||
void script_setenv __P((char *, char *, int)); /* set script env var */
|
||||
void script_unsetenv __P((char *)); /* unset script env var */
|
||||
@ -536,8 +546,8 @@ void add_notifier __P((struct notifier **, notify_func, void *));
|
||||
void remove_notifier __P((struct notifier **, notify_func, void *));
|
||||
void notify __P((struct notifier *, int));
|
||||
#endif /* UNUSED */
|
||||
int ppp_send_config __P((int, int, u_int32_t, int, int));
|
||||
int ppp_recv_config __P((int, int, u_int32_t, int, int));
|
||||
//int ppp_send_config __P((int, int, u_int32_t, int, int));
|
||||
//int ppp_recv_config __P((int, int, u_int32_t, int, int));
|
||||
//void remove_pidfiles __P((void));
|
||||
void lock_db __P((void));
|
||||
void unlock_db __P((void));
|
||||
@ -668,21 +678,21 @@ int ccp_test __P((int, u_char *, int, int));
|
||||
void ccp_flags_set __P((int, int, int));
|
||||
/* Set kernel CCP state */
|
||||
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
||||
int get_idle_time __P((int, struct ppp_idle *));
|
||||
//int get_idle_time __P((int, struct ppp_idle *));
|
||||
/* Find out how long link has been idle */
|
||||
int get_ppp_stats __P((int, struct pppd_stats *));
|
||||
//int get_ppp_stats __P((int, struct pppd_stats *));
|
||||
/* Return link statistics */
|
||||
void netif_set_mtu __P((int, int)); /* Set PPP interface MTU */
|
||||
int netif_get_mtu __P((int)); /* Get PPP interface MTU */
|
||||
int sifvjcomp __P((int, int, int, int));
|
||||
//void netif_set_mtu __P((int, int)); /* Set PPP interface MTU */
|
||||
//int netif_get_mtu __P((int)); /* Get PPP interface MTU */
|
||||
//int sifvjcomp __P((int, int, int, int));
|
||||
/* Configure VJ TCP header compression */
|
||||
int sifup __P((int)); /* Configure i/f up for one protocol */
|
||||
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
||||
//int sifup __P((int)); /* Configure i/f up for one protocol */
|
||||
//int sifnpmode __P((int u, int proto, enum NPmode mode));
|
||||
/* Set mode for handling packets for proto */
|
||||
int sifdown __P((int)); /* Configure i/f down for one protocol */
|
||||
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
||||
//int sifdown __P((int)); /* Configure i/f down for one protocol */
|
||||
//int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
||||
/* Configure IPv4 addresses for i/f */
|
||||
int cifaddr __P((int, u_int32_t, u_int32_t));
|
||||
//int cifaddr __P((int, u_int32_t, u_int32_t));
|
||||
/* Reset i/f IP addresses */
|
||||
#ifdef INET6
|
||||
int sif6addr __P((int, eui64_t, eui64_t));
|
||||
@ -690,15 +700,15 @@ int sif6addr __P((int, eui64_t, eui64_t));
|
||||
int cif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Remove an IPv6 address from i/f */
|
||||
#endif
|
||||
int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
|
||||
//int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
|
||||
/* Create default route through i/f */
|
||||
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
//int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Delete default route through i/f */
|
||||
int sifproxyarp __P((int, u_int32_t));
|
||||
//int sifproxyarp __P((int, u_int32_t));
|
||||
/* Add proxy ARP entry for peer */
|
||||
int cifproxyarp __P((int, u_int32_t));
|
||||
//int cifproxyarp __P((int, u_int32_t));
|
||||
/* Delete proxy ARP entry for peer */
|
||||
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
||||
//u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
||||
#if 0 /* Unused */
|
||||
int lock __P((char *)); /* Create lock file for device */
|
||||
int relock __P((int)); /* Rewrite lock file with new pid */
|
||||
|
@ -26,6 +26,15 @@
|
||||
/* FIXME: add a phase per PPP session */
|
||||
int phase; /* where the link is at */
|
||||
|
||||
/* FIXME: add stats per PPP session */
|
||||
#if PPP_STATS_SUPPORT
|
||||
static struct timeval start_time; /* Time when link was started. */
|
||||
static struct pppd_stats old_link_stats;
|
||||
struct pppd_stats link_stats;
|
||||
unsigned link_connect_time;
|
||||
int link_stats_valid;
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
/* PPP packet parser states. Current state indicates operation yet to be
|
||||
* completed. */
|
||||
typedef enum {
|
||||
@ -148,8 +157,7 @@ PACK_STRUCT_END
|
||||
|
||||
|
||||
/** Initiate LCP open request */
|
||||
static void pppStart(int pd)
|
||||
{
|
||||
static void pppStart(int pd) {
|
||||
PPPDEBUG(LOG_DEBUG, ("pppStart: unit %d\n", pd));
|
||||
lcp_open(pd); /* Start protocol */
|
||||
lcp_lowerup(pd);
|
||||
@ -454,9 +462,7 @@ int ppp_init(void) {
|
||||
(*protp->init)(0);
|
||||
}
|
||||
|
||||
void
|
||||
pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd)
|
||||
{
|
||||
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) {
|
||||
/* FIXME: the following may look stupid, but this is just an easy way
|
||||
* to check different auth by changing compile time option
|
||||
*/
|
||||
@ -649,9 +655,7 @@ drop:
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
pppOverEthernetInitFailed(int pd)
|
||||
{
|
||||
void pppOverEthernetInitFailed(int pd) {
|
||||
PPPControl* pc;
|
||||
|
||||
//pppHup(pd);
|
||||
@ -666,9 +670,7 @@ pppOverEthernetInitFailed(int pd)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pppOverEthernetLinkStatusCB(int pd, int up)
|
||||
{
|
||||
static void pppOverEthernetLinkStatusCB(int pd, int up) {
|
||||
printf("pppOverEthernetLinkStatusCB: called, pd = %d, up = %d\n", pd, up);
|
||||
if(up) {
|
||||
PPPDEBUG(LOG_INFO, ("pppOverEthernetLinkStatusCB: unit %d: Connecting\n", pd));
|
||||
@ -680,9 +682,7 @@ pppOverEthernetLinkStatusCB(int pd, int up)
|
||||
#endif
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
static err_t
|
||||
pppifOutputOverEthernet(int pd, struct pbuf *p)
|
||||
{
|
||||
static err_t pppifOutputOverEthernet(int pd, struct pbuf *p) {
|
||||
PPPControl *pc = &pppControl[pd];
|
||||
struct pbuf *pb;
|
||||
u_short protocol = PPP_IP;
|
||||
@ -724,9 +724,7 @@ pppifOutputOverEthernet(int pd, struct pbuf *p)
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
/* Send a packet on the given connection. */
|
||||
static err_t
|
||||
pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr)
|
||||
{
|
||||
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) {
|
||||
int pd = (int)(size_t)netif->state;
|
||||
PPPControl *pc = &pppControl[pd];
|
||||
#if PPPOS_SUPPORT
|
||||
@ -877,9 +875,7 @@ pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr)
|
||||
/*
|
||||
* Return the Maximum Transmission Unit for the given PPP connection.
|
||||
*/
|
||||
u_short
|
||||
pppMTU(int pd)
|
||||
{
|
||||
u_short pppMTU(int pd) {
|
||||
PPPControl *pc = &pppControl[pd];
|
||||
u_short st;
|
||||
|
||||
@ -894,9 +890,7 @@ pppMTU(int pd)
|
||||
}
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
int
|
||||
pppWriteOverEthernet(int pd, const u_char *s, int n)
|
||||
{
|
||||
int pppWriteOverEthernet(int pd, const u_char *s, int n) {
|
||||
PPPControl *pc = &pppControl[pd];
|
||||
struct pbuf *pb;
|
||||
|
||||
@ -939,9 +933,7 @@ pppWriteOverEthernet(int pd, const u_char *s, int n)
|
||||
* RETURN: >= 0 Number of characters written
|
||||
* -1 Failed to write to device
|
||||
*/
|
||||
int
|
||||
pppWrite(int pd, const u_char *s, int n)
|
||||
{
|
||||
int pppWrite(int pd, const u_char *s, int n) {
|
||||
PPPControl *pc = &pppControl[pd];
|
||||
#if PPPOS_SUPPORT
|
||||
u_char c;
|
||||
@ -1030,12 +1022,7 @@ void output (int unit, unsigned char *p, int len)
|
||||
* ppp_send_config - configure the transmit-side characteristics of
|
||||
* the ppp interface.
|
||||
*/
|
||||
int
|
||||
ppp_send_config(unit, mtu, accm, pcomp, accomp)
|
||||
int unit, mtu;
|
||||
u_int32_t accm;
|
||||
int pcomp, accomp;
|
||||
{
|
||||
int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp) {
|
||||
PPPControl *pc = &pppControl[unit];
|
||||
int i;
|
||||
|
||||
@ -1050,18 +1037,14 @@ ppp_send_config(unit, mtu, accm, pcomp, accomp)
|
||||
PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]: outACCM=%X %X %X %X\n",
|
||||
unit,
|
||||
pc->outACCM[0], pc->outACCM[1], pc->outACCM[2], pc->outACCM[3]));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ppp_recv_config - configure the receive-side characteristics of
|
||||
* the ppp interface.
|
||||
*/
|
||||
int
|
||||
ppp_recv_config(unit, mru, accm, pcomp, accomp)
|
||||
int unit, mru;
|
||||
u_int32_t accm;
|
||||
int pcomp, accomp;
|
||||
{
|
||||
int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp) {
|
||||
PPPControl *pc = &pppControl[unit];
|
||||
int i;
|
||||
SYS_ARCH_DECL_PROTECT(lev);
|
||||
@ -1080,17 +1063,15 @@ ppp_recv_config(unit, mru, accm, pcomp, accomp)
|
||||
PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]: inACCM=%X %X %X %X\n",
|
||||
unit,
|
||||
pc->rx.inACCM[0], pc->rx.inACCM[1], pc->rx.inACCM[2], pc->rx.inACCM[3]));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* sifaddr - Config the interface IP addresses and netmask.
|
||||
*/
|
||||
int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr,
|
||||
u_int32_t net_mask)
|
||||
{
|
||||
u_int32_t net_mask) {
|
||||
PPPControl *pc = &pppControl[unit];
|
||||
int st = 1;
|
||||
|
||||
@ -1118,16 +1099,6 @@ int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) {
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* sifdown - Disable the indicated protocol and config the interface
|
||||
* down if there are no remaining protocols.
|
||||
*/
|
||||
int sifdown (int u) {
|
||||
/* FIXME: do the code which shutdown a PPP interface */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* pppifNetifInit - netif init callback
|
||||
*/
|
||||
@ -1178,13 +1149,20 @@ int sifup(int u)
|
||||
return st;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* sifdown - Disable the indicated protocol and config the interface
|
||||
* down if there are no remaining protocols.
|
||||
*/
|
||||
int sifdown (int u) {
|
||||
/* FIXME: do the code which shutdown a PPP interface */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* sifnpmode - Set the mode for handling packets for a given NP.
|
||||
*/
|
||||
int
|
||||
sifnpmode(int u, int proto, enum NPmode mode)
|
||||
{
|
||||
int sifnpmode(int u, int proto, enum NPmode mode) {
|
||||
LWIP_UNUSED_ARG(u);
|
||||
LWIP_UNUSED_ARG(proto);
|
||||
LWIP_UNUSED_ARG(mode);
|
||||
@ -1197,6 +1175,12 @@ sifnpmode(int u, int proto, enum NPmode mode)
|
||||
void netif_set_mtu(int unit, int mtu) {
|
||||
/* FIXME: set lwIP MTU */
|
||||
}
|
||||
/*
|
||||
* netif_get_mtu - get PPP interface MTU
|
||||
*/
|
||||
int netif_get_mtu(int mtu) {
|
||||
/* FIXME: get lwIP MTU */
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
@ -1450,3 +1434,54 @@ void new_phase(int p) {
|
||||
/* The one willing notify support should add here the code to be notified of phase changes */
|
||||
#endif /* PPP_NOTIFY */
|
||||
}
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
|
||||
/* ---- Note on PPP Stats support ----
|
||||
*
|
||||
* The one willing link stats support should add the get_ppp_stats()
|
||||
* to fetch statistics from lwIP.
|
||||
*/
|
||||
|
||||
/*
|
||||
* reset_link_stats - "reset" stats when link goes up.
|
||||
*/
|
||||
void reset_link_stats(int u) {
|
||||
if (!get_ppp_stats(u, &old_link_stats))
|
||||
return;
|
||||
gettimeofday(&start_time, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* update_link_stats - get stats at link termination.
|
||||
*/
|
||||
void update_link_stats(int u) {
|
||||
|
||||
struct timeval now;
|
||||
char numbuf[32];
|
||||
|
||||
if (!get_ppp_stats(u, &link_stats)
|
||||
|| gettimeofday(&now, NULL) < 0)
|
||||
return;
|
||||
link_connect_time = now.tv_sec - start_time.tv_sec;
|
||||
link_stats_valid = 1;
|
||||
|
||||
link_stats.bytes_in -= old_link_stats.bytes_in;
|
||||
link_stats.bytes_out -= old_link_stats.bytes_out;
|
||||
link_stats.pkts_in -= old_link_stats.pkts_in;
|
||||
link_stats.pkts_out -= old_link_stats.pkts_out;
|
||||
}
|
||||
|
||||
void print_link_stats() {
|
||||
/*
|
||||
* Print connect time and statistics.
|
||||
*/
|
||||
if (link_stats_valid) {
|
||||
int t = (link_connect_time + 5) / 6; /* 1/10ths of minutes */
|
||||
info("Connect time %d.%d minutes.", t/10, t%10);
|
||||
info("Sent %u bytes, received %u bytes.",
|
||||
link_stats.bytes_out, link_stats.bytes_in);
|
||||
link_stats_valid = 0;
|
||||
}
|
||||
}
|
||||
#endif PPP_STATS_SUPPORT
|
||||
|
@ -12,9 +12,16 @@
|
||||
|
||||
#include <syslog.h> /* FIXME: temporary */
|
||||
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
#ifndef bool
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*************************
|
||||
*** PUBLIC DEFINITIONS ***
|
||||
*************************/
|
||||
@ -38,6 +45,17 @@ struct ppp_addrs {
|
||||
ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
|
||||
};
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
/*
|
||||
* PPP statistics structure
|
||||
*/
|
||||
struct pppd_stats {
|
||||
unsigned int bytes_in;
|
||||
unsigned int bytes_out;
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
/* FIXME: use PPP option instead ? */
|
||||
|
||||
@ -121,6 +139,14 @@ enum pppAuthType {
|
||||
#endif /* CHAP_SUPPORT */
|
||||
};
|
||||
|
||||
struct pbuf * pppSingleBuf(struct pbuf *p);
|
||||
|
||||
static void pppStart(int pd);
|
||||
|
||||
static void ppp_input(void *arg);
|
||||
|
||||
int ppp_init(void);
|
||||
|
||||
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
|
||||
|
||||
/* Link status callback function prototype */
|
||||
@ -132,8 +158,56 @@ typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
|
||||
int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name,
|
||||
pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
||||
|
||||
|
||||
void pppInProcOverEthernet(int pd, struct pbuf *pb);
|
||||
|
||||
void pppOverEthernetInitFailed(int pd);
|
||||
|
||||
static void pppOverEthernetLinkStatusCB(int pd, int up);
|
||||
|
||||
static err_t pppifOutputOverEthernet(int pd, struct pbuf *p);
|
||||
|
||||
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr);
|
||||
|
||||
u_short pppMTU(int pd);
|
||||
|
||||
int pppWriteOverEthernet(int pd, const u_char *s, int n);
|
||||
|
||||
int pppWrite(int pd, const u_char *s, int n);
|
||||
|
||||
void pppInProcOverEthernet(int pd, struct pbuf *pb);
|
||||
|
||||
void output (int unit, unsigned char *p, int len);
|
||||
|
||||
int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp);
|
||||
int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp);
|
||||
|
||||
int sifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr, u_int32_t net_mask);
|
||||
int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr);
|
||||
|
||||
static err_t pppifNetifInit(struct netif *netif);
|
||||
|
||||
int sifup(int u);
|
||||
int sifdown (int u);
|
||||
|
||||
int sifnpmode(int u, int proto, enum NPmode mode);
|
||||
|
||||
void netif_set_mtu(int unit, int mtu);
|
||||
int netif_get_mtu(int mtu);
|
||||
|
||||
int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace);
|
||||
int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway);
|
||||
|
||||
int sifproxyarp (int unit, u_int32_t his_adr);
|
||||
int cifproxyarp (int unit, u_int32_t his_adr);
|
||||
|
||||
int sifvjcomp (int u, int vjcomp, int cidcomp, int maxcid);
|
||||
|
||||
int get_idle_time(int u, struct ppp_idle *ip);
|
||||
|
||||
int get_loop_output(void);
|
||||
|
||||
u_int32_t GetMask (u_int32_t addr);
|
||||
|
||||
#if PPP_PROTOCOLNAME
|
||||
const char * protocol_name(int proto);
|
||||
@ -141,4 +215,10 @@ const char * protocol_name(int proto);
|
||||
|
||||
void new_phase(int p);
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
void print_link_stats(void); /* Print stats, if available */
|
||||
void reset_link_stats(int u); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats(int u); /* Get stats at link termination */
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
#endif /* PPPMY_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user