ilb_ip.h revision 10946:324bab2b3370
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
34extern "C" {
35#endif
36
37extern void ilb_ddi_g_init(void);
38extern 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
45extern boolean_t ilb_has_rules(ilb_stack_t *);
46
47extern int ilb_check_v4(ilb_stack_t *, ill_t *, mblk_t *, ipha_t *, int,
48    uint8_t *, ipaddr_t *);
49extern int ilb_check_v6(ilb_stack_t *, ill_t *, mblk_t *, ip6_t *, int,
50    uint8_t *, in6_addr_t *);
51extern boolean_t ilb_rule_match_vip_v4(ilb_stack_t *, ipaddr_t, ilb_rule_t **);
52extern boolean_t ilb_rule_match_vip_v6(ilb_stack_t *, in6_addr_t *,
53    ilb_rule_t **);
54
55extern int ip_sioctl_ilb_cmd(ipif_t *, sin_t *, queue_t *, mblk_t *,
56    ip_ioctl_cmd_t *, void *);
57
58extern int ilb_rule_add(ilb_stack_t *, zoneid_t, const ilb_rule_cmd_t *);
59extern int ilb_rule_del(ilb_stack_t *, zoneid_t, const char *);
60extern void ilb_rule_del_all(ilb_stack_t *, zoneid_t);
61extern int ilb_rule_enable(ilb_stack_t *, zoneid_t, const char *,
62    ilb_rule_t *);
63extern void ilb_rule_enable_all(ilb_stack_t *, zoneid_t);
64extern int ilb_rule_disable(ilb_stack_t *, zoneid_t, const char *,
65    ilb_rule_t *);
66extern void ilb_rule_disable_all(ilb_stack_t *, zoneid_t);
67extern int ilb_rule_list(ilb_stack_t *, zoneid_t, ilb_rule_cmd_t *);
68
69extern void ilb_get_num_rules(ilb_stack_t *, zoneid_t, uint32_t *);
70extern int ilb_get_num_servers(ilb_stack_t *, zoneid_t, const char *,
71    uint32_t *);
72extern ilb_rule_t *ilb_find_rule(ilb_stack_t *, zoneid_t, const char *, int *);
73extern void ilb_get_rulenames(ilb_stack_t *, zoneid_t, uint32_t *,
74    char *);
75extern int ilb_get_servers(ilb_stack_t *, zoneid_t, const char *,
76    ilb_server_info_t *, uint32_t *);
77
78extern int ilb_server_add(ilb_stack_t *, ilb_rule_t *, ilb_server_info_t *);
79extern int ilb_server_del(ilb_stack_t *, zoneid_t, const char *,
80    ilb_rule_t *, in6_addr_t *);
81extern int ilb_server_enable(ilb_stack_t *, zoneid_t, const char *,
82    ilb_rule_t *, in6_addr_t *);
83extern int ilb_server_disable(ilb_stack_t *, zoneid_t, const char *,
84    ilb_rule_t *, in6_addr_t *);
85
86extern int ilb_list_nat(ilb_stack_t *, zoneid_t, ilb_nat_entry_t *,
87    uint32_t *, uint32_t *);
88extern 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