Beispiel #1
0
/* Modify or displace interface trace flags */
int
dotrace(
int argc,
char *argv[],
void *p)
{
	struct iface *ifp;
	struct tracecmd *tp;

	if(argc < 2){
		for(ifp = Ifaces; ifp != NULL; ifp = ifp->next)
			showtrace(ifp);
		return 0;
	}
	if((ifp = if_lookup(argv[1])) == NULL){
		printf("Interface %s unknown\n",argv[1]);
		return 1;
	}
	if(argc == 2){
		showtrace(ifp);
		return 0;
	}
	/* MODIFY THIS TO HANDLE MULTIPLE OPTIONS */
	if(argc >= 3){
		for(tp = Tracecmd;tp->name != NULL;tp++)
			if(strncmp(tp->name,argv[2],strlen(argv[2])) == 0)
				break;
		if(tp->name != NULL)
			ifp->trace = (ifp->trace & ~tp->mask) | tp->val;
		else
			ifp->trace = htoi(argv[2]);
	}
	if(ifp->trfp != NULL && ifp->trfp != stdout){
		/* Close existing trace file */
		fclose(ifp->trfp);
	}
	ifp->trfp = stdout;
	if(argc >= 4){
		if((ifp->trfp = fopen(argv[3],APPEND_TEXT)) == NULL){
			printf("Can't write to %s\n",argv[3]);
			ifp->trfp = stdout;
		}
	}
	showtrace(ifp);
	return 0;
}
Beispiel #2
0
static int jh_build_table (char *ptr, char *ifacename)
{
	char *orig_ptr = ptr;
	struct iface *ifp;
	struct lq *lp;
	int heard = 0;

	if (*ifacename)
		cur_iface = if_lookup (ifacename);

	if (cur_iface == (struct iface*)0)
		cur_iface = Ifaces;

	ptr += sprintf (ptr, "%s", jh_str1);

	for (lp = Lq; lp != NULLLQ; lp = lp->next)
	{
		if (lp->iface != cur_iface)
			continue;

		ptr = jh_stations_option (ptr, lp);

		heard = 1;
	}

	if (!heard)
		ptr = jh_stations_option (ptr, (struct lq*)0);

	ptr += sprintf (ptr, "%s", jh_str2);

	for (ifp = Ifaces; ifp != NULLIF; ifp = ifp->next)
	{
		if(ifp->type != CL_AX25 || !(ifp->flags & LOG_AXHEARD))
			continue;

		ptr = jh_interface_option (ptr, ifp->name, (ifp == cur_iface));
	}

	ptr += sprintf (ptr, "%s", jh_str3);

	ptr += sprintf (ptr, "%s", cur_iface->descr);

	ptr += sprintf (ptr, "%s", jh_str4);

	return (ptr - orig_ptr);
}
Beispiel #3
0
int fldigi_attach (int argc, char **argv, void *p)
{
	struct iface *ifp;

	if ((ifp = if_lookup (argv[1])) == NULLIF)
	{
		tprintf (Badinterface,argv[1]);
		return 1;
	}

	fldigiport = j2strdup (argv[1]);

	fldigi_command (ifp, "\xC0\x06KISSRAW:ON\xC0");

	// system ("/jnos/rte/send.pl");

	return 0;
}
Beispiel #4
0
int ethertap_attach(int argc, char *argv[], void *p)
{

  char *ifname;
  char devname[1024];
  int fd;
  struct edv_t *edv;
  struct iface *ifp;

  ifname = argv[1];
  if (if_lookup(ifname)) {
    printf("Interface %s already exists\n", ifname);
    return -1;
  }
  strcpy(devname, "/dev/");
  strcat(devname, ifname);
  fd = open(devname, O_RDWR);
  if (fd < 0) {
    printf("%s: %s\n", devname, strerror(errno));
    return -1;
  }
  ifp = (struct iface *) callocw(1, sizeof(struct iface));
  ifp->name = strdup(ifname);
  ifp->addr = Ip_addr;
  ifp->broadcast = 0xffffffffUL;
  ifp->netmask = 0xffffffffUL;
  ifp->mtu = 0xffff;
  setencap(ifp, "None");
  edv = (struct edv_t *) malloc(sizeof(struct edv_t));
  edv->fd = fd;
  ifp->edv = edv;
  ifp->send = ethertap_send;
  on_read(fd, ethertap_recv, (void *) ifp);
  ifp->next = Ifaces;
  Ifaces = ifp;
  return 0;
}
Beispiel #5
0
int ipip_attach(int argc, char *argv[], void *p)
{

  char *ifname = "ipip";
  int fd;
  int port = IP4_PTCL;
  int type = USE_IP;
  struct edv_t *edv;
  struct iface *ifp;
  struct sockaddr_in addr;

  if (argc >= 2) ifname = argv[1];

  if (if_lookup(ifname) != NULL) {
    printf("Interface %s already exists\n", ifname);
    return -1;
  }

  if (argc >= 3)
    switch (*argv[2]) {
    case 'I':
    case 'i':
      type = USE_IP;
      break;
    case 'U':
    case 'u':
      type = USE_UDP;
      break;
    default:
      printf("Type must be IP or UDP\n");
      return -1;
    }

  if (argc >= 4) port = atoi(argv[3]);

  if (type == USE_IP)
    fd = socket(AF_INET, SOCK_RAW, port);
  else
    fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (fd < 0) {
    printf("cannot create socket: %s\n", strerror(errno));
    return -1;
  }

  if (type == USE_UDP) {
    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = INADDR_ANY;
    addr.sin_port = htons(port);
    if (bind(fd, (struct sockaddr *) &addr, sizeof(addr))) {
      printf("cannot bind address: %s\n", strerror(errno));
      close(fd);
      return -1;
    }
  }

  ifp = (struct iface *) callocw(1, sizeof(struct iface));
  ifp->name = strdup(ifname);
  ifp->addr = Ip_addr;
  ifp->broadcast = 0xffffffffUL;
  ifp->netmask = 0xffffffffUL;
  ifp->mtu = MAX_FRAME;
  ifp->flags = NO_RT_ADD;
  setencap(ifp, "None");

  edv = (struct edv_t *) malloc(sizeof(struct edv_t));
  edv->type = type;
  edv->port = port;
  edv->fd = fd;
  ifp->edv = edv;

  ifp->send = ipip_send;
  on_read(fd, ipip_receive, (void * ) ifp);

  ifp->next = Ifaces;
  Ifaces = ifp;

  return 0;
}
Beispiel #6
0
int doaxui(int argc, char *argv[],void *p) {
char *cp;
char name[AXBUF];
char buf[256];
int i;
char tmpcall[AXALEN];
char tmpcall2[AXALEN];
struct session *sp;
struct mbuf *bp;
struct iface *axif,*ifc;
int first = 1;

	int goto_restart = 0, goto_done = 0;
  
	/* Check if this comes from console */
	if(Curproc->input != Command->input)
		return 1;

	/* Check to see if AXUI is already running. Only one copy at a time */
	if (Axui_sock != -1)	{
		tprintf("%s already running\n", Sestypes[AXUITNC]);
		return 1;
	}

	if(((axif = if_lookup(argv[1])) == NULLIF) || (axif->type != CL_AX25)) {
		tprintf("Iface %s not defined or not an AX25 type interface\n",argv[1]);
		return 1;
	}

	if (argc == 2 || setcall (tmpcall, argv[2]) == -1)
		memcpy (tmpcall, Ax25multi[IDCALL], AXALEN);
        if(argc > 3)  /* digis present? */
            if(connect_filt(argc,argv,tmpcall,axif) == 0)
                return 1;

	/* Now everything seems okay ! Get a session */
	if((sp = newsession("axui",AXUITNC,1)) == NULLSESSION) {
		j2tputs(TooManySessions);
		return 1;
	}

	while (1)
	{

/* restart: replace GOTO label with while loop */

	tprintf("%s%s session %u UI frames %s->%s on interface %s\n",
		(first) ? "" : "\n", Sestypes[sp->type],sp->num,
			pax25(buf, axif->hwaddr), pax25(name,tmpcall), axif->name);
	Axui_sock = Curproc->output;
	first = 0;
  
	/* Process whatever's typed on the terminal */
	while(recvline(Curproc->input,buf,sizeof(buf)-1) >= 0)
	{
		goto_restart = 0;	/* replaces GOTO label */
		goto_done = 0;		/* replaces GOTO label */

		if(buf[0] == '/')
		{
			rip (buf);
			cp = skipnonwhite(buf);  /* advance to first arg */
			cp = skipwhite(cp);

			/* process commands */
			switch(tolower(buf[1]))
			{
				case 'h':
				case '?':
						j2tputs("<Cmds>: /c call; /i iface; /q (to quit); /t (toggle timestamp)\n");
						goto_restart = 1;
						break;
				case 'c':
						if (argc > 3)
						{
							j2tputs(DigisUsed);
							break;
						}
						if (setcall (tmpcall2, cp) == -1)
							break;
						memcpy (tmpcall, tmpcall2, AXALEN);
						goto_restart = 1;
						break;
				case 'i':
						if (argc > 3)
						{
							j2tputs(DigisUsed);
							break;
						}
						if(((ifc = if_lookup(cp)) != NULLIF)
							&& (ifc->type == CL_AX25))
						{
							axif = ifc;
							goto_restart = 1;
						}
						else
							j2tputs ("<invalid interface>\n");
						break;
				case 'b':
				case 'e':
				case 'q':
						goto_done = 1;
						break;
				case 't':
						ui_timestamp = !ui_timestamp;
						break;
			}
			if (goto_done)	/* replaces GOTO 'done:' label */
				break;
			if (goto_restart)	/* replaces GOTO 'restart:' label */
				break;
		}
		else
		{
			i = strlen(buf);
			if((bp = alloc_mbuf(i)) == NULLBUF)
				break;

			/* unwritten protocol is that AX.25 lines end in \r, not \n.
			 * recvline will always return at least one character.  If the
			 * operater typed more than sizeof(buf) - 1 without eol,
			 * TOUGH! - K5JB
			 */
			buf[i - 1] = '\r';

			bp->cnt = i;	
			memcpy(bp->data,buf,(size_t)i);

			/* send it */
			(*axif->output)(axif, tmpcall, axif->hwaddr, PID_NO_L3, bp);
		}
		usflush(Curproc->output);
	}

	if (!goto_restart)	/* means the recv_line while naturally exited */
		break;			/* this covers the goto_done cases nicely */

	}	/* end of GOTO while loop */

/* done: */
	if (argc > 3)	/* remove digi route added by connect_filt */
		ax_drop(tmpcall, axif, 0);
	Axui_sock = -1;
	tprintf("\n%s session %u closed: EOF\n", Sestypes[sp->type],sp->num);
	keywait(NULLCHAR,1);
	freesession(sp);
	return 0;
}
Beispiel #7
0
static int dohfddsrv (int argc, char *argv[], void *p)
{
	static struct proc *hfsrvp = (struct proc*)0;

	if (argc == 3)
	{
		if (!stricmp (argv[2], "start"))
		{
			char **pargv = (char**)callocw (3, sizeof(char*));

			log (-1, "start hfdd server on port [%s]", argv[1]);

			pargv[0] = "c";
			pargv[1] = j2strdup (argv[1]);
			pargv[2] = "bbs";

			hfsrvp = newproc ("hfddsrv", 2048, hfddsrv2, 3, pargv, (void*)0, 1);
		}
		/* 09Mar2005, Maiko, Kick option incase server goes into limbo */
		else if (!stricmp (argv[2], "kick"))
		{
			log (-1, "kick hfdd server on port [%s]", argv[1]);
			alert (hfsrvp, EABORT);
		}
		/* 23Sep2006, Maiko, Unproto option for sysop to FEC at will,
		 * note this is a bit of a kludge in that we have to pass the
		 * name of the interface (will fix that later) ...
		 */
		else if (!stricmp (argv[2], "unproto"))
		{
			struct iface *ifp;

			log (-1, "sending unproto (FEC) beacon");

			/* 20Mar2007, Maiko, Added KAM hostmode */
   			if ((ifp = if_lookup (argv[1])) != NULLIF)
			{
				if (hfdd_is_dxp (ifp->name))
					dxp_FEC (ifp->dev, 1);
				else if (hfdd_is_kam (ifp->name))
					kam_FEC ();
				/* 16Apr2007, Maiko, Added FEC code for SCS modem */
				else if (hfdd_is_ptc (ifp->name))
					ptc_FEC ();
				/* 20Sepr2008, Maiko, Added FEC code for PK232 modem */
				else if (hfdd_is_pk232 (ifp->name))
					pk232_FEC (ifp->dev);
			}
		}
		/*
		 * 14Mar2007, Maiko, Utility to EXIT hostmode incase the
		 * TNC seems to get into the occasional I AM IN HOSTMODE
		 * but I AM NOT RESPONDING type of situation. Doing this
		 * kick will force the code to recognize NOT IN HOSTMODE
		 * status, and reinitialize the TNC (KAM).
		 */
		else if (!stricmp (argv[2], "exit"))
		{
			struct iface *ifp;

   			if ((ifp = if_lookup (argv[1])) != NULLIF)
			{
				/* 15May07, Now have hostmode exit for PTC-IIusb modem */
				if (hfdd_is_ptc (ifp->name))
					ptc_exit_hostmode (ifp->dev);
				/* 23Apr08, Maiko, Supporting PK232 now */
				else if (hfdd_is_pk232 (ifp->name))
					pk232_exit_hostmode (ifp->dev);
				else
					kam_exit_hostmode (ifp->dev);
			}
		}
	}
	else
		tprintf ("use: hfdd server [iface] [start|stop]\n"); 

	return 0;
}
Beispiel #8
0
int hfddsrv (int argc, char **argv, void *p)
{
	struct session spdummy, *sp = &spdummy;
	struct iface *ifp;
	struct asy *ap;
	char *ifn;

	/* 07Apr2010, Maiko, Winmor sound card tnc support */
	int notwinmor = 1;

#ifdef WINMOR
	ifp = &ifdummy;
	ifdummy.name = j2strdup ("winmor");
#endif
	/*
	 *  HFDD_PARAMS	hfddp;
	 *
	 * wonder if this getting destroyed when the client terminates is
	 * causing crashes, since a process might still be alive that expects
	 * this. Make it a static for now to see if that solves crashing !
	 */

	if (p != (void*)0)
		sp = (struct session*)p;

#ifdef WINMOR
	/* 07Apr2010, Maiko, No physical TTY for the WINMOR device */
	notwinmor = strcmp ("mor", argv[1]);
#endif

	if (notwinmor)
	{
		if (hfdd_debug)
			log (-1, "argc %d iface %s call %s", argc, argv[1], argv[2]);

    	if ((ifp = if_lookup (argv[1])) == NULLIF)
		{
        	tprintf (Badinterface, argv[1]);
        	return 1;
    	}

    	ap = &Asy[ifp->dev];
    	if (ifp->dev >= ASY_MAX || ap->iface != ifp)
		{
        	tprintf ("Interface %s not asy port\n", argv[1]);
        	return 1;
    	}

    	if (ifp->raw == bitbucket)
		{
        	tprintf ("hfdd session already active on %s\n", argv[1]);
        	return 1;
    	}

    	/* Save output handler and temporarily redirect output to null */
    	ifp->raw = bitbucket;
	}

   	/* Put tty into raw mode */
   	sp->ttystate.echo = 0;
   	sp->ttystate.edit = 0;
   	sockmode (sp->output, SOCK_BINARY);

	/*
	 * 03Jun2007, Maiko, No more keyboard mode for now. This will all be
	 * for mail forwarding only. The keyboard mode never worked very well,
	 * never got developed to it's fullest potential, and introduced some
	 * technical and logistical challenges just not worth doing (yet) !
	 */

	hfddp.keyboard = 0;	/* always from mailbox now, no keyboard user mode */

	hfddp.call = j2strdup (argv[2]);
	hfddp.iface = j2strdup (argv[1]);

	if (notwinmor)
	{
 	  /* 15Feb2005, Maiko, now using device params to configure this */
	  hfddp.pactor = (ap->flags & ASY_PACTOR);
	}
	else hfddp.pactor = 1;	/* 09Apr2010, Maiko, Automatic apparently */

	hfdd_fwdsock = -1;	/* 12Mar2005, Maiko, Make sure of this !!! */

	/*
	 * start up the keyboard handler (as of 02Feb2005, there is only
	 * only one keyboard handler now for all devices, the device specific
	 * stuff is now contained within the handler, instead of having a
	 * separate keyboard handler for each device. More standardized !
	 */
	ifn = if_name (ifp, " keybd");
	sp->proc1 = newproc (ifn, 1024, keyboard_to_hfdd, ifp->dev, sp, &hfddp, 0);
	free (ifn);

    ifn = if_name (ifp, " modem");
    chname (Curproc, ifn);
    free (ifn);

    sp->proc = Curproc;	/* important for alert */
  
    /* bring the line up (just in case) */
    if (ifp->ioctl != NULL)
        (*ifp->ioctl)(ifp, PARAM_UP, TRUE, 0L);

	if (hfdd_debug)
		log (-1, "start the modem machine");

	/*
	 * 22Jan2005, Maiko, Added 'realuser' parameter to the xxx_machine
	 * functions, so that tprintf()'s are suppressed, and the j2alarm()
	 * calls are invoked. Forwarding and having a real user at the
	 * keyboard have slightly different input/output requirements.
	 */
	if (hfdd_is_ptc (hfddp.iface))
		ptc_machine (ifp->dev, hfddp.call);
	else if (hfdd_is_dxp (hfddp.iface))
		dxp_machine (ifp->dev, &hfddp);
	/* 05Feb2007, Maiko, Switched parameters passed to function */
	else if (hfdd_is_kam (hfddp.iface))
		kam_machine (ifp->dev, &hfddp);
	/* 22Apr2008, Maiko, Now support AEA PK232 modem */
	else if (hfdd_is_pk232 (hfddp.iface))
		pk232_machine (ifp->dev, &hfddp);
#ifdef WINMOR
	/* 07Apr2010, Maiko, Support the WINMOR Sound Card modem */
	else if (hfdd_is_winmor (hfddp.iface))
		winmor_machine (ifp->dev, &hfddp);
#endif

	/* 08Feb2007, Maiko, MODEM machine will now never die !!! */

	if (hfdd_debug)
		log (-1, "left the modem machine");

	return 0;
}