1*0e390eeeSozaki-r /* $NetBSD: portalgo.h,v 1.3 2022/10/28 05:18:39 ozaki-r Exp $ */ 284f52095Schristos 384f52095Schristos /* 484f52095Schristos * Copyright 2011 Vlad Balan 584f52095Schristos * 684f52095Schristos * Written by Vlad Balan for the NetBSD Foundation. 784f52095Schristos * 884f52095Schristos * Redistribution and use in source and binary forms, with or without 984f52095Schristos * modification, are permitted provided that the following conditions 1084f52095Schristos * are met: 1184f52095Schristos * 1. Redistributions of source code must retain the above copyright 1284f52095Schristos * notice, this list of conditions and the following disclaimer. 1384f52095Schristos * 2. Redistributions in binary form must reproduce the above copyright 1484f52095Schristos * notice, this list of conditions and the following disclaimer in the 1584f52095Schristos * documentation and/or other materials provided with the distribution. 1684f52095Schristos * 1784f52095Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1884f52095Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1984f52095Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2084f52095Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2184f52095Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2284f52095Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2384f52095Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2484f52095Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2584f52095Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2684f52095Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2784f52095Schristos * SUCH DAMAGE. 2884f52095Schristos * 2984f52095Schristos */ 3084f52095Schristos #ifndef _NETINET_PORTALGO_H_ 3184f52095Schristos #define _NETINET_PORTALGO_H_ 3284f52095Schristos 3384f52095Schristos #ifdef _KERNEL 3484f52095Schristos #include <sys/sysctl.h> 3584f52095Schristos 36*0e390eeeSozaki-r struct inpcb; 37*0e390eeeSozaki-r int portalgo_randport(uint16_t *, struct inpcb *, kauth_cred_t); 38cbf1f72bSchristos int sysctl_portalgo_selected4(SYSCTLFN_ARGS); 3984f52095Schristos int sysctl_portalgo_selected6(SYSCTLFN_ARGS); 40cbf1f72bSchristos int sysctl_portalgo_reserve4(SYSCTLFN_ARGS); 41cbf1f72bSchristos int sysctl_portalgo_reserve6(SYSCTLFN_ARGS); 4284f52095Schristos int sysctl_portalgo_available(SYSCTLFN_ARGS); 43*0e390eeeSozaki-r int portalgo_algo_index_select(struct inpcb *, int); 4484f52095Schristos 4584f52095Schristos #define PORTALGO_MAXLEN 16 4684f52095Schristos #endif /* _KERNEL */ 4784f52095Schristos 4884f52095Schristos /* 4984f52095Schristos * User-settable options (used with setsockopt). 5084f52095Schristos */ 5184f52095Schristos #define PORTALGO_DEFAULT 0xffff 5284f52095Schristos #define PORTALGO_BSD 0 5384f52095Schristos #define PORTALGO_RANDOM_START 1 5484f52095Schristos #define PORTALGO_RANDOM_PICK 2 5584f52095Schristos #define PORTALGO_HASH 3 5684f52095Schristos #define PORTALGO_DOUBLEHASH 4 5784f52095Schristos #define PORTALGO_RANDINC 5 5884f52095Schristos 5984f52095Schristos #endif /* !_NETINET_PORTALGO_H_ */ 60