| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * replay-database.h | |
| 3 * | |
| 4 * interface for a replay database for packet security | |
| 5 * | |
| 6 * David A. McGrew | |
| 7 * Cisco Systems, Inc. | |
| 8 */ | |
| 9 | |
| 10 | |
| 11 /* | |
| 12 * | |
| 13 * Copyright (c) 2001-2006, Cisco Systems, Inc. | |
| 14 * All rights reserved. | |
| 15 * | |
| 16 * Redistribution and use in source and binary forms, with or without | |
| 17 * modification, are permitted provided that the following conditions | |
| 18 * are met: | |
| 19 * | |
| 20 * Redistributions of source code must retain the above copyright | |
| 21 * notice, this list of conditions and the following disclaimer. | |
| 22 * | |
| 23 * Redistributions in binary form must reproduce the above | |
| 24 * copyright notice, this list of conditions and the following | |
| 25 * disclaimer in the documentation and/or other materials provided | |
| 26 * with the distribution. | |
| 27 * | |
| 28 * Neither the name of the Cisco Systems, Inc. nor the names of its | |
| 29 * contributors may be used to endorse or promote products derived | |
| 30 * from this software without specific prior written permission. | |
| 31 * | |
| 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 35 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 36 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 37 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 43 * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 44 * | |
| 45 */ | |
| 46 | |
| 47 #ifndef REPLAY_DB_H | |
| 48 #define REPLAY_DB_H | |
| 49 | |
| 50 #include "integers.h" /* for uint32_t */ | |
| 51 #include "datatypes.h" /* for v128_t */ | |
| 52 #include "err.h" /* for err_status_t */ | |
| 53 | |
| 54 /* | |
| 55 * if the ith least significant bit is one, then the packet index | |
| 56 * window_end-i is in the database | |
| 57 */ | |
| 58 | |
| 59 typedef struct { | |
| 60 uint32_t window_start; /* packet index of the first bit in bitmask */ | |
| 61 v128_t bitmask; | |
| 62 } rdb_t; | |
| 63 | |
| 64 #define rdb_bits_in_bitmask (8*sizeof(v128_t)) | |
| 65 | |
| 66 /* | |
| 67 * rdb init | |
| 68 * | |
| 69 * initalizes rdb | |
| 70 * | |
| 71 * returns err_status_ok on success, err_status_t_fail otherwise | |
| 72 */ | |
| 73 | |
| 74 err_status_t | |
| 75 rdb_init(rdb_t *rdb); | |
| 76 | |
| 77 | |
| 78 /* | |
| 79 * rdb_check | |
| 80 * | |
| 81 * checks to see if index appears in rdb | |
| 82 * | |
| 83 * returns err_status_fail if the index already appears in rdb, | |
| 84 * returns err_status_ok otherwise | |
| 85 */ | |
| 86 | |
| 87 err_status_t | |
| 88 rdb_check(const rdb_t *rdb, uint32_t rdb_index); | |
| 89 | |
| 90 /* | |
| 91 * rdb_add_index | |
| 92 * | |
| 93 * adds index to rdb_t (and does *not* check if index appears in db) | |
| 94 * | |
| 95 * returns err_status_ok on success, err_status_fail otherwise | |
| 96 * | |
| 97 */ | |
| 98 | |
| 99 err_status_t | |
| 100 rdb_add_index(rdb_t *rdb, uint32_t rdb_index); | |
| 101 | |
| 102 /* | |
| 103 * the functions rdb_increment() and rdb_get_value() are for use by | |
| 104 * senders, not receivers - DO NOT use these functions on the same | |
| 105 * rdb_t upon which rdb_add_index is used! | |
| 106 */ | |
| 107 | |
| 108 | |
| 109 /* | |
| 110 * rdb_increment(db) increments the sequence number in db, if it is | |
| 111 * not too high | |
| 112 * | |
| 113 * return values: | |
| 114 * | |
| 115 * err_status_ok no problem | |
| 116 * err_status_key_expired sequence number too high | |
| 117 * | |
| 118 */ | |
| 119 err_status_t | |
| 120 rdb_increment(rdb_t *rdb); | |
| 121 | |
| 122 /* | |
| 123 * rdb_get_value(db) returns the current sequence number of db | |
| 124 */ | |
| 125 | |
| 126 uint32_t | |
| 127 rdb_get_value(const rdb_t *rdb); | |
| 128 | |
| 129 | |
| 130 #endif /* REPLAY_DB_H */ | |
| OLD | NEW |