xref: /openbsd-src/lib/libssl/pqueue.h (revision a9f45c63c80b0ab8b60c740ad99abefe7e501cb0)
1*a9f45c63Sguenther /* $OpenBSD: pqueue.h,v 1.4 2016/11/04 18:28:58 guenther Exp $ */
2c3d6a26aSderaadt 
34c60c45eSmiod /*
44c60c45eSmiod  * DTLS implementation written by Nagendra Modadugu
54c60c45eSmiod  * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
64c60c45eSmiod  */
74c60c45eSmiod /* ====================================================================
84c60c45eSmiod  * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
94c60c45eSmiod  *
104c60c45eSmiod  * Redistribution and use in source and binary forms, with or without
114c60c45eSmiod  * modification, are permitted provided that the following conditions
124c60c45eSmiod  * are met:
134c60c45eSmiod  *
144c60c45eSmiod  * 1. Redistributions of source code must retain the above copyright
154c60c45eSmiod  *    notice, this list of conditions and the following disclaimer.
164c60c45eSmiod  *
174c60c45eSmiod  * 2. Redistributions in binary form must reproduce the above copyright
184c60c45eSmiod  *    notice, this list of conditions and the following disclaimer in
194c60c45eSmiod  *    the documentation and/or other materials provided with the
204c60c45eSmiod  *    distribution.
214c60c45eSmiod  *
224c60c45eSmiod  * 3. All advertising materials mentioning features or use of this
234c60c45eSmiod  *    software must display the following acknowledgment:
244c60c45eSmiod  *    "This product includes software developed by the OpenSSL Project
254c60c45eSmiod  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
264c60c45eSmiod  *
274c60c45eSmiod  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
284c60c45eSmiod  *    endorse or promote products derived from this software without
294c60c45eSmiod  *    prior written permission. For written permission, please contact
304c60c45eSmiod  *    openssl-core@OpenSSL.org.
314c60c45eSmiod  *
324c60c45eSmiod  * 5. Products derived from this software may not be called "OpenSSL"
334c60c45eSmiod  *    nor may "OpenSSL" appear in their names without prior written
344c60c45eSmiod  *    permission of the OpenSSL Project.
354c60c45eSmiod  *
364c60c45eSmiod  * 6. Redistributions of any form whatsoever must retain the following
374c60c45eSmiod  *    acknowledgment:
384c60c45eSmiod  *    "This product includes software developed by the OpenSSL Project
394c60c45eSmiod  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
404c60c45eSmiod  *
414c60c45eSmiod  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
424c60c45eSmiod  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
434c60c45eSmiod  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
444c60c45eSmiod  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
454c60c45eSmiod  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
464c60c45eSmiod  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
474c60c45eSmiod  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
484c60c45eSmiod  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
494c60c45eSmiod  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
504c60c45eSmiod  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
514c60c45eSmiod  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
524c60c45eSmiod  * OF THE POSSIBILITY OF SUCH DAMAGE.
534c60c45eSmiod  * ====================================================================
544c60c45eSmiod  *
554c60c45eSmiod  * This product includes cryptographic software written by Eric Young
564c60c45eSmiod  * (eay@cryptsoft.com).  This product includes software written by Tim
574c60c45eSmiod  * Hudson (tjh@cryptsoft.com).
584c60c45eSmiod  *
594c60c45eSmiod  */
604c60c45eSmiod 
614c60c45eSmiod #ifndef HEADER_PQUEUE_H
624c60c45eSmiod #define HEADER_PQUEUE_H
634c60c45eSmiod 
64*a9f45c63Sguenther __BEGIN_HIDDEN_DECLS
65*a9f45c63Sguenther 
664c60c45eSmiod typedef struct _pqueue *pqueue;
674c60c45eSmiod 
684c60c45eSmiod typedef struct _pitem {
694c60c45eSmiod 	unsigned char priority[8]; /* 64-bit value in big-endian encoding */
704c60c45eSmiod 	void *data;
714c60c45eSmiod 	struct _pitem *next;
724c60c45eSmiod } pitem;
734c60c45eSmiod 
744c60c45eSmiod typedef struct _pitem *piterator;
754c60c45eSmiod 
764c60c45eSmiod pitem *pitem_new(unsigned char *prio64be, void *data);
774c60c45eSmiod void   pitem_free(pitem *item);
784c60c45eSmiod 
794c60c45eSmiod pqueue pqueue_new(void);
804c60c45eSmiod void   pqueue_free(pqueue pq);
814c60c45eSmiod 
824c60c45eSmiod pitem *pqueue_insert(pqueue pq, pitem *item);
834c60c45eSmiod pitem *pqueue_peek(pqueue pq);
844c60c45eSmiod pitem *pqueue_pop(pqueue pq);
854c60c45eSmiod pitem *pqueue_find(pqueue pq, unsigned char *prio64be);
864c60c45eSmiod pitem *pqueue_iterator(pqueue pq);
874c60c45eSmiod pitem *pqueue_next(piterator *iter);
884c60c45eSmiod 
894c60c45eSmiod int    pqueue_size(pqueue pq);
904c60c45eSmiod 
91*a9f45c63Sguenther __END_HIDDEN_DECLS
92*a9f45c63Sguenther 
934c60c45eSmiod #endif /* ! HEADER_PQUEUE_H */
94