/* virt-hostinfo * Copyright (C) 2009 Red Hat Inc. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HOSTINFOD_H #define HOSTINFOD_H #include #include #include #include #include #include enum guest_state { guest_state_connecting, /* Connecting to socket. */ guest_state_request, /* Waiting or reading the request. */ guest_state_reply, /* Sending the reply. */ guest_state_dead /* Connection is dead. */ }; struct guest_description { int counter; apr_pool_t *pool; /* Pool for lifetime of guest connection. */ const char *name; /* "driver-name" */ const char *sock_path; /* Full path to socket. */ int sock; /* Real socket. */ apr_socket_t *aprsock; /* APR socket. */ apr_pollfd_t pollfd; /* APR poll descriptor. */ enum guest_state state; /* State of the connection. */ /* Increments every time guest does something bad, decremented once per min */ unsigned penalty; time_t last_penalty_decr; unsigned request_max; /* Max. length of request buffer. */ unsigned request_posn; /* Position in request buffer. */ char *request; /* Request buffer. */ unsigned reply_alloc; /* Allocated for reply buffer. */ unsigned reply_size; /* Size used in reply buffer. */ unsigned reply_posn; /* Position in reply buffer. */ char *reply; /* Reply buffer. */ }; /* main.c */ extern const char *conf_file; extern char *socket_dir; extern char *guests_file; extern int verbose; extern int verbose_set_on_cmdline; extern int foreground; extern int foreground_set_on_cmdline; extern int messages_to_stderr; extern apr_pool_t *pool; /* pool for global memory allocation */ /* error.c */ extern void init_syslog (void); extern void error (const char *fs, ...) __attribute__((format (printf,1,2))); extern void perrorf (const char *fs, ...) __attribute__((format (printf,1,2))); extern void warning (const char *fs, ...) __attribute__((format (printf,1,2))); extern void pwarningf (const char *fs, ...) __attribute__((format (printf,1,2))); extern void debug (const char *fs, ...) __attribute__((format (printf,1,2))); extern void message (const char *fs, ...) __attribute__((format (printf,1,2))); extern void paprerror (apr_status_t r, const char *fs, ...) __attribute__((format (printf,2,3))); /* configuration.c */ extern void read_main_conf_file (void); /* monitor_sockets.c */ extern int sockets_inotify_fd; extern void monitor_socket_dir (void); /* commands.c */ extern void execute_command (time_t now, struct guest_description *hval, const char *command); #endif /* HOSTINFOD_H */