1/**************************************************************************
2
3Copyright (c) 2008-2010, BitGravity Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10    this list of conditions and the following disclaimer.
11
12 2. Neither the name of the BitGravity Corporation nor the names of its
13    contributors may be used to endorse or promote products derived from
14    this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28$FreeBSD$
29
30***************************************************************************/
31
32#ifndef	_NET_FLOWTABLE_H_
33#define	_NET_FLOWTABLE_H_
34
35#ifdef	_KERNEL
36
37#define	FL_HASH_ALL	(1<<0)	/* hash 4-tuple + protocol */
38#define	FL_PCPU		(1<<1)	/* pcpu cache */
39#define	FL_NOAUTO	(1<<2)	/* don't automatically add flentry on miss */
40#define FL_IPV6  	(1<<9)
41
42#define	FL_TCP		(1<<11)
43#define	FL_SCTP		(1<<12)
44#define	FL_UDP		(1<<13)
45#define	FL_DEBUG	(1<<14)
46#define	FL_DEBUG_ALL	(1<<15)
47
48struct flowtable;
49struct flentry;
50struct route;
51struct route_in6;
52
53VNET_DECLARE(struct flowtable *, ip_ft);
54#define	V_ip_ft			VNET(ip_ft)
55
56VNET_DECLARE(struct flowtable *, ip6_ft);
57#define	V_ip6_ft		VNET(ip6_ft)
58
59struct flowtable *flowtable_alloc(char *name, int nentry, int flags);
60
61/*
62 * Given a flow table, look up the L3 and L2 information and
63 * return it in the route.
64 *
65 */
66struct flentry *flowtable_lookup_mbuf(struct flowtable *ft, struct mbuf *m, int af);
67
68struct flentry *flowtable_lookup(struct flowtable *ft, struct sockaddr_storage *ssa,
69    struct sockaddr_storage *dsa, uint32_t fibnum, int flags);
70
71int kern_flowtable_insert(struct flowtable *ft, struct sockaddr_storage *ssa,
72    struct sockaddr_storage *dsa, struct route *ro, uint32_t fibnum, int flags);
73
74void flow_invalidate(struct flentry *fl);
75void flowtable_route_flush(struct flowtable *ft, struct rtentry *rt);
76
77void flow_to_route(struct flentry *fl, struct route *ro);
78
79void flow_to_route_in6(struct flentry *fl, struct route_in6 *ro);
80
81
82#endif /* _KERNEL */
83#endif
84