mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-05 05:54:37 +08:00
print packet is working back, at least for PPPoE
This commit is contained in:
parent
d27da93c33
commit
b922eaa754
@ -91,19 +91,17 @@ struct option_value {
|
|||||||
* Option variables and default values.
|
* Option variables and default values.
|
||||||
*/
|
*/
|
||||||
int debug = 0; /* Debug flag */
|
int debug = 0; /* Debug flag */
|
||||||
|
#if 0
|
||||||
int kdebugflag = 0; /* Tell kernel to print debug messages */
|
int kdebugflag = 0; /* Tell kernel to print debug messages */
|
||||||
int default_device = 1; /* Using /dev/tty or equivalent */
|
int default_device = 1; /* Using /dev/tty or equivalent */
|
||||||
#if 0
|
|
||||||
char devnam[MAXPATHLEN]; /* Device name */
|
char devnam[MAXPATHLEN]; /* Device name */
|
||||||
#endif
|
|
||||||
bool nodetach = 0; /* Don't detach from controlling tty */
|
bool nodetach = 0; /* Don't detach from controlling tty */
|
||||||
bool updetach = 0; /* Detach once link is up */
|
bool updetach = 0; /* Detach once link is up */
|
||||||
#if 0
|
|
||||||
int maxconnect = 0; /* Maximum connect time */
|
int maxconnect = 0; /* Maximum connect time */
|
||||||
char user[MAXNAMELEN]; /* Username for PAP */
|
char user[MAXNAMELEN]; /* Username for PAP */
|
||||||
char passwd[MAXSECRETLEN]; /* Password for PAP */
|
char passwd[MAXSECRETLEN]; /* Password for PAP */
|
||||||
#endif
|
|
||||||
bool persist = 0; /* Reopen link after it goes down */
|
bool persist = 0; /* Reopen link after it goes down */
|
||||||
|
#endif
|
||||||
char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
|
char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
|
||||||
#if DEMAND_SUPPORT
|
#if DEMAND_SUPPORT
|
||||||
bool demand = 0; /* do dial-on-demand */
|
bool demand = 0; /* do dial-on-demand */
|
||||||
|
@ -1057,6 +1057,10 @@ void ppp_input_over_ethernet(int pd, struct pbuf *pb) {
|
|||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PRINTPKT_SUPPORT
|
||||||
|
dump_packet("rcvd", pb->payload, pb->len);
|
||||||
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
|
||||||
in_protocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1];
|
in_protocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1];
|
||||||
|
|
||||||
/* make room for ppp_input_header - should not fail */
|
/* make room for ppp_input_header - should not fail */
|
||||||
@ -1068,7 +1072,7 @@ void ppp_input_over_ethernet(int pd, struct pbuf *pb) {
|
|||||||
pih = pb->payload;
|
pih = pb->payload;
|
||||||
|
|
||||||
pih->unit = pd;
|
pih->unit = pd;
|
||||||
pih->proto = in_protocol;
|
pih->proto = in_protocol; /* pih->proto is now in host byte order */
|
||||||
|
|
||||||
/* Dispatch the packet thereby consuming it. */
|
/* Dispatch the packet thereby consuming it. */
|
||||||
ppp_input(pb);
|
ppp_input(pb);
|
||||||
@ -1540,6 +1544,10 @@ static int ppp_write_over_ethernet(int pd, const u_char *s, int n) {
|
|||||||
return PPPERR_DEVICE;
|
return PPPERR_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PRINTPKT_SUPPORT
|
||||||
|
dump_packet("sent", (unsigned char *)s, n);
|
||||||
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
|
||||||
snmp_add_ifoutoctets(&pc->netif, (u16_t)n);
|
snmp_add_ifoutoctets(&pc->netif, (u16_t)n);
|
||||||
snmp_inc_ifoutucastpkts(&pc->netif);
|
snmp_inc_ifoutucastpkts(&pc->netif);
|
||||||
LINK_STATS_INC(link.xmit);
|
LINK_STATS_INC(link.xmit);
|
||||||
|
@ -56,9 +56,10 @@
|
|||||||
|
|
||||||
#include "upap.h"
|
#include "upap.h"
|
||||||
|
|
||||||
#if 0 /* UNUSED */
|
/* FIXME: move that to ppp_options */
|
||||||
|
#if PRINTPKT_SUPPORT
|
||||||
static bool hide_password = 1;
|
static bool hide_password = 1;
|
||||||
#endif /* UNUSED */
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
|
||||||
#if PPP_OPTIONS
|
#if PPP_OPTIONS
|
||||||
/*
|
/*
|
||||||
|
@ -75,12 +75,12 @@ static void log_write (int, char *);
|
|||||||
static void vslp_printer (void *, char *, ...);
|
static void vslp_printer (void *, char *, ...);
|
||||||
static void format_packet (u_char *, int, void (*) (void *, char *, ...),
|
static void format_packet (u_char *, int, void (*) (void *, char *, ...),
|
||||||
void *);
|
void *);
|
||||||
#endif /* PRINTPKT_SUPPORT */
|
|
||||||
|
|
||||||
struct buffer_info {
|
struct buffer_info {
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int len;
|
int len;
|
||||||
};
|
};
|
||||||
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
|
* strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
|
||||||
@ -482,10 +482,9 @@ format_packet(p, len, printer, arg)
|
|||||||
u_short proto;
|
u_short proto;
|
||||||
struct protent *protp;
|
struct protent *protp;
|
||||||
|
|
||||||
if (len >= PPP_HDRLEN && p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) {
|
if (len >= 2) {
|
||||||
p += 2;
|
|
||||||
GETSHORT(proto, p);
|
GETSHORT(proto, p);
|
||||||
len -= PPP_HDRLEN;
|
len -= 2;
|
||||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||||
if (proto == protp->protocol)
|
if (proto == protp->protocol)
|
||||||
break;
|
break;
|
||||||
@ -651,9 +650,7 @@ log_write(level, buf)
|
|||||||
int level;
|
int level;
|
||||||
char *buf;
|
char *buf;
|
||||||
{
|
{
|
||||||
/* FIXME: replace this with a log callback */
|
PPPDEBUG(level, ("%s\n", buf) );
|
||||||
/* if(level >= min_log_level) */ /* FIXME: add a minimum log level */
|
|
||||||
PPPDEBUG(LOG_DEBUG, ("LOG: %s\n", buf) );
|
|
||||||
#if 0
|
#if 0
|
||||||
if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
|
if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) {
|
||||||
int n = strlen(buf);
|
int n = strlen(buf);
|
||||||
@ -764,18 +761,28 @@ dump_packet(const char *tag, unsigned char *p, int len)
|
|||||||
if (!debug)
|
if (!debug)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* don't print IPv4 and IPv6 packets.
|
||||||
|
*/
|
||||||
|
proto = (p[0] << 8) + p[1];
|
||||||
|
if (proto == PPP_IP)
|
||||||
|
return;
|
||||||
|
#ifdef INET6
|
||||||
|
if (proto == PPP_IPV6 || proto == PPP_IPV6CP)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* don't print LCP echo request/reply packets if debug <= 1
|
* don't print LCP echo request/reply packets if debug <= 1
|
||||||
* and the link is up.
|
* and the link is up.
|
||||||
*/
|
*/
|
||||||
proto = (p[2] << 8) + p[3];
|
|
||||||
if (debug <= 1 && unsuccess == 0 && proto == PPP_LCP
|
if (debug <= 1 && unsuccess == 0 && proto == PPP_LCP
|
||||||
&& len >= PPP_HDRLEN + HEADERLEN) {
|
&& len >= 2 + HEADERLEN) {
|
||||||
unsigned char *lcp = p + PPP_HDRLEN;
|
unsigned char *lcp = p + 2;
|
||||||
int l = (lcp[2] << 8) + lcp[3];
|
int l = (lcp[2] << 8) + lcp[3];
|
||||||
|
|
||||||
if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP)
|
if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP)
|
||||||
&& l >= HEADERLEN && l <= len - PPP_HDRLEN)
|
&& l >= HEADERLEN && l <= len - 2)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user