1/* 2 * OpenVPN -- An application to securely tunnel IP networks 3 * over a single TCP/UDP port, with support for SSL/TLS-based 4 * session authentication and key exchange, 5 * packet encryption, packet authentication, and 6 * packet compression. 7 * 8 * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License version 2 12 * as published by the Free Software Foundation. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program (see the file COPYING included with this 21 * distribution); if not, write to the Free Software Foundation, Inc., 22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 */ 24 25#ifndef STATUS_H 26#define STATUS_H 27 28#include "interval.h" 29 30//Sam.B 2013/10/31 31#define TYPEDEF_BOOL //will skip in typedefs.h 32#include <unistd.h> 33#include <bcmnvram.h> 34#include "shared.h" 35 36#define EXIT_GOOD 0 37#define EXIT_ERROR 1 38#define ADDR_CONFLICTED 2 39#define ROUTE_CONFLICTED 3 40#define RUNNING 4 41#define SSLPARAM_ERROR 5 42#define SSLPARAM_DH_ERROR 6 43#define RCV_AUTH_FAILED_ERROR 7 44 45#define ST_EXIT 0 46#define ST_INIT 1 47#define ST_RUNNING 2 48#define ST_ERROR -1 49 50#define ERRNO_DEFAULT 0 51#define ERRNO_IP 1 52#define ERRNO_ROUTE 2 53#define ERRNO_SSL 4 54#define ERRNO_DH 5 55#define ERRNO_AUTH 6 56 57void update_nvram_status(int flag); 58int current_addr(in_addr_t addr); 59int current_route(in_addr_t network, in_addr_t netmask); 60//Sam.E 2013/10/31 61 62/* 63 * virtual function interface for status output 64 */ 65struct virtual_output { 66 void *arg; 67 unsigned int flags_default; 68 void (*func) (void *arg, const unsigned int flags, const char *str); 69}; 70 71static inline void 72virtual_output_print (const struct virtual_output *vo, const unsigned int flags, const char *str) 73{ 74 (*vo->func) (vo->arg, flags, str); 75} 76 77/* 78 * printf-style interface for inputting/outputting status info 79 */ 80 81struct status_output 82{ 83# define STATUS_OUTPUT_READ (1<<0) 84# define STATUS_OUTPUT_WRITE (1<<1) 85 unsigned int flags; 86 87 char *filename; 88 int fd; 89 int msglevel; 90 const struct virtual_output *vout; 91 92 struct buffer read_buf; 93 94 struct event_timeout et; 95 96 bool errors; 97}; 98 99struct status_output *status_open (const char *filename, 100 const int refresh_freq, 101 const int msglevel, 102 const struct virtual_output *vout, 103 const unsigned int flags); 104 105bool status_trigger_tv (struct status_output *so, struct timeval *tv); 106bool status_trigger (struct status_output *so); 107void status_reset (struct status_output *so); 108void status_flush (struct status_output *so); 109bool status_close (struct status_output *so); 110void status_printf (struct status_output *so, const char *format, ...) 111#ifdef __GNUC__ 112#if __USE_MINGW_ANSI_STDIO 113 __attribute__ ((format (gnu_printf, 2, 3))) 114#else 115 __attribute__ ((format (__printf__, 2, 3))) 116#endif 117#endif 118 ; 119 120bool status_read (struct status_output *so, struct buffer *buf); 121 122static inline unsigned int 123status_rw_flags (const struct status_output *so) 124{ 125 if (so) 126 return so->flags; 127 else 128 return 0; 129} 130 131#endif 132