Date: Tue, 4 Oct 2005 23:54:02 +0200 From: Remigiusz Hajduk <rhajduk@gmail.com> To: freebsd-ipfw@freebsd.org Subject: [PATCH] log + MAC Message-ID: <c50c40ec0510041454r54ce1d8ey@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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 Ex= p $ --- 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 =3D=3D 0) { /* non-ip */ - snprintf(SNPARGS(proto, 0), "MAC"); + int len, i; + u_char *ptr; + + len =3D snprintf(SNPARGS(proto, 0), "MAC "); + + i =3D ETHER_ADDR_LEN; + ptr =3D eh->ether_dhost; + + do { + len +=3D snprintf(SNPARGS(proto, len), "%s%02x", (i=3D=3DETHER_ADDR_LEN) ? "" : ":", *ptr++); + } while(--i > 0); + + i =3D ETHER_ADDR_LEN; + ptr =3D eh->ether_shost; + len +=3D snprintf(SNPARGS(proto, len), " "); + do { + len +=3D snprintf(SNPARGS(proto, len), "%s%02x", (i=3D=3DETHER_ADDR_LEN) ? "" : ":", *ptr++); + } while(--i > 0); + } else { struct ip *ip =3D mtod(m, struct ip *); /* these three are all aliases to the same thing */ -- Remigiusz Hajduk
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c50c40ec0510041454r54ce1d8ey>