Commit | Line | Data |
---|---|---|
ff72d400 KS |
1 | /*********************************************************** |
2 | Copyright IBM Corporation 1987 | |
3 | ||
4 | All Rights Reserved | |
5 | ||
6 | Permission to use, copy, modify, and distribute this software and its | |
7 | documentation for any purpose and without fee is hereby granted, | |
8 | provided that the above copyright notice appear in all copies and that | |
9 | both that copyright notice and this permission notice appear in | |
10 | supporting documentation, and that the name of IBM not be | |
11 | used in advertising or publicity pertaining to distribution of the | |
12 | software without specific, written prior permission. | |
13 | ||
14 | IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | |
15 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
16 | IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
17 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
18 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
19 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
20 | SOFTWARE. | |
21 | ||
22 | ******************************************************************/ | |
23 | ||
24 | /* | |
25 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison | |
26 | */ | |
27 | /* | |
28 | * ARGO TP | |
29 | * | |
30 | * $Header: tp_pcb.h,v 5.2 88/11/18 17:09:32 nhall Exp $ | |
31 | * $Source: /usr/argo/sys/netiso/RCS/tp_pcb.h,v $ | |
44f52ea5 | 32 | * @(#)tp_pcb.h 7.4 (Berkeley) %G% * |
ff72d400 KS |
33 | * |
34 | * | |
35 | * This file defines the transport protocol control block (tpcb). | |
36 | * and a bunch of #define values that are used in the tpcb. | |
37 | */ | |
38 | ||
39 | #ifndef __TP_PCB__ | |
40 | #define __TP_PCB__ | |
41 | ||
42 | #include "../netiso/tp_param.h" | |
43 | #include "../netiso/tp_timer.h" | |
44 | #include "../netiso/tp_user.h" | |
45 | #ifndef sblock | |
e663c139 | 46 | #include "socketvar.h" |
ff72d400 KS |
47 | #endif sblock |
48 | ||
49 | /* NOTE: the code depends on REF_CLOSED > REF_OPEN > the rest, and | |
50 | * on REF_FREE being zero | |
51 | * | |
52 | * Possible improvement: | |
53 | * think about merging the tp_ref w/ the tpcb and doing a search | |
54 | * through the tpcb list, from tpb. This would slow down lookup | |
55 | * during data transfer | |
56 | * It would be a little nicer also to have something based on the | |
57 | * clock (like top n bits of the reference is part of the clock, to | |
58 | * minimize the likelihood of reuse after a crash) | |
59 | * also, need to keep the timer servicing part to a minimum (although | |
60 | * the cost of this is probably independent of whether the timers are | |
61 | * in the pcb or in an array.. | |
62 | * Last, would have to make the number of timers a function of the amount of | |
63 | * mbufs available, plus some for the frozen references. | |
64 | * | |
65 | * Possible improvement: | |
66 | * Might not need the ref_state stuff either... | |
67 | * REF_FREE could correspond to tp_state == CLOSED or nonexistend tpcb, | |
68 | * REF_OPEN to tp_state anywhere from AK_WAIT or CR_SENT to CLOSING | |
69 | * REF_OPENING could correspond to LISTENING, because that's the | |
70 | * way it's used, not because the correspondence is exact. | |
71 | * REF_CLOSED could correspond to REFWAIT | |
72 | */ | |
73 | #define REF_FROZEN 3 /* has ref timer only */ | |
74 | #define REF_OPEN 2 /* has timers, possibly active */ | |
75 | #define REF_OPENING 1 /* in use (has a pcb) but no timers */ | |
76 | #define REF_FREE 0 /* free to reallocate */ | |
77 | ||
78 | #define N_CTIMERS 4 | |
79 | #define N_ETIMERS 2 | |
80 | ||
81 | struct tp_ref { | |
82 | u_char tpr_state; /* values REF_FROZEN, etc. above */ | |
83 | struct Ccallout tpr_callout[N_CTIMERS]; /* C timers */ | |
84 | struct Ecallout tpr_calltodo; /* list of active E timers */ | |
85 | struct tp_pcb *tpr_pcb; /* back ptr to PCB */ | |
86 | }; | |
87 | ||
88 | struct tp_param { | |
89 | /* PER system stuff (one static structure instead of a bunch of names) */ | |
90 | unsigned tpp_configed:1; /* Has TP been initialized? */ | |
91 | }; | |
92 | ||
93 | ||
94 | /* | |
95 | * retransmission control and performance measurement | |
96 | */ | |
97 | struct tp_rtc { | |
98 | struct tp_rtc *tprt_next; /* ptr to next rtc structure in the list */ | |
99 | SeqNum tprt_seq; /* seq # of this TPDU */ | |
100 | int tprt_eot; /* Will this TPDU have the eot bit set? */ | |
101 | int tprt_octets;/* # octets in this TPDU */ | |
102 | struct mbuf *tprt_data; /* ptr to the octets of data */ | |
103 | }; | |
104 | ||
105 | extern | |
106 | struct nl_protosw { | |
107 | int nlp_afamily; /* address family */ | |
108 | int (*nlp_putnetaddr)(); /* puts addresses in nl pcb */ | |
109 | int (*nlp_getnetaddr)(); /* gets addresses from nl pcb */ | |
110 | int (*nlp_putsufx)(); /* puts transport suffixes in nl pcb */ | |
111 | int (*nlp_getsufx)(); /* gets transport suffixes from nl pcb */ | |
112 | int (*nlp_recycle_suffix)();/* clears suffix from nl pcb */ | |
113 | int (*nlp_mtu)(); /* figures out mtu based on nl used */ | |
114 | int (*nlp_pcbbind)(); /* bind to pcb for net level */ | |
115 | int (*nlp_pcbconn)(); /* connect for net level */ | |
116 | int (*nlp_pcbdisc)(); /* disconnect net level */ | |
117 | int (*nlp_pcbdetach)(); /* detach net level pcb */ | |
118 | int (*nlp_pcballoc)(); /* allocate a net level pcb */ | |
119 | int (*nlp_output)(); /* prepare a packet to give to nl */ | |
120 | int (*nlp_dgoutput)(); /* prepare a packet to give to nl */ | |
121 | int (*nlp_ctloutput)(); /* hook for network set/get options */ | |
122 | caddr_t nlp_pcblist; /* list of xx_pcb's for connections */ | |
123 | } nl_protosw[]; | |
124 | ||
ff72d400 KS |
125 | |
126 | struct tp_pcb { | |
127 | u_short tp_state; /* state of fsm */ | |
128 | short tp_retrans; /* # times can still retrans */ | |
129 | struct tp_ref *tp_refp; /* rest of pcb */ | |
ff72d400 KS |
130 | caddr_t tp_npcb; /* to lower layer pcb */ |
131 | struct nl_protosw *tp_nlproto; /* lower-layer dependent routines */ | |
132 | struct socket *tp_sock; /* back ptr */ | |
133 | ||
ff72d400 KS |
134 | |
135 | RefNum tp_lref; /* local reference */ | |
136 | RefNum tp_fref; /* foreign reference */ | |
137 | ||
138 | u_int tp_seqmask; /* mask for seq space */ | |
139 | u_int tp_seqbit; /* bit for seq number wraparound */ | |
140 | u_int tp_seqhalf; /* half the seq space */ | |
141 | ||
ff72d400 KS |
142 | /* credit & sequencing info for SENDING */ |
143 | u_short tp_fcredit; /* current remote credit in # packets */ | |
144 | ||
145 | u_short tp_cong_win; /* congestion window : set to 1 on | |
146 | * source quench | |
147 | * Minimizes the amount of retrans- | |
148 | * missions (independently of the | |
149 | * retrans strategy). Increased | |
150 | * by one for each good ack received. | |
151 | * Minimizes the amount sent in a | |
152 | * regular tp_send() also. | |
153 | */ | |
ff72d400 KS |
154 | SeqNum tp_snduna; /* seq # of lowest unacked DT */ |
155 | struct tp_rtc *tp_snduna_rtc; /* lowest unacked stuff sent so far */ | |
156 | SeqNum tp_sndhiwat; /* highest seq # sent so far */ | |
157 | struct tp_rtc *tp_sndhiwat_rtc; /* last stuff sent so far */ | |
158 | int tp_Nwindow; /* for perf. measurement */ | |
a50e2bc0 | 159 | struct mbuf *tp_ucddata; /* user connect/disconnect data */ |
ff72d400 KS |
160 | |
161 | /* credit & sequencing info for RECEIVING */ | |
162 | SeqNum tp_sent_lcdt; /* cdt according to last ack sent */ | |
163 | SeqNum tp_sent_uwe; /* uwe according to last ack sent */ | |
164 | SeqNum tp_sent_rcvnxt; /* rcvnxt according to last ack sent | |
165 | * needed for perf measurements only | |
166 | */ | |
167 | u_short tp_lcredit; /* current local credit in # packets */ | |
168 | SeqNum tp_rcvnxt; /* next DT seq # expect to recv */ | |
169 | struct tp_rtc *tp_rcvnxt_rtc; /* unacked stuff recvd out of order */ | |
ff72d400 KS |
170 | |
171 | /* parameters per-connection controllable by user */ | |
172 | struct tp_conn_param _tp_param; | |
173 | ||
174 | #define tp_Nretrans _tp_param.p_Nretrans | |
175 | #define tp_dr_ticks _tp_param.p_dr_ticks | |
176 | #define tp_cc_ticks _tp_param.p_cc_ticks | |
177 | #define tp_dt_ticks _tp_param.p_dt_ticks | |
178 | #define tp_xpd_ticks _tp_param.p_x_ticks | |
179 | #define tp_cr_ticks _tp_param.p_cr_ticks | |
180 | #define tp_keepalive_ticks _tp_param.p_keepalive_ticks | |
181 | #define tp_sendack_ticks _tp_param.p_sendack_ticks | |
182 | #define tp_refer_ticks _tp_param.p_ref_ticks | |
183 | #define tp_inact_ticks _tp_param.p_inact_ticks | |
184 | #define tp_xtd_format _tp_param.p_xtd_format | |
185 | #define tp_xpd_service _tp_param.p_xpd_service | |
186 | #define tp_ack_strat _tp_param.p_ack_strat | |
187 | #define tp_rx_strat _tp_param.p_rx_strat | |
188 | #define tp_use_checksum _tp_param.p_use_checksum | |
189 | #define tp_use_efc _tp_param.p_use_efc | |
190 | #define tp_use_nxpd _tp_param.p_use_nxpd | |
191 | #define tp_use_rcc _tp_param.p_use_rcc | |
192 | #define tp_tpdusize _tp_param.p_tpdusize | |
193 | #define tp_class _tp_param.p_class | |
194 | #define tp_winsize _tp_param.p_winsize | |
195 | #define tp_no_disc_indications _tp_param.p_no_disc_indications | |
196 | #define tp_dont_change_params _tp_param.p_dont_change_params | |
197 | #define tp_netservice _tp_param.p_netservice | |
198 | ||
199 | int tp_l_tpdusize; | |
200 | /* whereas tp_tpdusize is log2(the negotiated max size) | |
201 | * l_tpdusize is the size we'll use when sending, in # chars | |
202 | */ | |
203 | ||
204 | struct timeval tp_rtv; /* max round-trip time variance */ | |
205 | struct timeval tp_rtt; /* smoothed round-trip time */ | |
206 | struct timeval tp_rttemit[ TP_RTT_NUM + 1 ]; | |
207 | /* times that the last TP_RTT_NUM DT_TPDUs were emitted */ | |
208 | unsigned | |
209 | tp_sendfcc:1, /* shall next ack include FCC parameter? */ | |
210 | tp_trace:1, /* is this pcb being traced? (not used yet) */ | |
211 | tp_perf_on:1, /* 0/1 -> performance measuring on */ | |
212 | tp_reneged:1, /* have we reneged on cdt since last ack? */ | |
213 | tp_decbit:4, /* dec bit was set, we're in reneg mode */ | |
214 | tp_flags:8, /* values: */ | |
215 | #define TPF_CONN_DATA_OUT TPFLAG_CONN_DATA_OUT | |
216 | #define TPF_CONN_DATA_IN TPFLAG_CONN_DATA_IN | |
217 | #define TPF_DISC_DATA_IN TPFLAG_DISC_DATA_IN | |
218 | #define TPF_DISC_DATA_OUT TPFLAG_DISC_DATA_OUT | |
219 | #define TPF_XPD_PRESENT TPFLAG_XPD_PRESENT | |
220 | #define TPF_NLQOS_PDN TPFLAG_NLQOS_PDN | |
221 | #define TPF_PEER_ON_SAMENET TPFLAG_PEER_ON_SAMENET | |
222 | ||
223 | #define PEER_IS_LOCAL(t) \ | |
224 | (((t)->tp_flags & TPF_PEER_ON_SAME_NET)==TPF_PEER_ON_SAME_NET) | |
225 | #define USES_PDN(t) \ | |
226 | (((t)->tp_flags & TPF_NLQOS_PDN)==TPF_NLQOS_PDN) | |
227 | ||
228 | tp_unused:16; | |
229 | ||
ff72d400 KS |
230 | |
231 | #ifdef TP_PERF_MEAS | |
232 | /* performance stats - see tp_stat.h */ | |
a50e2bc0 KS |
233 | struct tp_pmeas *tp_p_meas; |
234 | struct mbuf *tp_p_mbuf; | |
ff72d400 | 235 | #endif TP_PERF_MEAS |
a50e2bc0 KS |
236 | /* addressing */ |
237 | u_short tp_domain; /* domain (INET, ISO) */ | |
238 | /* for compatibility with the *old* way and with INET, be sure that | |
239 | * that lsuffix and fsuffix are aligned to a short addr. | |
240 | * having them follow the u_short *suffixlen should suffice (choke) | |
241 | */ | |
242 | u_short tp_fsuffixlen; /* foreign suffix */ | |
243 | char tp_fsuffix[MAX_TSAP_SEL_LEN]; | |
244 | u_short tp_lsuffixlen; /* local suffix */ | |
245 | char tp_lsuffix[MAX_TSAP_SEL_LEN]; | |
246 | #define SHORT_LSUFXP(tpcb) ((short *)((tpcb)->tp_lsuffix)) | |
247 | #define SHORT_FSUFXP(tpcb) ((short *)((tpcb)->tp_fsuffix)) | |
248 | ||
249 | u_char tp_vers; /* protocol version */ | |
250 | u_char tp_peer_acktime; /* used to compute DT retrans time */ | |
251 | ||
252 | struct sockbuf tp_Xsnd; /* for expedited data */ | |
253 | /* struct sockbuf tp_Xrcv; /* for expedited data */ | |
254 | #define tp_Xrcv tp_sock->so_rcv | |
255 | SeqNum tp_Xsndnxt; /* next XPD seq # to send */ | |
256 | SeqNum tp_Xuna; /* seq # of unacked XPD */ | |
257 | SeqNum tp_Xrcvnxt; /* next XPD seq # expect to recv */ | |
258 | ||
259 | /* AK subsequencing */ | |
260 | u_short tp_s_subseq; /* next subseq to send */ | |
261 | u_short tp_r_subseq; /* highest recv subseq */ | |
262 | ||
ff72d400 KS |
263 | }; |
264 | ||
265 | extern struct timeval time; | |
266 | extern struct tp_ref tp_ref[]; | |
267 | extern struct tp_param tp_param; | |
268 | ||
ff72d400 KS |
269 | #define sototpcb(so) ((struct tp_pcb *)(so->so_tpcb)) |
270 | #define sototpref(so) ((struct tp_ref *)((so)->so_tpcb->tp_ref)) | |
271 | #define tpcbtoso(tp) ((struct socket *)((tp)->tp_sock)) | |
272 | #define tpcbtoref(tp) ((struct tp_ref *)((tp)->tp_ref)) | |
ff72d400 KS |
273 | |
274 | #endif __TP_PCB__ |