/***************************************************************************
 * DBS: Distributed Benchmark System
 * Copyright (c) 1995, 1996, 1997 Yukio Murayama
 * Copyright (c) 1995, 1996, 1997 Nara Institute of Science and Technology
 * All rights reserved.
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided only with the following
 * conditions are satisfied:
 *
 * 1. Both the copyright notice and this permission notice appear in
 *    all copies of the software, derivative works or modified versions,
 *    and any portions thereof, and that both notices appear in
 *    supporting documentation.
 * 2. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgement:
 *      This product includes software developed by Nara Institute of 
 *      Science and Technology and its contributors.
 * 3. Neither the name of Nara Institute of Science and Technology nor 
 *    the names of its contributors may be used to endorse or promote 
 *    products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND NARA 
 * INSTITUTE OF SCIENCE AND TECHNOLOGY DISCLAIMS ANY LIABILITY OF 
 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF 
 * THIS SOFTWARE. ALSO, THERE IS NO WARRANTY IMPLIED OR OTHERWISE, 
 * NOR IS SUPPORT PROVIDED.
 *
 * Feedback of the results generated from any improvements or
 * extensions made to this software would be much appreciated.
 * Any such feedback should be sent to:
 *
 *  Yukio Murayama
 *  E-mail:  <yukio-m@is.aist-nara.ac.jp>
 *  URL:     <http://shika.aist-nara.ac.jp/member/yukio-m/index.html>
 *  Address: Graduate School of Information Science, 
 *           Nara Institute of Science and Technology,
 *           Takayama 8916-5, Ikoma, Nara, Japan
 *
 * Nara Institute of Science and Technology has the rights to 
 * redistribute these changes.
 ***************************************************************************/
/*****************************************************************
 * Distributed Benchmark System
 * RECORD Header File
 * $Revision: 1.11 $
 * $Date: 1997/07/11 00:54:09 $
 * $Author: yukio-m $
 *****************************************************************/

#include <sys/types.h>
/*#include <sys/socket.h>*/
#include <sys/socketvar.h>
/*#define PRUREQUESTS*/

#if !defined(sony_news) && !defined(__linux__)
#include <sys/protosw.h>
#endif

#include <sys/file.h>

#include <net/route.h>
#include <net/if.h>

#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>

#ifndef __linux__
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/tcpip.h>
/*#define TCPSTATES*/
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_seq.h>
/*#define TCPTIMERS*/
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
/*#define TANAMES*/
#include <netinet/tcp_debug.h>
#endif

/*#include <arpa/inet.h>*/

#ifdef __linux__
#define TA_INPUT   0
#define TA_OUTPUT  1
#define TA_USER    2
#define TA_RESPOND 3
#define TA_DROP    4
#endif

/***** Time Record Structure *****/
struct record_d {
    struct timeval tv;
    int    packet_no;
    int    packet_size;
};

struct record {
    struct record_d *d;
    int    n;
    int    size;
};

struct tcp_trace {
    struct tcp_debug *d;
    int     n;
    caddr_t tcp_addr;
    int     size;
    int     memf;
    int     p;
};

/***** sendrecv.c *****/
int tcp_send __P((struct dbsd_param * volatile cmd, char *data, struct record *rd, struct record *rd2, struct tcp_trace *  volatile rt));
int tcp_recv __P((struct dbsd_param * volatile cmd, char *data, struct record *rd, struct record *rd2, struct tcp_trace *  volatile rt));
int udp_send __P((struct dbsd_param * volatile cmd, char *data, struct record *rd));
int udp_recv __P((struct dbsd_param * volatile cmd, char *data, struct record *rd));

/***** tcp_trace.c *****/
void record_tcp_trace __P((struct tcp_trace *rt, struct assosiation *a, int act));
void record_tcp_trace2 __P((struct tcp_trace *rt, struct assosiation *a, int act));
void init_so_debug    __P((struct tcp_trace *rt, struct assosiation *a, int act, int flg));





syntax highlighted by Code2HTML, v. 0.9.1