#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.44 2000-09-18 05:11:44 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.57 2000-12-04 06:47:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
+#endif
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
-#ifdef __bsdi__
-#include <net/slcompress.h>
-#include <net/if_ppp.h>
-#endif
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
#include "ppp.h"
#include "chdlc.h"
-
-/* XXX This goes somewhere else. */
-#define PPP_HDRLEN 4
+#include "ethertype.h"
/*
* The following constatns are defined by IANA. Please refer to
#define BAP_CSIND 7
#define BAP_CSRES 8
-static const char *ppp_protoname __P((u_int proto));
-static void handle_ctrl_proto __P((u_int proto,const u_char *p, int length));
-static void handle_chap __P((const u_char *p, int length));
-static void handle_pap __P((const u_char *p, int length));
-static void handle_bap __P((const u_char *p, int length));
-static int print_lcp_config_options __P((const u_char *p, int));
-static int print_ipcp_config_options __P((const u_char *p, int));
-static int print_ccp_config_options __P((const u_char *p, int));
-static int print_bacp_config_options __P((const u_char *p, int));
-static void handle_ppp __P((u_int proto, const u_char *p, int length));
+static const char *ppp_protoname (u_int proto);
+static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
+static void handle_chap (const u_char *p, int length);
+static void handle_pap (const u_char *p, int length);
+static void handle_bap (const u_char *p, int length);
+static int print_lcp_config_options (const u_char *p, int);
+static int print_ipcp_config_options (const u_char *p, int);
+static int print_ccp_config_options (const u_char *p, int);
+static int print_bacp_config_options (const u_char *p, int);
+static void handle_ppp (u_int proto, const u_char *p, int length);
static const char *
ppp_protoname(u_int proto)
#ifdef PPP_XNS
case PPP_XNS: return "XNS";
#endif
-#ifdef PPP_IPX
case PPP_IPX: return "IPX";
-#endif
+ case PPP_VJC: return "VJC";
+ case PPP_VJNC: return "VJNC";
#ifdef PPP_COMP
case PPP_COMP: return "COMP";
#endif
-#ifdef PPP_IPCP
case PPP_IPCP: return "IPCP";
-#endif
-#ifdef PPP_IPV6CP
case PPP_IPV6CP: return "IPV6CP";
-#endif
-#ifdef PPP_IPXCP
case PPP_IPXCP: return "IPXCP";
-#endif
-#ifdef PPP_CCP
case PPP_CCP: return "CCP";
-#endif
-#ifdef PPP_LCP
case PPP_LCP: return "LCP";
-#endif
-#ifdef PPP_PAP
case PPP_PAP: return "PAP";
-#endif
#ifdef PPP_LQR
case PPP_LQR: return "LQR";
#endif
-#ifdef PPP_CHAP
case PPP_CHAP: return "CHAP";
-#endif
-#ifdef PPP_BACP
case PPP_BACP: return "BACP";
-#endif
-#ifdef PPP_BAP
case PPP_BAP: return "BAP";
-#endif
default:
snprintf(buf, sizeof(buf), "unknown-0x%04x", proto);
return buf;
case PPP_BACP:
pfunc = print_bacp_config_options;
break;
+ default:
+ /*
+ * This should never happen, but we set
+ * "pfunc" to squelch uninitialized
+ * variable warnings from compilers.
+ */
+ pfunc = NULL;
+ break;
}
if ((j = (*pfunc)(p, len)) == 0)
break;
print_lcp_config_options(const u_char *p, int length)
{
int len, opt;
- int i;
if (length < 2)
return 0;
}
}
-/* PAP */
+/* PAP (see RFC 1334) */
static void
handle_pap(const u_char *p, int length)
{
}
code = *p;
- if (length < 4)
if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
printf("%s", papcode[code - 1]);
else {
return;
msg_len = *p; /* Msg-Length */
p++;
- if (length - (p - p0) < passwd_len)
+ if (length - (p - p0) < msg_len)
return;
printf(", Msg=");
for (i = 0; i< msg_len; i++)
ipaddr_string(p + 6));
break;
case IPCPOPT_IPCOMP:
- if (len != 4)
+ if (len < 4)
goto invlen;
printf(", IP-Comp");
if (EXTRACT_16BITS(p + 2) == PPP_VJC) {
ip6_print(p, length);
break;
#endif
+ case ETHERTYPE_IPX: /*XXX*/
+ case PPP_IPX:
+ ipx_print(p, length);
+ break;
}
}
ppp_print(register const u_char *p, u_int length)
{
u_int proto;
+ u_int full_length = length;
/*
* Here, we assume that p points to the Address and Control
length -= 2;
}
- printf("%s: ", ppp_protoname(proto));
+ printf("%s %d: ", ppp_protoname(proto), full_length);
handle_ppp(proto, p, length);
return;
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- const struct ip *ip;
- u_int proto;
ts_print(&h->ts);
printf("] ");
}
}
- if (eflag)
- printf("%d ", length);
}
+ if (eflag)
+ printf("%d ", length);
if (p[SLC_CHL]) {
q = p + SLC_BPFHDRLEN + p[SLC_LLHL];