/*
 *  File: sadoor.h
 *  Author: Claes M. Nyberg <md0claes@mdstud.chalmers.se>
 *  Description: SAdoor main header file.
 *  Version: 1.0
 *  Date: Mon Mar 17 20:11:03 CET 2003
 *
 *  Copyright (c) 2003 Claes M. Nyberg <md0claes@mdstud.chalmers.se>
 *  All rights reserved, all wrongs reversed.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. The name of author may not be used to endorse or promote products
 *     derived from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 *  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 *  THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _SADOOR_H
#define _SADOOR_H

#include <syslog.h>
#include "sapc.h"
#include "sadc.h"
#include "utils.h"
#include "log.h"
#include "capture.h"
#include "net.h"
#include "bfish.h"
#include "replay.h"

#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif 

#ifndef VERSION
#define VERSION "1.0-DAEMON"
#endif

/* Default UMASK */
#define SADOOR_UMASK		077

/* Default config directory */
#ifndef SADOOR_CONFIG_DIR
#define SADOOR_CONFIG_DIR     "/etc/sadoor"
#endif

/* Config file */
#ifndef SADOOR_CONFIG_FILE
#define SADOOR_CONFIG_FILE   SADOOR_CONFIG_DIR "/" "sadoor.conf"
#endif

/* Packet config */
#ifndef SADOOR_PKTCONFIG_FILE
#define SADOOR_PKTCONFIG_FILE   SADOOR_CONFIG_DIR "/" "sadoor.pkts"
#endif

/* Key file */
#ifndef SADOOR_KEY_FILE
#define SADOOR_KEY_FILE      SADOOR_CONFIG_DIR "/" "sadoor.key"
#endif

/* Private logfile */
#ifndef SADOOR_PRIVLOG
#define SADOOR_PRIVLOG		 SADOOR_CONFIG_DIR "/" "sadoor.log"
#endif

/* SAdoor databse file generated by 'mksadb(8)' */
#ifndef SADOOR_SADBFILE
#define SADOOR_SADBFILE		SADOOR_CONFIG_DIR "/" "sadoor.db"
#endif

/* Name of file holding our PID */
#ifndef SADOOR_PID_FILE
#define SADOOR_PID_FILE		"/var/run/sadoor.pid"
#endif

/* Default syslog facility */
#ifndef SADOOR_SYSLOG_FACILITY
#define SADOOR_SYSLOG_FACILITY	LOG_DAEMON
#endif

/* Default syslog priority */
#ifndef SADOOR_SYSLOG_PRIORITY
#define SADOOR_SYSLOG_PRIORITY	LOG_INFO
#endif

/* Default shell (if program is missing in config file) */
#define SADOOR_SHELL		 "/bin/sh"

/* Name of environ variable(s) to set on connect */
#define SADOOR_ENV_CLIENTADDR		"SADOOR_CLIENT"
#define SADOOR_ENV_CLIENTNAME		"SADOOR_CLIENT_HOSTNAME"

/* daemon.c */
extern int go_daemon(void);

/* conn.c */
extern int conn_bindsock(long, u_short, struct sockaddr_in *);
extern int conn_accept(int, time_t, u_long, u_short);
extern int conn_connect(u_long, u_short);

/* connloop.c */
extern int handle_connection(int, struct bfish_key *);
#endif /* _SADOOR_H */
