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