/*

Part of the TCP Testing Tool (ttt).

Include files used by the other C files.

Eloy Paris <elparis@cisco.com>

$Id: includes.h,v 1.5 2003/07/15 18:01:31 peloy Exp $

*/

#ifndef _INCLUDES_H
#define _INCLUDES_H

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <netdb.h>
#include <time.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <openssl/md5.h>
#include <getopt.h>

#include "byteorder.h" /* Stolen from Samba */

#define VERSION "1.3"

/* To keep track of data to send or receive */
struct payload {
	char *data;
	unsigned len;
};

/* For command-line options */
struct options {
	/* General options */
	int count;
	int delay;
	int flood_count;

	/* IP-related options */
	struct in_addr source_ip;
	struct in_addr destination_ip;
	struct u_int16_spec *ip_id;
	struct u_int8_spec *ip_ttl;
	struct u_int8_spec *ip_tos;

	/* TCP-related options */
	struct u_int16_spec *src_port;
	struct u_int16_spec *dst_port;
	struct u_int32_spec *sequence_number;
	struct u_int32_spec *ack_seq;
	struct u_int16_spec *window;
	struct u_int16_spec *urg_ptr;
	int urg;
	int ack;
	int psh;
	int rst;
	int syn;
	int fin;
	struct payload payload;
	char *md5_secret;
	struct u_int16_spec *mss;
	struct u_int8_spec *wscale;
	int no_cksum;
};

/* From ttt.c */
extern char *program_name;

/* From util.c */
char *copy_argv(char **);
void dump(const unsigned char *data, unsigned len);
void error(int, const char *, ...);
void debug(const char *fmt, ...);
void read_payload(char *, struct payload *);
void read_payload_from_stdin(struct payload *);

/* From options.c */
extern struct options options;

void process_options(int argc, char **argv);

/* From numbers.c */
enum {
	NUMTYPE_FIXED,
	NUMTYPE_RANGE,
	NUMTYPE_RANDOM,
	NUMTYPE_INCR,
	NUMTYPE_DECR
};

struct u_int8_spec {
	u_int8_t current;
	int type;
	u_int8_t range_start;
	u_int8_t range_end;
};

struct u_int16_spec {
	u_int16_t current;
	int type;
	u_int16_t range_start;
	u_int16_t range_end;
};

struct u_int32_spec {
	u_int32_t current;
	int type;
	u_int32_t range_start;
	u_int32_t range_end;
};

struct u_int8_spec *u_int8_init(const char *number_spec);
u_int8_t u_int8_next(struct u_int8_spec *spec);

struct u_int16_spec *u_int16_init(const char *number_spec);
u_int16_t u_int16_next(struct u_int16_spec *spec);

struct u_int32_spec *u_int32_init(const char *number_spec);
u_int32_t u_int32_next(struct u_int32_spec *spec);

/* From packet-factory.h */
int send_segment(void);

#endif /* _INCLUDES_H */

