tcp: Dragging RescueRxt along with HighRxt should depend on tcp.rescuesack_agg
[dragonfly.git] / include / utmpx.h
1 /*-
2  * Copyright (c) 2002 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Christos Zoulas.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef _UTMPX_H_
31 #define _UTMPX_H_
32
33 #include <sys/cdefs.h>
34 #include <sys/socket.h>
35 #include <sys/time.h>
36
37 #define _PATH_UTMPX             "/var/run/utmpx"
38 #define _PATH_WTMPX             "/var/log/wtmpx"
39 #define _PATH_LASTLOGX          "/var/log/lastlogx"
40 #define _PATH_UTMP_UPDATE       "/usr/libexec/utmp_update"
41
42 #define _UTX_USERSIZE   32
43 #define _UTX_LINESIZE   32
44 #define _UTX_IDSIZE     4
45 #define _UTX_HOSTSIZE   256
46
47 #define UTX_USERSIZE    _UTX_USERSIZE
48 #define UTX_LINESIZE    _UTX_LINESIZE
49 #define UTX_IDSIZE      _UTX_IDSIZE
50 #define UTX_HOSTSIZE    _UTX_HOSTSIZE
51
52
53 #define EMPTY           0
54 #define RUN_LVL         1
55 #define BOOT_TIME       2
56 #define OLD_TIME        3
57 #define NEW_TIME        4
58 #define INIT_PROCESS    5
59 #define LOGIN_PROCESS   6
60 #define USER_PROCESS    7
61 #define DEAD_PROCESS    8
62
63 #define ACCOUNTING      9
64 #define SIGNATURE       10
65 #define DOWN_TIME       11
66
67 /*
68  * Strings placed in the ut_line field to indicate special type entries
69  */
70 #define RUNLVL_MSG      "run-level %c"
71 #define BOOT_MSG        "system boot"
72 #define OTIME_MSG       "old time"
73 #define NTIME_MSG       "new time"
74 #define DOWN_MSG        "system down"
75
76 #define ut_user ut_name
77 #define ut_xtime ut_tv.tv_sec
78
79 typedef enum {
80         UTX_DB_UTMPX,
81         UTX_DB_WTMPX,
82         UTX_DB_LASTLOGX
83 } utx_db_t;
84
85 struct exit_status
86 {
87         uint16_t e_termination;         /* termination status */
88         uint16_t e_exit;                /* exit status */
89 };
90
91 struct utmpx {
92         char ut_name[_UTX_USERSIZE];    /* login name */
93         char ut_id[_UTX_IDSIZE];        /* inittab id */
94         char ut_line[_UTX_LINESIZE];    /* tty name */
95         char ut_host[_UTX_HOSTSIZE];    /* host name */
96         uint8_t ut_unused[16];          /* reserved for future use */
97         uint16_t ut_session;            /* session id used for windowing */
98         uint16_t ut_type;               /* type of this entry */
99         pid_t ut_pid;                   /* process id creating the entry */
100         struct exit_status ut_exit;     /* process termination/exit status */
101         struct sockaddr_storage ut_ss;  /* address where entry was made from */
102         struct timeval ut_tv;           /* time entry was created */
103         uint8_t ut_unused2[16];         /* reserved for future use */
104 };
105
106 struct lastlogx {
107         struct timeval ll_tv;           /* time entry was created */
108         char ll_line[_UTX_LINESIZE];    /* tty name */
109         char ll_host[_UTX_HOSTSIZE];    /* host name */
110         struct sockaddr_storage ll_ss;  /* address where entry was made from */
111 };
112
113 __BEGIN_DECLS
114 void          endutxent(void);
115 struct utmpx *getutxent(void);
116 struct utmpx *getutxid(const struct utmpx *);
117 struct utmpx *getutxline(const struct utmpx *);
118 struct utmpx *pututxline(const struct utmpx *);
119 void          setutxent(void);
120
121 #ifdef __BSD_VISIBLE
122 int _updwtmpx(const char *, const struct utmpx *);
123 void updwtmpx(const char *, const struct utmpx *);
124 struct lastlogx *getlastlogx(const char *, uid_t, struct lastlogx *);
125 int updlastlogx(const char *, uid_t, struct lastlogx *);
126 struct utmp;
127 void getutmp(const struct utmpx *, struct utmp *);
128 void getutmpx(const struct utmp *, struct utmpx *);
129 int utmpxname(const char *);
130 int setutxdb(utx_db_t, char *);
131 #endif
132 __END_DECLS
133
134 #endif /* _UTMPX_H_ */
135