]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sunatm.c
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / print-sunatm.c
index f3aafe94135f8a9f6caa7053b9df3d28be1ab61a..0fe5eee8e411b5f281cf1fc6baef6ae5176a1b03 100644 (file)
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.3 2002-08-05 07:47:23 guy Exp $ (LBL)";
-#endif
+
+/* \summary: SunATM DLPI capture printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <tcpdump-stdinc.h>
-struct mbuf;
-struct rtentry;
-#include <stdio.h>
-#include <pcap.h>
+#include "netdissect-stdinc.h"
 
-#include "interface.h"
+#define ND_LONGJMP_FROM_TCHECK
+#include "netdissect.h"
 #include "extract.h"
-#include "addrtoname.h"
 
 #include "atm.h"
-#include "atmuni31.h"
 
 /* SunATM header for ATM packet */
 #define DIR_POS                0       /* Direction (0x80 = transmit, 0x00 = receive) */
@@ -64,13 +55,14 @@ struct rtentry;
 #define PT_LLC         0x02    /* LLC encapsulation */
 
 /*
- * This is the top level routine of the printer.  'p' is the points
- * to the SunATM pseudo-header for the packet, 'h->tv' is the timestamp,
- * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * This is the top level routine of the printer.  'p' points
+ * to the SunATM pseudo-header for the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
 void
-sunatm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+sunatm_if_print(netdissect_options *ndo,
+                const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int caplen = h->caplen;
        u_int length = h->len;
@@ -78,21 +70,13 @@ sunatm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        u_char vpi;
        u_int traftype;
 
-       ts_print(&h->ts);
+       ndo->ndo_protocol = "sunatm";
 
-       if (caplen < PKT_BEGIN_POS) {
-               printf("[|atm]");
-               goto out;
+       if (ndo->ndo_eflag) {
+               ND_PRINT(GET_U_1(p + DIR_POS) & 0x80 ? "Tx: " : "Rx: ");
        }
 
-       if (eflag) {
-               if (p[DIR_POS] & 0x80)
-                       printf("Tx: ");
-               else
-                       printf("Rx: ");
-       }
-
-       switch (p[DIR_POS] & 0x0f) {
+       switch (GET_U_1(p + DIR_POS) & 0x0f) {
 
        case PT_LANE:
                traftype = ATM_LANE;
@@ -107,17 +91,12 @@ sunatm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                break;
        }
 
-       vci = EXTRACT_16BITS(&p[VCI_POS]);
-       vpi = p[VPI_POS];
+       vpi = GET_U_1(p + VPI_POS);
+       vci = GET_BE_U_2(p + VCI_POS);
 
        p += PKT_BEGIN_POS;
        caplen -= PKT_BEGIN_POS;
        length -= PKT_BEGIN_POS;
-       atm_print(vpi, vci, traftype, p, length, caplen);
-
- out:
-       putchar('\n');
-       --infodelay;
-       if (infoprint)
-               info(0);
+       ndo->ndo_ll_hdr_len += PKT_BEGIN_POS;
+       atm_print(ndo, vpi, vci, traftype, p, length, caplen);
 }