1294332Sdes/* $OpenBSD: dispatch.h,v 1.12 2015/01/19 20:07:45 markus Exp $ */ 276259Sgreen 365668Skris/* 465668Skris * Copyright (c) 2000 Markus Friedl. All rights reserved. 565668Skris * 665668Skris * Redistribution and use in source and binary forms, with or without 765668Skris * modification, are permitted provided that the following conditions 865668Skris * are met: 965668Skris * 1. Redistributions of source code must retain the above copyright 1065668Skris * notice, this list of conditions and the following disclaimer. 1165668Skris * 2. Redistributions in binary form must reproduce the above copyright 1265668Skris * notice, this list of conditions and the following disclaimer in the 1365668Skris * documentation and/or other materials provided with the distribution. 1465668Skris * 1565668Skris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1665668Skris * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1765668Skris * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1865668Skris * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1965668Skris * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2065668Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2165668Skris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2265668Skris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2365668Skris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2465668Skris * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2565668Skris */ 26162852Sdes 27294332Sdes#ifndef DISPATCH_H 28294332Sdes#define DISPATCH_H 29162852Sdes 30294332Sdes#define DISPATCH_MAX 255 31294332Sdes 3260573Skrisenum { 3360573Skris DISPATCH_BLOCK, 3460573Skris DISPATCH_NONBLOCK 3560573Skris}; 3660573Skris 37294332Sdesstruct ssh; 3860573Skris 39294332Sdestypedef int dispatch_fn(int, u_int32_t, void *); 40294332Sdes 41294332Sdesint dispatch_protocol_error(int, u_int32_t, void *); 42294332Sdesint dispatch_protocol_ignore(int, u_int32_t, void *); 43294332Sdesvoid ssh_dispatch_init(struct ssh *, dispatch_fn *); 44294332Sdesvoid ssh_dispatch_set(struct ssh *, int, dispatch_fn *); 45294332Sdesvoid ssh_dispatch_range(struct ssh *, u_int, u_int, dispatch_fn *); 46294332Sdesint ssh_dispatch_run(struct ssh *, int, volatile sig_atomic_t *, void *); 47294332Sdesvoid ssh_dispatch_run_fatal(struct ssh *, int, volatile sig_atomic_t *, void *); 48294332Sdes 49294332Sdes#define dispatch_init(dflt) \ 50294332Sdes ssh_dispatch_init(active_state, (dflt)) 51294332Sdes#define dispatch_range(from, to, fn) \ 52294332Sdes ssh_dispatch_range(active_state, (from), (to), (fn)) 53294332Sdes#define dispatch_set(type, fn) \ 54294332Sdes ssh_dispatch_set(active_state, (type), (fn)) 55294332Sdes#define dispatch_run(mode, done, ctxt) \ 56294332Sdes ssh_dispatch_run_fatal(active_state, (mode), (done), (ctxt)) 57294332Sdes 58294332Sdes#endif 59