Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  * llc_c_ac.c - actions performed during connection state transition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *   Functions in this module are implementation of connection component actions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *   Details of actions can be found in IEEE-802.2 standard document.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *   All functions have one connection and one event as input argument. All of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *   them return 0 On success and 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * Copyright (c) 1997 by Procom Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  * This program can be redistributed or modified under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  * GNU General Public License as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  * This program is distributed without any warranty or implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  * of merchantability or fitness for a particular purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  * See the GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <net/llc_conn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <net/llc_sap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <net/llc_c_ev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <net/llc_c_ac.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <net/llc_c_st.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <net/llc_pdu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <net/llc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) static int llc_conn_ac_data_confirm(struct sock *sk, struct sk_buff *ev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) static int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 					       struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) static int llc_conn_ac_set_p_flag_1(struct sock *sk, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #define INCORRECT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 	if (llc->remote_busy_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 		u8 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 		struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 		llc->remote_busy_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 		del_timer(&llc->busy_state_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 		nr = LLC_I_GET_NR(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 		llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	ev->ind_prim = LLC_CONN_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	ev->cfm_prim = LLC_CONN_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) static int llc_conn_ac_data_confirm(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	ev->cfm_prim = LLC_DATA_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) int llc_conn_ac_data_ind(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	llc_conn_rtn_pdu(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) int llc_conn_ac_disc_ind(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	u8 reason = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	if (ev->type == LLC_CONN_EV_TYPE_PDU) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 		struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		if (LLC_PDU_IS_RSP(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 		    LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 		    LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 			reason = LLC_DISC_REASON_RX_DM_RSP_PDU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 		else if (LLC_PDU_IS_CMD(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 			   LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 			   LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 			reason = LLC_DISC_REASON_RX_DISC_CMD_PDU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	} else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 		reason = LLC_DISC_REASON_ACK_TMR_EXP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 		rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 		ev->reason   = reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 		ev->ind_prim = LLC_DISC_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) int llc_conn_ac_disc_confirm(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	ev->reason   = ev->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	ev->cfm_prim = LLC_DISC_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	u8 reason = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	int rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	switch (ev->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	case LLC_CONN_EV_TYPE_PDU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		if (LLC_PDU_IS_RSP(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 		    LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 		    LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 			reason = LLC_RESET_REASON_LOCAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 			rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 		} else if (LLC_PDU_IS_CMD(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 			   LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 			   LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 			reason = LLC_RESET_REASON_REMOTE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 			rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	case LLC_CONN_EV_TYPE_ACK_TMR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	case LLC_CONN_EV_TYPE_P_TMR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	case LLC_CONN_EV_TYPE_REJ_TMR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	case LLC_CONN_EV_TYPE_BUSY_TMR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 		if (llc->retry_count > llc->n2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 			reason = LLC_RESET_REASON_LOCAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 			rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 		ev->reason   = reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 		ev->ind_prim = LLC_RESET_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) int llc_conn_ac_rst_confirm(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	ev->reason   = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	ev->cfm_prim = LLC_RESET_PRIM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) int llc_conn_ac_clear_remote_busy_if_f_eq_1(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 					    struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	if (LLC_PDU_IS_RSP(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	    LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	    LLC_I_PF_IS_1(pdu) && llc_sk(sk)->ack_pf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 		llc_conn_ac_clear_remote_busy(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 					       struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	if (llc->data_flag == 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 		del_timer(&llc->rej_sent_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 				    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		llc_pdu_init_as_disc_cmd(nskb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 		llc_conn_ac_set_p_flag_1(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		llc_pdu_init_as_dm_rsp(nskb, f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 		llc_pdu_init_as_dm_rsp(nskb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	struct sk_buff *nskb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	llc->rx_pdu_hdr = *((u32 *)pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	if (LLC_PDU_IS_CMD(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		f_bit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 			       sizeof(struct llc_frmr_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 		llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 					 llc->vR, INCORRECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 					       sizeof(struct llc_frmr_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 		struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 		llc_pdu_init_as_frmr_rsp(nskb, pdu, 0, llc->vS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 					 llc->vR, INCORRECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	struct sk_buff *nskb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 			       sizeof(struct llc_frmr_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 					 llc->vR, INCORRECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 			    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	if (likely(!rc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 		skb_get(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 		llc_conn_send_pdu(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 		llc_conn_ac_inc_vs_by_1(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) static int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 	struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 			    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 	llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	if (likely(!rc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 		skb_get(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 		llc_conn_send_pdu(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 		llc_conn_ac_inc_vs_by_1(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 			    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	if (likely(!rc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		skb_get(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		llc_conn_send_pdu(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		llc_conn_ac_inc_vs_by_1(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) int llc_conn_ac_resend_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	u8 nr = LLC_I_GET_NR(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 						struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	u8 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 		llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 		if (likely(!rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 			llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 			kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 		nr = LLC_I_GET_NR(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 		rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	u8 nr = LLC_I_GET_NR(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	llc_conn_resend_i_pdu_as_rsp(sk, nr, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 				    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 		llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 		llc_pdu_init_as_rej_rsp(nskb, 1, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 		llc_pdu_init_as_rej_rsp(nskb, 0, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 				    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 		llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 		llc_pdu_init_as_rnr_rsp(nskb, 1, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 		llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	if (!llc->remote_busy_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 		llc->remote_busy_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 		mod_timer(&llc->busy_state_timer.timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 			 jiffies + llc->busy_state_timer.expire);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 		llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 				    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		u8 f_bit = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		llc_pdu_init_as_rr_rsp(nskb, 1, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) void llc_conn_set_p_flag(struct sock *sk, u8 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	int state_changed = llc_sk(sk)->p_flag && !value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	llc_sk(sk)->p_flag = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	if (state_changed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 		sk->sk_state_change(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 		u8 *dmac = llc->daddr.mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		if (llc->dev->flags & IFF_LOOPBACK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 			dmac = llc->dev->dev_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 				    llc->daddr.lsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 		llc_pdu_init_as_sabme_cmd(nskb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		llc_conn_set_p_flag(sk, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		nskb->dev = llc->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 		llc_pdu_init_as_ua_rsp(nskb, f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) int llc_conn_ac_set_s_flag_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	llc_sk(sk)->s_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) int llc_conn_ac_set_s_flag_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	llc_sk(sk)->s_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	llc_conn_set_p_flag(sk, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	mod_timer(&llc->pf_cycle_timer.timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		  jiffies + llc->pf_cycle_timer.expire);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854)  *	llc_conn_ac_send_ack_if_needed - check if ack is needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855)  *	@sk: current connection structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856)  *	@skb: current event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858)  *	Checks number of received PDUs which have not been acknowledged, yet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859)  *	If number of them reaches to "npta"(Number of PDUs To Acknowledge) then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860)  *	sends an RR response as acknowledgement for them.  Returns 0 for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861)  *	success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) int llc_conn_ac_send_ack_if_needed(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	u8 pf_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	llc_pdu_decode_pf_bit(skb, &pf_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	llc->ack_pf |= pf_bit & 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	if (!llc->ack_must_be_send) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 		llc->first_pdu_Ns = llc->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		llc->ack_must_be_send = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		llc->ack_pf = pf_bit & 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	if (((llc->vR - llc->first_pdu_Ns + 1 + LLC_2_SEQ_NBR_MODULO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 			% LLC_2_SEQ_NBR_MODULO) >= llc->npta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 		llc_conn_ac_send_rr_rsp_f_set_ackpf(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 		llc->ack_must_be_send	= 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		llc->ack_pf		= 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 		llc_conn_ac_inc_npta_value(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886)  *	llc_conn_ac_rst_sendack_flag - resets ack_must_be_send flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887)  *	@sk: current connection structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888)  *	@skb: current event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890)  *	This action resets ack_must_be_send flag of given connection, this flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891)  *	indicates if there is any PDU which has not been acknowledged yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892)  *	Returns 0 for success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) int llc_conn_ac_rst_sendack_flag(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	llc_sk(sk)->ack_must_be_send = llc_sk(sk)->ack_pf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901)  *	llc_conn_ac_send_i_rsp_f_set_ackpf - acknowledge received PDUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902)  *	@sk: current connection structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903)  *	@skb: current event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905)  *	Sends an I response PDU with f-bit set to ack_pf flag as acknowledge to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906)  *	all received PDUs which have not been acknowledged, yet. ack_pf flag is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907)  *	set to one if one PDU with p-bit set to one is received.  Returns 0 for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908)  *	success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) static int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 					      struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 			    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	if (likely(!rc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 		skb_get(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		llc_conn_send_pdu(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 		llc_conn_ac_inc_vs_by_1(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930)  *	llc_conn_ac_send_i_as_ack - sends an I-format PDU to acknowledge rx PDUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934)  *	This action sends an I-format PDU as acknowledge to received PDUs which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935)  *	have not been acknowledged, yet, if there is any. By using of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936)  *	action number of acknowledgements decreases, this technic is called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937)  *	piggy backing. Returns 0 for success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) int llc_conn_ac_send_i_as_ack(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	if (llc->ack_must_be_send) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 		ret = llc_conn_ac_send_i_rsp_f_set_ackpf(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 		llc->ack_must_be_send = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		llc->ack_pf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		ret = llc_conn_ac_send_i_cmd_p_set_0(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956)  *	llc_conn_ac_send_rr_rsp_f_set_ackpf - ack all rx PDUs not yet acked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960)  *	This action sends an RR response with f-bit set to ack_pf flag as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961)  *	acknowledge to all received PDUs which have not been acknowledged, yet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962)  *	if there is any. ack_pf flag indicates if a PDU has been received with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963)  *	p-bit set to one. Returns 0 for success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 					       struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	int rc = -ENOBUFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	if (nskb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		struct llc_sap *sap = llc->sap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 				    llc->daddr.lsap, LLC_PDU_RSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 		if (unlikely(rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 			goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		llc_conn_send_pdu(sk, nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	kfree_skb(nskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991)  *	llc_conn_ac_inc_npta_value - tries to make value of npta greater
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995)  *	After "inc_cntr" times calling of this action, "npta" increase by one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996)  *	this action tries to make vale of "npta" greater as possible; number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997)  *	acknowledgements decreases by increasing of "npta". Returns 0 for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998)  *	success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) static int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	if (!llc->inc_cntr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 		llc->dec_step = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 		llc->dec_cntr = llc->inc_cntr = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		++llc->npta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 		if (llc->npta > (u8) ~LLC_2_SEQ_NBR_MODULO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 			llc->npta = (u8) ~LLC_2_SEQ_NBR_MODULO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 		--llc->inc_cntr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016)  *	llc_conn_ac_adjust_npta_by_rr - decreases "npta" by one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)  *	After receiving "dec_cntr" times RR command, this action decreases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)  *	"npta" by one. Returns 0 for success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) int llc_conn_ac_adjust_npta_by_rr(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	if (!llc->connect_step && !llc->remote_busy_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 		if (!llc->dec_step) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 			if (!llc->dec_cntr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 				llc->inc_cntr = llc->dec_cntr = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 				if (llc->npta > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 					llc->npta = llc->npta - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 			} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 				llc->dec_cntr -=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		llc->connect_step = 0 ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)  *	llc_conn_ac_adjust_npta_by_rnr - decreases "npta" by one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)  *	After receiving "dec_cntr" times RNR command, this action decreases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047)  *	"npta" by one. Returns 0 for success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) int llc_conn_ac_adjust_npta_by_rnr(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	if (llc->remote_busy_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 		if (!llc->dec_step) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 			if (!llc->dec_cntr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 				llc->inc_cntr = llc->dec_cntr = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 				if (llc->npta > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 					--llc->npta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 			} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 				--llc->dec_cntr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)  *	llc_conn_ac_dec_tx_win_size - decreases tx window size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)  *	After receiving of a REJ command or response, transmit window size is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071)  *	decreased by number of PDUs which are outstanding yet. Returns 0 for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072)  *	success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	u8 unacked_pdu = skb_queue_len(&llc->pdu_unack_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	if (llc->k - unacked_pdu < 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 		llc->k = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 		llc->k -= unacked_pdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)  *	llc_conn_ac_inc_tx_win_size - tx window size is inc by 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088)  *	@sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)  *	@skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091)  *	After receiving an RR response with f-bit set to one, transmit window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092)  *	size is increased by one. Returns 0 for success, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	llc->k += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	if (llc->k > (u8) ~LLC_2_SEQ_NBR_MODULO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 		llc->k = (u8) ~LLC_2_SEQ_NBR_MODULO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) int llc_conn_ac_stop_all_timers(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	llc_sk_stop_all_timers(sk, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) int llc_conn_ac_stop_other_timers(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	del_timer(&llc->rej_sent_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	del_timer(&llc->pf_cycle_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	del_timer(&llc->busy_state_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	llc->ack_must_be_send = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	llc->ack_pf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 	mod_timer(&llc->rej_sent_timer.timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 		  jiffies + llc->rej_sent_timer.expire);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 					     struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	if (!timer_pending(&llc->ack_timer.timer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 		mod_timer(&llc->ack_timer.timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 			  jiffies + llc->ack_timer.expire);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) int llc_conn_ac_stop_ack_timer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	del_timer(&llc_sk(sk)->ack_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) int llc_conn_ac_stop_p_timer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	del_timer(&llc->pf_cycle_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	llc_conn_set_p_flag(sk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) int llc_conn_ac_stop_rej_timer(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	del_timer(&llc_sk(sk)->rej_sent_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	int acked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	u16 unacked = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 	struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	llc->last_nr = PDU_SUPV_GET_Nr(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	acked = llc_conn_remove_acked_pdus(sk, llc->last_nr, &unacked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	/* On loopback we don't queue I frames in unack_pdu_q queue. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	if (acked > 0 || (llc->dev->flags & IFF_LOOPBACK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 		llc->retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 		del_timer(&llc->ack_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 		if (llc->failed_data_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 			/* already, we did not accept data from upper layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 			 * (tx_window full or unacceptable state). Now, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 			 * can send data and must inform to upper layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 			llc->failed_data_req = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 			llc_conn_ac_data_confirm(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 		if (unacked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 			mod_timer(&llc->ack_timer.timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 				  jiffies + llc->ack_timer.expire);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	} else if (llc->failed_data_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 		u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 		llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 		if (f_bit == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 			llc->failed_data_req = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 			llc_conn_ac_data_confirm(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) int llc_conn_ac_upd_p_flag(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	if (LLC_PDU_IS_RSP(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 		u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 		llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 		if (f_bit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 			llc_conn_set_p_flag(sk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 			llc_conn_ac_stop_p_timer(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) int llc_conn_ac_set_data_flag_2(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	llc_sk(sk)->data_flag = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) int llc_conn_ac_set_data_flag_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	llc_sk(sk)->data_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) int llc_conn_ac_set_data_flag_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	llc_sk(sk)->data_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) int llc_conn_ac_set_data_flag_1_if_data_flag_eq_0(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 						  struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	if (!llc_sk(sk)->data_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 		llc_sk(sk)->data_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) int llc_conn_ac_set_p_flag_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	llc_conn_set_p_flag(sk, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) static int llc_conn_ac_set_p_flag_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 	llc_conn_set_p_flag(sk, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) int llc_conn_ac_set_remote_busy_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	llc_sk(sk)->remote_busy_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) int llc_conn_ac_set_cause_flag_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	llc_sk(sk)->cause_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) int llc_conn_ac_set_cause_flag_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	llc_sk(sk)->cause_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) int llc_conn_ac_set_retry_cnt_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	llc_sk(sk)->retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) int llc_conn_ac_inc_retry_cnt_by_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	llc_sk(sk)->retry_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) int llc_conn_ac_set_vr_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	llc_sk(sk)->vR = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) int llc_conn_ac_inc_vr_by_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	llc_sk(sk)->vR = PDU_GET_NEXT_Vr(llc_sk(sk)->vR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) int llc_conn_ac_set_vs_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 	llc_sk(sk)->vS = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	llc_sk(sk)->vS = llc_sk(sk)->last_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % LLC_2_SEQ_NBR_MODULO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) static void llc_conn_tmr_common_cb(struct sock *sk, u8 type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	if (skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 		struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 		skb_set_owner_r(skb, sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 		ev->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 		llc_process_tmr_ev(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) void llc_conn_pf_cycle_tmr_cb(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	struct llc_sock *llc = from_timer(llc, t, pf_cycle_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	llc_conn_tmr_common_cb(&llc->sk, LLC_CONN_EV_TYPE_P_TMR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) void llc_conn_busy_tmr_cb(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	struct llc_sock *llc = from_timer(llc, t, busy_state_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	llc_conn_tmr_common_cb(&llc->sk, LLC_CONN_EV_TYPE_BUSY_TMR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) void llc_conn_ack_tmr_cb(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	struct llc_sock *llc = from_timer(llc, t, ack_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	llc_conn_tmr_common_cb(&llc->sk, LLC_CONN_EV_TYPE_ACK_TMR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) void llc_conn_rej_tmr_cb(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	struct llc_sock *llc = from_timer(llc, t, rej_sent_timer.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	llc_conn_tmr_common_cb(&llc->sk, LLC_CONN_EV_TYPE_REJ_TMR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 	llc_sk(sk)->X = llc_sk(sk)->vS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	llc_conn_ac_set_vs_nr(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) int llc_conn_ac_upd_vs(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	u8 nr = PDU_SUPV_GET_Nr(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	if (llc_circular_between(llc_sk(sk)->vS, nr, llc_sk(sk)->X))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 		llc_conn_ac_set_vs_nr(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382)  * Non-standard actions; these not contained in IEEE specification; for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383)  * our own usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386)  *	llc_conn_disc - removes connection from SAP list and frees it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)  *	@sk: closed connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)  *	@skb: occurred event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) int llc_conn_disc(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	/* FIXME: this thing seems to want to die */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397)  *	llc_conn_reset - resets connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398)  *	@sk : reseting connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)  *	@skb: occurred event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401)  *	Stop all timers, empty all queues and reset all flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) int llc_conn_reset(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	llc_sk_reset(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410)  *	llc_circular_between - designates that b is between a and c or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411)  *	@a: lower bound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412)  *	@b: element to see if is between a and b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413)  *	@c: upper bound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415)  *	This function designates that b is between a and c or not (for example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416)  *	0 is between 127 and 1). Returns 1 if b is between a and c, 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)  *	otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) u8 llc_circular_between(u8 a, u8 b, u8 c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 	b = b - a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	c = c - a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 	return b <= c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427)  *	llc_process_tmr_ev - timer backend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428)  *	@sk: active connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429)  *	@skb: occurred event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431)  *	This function is called from timer callback functions. When connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)  *	is busy (during sending a data frame) timer expiration event must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)  *	queued. Otherwise this event can be sent to connection state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434)  *	Queued events will process by llc_backlog_rcv function after sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435)  *	data frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 	if (llc_sk(sk)->state == LLC_CONN_OUT_OF_SVC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 		printk(KERN_WARNING "%s: timer called on closed connection\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 		       __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 		kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 		if (!sock_owned_by_user(sk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 			llc_conn_state_process(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 			llc_set_backlog_type(skb, LLC_EVENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 			__sk_add_backlog(sk, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) }