Deleted Added
full compact
ip_fw_log.c (201122) ip_fw_log.c (201527)
1/*-
2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_fw_log.c 201122 2009-12-28 10:47:04Z luigi $");
27__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_fw_log.c 201527 2010-01-04 19:01:22Z luigi $");
28
29/*
30 * Logging support for ipfw
31 */
32
33#if !defined(KLD_MODULE)
34#include "opt_ipfw.h"
35#include "opt_ipdivert.h"

--- 124 unchanged lines hidden (view full) ---

160 mh.mh_len = ETHER_HDR_LEN;
161 if (args->eh) { /* layer2, use orig hdr */
162 mh.mh_data = (char *)args->eh;
163 } else {
164 /* add fake header. Later we will store
165 * more info in the header
166 */
167 mh.mh_data = "DDDDDDSSSSSS\x08\x00";
28
29/*
30 * Logging support for ipfw
31 */
32
33#if !defined(KLD_MODULE)
34#include "opt_ipfw.h"
35#include "opt_ipdivert.h"

--- 124 unchanged lines hidden (view full) ---

160 mh.mh_len = ETHER_HDR_LEN;
161 if (args->eh) { /* layer2, use orig hdr */
162 mh.mh_data = (char *)args->eh;
163 } else {
164 /* add fake header. Later we will store
165 * more info in the header
166 */
167 mh.mh_data = "DDDDDDSSSSSS\x08\x00";
168 if (args->f_id.addr_type == 4) {
169 /* restore wire format */
170 SET_NET_IPLEN(ip);
171 }
172 }
173 BPF_MTAP(log_if, (struct mbuf *)&mh);
168 }
169 BPF_MTAP(log_if, (struct mbuf *)&mh);
174 if (args->eh == NULL && args->f_id.addr_type == 4) {
175 /* restore host format */
176 SET_HOST_IPLEN(ip);
177 }
178#endif /* !WITHOUT_BPF */
179 return;
180 }
181 /* the old 'log' function */
182 fragment[0] = '\0';
183 proto[0] = '\0';
184
185 if (f == NULL) { /* bogus pkt */

--- 218 unchanged lines hidden (view full) ---

404 " (frag %08x:%d@%d%s)",
405 args->f_id.frag_id6,
406 ntohs(ip6->ip6_plen) - hlen,
407 ntohs(offset & IP6F_OFF_MASK) << 3,
408 (offset & IP6F_MORE_FRAG) ? "+" : "");
409 } else
410#endif
411 {
170#endif /* !WITHOUT_BPF */
171 return;
172 }
173 /* the old 'log' function */
174 fragment[0] = '\0';
175 proto[0] = '\0';
176
177 if (f == NULL) { /* bogus pkt */

--- 218 unchanged lines hidden (view full) ---

396 " (frag %08x:%d@%d%s)",
397 args->f_id.frag_id6,
398 ntohs(ip6->ip6_plen) - hlen,
399 ntohs(offset & IP6F_OFF_MASK) << 3,
400 (offset & IP6F_MORE_FRAG) ? "+" : "");
401 } else
402#endif
403 {
412 int ip_off, ip_len;
413#ifndef HAVE_NET_IPLEN
414 if (args->eh == NULL) {
415 ip_off = ip->ip_off;
416 ip_len = ip->ip_len;
417 } else
418#endif /* !HAVE_NET_IPLEN */
419 {
420 ip_off = ntohs(ip->ip_off);
421 ip_len = ntohs(ip->ip_len);
422 }
423 if (ip_off & (IP_MF | IP_OFFMASK))
404 int ipoff, iplen;
405 ipoff = ntohs(ip->ip_off);
406 iplen = ntohs(ip->ip_len);
407 if (ipoff & (IP_MF | IP_OFFMASK))
424 snprintf(SNPARGS(fragment, 0),
425 " (frag %d:%d@%d%s)",
408 snprintf(SNPARGS(fragment, 0),
409 " (frag %d:%d@%d%s)",
426 ntohs(ip->ip_id), ip_len - (ip->ip_hl << 2),
410 ntohs(ip->ip_id), iplen - (ip->ip_hl << 2),
427 offset << 3,
411 offset << 3,
428 (ip_off & IP_MF) ? "+" : "");
412 (ipoff & IP_MF) ? "+" : "");
429 }
430 }
431 if (oif || m->m_pkthdr.rcvif)
432 log(LOG_SECURITY | LOG_INFO,
433 "ipfw: %d %s %s %s via %s%s\n",
434 f ? f->rulenum : -1,
435 action, proto, oif ? "out" : "in",
436 oif ? oif->if_xname : m->m_pkthdr.rcvif->if_xname,

--- 12 unchanged lines hidden ---
413 }
414 }
415 if (oif || m->m_pkthdr.rcvif)
416 log(LOG_SECURITY | LOG_INFO,
417 "ipfw: %d %s %s %s via %s%s\n",
418 f ? f->rulenum : -1,
419 action, proto, oif ? "out" : "in",
420 oif ? oif->if_xname : m->m_pkthdr.rcvif->if_xname,

--- 12 unchanged lines hidden ---