diff options
Diffstat (limited to 'sys/netccitt/llc_subr.c')
-rw-r--r-- | sys/netccitt/llc_subr.c | 296 |
1 files changed, 148 insertions, 148 deletions
diff --git a/sys/netccitt/llc_subr.c b/sys/netccitt/llc_subr.c index f38c575..9699be6 100644 --- a/sys/netccitt/llc_subr.c +++ b/sys/netccitt/llc_subr.c @@ -1,9 +1,9 @@ -/* - * Copyright (C) Dirk Husemann, Computer Science Department IV, +/* + * Copyright (C) Dirk Husemann, Computer Science Department IV, * University of Erlangen-Nuremberg, Germany, 1990, 1991, 1992 * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. - * + * * This code is derived from software contributed to Berkeley by * Dirk Husemann and the Computer Science Department (IV) of * the University of Erlangen-Nuremberg, Germany. @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * @(#)llc_subr.c 8.1 (Berkeley) 6/10/93 - * $Id: llc_subr.c,v 1.3 1994/12/13 22:32:14 wollman Exp $ + * $Id: llc_subr.c,v 1.4 1995/05/11 19:26:40 rgrimes Exp $ */ #include <sys/param.h> @@ -86,8 +86,8 @@ struct bitslice llc_bitslice[] = { }; /* - * We keep the link control blocks on a doubly linked list - - * primarily for checking in llc_time() + * We keep the link control blocks on a doubly linked list - + * primarily for checking in llc_time() */ struct llccb_q llccb_q = { &llccb_q, &llccb_q }; @@ -97,7 +97,7 @@ struct llccb_q llccb_q = { &llccb_q, &llccb_q }; * initialized yet. */ -int af_link_rts_init_done = 0; +int af_link_rts_init_done = 0; /* @@ -126,20 +126,20 @@ sdl_swapaddr(struct sockaddr_dl *sdl_a, struct sockaddr_dl *sdl_b) { struct sockaddr_dl sdl_tmp; - sdl_copy(sdl_a, &sdl_tmp); - sdl_copy(sdl_b, sdl_a); + sdl_copy(sdl_a, &sdl_tmp); + sdl_copy(sdl_b, sdl_a); sdl_copy(&sdl_tmp, sdl_b); } /* Fetch the sdl of the associated if */ -struct sockaddr_dl * +struct sockaddr_dl * sdl_getaddrif(struct ifnet *ifp) { register struct ifaddr *ifa; - for(ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) - if (ifa->ifa_addr->sa_family == AF_LINK ) + for(ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) + if (ifa->ifa_addr->sa_family == AF_LINK ) return((struct sockaddr_dl *)(ifa->ifa_addr)); return((struct sockaddr_dl *)0); @@ -151,27 +151,27 @@ sdl_checkaddrif(struct ifnet *ifp, struct sockaddr_dl *sdl_c) { register struct ifaddr *ifa; - for(ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) - if ((ifa->ifa_addr->sa_family == AF_LINK ) && + for(ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) + if ((ifa->ifa_addr->sa_family == AF_LINK ) && !sdl_cmp((struct sockaddr_dl *)(ifa->ifa_addr), sdl_c)) return(1); - + return(0); } /* Build an sdl from MAC addr, DLSAP addr, and interface */ -sdl_setaddrif(struct ifnet *ifp, u_char *mac_addr, u_char dlsap_addr, +sdl_setaddrif(struct ifnet *ifp, u_char *mac_addr, u_char dlsap_addr, u_char mac_len, struct sockaddr_dl *sdl_to) { register struct sockaddr_dl *sdl_tmp; - if ((sdl_tmp = sdl_getaddrif(ifp)) ) { - sdl_copy(sdl_tmp, sdl_to); + if ((sdl_tmp = sdl_getaddrif(ifp)) ) { + sdl_copy(sdl_tmp, sdl_to); bcopy((caddr_t) mac_addr, (caddr_t) LLADDR(sdl_to), mac_len); *(LLADDR(sdl_to)+mac_len) = dlsap_addr; - sdl_to->sdl_alen = mac_len+1; - return(1); + sdl_to->sdl_alen = mac_len+1; + return(1); } else return(0); } @@ -188,9 +188,9 @@ sdl_sethdrif(struct ifnet *ifp, u_char *mac_src, u_char dlsap_src, u_char *mac_d else return(1); } -static struct sockaddr_dl sap_saddr; +static struct sockaddr_dl sap_saddr; static struct sockaddr_dl sap_sgate = { - sizeof(struct sockaddr_dl), /* _len */ + sizeof(struct sockaddr_dl), /* _len */ AF_LINK /* _af */ }; @@ -200,61 +200,61 @@ static struct sockaddr_dl sap_sgate = { struct npaidbentry * llc_setsapinfo(struct ifnet *ifp, u_char af, u_char sap, struct dllconfig *llconf) { - struct protosw *pp; - struct sockaddr_dl *ifdl_addr; - struct rtentry *sirt = (struct rtentry *)0; - struct npaidbentry *sapinfo; - u_char saploc; + struct protosw *pp; + struct sockaddr_dl *ifdl_addr; + struct rtentry *sirt = (struct rtentry *)0; + struct npaidbentry *sapinfo; + u_char saploc; int size = sizeof(struct npaidbentry); USES_AF_LINK_RTS; - /* - * We rely/assume that only STREAM protocols will make use of - * connection oriented LLC2. If this will one day not be the - * case this will obviously fail. - */ - pp = pffindtype (af, SOCK_STREAM); - if (pp == 0 || pp->pr_input == 0 || pp->pr_ctlinput == 0) { - printf("network level protosw error"); - return 0; + /* + * We rely/assume that only STREAM protocols will make use of + * connection oriented LLC2. If this will one day not be the + * case this will obviously fail. + */ + pp = pffindtype (af, SOCK_STREAM); + if (pp == 0 || pp->pr_input == 0 || pp->pr_ctlinput == 0) { + printf("network level protosw error"); + return 0; } /* * We need a way to jot down the LLC2 configuration for - * a certain LSAP address. To do this we enter + * a certain LSAP address. To do this we enter * a "route" for the SAP. */ ifdl_addr = sdl_getaddrif(ifp); - sdl_copy(ifdl_addr, &sap_saddr); + sdl_copy(ifdl_addr, &sap_saddr); sdl_copy(ifdl_addr, &sap_sgate); - saploc = LLSAPLOC(&sap_saddr, ifp); + saploc = LLSAPLOC(&sap_saddr, ifp); sap_saddr.sdl_data[saploc] = sap; sap_saddr.sdl_alen++; - /* now enter it */ + /* now enter it */ rtrequest(RTM_ADD, (struct sockaddr *)&sap_saddr, - (struct sockaddr *)&sap_sgate, 0, 0, &sirt); - if (sirt == 0) + (struct sockaddr *)&sap_sgate, 0, 0, &sirt); + if (sirt == 0) return 0; /* Plug in config information in rt->rt_llinfo */ - sirt->rt_llinfo = malloc(size , M_PCB, M_WAITOK); - sapinfo = (struct npaidbentry *) sirt->rt_llinfo; - if (sapinfo) { - bzero ((caddr_t)sapinfo, size); - /* - * For the time being we support LLC CLASS II here - * only - */ - sapinfo->si_class = LLC_CLASS_II; + sirt->rt_llinfo = malloc(size , M_PCB, M_WAITOK); + sapinfo = (struct npaidbentry *) sirt->rt_llinfo; + if (sapinfo) { + bzero ((caddr_t)sapinfo, size); + /* + * For the time being we support LLC CLASS II here + * only + */ + sapinfo->si_class = LLC_CLASS_II; sapinfo->si_window = llconf->dllcfg_window; - sapinfo->si_trace = llconf->dllcfg_trace; + sapinfo->si_trace = llconf->dllcfg_trace; if (sapinfo->si_trace) llc_tracelevel--; else llc_tracelevel++; - sapinfo->si_input = pp->pr_input; + sapinfo->si_input = pp->pr_input; sapinfo->si_ctlinput = (caddr_t (*)())pp->pr_ctlinput; return (sapinfo); @@ -264,26 +264,26 @@ llc_setsapinfo(struct ifnet *ifp, u_char af, u_char sap, struct dllconfig *llcon } /* - * Get sapinfo for SAP address and interface + * Get sapinfo for SAP address and interface */ struct npaidbentry * llc_getsapinfo(u_char sap, struct ifnet *ifp) { - struct sockaddr_dl *ifdl_addr; - struct sockaddr_dl si_addr; - struct rtentry *sirt; + struct sockaddr_dl *ifdl_addr; + struct sockaddr_dl si_addr; + struct rtentry *sirt; u_char saploc; USES_AF_LINK_RTS; - ifdl_addr = sdl_getaddrif(ifp); - sdl_copy(ifdl_addr, &si_addr); - saploc = LLSAPLOC(&si_addr, ifp); + ifdl_addr = sdl_getaddrif(ifp); + sdl_copy(ifdl_addr, &si_addr); + saploc = LLSAPLOC(&si_addr, ifp); si_addr.sdl_data[saploc] = sap; si_addr.sdl_alen++; - if ((sirt = rtalloc1((struct sockaddr *)&si_addr, 0, 0UL))) - sirt->rt_refcnt--; + if ((sirt = rtalloc1((struct sockaddr *)&si_addr, 0, 0UL))) + sirt->rt_refcnt--; else return(0); return((struct npaidbentry *)sirt->rt_llinfo); @@ -305,8 +305,8 @@ llc_getsapinfo(u_char sap, struct ifnet *ifp) * The slot sl(sn) for any given sequence number sn is given by * * sl(sn) = (llcl_freeslot + llcl_window - 1 - (llcl_projvs + - * LLC_MAX_SEQUENCE- sn) % LLC_MAX_SEQUENCE) % - * llcl_window + * LLC_MAX_SEQUENCE- sn) % LLC_MAX_SEQUENCE) % + * llcl_window * * i.e. we first calculate the number of frames we need to ``go back'' * from the current one (really the next one, but that doesn't matter as @@ -319,8 +319,8 @@ llc_seq2slot(struct llc_linkcb *linkp, short seqn) { register sn = 0; - sn = (linkp->llcl_freeslot + linkp->llcl_window - - (linkp->llcl_projvs + LLC_MAX_SEQUENCE - seqn) % + sn = (linkp->llcl_freeslot + linkp->llcl_window - + (linkp->llcl_projvs + LLC_MAX_SEQUENCE - seqn) % LLC_MAX_SEQUENCE) % linkp->llcl_window; return sn; @@ -331,10 +331,10 @@ llc_seq2slot(struct llc_linkcb *linkp, short seqn) * * There is in most cases one function per LLC2 state. The LLC2 standard * ISO 8802-2 allows in some cases for ambiguities, i.e. we have the choice - * to do one thing or the other. Right now I have just chosen one but have also - * indicated the spot by "multiple possibilities". One could make the behavior + * to do one thing or the other. Right now I have just chosen one but have also + * indicated the spot by "multiple possibilities". One could make the behavior * in those cases configurable, allowing the superuser to enter a profile word - * (32/64 bits, whatever is needed) that would suit her needs [I quite like + * (32/64 bits, whatever is needed) that would suit her needs [I quite like * that idea, perhaps I'll get around to it]. * * [Preceeding each state handler function is the description as taken from @@ -364,7 +364,7 @@ llc_state_ADM(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_NEWSTATE(linkp, SETUP); break; case LLCFT_SABME + LLC_CMD: - /* + /* * ISO 8802-2, table 7-1, ADM state says to set * the P flag, yet this will cause an SABME [P] to be * answered with an UA only, not an UA [F], all @@ -378,7 +378,7 @@ llc_state_ADM(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, llc_send(linkp, LLCFT_DM, LLC_RSP, pollfinal); break; default: - if (cmdrsp == LLC_CMD && pollfinal == 1) + if (cmdrsp == LLC_CMD && pollfinal == 1) llc_send(linkp, LLCFT_DM, LLC_RSP, 1); /* remain in ADM state */ } @@ -424,7 +424,7 @@ llc_state_CONN(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, /* * RESET_WAIT --- The local connection component is waiting for the local user - * to indicate a RESET_REQUEST or a DISCONNECT_REQUEST. + * to indicate a RESET_REQUEST or a DISCONNECT_REQUEST. */ int llc_state_RESET_WAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, @@ -441,7 +441,7 @@ llc_state_RESET_WAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind linkp->llcl_retry = 0; LLC_NEWSTATE(linkp, RESET); } else { - llc_send(linkp, LLCFT_UA, LLC_RSP, + llc_send(linkp, LLCFT_UA, LLC_RSP, LLC_GETFLAG(linkp, F)); LLC_RESETCOUNTER(linkp); LLC_SETFLAG(linkp, P, 0); @@ -458,7 +458,7 @@ llc_state_RESET_WAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind linkp->llcl_retry = 0; LLC_NEWSTATE(linkp, D_CONN); } else { - llc_send(linkp, LLCFT_DM, LLC_RSP, + llc_send(linkp, LLCFT_DM, LLC_RSP, LLC_GETFLAG(linkp, F)); LLC_NEWSTATE(linkp, ADM); } @@ -682,7 +682,7 @@ llc_state_D_CONN(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, /* * ERROR --- The local connection component has detected an error in a received - * PDU and has sent a FRMR response PDU. It is waiting for a reply from + * PDU and has sent a FRMR response PDU. It is waiting for a reply from * the remote connection component. */ int @@ -790,7 +790,7 @@ llc_state_NBRAcore(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; case LLC_INVALID_NR + LLC_CMD: case LLC_INVALID_NS + LLC_CMD: - LLC_SETFRMR(linkp, frame, cmdrsp, + LLC_SETFRMR(linkp, frame, cmdrsp, (frame_kind == LLC_INVALID_NR ? LLC_FRMR_Z : (LLC_FRMR_V | LLC_FRMR_W))); llc_send(linkp, LLCFT_FRMR, LLC_RSP, pollfinal); @@ -821,7 +821,7 @@ llc_state_NBRAcore(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; } default: - if (cmdrsp == LLC_RSP && pollfinal == 1 && + if (cmdrsp == LLC_RSP && pollfinal == 1 && LLC_GETFLAG(linkp, P) == 0) { LLC_SETFRMR(linkp, frame, cmdrsp, LLC_FRMR_W); LLC_STOP_ALL_TIMERS(linkp); @@ -869,7 +869,7 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, if (LLC_TIMERXPIRED(linkp, ACK) != LLC_TIMER_RUNNING) LLC_START_ACK_TIMER(linkp); } else { -#endif +#endif /* multiple possibilities */ llc_send(linkp, LLCFT_INFO, LLC_CMD, 0); if (LLC_TIMERXPIRED(linkp, ACK) != LLC_TIMER_RUNNING) @@ -889,12 +889,12 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_SETFLAG(linkp, DATA, 0); LLC_NEWSTATE(linkp, BUSY); action = 0; - } else { + } else { /* multiple possibilities --- CMD/RSP-wise */ llc_send(linkp, LLCFT_RNR, LLC_CMD, 0); LLC_SETFLAG(linkp, DATA, 0); LLC_NEWSTATE(linkp, BUSY); - action = 0; + action = 0; } break; case LLC_INVALID_NS + LLC_CMD: @@ -914,7 +914,7 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_START_REJ_TIMER(linkp); LLC_NEWSTATE(linkp, REJECT); action = 0; - } else if ((pollfinal == 0 && p == 0) || + } else if ((pollfinal == 0 && p == 0) || (pollfinal == 1 && p == 1 && cmdrsp == LLC_RSP)) { llc_send(linkp, LLCFT_REJ, LLC_CMD, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -926,12 +926,12 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_NEWSTATE(linkp, REJECT); } break; - } + } case LLCFT_INFO + LLC_CMD: case LLCFT_INFO + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { LLC_INC(linkp->llcl_vr); LLC_SENDACKNOWLEDGE(linkp, LLC_RSP, 1); @@ -948,7 +948,7 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); LLC_SENDACKNOWLEDGE(linkp, LLC_CMD, 0); LLC_UPDATE_NR_RECEIVED(linkp, nr); - if (cmdrsp == LLC_RSP && pollfinal == 1) + if (cmdrsp == LLC_RSP && pollfinal == 1) LLC_CLEAR_REMOTE_BUSY(linkp, action); action = LLC_DATA_INDICATION; } @@ -963,24 +963,24 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_SENDACKNOWLEDGE(linkp, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); LLC_CLEAR_REMOTE_BUSY(linkp, action); - } else if ((pollfinal == 0) || + } else if ((pollfinal == 0) || (cmdrsp == LLC_RSP && pollfinal == 1 && p == 1)) { LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); LLC_UPDATE_NR_RECEIVED(linkp, nr); LLC_CLEAR_REMOTE_BUSY(linkp, action); - } + } break; } case LLCFT_RNR + LLC_CMD: case LLCFT_RNR + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); LLC_SET_REMOTE_BUSY(linkp, action); - } else if ((pollfinal == 0) || + } else if ((pollfinal == 0) || (cmdrsp == LLC_RSP && pollfinal == 1 && p == 1)) { LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1031,7 +1031,7 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; case LLC_ACK_TIMER_EXPIRED: case LLC_BUSY_TIMER_EXPIRED: - if ((LLC_GETFLAG(linkp, P) == 0) + if ((LLC_GETFLAG(linkp, P) == 0) && (linkp->llcl_retry < llc_n2)) { llc_send(linkp, LLCFT_RR, LLC_CMD, 1); LLC_START_P_TIMER(linkp); @@ -1042,7 +1042,7 @@ llc_state_NORMAL(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; } if (action == LLC_PASSITON) - action = llc_state_NBRAcore(linkp, frame, frame_kind, + action = llc_state_NBRAcore(linkp, frame, frame_kind, cmdrsp, pollfinal); return action; @@ -1082,7 +1082,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, register int df = LLC_GETFLAG(linkp, DATA); switch (df) { - case 1: + case 1: if (p == 0) { /* multiple possibilities */ llc_send(linkp, LLCFT_REJ, LLC_CMD, 1); @@ -1142,7 +1142,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, llc_send(linkp, LLCFT_RNR, LLC_CMD, 0); LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); LLC_UPDATE_NR_RECEIVED(linkp, nr); - if (LLC_GETFLAG(linkp, DATA) == 0) + if (LLC_GETFLAG(linkp, DATA) == 0) LLC_SETFLAG(linkp, DATA, 1); if (cmdrsp == LLC_RSP && pollfinal == 1) { LLC_CLEAR_REMOTE_BUSY(linkp, action); @@ -1160,7 +1160,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, case LLCFT_INFO + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { LLC_INC(linkp->llcl_vr); llc_send(linkp, LLCFT_RNR, LLC_RSP, 1); @@ -1168,7 +1168,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, if (LLC_GETFLAG(linkp, DATA) == 2) LLC_STOP_REJ_TIMER(linkp); LLC_SETFLAG(linkp, DATA, 0); - action = LLC_DATA_INDICATION; + action = LLC_DATA_INDICATION; } else if ((cmdrsp == LLC_CMD && pollfinal == 0 && p == 0) || (cmdrsp == LLC_RSP && pollfinal == p)) { LLC_INC(linkp->llcl_vr); @@ -1192,12 +1192,12 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; } case LLCFT_RR + LLC_CMD: - case LLCFT_RR + LLC_RSP: + case LLCFT_RR + LLC_RSP: case LLCFT_RNR + LLC_CMD: - case LLCFT_RNR + LLC_RSP: { + case LLCFT_RNR + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RNR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1206,7 +1206,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, } else { LLC_SET_REMOTE_BUSY(linkp, action); } - } else if (pollfinal = 0 || + } else if (pollfinal = 0 || (cmdrsp == LLC_RSP && pollfinal == 1)) { LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1272,7 +1272,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, } break; case LLC_REJ_TIMER_EXPIRED: - if (linkp->llcl_retry < llc_n2) + if (linkp->llcl_retry < llc_n2) if (LLC_GETFLAG(linkp, P) == 0) { /* multiple possibilities */ llc_send(linkp, LLCFT_RNR, LLC_CMD, 1); @@ -1286,11 +1286,11 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_NEWSTATE(linkp, BUSY); action = 0; } - + break; } if (action == LLC_PASSITON) - action = llc_state_NBRAcore(linkp, frame, frame_kind, + action = llc_state_NBRAcore(linkp, frame, frame_kind, cmdrsp, pollfinal); return action; @@ -1303,7 +1303,7 @@ llc_state_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, * component resend a specific I PDU that the local connection * componnent has detected as being out of sequence. Both I PDUs and * supervisory PDUs may be sent and received. - */ + */ int llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, int cmdrsp, int pollfinal) @@ -1319,7 +1319,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_START_ACK_TIMER(linkp); LLC_NEWSTATE(linkp, REJECT); action = 0; - } else { + } else { llc_send(linkp, LLCFT_INFO, LLC_CMD, 0); if (LLC_TIMERXPIRED(linkp, ACK) != LLC_TIMER_RUNNING) LLC_START_ACK_TIMER(linkp); @@ -1342,7 +1342,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, } break; case LLC_INVALID_NS + LLC_CMD: - case LLC_INVALID_NS + LLC_RSP: { + case LLC_INVALID_NS + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); @@ -1350,7 +1350,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, llc_send(linkp, LLCFT_RR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); action = 0; - } else if (pollfinal == 0 || + } else if (pollfinal == 0 || (cmdrsp == LLC_RSP && pollfinal == 1 && p == 1)) { LLC_UPDATE_NR_RECEIVED(linkp, nr); LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); @@ -1364,7 +1364,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, case LLCFT_INFO + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { LLC_INC(linkp->llcl_vr); LLC_SENDACKNOWLEDGE(linkp, LLC_RSP, 1); @@ -1401,7 +1401,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_SENDACKNOWLEDGE(linkp, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); LLC_CLEAR_REMOTE_BUSY(linkp, action); - } else if (pollfinal == 0 || + } else if (pollfinal == 0 || (cmdrsp == LLC_RSP && pollfinal == 1 && p == 1)) { LLC_UPDATE_P_FLAG(linkp, cmdrsp, pollfinal); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1413,7 +1413,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, case LLCFT_RNR + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1483,7 +1483,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, LLC_START_P_TIMER(linkp); LLC_START_REJ_TIMER(linkp); linkp->llcl_retry++; - /* + /* * I cannot locate the description of RESET_V(S) * in ISO 8802-2, table 7-1, state REJECT, last event, * and assume they meant to set V(S) to 0 ... @@ -1496,7 +1496,7 @@ llc_state_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; } if (action == LLC_PASSITON) - action = llc_state_NBRAcore(linkp, frame, frame_kind, + action = llc_state_NBRAcore(linkp, frame, frame_kind, cmdrsp, pollfinal); return action; @@ -1527,7 +1527,7 @@ llc_state_AWAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, case LLC_INVALID_NS + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_REJ, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1556,7 +1556,7 @@ llc_state_AWAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, case LLCFT_INFO + LLC_CMD: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + LLC_INC(linkp->llcl_vr); if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RR, LLC_RSP, 1); @@ -1583,7 +1583,7 @@ llc_state_AWAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, case LLCFT_REJ + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1598,7 +1598,7 @@ llc_state_AWAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, } else if (pollfinal == 0) { LLC_UPDATE_NR_RECEIVED(linkp, nr); LLC_CLEAR_REMOTE_BUSY(linkp, action); - } + } break; } case LLCFT_RNR + LLC_CMD: @@ -1632,7 +1632,7 @@ llc_state_AWAIT(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, break; } if (action == LLC_PASSITON) - action = llc_state_NBRAcore(linkp, frame, frame_kind, + action = llc_state_NBRAcore(linkp, frame, frame_kind, cmdrsp, pollfinal); return action; @@ -1707,7 +1707,7 @@ llc_state_AWAIT_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind case LLCFT_INFO + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RNR, LLC_RSP, 1); LLC_INC(linkp->llcl_vr); @@ -1740,7 +1740,7 @@ llc_state_AWAIT_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind case LLCFT_REJ + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RNR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1765,7 +1765,7 @@ llc_state_AWAIT_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind case LLCFT_RNR + LLC_RSP: { register int p = LLC_GETFLAG(linkp, P); register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RNR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1792,7 +1792,7 @@ llc_state_AWAIT_BUSY(struct llc_linkcb *linkp, struct llc *frame, int frame_kind break; } if (action == LLC_PASSITON) - action = llc_state_NBRAcore(linkp, frame, frame_kind, + action = llc_state_NBRAcore(linkp, frame, frame_kind, cmdrsp, pollfinal); return action; @@ -1827,7 +1827,7 @@ llc_state_AWAIT_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_ki case LLC_INVALID_NS + LLC_CMD: case LLC_INVALID_NS + LLC_RSP: { register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1841,7 +1841,7 @@ llc_state_AWAIT_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_ki LLC_NEWSTATE(linkp, REJECT); } else if (pollfinal == 0) { LLC_UPDATE_NR_RECEIVED(linkp, nr); - action = 0; + action = 0; } break; } @@ -1881,7 +1881,7 @@ llc_state_AWAIT_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_ki case LLCFT_RR + LLC_RSP: case LLCFT_REJ + LLC_RSP: { register int nr = LLCGBITS(frame->llc_control_ext, s_nr); - + if (cmdrsp == LLC_CMD && pollfinal == 1) { llc_send(linkp, LLCFT_RR, LLC_RSP, 1); LLC_UPDATE_NR_RECEIVED(linkp, nr); @@ -1929,7 +1929,7 @@ llc_state_AWAIT_REJECT(struct llc_linkcb *linkp, struct llc *frame, int frame_ki break; } if (action == LLC_PASSITON) - action = llc_state_NBRAcore(linkp, frame, frame_kind, + action = llc_state_NBRAcore(linkp, frame, frame_kind, cmdrsp, pollfinal); return action; @@ -1958,7 +1958,7 @@ llc_statehandler(struct llc_linkcb *linkp, struct llc *frame, int frame_kind, /* * Now call the current statehandler function. */ - action = (*linkp->llcl_statehandler)(linkp, frame, frame_kind, + action = (*linkp->llcl_statehandler)(linkp, frame, frame_kind, cmdrsp, pollfinal); once_more_and_again: switch (action) { @@ -1966,7 +1966,7 @@ once_more_and_again: int naction; LLC_TRACE(linkp, LLCTR_INTERESTING, "CONNECT INDICATION"); - linkp->llcl_nlnext = + linkp->llcl_nlnext = (*linkp->llcl_sapinfo->si_ctlinput) (PRC_CONNECT_INDICATION, (struct sockaddr *) &linkp->llcl_addr, (caddr_t) linkp); @@ -1983,7 +1983,7 @@ once_more_and_again: case LLC_DISCONNECT_INDICATION: LLC_TRACE(linkp, LLCTR_INTERESTING, "DISCONNECT INDICATION"); (*linkp->llcl_sapinfo->si_ctlinput) - (PRC_DISCONNECT_INDICATION, + (PRC_DISCONNECT_INDICATION, (struct sockaddr *) &linkp->llcl_addr, linkp->llcl_nlnext); break; /* internally visible only */ @@ -1996,7 +1996,7 @@ once_more_and_again: break; case LLC_RESET_INDICATION_REMOTE: LLC_TRACE(linkp, LLCTR_SHOULDKNOW, "RESET INDICATION (REMOTE)"); - action = (*linkp->llcl_statehandler)(linkp, frame, + action = (*linkp->llcl_statehandler)(linkp, frame, NL_RESET_RESPONSE, 0, 0); goto once_more_and_again; case LLC_FRMR_SENT: @@ -2006,7 +2006,7 @@ once_more_and_again: LLC_TRACE(linkp, LLCTR_URGEN, "FRMR RECEIVED"); action = (*linkp->llcl_statehandler)(linkp, frame, NL_RESET_REQUEST, 0, 0); - + goto once_more_and_again; case LLC_REMOTE_BUSY: LLC_TRACE(linkp, LLCTR_SHOULDKNOW, "REMOTE BUSY"); @@ -2018,12 +2018,12 @@ once_more_and_again: */ llc_start(linkp); break; - } + } /* * Only LLC_DATA_INDICATION is for the time being * passed up to the network layer entity. - * The remaining action codes are for the time + * The remaining action codes are for the time * being visible internally only. * However, this can/may be changed if necessary. */ @@ -2034,7 +2034,7 @@ once_more_and_again: /* * Core LLC2 routines - */ + */ /* * The INIT call. This routine is called once after the system is booted. @@ -2061,8 +2061,8 @@ llc_resetwindow(struct llc_linkcb *linkp) /* Pick up all queued frames and collect them in a linked mbuf list */ if (linkp->llcl_slotsfree != linkp->llcl_window) { i = llc_seq2slot(linkp, linkp->llcl_nr_received); - anchor = mptr = linkp->llcl_output_buffers[i]; - for (; i != linkp->llcl_freeslot; + anchor = mptr = linkp->llcl_output_buffers[i]; + for (; i != linkp->llcl_freeslot; i = llc_seq2slot(linkp, i+1)) { if (linkp->llcl_output_buffers[i]) { mptr->m_nextpkt = linkp->llcl_output_buffers[i]; @@ -2083,7 +2083,7 @@ llc_resetwindow(struct llc_linkcb *linkp) } linkp->llcl_freeslot = i; } else linkp->llcl_freeslot = 0; - + /* We're resetting the link, the next frame to be acknowledged is 0 */ linkp->llcl_nr_received = 0; @@ -2092,14 +2092,14 @@ llc_resetwindow(struct llc_linkcb *linkp) return; } - + /* * llc_newlink() --- We allocate enough memory to contain a link control block * and initialize it properly. We don't intiate the actual setup * of the LLC2 link here. */ struct llc_linkcb * -llc_newlink(struct sockaddr_dl *dst, struct ifnet *ifp, struct rtentry *nlrt, +llc_newlink(struct sockaddr_dl *dst, struct ifnet *ifp, struct rtentry *nlrt, caddr_t nlnext, struct rtentry *llrt) { struct llc_linkcb *nlinkp; @@ -2113,7 +2113,7 @@ llc_newlink(struct sockaddr_dl *dst, struct ifnet *ifp, struct rtentry *nlrt, if (nlinkp == 0) return (NULL); bzero((caddr_t)nlinkp, sizeof(struct llc_linkcb)); - + /* copy link address */ sdl_copy(dst, &nlinkp->llcl_addr); @@ -2131,7 +2131,7 @@ llc_newlink(struct sockaddr_dl *dst, struct ifnet *ifp, struct rtentry *nlrt, /* setup initial state handler function */ nlinkp->llcl_statehandler = llc_state_ADM; - + /* hold on to interface pointer */ nlinkp->llcl_if = ifp; @@ -2143,13 +2143,13 @@ llc_newlink(struct sockaddr_dl *dst, struct ifnet *ifp, struct rtentry *nlrt, llcwindow = LLC_MAX_WINDOW; /* allocate memory for window buffer */ - MALLOC(nlinkp->llcl_output_buffers, struct mbuf **, + MALLOC(nlinkp->llcl_output_buffers, struct mbuf **, llcwindow*sizeof(struct mbuf *), M_PCB, M_DONTWAIT); if (nlinkp->llcl_output_buffers == 0) { FREE(nlinkp, M_PCB); return(NULL); } - bzero((caddr_t)nlinkp->llcl_output_buffers, + bzero((caddr_t)nlinkp->llcl_output_buffers, llcwindow*sizeof(struct mbuf *)); /* set window size & slotsfree */ @@ -2174,12 +2174,12 @@ llc_dellink(struct llc_linkcb *linkp) /* notify upper layer of imminent death */ if (linkp->llcl_nlnext && sapinfo->si_ctlinput) (*sapinfo->si_ctlinput) - (PRC_DISCONNECT_INDICATION, + (PRC_DISCONNECT_INDICATION, (struct sockaddr *)&linkp->llcl_addr, linkp->llcl_nlnext); /* pull the plug */ if (linkp->llcl_llrt) - ((struct npaidbentry *)(linkp->llcl_llrt->rt_llinfo))->np_link + ((struct npaidbentry *)(linkp->llcl_llrt->rt_llinfo))->np_link = (struct llc_linkcb *) 0; /* leave link control block queue */ @@ -2249,7 +2249,7 @@ llc_decode(struct llc* frame, struct llc_linkcb * linkp) case LLCFT_RNR: case LLCFT_REJ: /* splash! */ - if (LLC_NR_VALID(linkp, LLCGBITS(frame->llc_control_ext, + if (LLC_NR_VALID(linkp, LLCGBITS(frame->llc_control_ext, s_nr)) == 0) ft = LLC_INVALID_NR; break; @@ -2266,7 +2266,7 @@ int llc_anytimersup(struct llc_linkcb * linkp) { register int i; - + FOR_ALL_LLC_TIMERS(i) if (linkp->llcl_timers[i] > 0) break; @@ -2313,7 +2313,7 @@ llc_link_dump(struct llc_linkcb* linkp, const char *message) /* print interface */ printf("if %s%d\n", linkp->llcl_if->if_name, linkp->llcl_if->if_unit); - + /* print message */ printf(">> %s <<\n", message); @@ -2327,16 +2327,16 @@ llc_link_dump(struct llc_linkcb* linkp, const char *message) /* print state we're in and timers */ printf("state %s, ", llc_getstatename(linkp)); for (i = LLC_ACK_SHIFT; i < LLC_AGE_SHIFT; i++) - printf("%s-%c %d/", timer_names[i], + printf("%s-%c %d/", timer_names[i], (linkp->llcl_timerflags & (1<<i) ? 'R' : 'S'), linkp->llcl_timers[i]); - printf("%s-%c %d\n", timer_names[i], (linkp->llcl_timerflags & (1<<i) ? + printf("%s-%c %d\n", timer_names[i], (linkp->llcl_timerflags & (1<<i) ? 'R' : 'S'), linkp->llcl_timers[i]); /* print flag values */ printf("flags P %d/F %d/S %d/DATA %d/REMOTE_BUSY %d\n", LLC_GETFLAG(linkp, P), LLC_GETFLAG(linkp, F), - LLC_GETFLAG(linkp, S), + LLC_GETFLAG(linkp, S), LLC_GETFLAG(linkp, DATA), LLC_GETFLAG(linkp, REMOTE_BUSY)); /* print send and receive state variables, ack, and window */ |