ipclassifier.h revision 19a8a986a692bc1fdeb3de480b5d435d2d13bede
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _INET_IPCLASSIFIER_H
#define _INET_IPCLASSIFIER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket_proto.h>
/*
* ==============================
* = The CONNECTION =
* ==============================
*/
/*
* The connection structure contains the common information/flags/ref needed.
* Implementation will keep the connection struct, the layers (with their
* respective data for event i.e. tcp_t if event was tcp_input) all in one
* contiguous memory location.
*/
/* Conn Flags */
/* Unused 0x00020000 */
/* Unused 0x00040000 */
/* Unused 0x02000000 */
/* Unused 0x10000000 */
/* Unused 0x20000000 */
/* Flags identifying the type of conn */
/* Conn Masks */
#define IPCL_REMOVED 0x00000100
#define IPCL_REUSED 0x00000200
/* The packet format is IPv4; could be an AF_INET or AF_INET6 socket */
#define IPCL_IS_TCP4(connp) \
/* Connected AF_INET with no IPsec policy */
#define IPCL_IS_TCP4_CONNECTED_NO_POLICY(connp) \
(((connp)->conn_flags & \
== (IPCL_TCP4|IPCL_CONNECTED))
#define IPCL_IS_CONNECTED(connp) \
#define IPCL_IS_BOUND(connp) \
/* AF_INET TCP that is bound */
#define IPCL_IS_TCP4_BOUND(connp) \
(((connp)->conn_flags & \
#define IPCL_IS_FULLY_BOUND(connp) \
/*
* Can't use conn_protocol since we need to tell difference
* between a real TCP socket and a SOCK_RAW, IPPROTO_TCP.
*/
#define IPCL_IS_TCP(connp) \
#define IPCL_IS_SCTP(connp) \
#define IPCL_IS_UDP(connp) \
#define IPCL_IS_RAWIP(connp) \
#define IPCL_IS_RTS(connp) \
/* FIXME: Isn't it sufficient to check IPCL_IPTUN? */
#define IPCL_IS_IPTUN(connp) \
typedef struct
{
int ctb_depth;
#define CONN_STACK_DEPTH 15
} conn_trace_t;
typedef struct ip_helper_minor_info_s {
/*
* ip helper stream info
*/
typedef struct ip_helper_stream_info_s {
/*
* The initial fields in the conn_t are setup by the kmem_cache constructor,
* and are preserved when it is freed. Fields after that are bzero'ed when
* the conn_t is freed.
*/
struct conn_s {
union {
void *cp_priv;
/* Fields after this are bzero'ed when the conn_t is freed. */
#define conn_start_clr conn_state_flags
unsigned int
conn_nexthop_set : 1,
unsigned int
struct {
union {
/* Used for classifier match performance */
struct {
} tcpu_ports;
} u_port;
int conn_ilg_allocated; /* Number allocated */
int conn_ilg_inuse; /* Number currently used */
int conn_ilg_walker_cnt; /* No of ilg walkers */
/* XXXX get rid of this, once ilg_delete_all is fixed */
int conn_orig_bound_ifindex; /* BOUND_IF before MOVE */
/* IPv6 MC IF before MOVE */
/* mtuinfo from IPV6_PACKET_TOO_BIG conditional on conn_pathmtu_valid */
struct ip6_mtuinfo mtuinfo;
unsigned int
conn_spare : 26;
#ifdef CONN_DEBUG
#define CONN_TRACE_MAX 10
int conn_trace_last; /* ndx of last used tracebuf */
#endif
};
/*
* connf_t - connection fanout data.
*
* The hash tables and their linkage (conn_t.{hashnextp, hashprevp} are
* protected by the per-bucket lock. Each conn_t inserted in the list
* points back at the connf_t that heads the bucket.
*/
struct connf_s {
struct conn_s *connf_head;
};
#define CONN_INC_REF(connp) { \
}
#define CONN_INC_REF_LOCKED(connp) { \
}
#define CONN_DEC_REF(connp) { \
/* \
* The squeue framework always does a CONN_DEC_REF after return \
* from TCP. Hence the refcnt must be at least 2 if conn_on_sqp \
* is B_TRUE and conn_ref is being decremented. This is to \
* account for the mblk being currently processed. \
*/ \
/* Refcnt can't increase again, safe to drop lock */ \
} else { \
} \
}
/*
* For use with subsystems within ip which use ALL_ZONES as a wildcard
*/
#define IPCL_ZONEID(connp) \
/*
* For matching between a conn_t and a zoneid.
*/
(((connp)->conn_allzones) || \
#define _IPCL_V4_MATCH_ANY(addr) \
/*
* IPCL_PROTO_MATCH() only matches conns with the specified zoneid, while
* IPCL_PROTO_MATCH_V6() can match other conns in the multicast case, see
* ip_fanout_proto().
*/
fanout_flags, zoneid) \
((protocol) == IPPROTO_RSVP)))
fanout_flags, zoneid) \
!(connp)->conn_ipv6_v6only)
}
}
!(connp)->conn_ipv6_v6only)
!(connp)->conn_ipv6_v6only)
}
}
#define CONN_G_HASH_SIZE 1024
/* Raw socket hash function. */
/*
* This is similar to IPCL_BIND_MATCH except that the local port check
* is changed to a wildcard port check.
*/
(connp)->conn_lport == 0 && \
(connp)->conn_lport == 0 && \
/* Function prototypes */
extern void ipcl_g_init(void);
extern void ipcl_init(ip_stack_t *);
extern void ipcl_g_destroy(void);
extern void ipcl_destroy(ip_stack_t *);
extern void ipcl_conn_destroy(conn_t *);
void ipcl_hash_remove(conn_t *);
uint16_t);
uint32_t);
ip_stack_t *);
void ipcl_globalhash_insert(conn_t *);
void ipcl_globalhash_remove(conn_t *);
ip_stack_t *);
ip_stack_t *);
int conn_trace_ref(conn_t *);
int conn_untrace_ref(conn_t *);
void ipcl_conn_cleanup(conn_t *);
ip_stack_t *);
ip_stack_t *);
cred_t *);
#ifdef __cplusplus
}
#endif
#endif /* _INET_IPCLASSIFIER_H */