1 | /* 2 | * Layer Two Tunnelling Protocol Daemon 3 | * Copyright (C) 1998 Adtran, Inc. 4 | * 5 | * Mark Spencer 6 | * 7 | * This software is distributed under the terms 8 | * of the GPL, which you should have received 9 | * along with this source. 10 | * 11 | * Handle a call as a separate thread (header file) 12 | */ 13 | #include <sys/time.h> 14 | #include "misc.h" 15 | #include "common.h" 16 | 17 | #define CALL_CACHE_SIZE 256 18 | 19 | struct call 20 | { 21 | /* int rbit; Set the "R" bit on the next packet? */ 22 | int lbit; /* Should we send length field? */ 23 | /* int throttle; Throttle the connection? */ 24 | int seq_reqd; /* Sequencing required? */ 25 | int tx_pkts; /* Transmitted packets */ 26 | int rx_pkts; /* Received packets */ 27 | int tx_bytes; /* transmitted bytes */ 28 | int rx_bytes; /* received bytes */ 29 | struct schedule_entry *zlb_xmit; 30 | /* Scheduled ZLB transmission */ 31 | /* struct schedule_entry *dethrottle; */ 32 | /* Scheduled dethrottling (overrun) */ 33 | /* int timeout; Has our timeout expired? If so, we'll go ahead 34 | and transmit, full window or not, and set the 35 | R-bit on this packet. */ 36 | int prx; /* What was the last packet we sent 37 | as an Nr? Used to manage payload ZLB's */ 38 | int state; /* Current state */ 39 | int frame; /* Framing being used */ 40 | struct call *next; /* Next call, for linking */ 41 | int debug; 42 | int msgtype; /* What kind of message are we 43 | working with right now? */ 44 | 45 | int ourcid; /* Our call number */ 46 | int cid; /* Their call number */ 47 | int qcid; /* Quitting CID */ 48 | int bearer; /* Bearer type of call */ 49 | unsigned int serno; /* Call serial number */ 50 | unsigned int addr; /* Address reserved for this call */ 51 | int txspeed; /* Transmit speed */ 52 | int rxspeed; /* Receive speed */ 53 | int ppd; /* Packet processing delay (of peer) */ 54 | int physchan; /* Physical channel ID */ 55 | char dialed[MAXSTRLEN]; /* Number dialed for call */ 56 | char dialing[MAXSTRLEN]; /* Original caller ID */ 57 | char subaddy[MAXSTRLEN]; /* Sub address */ 58 | 59 | int needclose; /* Do we need to close this call? */ 60 | int closing; /* Are we actually in the process of closing? */ 61 | /* 62 | needclose closing state 63 | ========= ======= ===== 64 | 0 0 Running 65 | 1 0 Send Closing notice 66 | 1 1 Waiting for closing notice 67 | 0 1 Closing ZLB received, actulaly close 68 | */ 69 | struct tunnel *container; /* Tunnel we belong to */ 70 | int fd; /* File descriptor for pty */ 71 | struct termios *oldptyconf; 72 | int die; 73 | int nego; /* Show negotiation? */ 74 | int pppd; /* PID of pppd */ 75 | int result; /* Result code */ 76 | int error; /* Error code */ 77 | int fbit; /* Use sequence numbers? */ 78 | int ourfbit; /* Do we want sequence numbers? */ 79 | /* int ourrws; Our RWS for the call */ 80 | int cnu; /* Do we need to send updated Ns, Nr values? */ 81 | int pnu; /* ditto for payload packet */ 82 | char errormsg[MAXSTRLEN]; /* Error message */ 83 | /* int rws; Receive window size, or -1 for none */ 84 | struct timeval lastsent; /* When did we last send something? */ 85 | _u16 pSs; /* Sequence for next payload packet */ 86 | _u16 pSr; /* Sequence for next received payload packet */ 87 | _u16 closeSs; /* What number was in Ns when we started to close? */ 88 | int pLr; /* Last packet received by peer */ 89 | struct lns *lns; /* LNS that owns us */ 90 | struct lac *lac; /* LAC that owns us */ 91 | char dial_no[128]; /* jz: dialing number for outgoing call */ 92 | }; 93 | 94 | 95 | extern void push_handler (int); 96 | extern void toss (struct buffer *); 97 | extern struct call *get_call (int, int, unsigned int, int); 98 | extern struct call *get_tunnel (int, unsigned int, int); 99 | extern void destroy_call (struct call *); 100 | extern struct call *new_call (struct tunnel *); 101 | extern void set_error (struct call *, int, const char *, ...); 102 | void *call_thread_init (void *); 103 | void call_close (struct call *);