Deleted Added
sdiff udiff text old ( 181803 ) new ( 183550 )
full compact
1/* $OpenBSD: pf.c,v 1.527 2007/02/22 15:23:23 pyr Exp $ */
2/* add: $OpenBSD: pf.c,v 1.559 2007/09/18 18:45:59 markus Exp $ */
3
4/*
5 * Copyright (c) 2001 Daniel Hartmeier
6 * Copyright (c) 2002,2003 Henning Brauer
7 * All rights reserved.
8 *

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

36 *
37 */
38
39#ifdef __FreeBSD__
40#include "opt_inet.h"
41#include "opt_inet6.h"
42
43#include <sys/cdefs.h>
44__FBSDID("$FreeBSD: head/sys/contrib/pf/net/pf.c 183550 2008-10-02 15:37:58Z zec $");
45#endif
46
47#ifdef __FreeBSD__
48#include "opt_mac.h"
49#include "opt_bpf.h"
50#include "opt_pf.h"
51
52#ifdef DEV_BPF

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

1754#else
1755pf_send_tcp(const struct pf_rule *r, sa_family_t af,
1756#endif
1757 const struct pf_addr *saddr, const struct pf_addr *daddr,
1758 u_int16_t sport, u_int16_t dport, u_int32_t seq, u_int32_t ack,
1759 u_int8_t flags, u_int16_t win, u_int16_t mss, u_int8_t ttl, int tag,
1760 u_int16_t rtag, struct ether_header *eh, struct ifnet *ifp)
1761{
1762 INIT_VNET_INET(curvnet);
1763 struct mbuf *m;
1764 int len, tlen;
1765#ifdef INET
1766 struct ip *h;
1767#endif /* INET */
1768#ifdef INET6
1769 struct ip6_hdr *h6;
1770#endif /* INET6 */

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

2918
2919int
2920#ifdef __FreeBSD__
2921pf_socket_lookup(int direction, struct pf_pdesc *pd, struct inpcb *inp_arg)
2922#else
2923pf_socket_lookup(int direction, struct pf_pdesc *pd)
2924#endif
2925{
2926 INIT_VNET_INET(curvnet);
2927 struct pf_addr *saddr, *daddr;
2928 u_int16_t sport, dport;
2929#ifdef __FreeBSD__
2930 struct inpcbinfo *pi;
2931#else
2932 struct inpcbtable *tb;
2933#endif
2934 struct inpcb *inp;

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

3098 }
3099 }
3100 return (wscale);
3101}
3102
3103u_int16_t
3104pf_get_mss(struct mbuf *m, int off, u_int16_t th_off, sa_family_t af)
3105{
3106 INIT_VNET_INET(curvnet);
3107 int hlen;
3108 u_int8_t hdr[60];
3109 u_int8_t *opt, optlen;
3110 u_int16_t mss = V_tcp_mssdflt;
3111
3112 hlen = th_off << 2; /* hlen <= sizeof(hdr) */
3113 if (hlen <= sizeof(struct tcphdr))
3114 return (0);

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

3138 }
3139 return (mss);
3140}
3141
3142u_int16_t
3143pf_calc_mss(struct pf_addr *addr, sa_family_t af, u_int16_t offer)
3144{
3145#ifdef INET
3146 INIT_VNET_INET(curvnet);
3147 struct sockaddr_in *dst;
3148 struct route ro;
3149#endif /* INET */
3150#ifdef INET6
3151 struct sockaddr_in6 *dst6;
3152 struct route_in6 ro6;
3153#endif /* INET6 */
3154 struct rtentry *rt = NULL;

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

3241#ifdef __FreeBSD__
3242 struct pf_pdesc *pd, struct pf_rule **am, struct pf_ruleset **rsm,
3243 struct ifqueue *ifq, struct inpcb *inp)
3244#else
3245 struct pf_pdesc *pd, struct pf_rule **am, struct pf_ruleset **rsm,
3246 struct ifqueue *ifq)
3247#endif
3248{
3249 INIT_VNET_INET(curvnet);
3250 struct pf_rule *nr = NULL;
3251 struct pf_addr *saddr = pd->src, *daddr = pd->dst;
3252 struct tcphdr *th = pd->hdr.tcp;
3253 u_int16_t bport, nport = 0;
3254 sa_family_t af = pd->af;
3255 struct pf_rule *r, *a = NULL;
3256 struct pf_ruleset *ruleset = NULL;
3257 struct pf_src_node *nsn = NULL;

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

6096}
6097
6098#ifdef INET
6099
6100void
6101pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
6102 struct pf_state *s, struct pf_pdesc *pd)
6103{
6104 INIT_VNET_INET(curvnet);
6105 struct mbuf *m0, *m1;
6106 struct route iproute;
6107 struct route *ro = NULL;
6108 struct sockaddr_in *dst;
6109 struct ip *ip;
6110 struct ifnet *ifp = NULL;
6111 struct pf_addr naddr;
6112 struct pf_src_node *sn = NULL;

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

6634#endif /* INET6 */
6635 default:
6636 return (1);
6637 }
6638 }
6639 if (sum) {
6640 switch (p) {
6641 case IPPROTO_TCP:
6642 {
6643 INIT_VNET_INET(curvnet);
6644 V_tcpstat.tcps_rcvbadsum++;
6645 break;
6646 }
6647 case IPPROTO_UDP:
6648 {
6649 INIT_VNET_INET(curvnet);
6650 V_udpstat.udps_badsum++;
6651 break;
6652 }
6653 case IPPROTO_ICMP:
6654 {
6655 INIT_VNET_INET(curvnet);
6656 V_icmpstat.icps_checksum++;
6657 break;
6658 }
6659#ifdef INET6
6660 case IPPROTO_ICMPV6:
6661 {
6662 INIT_VNET_INET6(curvnet);
6663 V_icmp6stat.icp6s_checksum++;
6664 break;
6665 }
6666#endif /* INET6 */
6667 }
6668 return (1);
6669 } else {
6670 if (p == IPPROTO_TCP || p == IPPROTO_UDP) {
6671 m->m_pkthdr.csum_flags |=
6672 (CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
6673 m->m_pkthdr.csum_data = 0xffff;

--- 958 unchanged lines hidden ---