Remove IPsec and related code from the system.
[dragonfly.git] / usr.sbin / inetd / inetd.h
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. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD: src/usr.sbin/inetd/inetd.h,v 1.4.2.4 2002/08/21 10:00:24 ume Exp $
30  */
31
32 #include <sys/time.h>
33 #include <sys/socket.h>
34 #include <sys/un.h>
35 #include <sys/queue.h>
36
37 #include <netinet/in.h>
38
39 #include <stdio.h>
40
41 #define BUFSIZE 8192
42 #define LINESIZ 72
43
44 #define NORM_TYPE       0
45 #define MUX_TYPE        1
46 #define MUXPLUS_TYPE    2
47 #define TTCP_TYPE       3
48 #define ISMUX(sep)      (((sep)->se_type == MUX_TYPE) || \
49                          ((sep)->se_type == MUXPLUS_TYPE))
50 #define ISMUXPLUS(sep)  ((sep)->se_type == MUXPLUS_TYPE)
51 #define ISTTCP(sep)     ((sep)->se_type == TTCP_TYPE)
52
53 struct procinfo {
54         LIST_ENTRY(procinfo) pr_link;
55         pid_t           pr_pid;         /* child pid */
56         struct conninfo *pr_conn;
57 };
58
59 struct conninfo {
60         LIST_ENTRY(conninfo) co_link;
61         struct sockaddr_storage co_addr;        /* source address */
62         int             co_numchild;    /* current number of children */
63         struct procinfo **co_proc;      /* array of child proc entry */
64 };
65
66 #define PERIPSIZE       256
67
68 struct  servtab {
69         char    *se_service;            /* name of service */
70         int     se_socktype;            /* type of socket to use */
71         int     se_family;              /* address family */
72         char    *se_proto;              /* protocol used */
73         int     se_maxchild;            /* max number of children */
74         int     se_maxcpm;              /* max connects per IP per minute */
75         int     se_numchild;            /* current number of children */
76         pid_t   *se_pids;               /* array of child pids */
77         char    *se_user;               /* user name to run as */
78         char    *se_group;              /* group name to run as */
79 #ifdef  LOGIN_CAP
80         char    *se_class;              /* login class name to run with */
81 #endif
82         struct  biltin *se_bi;          /* if built-in, description */
83         char    *se_server;             /* server program */
84         char    *se_server_name;        /* server program without path */
85 #define MAXARGV 20
86         char    *se_argv[MAXARGV+1];    /* program arguments */
87         int     se_fd;                  /* open descriptor */
88         union {                         /* bound address */
89                 struct  sockaddr se_un_ctrladdr;
90                 struct  sockaddr_in se_un_ctrladdr4;
91                 struct  sockaddr_in6 se_un_ctrladdr6;
92                 struct  sockaddr_un se_un_ctrladdr_un;
93         } se_un;
94 #define se_ctrladdr     se_un.se_un_ctrladdr
95 #define se_ctrladdr4    se_un.se_un_ctrladdr4
96 #define se_ctrladdr6    se_un.se_un_ctrladdr6
97 #define se_ctrladdr_un   se_un.se_un_ctrladdr_un
98         socklen_t       se_ctrladdr_size;
99         uid_t   se_sockuid;             /* Owner for unix domain socket */
100         gid_t   se_sockgid;             /* Group for unix domain socket */
101         mode_t  se_sockmode;            /* Mode for unix domain socket */
102         u_char  se_type;                /* type: normal, mux, or mux+ */
103         u_char  se_checked;             /* looked at during merge */
104         u_char  se_accept;              /* i.e., wait/nowait mode */
105         u_char  se_rpc;                 /* ==1 if RPC service */
106         int     se_rpc_prog;            /* RPC program number */
107         u_int   se_rpc_lowvers;         /* RPC low version */
108         u_int   se_rpc_highvers;        /* RPC high version */
109         int     se_count;               /* number started since se_time */
110         struct  timeval se_time;        /* start of se_count */
111         struct  servtab *se_next;
112         struct se_flags {
113                 u_int se_nomapped : 1;
114                 u_int se_reset : 1;
115         } se_flags;
116         int     se_maxperip;            /* max number of children per src */
117         LIST_HEAD(, conninfo) se_conn[PERIPSIZE];
118 };
119
120 #define se_nomapped             se_flags.se_nomapped
121 #define se_reset                se_flags.se_reset
122
123 int             check_loop(const struct sockaddr *, const struct servtab *sep);
124 int             getvalue(const char *, int *, const char *);
125 char           *newstr(const char *);
126 void            inetd_setproctitle(const char *, int);
127 void            print_service(const char *, const struct servtab *);
128 char           *sskip(char **);
129 char           *skip(char **);
130 struct servtab *tcpmux(int);
131
132 extern int       debug;
133 extern struct servtab *servtab;
134
135 typedef void (bi_fn_t)(int, struct servtab *);
136
137 struct biltin {
138         const char *bi_service;         /* internally provided service name */
139         int     bi_socktype;            /* type of socket supported */
140         short   bi_fork;                /* 1 if should fork before call */
141         int     bi_maxchild;            /* max number of children, -1=default */
142         bi_fn_t *bi_fn;                 /* function which performs it */
143 };