/* command to send a packet to a host ... the idea is to send fragments */

#ifndef lint
static char *rcsid_log_c = "$Header: log.c,v 1.2 87/07/16 01:50:11 jon Exp $";
#endif	lint

#include <types.h>
#include <sys.h>
#include "const.h"
#include "defs.h"
#include "macs.h"
#include "net.h"
#include "ext.h"
#undef NULL
#include "../../lib.vax/stdio.h"
#include "../opcon/opcon.h"
#include "gw/in/in.h"
#include "gw/in/inext.h"

/* Interface to command interpreter. */

void hose_cmd ();

static subcommand test_scmd[] = {
    { "hose", "Hose a host", hose_cmd, 0 },
    { NULL, NULL, NULL, 0},
};

command test_cmd =
    { NULL, "test", "Gateway testing", test_scmd };

int test_packet_len = 4096; /* patch with DDT */

hose_cmd(devp, arg, jcl)
dct *devp;
int arg;
char *jcl;
{
    inaddr dst;
    reg iorb *iob;
    inia *inina = iniatlst[0];  /* steal one of our address from here */

    if (jcl == NULL) {
 	fprintf(devp, "Usage: hose host\n");
	return;
      }

    dst.i_long = getdmch(jcl);
    if (dst.i_long == 0) {
	fprintf(devp, "Bad address %s.\n", jcl);
	return;
    }

    if ((iob = mkiorb(getbuf())) == NULL) {
	niflog(L_ERRC)
	  dolog("TEST can't get buffer.\n");
	return;
    }
	
    mkinpkt(iob, inina->inia_addr, &dst, INEGP /* who cares? */, test_packet_len);

    dolog("TEST sending packet w/len %d to %d.%d.%d.%d from %d.%d.%d.%d\n", 
	  test_packet_len, mksina(&dst), mksina (inina->inia_addr));

    in_frg (iob, nets);
}

