/*
 * netrecon.h: Header file for netrecon program.
 * License   : See COPYING file for details.
 */

#ifndef _NETRECON_H
#define _NETRECON_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <pcap.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#ifndef NETBSD
#include <net/ethernet.h>
#endif
#include <netinet/ip_icmp.h>
#include <netinet/udp.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 <getopt.h>
#include <netinet/udp.h>
#include <net/if.h>
#ifdef NETBSD
#include <net/if_ether.h>
#endif
#include <sys/ioctl.h>
#include <time.h>

/* TCP v4 header */
struct tcphdr4 {
    uint16_t th_sport;
    uint16_t th_dport;
    uint32_t th_seq;
    uint32_t th_ack;
#  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 th_win;
    uint16_t check;
    uint16_t urg_ptr;
};

#define ARP_REQUEST 1
#define ARP_RERPLY 2

typedef struct arphdr {
    u_int16_t hwtype;
    u_int16_t proto;
    u_char hwlen;
    u_char proto_len;
    u_int16_t opcode;
    u_char sender_hwaddr[6];
    u_char sender_ipaddr[4];
    u_char target_hwaddr[6];
    u_char target_ipaddr[4];
} arphdr_t;

typedef struct ether_header eth_hdr; /* Ethernet header */
typedef struct ip ip4ip;             /* IP data         */
typedef struct tcphdr4 tcp_hdr;      /* TCP header      */

#define PORTMAX 65535
#define IPV4CW 16
#define PORT_THRESHOLD_DEFAULT 16
#define NPOLLS_DEFAULT 64

#define DEFAULT_START_PORT 1    /* default starting port to scan */
#define DEFAULT_END_PORT 1024   /* default ending port to scan */
#define DEFAULT_INET_TIMEOUT 2  /* default AF_INET connect timeout */

/* XXX temp */
char * pcap_dev; /* For scan_passive and netdump */

struct setdata {
	short int xflag;       /* Do ports beyond 1024 flag (or eXtra) */
	short int vflag;       /* Verbosity flag */
	u_short port_start;    /* Scan connect starting port */
	u_short port_end;      /* Scan connect last port */
	int subnet_start;      /* Scan connect subnet start */
	int subnet_end;        /* Scan connect subnet end=start not specified */
	short int cflag;       /* Scan Connect full TCP Connect for every scan */
	short int inet_timeo;  /* Scan connect timeout in seconds */
	short int inet_utimeo; /* Scan connect timeout useconds */
	char *start_vector;    /* Scan connect starting subnet vector pointer */
	char addr[1024];       /* Scan connect raw start address from stdin */
	char *portstring;      /* Scan connect, if only portchecking use this */
	char *socktype;        /* Scan connect socket type */
	char *pcap_filter;     /* Pcap filter for passive scan and netdump */
	char *pcap_if;         /* Pcap interface for passive scan and netdump */
	int pcap_polls;        /* Pcap polls for passive scan and netdump */
	int proto_threshold;   /* Passive protocol hit/count threshold */
	int arpflag;           /* Netdump arpflag */
	int decode;            /* Netdump decode flag */
	int isv6;              /* Scan connect ipv6 flag */
} sdata;

struct setdata *sd = &sdata;

#endif /* _NETRECON_H */


