1191255Skmacy/**************************************************************************
2191255Skmacy
3205066SkmacyCopyright (c) 2008-2010, BitGravity Inc.
4191255SkmacyAll rights reserved.
5191255Skmacy
6191255SkmacyRedistribution and use in source and binary forms, with or without
7191255Skmacymodification, are permitted provided that the following conditions are met:
8191255Skmacy
9191255Skmacy 1. Redistributions of source code must retain the above copyright notice,
10191255Skmacy    this list of conditions and the following disclaimer.
11191255Skmacy
12191255Skmacy 2. Neither the name of the BitGravity Corporation nor the names of its
13191255Skmacy    contributors may be used to endorse or promote products derived from
14191255Skmacy    this software without specific prior written permission.
15191255Skmacy
16191255SkmacyTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17191255SkmacyAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18191255SkmacyIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19191255SkmacyARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20191255SkmacyLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21191255SkmacyCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22191255SkmacySUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23191255SkmacyINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24191255SkmacyCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25191255SkmacyARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26191255SkmacyPOSSIBILITY OF SUCH DAMAGE.
27191255Skmacy
28191255Skmacy$FreeBSD$
29191255Skmacy
30191255Skmacy***************************************************************************/
31191255Skmacy
32191255Skmacy#ifndef	_NET_FLOWTABLE_H_
33191255Skmacy#define	_NET_FLOWTABLE_H_
34191255Skmacy
35191255Skmacy#ifdef	_KERNEL
36191255Skmacy
37205066Skmacy#define	FL_HASH_ALL	(1<<0)	/* hash 4-tuple + protocol */
38191255Skmacy#define	FL_PCPU		(1<<1)	/* pcpu cache */
39205066Skmacy#define	FL_NOAUTO	(1<<2)	/* don't automatically add flentry on miss */
40208171Skmacy#define FL_IPV6  	(1<<9)
41191255Skmacy
42205066Skmacy#define	FL_TCP		(1<<11)
43205066Skmacy#define	FL_SCTP		(1<<12)
44205066Skmacy#define	FL_UDP		(1<<13)
45205066Skmacy#define	FL_DEBUG	(1<<14)
46205066Skmacy#define	FL_DEBUG_ALL	(1<<15)
47205066Skmacy
48191255Skmacystruct flowtable;
49205066Skmacystruct flentry;
50205066Skmacystruct route;
51205066Skmacystruct route_in6;
52205066Skmacy
53195699SrwatsonVNET_DECLARE(struct flowtable *, ip_ft);
54195727Srwatson#define	V_ip_ft			VNET(ip_ft)
55191255Skmacy
56205066SkmacyVNET_DECLARE(struct flowtable *, ip6_ft);
57205066Skmacy#define	V_ip6_ft		VNET(ip6_ft)
58191255Skmacy
59205066Skmacystruct flowtable *flowtable_alloc(char *name, int nentry, int flags);
60205066Skmacy
61191255Skmacy/*
62191255Skmacy * Given a flow table, look up the L3 and L2 information and
63194077Sbz * return it in the route.
64191255Skmacy *
65191255Skmacy */
66205066Skmacystruct flentry *flowtable_lookup_mbuf(struct flowtable *ft, struct mbuf *m, int af);
67191255Skmacy
68205066Skmacystruct flentry *flowtable_lookup(struct flowtable *ft, struct sockaddr_storage *ssa,
69205066Skmacy    struct sockaddr_storage *dsa, uint32_t fibnum, int flags);
70205066Skmacy
71205066Skmacyint kern_flowtable_insert(struct flowtable *ft, struct sockaddr_storage *ssa,
72205066Skmacy    struct sockaddr_storage *dsa, struct route *ro, uint32_t fibnum, int flags);
73205066Skmacy
74205066Skmacyvoid flow_invalidate(struct flentry *fl);
75197687Sqinglivoid flowtable_route_flush(struct flowtable *ft, struct rtentry *rt);
76197687Sqingli
77205066Skmacyvoid flow_to_route(struct flentry *fl, struct route *ro);
78205066Skmacy
79205066Skmacyvoid flow_to_route_in6(struct flentry *fl, struct route_in6 *ro);
80205066Skmacy
81205066Skmacy
82194077Sbz#endif /* _KERNEL */
83191255Skmacy#endif
84