Deleted Added
full compact
1/* $OpenBSD: pf_ruleset.c,v 1.1 2006/10/27 13:56:51 mcbride Exp $ */
2
3/*
4 * Copyright (c) 2001 Daniel Hartmeier
5 * Copyright (c) 2002,2003 Henning Brauer
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Effort sponsored in part by the Defense Advanced Research Projects
33 * Agency (DARPA) and Air Force Research Laboratory, Air Force
34 * Materiel Command, USAF, under agreement number F30602-01-2-0537.
35 *
36 */
37
38#ifdef __FreeBSD__
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/sys/contrib/pf/net/pf_ruleset.c 171168 2007-07-03 12:16:07Z mlaier $");
41#endif
42
43#include <sys/param.h>
44#include <sys/socket.h>
45#ifdef _KERNEL
46# include <sys/systm.h>
47#endif /* _KERNEL */
48#include <sys/mbuf.h>
49
50#include <netinet/in.h>

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

59#include <netinet/ip6.h>
60#endif /* INET6 */
61
62
63#ifdef _KERNEL
64# define DPFPRINTF(format, x...) \
65 if (pf_status.debug >= PF_DEBUG_NOISY) \
66 printf(format , ##x)
67#ifdef __FreeBSD__
68#define rs_malloc(x) malloc(x, M_TEMP, M_NOWAIT)
69#else
70#define rs_malloc(x) malloc(x, M_TEMP, M_WAITOK)
71#endif
72#define rs_free(x) free(x, M_TEMP)
73
74#else
75/* Userland equivalents so we can lend code to pfctl et al. */
76
77# include <arpa/inet.h>
78# include <errno.h>
79# include <stdio.h>

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

89# define DPFPRINTF(format, x...) ((void)0)
90# endif /* PFDEBUG */
91#endif /* _KERNEL */
92
93
94struct pf_anchor_global pf_anchors;
95struct pf_anchor pf_main_anchor;
96
97#ifndef __FreeBSD__
98/* XXX: hum? */
99int pf_get_ruleset_number(u_int8_t);
100void pf_init_ruleset(struct pf_ruleset *);
101int pf_anchor_setup(struct pf_rule *,
102 const struct pf_ruleset *, const char *);
103int pf_anchor_copyout(const struct pf_ruleset *,
104 const struct pf_rule *, struct pfioc_rule *);
105void pf_anchor_remove(struct pf_rule *);
106#endif
107
108static __inline int pf_anchor_compare(struct pf_anchor *, struct pf_anchor *);
109
110RB_GENERATE(pf_anchor_global, pf_anchor, entry_global, pf_anchor_compare);
111RB_GENERATE(pf_anchor_node, pf_anchor, entry_node, pf_anchor_compare);
112
113static __inline int
114pf_anchor_compare(struct pf_anchor *a, struct pf_anchor *b)

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

191 return (&anchor->ruleset);
192}
193
194struct pf_ruleset *
195pf_find_or_create_ruleset(const char *path)
196{
197 char *p, *q, *r;
198 struct pf_ruleset *ruleset;
199#ifdef __FreeBSD__
200 struct pf_anchor *anchor = NULL, *dup, *parent = NULL;
201#else
202 struct pf_anchor *anchor, *dup, *parent = NULL;
203#endif
204
205 if (path[0] == 0)
206 return (&pf_main_ruleset);
207 while (*path == '/')
208 path++;
209 ruleset = pf_find_ruleset(path);
210 if (ruleset != NULL)
211 return (ruleset);

--- 220 unchanged lines hidden ---