1 /* $NetBSD: llc_var.h,v 1.13 2003/08/07 16:33:03 agc Exp $ */
2
3 /*
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Dirk Husemann and the Computer Science Department (IV) of
9 * the University of Erlangen-Nuremberg, Germany.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)llc_var.h 8.2 (Berkeley) 2/9/95
36 */
37
38 /*
39 * Copyright (c) 1990, 1991, 1992
40 * Dirk Husemann, Computer Science Department IV,
41 * University of Erlangen-Nuremberg, Germany.
42 *
43 * This code is derived from software contributed to Berkeley by
44 * Dirk Husemann and the Computer Science Department (IV) of
45 * the University of Erlangen-Nuremberg, Germany.
46 *
47 * Redistribution and use in source and binary forms, with or without
48 * modification, are permitted provided that the following conditions
49 * are met:
50 * 1. Redistributions of source code must retain the above copyright
51 * notice, this list of conditions and the following disclaimer.
52 * 2. Redistributions in binary form must reproduce the above copyright
53 * notice, this list of conditions and the following disclaimer in the
54 * documentation and/or other materials provided with the distribution.
55 * 3. All advertising materials mentioning features or use of this software
56 * must display the following acknowledgement:
57 * This product includes software developed by the University of
58 * California, Berkeley and its contributors.
59 * 4. Neither the name of the University nor the names of its contributors
60 * may be used to endorse or promote products derived from this software
61 * without specific prior written permission.
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
64 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
67 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73 * SUCH DAMAGE.
74 *
75 * @(#)llc_var.h 8.2 (Berkeley) 2/9/95
76 */
77
78 struct llc;
79
80 #define NPAIDB_LINK 0
81
82 struct npaidbentry {
83 union {
84 /* MAC,DLSAP -> CONS */
85 struct {
86 struct llc_linkcb *NE_link;
87 struct rtentry *NE_rt;
88 } NE;
89 /* SAP info for unconfigured incoming calls */
90 struct {
91 u_short SI_class;
92 #define LLC_CLASS_I 0x1
93 #define LLC_CLASS_II 0x3
94 #define LLC_CLASS_III 0x4 /* Future */
95 #define LLC_CLASS_IV 0x7 /* Future */
96 u_short SI_window;
97 u_short SI_trace;
98 u_short SI_xchxid;
99 void (*SI_input)
100 __P((struct mbuf *,...));
101 void *(*SI_ctlinput)
102 __P((int,struct sockaddr *,void *));
103 } SI;
104 } NESIun;
105 };
106 #define np_link NESIun.NE.NE_link
107 #define np_rt NESIun.NE.NE_rt
108 #define si_class NESIun.SI.SI_class
109 #define si_window NESIun.SI.SI_window
110 #define si_trace NESIun.SI.SI_trace
111 #define si_xchxid NESIun.SI.SI_xchxid
112 #define si_input NESIun.SI.SI_input
113 #define si_ctlinput NESIun.SI.SI_ctlinput
114
115 #define NPDL_SAPNETMASK 0x7e
116
117 /*
118 * Definitions for accessing bitfields/bitslices inside
119 * LLC2 headers
120 */
121 struct bitslice {
122 unsigned int bs_mask;
123 unsigned int bs_shift;
124 };
125
126
127 #define i_z 0
128 #define i_ns 1
129 #define i_pf 0
130 #define i_nr 1
131 #define s_oz 2
132 #define s_selector 3
133 #define s_pf 0
134 #define s_nr 1
135 #define u_bb 2
136 #define u_select_other 3
137 #define u_pf 4
138 #define u_select 5
139 #define f_vs 1
140 #define f_cr 0
141 #define f_vr 1
142 #define f_wxyzv 6
143
144 #define LLCGBITS(Arg,Index) \
145 (((Arg) & llc_bitslice[(Index)].bs_mask) >> \
146 llc_bitslice[(Index)].bs_shift)
147 #define LLCSBITS(Arg,Index,Val) \
148 (Arg) |= (((Val) << llc_bitslice[(Index)].bs_shift) & \
149 llc_bitslice[(Index)].bs_mask)
150 #define LLCCSBITS(Arg,Index,Val) \
151 (Arg) = (((Val) << llc_bitslice[(Index)].bs_shift) & \
152 llc_bitslice[(Index)].bs_mask)
153
154 extern struct bitslice llc_bitslice[];
155
156 #define LLC_CMD 0
157 #define LLC_RSP 1
158 #define LLC_MAXCMDRSP 2
159
160 /*
161 * LLC events --- These events may either be frames received from the
162 * remote LLC DSAP,request from the network layer user,
163 * timer events from llc_timer(),or diagnostic events from
164 * llc_input().
165 */
166
167 /* LLC frame types */
168 #define LLCFT_INFO 0 * LLC_MAXCMDRSP
169 #define LLCFT_RR 1 * LLC_MAXCMDRSP
170 #define LLCFT_RNR 2 * LLC_MAXCMDRSP
171 #define LLCFT_REJ 3 * LLC_MAXCMDRSP
172 #define LLCFT_DM 4 * LLC_MAXCMDRSP
173 #define LLCFT_SABME 5 * LLC_MAXCMDRSP
174 #define LLCFT_DISC 6 * LLC_MAXCMDRSP
175 #define LLCFT_UA 7 * LLC_MAXCMDRSP
176 #define LLCFT_FRMR 8 * LLC_MAXCMDRSP
177 #define LLCFT_UI 9 * LLC_MAXCMDRSP
178 #define LLCFT_XID 10 * LLC_MAXCMDRSP
179 #define LLCFT_TEST 11 * LLC_MAXCMDRSP
180
181 /* LLC2 timer events */
182 #define LLC_ACK_TIMER_EXPIRED 12 * LLC_MAXCMDRSP
183 #define LLC_P_TIMER_EXPIRED 13 * LLC_MAXCMDRSP
184 #define LLC_REJ_TIMER_EXPIRED 14 * LLC_MAXCMDRSP
185 #define LLC_BUSY_TIMER_EXPIRED 15 * LLC_MAXCMDRSP
186
187 /* LLC2 diagnostic events */
188 #define LLC_INVALID_NR 16 * LLC_MAXCMDRSP
189 #define LLC_INVALID_NS 17 * LLC_MAXCMDRSP
190 #define LLC_BAD_PDU 18 * LLC_MAXCMDRSP
191 #define LLC_LOCAL_BUSY_DETECTED 19 * LLC_MAXCMDRSP
192 #define LLC_LOCAL_BUSY_CLEARED 20 * LLC_MAXCMDRSP
193
194 /* Network layer user requests */
195 /*
196 * NL_CONNECT_REQUEST --- The user has requested that a data link connection
197 * be established with a remote LLC DSAP.
198 */
199 #define NL_CONNECT_REQUEST 21 * LLC_MAXCMDRSP
200 /*
201 * NL_CONNECT_RESPONSE --- The user has accepted the data link connection.
202 */
203 #define NL_CONNECT_RESPONSE 22 * LLC_MAXCMDRSP
204 /*
205 * NL_RESET_REQUEST --- The user has requested that the data link with the
206 * remote LLC DSAP be reset.
207 */
208 #define NL_RESET_REQUEST 23 * LLC_MAXCMDRSP
209 /*
210 * NL_RESET_RESPONSE --- The user has accepted the reset of the data link
211 * connection.
212 */
213 #define NL_RESET_RESPONSE 24 * LLC_MAXCMDRSP
214 /*
215 * NL_DISCONNECT_REQUEST --- The user has requested that the data link
216 * connection with remote LLC DSAP be terminated.
217 */
218 #define NL_DISCONNECT_REQUEST 25 * LLC_MAXCMDRSP
219 /*
220 * NL_DATA_REQUEST --- The user has requested that a data unit be sent ot the
221 * remote LLC DSAP.
222 */
223 #define NL_DATA_REQUEST 26 * LLC_MAXCMDRSP
224 /*
225 * NL_INITIATE_PF_CYCLE --- The local LLC wants to initiate a P/F cycle.
226 */
227 #define NL_INITIATE_PF_CYCLE 27 * LLC_MAXCMDRSP
228 /*
229 * NL_LOCAL_BUSY_DETECTED --- The local entity has encountered a busy condition
230 */
231 #define NL_LOCAL_BUSY_DETECTED 28 * LLC_MAXCMDRSP
232
233 #define LLCFT_NONE 255
234
235 /* return message from state handlers */
236
237 /*
238 * LLC_CONNECT_INDICATION --- Inform the user that a connection has been
239 * requested by a remote LLC SSAP.
240 */
241 #define LLC_CONNECT_INDICATION 1
242 /*
243 * LLC_CONNECT_CONFIRM --- The connection service component indicates that the
244 * remote network entity has accepted the connection.
245 */
246 #define LLC_CONNECT_CONFIRM 2
247 /*
248 * LLC_DISCONNECT_INDICATION --- Inform the user that the remote network
249 * entity has intiated disconnection of the data
250 * link connection.
251 */
252 #define LLC_DISCONNECT_INDICATION 3
253 /*
254 * LLC_RESET_CONFIRM --- The connection service component indicates that the
255 * remote network entity has accepted the reset.
256 */
257 #define LLC_RESET_CONFIRM 4
258 /*
259 * LLC_RESET_INDICATION_REMOTE --- The remote network entity or remote peer
260 * has initiated a reset of the data link
261 * connection.
262 */
263 #define LLC_RESET_INDICATION_REMOTE 5
264 /*
265 * LLC_RESET_INDICATION_LOCAL --- The local LLC has determined that the data
266 * link connection is in need of
267 * reinitialization.
268 */
269 #define LLC_RESET_INDICATION_LOCAL 6
270 /*
271 * LLC_FRMR_RECEIVED --- The local connection service component has received a
272 * FRMR response PDU.
273 */
274 #define LLC_FRMR_RECEIVED 7
275 /*
276 * LLC_FRMR_SENT --- The local connection component has received an ivalid
277 * PDU,and has sent a FRMR response PDU.
278 */
279 #define LLC_FRMR_SENT 8
280 /*
281 * LLC_DATA_INDICATION --- The connection service component passes the data
282 * unit from the received I PDU to the user.
283 */
284 #define LLC_DATA_INDICATION 9
285 /*
286 * LLC_REMOTE_NOT_BUSY --- The remote LLC DSAP is no longer busy. The local
287 * connection service component will now accept a
288 * DATA_REQUEST.
289 */
290 #define LLC_REMOTE_NOT_BUSY 10
291 /*
292 * LLC_REMOTE_BUSY --- The remote LLC DSAP is busy. The local connection
293 * service component will not accept a DATA_REQUEST.
294 */
295 #define LLC_REMOTE_BUSY 11
296
297 /* Internal return code */
298 #define LLC_PASSITON 255
299
300 #define INFORMATION_CONTROL 0x00
301 #define SUPERVISORY_CONTROL 0x02
302 #define UNUMBERED_CONTROL 0x03
303
304 /*
305 * Other necessary definitions
306 */
307
308 #define LLC_MAX_SEQUENCE 128
309 #define LLC_MAX_WINDOW 127
310 #define LLC_WINDOW_SIZE 7
311
312 /*
313 * Don't we love this one? CCITT likes to suck on bits 8=)
314 */
315 #define NLHDRSIZEGUESS 3
316
317 /*
318 * LLC control block
319 */
320
321 struct llc_linkcb {
322 struct llccb_q {
323 struct llccb_q *q_forw; /* admin chain */
324 struct llccb_q *q_backw;
325 } llcl_q;
326 struct npaidbentry *llcl_sapinfo; /* SAP information */
327 struct sockaddr_dl llcl_addr; /* link snpa address */
328 struct rtentry *llcl_nlrt; /* layer 3 -> LLC */
329 struct rtentry *llcl_llrt; /* LLC -> layer 3 */
330 struct ifnet *llcl_if; /* our interface */
331 caddr_t llcl_nlnext; /* cb for network layer */
332 struct mbuf *llcl_writeqh; /* Write queue head */
333 struct mbuf *llcl_writeqt; /* Write queue tail */
334 struct mbuf **llcl_output_buffers;
335 short llcl_timers[6]; /* timer array */
336 long llcl_timerflags; /* flags signalling running timers */
337 int (*llcl_statehandler)
338 __P((struct llc_linkcb *,struct llc *,int,int,int));
339 int llcl_P_flag;
340 int llcl_F_flag;
341 int llcl_S_flag;
342 int llcl_DATA_flag;
343 int llcl_REMOTE_BUSY_flag;
344 int llcl_DACTION_flag; /* delayed action */
345 int llcl_retry;
346 /*
347 * The following components deal --- in one way or the other ---
348 * with the LLC2 window. Indicated by either [L] or [W] is the
349 * domain of the specific component:
350 *
351 * [L] The domain is 0--LLC_MAX_WINDOW
352 * [W] The domain is 0--llcl_window
353 */
354 short llcl_vr; /* next to receive [L] */
355 short llcl_vs; /* next to send [L] */
356 short llcl_nr_received; /* next frame to b ack'd [L] */
357 short llcl_freeslot; /* next free slot [W] */
358 short llcl_projvs; /* V(S) associated with freeslot */
359 short llcl_slotsfree; /* free slots [W] */
360 short llcl_window; /* window size */
361 /*
362 * In llcl_frmrinfo we jot down the last frmr info field,which we
363 * need to do as we need to be able to resend it in the ERROR state.
364 */
365 struct frmrinfo llcl_frmrinfo; /* last FRMR info field */
366 };
367 #define llcl_frmr_pdu0 llcl_frmrinfo.frmr_rej_pdu0
368 #define llcl_frmr_pdu1 llcl_frmrinfo.frmr_rej_pdu1
369 #define llcl_frmr_control llcl_frmrinfo.frmr_control
370 #define llcl_frmr_control_ext llcl_frmrinfo.frmr_control_ext
371 #define llcl_frmr_cause llcl_frmrinfo.frmr_cause
372
373 #define LQNEXT(l) (struct llc_linkcb *)((l)->llcl_q.q_forw)
374 #define LQEMPTY (llccb_q.q_forw == &llccb_q)
375 #define LQFIRST (struct llc_linkcb *)(llccb_q.q_forw)
376 #define LQVALID(l) (!((struct llccb_q *)(l) == &llccb_q))
377
378 #define LLC_ENQUEUE(l,m) if ((l)->llcl_writeqh == NULL) { \
379 (l)->llcl_writeqh = (m); \
380 (l)->llcl_writeqt = (m); \
381 } else { \
382 (l)->llcl_writeqt->m_nextpkt = (m); \
383 (l)->llcl_writeqt = (m); \
384 }
385
386 #define LLC_DEQUEUE(l,m) if ((l)->llcl_writeqh == NULL) \
387 (m) = NULL; \
388 else { \
389 (m) = (l)->llcl_writeqh; \
390 (l)->llcl_writeqh = (l)->llcl_writeqh->m_nextpkt; \
391 }
392
393 #define LLC_SETFRAME(l,m) { \
394 if ((l)->llcl_slotsfree > 0) { \
395 (l)->llcl_slotsfree--; \
396 (l)->llcl_output_buffers[(l)->llcl_freeslot] = (m); \
397 (l)->llcl_freeslot = ((l)->llcl_freeslot+1) % (l)->llcl_window; \
398 LLC_INC((l)->llcl_projvs); \
399 } \
400 }
401
402 /*
403 * handling of sockaddr_dl's
404 */
405
406 #define LLADDRLEN(s) ((s)->sdl_alen + (s)->sdl_nlen)
407 #define LLSAPADDR(s) ((s)->sdl_data[LLADDRLEN(s)-1] & 0xff)
408 #define LLSAPLOC(s,if) ((s)->sdl_nlen + (if)->if_addrlen)
409
410 struct sdl_hdr {
411 struct sockaddr_dl sdlhdr_dst;
412 struct sockaddr_dl sdlhdr_src;
413 long sdlhdr_len;
414 };
415
416 #define LLC_GETHDR(f,m) { \
417 struct mbuf *_m = (struct mbuf *) (m); \
418 if (_m) { \
419 M_PREPEND(_m,LLC_ISFRAMELEN,M_DONTWAIT); \
420 bzero(mtod(_m,caddr_t),LLC_ISFRAMELEN); \
421 } else { \
422 MGETHDR (_m,M_DONTWAIT,MT_HEADER); \
423 if (_m != NULL) { \
424 _m->m_pkthdr.len = _m->m_len = LLC_UFRAMELEN; \
425 _m->m_next = _m->m_nextpkt = NULL; \
426 bzero(mtod(_m,caddr_t),LLC_UFRAMELEN); \
427 } else return; \
428 } \
429 (m) = _m; \
430 (f) = mtod(m,struct llc *); \
431 }
432
433 #define LLC_NEWSTATE(l,LLCstate) \
434 (l)->llcl_statehandler = __CONCAT(llc_state_,LLCstate)
435 #define LLC_STATEEQ(l,LLCstate) \
436 ((l)->llcl_statehandler == __CONCAT(llc_state_,LLCstate) ? 1 : 0)
437
438 #define LLC_ACK_SHIFT 0
439 #define LLC_P_SHIFT 1
440 #define LLC_BUSY_SHIFT 2
441 #define LLC_REJ_SHIFT 3
442 #define LLC_AGE_SHIFT 4
443 #define LLC_DACTION_SHIFT 5
444
445 #define LLC_TIMER_NOTRUNNING 0
446 #define LLC_TIMER_RUNNING 1
447 #define LLC_TIMER_EXPIRED 2
448
449 #ifndef __CONCAT3
450 # if __STDC__
451 # define __CONCAT3(a,b,c) a ## b ## c
452 # else
453 # define __CONCAT3(a,b,c) a/**/b/**/c
454 # endif /* __STDC__ */
455 #endif
456
457 #define LLC_STARTTIMER(l,LLCtimer) { \
458 (l)->llcl_timers[__CONCAT3(LLC_,LLCtimer,_SHIFT)] = \
459 __CONCAT3(llc_,LLCtimer,_timer); \
460 (l)->llcl_timerflags |= (1 << __CONCAT3(LLC_,LLCtimer,_SHIFT)); \
461 }
462 #define LLC_STOPTIMER(l,LLCtimer) { \
463 (l)->llcl_timers[__CONCAT3(LLC_,LLCtimer,_SHIFT)] = 0; \
464 (l)->llcl_timerflags &= ~(1<<__CONCAT3(LLC_,LLCtimer,_SHIFT)); \
465 }
466 #define LLC_AGETIMER(l,LLCtimer) \
467 if ((l)->llcl_timers[__CONCAT3(LLC_,LLCtimer,_SHIFT)] > 0) \
468 (l)->llcl_timers[__CONCAT3(LLC_,LLCtimer,_SHIFT)]--;
469
470 #define LLC_TIMERXPIRED(l,LLCtimer) \
471 (((l)->llcl_timerflags & (1<<__CONCAT3(LLC_,LLCtimer,_SHIFT))) ? \
472 (((l)->llcl_timers[__CONCAT3(LLC_,LLCtimer,_SHIFT)] == 0 ) ? \
473 LLC_TIMER_EXPIRED : LLC_TIMER_RUNNING) : LLC_TIMER_NOTRUNNING)
474
475 #define FOR_ALL_LLC_TIMERS(t) \
476 for ((t) = LLC_ACK_SHIFT; (t) < LLC_AGE_SHIFT; (t)++)
477
478 #define LLC_SETFLAG(l,LLCflag,v) (l)->__CONCAT3(llcl_,LLCflag,_flag) = (v)
479 #define LLC_GETFLAG(l,LLCflag) (l)->__CONCAT3(llcl_,LLCflag,_flag)
480
481 #define LLC_RESETCOUNTER(l) { \
482 (l)->llcl_vs = (l)->llcl_vr = (l)->llcl_retry = 0; \
483 llc_resetwindow((l)); \
484 }
485
486 /*
487 * LLC2 macro definitions
488 */
489
490
491 #define LLC_START_ACK_TIMER(l) LLC_STARTTIMER((l),ACK)
492 #define LLC_STOP_ACK_TIMER(l) LLC_STOPTIMER((l),ACK)
493 #define LLC_START_REJ_TIMER(l) LLC_STARTTIMER((l),REJ)
494 #define LLC_STOP_REJ_TIMER(l) LLC_STOPTIMER((l),REJ)
495 #define LLC_START_P_TIMER(l) { \
496 LLC_STARTTIMER((l),P); \
497 if (LLC_GETFLAG((l),P) == 0) \
498 (l)->llcl_retry = 0; \
499 LLC_SETFLAG((l),P,1); \
500 }
501 #define LLC_STOP_P_TIMER(l) { \
502 LLC_STOPTIMER((l),P); \
503 LLC_SETFLAG((l),P,0); \
504 }
505 #define LLC_STOP_ALL_TIMERS(l) { \
506 LLC_STOPTIMER((l),ACK); \
507 LLC_STOPTIMER((l),REJ); \
508 LLC_STOPTIMER((l),BUSY); \
509 LLC_STOPTIMER((l),P); \
510 }
511
512
513 #define LLC_INC(i) (i) = ((i)+1) % LLC_MAX_SEQUENCE
514
515 #define LLC_NR_VALID(l,nr) \
516 ((l)->llcl_vs < (l)->llcl_nr_received ? \
517 (((nr) >= (l)->llcl_nr_received) || \
518 ((nr) <= (l)->llcl_vs) ? 1 : 0) : \
519 (((nr) <= (l)->llcl_vs) && \
520 ((nr) >= (l)->llcl_nr_received) ? 1 : 0))
521
522 #define LLC_UPDATE_P_FLAG(l,cr,pf) { \
523 if ((cr) == LLC_RSP && (pf) == 1) { \
524 LLC_SETFLAG((l),P,0); \
525 LLC_STOPTIMER((l),P); \
526 } \
527 }
528
529 #define LLC_UPDATE_NR_RECEIVED(l,nr) { \
530 while ((l)->llcl_nr_received != (nr)) { \
531 struct mbuf *_m; \
532 short seq; \
533 seq = llc_seq2slot((l),(l)->llcl_nr_received); \
534 if ((_m = (l)->llcl_output_buffers[seq]) != NULL) \
535 m_freem(_m); \
536 (l)->llcl_output_buffers[seq] = NULL; \
537 LLC_INC((l)->llcl_nr_received); \
538 (l)->llcl_slotsfree++; \
539 } \
540 (l)->llcl_retry = 0; \
541 if ((l)->llcl_slotsfree < (l)->llcl_window) { \
542 LLC_START_ACK_TIMER(l); \
543 } else { \
544 LLC_STOP_ACK_TIMER(l); \
545 } \
546 LLC_STARTTIMER((l),DACTION); \
547 }
548
549 #define LLC_SET_REMOTE_BUSY(l,a) { \
550 if (LLC_GETFLAG((l),REMOTE_BUSY) == 0) { \
551 LLC_SETFLAG((l),REMOTE_BUSY,1); \
552 LLC_STARTTIMER((l),BUSY); \
553 (a) = LLC_REMOTE_BUSY; \
554 } else { \
555 (a) = 0; \
556 } \
557 }
558
559 #define LLC_CLEAR_REMOTE_BUSY(l,a) { \
560 if (LLC_GETFLAG((l),REMOTE_BUSY) == 1) { \
561 LLC_SETFLAG((l),REMOTE_BUSY,1); \
562 LLC_STOPTIMER((l),BUSY); \
563 if (LLC_STATEEQ((l),NORMAL) || \
564 LLC_STATEEQ((l),REJECT) || \
565 LLC_STATEEQ((l),BUSY)) \
566 llc_resend((l),LLC_CMD,0); \
567 (a) = LLC_REMOTE_NOT_BUSY; \
568 } else { \
569 (a) = 0; \
570 } \
571 }
572
573 #define LLC_DACKCMD 0x1
574 #define LLC_DACKCMDPOLL 0x2
575 #define LLC_DACKRSP 0x3
576 #define LLC_DACKRSPFINAL 0x4
577
578 #define LLC_SENDACKNOWLEDGE(l,cmd,pf) { \
579 if ((cmd) == LLC_CMD) { \
580 LLC_SETFLAG((l),DACTION,((pf) == 0 ? LLC_DACKCMD : \
581 LLC_DACKCMDPOLL)); \
582 } else { \
583 LLC_SETFLAG((l),DACTION,((pf) == 0 ? LLC_DACKRSP : \
584 LLC_DACKRSPFINAL)); \
585 } \
586 }
587
588 #define LLC_FRMR_W (1<<0)
589 #define LLC_FRMR_X (1<<1)
590 #define LLC_FRMR_Y (1<<2)
591 #define LLC_FRMR_Z (1<<3)
592 #define LLC_FRMR_V (1<<4)
593
594 #define LLC_SETFRMR(l,f,cr,c) { \
595 if ((f)->llc_control & 0x3) { \
596 (l)->llcl_frmr_pdu0 = (f)->llc_control; \
597 (l)->llcl_frmr_pdu1 = 0; \
598 } else { \
599 (l)->llcl_frmr_pdu0 = (f)->llc_control; \
600 (l)->llcl_frmr_pdu1 = (f)->llc_control_ext; \
601 } \
602 LLCCSBITS((l)->llcl_frmr_control,f_vs,(l)->llcl_vs); \
603 LLCCSBITS((l)->llcl_frmr_control_ext,f_cr,(cr)); \
604 LLCSBITS((l)->llcl_frmr_control_ext,f_vr,(l)->llcl_vr); \
605 LLCCSBITS((l)->llcl_frmr_cause,f_wxyzv,(c)); \
606 }
607
608 /*
609 * LLC tracing levels:
610 * LLCTR_INTERESTING interesting event,we might care to know about
611 * it,but then again,we might not ...
612 * LLCTR_SHOULDKNOW we probably should know about this event
613 * LLCTR_URGENT something has gone utterly wrong ...
614 */
615 #define LLCTR_INTERESTING 1
616 #define LLCTR_SHOULDKNOW 2
617 #define LLCTR_URGENT 3
618
619 #ifdef LLCDEBUG
620 #define LLC_TRACE(lp,l,msg) llc_trace((lp),(l),(msg))
621 #else /* LLCDEBUG */
622 #define LLC_TRACE(lp,l,msg) /* NOOP */
623 #endif /* LLCDEBUG */
624
625 #define LLC_N2_VALUE 15 /* up to 15 retries */
626 #define LLC_ACK_TIMER 10 /* 5 secs */
627 #define LLC_P_TIMER 4 /* 2 secs */
628 #define LLC_BUSY_TIMER 12 /* 6 secs */
629 #define LLC_REJ_TIMER 12 /* 6 secs */
630 #define LLC_AGE_TIMER 40 /* 20 secs */
631 #define LLC_DACTION_TIMER 2 /* 1 secs */
632
633 #if defined (_KERNEL)
634 extern int llc_n2;
635 extern int llc_ACK_timer;
636 extern int llc_P_timer;
637 extern int llc_REJ_timer;
638 extern int llc_BUSY_timer;
639 extern int llc_AGE_timer;
640 extern int llc_DACTION_timer;
641
642 extern int af_link_rts_init_done;
643
644 #define USES_AF_LINK_RTS { \
645 if (!af_link_rts_init_done) { \
646 rn_inithead((void **)&rt_tables[AF_LINK],32); \
647 af_link_rts_init_done++; \
648 } \
649 }
650
651 extern struct ifqueue llcintrq;
652
653 extern struct llccb_q llccb_q;
654 extern char *frame_names[];
655
656 /*
657 * Function prototypes
658 */
659 /* llc_input.c */
660 void llcintr __P((void));
661 int llc_input __P((struct mbuf *, ...));
662 void *llc_ctlinput __P((int, struct sockaddr *, void *));
663
664 /* llc_output.c */
665 int llc_output __P((struct mbuf *, ...));
666 void llc_start __P((struct llc_linkcb *));
667 void llc_send __P((struct llc_linkcb *, int, int, int));
668 void llc_resend __P((struct llc_linkcb *, int, int));
669 void llc_rawsend __P((struct llc_linkcb *, struct mbuf *, struct llc *, int,
670 int, int, int));
671
672 /* llc_subr.c */
673 int sdl_cmp __P((struct sockaddr_dl *, struct sockaddr_dl *));
674 void sdl_copy __P((struct sockaddr_dl *, struct sockaddr_dl *));
675 void sdl_swapaddr __P((struct sockaddr_dl *, struct sockaddr_dl *));
676 struct sockaddr_dl *sdl_getaddrif __P((struct ifnet *));
677 int sdl_checkaddrif __P((struct ifnet *, struct sockaddr_dl *));
678 int sdl_setaddrif __P((struct ifnet *, u_char *, u_char, u_char,
679 struct sockaddr_dl *));
680 int sdl_sethdrif __P((struct ifnet *, u_char *, u_char, u_char *, u_char,
681 u_char, struct sdl_hdr *));
682 struct npaidbentry *llc_setsapinfo __P((struct ifnet *, u_char, u_char,
683 struct dllconfig *));
684 struct npaidbentry *llc_getsapinfo __P((u_char, struct ifnet *));
685 short llc_seq2slot __P((struct llc_linkcb *, short));
686 int llc_state_ADM __P((struct llc_linkcb *, struct llc *, int, int, int));
687 int llc_state_CONN __P((struct llc_linkcb *, struct llc *, int, int, int));
688 int llc_state_RESET_WAIT __P((struct llc_linkcb *, struct llc *, int,
689 int, int));
690 int llc_state_RESET_CHECK __P((struct llc_linkcb *, struct llc *, int,
691 int, int));
692 int llc_state_SETUP __P((struct llc_linkcb *, struct llc *, int, int, int));
693 int llc_state_RESET __P((struct llc_linkcb *, struct llc *, int, int, int));
694 int llc_state_D_CONN __P((struct llc_linkcb *, struct llc *, int, int, int));
695 int llc_state_ERROR __P((struct llc_linkcb *, struct llc *, int, int, int));
696 int llc_state_NBRAcore __P((struct llc_linkcb *, struct llc *, int, int, int));
697 int llc_state_NORMAL __P((struct llc_linkcb *, struct llc *, int, int, int));
698 int llc_state_BUSY __P((struct llc_linkcb *, struct llc *, int, int, int));
699 int llc_state_REJECT __P((struct llc_linkcb *, struct llc *, int, int, int));
700 int llc_state_AWAIT __P((struct llc_linkcb *, struct llc *, int, int, int));
701 int llc_state_AWAIT_BUSY __P((struct llc_linkcb *, struct llc *, int, int,
702 int));
703 int llc_state_AWAIT_REJECT __P((struct llc_linkcb *, struct llc *, int, int,
704 int));
705 int llc_statehandler __P((struct llc_linkcb *, struct llc *, int, int, int));
706 void llc_init __P((void));
707 void llc_resetwindow __P((struct llc_linkcb *));
708 struct llc_linkcb *llc_newlink __P((struct sockaddr_dl *, struct ifnet *,
709 struct rtentry *, caddr_t,
710 struct rtentry *));
711 void llc_dellink __P((struct llc_linkcb *));
712 int llc_decode __P((struct llc *, struct llc_linkcb *));
713 int llc_anytimersup __P((struct llc_linkcb *));
714 char *llc_getstatename __P((struct llc_linkcb *));
715 void llc_link_dump __P((struct llc_linkcb *, const char *));
716 void llc_trace __P((struct llc_linkcb *, int, const char *));
717
718 /* llc_timer.c */
719 void llc_timer __P((void));
720
721 #endif
Cache object: 7150ff9307965e296481573b8837cf52
|