File: upsd.h

package info (click to toggle)
nut 0.45.5-rel-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,984 kB
  • ctags: 2,146
  • sloc: ansic: 22,216; sh: 1,138; makefile: 405
file content (153 lines) | stat: -rw-r--r-- 4,403 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* upsd.h - support structures and other minor details

   Copyright (C) 1999  Russell Kroll <rkroll@exploits.org>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/*
 * Much of the content from here was also useful to the
 * model drivers, so has been moved into include/shared-tables.h
 * instead of being within the daemon specific include file
 *
 */

#ifndef UPSD_H_SEEN
#define UPSD_H_SEEN

#include "common.h"
#include "shared.h"

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#ifdef HAVE_MMAP
#include <sys/mman.h>
#endif

#include "timehead.h"

#ifdef HAVE_SHMAT
#include <sys/ipc.h>
#include <sys/shm.h>
#endif

#include <sys/file.h>

#ifndef STANDALONE
void do_sendver (struct sockaddr_in *dest, char *arg, char *rest);
void do_sendans (struct sockaddr_in *dest, char *arg, char *rest);
void do_sendhelp (struct sockaddr_in *dest, char *arg, char *rest);
void do_listvars (struct sockaddr_in *dest, char *arg, char *rest);
void do_logout (struct sockaddr_in *dest, char *arg, char *rest);
void do_login (struct sockaddr_in *dest, char *arg, char *rest);
void do_password (struct sockaddr_in *dest, char *arg, char *rest);
void do_listrw (struct sockaddr_in *dest, char *arg, char *rest);
void do_vartype (struct sockaddr_in *dest, char *arg, char *rest);
void do_vardesc (struct sockaddr_in *dest, char *arg, char *rest);
void do_enum (struct sockaddr_in *dest, char *arg, char *rest);
void do_set (struct sockaddr_in *dest, char *arg, char *rest);
void do_instcmd (struct sockaddr_in *dest, char *arg, char *rest);
void do_listinstcmd (struct sockaddr_in *dest, char *arg, char *rest);
void do_instcmddesc (struct sockaddr_in *dest, char *arg, char *rest);
void do_fsd (struct sockaddr_in *dest, char *arg, char *rest);
void do_master (struct sockaddr_in *dest, char *arg, char *rest);
void do_username (struct sockaddr_in *dest, char *arg, char *rest);
void do_starttls (struct sockaddr_in *dest, char *arg, char *rest);

/* ACL structure */
typedef struct {
        char    *name;
        unsigned int    addr;
        unsigned int    mask;
        void    *next;
}       acltype;

/* ACCESS structure */
typedef struct {
	int	action;
	int	level;
	char	*aclname;
	char	*password;
	void	*next;
}	acctype;

/* structure for the linked list of each UPS that we track */
typedef struct {
	char	*fn;
	int	shmid;
	char	*name;
	itype	*info;
	itype	*shared_info;
	size_t	info_size;
	int	fd;
	int	sock_fd;
	int	stale;

	ino_t	st_ino;
	off_t	st_size;

#ifdef HAVE_SHMAT
	struct	shmid_ds shmbuf;
#endif
	int	numinfo;
	int	numlogins;
	int	fsd;		/* forced shutdown in effect? */
	int	retain;
	void	*next;
}	upstype;

/* prototypes from upsd.c */

const char *instcmdname(int cmdnum);
int checkacl(const char *aclname, const struct sockaddr_in *addr);
void addups(char *fn, char *name);
void addacl(char *aclname, char *ipblock);
void addaccess(const char *action, char *level, char *aclname, char *password);
upstype *findups(const char *upsname);
void redefine_ups(char *fn, char *name);
void kick_login_clients(char *upsname);

/* prototypes from user.c: user handling functions */

void user_load(void);
int user_checkinstcmd(struct sockaddr_in *ip, char *username, char *password,
                      int cmd);
int user_checkaction(struct sockaddr_in *ip, char *username, char *password,
                     char *action);

extern int upslog_flags;

/* map commands onto signals */

#define SIGCMD_STOP	SIGTERM
#define SIGCMD_RELOAD	SIGHUP

/* Linux doesn't have MAP_NOSYNC, but it's the default, so... */

#ifndef MAP_NOSYNC
#define MAP_NOSYNC 0
#endif

/* Linux libc5 doesn't have MAP_FAILED */

#ifndef MAP_FAILED
#define MAP_FAILED (void *) -1
#endif

#endif	/* STANDALONE */
#endif	/* UPSD_H_SEEN */