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

  1. /* Header for Bpqcode to nos
  2.  * by paul h launspach n5faz
  3.  * (c) 1993,1994 FazCom
  4.  * 4-13-93
  5.  */
  6. /* $Id: bpq.h 1.4 1994/03/11 14:20:00 fz-phl Exp $ */
  7.   
  8. /* $Log: bpq.h $
  9.  * Revision 1.4  1994/03/11  14:20:00  fz-phl
  10.  * added BPQJNOS to detect 911229 based versions.
  11.  *
  12.  * Revision 1.3  1994/03/11  13:50:49  Johan
  13.  * changed uint16 typedef to #define
  14.  *
  15.  * Revision 1.2  1994/03/11  13:36:08  fz-phl
  16.  * added typedef uint16 and ifdef BPQSOCK for JNOS
  17.  *
  18.  * Revision 1.1  1994/03/11  02:23:37  fz-phl
  19.  * Initial revision
  20.  *
  21.  */
  22.   
  23. #ifndef _BPQ_H
  24. #define _BPQ_H
  25.   
  26. #ifndef _MBUF_H
  27. #include "mbuf.h"
  28. #endif
  29.   
  30. #ifndef _IFACE_H
  31. #include "iface.h"
  32. #endif
  33.   
  34. #define BPQSOCK 1          /* include bpqhost socket code */
  35.                             /* only works with new karncode  */
  36.   
  37. #define BPQJNOS 1           /* set if we are using a 911229 version */
  38. #ifdef BPQJNOS
  39. #define uint16 int16        /* typedef-ed in new karn global.h */
  40. #undef BPQSOCK
  41. #endif
  42.   
  43. #define BPQHEADER 5         /* size of header added by bpqcode */
  44. #define BPQMAXPORT 8        /* max number of bpq radio ports supported */
  45. #define BPQMAXSTREAM 64
  46. #define BPQSIZE 340         /* size of the alloc recieve mbuf  */
  47. #define BPQDSIZE 256
  48. #define BPQWINDOW 8
  49.   
  50. #ifndef AXBUF
  51. #define AXBUF 10
  52. #endif
  53.   
  54. #ifdef BPQSOCK
  55. struct sockaddr_bq {
  56.     short bpq_family;
  57.     char bpq_addr[AXBUF];
  58.     char bpq_appl;
  59.     char bpq_flag;
  60.     char zero[2];
  61. };
  62.   
  63. struct bpq_cb {
  64.     struct bpq_cb *next;
  65.   
  66.     char stream;          /* stream number of this connection */
  67.     char appl;           /* application number */
  68.     char applflag;       /* application flags */
  69.     int mode;
  70.     uint16 state;
  71.   
  72.     struct mbuf *txq;
  73.     struct mbuf *rxq;
  74.   
  75.     char local[AXBUF];
  76.     char remote[AXBUF];
  77.   
  78.     uint16 unack;           /* Number of unacked frames */
  79.     uint16 maxframe;        /* Transmit flow control level, frames */
  80.     uint16 paclen;          /* Maximum outbound packet size, bytes */
  81.     int recv;               /* total packets recvd */
  82.     int send;               /* total packets sent  */
  83.   
  84.     struct bpq_serv *serv;
  85.     int conn;
  86.     int sconn;
  87.   
  88.     void (*r_upcall)  (struct bpq_cb *, int);
  89.     void (*t_upcall)  (struct bpq_cb *, int);
  90.     void (*s_upcall)  (struct bpq_cb *, int, int);
  91.     int user;           /* User pointer */
  92.   
  93. };
  94. #define NULLBPQ (struct bpq_cb *)0
  95.   
  96. struct bpq_servers {
  97.     char *name;                         /* name */
  98.     void (*task)(int,void *,void *);    /* process to run */
  99.     int stack;                          /* stack size */
  100.     char flag;                          /* bpq appl flags */
  101.     int file;                           /* 1 = open network file */
  102. };                                      /* before starting proc */
  103.   
  104. struct bpq_serv {
  105.     struct bpq_serv *next;
  106.     struct bpq_servers *serv;
  107.     int users;                  /* total users */
  108.     int curr;                   /* current users */
  109.     int s;                      /* listeners socket */
  110.     int appl;                   /* bpq application number */
  111. };
  112. #define NULLBPQS (struct bpq_serv *)0
  113.   
  114. extern struct bpq_servers Bpqserv[];
  115. #endif /* BPQSOCK */
  116.   
  117. struct bpqinfo {
  118.     char vec;               /* bpq_host interupt number  */
  119.     char monstream;         /* bpq_host stream number used by nos */
  120.     int maxport;            /* number of bpq ports in use */
  121.     struct iface *ports[BPQMAXPORT];  /* stash for iface structs */
  122.     char maxstream;         /* last stream nos can use */
  123. #ifdef BPQSOCK
  124.     struct bpq_cb *cb;      /* list of active connections  */
  125.     struct bpq_serv *serv;  /* list of active servers  */
  126.     struct proc *rxproc;  /* bpq recieve process */
  127. #endif
  128.     struct mbuf *buffer;    /* mbuf for next recieved packet */
  129.     int32 recv;             /* packets recv from bpq_host */
  130.     int32 send;             /* packets sent to bpq_host  */
  131.     int32 recvcnt;          /* total l2 frames recieved from bpq */
  132.     int32 sendcnt;          /* total l2 frames sent */
  133.     int32 contcnt;          /* number of control calls to bpq */
  134.     int32 txcnt;            /* number of transmit calls to bpq */
  135.     int32 rxcnt;            /* number of recieve calls to bpq */
  136.     int maxconn;            /* total number of connections */
  137.     int nextconn;           /* next connection number */
  138.     int curr;               /* current number of connections */
  139.     uint16 window;             /* frames to send before blocking tx */
  140.     int minfree;            /* min free buffers  */
  141. };
  142.   
  143. extern struct bpqinfo Bpqinfo;
  144. extern char *Bpqstates[];
  145. extern char *Bpqreasons[];
  146.   
  147. /* bpq_host commands */
  148. #define BPQ_VERSION  0  /* not supported */
  149. #define BPQ_SET      1
  150. #define BPQ_SEND     2
  151. #define BPQ_RECV     3
  152. #define BPQ_STATE    4
  153. #define BPQ_ACKSTATE 5
  154. #define BPQ_CONNECT  6
  155. #define BPQ_BUF      7
  156. #define BPQ_UNACK   17
  157. #define BPQ_RECVQUE 27
  158. #define BPQ_USERCALL 8
  159. #define BPQ_PACLEN  18
  160. #define BPQ_MAXFR   28
  161. #define BPQ_CALLS    9  /* not supported */
  162. #define BPQ_TX      10
  163. #define BPQ_RX      11
  164. #define BPQ_BEACON  12
  165. #define BPQ_TIME    15
  166.   
  167. /* bpq application flags  used by SET command */
  168. #define BPQ_MONITOR 0x80    /* monitor */
  169. #define BPQ_CMSG_U  0x02    /* Connected to xxx sent to user  */
  170. #define BPQ_CMSG_AP 0x04    /* Connected to xxx sent to application */
  171. #define BPQ_CMD_AP  0x01    /* user command sent to application */
  172.   
  173. /* bpq application masks  used by SET command  */
  174. #define BPQ_NONE    0x0
  175. #define BPQ_NODE    0x0
  176. #define BPQ_BBS     0x01
  177. #define BPQ_CON     0x02
  178. #define BPQ_SYSOP   0x04
  179. #define BPQ_AP4     0x08
  180. #define BPQ_AP5     0x10
  181. #define BPQ_AP6     0x20
  182. #define BPQ_AP7     0x40
  183. #define BPQ_AP8     0x80
  184.   
  185. /* bpq CONNECT command flags  */
  186. #define BPQ_CONNODE 0x0     /* outgoing connect using node call */
  187. #define BPQ_CONNBBS 0x0100  /* outgoing connect using bbs call */
  188. #define BPQ_CONN    0x01    /* appl mask == 1 ? bbs call : node call */
  189. #define BPQ_DISC    0x02    /* disconnect */
  190. #define BPQ_RET     0x03    /* return user to node */
  191.   
  192. /* bpq USERCALL command return value masks */
  193. /* bpq radio port of connection returned in hibyte if level 2 */
  194. /* session type returned in lowbyte as */
  195. #define BPQ_L2      0x0100
  196. #define BPQ_SESSION 0x0200    /* level 4 connection */
  197. #define BPQ_UPLINK  0x0400
  198. #define BPQ_DOWNLK  0x0800
  199. #define BPQ_HOST    0x2000    /* outgoing appl connection */
  200.   
  201. /* bpq STATE command return value masks */
  202. #define BPQ_ST_DIS  0x0     /* disconnected */
  203. #define BPQ_ST_CON  0x01    /* connected */
  204. #define BPQ_ST_LIS  0x02    /* Listen */
  205. #define BPQ_ST_CHG  0x0100  /* state has changed sence last reported */
  206.   
  207. /* in bpq.c */
  208. uint16 bpq_int (char, char, int, char *);
  209.   
  210. /* bpqcmd.c */
  211. void st_bpq (int);
  212. #ifdef BPQSOCK
  213. void st_bpq_cb (struct bpq_cb *);
  214.   
  215. /* bpqsock.c */
  216. int so_bpq (struct usock *,int);
  217. int so_bpq_listen (struct usock *,int);
  218. int so_bpq_conn (struct usock *);
  219. int so_bpq_recv (struct usock *,struct mbuf **,char *,int *);
  220. int so_bpq_send (struct usock *,struct mbuf *,char *);
  221. int so_bpq_qlen (struct usock *,int);
  222. int so_bpq_shut (struct usock *,int);
  223. int so_bpq_close (struct usock *);
  224. int so_bpq_stat (struct usock *);
  225. char *bpqstate (struct usock *);
  226. char *bpqpsocket (struct sockaddr *);
  227.   
  228. /* bpqsubr.c */
  229. void bpqrxp (int,void *,void *);
  230. void bpqstop (void);
  231. struct bpq_cb *cr_bpq (void);
  232. void del_bpq (struct bpq_cb *);
  233.   
  234. /* bpquser.c */
  235. int send_bpq (struct bpq_cb *,struct mbuf *);
  236. struct mbuf *recv_bpq (struct bpq_cb *,uint16);
  237. int bpq_out (struct bpq_cb *);
  238. struct bpq_cb *find_bpq (int);
  239. struct bpq_cb *open_bpq (char *,char *,int,void (*)(),void (*)(),
  240. void (*)(),int user);
  241. void disc_bpq (struct bpq_cb *,int);
  242. void reset_bpq (struct bpq_cb *);
  243. int kick_bpq (struct bpq_cb *);
  244. int bpqval (struct bpq_cb *);
  245.   
  246. /* bpqmail.c */
  247. int bpqstart (int,char *argv[],void *);
  248. int bpq0 (int,char *argv[],void *);
  249. void bpqfinger (int,void *,void *);
  250.   
  251. #endif /* BPQSOCK */
  252. #endif /* _BPQ_H */
  253.