2011-11-29 13:47:48 +04:00
|
|
|
#ifndef YASND_H
|
|
|
|
#define YASND_H
|
|
|
|
|
|
|
|
// Debug verbosity
|
|
|
|
#define DEBUG_BASE 1
|
|
|
|
#define DEBUG_ALL 2
|
|
|
|
|
2011-12-19 18:35:14 +04:00
|
|
|
// IPC message types
|
|
|
|
#define SMS_SEND_TYPE 1
|
|
|
|
#define SMS_RECEIVE_TYPE 2
|
|
|
|
|
|
|
|
#include <unistd.h>
|
2011-12-19 11:08:19 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2011-12-14 18:13:42 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
2011-12-14 17:52:13 +04:00
|
|
|
#include <signal.h>
|
2011-11-29 13:47:48 +04:00
|
|
|
#include <stdbool.h>
|
2011-11-30 16:21:34 +04:00
|
|
|
#include <string.h>
|
2011-12-14 17:52:13 +04:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <sched.h>
|
2011-11-29 13:47:48 +04:00
|
|
|
|
2011-12-14 17:52:13 +04:00
|
|
|
// Structure, that described single checked host
|
2011-11-29 13:47:48 +04:00
|
|
|
typedef struct {
|
|
|
|
char* hostname; // address of host
|
2011-12-19 15:19:18 +04:00
|
|
|
int lpt_pin; // pin on LPT control circuit for reset
|
2011-11-29 13:47:48 +04:00
|
|
|
pid_t helper_pid; // pid of helper('pinger') child process
|
|
|
|
int fail_count; // how many times in a row host was unreachable
|
2011-12-12 14:31:18 +04:00
|
|
|
bool alert_sent; // variable, that changed when host goes online/offline
|
2011-12-19 17:02:42 +04:00
|
|
|
bool reaction_obtained; // variable, that changed when reaction on it's behaviour obtained
|
2011-11-29 13:47:48 +04:00
|
|
|
} host_decl;
|
|
|
|
|
2011-12-14 17:52:13 +04:00
|
|
|
// Structure, that described single IPC message
|
|
|
|
typedef struct {
|
|
|
|
long mtype; /* Message type */
|
|
|
|
char mtext[100];
|
|
|
|
} mymsgbuf;
|
|
|
|
|
|
|
|
// External functions
|
|
|
|
extern void log_event(const char *message);
|
|
|
|
extern void log_debug(const char *message,int verbosity);
|
|
|
|
extern void* allocate_memory(int bytes);
|
|
|
|
extern bool gammu_init();
|
|
|
|
extern bool gammu_send_sms(const char* message);
|
2011-12-20 17:02:34 +04:00
|
|
|
extern bool gammu_read_sms();
|
2011-12-14 17:52:13 +04:00
|
|
|
extern void ipc_init();
|
2011-12-14 18:13:42 +04:00
|
|
|
extern void ipc_free();
|
2011-12-14 17:52:13 +04:00
|
|
|
extern int send_message(int qid, mymsgbuf* qbuf);
|
2011-12-19 11:08:19 +04:00
|
|
|
extern void gammu_free();
|
2011-12-14 17:52:13 +04:00
|
|
|
|
2011-11-30 16:21:34 +04:00
|
|
|
// External variables
|
2011-11-29 13:47:48 +04:00
|
|
|
extern int hosts_count; // count of hosts
|
|
|
|
extern int debug_flag;
|
2011-12-12 13:28:07 +04:00
|
|
|
extern char* recipient_number;
|
2011-12-12 14:10:05 +04:00
|
|
|
extern char* phone_device; // phone device for gammu, for example: "/dev/ttyACM0"
|
|
|
|
extern char* phone_model; // gammu phone model, for example: "at"
|
|
|
|
extern char* phone_connection; // gammu phone connection type, for example: "at"
|
2011-12-19 18:35:14 +04:00
|
|
|
extern bool sms_send_enable;
|
|
|
|
extern int qid;
|
2011-11-29 13:47:48 +04:00
|
|
|
|
|
|
|
#endif
|