pf_ruleset.c (171165) | pf_ruleset.c (171168) |
---|---|
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 | 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 |
|
38#include <sys/param.h> 39#include <sys/socket.h> 40#ifdef _KERNEL 41# include <sys/systm.h> 42#endif /* _KERNEL */ 43#include <sys/mbuf.h> 44 45#include <netinet/in.h> --- 8 unchanged lines hidden (view full) --- 54#include <netinet/ip6.h> 55#endif /* INET6 */ 56 57 58#ifdef _KERNEL 59# define DPFPRINTF(format, x...) \ 60 if (pf_status.debug >= PF_DEBUG_NOISY) \ 61 printf(format , ##x) | 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 |
|
62#define rs_malloc(x) malloc(x, M_TEMP, M_WAITOK) | 70#define rs_malloc(x) malloc(x, M_TEMP, M_WAITOK) |
71#endif |
|
63#define rs_free(x) free(x, M_TEMP) 64 65#else 66/* Userland equivalents so we can lend code to pfctl et al. */ 67 68# include <arpa/inet.h> 69# include <errno.h> 70# include <stdio.h> --- 9 unchanged lines hidden (view full) --- 80# define DPFPRINTF(format, x...) ((void)0) 81# endif /* PFDEBUG */ 82#endif /* _KERNEL */ 83 84 85struct pf_anchor_global pf_anchors; 86struct pf_anchor pf_main_anchor; 87 | 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? */ |
|
88int pf_get_ruleset_number(u_int8_t); 89void pf_init_ruleset(struct pf_ruleset *); 90int pf_anchor_setup(struct pf_rule *, 91 const struct pf_ruleset *, const char *); 92int pf_anchor_copyout(const struct pf_ruleset *, 93 const struct pf_rule *, struct pfioc_rule *); 94void pf_anchor_remove(struct pf_rule *); | 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 |
|
95 96static __inline int pf_anchor_compare(struct pf_anchor *, struct pf_anchor *); 97 98RB_GENERATE(pf_anchor_global, pf_anchor, entry_global, pf_anchor_compare); 99RB_GENERATE(pf_anchor_node, pf_anchor, entry_node, pf_anchor_compare); 100 101static __inline int 102pf_anchor_compare(struct pf_anchor *a, struct pf_anchor *b) --- 76 unchanged lines hidden (view full) --- 179 return (&anchor->ruleset); 180} 181 182struct pf_ruleset * 183pf_find_or_create_ruleset(const char *path) 184{ 185 char *p, *q, *r; 186 struct pf_ruleset *ruleset; | 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 |
|
187 struct pf_anchor *anchor, *dup, *parent = NULL; | 202 struct pf_anchor *anchor, *dup, *parent = NULL; |
203#endif |
|
188 189 if (path[0] == 0) 190 return (&pf_main_ruleset); 191 while (*path == '/') 192 path++; 193 ruleset = pf_find_ruleset(path); 194 if (ruleset != NULL) 195 return (ruleset); --- 220 unchanged lines hidden --- | 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 --- |