michael@0: /* michael@0: * replay-database.h michael@0: * michael@0: * interface for a replay database for packet security michael@0: * michael@0: * David A. McGrew michael@0: * Cisco Systems, Inc. michael@0: */ michael@0: /* michael@0: * michael@0: * Copyright (c) 2001-2006, Cisco Systems, Inc. michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * michael@0: * Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * michael@0: * Redistributions in binary form must reproduce the above michael@0: * copyright notice, this list of conditions and the following michael@0: * disclaimer in the documentation and/or other materials provided michael@0: * with the distribution. michael@0: * michael@0: * Neither the name of the Cisco Systems, Inc. nor the names of its michael@0: * contributors may be used to endorse or promote products derived michael@0: * from this software without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS michael@0: * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE michael@0: * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, michael@0: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES michael@0: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR michael@0: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) michael@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, michael@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) michael@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED michael@0: * OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: * michael@0: */ michael@0: michael@0: michael@0: #ifndef REPLAY_DB_H michael@0: #define REPLAY_DB_H michael@0: michael@0: #include "integers.h" /* for uint32_t */ michael@0: #include "datatypes.h" /* for v128_t */ michael@0: #include "err.h" /* for err_status_t */ michael@0: michael@0: /* michael@0: * if the ith least significant bit is one, then the packet index michael@0: * window_end-i is in the database michael@0: */ michael@0: michael@0: typedef struct { michael@0: uint32_t window_start; /* packet index of the first bit in bitmask */ michael@0: v128_t bitmask; michael@0: } rdb_t; michael@0: michael@0: #define rdb_bits_in_bitmask (8*sizeof(v128_t)) michael@0: michael@0: /* michael@0: * rdb init michael@0: * michael@0: * initalizes rdb michael@0: * michael@0: * returns err_status_ok on success, err_status_t_fail otherwise michael@0: */ michael@0: michael@0: err_status_t michael@0: rdb_init(rdb_t *rdb); michael@0: michael@0: michael@0: /* michael@0: * rdb_check michael@0: * michael@0: * checks to see if index appears in rdb michael@0: * michael@0: * returns err_status_fail if the index already appears in rdb, michael@0: * returns err_status_ok otherwise michael@0: */ michael@0: michael@0: err_status_t michael@0: rdb_check(const rdb_t *rdb, uint32_t rdb_index); michael@0: michael@0: /* michael@0: * rdb_add_index michael@0: * michael@0: * adds index to rdb_t (and does *not* check if index appears in db) michael@0: * michael@0: * returns err_status_ok on success, err_status_fail otherwise michael@0: * michael@0: */ michael@0: michael@0: err_status_t michael@0: rdb_add_index(rdb_t *rdb, uint32_t rdb_index); michael@0: michael@0: /* michael@0: * the functions rdb_increment() and rdb_get_value() are for use by michael@0: * senders, not receivers - DO NOT use these functions on the same michael@0: * rdb_t upon which rdb_add_index is used! michael@0: */ michael@0: michael@0: michael@0: /* michael@0: * rdb_increment(db) increments the sequence number in db, if it is michael@0: * not too high michael@0: * michael@0: * return values: michael@0: * michael@0: * err_status_ok no problem michael@0: * err_status_key_expired sequence number too high michael@0: * michael@0: */ michael@0: err_status_t michael@0: rdb_increment(rdb_t *rdb); michael@0: michael@0: /* michael@0: * rdb_get_value(db) returns the current sequence number of db michael@0: */ michael@0: michael@0: uint32_t michael@0: rdb_get_value(const rdb_t *rdb); michael@0: michael@0: michael@0: #endif /* REPLAY_DB_H */