home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / AX25MAIL.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  3KB  |  104 lines

  1. /* AX25 mailbox interface
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  *
  4.  *  May '91 Bill Simpson
  5.  *      move to separate file for compilation & linking
  6.  */
  7. #include "global.h"
  8. #ifdef AX25SERVER
  9. #include "proc.h"
  10. #include "iface.h"
  11. #include "pktdrvr.h"
  12. #include "ax25.h"
  13. #include "usock.h"
  14. #include "socket.h"
  15. #include "session.h"
  16. #include "mailbox.h"
  17. #include "telnet.h"
  18. #include "ax25mail.h"
  19.   
  20. /* Axi_sock is kept in Socket.c, so that this module won't be called */
  21. extern void conv_incom(int,void *,void *);
  22.   
  23. int
  24. ax25start(argc,argv,p)
  25. int argc;
  26. char *argv[];
  27. void *p;
  28. {
  29.     int s,whatcall;
  30.     struct usock *up;
  31.   
  32.     if (Axi_sock != -1)
  33.         return 0;
  34.   
  35.     psignal(Curproc,0); /* Don't keep the parser waiting */
  36.     chname(Curproc,"AX25 listener");
  37.     Axi_sock = socket(AF_AX25,SOCK_STREAM,0);
  38.     /* bind() is done automatically */
  39.     if(listen(Axi_sock,1) == -1){
  40.         close_s(Axi_sock);
  41.         return -1;
  42.     }
  43.     for(;;){
  44.         if((s = accept(Axi_sock,NULLCHAR,NULLINT)) == -1)
  45.             break;  /* Service is shutting down */
  46.         /* Spawn a server */
  47.         up = itop(s);
  48.         whatcall = up->cb.ax25->jumpstarted;
  49.         /* Check to see if jumpstart was actually used for
  50.          * this connection.
  51.          * If not, then again eat the line triggering this all
  52.          */
  53.         if(!(whatcall&JUMPSTARTED)) {
  54.             sockmode(s,SOCK_ASCII);    /* To make recvline work */
  55.             recvline(s,NULLCHAR,80);
  56.         }
  57.         /* Now find the right process to start - WG7J */
  58. #ifdef CONVERS
  59.         if(whatcall & CONF_LINK) {
  60.             if(newproc("CONVERS Server",1048,conv_incom,s,(void *)AX25TNC,NULL,0) == NULLPROC)
  61.                 close_s(s);
  62.             continue;
  63.         }
  64. #endif
  65.   
  66. #ifdef MAILBOX
  67.   
  68. #ifdef TTYCALL
  69.         if(whatcall & TTY_LINK) {
  70.             if(newproc("TTYLINK Server",2048,ttylhandle,s,(void *)AX25TNC,NULL,0) == NULLPROC)
  71.                 close_s(s);
  72.             continue;
  73.         }
  74. #endif
  75.         if(newproc("MBOX Server",2048,mbx_incom,s,(void *)whatcall,NULL,0) == NULLPROC)
  76.             close_s(s);
  77.   
  78. #else /* no MAILBOX ! */
  79.   
  80.         /* Anything now goes to ttylink */
  81.         if(newproc("TTYLINK Server",2048,ttylhandle,s,(void *)AX25TNC,NULL,0) == NULLPROC)
  82.             close_s(s);
  83.   
  84. #endif /* MAILBOX */
  85.   
  86.     }
  87.     close_s(Axi_sock);
  88.     Axi_sock = -1;
  89.     return 0;
  90. }
  91.   
  92. int
  93. ax250(argc,argv,p)
  94. int argc;
  95. char *argv[];
  96. void *p;
  97. {
  98.     close_s(Axi_sock);
  99.     Axi_sock = -1;
  100.     return 0;
  101. }
  102.   
  103. #endif /* AX25SERVER */
  104.