*** empty log message ***
authorMatthew Mondor <mmondor@pulsar-zone.net>
Thu, 20 Dec 2007 19:27:27 +0000 (19:27 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Thu, 20 Dec 2007 19:27:27 +0000 (19:27 +0000)
mmsoftware/tap-bridge/modules/tap-logger.c

index 51a8c2e..a360e2b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: tap-logger.c,v 1.2 2007/12/20 01:32:19 mmondor Exp $ */
+/* $Id: tap-logger.c,v 1.3 2007/12/20 19:27:27 mmondor Exp $ */
 
 /*
  * Copyright (C) 2007, Matthew Mondor
@@ -146,10 +146,7 @@ frame_log(frame_t *f, const char *d)
 {
        char            origin[32], destination[32];
        struct hdr_tap  *hdrtap = (struct hdr_tap *)f->data;
-       struct hdr_arp  *hdrarp;
-       struct hdr_ip   *hdrip;
        void            *ahdrtap = &hdrtap[1];
-       void            *ahdrip;
 
        if (f->size < sizeof(struct hdr_tap)) {
                logprintf("%s Short ethernet frame: Size: %u\n", d, f->size);
@@ -161,37 +158,37 @@ frame_log(frame_t *f, const char *d)
        logprintf("%s Src: %s, Dst: %s - EType: %04x, Size: %u\n",
            d, origin, destination, f->type, f->size);
 
-       switch (f->type) {
-       case HDR_TAP_ETYPE_ARP:
-               if (f->size < sizeof(struct hdr_tap) + sizeof(struct hdr_arp)) {
-                       logprintf(" Short ARP packet\n");
+       /*
+        * Orignally used switch/case but if proves to be cleaner because of
+        * required variables, while requireing less indentation levels.
+        */
+       if (f->type == HDR_TAP_ETYPE_ARP) {
+               struct hdr_arp *hdrarp;
+
+               if (f->size < sizeof(struct hdr_tap) +
+                   sizeof(struct hdr_arp)) {
+                       logprintf(" Short ARP header\n");
                        return;
                }
                hdrarp = ahdrtap;
-               break;
-       case HDR_TAP_ETYPE_IP:
+               /* XXX */
+
+               return;
+       }
+
+       if (f->type == HDR_TAP_ETYPE_IP) {
+               struct hdr_ip   *hdrip;
+               /*void          *ahdrip;*/
+
                if (f->size < sizeof(struct hdr_tap) + sizeof(struct hdr_ip)) {
-                       logprintf(" Short IP packet\n");
+                       logprintf(" Short IP header\n");
                        return;
                }
                hdrip = ahdrtap;
-               /* XXX We must find pointer to location after options */
-               ahdrip = &hdrip[1];
-               switch (hdrip->protocol) {
-               case HDR_IP_PROTO_UDP:
-                       break;
-               case HDR_IP_PROTO_TCP:
-                       break;
-               case HDR_IP_PROTO_ICMP:
-                       break;
-               default:
-                       logprintf(" Unsupported IP protocol (0x%04x)\n",
-                           hdrip->protocol);
-                       break;
-               }
-               break;
-       default:
-               logprintf(" Unsupported ethertype (0x%04x)\n", f->type);
-               break;
+               /* XXX */
+
+               return;
        }
+
+       logprintf(" Unsupported ethertype (0x%04x)\n", f->type);
 }