*** empty log message ***
authorMatthew Mondor <mmondor@pulsar-zone.net>
Wed, 26 Dec 2007 16:23:21 +0000 (16:23 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Wed, 26 Dec 2007 16:23:21 +0000 (16:23 +0000)
mmsoftware/tap-bridge/modules/tap-logger.c

index 1a224d3..0c9deb1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: tap-logger.c,v 1.8 2007/12/24 19:08:17 mmondor Exp $ */
+/* $Id: tap-logger.c,v 1.9 2007/12/26 16:23:21 mmondor Exp $ */
 
 /*
  * Copyright (C) 2007, Matthew Mondor
@@ -226,11 +226,12 @@ frame_log(frame_t *f, int d)
                if (hlen > 5) {
                        uint32_t        *optword;
 
-                       /* IP options */
+                       /* XXX IP options */
                        logprintf("      IP OPTIONS:\n");
                        for (optword = &((uint32_t *)hdrip)[5];
                            optword < (uint32_t *)ahdrip; optword++)
-                               logprintf("       0x%08x\n", *optword);
+                               logprintf("       0x%08x\n",
+                                   BYTEORDER_HOST32(*optword));
                }
 
                if (hdrip->protocol == HDR_IP_PROTO_ICMP) {
@@ -249,11 +250,64 @@ frame_log(frame_t *f, int d)
                            BYTEORDER_HOST16(hdricmp->hsum),
                            BYTEORDER_HOST16(hdricmp->id),
                            BYTEORDER_HOST16(hdricmp->seq));
+
+                       /* XXX ICMP padding payload */
                        return;
                }
 
                if (hdrip->protocol == HDR_IP_PROTO_TCP) {
-                       /* XXX */
+                       struct hdr_tcp          *hdrtcp;
+                       int                     doff, res, i;
+                       static const char       flagbits[] = "CEUAPRSF";
+                       char                    flags[9], *cptr;
+                       void                    *ahdrtcp;
+
+                       if (f->size < (ahdrip - (void *)f->data) +
+                           sizeof(struct hdr_tcp)) {
+                               logprintf("  Short TCP header\n");
+                               return;
+                       }
+                       hdrtcp = ahdrip;
+
+                       doff = HDR_TCP_DOFF_GET(hdrtcp->doff_res);
+                       res = HDR_TCP_RES_GET(hdrtcp->doff_res);
+                       if (doff < 5) {
+                               logprintf("  Short TCP header length (%d)\n",
+                                   doff);
+                               return;
+                       }
+                       ahdrtcp = &((uint32_t *)hdrtcp)[doff];
+
+                       for (i = 0, cptr = flags; i < 8; i++)
+                               *cptr++ = ((hdrtcp->flags & (1 << i)) != 0) ?
+                                   flagbits[i] : '-';
+                       *cptr = '\0';
+
+                       logprintf("  TCP: srcport=%u dstport=%u seq=0x%08x "
+                           "ack=0x%08x doff=%d res=0x%01x\n"
+                           "       flags=%s window=%u hsum=0x%04x "
+                           "urgptr=0x%04x\n",
+                           BYTEORDER_HOST16(hdrtcp->srcport),
+                           BYTEORDER_HOST16(hdrtcp->dstport),
+                           BYTEORDER_HOST32(hdrtcp->seq),
+                           BYTEORDER_HOST32(hdrtcp->ack),
+                           doff, res, flags,
+                           BYTEORDER_HOST16(hdrtcp->window),
+                           BYTEORDER_HOST16(hdrtcp->hsum),
+                           BYTEORDER_HOST16(hdrtcp->urgptr));
+
+                       if (doff > 5) {
+                               uint32_t        *optword;
+
+                               /* XXX TCP options */
+                               logprintf("       TCP OPTIONS:\n");
+                               for (optword = &((uint32_t *)hdrtcp)[5];
+                                   optword < (uint32_t *)ahdrtcp; optword++)
+                                       logprintf("        0x%08x\n",
+                                           BYTEORDER_HOST32(*optword));
+                       }
+
+                       /* XXX TCP payload */
                        return;
                }
 
@@ -273,6 +327,8 @@ frame_log(frame_t *f, int d)
                            BYTEORDER_HOST16(hdrudp->dstport),
                            BYTEORDER_HOST16(hdrudp->len),
                            BYTEORDER_HOST16(hdrudp->hsum));
+
+                       /* XXX UDP payload */
                        return;
                }