inetd.h revision 78356
1/* 2 * Copyright (c) 1983, 1991, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * $FreeBSD: head/usr.sbin/inetd/inetd.h 78356 2001-06-16 18:54:54Z dwmalone $ 34 */ 35 36#include <sys/time.h> 37#include <sys/socket.h> 38#include <sys/un.h> 39 40#include <netinet/in.h> 41 42#include <stdio.h> 43 44#define BUFSIZE 8192 45#define LINESIZ 72 46 47#define NORM_TYPE 0 48#define MUX_TYPE 1 49#define MUXPLUS_TYPE 2 50#define TTCP_TYPE 3 51#define FAITH_TYPE 4 52#define ISMUX(sep) (((sep)->se_type == MUX_TYPE) || \ 53 ((sep)->se_type == MUXPLUS_TYPE)) 54#define ISMUXPLUS(sep) ((sep)->se_type == MUXPLUS_TYPE) 55#define ISTTCP(sep) ((sep)->se_type == TTCP_TYPE) 56 57struct servtab { 58 char *se_service; /* name of service */ 59 int se_socktype; /* type of socket to use */ 60 int se_family; /* address family */ 61 char *se_proto; /* protocol used */ 62 int se_maxchild; /* max number of children */ 63 int se_maxcpm; /* max connects per IP per minute */ 64 int se_numchild; /* current number of children */ 65 pid_t *se_pids; /* array of child pids */ 66 char *se_user; /* user name to run as */ 67 char *se_group; /* group name to run as */ 68#ifdef LOGIN_CAP 69 char *se_class; /* login class name to run with */ 70#endif 71 struct biltin *se_bi; /* if built-in, description */ 72 char *se_server; /* server program */ 73 char *se_server_name; /* server program without path */ 74#define MAXARGV 20 75 char *se_argv[MAXARGV+1]; /* program arguments */ 76#ifdef IPSEC 77 char *se_policy; /* IPsec policy string */ 78#endif 79 int se_fd; /* open descriptor */ 80 union { /* bound address */ 81 struct sockaddr se_un_ctrladdr; 82 struct sockaddr_in se_un_ctrladdr4; 83 struct sockaddr_in6 se_un_ctrladdr6; 84 struct sockaddr_un se_un_ctrladdr_un; 85 } se_un; 86#define se_ctrladdr se_un.se_un_ctrladdr 87#define se_ctrladdr4 se_un.se_un_ctrladdr4 88#define se_ctrladdr6 se_un.se_un_ctrladdr6 89#define se_ctrladdr_un se_un.se_un_ctrladdr_un 90 socklen_t se_ctrladdr_size; 91 uid_t se_sockuid; /* Owner for unix domain socket */ 92 gid_t se_sockgid; /* Group for unix domain socket */ 93 mode_t se_sockmode; /* Mode for unix domain socket */ 94 u_char se_type; /* type: normal, mux, or mux+ */ 95 u_char se_checked; /* looked at during merge */ 96 u_char se_accept; /* i.e., wait/nowait mode */ 97 u_char se_rpc; /* ==1 if RPC service */ 98 int se_rpc_prog; /* RPC program number */ 99 u_int se_rpc_lowvers; /* RPC low version */ 100 u_int se_rpc_highvers; /* RPC high version */ 101 int se_count; /* number started since se_time */ 102 struct timeval se_time; /* start of se_count */ 103 struct servtab *se_next; 104 struct se_flags { 105 u_int se_nomapped : 1; 106 u_int se_reset : 1; 107 } se_flags; 108}; 109 110#define se_nomapped se_flags.se_nomapped 111#define se_reset se_flags.se_reset 112 113void chargen_dg __P((int, struct servtab *)); 114void chargen_stream __P((int, struct servtab *)); 115void close_sep __P((struct servtab *)); 116void flag_signal __P((int)); 117void flag_config __P((int)); 118void config __P((void)); 119void daytime_dg __P((int, struct servtab *)); 120void daytime_stream __P((int, struct servtab *)); 121void discard_dg __P((int, struct servtab *)); 122void discard_stream __P((int, struct servtab *)); 123void echo_dg __P((int, struct servtab *)); 124void echo_stream __P((int, struct servtab *)); 125void endconfig __P((void)); 126struct servtab *enter __P((struct servtab *)); 127void freeconfig __P((struct servtab *)); 128struct servtab *getconfigent __P((void)); 129void iderror __P((int, int, int, char *)); 130void ident_stream __P((int, struct servtab *)); 131void machtime_dg __P((int, struct servtab *)); 132void machtime_stream __P((int, struct servtab *)); 133int matchservent __P((char *, char *, char *)); 134char *newstr __P((char *)); 135char *nextline __P((FILE *)); 136void print_service __P((char *, struct servtab *)); 137void addchild __P((struct servtab *, int)); 138void flag_reapchild __P((int)); 139void reapchild __P((void)); 140void enable __P((struct servtab *)); 141void disable __P((struct servtab *)); 142void flag_retry __P((int)); 143void retry __P((void)); 144int setconfig __P((void)); 145void setup __P((struct servtab *)); 146#ifdef IPSEC 147void ipsecsetup __P((struct servtab *)); 148#endif 149char *sskip __P((char **)); 150char *skip __P((char **)); 151struct servtab *tcpmux __P((int)); 152int cpmip __P((struct servtab *, int)); 153void inetd_setproctitle __P((char *, int)); 154int check_loop __P((struct sockaddr *, struct servtab *sep)); 155 156void unregisterrpc __P((register struct servtab *sep)); 157 158struct biltin { 159 char *bi_service; /* internally provided service name */ 160 int bi_socktype; /* type of socket supported */ 161 short bi_fork; /* 1 if should fork before call */ 162 int bi_maxchild; /* max number of children, -1=default */ 163 void (*bi_fn)(); /* function which performs it */ 164}; 165