/* AX25 mailbox interface * Copyright 1991 Phil Karn, KA9Q * * May '91 Bill Simpson * move to separate file for compilation & linking */ #include "global.h" #include "proc.h" #include "ax25.h" #include "socket.h" #include "session.h" #include "mailbox.h" #include "ax25mail.h" /* Axi_sock is kept in Socket.c, so that this module won't be called */ int ax25start(argc,argv,p) int argc; char *argv[]; void *p; { int s,type; if (Axi_sock != -1) return 0; psignal(Curproc,0); /* Don't keep the parser waiting */ chname(Curproc,"AX25 listener"); Axi_sock = socket(AF_AX25,SOCK_STREAM,0); /* bind() is done automatically */ if(listen(Axi_sock,1) == -1){ close_s(Axi_sock); return -1; } for(;;){ if((s = accept(Axi_sock,NULLCHAR,NULLINT)) == -1) break; /* Service is shutting down */ type = AX25TNC; /* Eat the line that triggered the connection * and then start the mailbox */ sockmode(s,SOCK_ASCII); /* To make recvline work */ recvline(s,NULLCHAR,80); newproc("mbox",2048,mbx_incom,s,(void *)type,NULL,0); } close_s(Axi_sock); Axi_sock = -1; return 0; } int ax250(argc,argv,p) int argc; char *argv[]; void *p; { close_s(Axi_sock); Axi_sock = -1; return 0; } int dogateway(argc,argv,p) int argc; char *argv[]; void *p; { struct mbx *m; struct sockaddr_ax fsocket; int ndigis,i,s; char digis[MAXDIGIS][AXALEN]; char target[AXALEN]; m = (struct mbx *)p; if(!(m->privs & AX25_CMD)){ tprintf(Noperm); return 0; } /* If digipeaters are given, put them in the routing table */ if(argc > 3){ setcall(target,argv[2]); ndigis = argc - 3; if(ndigis > MAXDIGIS){ tprintf("Too many digipeaters\n"); return 1; } for(i=0;istartmsg = mallocw(80); sprintf(m->startmsg,"*** LINKED to %s\n",m->name); return gw_connect(m,s,(char *)&fsocket, sizeof(struct sockaddr_ax)); }