# 2.11BSD#431 - /usr/src/libexec/tcpd/tcpd.h

##### Macros

    AC_DENY           X
    AC_ERROR          X
    AC_PERMIT         X
    HOSTNAME_KNOWN    X
    NOT_INADDR        X
    RQ_CLIENT_ADDR    X
    RQ_CLIENT_NAME    X
    RQ_CLIENT_SIN     X
    RQ_DAEMON         X
    RQ_FILE           X
    RQ_SERVER_ADDR    X
    RQ_SERVER_NAME    X
    RQ_SERVER_SIN     X
    RQ_USER           X
    STRING_LENGTH     X
    STRING_PARANOID   X
    STRING_UNKNOWN    X
    STRN_CPY          X
    STRN_EQ           X
    STRN_NE           X
    STR_EQ            X
    STR_NE            X
    eval_daemon       X
    eval_pid          X
    fgets             X
    fromhost          X
    gethostbyname     X
    getpeername       X
    inet_addr         X
    recvfrom          X
    sock_methods      X

##### struct's

    host_info         X
    request_info      X
    tcpd_context      X

       1:  /*
       2:   * @(#) tcpd.h 1.3 95/01/08 21:07:59
       3:   *
       4:   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
       5:   */
       6:
       7: /* Structure to describe one communications endpoint. */
       8:
       9: #define STRING_LENGTH   128     /* hosts, users, processes */
      10:
      11: struct host_info {
      12:     char    name[STRING_LENGTH];    /* access via eval_hostname(host) */
      13:     char    addr[STRING_LENGTH];    /* access via eval_hostaddr(host) */
      14:     struct sockaddr_in *sin;        /* socket address or 0 */
      15:     struct t_unitdata *unit;        /* TLI transport address or 0 */
      16:     struct request_info *request;   /* for shared information */
      17: };
      18:
      19: /* Structure to describe what we know about a service request. */
      20:
      21: struct request_info {
      22:     int     fd;             /* socket handle */
      23:     char    user[STRING_LENGTH];    /* access via eval_user(request) */
      24:     char    daemon[STRING_LENGTH];  /* access via eval_daemon(request) */
      25:     char    pid[10];            /* access via eval_pid(request) */
      26:     struct host_info client[1];     /* client endpoint info */
      27:     struct host_info server[1];     /* server endpoint info */
      28:     void  (*sink) ();           /* datagram sink function or 0 */
      29:     void  (*hostname) ();       /* address to printable hostname */
      30:     void  (*hostaddr) ();       /* address to printable address */
      31:     void  (*cleanup) ();        /* cleanup function or 0 */
      32:     struct netconfig *config;       /* netdir handle */
      33: };
      34:
      35: /* Common string operations. Less clutter should be more readable. */
      36:
      37: #define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; }
      38:
      39: #define STRN_EQ(x,y,l)  (strncasecmp((x),(y),(l)) == 0)
      40: #define STRN_NE(x,y,l)  (strncasecmp((x),(y),(l)) != 0)
      41: #define STR_EQ(x,y) (strcasecmp((x),(y)) == 0)
      42: #define STR_NE(x,y) (strcasecmp((x),(y)) != 0)
      43:
      44:  /*
      45:   * Initially, all above strings have the empty value. Information that
      46:   * cannot be determined at runtime is set to "unknown", so that we can
      47:   * distinguish between `unavailable' and `not yet looked up'. A hostname
      48:   * that we do not believe in is set to "paranoid".
      49:   */
      50:
      51: #define STRING_UNKNOWN  "unknown"   /* lookup failed */
      52: #define STRING_PARANOID "paranoid"  /* hostname conflict */
      53:
      54: extern char unknown[];
      55: extern char paranoid[];
      56:
      57: #define HOSTNAME_KNOWN(s) (STR_NE((s),unknown) && STR_NE((s),paranoid))
      58:
      59: #define NOT_INADDR(s) (s[strspn(s,"01234567890./")] != 0)
      60:
      61: /* Global functions. */
      62:
      63: #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
      64: extern void fromhost();         /* get/validate client host info */
      65: #else
      66: #define fromhost sock_host      /* no TLI support needed */
      67: #endif
      68:
      69: extern int hosts_access();      /* access control */
      70: extern void shell_cmd();        /* execute shell command */
      71: extern char *percent_x();       /* do %<char> expansion */
      72: extern void rfc931();           /* client name from RFC 931 daemon */
      73: extern void clean_exit();       /* clean up and exit */
      74: extern void refuse();           /* clean up and exit */
      75: extern char *xgets();           /* fgets() on steroids */
      76: extern char *split_at();        /* strchr() and split */
      77: extern unsigned long dot_quad_addr();   /* restricted inet_addr() */
      78:
      79: /* Global variables. */
      80:
      81: extern int allow_severity;      /* for connection logging */
      82: extern int deny_severity;       /* for connection logging */
      83: extern char *hosts_allow_table;     /* for verification mode redirection */
      84: extern char *hosts_deny_table;      /* for verification mode redirection */
      85: extern int hosts_access_verbose;    /* for verbose matching mode */
      86: extern int rfc931_timeout;      /* user lookup timeout */
      87:
      88:  /*
      89:   * Routines for controlled initialization and update of request structure
      90:   * attributes. Each attribute has its own key.
      91:   */
      92:
      93: #ifdef __STDC__
      94: extern struct request_info *request_init(struct request_info *,...);
      95: extern struct request_info *request_set(struct request_info *,...);
      96: #else
      97: extern struct request_info *request_init(); /* initialize request */
      98: extern struct request_info *request_set();  /* update request structure */
      99: #endif
     100:
     101: #define RQ_FILE     1       /* file descriptor */
     102: #define RQ_DAEMON   2       /* server process (argv[0]) */
     103: #define RQ_USER     3       /* client user name */
     104: #define RQ_CLIENT_NAME  4       /* client host name */
     105: #define RQ_CLIENT_ADDR  5       /* client host address */
     106: #define RQ_CLIENT_SIN   6       /* client endpoint (internal) */
     107: #define RQ_SERVER_NAME  7       /* server host name */
     108: #define RQ_SERVER_ADDR  8       /* server host address */
     109: #define RQ_SERVER_SIN   9       /* server endpoint (internal) */
     110:
     111:  /*
     112:   * Routines for delayed evaluation of request attributes. Each attribute
     113:   * type has its own access method. The trivial ones are implemented by
     114:   * macros. The other ones are wrappers around the transport-specific host
     115:   * name, address, and client user lookup methods. The request_info and
     116:   * host_info structures serve as caches for the lookup results.
     117:   */
     118:
     119: extern char *eval_user();       /* client user */
     120: extern char *eval_hostname();       /* printable hostname */
     121: extern char *eval_hostaddr();       /* printable host address */
     122: extern char *eval_hostinfo();       /* host name or address */
     123: extern char *eval_client();     /* whatever is available */
     124: extern char *eval_server();     /* whatever is available */
     125: #define eval_daemon(r)  ((r)->daemon)   /* daemon process name */
     126: #define eval_pid(r) ((r)->pid)  /* process id */
     127:
     128: /* Socket-specific methods, including DNS hostname lookups. */
     129:
     130: extern void sock_host();        /* look up endpoint addresses */
     131: extern void sock_hostname();        /* translate address to hostname */
     132: extern void sock_hostaddr();        /* address to printable address */
     133: #define sock_methods(r) \
     134:     { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
     135:
     136: /* The System V Transport-Level Interface (TLI) interface. */
     137:
     138: #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
     139: extern void tli_host();         /* look up endpoint addresses etc. */
     140: #endif
     141:
     142:  /*
     143:   * Problem reporting interface. Additional file/line context is reported
     144:   * when available. The jump buffer (tcpd_buf) is not declared here, or
     145:   * everyone would have to include <setjmp.h>.
     146:   */
     147:
     148: #ifdef __STDC__
     149: extern void tcpd_warn(char *, ...); /* report problem and proceed */
     150: extern void tcpd_jump(char *, ...); /* report problem and jump */
     151: #else
     152: extern void tcpd_warn();
     153: extern void tcpd_jump();
     154: #endif
     155:
     156: struct tcpd_context {
     157:     char   *file;           /* current file */
     158:     int     line;           /* current line */
     159: };
     160: extern struct tcpd_context tcpd_context;
     161:
     162:  /*
     163:   * While processing access control rules, error conditions are handled by
     164:   * jumping back into the hosts_access() routine. This is cleaner than
     165:   * checking the return value of each and every silly little function. The
     166:   * (-1) returns are here because zero is already taken by longjmp().
     167:   */
     168:
     169: #define AC_PERMIT   1       /* permit access */
     170: #define AC_DENY     (-1)        /* deny_access */
     171: #define AC_ERROR    AC_DENY     /* XXX */
     172:
     173:  /*
     174:   * In verification mode an option function should just say what it would do,
     175:   * instead of really doing it. An option function that would not return
     176:   * should clear the dry_run flag to inform the caller of this unusual
     177:   * behavior.
     178:   */
     179:
     180: extern void process_options();      /* execute options */
     181: extern int dry_run;         /* verification flag */
     182:
     183: /* Bug workarounds. */
     184:
     185: #ifdef INET_ADDR_BUG            /* inet_addr() returns struct */
     186: #define inet_addr fix_inet_addr
     187: extern long fix_inet_addr();
     188: #endif
     189:
     190: #ifdef BROKEN_FGETS         /* partial reads from sockets */
     191: #define fgets fix_fgets
     192: extern char *fix_fgets();
     193: #endif
     194:
     195: #ifdef RECVFROM_BUG         /* no address family info */
     196: #define recvfrom fix_recvfrom
     197: extern int fix_recvfrom();
     198: #endif
     199:
     200: #ifdef GETPEERNAME_BUG          /* claims success with UDP */
     201: #define getpeername fix_getpeername
     202: extern int fix_getpeername();
     203: #endif
     204:
     205: #ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */
     206: #define gethostbyname fix_gethostbyname
     207: extern struct hostent *fix_gethostbyname();
     208: #endif

#### Defined struct's

host_info defined in line 11; used 20 times

- in line 26-27(4)
- in /usr/src/libexec/tcpd/eval.c line 59(2), 72(2), 85(2)
- in /usr/src/libexec/tcpd/hosts_access.c line 238(2)
- in /usr/src/libexec/tcpd/socket.c line 126(2), 137(2)
- in /usr/src/libexec/tcpd/tli.c line 212(2), 229(2)

request_info defined in line 21; used 133 times

- in line 16, 94-98(12)
- in /usr/src/libexec/tcpd/clean_exit.c line 24(2)
- in /usr/src/libexec/tcpd/eval.c line 46(2), 104(2), 124(2)
- in /usr/src/libexec/tcpd/fix_options.c line 24(2)
- in /usr/src/libexec/tcpd/fromhost.c line 32(2)
- in /usr/src/libexec/tcpd/hosts_access.c line 87(2), 119(2), 178(2), 206(2), 222(2)
- in /usr/src/libexec/tcpd/hosts_ctl.c line 30(2)
- in /usr/src/libexec/tcpd/miscd.c line 50(2)
- in /usr/src/libexec/tcpd/ncr.c line 28(2)
- in /usr/src/libexec/tcpd/options.c line 132(2), 198(2), 209(2), 218(2), 247(2), 266(2), 288(2), 304(2), 316(2), 338(2), 353(2), 368(2), 403(2), 422(2), 546(2)
- in /usr/src/libexec/tcpd/percent_x.c line 35(2)
- in /usr/src/libexec/tcpd/ptx.c line 39(2)
- in /usr/src/libexec/tcpd/refuse.c line 26(2)
- in /usr/src/libexec/tcpd/scaffold.c line 127(2), 174(2), 184(2)
- in /usr/src/libexec/tcpd/socket.c line 75(2)
- in /usr/src/libexec/tcpd/tcpd.c line 48(2)
- in /usr/src/libexec/tcpd/tcpdchk.c line 89(2), 181(2)
- in /usr/src/libexec/tcpd/tcpdmatch.c line 63(2), 260(2), 271(2)
- in /usr/src/libexec/tcpd/tli-sequent.c line 53(2)
- in /usr/src/libexec/tcpd/tli.c line 64(2), 98(2), 111(2), 214(2), 231(2)
- in /usr/src/libexec/tcpd/try-from.c line 44(2)
- in /usr/src/libexec/tcpd/update.c line 33-34(4), 85-88(8), 96(2), 110-115(8)

tcpd_context defined in line 156; used 10 times

- in line 160(2)
- in /usr/src/libexec/tcpd/diag.c line 27(2)
- in /usr/src/libexec/tcpd/hosts_access.c line 126(2)
- in /usr/src/libexec/tcpd/inetcf.c line 68(2)
- in /usr/src/libexec/tcpd/tcpdchk.c line 190(2)

#### Defined macros

AC_DENY defined in line 170; used 2 times

- in line 171
- in /usr/src/libexec/tcpd/options.c line 211

AC_ERROR defined in line 171; used 1 times

- in /usr/src/libexec/tcpd/diag.c line 68

AC_PERMIT defined in line 169; used 3 times

- in /usr/src/libexec/tcpd/hosts_access.c line 107
- in /usr/src/libexec/tcpd/options.c line 200
- in /usr/src/libexec/tcpd/tcpdchk.c line 226

HOSTNAME_KNOWN defined in line 57; used 5 times

- in /usr/src/libexec/tcpd/eval.c line 94
- in /usr/src/libexec/tcpd/hosts_access.c line 263-266(2)
- in /usr/src/libexec/tcpd/tcpdmatch.c line 159, 203

NOT_INADDR defined in line 59; used 5 times

- in /usr/src/libexec/tcpd/hosts_access.c line 271
- in /usr/src/libexec/tcpd/scaffold.c line 103
- in /usr/src/libexec/tcpd/tcpdchk.c line 419
- in /usr/src/libexec/tcpd/tcpdmatch.c line 159, 203

RQ_CLIENT_ADDR defined in line 105; used 5 times

- in /usr/src/libexec/tcpd/hosts_ctl.c line 35
- in /usr/src/libexec/tcpd/scaffold.c line 149
- in /usr/src/libexec/tcpd/tcpdchk.c line 151
- in /usr/src/libexec/tcpd/tcpdmatch.c line 194, 231

RQ_CLIENT_NAME defined in line 104; used 5 times

- in /usr/src/libexec/tcpd/hosts_ctl.c line 34
- in /usr/src/libexec/tcpd/scaffold.c line 149
- in /usr/src/libexec/tcpd/tcpdchk.c line 150
- in /usr/src/libexec/tcpd/tcpdmatch.c line 204, 231

RQ_CLIENT_SIN defined in line 106; used 2 times

- in /usr/src/libexec/tcpd/scaffold.c line 135
- in /usr/src/libexec/tcpd/tcpdmatch.c line 221

RQ_DAEMON defined in line 102; used 6 times

- in /usr/src/libexec/tcpd/hosts_ctl.c line 33
- in /usr/src/libexec/tcpd/miscd.c line 75
- in /usr/src/libexec/tcpd/tcpd.c line 85
- in /usr/src/libexec/tcpd/tcpdchk.c line 146
- in /usr/src/libexec/tcpd/tcpdmatch.c line 150
- in /usr/src/libexec/tcpd/try-from.c line 65

RQ_FILE defined in line 101; used 5 times

- in /usr/src/libexec/tcpd/miscd.c line 75
- in /usr/src/libexec/tcpd/tcpd.c line 85
- in /usr/src/libexec/tcpd/tcpdchk.c line 152
- in /usr/src/libexec/tcpd/tcpdmatch.c line 150
- in /usr/src/libexec/tcpd/try-from.c line 65

RQ_SERVER_ADDR defined in line 108; used 2 times

- in /usr/src/libexec/tcpd/tcpdchk.c line 148
- in /usr/src/libexec/tcpd/tcpdmatch.c line 174

RQ_SERVER_NAME defined in line 107; used 3 times

- in /usr/src/libexec/tcpd/tcpdchk.c line 147
- in /usr/src/libexec/tcpd/tcpdmatch.c line 174, 186

RQ_SERVER_SIN defined in line 109; used 1 times

- in /usr/src/libexec/tcpd/tcpdmatch.c line 164

RQ_USER defined in line 103; used 3 times

- in /usr/src/libexec/tcpd/hosts_ctl.c line 36
- in /usr/src/libexec/tcpd/tcpdchk.c line 149
- in /usr/src/libexec/tcpd/tcpdmatch.c line 150

STRING_LENGTH defined in line 9; used 9 times

- in line 12-13(2), 23-24(2)
- in /usr/src/libexec/tcpd/eval.c line 106, 126
- in /usr/src/libexec/tcpd/myvsyslog.c line 27
- in /usr/src/libexec/tcpd/rfc931.c line 164
- in /usr/src/libexec/tcpd/update.c line 78

STRING_PARANOID defined in line 52; used 1 times

- in /usr/src/libexec/tcpd/eval.c line 41

STRING_UNKNOWN defined in line 51; used 1 times

- in /usr/src/libexec/tcpd/eval.c line 40

STRN_CPY defined in line 37; used 6 times

- in /usr/src/libexec/tcpd/rfc931.c line 164
- in /usr/src/libexec/tcpd/socket.c line 131, 154
- in /usr/src/libexec/tcpd/tli.c line 221, 286
- in /usr/src/libexec/tcpd/update.c line 78

STRN_EQ defined in line 39; used 1 times

- in /usr/src/libexec/tcpd/hosts_access.c line 291

STRN_NE defined in line 40; never used
STR_EQ defined in line 41; used 41 times

- in /usr/src/libexec/tcpd/hosts_access.c line 191, 261-264(2), 285-293(4)
- in /usr/src/libexec/tcpd/inetcf.c line 121, 185, 193(2), 199, 213, 245, 260, 296
- in /usr/src/libexec/tcpd/miscd.c line 85
- in /usr/src/libexec/tcpd/options.c line 534
- in /usr/src/libexec/tcpd/scaffold.c line 150
- in /usr/src/libexec/tcpd/tcpd.c line 95
- in /usr/src/libexec/tcpd/tcpdchk.c line 287, 315, 342-344(3), 374-377(4), 414, 426(2), 442-446(5)
- in /usr/src/libexec/tcpd/tcpdmatch.c line 175, 232, 302
- in /usr/src/libexec/tcpd/tli.c line 77

STR_NE defined in line 42; used 14 times

- in line 57(2)
- in /usr/src/libexec/tcpd/eval.c line 113, 130
- in /usr/src/libexec/tcpd/hosts_access.c line 194, 263, 289
- in /usr/src/libexec/tcpd/inetcf.c line 109(2)
- in /usr/src/libexec/tcpd/options.c line 174
- in /usr/src/libexec/tcpd/scaffold.c line 115
- in /usr/src/libexec/tcpd/socket.c line 179-180(2)
- in /usr/src/libexec/tcpd/tcpdmatch.c line 264

eval_daemon defined in line 125; used 5 times

- in /usr/src/libexec/tcpd/eval.c line 128
- in /usr/src/libexec/tcpd/hosts_access.c line 211-213(2)
- in /usr/src/libexec/tcpd/options.c line 226
- in /usr/src/libexec/tcpd/percent_x.c line 60

eval_pid defined in line 126; used 1 times

- in /usr/src/libexec/tcpd/percent_x.c line 65

fgets defined in line 191; used 6 times

- in /usr/src/libexec/tcpd/hosts_access.c line 37
- in /usr/src/libexec/tcpd/misc.c line 20, 36
- in /usr/src/libexec/tcpd/options.c line 231
- in /usr/src/libexec/tcpd/rfc931.c line 143
- in /usr/src/libexec/tcpd/workarounds.c line 77

fromhost defined in line 66; used 4 times

- in line 64
- in /usr/src/libexec/tcpd/miscd.c line 76
- in /usr/src/libexec/tcpd/tcpd.c line 86
- in /usr/src/libexec/tcpd/try-from.c line 66

gethostbyname defined in line 206; used 6 times

- in /usr/src/libexec/tcpd/scaffold.c line 107
- in /usr/src/libexec/tcpd/socket.c line 62-65(2), 169
- in /usr/src/libexec/tcpd/workarounds.c line 217, 229

getpeername defined in line 201; used 3 times

- in /usr/src/libexec/tcpd/socket.c line 95
- in /usr/src/libexec/tcpd/workarounds.c line 160, 170

inet_addr defined in line 186; used 4 times

- in /usr/src/libexec/tcpd/misc.c line 86
- in /usr/src/libexec/tcpd/workarounds.c line 56-61(2), 231

recvfrom defined in line 196; used 5 times

- in /usr/src/libexec/tcpd/ptx.c line 100
- in /usr/src/libexec/tcpd/socket.c line 98, 234
- in /usr/src/libexec/tcpd/workarounds.c line 120, 134

sock_methods defined in line 133; used 6 times

- in /usr/src/libexec/tcpd/ptx.c line 59
- in /usr/src/libexec/tcpd/scaffold.c line 136
- in /usr/src/libexec/tcpd/socket.c line 83
- in /usr/src/libexec/tcpd/tcpdmatch.c line 151
- in /usr/src/libexec/tcpd/tli-sequent.c line 66
- in /usr/src/libexec/tcpd/tli.c line 87

#### Usage of this include

tcpd.h used 28 times

- in /usr/src/libexec/tcpd/clean_exit.c line 19
- in /usr/src/libexec/tcpd/diag.c line 24
- in /usr/src/libexec/tcpd/eval.c line 32
- in /usr/src/libexec/tcpd/fix_options.c line 19
- in /usr/src/libexec/tcpd/fromhost.c line 27
- in /usr/src/libexec/tcpd/hosts_access.c line 46
- in /usr/src/libexec/tcpd/hosts_ctl.c line 20
- in /usr/src/libexec/tcpd/inetcf.c line 21
- in /usr/src/libexec/tcpd/misc.c line 18
- in /usr/src/libexec/tcpd/miscd.c line 41
- in /usr/src/libexec/tcpd/myvsyslog.c line 18
- in /usr/src/libexec/tcpd/ncr.c line 21
- in /usr/src/libexec/tcpd/options.c line 57
- in /usr/src/libexec/tcpd/percent_x.c line 27
- in /usr/src/libexec/tcpd/ptx.c line 30
- in /usr/src/libexec/tcpd/refuse.c line 21
- in /usr/src/libexec/tcpd/rfc931.c line 29
- in /usr/src/libexec/tcpd/scaffold.c line 32
- in /usr/src/libexec/tcpd/shell_cmd.c line 28
- in /usr/src/libexec/tcpd/socket.c line 37
- in /usr/src/libexec/tcpd/tcpd.c line 39
- in /usr/src/libexec/tcpd/tcpdchk.c line 45
- in /usr/src/libexec/tcpd/tcpdmatch.c line 43
- in /usr/src/libexec/tcpd/tli-sequent.c line 42
- in /usr/src/libexec/tcpd/tli.c line 49
- in /usr/src/libexec/tcpd/try-from.c line 35
- in /usr/src/libexec/tcpd/update.c line 29
- in /usr/src/libexec/tcpd/workarounds.c line 26

Last modified: 1995-01-08 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 866 |