1*3b6c3722Schristos /* 2*3b6c3722Schristos * testcode/fake_event.h - fake event handling that replays existing scenario. 3*3b6c3722Schristos * 4*3b6c3722Schristos * Copyright (c) 2007, NLnet Labs. All rights reserved. 5*3b6c3722Schristos * 6*3b6c3722Schristos * This software is open source. 7*3b6c3722Schristos * 8*3b6c3722Schristos * Redistribution and use in source and binary forms, with or without 9*3b6c3722Schristos * modification, are permitted provided that the following conditions 10*3b6c3722Schristos * are met: 11*3b6c3722Schristos * 12*3b6c3722Schristos * Redistributions of source code must retain the above copyright notice, 13*3b6c3722Schristos * this list of conditions and the following disclaimer. 14*3b6c3722Schristos * 15*3b6c3722Schristos * Redistributions in binary form must reproduce the above copyright notice, 16*3b6c3722Schristos * this list of conditions and the following disclaimer in the documentation 17*3b6c3722Schristos * and/or other materials provided with the distribution. 18*3b6c3722Schristos * 19*3b6c3722Schristos * Neither the name of the NLNET LABS nor the names of its contributors may 20*3b6c3722Schristos * be used to endorse or promote products derived from this software without 21*3b6c3722Schristos * specific prior written permission. 22*3b6c3722Schristos * 23*3b6c3722Schristos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24*3b6c3722Schristos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25*3b6c3722Schristos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26*3b6c3722Schristos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27*3b6c3722Schristos * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28*3b6c3722Schristos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29*3b6c3722Schristos * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30*3b6c3722Schristos * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31*3b6c3722Schristos * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32*3b6c3722Schristos * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33*3b6c3722Schristos * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*3b6c3722Schristos */ 35*3b6c3722Schristos 36*3b6c3722Schristos /** 37*3b6c3722Schristos * \file 38*3b6c3722Schristos * Event service that replays a scenario. 39*3b6c3722Schristos * This implements the same exported symbols as the files: 40*3b6c3722Schristos * util/netevent.c 41*3b6c3722Schristos * services/listen_dnsport.c 42*3b6c3722Schristos * services/outside_network.c 43*3b6c3722Schristos * But these do not actually access the network or events, instead 44*3b6c3722Schristos * the scenario is played. 45*3b6c3722Schristos */ 46*3b6c3722Schristos 47*3b6c3722Schristos #ifndef TESTCODE_FAKE_EVENT_H 48*3b6c3722Schristos #define TESTCODE_FAKE_EVENT_H 49*3b6c3722Schristos struct replay_scenario; 50*3b6c3722Schristos 51*3b6c3722Schristos /** 52*3b6c3722Schristos * Initialise fake event services. 53*3b6c3722Schristos * 54*3b6c3722Schristos * The fake event services will automatically start when the main program 55*3b6c3722Schristos * calls netevent.h functions, such as comm_base_dispatch(). 56*3b6c3722Schristos * 57*3b6c3722Schristos * @param scen: Set the scenario to use for upcoming event handling. 58*3b6c3722Schristos */ 59*3b6c3722Schristos void fake_event_init(struct replay_scenario* scen); 60*3b6c3722Schristos 61*3b6c3722Schristos /** 62*3b6c3722Schristos * Deinit fake event services. 63*3b6c3722Schristos */ 64*3b6c3722Schristos void fake_event_cleanup(void); 65*3b6c3722Schristos 66*3b6c3722Schristos /** 67*3b6c3722Schristos * Get filename to store temporary config stuff. The pid is added. in /tmp. 68*3b6c3722Schristos * @param adj: adjective, like "_cfg_", "_auto_" 69*3b6c3722Schristos * @param id: identifier, like "example.com". 70*3b6c3722Schristos * @param buf: where to store. 71*3b6c3722Schristos * @param len: length of buf. 72*3b6c3722Schristos */ 73*3b6c3722Schristos void fake_temp_file(const char* adj, const char* id, char* buf, size_t len); 74*3b6c3722Schristos 75*3b6c3722Schristos #endif /* TESTCODE_FAKE_EVENT_H */ 76