xref: /illumos-gate/usr/src/uts/common/inet/ilb_ip.h (revision 4df55fde49134f9735f84011f23a767c75e393c7)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #ifndef _INET_ILB_IP_H
27 #define	_INET_ILB_IP_H
28 
29 #include <inet/ilb.h>
30 #include <inet/ilb/ilb_stack.h>
31 #include <inet/ilb/ilb_impl.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 extern void ilb_ddi_g_init(void);
38 extern void ilb_ddi_g_destroy(void);
39 
40 /* Return values of ilb_check_*() */
41 #define	ILB_DROPPED	1	/* Caller should drop the packet. */
42 #define	ILB_PASSED	2	/* No load balanced rule is matched. */
43 #define	ILB_BALANCED	3	/* A rule is matached. */
44 
45 extern boolean_t ilb_has_rules(ilb_stack_t *);
46 
47 extern int ilb_check_v4(ilb_stack_t *, ill_t *, mblk_t *, ipha_t *, int,
48     uint8_t *, ipaddr_t *);
49 extern int ilb_check_v6(ilb_stack_t *, ill_t *, mblk_t *, ip6_t *, int,
50     uint8_t *, in6_addr_t *);
51 extern boolean_t ilb_rule_match_vip_v4(ilb_stack_t *, ipaddr_t, ilb_rule_t **);
52 extern boolean_t ilb_rule_match_vip_v6(ilb_stack_t *, in6_addr_t *,
53     ilb_rule_t **);
54 
55 extern int ip_sioctl_ilb_cmd(ipif_t *, sin_t *, queue_t *, mblk_t *,
56     ip_ioctl_cmd_t *, void *);
57 
58 extern int ilb_rule_add(ilb_stack_t *, zoneid_t, const ilb_rule_cmd_t *);
59 extern int ilb_rule_del(ilb_stack_t *, zoneid_t, const char *);
60 extern void ilb_rule_del_all(ilb_stack_t *, zoneid_t);
61 extern int ilb_rule_enable(ilb_stack_t *, zoneid_t, const char *,
62     ilb_rule_t *);
63 extern void ilb_rule_enable_all(ilb_stack_t *, zoneid_t);
64 extern int ilb_rule_disable(ilb_stack_t *, zoneid_t, const char *,
65     ilb_rule_t *);
66 extern void ilb_rule_disable_all(ilb_stack_t *, zoneid_t);
67 extern int ilb_rule_list(ilb_stack_t *, zoneid_t, ilb_rule_cmd_t *);
68 
69 extern void ilb_get_num_rules(ilb_stack_t *, zoneid_t, uint32_t *);
70 extern int ilb_get_num_servers(ilb_stack_t *, zoneid_t, const char *,
71     uint32_t *);
72 extern ilb_rule_t *ilb_find_rule(ilb_stack_t *, zoneid_t, const char *, int *);
73 extern void ilb_get_rulenames(ilb_stack_t *, zoneid_t, uint32_t *,
74     char *);
75 extern int ilb_get_servers(ilb_stack_t *, zoneid_t, const char *,
76     ilb_server_info_t *, uint32_t *);
77 
78 extern int ilb_server_add(ilb_stack_t *, ilb_rule_t *, ilb_server_info_t *);
79 extern int ilb_server_del(ilb_stack_t *, zoneid_t, const char *,
80     ilb_rule_t *, in6_addr_t *);
81 extern int ilb_server_enable(ilb_stack_t *, zoneid_t, const char *,
82     ilb_rule_t *, in6_addr_t *);
83 extern int ilb_server_disable(ilb_stack_t *, zoneid_t, const char *,
84     ilb_rule_t *, in6_addr_t *);
85 
86 extern int ilb_list_nat(ilb_stack_t *, zoneid_t, ilb_nat_entry_t *,
87     uint32_t *, uint32_t *);
88 extern int ilb_list_sticky(ilb_stack_t *, zoneid_t, ilb_sticky_entry_t *,
89     uint32_t *, uint32_t *);
90 
91 /* Currently supported transport protocol. */
92 #define	ILB_SUPP_L4(proto)						\
93 	((proto) == IPPROTO_TCP || (proto) == IPPROTO_UDP ||		\
94 	    (proto) == IPPROTO_ICMP || (proto) == IPPROTO_ICMPV6)
95 
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* _INET_ILB_IP_H */
102