
/* $Id: nw.h,v 1.26 2009/04/16 16:43:02 jayrfink Exp $ */

/* Netward Header file LICENSE: See COPYING for details */
#ifndef _NW_H
#define _NW_H

#define _BSD_SOURCE 1

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in_systm.h>
#include <pcap.h>
#ifndef NETBSD
#include <net/ethernet.h>
#endif
#include <netinet/in.h>
#include <netinet/ip.h>
#include <signal.h>
#include <math.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <semaphore.h>
#include <fcntl.h>
#include <getopt.h>
#include <errno.h>
#include <netinet/udp.h>
#include <net/if.h>
#ifdef NETBSD
#include <net/if_ether.h>
#endif
#include <sys/ioctl.h>
#include <time.h>

#include "utils.h"

#define PACKAGE "netward"
#define CFGFILE "/usr/local/etc/netward.conf"
#define LOGFILE "/var/log/netward.log"
#define DEFAULT_FILTER "portrange 2-1024 and not port 22"
#define DEFAULT_INTERVAL 30
#define DEFAULT_POLLS 32 
#define DEFAULT_THRESHOLD 16

char * dev; /* Ethernet Device */
int vflag;  /* Verbose flag */
int threshold; 
char * logfile;
char * configfile;

void pktinit    (char *, int);
void pkthandler (u_char *, const struct pcap_pkthdr *, const u_char *);

/* TCP header */
struct tcphdr {
        uint16_t source;
        uint16_t dest;
        uint32_t seq;
        uint32_t ack_seq;
#  if __BYTE_ORDER == __LITTLE_ENDIAN
        uint16_t res1:4;
        uint16_t doff:4;
        uint16_t fin:1;
        uint16_t syn:1;
        uint16_t rst:1;
        uint16_t psh:1;
        uint16_t ack:1;
        uint16_t urg:1;
        uint16_t res2:2;
#  elif __BYTE_ORDER == __BIG_ENDIAN
        uint16_t doff:4;
        uint16_t res1:4;
        uint16_t res2:2;
        uint16_t urg:1;
        uint16_t ack:1;
        uint16_t psh:1;
        uint16_t rst:1;
        uint16_t syn:1;
        uint16_t fin:1;
#  else
#   error "Adjust your <bits/endian.h> defines"
#  endif
        uint16_t window;
        uint16_t check;
        uint16_t urg_ptr;
};

typedef struct ether_header eth_hdr; /* Ethernet header */
typedef struct ip ip_hdr;            /* IP header       */

#endif

