Deleted Added
full compact
ip_input.c (89809) ip_input.c (90868)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/netinet/ip_input.c 89809 2002-01-26 10:14:08Z cjc $
34 * $FreeBSD: head/sys/netinet/ip_input.c 90868 2002-02-18 20:35:27Z mike $
35 */
36
37#define _IP_VHL
38
39#include "opt_bootp.h"
40#include "opt_ipfw.h"
41#include "opt_ipdn.h"
42#include "opt_ipdivert.h"

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

364 if (sum) {
365 ipstat.ips_badsum++;
366 goto bad;
367 }
368
369 /*
370 * Convert fields to host representation.
371 */
35 */
36
37#define _IP_VHL
38
39#include "opt_bootp.h"
40#include "opt_ipfw.h"
41#include "opt_ipdn.h"
42#include "opt_ipdivert.h"

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

364 if (sum) {
365 ipstat.ips_badsum++;
366 goto bad;
367 }
368
369 /*
370 * Convert fields to host representation.
371 */
372 NTOHS(ip->ip_len);
372 ip->ip_len = ntohs(ip->ip_len);
373 if (ip->ip_len < hlen) {
374 ipstat.ips_badlen++;
375 goto bad;
376 }
373 if (ip->ip_len < hlen) {
374 ipstat.ips_badlen++;
375 goto bad;
376 }
377 NTOHS(ip->ip_off);
377 ip->ip_off = ntohs(ip->ip_off);
378
379 /*
380 * Check that the amount of data in the buffers
381 * is as at least much as the IP header would have us expect.
382 * Trim mbufs if longer than we expect.
383 * Drop packet if shorter than we expect.
384 */
385 if (m->m_pkthdr.len < ip->ip_len) {

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

757 ipstat.ips_reassembled++;
758 ip = mtod(m, struct ip *);
759 /* Get the header length of the reassembled packet */
760 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
761#ifdef IPDIVERT
762 /* Restore original checksum before diverting packet */
763 if (divert_info != 0) {
764 ip->ip_len += hlen;
378
379 /*
380 * Check that the amount of data in the buffers
381 * is as at least much as the IP header would have us expect.
382 * Trim mbufs if longer than we expect.
383 * Drop packet if shorter than we expect.
384 */
385 if (m->m_pkthdr.len < ip->ip_len) {

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

757 ipstat.ips_reassembled++;
758 ip = mtod(m, struct ip *);
759 /* Get the header length of the reassembled packet */
760 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
761#ifdef IPDIVERT
762 /* Restore original checksum before diverting packet */
763 if (divert_info != 0) {
764 ip->ip_len += hlen;
765 HTONS(ip->ip_len);
766 HTONS(ip->ip_off);
765 ip->ip_len = htons(ip->ip_len);
766 ip->ip_off = htons(ip->ip_off);
767 ip->ip_sum = 0;
768 if (hlen == sizeof(struct ip))
769 ip->ip_sum = in_cksum_hdr(ip);
770 else
771 ip->ip_sum = in_cksum(m, hlen);
767 ip->ip_sum = 0;
768 if (hlen == sizeof(struct ip))
769 ip->ip_sum = in_cksum_hdr(ip);
770 else
771 ip->ip_sum = in_cksum(m, hlen);
772 NTOHS(ip->ip_off);
773 NTOHS(ip->ip_len);
772 ip->ip_off = ntohs(ip->ip_off);
773 ip->ip_len = ntohs(ip->ip_len);
774 ip->ip_len -= hlen;
775 }
776#endif
777 } else
778 ip->ip_len -= hlen;
779
780#ifdef IPDIVERT
781 /*

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

788 struct mbuf *clone = NULL;
789
790 /* Clone packet if we're doing a 'tee' */
791 if ((divert_info & IP_FW_PORT_TEE_FLAG) != 0)
792 clone = m_dup(m, M_DONTWAIT);
793
794 /* Restore packet header fields to original values */
795 ip->ip_len += hlen;
774 ip->ip_len -= hlen;
775 }
776#endif
777 } else
778 ip->ip_len -= hlen;
779
780#ifdef IPDIVERT
781 /*

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

788 struct mbuf *clone = NULL;
789
790 /* Clone packet if we're doing a 'tee' */
791 if ((divert_info & IP_FW_PORT_TEE_FLAG) != 0)
792 clone = m_dup(m, M_DONTWAIT);
793
794 /* Restore packet header fields to original values */
795 ip->ip_len += hlen;
796 HTONS(ip->ip_len);
797 HTONS(ip->ip_off);
796 ip->ip_len = htons(ip->ip_len);
797 ip->ip_off = htons(ip->ip_off);
798
799 /* Deliver packet to divert input routine */
800 ip_divert_cookie = divert_cookie;
801 divert_packet(m, 1, divert_info & 0xffff);
802 ipstat.ips_delivered++;
803
804 /* If 'tee', continue with original packet */
805 if (clone == NULL)

--- 1140 unchanged lines hidden ---
798
799 /* Deliver packet to divert input routine */
800 ip_divert_cookie = divert_cookie;
801 divert_packet(m, 1, divert_info & 0xffff);
802 ipstat.ips_delivered++;
803
804 /* If 'tee', continue with original packet */
805 if (clone == NULL)

--- 1140 unchanged lines hidden ---