Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ut-sim.h |
| 3 | * |
| 4 | * an unreliable transport simulator |
| 5 | * (for testing replay databases and suchlike) |
| 6 | * |
| 7 | * David A. McGrew |
| 8 | * Cisco Systems, Inc. |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * |
David McGrew | 7629bf2 | 2006-06-08 17:00:25 +0000 | [diff] [blame] | 13 | * Copyright (c) 2001-2006, Cisco Systems, Inc. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 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 | |
| 48 | |
| 49 | #ifndef UT_SIM_H |
| 50 | #define UT_SIM_H |
| 51 | |
| 52 | #include "integers.h" /* for uint32_t */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 53 | |
David Benjamin | 5f1b982 | 2016-07-26 18:18:01 -0400 | [diff] [blame] | 54 | #ifdef __cplusplus |
| 55 | extern "C" { |
| 56 | #endif |
| 57 | |
David McGrew | 11b2e41 | 2006-03-16 19:13:31 +0000 | [diff] [blame] | 58 | #define UT_BUF 160 /* maximum amount of packet reorder */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 59 | |
| 60 | typedef struct { |
| 61 | uint32_t index; |
| 62 | uint32_t buffer[UT_BUF]; |
| 63 | } ut_connection; |
| 64 | |
| 65 | /* |
| 66 | * ut_init(&u) initializes the ut_connection |
| 67 | * |
| 68 | * this function should always be the first one called on a new |
| 69 | * ut_connection |
| 70 | */ |
| 71 | |
| 72 | void |
| 73 | ut_init(ut_connection *utc); |
| 74 | |
| 75 | /* |
| 76 | * ut_next_index(&u) returns the next index from the simulated |
| 77 | * unreliable connection |
| 78 | */ |
| 79 | |
| 80 | uint32_t |
| 81 | ut_next_index(ut_connection *utc); |
| 82 | |
David Benjamin | 5f1b982 | 2016-07-26 18:18:01 -0400 | [diff] [blame] | 83 | #ifdef __cplusplus |
| 84 | } |
| 85 | #endif |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 86 | |
| 87 | #endif /* UT_SIM_H */ |