print-ppp.c (38638) | print-ppp.c (39300) |
---|---|
1/* | 1/* |
2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 | 2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 |
3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and 9 * this paragraph in its entirety in the documentation or other materials 10 * provided with the distribution, and (3) all advertising materials mentioning --- 5 unchanged lines hidden (view full) --- 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 */ 21 22#ifndef lint 23static const char rcsid[] = | 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and 9 * this paragraph in its entirety in the documentation or other materials 10 * provided with the distribution, and (3) all advertising materials mentioning --- 5 unchanged lines hidden (view full) --- 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 */ 21 22#ifndef lint 23static const char rcsid[] = |
24 "@(#) $Header: print-ppp.c,v 1.24 96/12/10 23:23:12 leres Exp $ (LBL)"; | 24 "@(#) $Header: print-ppp.c,v 1.26 97/06/12 14:21:29 leres Exp $ (LBL)"; |
25#endif 26 | 25#endif 26 |
27#ifdef PPP | |
28#include <sys/param.h> 29#include <sys/time.h> 30#include <sys/socket.h> 31#include <sys/file.h> 32#include <sys/ioctl.h> 33 34#if __STDC__ 35struct mbuf; 36struct rtentry; 37#endif 38#include <net/if.h> 39 40#include <netinet/in.h> 41#include <netinet/in_systm.h> 42#include <netinet/ip.h> 43 44#include <ctype.h> 45#include <netdb.h> 46#include <pcap.h> | 27#include <sys/param.h> 28#include <sys/time.h> 29#include <sys/socket.h> 30#include <sys/file.h> 31#include <sys/ioctl.h> 32 33#if __STDC__ 34struct mbuf; 35struct rtentry; 36#endif 37#include <net/if.h> 38 39#include <netinet/in.h> 40#include <netinet/in_systm.h> 41#include <netinet/ip.h> 42 43#include <ctype.h> 44#include <netdb.h> 45#include <pcap.h> |
47#include <signal.h> | |
48#include <stdio.h> 49 50#include <net/ethernet.h> 51#include "ethertype.h" 52 53#include <net/ppp_defs.h> 54#include "interface.h" 55#include "addrtoname.h" | 46#include <stdio.h> 47 48#include <net/ethernet.h> 49#include "ethertype.h" 50 51#include <net/ppp_defs.h> 52#include "interface.h" 53#include "addrtoname.h" |
54#include "ppp.h" |
|
56 57struct protonames { 58 u_short protocol; 59 char *name; 60}; 61 62static struct protonames protonames[] = { 63 /* --- 127 unchanged lines hidden (view full) --- 191#define IPCP_ADDR 3 192 193static int handle_lcp(const u_char *p, int length); 194static int print_lcp_config_options(u_char *p); 195static int handle_chap(const u_char *p, int length); 196static int handle_ipcp(const u_char *p, int length); 197static int handle_pap(const u_char *p, int length); 198 | 55 56struct protonames { 57 u_short protocol; 58 char *name; 59}; 60 61static struct protonames protonames[] = { 62 /* --- 127 unchanged lines hidden (view full) --- 190#define IPCP_ADDR 3 191 192static int handle_lcp(const u_char *p, int length); 193static int print_lcp_config_options(u_char *p); 194static int handle_chap(const u_char *p, int length); 195static int handle_ipcp(const u_char *p, int length); 196static int handle_pap(const u_char *p, int length); 197 |
198/* Standard PPP printer */ |
|
199void 200ppp_hdlc_print(const u_char *p, int length) 201{ 202 int proto = PPP_PROTOCOL(p); 203 int i, j, x; 204 u_char *ptr; 205 206 printf("ID-%03d ", *(p+5)); --- 320 unchanged lines hidden (view full) --- 527 } 528 529 if (xflag) 530 default_print((const u_char *)(p + PPP_HDRLEN), 531 caplen - PPP_HDRLEN); 532out: 533 putchar('\n'); 534} | 199void 200ppp_hdlc_print(const u_char *p, int length) 201{ 202 int proto = PPP_PROTOCOL(p); 203 int i, j, x; 204 u_char *ptr; 205 206 printf("ID-%03d ", *(p+5)); --- 320 unchanged lines hidden (view full) --- 527 } 528 529 if (xflag) 530 default_print((const u_char *)(p + PPP_HDRLEN), 531 caplen - PPP_HDRLEN); 532out: 533 putchar('\n'); 534} |
535#else 536#include <sys/types.h> 537#include <sys/time.h> | |
538 | 535 |
539#include <stdio.h> | 536/* proto type to string mapping */ 537static struct tok ptype2str[] = { 538 { PPP_VJC, "VJC" }, 539 { PPP_VJNC, "VJNC" }, 540 { PPP_OSI, "OSI" }, 541 { PPP_LCP, "LCP" }, 542 { PPP_IPCP, "IPCP" }, 543 { 0, NULL } 544}; |
540 | 545 |
541#include "interface.h" | 546#define PPP_BSDI_HDRLEN 24 547 548/* BSD/OS specific PPP printer */ |
542void | 549void |
543ppp_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) | 550ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, 551 register const u_char *p) |
544{ | 552{ |
545 error("not configured for ppp"); 546 /* NOTREACHED */ | 553 register u_int length = h->len; 554 register u_int caplen = h->caplen; 555 register int hdrlength; 556 u_short ptype; 557 558 ts_print(&h->ts); 559 560 if (caplen < PPP_BSDI_HDRLEN) { 561 printf("[|ppp]"); 562 goto out; 563 } 564 565 /* 566 * Some printers want to get back at the link level addresses, 567 * and/or check that they're not walking off the end of the packet. 568 * Rather than pass them all the way down, we set these globals. 569 */ 570 packetp = p; 571 snapend = p + caplen; 572 hdrlength = 0; 573 574 if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) { 575 if (eflag) 576 printf("%02x %02x ", p[0], p[1]); 577 p += 2; 578 hdrlength = 2; 579 } 580 581 if (eflag) 582 printf("%d ", length); 583 /* Retrieve the protocol type */ 584 if (*p & 01) { 585 /* Compressed protocol field */ 586 ptype = *p; 587 if (eflag) 588 printf("%02x ", ptype); 589 p++; 590 hdrlength += 1; 591 } else { 592 /* Un-compressed protocol field */ 593 ptype = ntohs(*(u_short *)p); 594 if (eflag) 595 printf("%04x ", ptype); 596 p += 2; 597 hdrlength += 2; 598 } 599 600 length -= hdrlength; 601 602 if (ptype == PPP_IP) 603 ip_print(p, length); 604 else 605 printf("%s ", tok2str(ptype2str, "proto-#%d", ptype)); 606 607 if (xflag) 608 default_print((const u_char *)p, caplen - hdrlength); 609out: 610 putchar('\n'); |
547} | 611} |
548#endif | |