40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi/*
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * CDDL HEADER START
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi *
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * The contents of this file are subject to the terms of the
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Common Development and Distribution License (the "License").
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * You may not use this file except in compliance with the License.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi *
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * or http://www.opensolaris.org/os/licensing.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * See the License for the specific language governing permissions
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * and limitations under the License.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi *
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * When distributing Covered Code, include this CDDL HEADER in each
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * If applicable, add the following below this CDDL HEADER, with the
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * fields enclosed by brackets "[]" replaced with your own identifying
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * information: Portions Copyright [yyyy] [name of copyright owner]
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi *
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * CDDL HEADER END
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi/*
2c2c41837e330b002c4220a39638150db504fe0evi * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi * Use is subject to license terms.
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#ifndef _SIP_HASH_H
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#define _SIP_HASH_H
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#pragma ident "%Z%%M% %I% %E% SMI"
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#ifdef __cplusplus
40cb5e5daa7b80bb70fcf8dadfb20f9281566331viextern "C" {
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#endif
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#include <pthread.h>
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi/* A prime number */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#define SIP_HASH_SZ 6037
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#define SIP_DIGEST_TO_HASH(digest) \
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi ((digest[0] + digest[1] + digest[2] + digest[3] + digest[4] + \
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi digest[5] + digest[6] + digest[7]) % SIP_HASH_SZ)
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi/* An entry in the hash table, sip_obj is opaque */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vitypedef struct sip_hash_obj_s {
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi void *sip_obj;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi struct sip_hash_obj_s *next_obj;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi struct sip_hash_obj_s *prev_obj;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi} sip_hash_obj_t;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi/* A hash list in the table */
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vitypedef struct sip_hash_s {
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi sip_hash_obj_t *hash_head;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi sip_hash_obj_t *hash_tail;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi int hash_count;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi pthread_mutex_t sip_hash_mutex;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi}sip_hash_t;
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331viint sip_hash_add(sip_hash_t *, void *, int);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vivoid *sip_hash_find(sip_hash_t *, void *, int,
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi boolean_t (*)(void *, void *));
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vivoid sip_walk_hash(sip_hash_t *, void (*)(void *, void *), void *);
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vivoid sip_hash_delete(sip_hash_t *, void *, int,
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi boolean_t (*)(void *, void *, int *));
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vivoid sip_hash_init();
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#ifdef __cplusplus
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi}
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#endif
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi
40cb5e5daa7b80bb70fcf8dadfb20f9281566331vi#endif /* _SIP_HASH_H */