1326943Sdim/* $OpenBSD: dispatch.h,v 1.12 2015/01/19 20:07:45 markus Exp $ */ 2326943Sdim 3353358Sdim/* 4353358Sdim * Copyright (c) 2000 Markus Friedl. All rights reserved. 5353358Sdim * 6326943Sdim * Redistribution and use in source and binary forms, with or without 7326943Sdim * modification, are permitted provided that the following conditions 8326943Sdim * are met: 9326943Sdim * 1. Redistributions of source code must retain the above copyright 10326943Sdim * notice, this list of conditions and the following disclaimer. 11326943Sdim * 2. Redistributions in binary form must reproduce the above copyright 12326943Sdim * notice, this list of conditions and the following disclaimer in the 13326943Sdim * documentation and/or other materials provided with the distribution. 14326943Sdim * 15326943Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16353358Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17326943Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18326943Sdim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19326943Sdim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20326943Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21336817Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22326943Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23336817Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24326943Sdim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25336817Sdim */ 26326943Sdim 27336817Sdim#ifndef DISPATCH_H 28336817Sdim#define DISPATCH_H 29326943Sdim 30326943Sdim#define DISPATCH_MAX 255 31336817Sdim 32336817Sdimenum { 33353358Sdim DISPATCH_BLOCK, 34326943Sdim DISPATCH_NONBLOCK 35326943Sdim}; 36326943Sdim 37326943Sdimstruct ssh; 38336817Sdim 39336817Sdimtypedef int dispatch_fn(int, u_int32_t, void *); 40336817Sdim 41336817Sdimint dispatch_protocol_error(int, u_int32_t, void *); 42336817Sdimint dispatch_protocol_ignore(int, u_int32_t, void *); 43336817Sdimvoid ssh_dispatch_init(struct ssh *, dispatch_fn *); 44336817Sdimvoid ssh_dispatch_set(struct ssh *, int, dispatch_fn *); 45336817Sdimvoid ssh_dispatch_range(struct ssh *, u_int, u_int, dispatch_fn *); 46336817Sdimint ssh_dispatch_run(struct ssh *, int, volatile sig_atomic_t *, void *); 47336817Sdimvoid ssh_dispatch_run_fatal(struct ssh *, int, volatile sig_atomic_t *, void *); 48336817Sdim 49336817Sdim#define dispatch_init(dflt) \ 50326943Sdim ssh_dispatch_init(active_state, (dflt)) 51326943Sdim#define dispatch_range(from, to, fn) \ 52336817Sdim ssh_dispatch_range(active_state, (from), (to), (fn)) 53336817Sdim#define dispatch_set(type, fn) \ 54336817Sdim ssh_dispatch_set(active_state, (type), (fn)) 55336817Sdim#define dispatch_run(mode, done, ctxt) \ 56336817Sdim ssh_dispatch_run_fatal(active_state, (mode), (done), (ctxt)) 57336817Sdim 58336817Sdim#endif 59336817Sdim