2 * (c) Copyright 1992 by Panagiotis Tsirigotis
3 * (c) Sections Copyright 1998-2001 by Rob Braun
4 * All rights reserved. The file named COPYRIGHT specifies the terms
5 * and conditions for redistribution.
12 * $Id: defs.h,v 1.3 2005/03/29 15:50:34 bbraun Exp $
20 #include <sys/socket.h>
21 #include <netinet/in.h>
25 struct sockaddr_in sa_in;
26 struct sockaddr_in6 sa_in6;
37 #define ES_NOMEM "out of memory"
39 #define INT_NULL ((int *)0)
40 #define CHAR_NULL ((char *)0)
41 #define VOID_NULL ((void *)0)
42 #define FD_SET_NULL ((fd_set *)0)
43 #define RUSAGE_NULL ((struct rusage *)0)
44 #define TIMEVAL_NULL ((struct timeval *)0)
46 #define EQ( s1, s2 ) ( strcasecmp( s1, s2 ) == 0 )
47 #define CLEAR( x ) (void) memset( (char *)&(x), 0, sizeof( x ) )
48 /* Apparently, some tcp wrapper header files export an SA definition.
49 * make sure we use ours instead of some other one.
53 #define SA( p ) ( (struct sockaddr *) (p) )
54 #define SAIN( p ) ( (struct sockaddr_in *) (p) )
55 #define SAIN6( p ) ( (struct sockaddr_in6 *) (p) )
56 #define NEW( type ) (type *) malloc( sizeof( type ) )
57 #define FREE( p ) (void) free( (char *)(p) )
60 * Value for unlimited server instances
62 #define UNLIMITED (-1)
65 * We pass to the child the descriptors 0..MAX_PASS_FD
70 * Service port for the identification service
72 #define IDENTITY_SERVICE_PORT 113
75 * This is the signal sent to interceptor processes to tell them
76 * to stop intercepting
78 #define INTERCEPT_SIG SIGUSR1
81 * This is how many descriptors we reserve for ourselves:
83 * 3 for stdin, stdout, stderr
86 * For the rest we just need to reserve the maximum of each category.
89 * 1 for registering rpc services (initialization phase)
90 * 4 for reading the configuration file during reconfiguration
91 * 1 for the configuration file
94 * 1 for /etc/services, /etc/protocols, /etc/rpc
95 * NOTE: We need only 1 descriptor for the last 3 files because
96 * the functions get{serv,proto,rpc}byname close the
97 * respective files after accessing them.
98 * 1 for dumping the internal state
99 * 1 for talking to the portmapper (reconfiguration phase)
100 * 1 for doing identification
102 * NOTE: we assume that the socket used for pmap_{set,unset} is closed
103 * after the operation is completed. If it stays open, then we
104 * need to increase DESCRIPTORS_RESERVED.
106 #define DESCRIPTORS_RESERVED 8
111 #define LISTEN_BACKLOG 64
114 * When explicit values are given for enum's, that is because the structures
115 * that the enum's are in may be initialized by a memory clear operation.
118 typedef enum { FAILED = 0, OK } status_e ;
119 typedef enum { NO = 0, YES } boolean_e ;
122 * Possible outcomes of an identification attempt
134 typedef int bool_int ;
136 typedef void (*voidfunc)() ;
137 typedef status_e (*statfunc)() ;
141 * A name-value list is exactly what its name says.
142 * The functions nv_get_name() and nv_get_value() return a pointer to
143 * the entry with the specified value or name respectively.
144 * The list ends when an antry with a NULL name is encountered.
145 * The value field of that entry is treated in a special manner: if it
146 * is non-zero, it is assumed that there exists one more entry whose
147 * name field will be returned by the nv_get_name function if it can't
148 * find an entry whose value field is equal to its 2nd parameter.
149 * If the value field of the NULL entry is 0, then nv_get_name() will
158 struct protocol_name_value
170 /* This is some forward prototypes to work out a couple
171 * circular dependencies in the data structures */
175 typedef struct connection connection_s ;
178 extern struct debug debug ;