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