17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*e11c3f44Smeem  * Common Development and Distribution License (the "License").
6*e11c3f44Smeem  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*e11c3f44Smeem  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _IPP_IPGPC_CLASSIFIER_H
277c478bd9Sstevel@tonic-gate #define	_IPP_IPGPC_CLASSIFIER_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
317c478bd9Sstevel@tonic-gate #include <ipp/ipgpc/filters.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /* Header file for classifier implementation for ipgpc */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	IPGPC_DEBUG
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifdef IPGPC_DEBUG
427c478bd9Sstevel@tonic-gate #include <sys/debug.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	ipgpc0dbg(a)	printf a
457c478bd9Sstevel@tonic-gate #define	ipgpc1dbg(a)	if (ipgpc_debug > 2) printf a
467c478bd9Sstevel@tonic-gate #define	ipgpc2dbg(a)	if (ipgpc_debug > 3) printf a
477c478bd9Sstevel@tonic-gate #define	ipgpc3dbg(a)	if (ipgpc_debug > 4) printf a
487c478bd9Sstevel@tonic-gate #define	ipgpc4dbg(a)	if (ipgpc_debug > 5) printf a
497c478bd9Sstevel@tonic-gate #else
507c478bd9Sstevel@tonic-gate #define	ipgpc0dbg(a)		/*  */
517c478bd9Sstevel@tonic-gate #define	ipgpc1dbg(a)		/*  */
527c478bd9Sstevel@tonic-gate #define	ipgpc2dbg(a)		/*  */
537c478bd9Sstevel@tonic-gate #define	ipgpc3dbg(a)		/*  */
547c478bd9Sstevel@tonic-gate #define	ipgpc4dbg(a)		/*  */
557c478bd9Sstevel@tonic-gate #endif /* IPGPC_DEBUG */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #define	BUMP_STATS(x)		++(x)
587c478bd9Sstevel@tonic-gate #define	SET_STATS(x, y)		x = y
597c478bd9Sstevel@tonic-gate #define	UPDATE_STATS(x, y)	x += y
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /* packet structure */
627c478bd9Sstevel@tonic-gate typedef struct ipgpc_packet_s {
637c478bd9Sstevel@tonic-gate 	/* IP Addresses are represented as IPV6 address structures */
647c478bd9Sstevel@tonic-gate 	in6_addr_t saddr;	/* IP source address */
657c478bd9Sstevel@tonic-gate 	in6_addr_t daddr;	/* IP destination address */
667c478bd9Sstevel@tonic-gate 	uint16_t sport;		/* source port */
677c478bd9Sstevel@tonic-gate 	uint16_t dport;		/* destination port */
687c478bd9Sstevel@tonic-gate 	uint8_t proto;		/* protocol field */
697c478bd9Sstevel@tonic-gate 	uint8_t dsfield;	/* Traffic class/DS */
707c478bd9Sstevel@tonic-gate 	uid_t uid;		/* user id for packet */
717c478bd9Sstevel@tonic-gate 	projid_t projid;	/* project id for packet */
727c478bd9Sstevel@tonic-gate 	uint_t if_index;	/* interface index */
737c478bd9Sstevel@tonic-gate 	uint32_t direction;	/* packet direction */
747c478bd9Sstevel@tonic-gate 	uint_t len;		/* length of packet */
757c478bd9Sstevel@tonic-gate } ipgpc_packet_t;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate extern int ipgpc_debug;
787c478bd9Sstevel@tonic-gate extern boolean_t ipgpc_action_exist; /* if an ipgpc action exists */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate extern ipgpc_class_t *ipgpc_classify(int, ipgpc_packet_t *);
817c478bd9Sstevel@tonic-gate extern void parse_packet(ipgpc_packet_t *, mblk_t *);
827c478bd9Sstevel@tonic-gate extern void parse_packet6(ipgpc_packet_t *, mblk_t *);
837c478bd9Sstevel@tonic-gate extern void print_packet(int, ipgpc_packet_t *);
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
867c478bd9Sstevel@tonic-gate }
877c478bd9Sstevel@tonic-gate #endif
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #endif	/* _IPP_IPGPC_CLASSIFIER_H */
90