]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sunatm.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-sunatm.c
index 3df26fb2c26343f6e853f05ed7d61c3658d1e339..fad2859f3cf72a82342b4389d0f67226f62d68f0 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.4 2002-09-05 21:25:49 guy Exp $ (LBL)";
-#endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
+
 struct mbuf;
 struct rtentry;
-#include <stdio.h>
-#include <pcap.h>
 
-#include "interface.h"
+#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) */
@@ -66,11 +57,12 @@ struct rtentry;
 /*
  * 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->length' is the length of the packet off the wire, and 'h->caplen'
+ * '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 _U_, const struct pcap_pkthdr *h, const u_char *p)
+u_int
+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,18 +70,13 @@ sunatm_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
        u_char vpi;
        u_int traftype;
 
-       ts_print(&h->ts);
-
        if (caplen < PKT_BEGIN_POS) {
-               printf("[|atm]");
-               goto out;
+               ND_PRINT((ndo, "[|atm]"));
+               return (caplen);
        }
 
-       if (eflag) {
-               if (p[DIR_POS] & 0x80)
-                       printf("Tx: ");
-               else
-                       printf("Rx: ");
+       if (ndo->ndo_eflag) {
+               ND_PRINT((ndo, p[DIR_POS] & 0x80 ? "Tx: " : "Rx: "));
        }
 
        switch (p[DIR_POS] & 0x0f) {
@@ -113,11 +100,7 @@ sunatm_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
        p += PKT_BEGIN_POS;
        caplen -= PKT_BEGIN_POS;
        length -= PKT_BEGIN_POS;
-       atm_print(vpi, vci, traftype, p, length, caplen);
+       atm_print(ndo, vpi, vci, traftype, p, length, caplen);
 
- out:
-       putchar('\n');
-       --infodelay;
-       if (infoprint)
-               info(0);
+       return (PKT_BEGIN_POS);
 }