1*82bad92dSderaadt /* $OpenBSD: doi.c,v 1.11 2013/03/21 04:30:14 deraadt Exp $ */
2eb840acdSniklas /* $EOM: doi.c,v 1.4 1999/04/02 00:57:36 niklas Exp $ */
32040585eSniklas
42040585eSniklas /*
5eb840acdSniklas * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved.
62040585eSniklas *
72040585eSniklas * Redistribution and use in source and binary forms, with or without
82040585eSniklas * modification, are permitted provided that the following conditions
92040585eSniklas * are met:
102040585eSniklas * 1. Redistributions of source code must retain the above copyright
112040585eSniklas * notice, this list of conditions and the following disclaimer.
122040585eSniklas * 2. Redistributions in binary form must reproduce the above copyright
132040585eSniklas * notice, this list of conditions and the following disclaimer in the
142040585eSniklas * documentation and/or other materials provided with the distribution.
152040585eSniklas *
162040585eSniklas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
172040585eSniklas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
182040585eSniklas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
192040585eSniklas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
202040585eSniklas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
212040585eSniklas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222040585eSniklas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232040585eSniklas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242040585eSniklas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
252040585eSniklas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262040585eSniklas */
272040585eSniklas
282040585eSniklas /*
292040585eSniklas * This code was written under funding by Ericsson Radio Systems.
302040585eSniklas */
312040585eSniklas
32*82bad92dSderaadt #include <sys/types.h>
332040585eSniklas
342040585eSniklas #include "doi.h"
352040585eSniklas
36fb9475d6Sderaadt static
37fb9475d6Sderaadt LIST_HEAD(doi_list, doi) doi_tab;
382040585eSniklas
392040585eSniklas void
doi_init(void)401616f820Sderaadt doi_init(void)
412040585eSniklas {
422040585eSniklas LIST_INIT(&doi_tab);
432040585eSniklas }
442040585eSniklas
452040585eSniklas struct doi *
doi_lookup(u_int8_t doi_id)462040585eSniklas doi_lookup(u_int8_t doi_id)
472040585eSniklas {
482040585eSniklas struct doi *doi;
492040585eSniklas
502040585eSniklas for (doi = LIST_FIRST(&doi_tab); doi && doi->id != doi_id;
51fb9475d6Sderaadt doi = LIST_NEXT(doi, link));
522040585eSniklas return doi;
532040585eSniklas }
542040585eSniklas
552040585eSniklas void
doi_register(struct doi * doi)562040585eSniklas doi_register(struct doi *doi)
572040585eSniklas {
582040585eSniklas LIST_INSERT_HEAD(&doi_tab, doi, link);
592040585eSniklas }
60