18f6d079fSchristos /*- 28f6d079fSchristos * Copyright (c) 2016 Mindaugas Rasiukevicius <rmind at noxt eu> 38f6d079fSchristos * All rights reserved. 48f6d079fSchristos * 58f6d079fSchristos * Redistribution and use in source and binary forms, with or without 68f6d079fSchristos * modification, are permitted provided that the following conditions 78f6d079fSchristos * are met: 88f6d079fSchristos * 1. Redistributions of source code must retain the above copyright 98f6d079fSchristos * notice, this list of conditions and the following disclaimer. 108f6d079fSchristos * 2. Redistributions in binary form must reproduce the above copyright 118f6d079fSchristos * notice, this list of conditions and the following disclaimer in the 128f6d079fSchristos * documentation and/or other materials provided with the distribution. 138f6d079fSchristos * 148f6d079fSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158f6d079fSchristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168f6d079fSchristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178f6d079fSchristos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188f6d079fSchristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198f6d079fSchristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208f6d079fSchristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218f6d079fSchristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228f6d079fSchristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238f6d079fSchristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248f6d079fSchristos * SUCH DAMAGE. 258f6d079fSchristos */ 268f6d079fSchristos 278f6d079fSchristos #ifndef _LPM_H_ 288f6d079fSchristos #define _LPM_H_ 298f6d079fSchristos 308f6d079fSchristos __BEGIN_DECLS 318f6d079fSchristos 328f6d079fSchristos typedef struct lpm lpm_t; 338f6d079fSchristos typedef void (*lpm_dtor_t)(void *, const void *, size_t, void *); 348f6d079fSchristos 35*a80fb120Schristos lpm_t * lpm_create(int); 368f6d079fSchristos void lpm_destroy(lpm_t *); 378f6d079fSchristos void lpm_clear(lpm_t *, lpm_dtor_t, void *); 388f6d079fSchristos 398f6d079fSchristos int lpm_insert(lpm_t *, const void *, size_t, unsigned, void *); 408f6d079fSchristos int lpm_remove(lpm_t *, const void *, size_t, unsigned); 418f6d079fSchristos void * lpm_lookup(lpm_t *, const void *, size_t); 4239013e66Srmind void * lpm_lookup_prefix(lpm_t *, const void *, size_t, unsigned); 438f6d079fSchristos int lpm_strtobin(const char *, void *, size_t *, unsigned *); 448f6d079fSchristos 458f6d079fSchristos __END_DECLS 468f6d079fSchristos 478f6d079fSchristos #endif 48