[PATCH] log + MAC

Remigiusz Hajduk rhajduk at gmail.com
Tue Oct 4 14:54:04 PDT 2005


I added MAC address logging facility.
I think that it is useful and should be committed to CURRENT.

$FreeBSD: src/sys/netinet/ip_fw2.c,v 1.70.2.14 2005/06/29 21:38:48 simon Exp $
--- sys/netinet/ip_fw2.c.orig   Tue Oct  4 22:54:31 2005
+++ sys/netinet/ip_fw2.c        Tue Oct  4 23:04:31 2005
@@ -665,7 +665,25 @@ ipfw_log(struct ip_fw *f, u_int hlen, st
        }

        if (hlen == 0) {        /* non-ip */
-               snprintf(SNPARGS(proto, 0), "MAC");
+               int len, i;
+               u_char *ptr;
+
+               len = snprintf(SNPARGS(proto, 0), "MAC ");
+
+               i = ETHER_ADDR_LEN;
+               ptr = eh->ether_dhost;
+
+               do {
+                       len += snprintf(SNPARGS(proto, len), "%s%02x",
(i==ETHER_ADDR_LEN) ? "" : ":", *ptr++);
+               } while(--i > 0);
+
+               i = ETHER_ADDR_LEN;
+               ptr = eh->ether_shost;
+               len += snprintf(SNPARGS(proto, len), " ");
+               do {
+                       len += snprintf(SNPARGS(proto, len), "%s%02x",
(i==ETHER_ADDR_LEN) ? "" : ":", *ptr++);
+               } while(--i > 0);
+
        } else {
                struct ip *ip = mtod(m, struct ip *);
                /* these three are all aliases to the same thing */


--
Remigiusz Hajduk


More information about the freebsd-ipfw mailing list