Commit 649cbf21 authored by David S. Miller's avatar David S. Miller

Merge master.kernel.org:/home/acme/BK/newdatalink-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents d572f1a5 c1d567a8
......@@ -24,25 +24,25 @@
/* All station state event action functions look like this */
typedef int (*llc_station_action_t)(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_start_ack_timer(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_set_retry_cnt_0(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_inc_retry_cnt_by_1(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_set_xid_r_cnt_0(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_inc_xid_r_cnt_by_1(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_send_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_send_xid_r(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_send_test_r(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_report_status(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_station_ac_report_status(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
#endif /* LLC_ACTN_H */
......@@ -87,168 +87,128 @@
#define LLC_CONN_AC_STOP_SENDACK_TMR 70
#define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
typedef int (*llc_conn_action_t)(struct sock *sk, struct llc_conn_state_ev *ev);
typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ac_clear_remote_busy(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_conn_confirm(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_data_ind(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_disc_ind(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_rst_ind(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_rst_confirm(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_report_status(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ac_conn_confirm(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_data_ind(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_disc_ind(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_rst_ind(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_rst_confirm(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_report_status(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_clear_remote_busy_if_f_eq_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_disc_cmd_p_set_x(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_dm_rsp_f_set_p(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_dm_rsp_f_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_dm_rsp_f_set_f_flag(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_send_i_cmd_p_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_send_i_cmd_p_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_i_cmd_p_set_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_send_i_cmd_p_set_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_resend_i_cmd_p_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_resend_i_cmd_p_set_1_or_send_rr(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_send_i_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_i_xxx_x_set_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_resend_i_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_resend_i_rsp_f_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rej_cmd_p_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rej_rsp_f_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rej_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_remote_busy(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_set_remote_busy(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rr_cmd_p_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_ack_cmd_p_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rr_rsp_f_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_ack_rsp_f_set_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_rr_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_ack_xxx_x_set_0(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_ua_rsp_f_set_f_flag(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_ua_rsp_f_set_p(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_s_flag_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_s_flag_1(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_start_p_timer(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_start_ack_timer(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_start_rej_timer(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_set_s_flag_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_s_flag_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_start_p_timer(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_start_ack_timer(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_start_rej_timer(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_start_ack_tmr_if_not_running(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_stop_ack_timer(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_stop_p_timer(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_stop_rej_timer(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_stop_all_timers(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_stop_other_timers(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_upd_nr_received(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_inc_tx_win_size(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_dec_tx_win_size(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_upd_p_flag(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_data_flag_2(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_data_flag_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_data_flag_1(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_stop_ack_timer(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_stop_p_timer(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_stop_rej_timer(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_stop_all_timers(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_stop_other_timers(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_upd_nr_received(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_inc_tx_win_size(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_dec_tx_win_size(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_upd_p_flag(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_data_flag_2(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_data_flag_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_data_flag_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_data_flag_1_if_data_flag_eq_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_p_flag_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_p_flag_1(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_remote_busy_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_retry_cnt_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_cause_flag_0(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_cause_flag_1(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_inc_retry_cnt_by_1(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_vr_0(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_inc_vr_by_1(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_vs_0(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_vs_nr(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_rst_vs(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_upd_vs(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_set_f_flag_p(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_disc(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_reset(struct sock* sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ac_disc_confirm(struct sock* sk, struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_set_p_flag_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_p_flag_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_remote_busy_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_retry_cnt_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_cause_flag_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_cause_flag_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_inc_retry_cnt_by_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_vr_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_inc_vr_by_1(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_vs_0(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_vs_nr(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_rst_vs(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_upd_vs(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_set_f_flag_p(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_disc(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_reset(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_disc_confirm(struct sock* sk, struct sk_buff *skb);
extern u8 llc_circular_between(u8 a, u8 b, u8 c);
extern int llc_conn_ac_send_ack_if_needed(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_inc_npta_value(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_adjust_npta_by_rr(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_adjust_npta_by_rnr(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_rst_sendack_flag(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_send_ack_if_needed(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_inc_npta_value(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_adjust_npta_by_rr(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_adjust_npta_by_rnr(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_rst_sendack_flag(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_send_i_rsp_as_ack(struct sock* sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ac_send_i_as_ack(struct sock* sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ac_send_i_rsp_as_ack(struct sock* sk, struct sk_buff *skb);
extern int llc_conn_ac_send_i_as_ack(struct sock* sk, struct sk_buff *skb);
#endif /* LLC_C_AC_H */
......@@ -124,7 +124,6 @@ struct llc_conn_ev_prim_if {
struct llc_conn_ev_pdu_if {
u8 ev;
u8 reason;
struct sk_buff *skb;
};
/* Event interface for timer-generated events */
......@@ -155,169 +154,156 @@ struct llc_conn_state_ev {
union llc_conn_ev_if data;
};
typedef int (*llc_conn_ev_t)(struct sock *sk, struct llc_conn_state_ev *ev);
typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk,
struct llc_conn_state_ev *ev);
static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
{
return (struct llc_conn_state_ev *)skb->cb;
}
extern int llc_conn_ev_conn_req(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ev_conn_resp(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ev_data_req(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ev_disc_req(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ev_rst_req(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_ev_rst_resp(struct sock *sk, struct llc_conn_state_ev *ev);
typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_conn_resp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_rst_resp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_local_busy_detected(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_local_busy_cleared(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_rx_bad_pdu(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_rx_xxx_yyy(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_xxx_yyy(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_p_tmr_exp(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_ack_tmr_exp(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_rej_tmr_exp(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_busy_tmr_exp(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_any_tmr_exp(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_sendack_tmr_exp(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_any_tmr_exp(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_sendack_tmr_exp(struct sock *sk, struct sk_buff *skb);
/* NOT_USED functions and their variations */
extern int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_xxx_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_rx_any_frame(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_tx_buffer_full(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_init_p_f_cycle(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb);
/* Available connection action qualifiers */
extern int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev);
extern int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb);
extern int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_init_p_f_cycle(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_conn(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_disc(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_failed(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_impossible(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_received(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
extern int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk,
struct llc_conn_state_ev *ev);
struct sk_buff *skb);
#endif /* LLC_C_EV_H */
......@@ -136,12 +136,10 @@ extern void llc_sock_reset(struct sock *sk);
extern int llc_sock_init(struct sock *sk);
/* Access to a connection */
extern struct llc_conn_state_ev *llc_conn_alloc_ev(struct sock *sk);
extern int llc_conn_send_ev(struct sock *sk, struct llc_conn_state_ev *ev);
extern int llc_conn_send_ev(struct sock *sk, struct sk_buff *skb);
extern void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb);
extern void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb,
struct llc_conn_state_ev *ev);
extern void llc_conn_free_ev(struct llc_conn_state_ev *ev);
extern void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb);
extern void llc_conn_free_ev(struct sk_buff *skb);
extern void llc_conn_resend_i_pdu_as_cmd(struct sock *sk, u8 nr,
u8 first_p_bit);
extern void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr,
......
......@@ -68,26 +68,32 @@ struct llc_station_state_ev {
struct list_head node; /* node in station->ev_q.list */
};
static __inline__ struct llc_station_state_ev *
llc_station_ev(struct sk_buff *skb)
{
return (struct llc_station_state_ev *)skb->cb;
}
typedef int (*llc_station_ev_t)(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_enable_with_dup_addr_check(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_enable_without_dup_addr_check(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct llc_station *
station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_rx_null_dsap_test_c(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern int llc_stat_ev_disable_req(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
#endif /* LLC_EVNT_H */
......@@ -20,4 +20,15 @@ extern struct net_device *mac_dev_peer(struct net_device *current_dev,
extern int llc_pdu_router(struct llc_sap *sap, struct sock *sk,
struct sk_buff *skb, u8 type);
extern u16 lan_hdrs_init(struct sk_buff *skb, u8 *sa, u8 *da);
static __inline__ void llc_set_backlog_type(struct sk_buff *skb, char type)
{
skb->cb[sizeof(skb->cb) - 1] = type;
}
static __inline__ char llc_backlog_type(struct sk_buff *skb)
{
return skb->cb[sizeof(skb->cb) - 1];
}
#endif /* LLC_MAC_H */
......@@ -19,35 +19,40 @@
#define LLC_ACK_TIME 3
#define LLC_REJ_TIME 3
#define LLC_BUSY_TIME 3
#define LLC_SENDACK_TIME 50
#define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */
#define LLC_DEST_SAP 1 /* Type 1 goes here */
#define LLC_DEST_CONN 2 /* Type 2 goes here */
/* LLC Layer global default parameters */
#define LLC_GLOBAL_DEFAULT_MAX_NBR_SAPS 4
#define LLC_GLOBAL_DEFAULT_MAX_NBR_CONNS 64
/* LLC station component (SAP and connection resource manager) */
/* Station component; one per adapter */
/**
* struct llc_station - LLC station component
*
* SAP and connection resource manager, one per adapter.
*
* @state - state of station
* @xid_r_count - XID response PDU counter
* @ack_tmr_running - 1 or 0
* @mac_sa - MAC source address
* @sap_list - list of related SAPs
* @ev_q - events entering state mach.
* @mac_pdu_q - PDUs ready to send to MAC
*/
struct llc_station {
u8 state; /* state of station */
u8 xid_r_count; /* XID response PDU counter */
u8 state;
u8 xid_r_count;
struct timer_list ack_timer;
u8 ack_tmr_running; /* 1 or 0 */
u8 ack_tmr_running;
u8 retry_count;
u8 maximum_retry;
u8 mac_sa[6]; /* MAC source address */
u8 mac_sa[6];
struct {
spinlock_t lock;
struct list_head list;
} sap_list; /* list of related SAPs */
} sap_list;
struct {
struct sk_buff_head list;
spinlock_t lock;
struct list_head list;
} ev_q; /* events entering state mach. */
struct sk_buff_head mac_pdu_q; /* PDUs ready to send to MAC */
} ev_q;
struct sk_buff_head mac_pdu_q;
};
struct llc_station_state_ev;
......@@ -56,10 +61,8 @@ extern void llc_sap_save(struct llc_sap *sap);
extern void llc_free_sap(struct llc_sap *sap);
extern struct llc_sap *llc_sap_find(u8 lsap);
extern struct llc_station *llc_station_get(void);
extern struct llc_station_state_ev *
llc_station_alloc_ev(struct llc_station *station);
extern void llc_station_send_ev(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
extern void llc_station_send_pdu(struct llc_station *station,
struct sk_buff *skb);
extern struct sk_buff *llc_alloc_frame(void);
......
......@@ -23,25 +23,17 @@
#define SAP_ACT_TEST_IND 9
/* All action functions must look like this */
typedef int (*llc_sap_action_t)(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_send_ui(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_send_xid_c(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_send_xid_r(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_send_test_c(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_send_test_r(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
struct sk_buff *skb);
extern int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_report_status(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_xid_ind(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_action_test_ind(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
struct sk_buff *skb);
extern int llc_sap_action_xid_ind(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_action_test_ind(struct llc_sap *sap, struct sk_buff *skb);
#endif /* LLC_S_AC_H */
......@@ -11,6 +11,9 @@
*
* See the GNU General Public License for more details.
*/
#include <linux/skbuff.h>
/* Defines SAP component events */
/* Types of events (possible values in 'ev->type') */
#define LLC_SAP_EV_TYPE_SIMPLE 1
......@@ -47,7 +50,6 @@ struct llc_sap_ev_prim_if {
struct llc_sap_ev_pdu_if {
u8 ev;
u8 reason;
struct sk_buff *skb;
};
struct llc_sap_ev_tmr_if {
......@@ -75,27 +77,24 @@ struct llc_sap_state_ev {
union llc_sap_ev_if data;
};
static __inline__ struct llc_sap_state_ev *llc_sap_ev(struct sk_buff *skb)
{
return (struct llc_sap_state_ev *)skb->cb;
}
struct llc_sap;
typedef int (*llc_sap_ev_t)(struct llc_sap *sap, struct llc_sap_state_ev *ev);
extern int llc_sap_ev_activation_req(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_rx_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev);
extern int llc_sap_ev_unitdata_req(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_xid_req(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_rx_xid_c(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_rx_xid_r(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_test_req(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_rx_test_c(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
extern int llc_sap_ev_rx_test_r(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
typedef int (*llc_sap_ev_t)(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_activation_req(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_rx_ui(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_unitdata_req(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_xid_req(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_test_req(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct sk_buff *skb);
extern int llc_sap_ev_deactivation_req(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
struct sk_buff *skb);
#endif /* LLC_S_EV_H */
......@@ -15,7 +15,8 @@
#define LLC_SAP_STATE_INACTIVE 1
#define LLC_SAP_STATE_ACTIVE 2
#define LLC_NBR_SAP_STATES 2 /* size of state table */
#define LLC_NR_SAP_STATES 2 /* size of state table */
/* structures and types */
/* SAP state table structure */
struct llc_sap_state_trans {
......@@ -30,5 +31,5 @@ struct llc_sap_state {
};
/* only access to SAP state table */
extern struct llc_sap_state llc_sap_state_table[LLC_NBR_SAP_STATES];
extern struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES];
#endif /* LLC_S_ST_H */
......@@ -49,9 +49,7 @@ struct llc_sap_state_ev;
extern void llc_sap_assign_sock(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_send_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev);
extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
struct llc_sap_state_ev *ev);
extern void llc_sap_send_ev(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb);
extern struct llc_sap_state_ev *llc_sap_alloc_ev(struct llc_sap *sap);
#endif /* LLC_SAP_H */
......@@ -27,7 +27,7 @@
static void llc_station_ack_tmr_callback(unsigned long timeout_data);
int llc_station_ac_start_ack_timer(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
del_timer(&station->ack_timer);
station->ack_timer.expires = jiffies + LLC_ACK_TIME * HZ;
......@@ -39,98 +39,94 @@ int llc_station_ac_start_ack_timer(struct llc_station *station,
}
int llc_station_ac_set_retry_cnt_0(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
station->retry_count = 0;
return 0;
}
int llc_station_ac_inc_retry_cnt_by_1(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
station->retry_count++;
return 0;
}
int llc_station_ac_set_xid_r_cnt_0(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
station->xid_r_count = 0;
return 0;
}
int llc_station_ac_inc_xid_r_cnt_by_1(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
station->xid_r_count++;
return 0;
}
int llc_station_ac_send_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (!skb)
if (!nskb)
goto out;
rc = 0;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD);
llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 127);
lan_hdrs_init(skb, station->mac_sa, station->mac_sa);
llc_station_send_pdu(station, skb);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD);
llc_pdu_init_as_xid_cmd(nskb, LLC_XID_NULL_CLASS_2, 127);
lan_hdrs_init(nskb, station->mac_sa, station->mac_sa);
llc_station_send_pdu(station, nskb);
out:
return rc;
}
int llc_station_ac_send_xid_r(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
u8 mac_da[ETH_ALEN], dsap;
int rc = 1;
struct sk_buff *ev_skb;
struct sk_buff* skb = llc_alloc_frame();
struct sk_buff* nskb = llc_alloc_frame();
if (!skb)
if (!nskb)
goto out;
rc = 0;
ev_skb = ev->data.pdu.skb;
skb->dev = ev_skb->dev;
llc_pdu_decode_sa(ev_skb, mac_da);
llc_pdu_decode_ssap(ev_skb, &dsap);
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
llc_pdu_init_as_xid_rsp(skb, LLC_XID_NULL_CLASS_2, 127);
lan_hdrs_init(skb, station->mac_sa, mac_da);
llc_station_send_pdu(station, skb);
nskb->dev = skb->dev;
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_ssap(skb, &dsap);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 127);
lan_hdrs_init(nskb, station->mac_sa, mac_da);
llc_station_send_pdu(station, nskb);
out:
return rc;
}
int llc_station_ac_send_test_r(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
u8 mac_da[ETH_ALEN], dsap;
int rc = 1;
struct sk_buff *ev_skb;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (!skb)
if (!nskb)
goto out;
rc = 0;
ev_skb = ev->data.pdu.skb;
skb->dev = ev_skb->dev;
llc_pdu_decode_sa(ev_skb, mac_da);
llc_pdu_decode_ssap(ev_skb, &dsap);
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
llc_pdu_init_as_test_rsp(skb, ev_skb);
lan_hdrs_init(skb, station->mac_sa, mac_da);
llc_station_send_pdu(station, skb);
nskb->dev = skb->dev;
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_ssap(skb, &dsap);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
llc_pdu_init_as_test_rsp(nskb, skb);
lan_hdrs_init(nskb, station->mac_sa, mac_da);
llc_station_send_pdu(station, nskb);
out:
return rc;
}
int llc_station_ac_report_status(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
return 0;
}
......@@ -138,13 +134,14 @@ int llc_station_ac_report_status(struct llc_station *station,
static void llc_station_ack_tmr_callback(unsigned long timeout_data)
{
struct llc_station *station = (struct llc_station *)timeout_data;
struct llc_station_state_ev *ev;
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
station->ack_tmr_running = 0;
ev = llc_station_alloc_ev(station);
if (ev) {
if (skb) {
struct llc_station_state_ev *ev = llc_station_ev(skb);
ev->type = LLC_STATION_EV_TYPE_ACK_TMR;
ev->data.tmr.timer_specific = NULL;
llc_station_send_ev(station, ev);
llc_station_send_ev(station, skb);
}
}
......@@ -32,22 +32,19 @@ static void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data);
static void llc_conn_ack_tmr_cb(unsigned long timeout_data);
static void llc_conn_rej_tmr_cb(unsigned long timeout_data);
static void llc_conn_busy_tmr_cb(unsigned long timeout_data);
static int llc_conn_ac_inc_vs_by_1(struct sock *sk,
struct llc_conn_state_ev *ev);
static void llc_process_tmr_ev(struct sock *sk, struct llc_conn_state_ev *ev);
static int llc_conn_ac_data_confirm(struct sock *sk,
struct llc_conn_state_ev *ev);
static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb);
static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb);
static int llc_conn_ac_data_confirm(struct sock *sk, struct sk_buff *ev);
#define INCORRECT 0
int llc_conn_ac_clear_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
if (llc->remote_busy_flag) {
u8 nr;
struct llc_pdu_sn *pdu =
(struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
llc->remote_busy_flag = 0;
del_timer(&llc->busy_state_timer.timer);
......@@ -58,16 +55,16 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
u8 dsap;
struct sk_buff *skb = ev->data.pdu.skb;
struct llc_sap *sap;
llc_pdu_decode_dsap(skb, &dsap);
sap = llc_sap_find(dsap);
if (sap) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
struct llc_opt *llc = llc_sk(sk);
......@@ -91,9 +88,9 @@ int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
return rc;
}
int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb)
{
struct sk_buff *skb = ev->data.pdu.skb;
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
......@@ -103,10 +100,7 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
prim_data->conn.pri = 0;
prim_data->conn.status = ev->status;
prim_data->conn.link = llc->link;
if (skb)
prim_data->conn.dev = skb->dev;
else
printk(KERN_ERR "%s: ev->data.pdu.skb == NULL\n", __FUNCTION__);
prim->data = prim_data;
prim->prim = LLC_CONN_PRIM;
prim->sap = sap;
......@@ -115,9 +109,9 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
static int llc_conn_ac_data_confirm(struct sock *sk,
struct llc_conn_state_ev *ev)
static int llc_conn_ac_data_confirm(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
......@@ -136,19 +130,20 @@ static int llc_conn_ac_data_confirm(struct sock *sk,
return 0;
}
int llc_conn_ac_data_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_data_ind(struct sock *sk, struct sk_buff *skb)
{
llc_conn_rtn_pdu(sk, ev->data.pdu.skb, ev);
llc_conn_rtn_pdu(sk, skb);
return 0;
}
int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_disc_ind(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
u8 reason = 0;
int rc = 1;
if (ev->type == LLC_CONN_EV_TYPE_PDU) {
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
if (!LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -186,8 +181,9 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
return rc;
}
int llc_conn_ac_disc_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_disc_confirm(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
......@@ -204,11 +200,12 @@ int llc_conn_ac_disc_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
{
u8 reason = 0;
int rc = 1;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
struct llc_opt *llc = llc_sk(sk);
switch (ev->type) {
......@@ -257,8 +254,9 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
return rc;
}
int llc_conn_ac_rst_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_confirm(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
......@@ -274,210 +272,201 @@ int llc_conn_ac_rst_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_report_status(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_report_status(struct sock *sk, struct sk_buff *skb)
{
return 0;
}
int llc_conn_ac_clear_remote_busy_if_f_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if (!LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_1(pdu) && llc_sk(sk)->ack_pf)
llc_conn_ac_clear_remote_busy(sk, ev);
llc_conn_ac_clear_remote_busy(sk, skb);
return 0;
}
int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
if (llc_sk(sk)->data_flag == 2) {
del_timer(&llc_sk(sk)->rej_sent_timer.timer);
llc_sk(sk)->rej_sent_timer.running = 0;
struct llc_opt *llc = llc_sk(sk);
if (llc->data_flag == 2) {
del_timer(&llc->rej_sent_timer.timer);
llc->rej_sent_timer.running = 0;
}
return 0;
}
int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
u8 p_bit = 1;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_disc_cmd(skb, p_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_disc_cmd(nskb, p_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
llc_conn_ac_set_p_flag_1(sk, ev);
llc_conn_ac_set_p_flag_1(sk, skb);
return rc;
}
int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct sk_buff *rx_skb = ev->data.pdu.skb;
u8 f_bit;
skb->dev = llc->dev;
llc_pdu_decode_pf_bit(rx_skb, &f_bit);
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_decode_pf_bit(skb, &f_bit);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_dm_rsp(skb, f_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_dm_rsp(nskb, f_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 1;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_dm_rsp(skb, f_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_dm_rsp(nskb, f_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_dm_rsp_f_set_f_flag(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_dm_rsp_f_set_f_flag(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = llc->f_flag;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_dm_rsp(skb, f_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_dm_rsp(nskb, f_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
{
u8 f_bit;
int rc = 1;
struct sk_buff *skb, *ev_skb = ev->data.pdu.skb;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev_skb->nh.raw;
struct sk_buff *nskb;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
struct llc_opt *llc = llc_sk(sk);
llc->rx_pdu_hdr = *((u32 *)pdu);
if (!LLC_PDU_IS_CMD(pdu))
llc_pdu_decode_pf_bit(ev_skb, &f_bit);
llc_pdu_decode_pf_bit(skb, &f_bit);
else
f_bit = 0;
skb = llc_alloc_frame();
if (skb) {
nskb = llc_alloc_frame();
if (nskb) {
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_frmr_rsp(skb, pdu, f_bit, llc->vS,
llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
llc->vR, INCORRECT);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
u8 f_bit = 0;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_frmr_rsp(skb, pdu, f_bit, llc->vS,
llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
llc->vR, INCORRECT);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
{
u8 f_bit;
int rc = 1;
struct sk_buff *skb;
struct sk_buff *nskb;
llc_pdu_decode_pf_bit(ev->data.pdu.skb, &f_bit);
skb = llc_alloc_frame();
if (skb) {
llc_pdu_decode_pf_bit(skb, &f_bit);
nskb = llc_alloc_frame();
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_pdu_sn *pdu =
(struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_frmr_rsp(skb, pdu, f_bit, llc->vS,
llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
llc->vR, INCORRECT);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{
u8 p_bit = 1;
struct sk_buff *skb = ev->data.prim.data->data->data.skb;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
......@@ -486,15 +475,13 @@ int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk,
llc_pdu_init_as_i_cmd(skb, p_bit, llc->vS, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_conn_send_pdu(sk, skb);
llc_conn_ac_inc_vs_by_1(sk, ev);
llc_conn_ac_inc_vs_by_1(sk, skb);
return 0;
}
int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk, struct sk_buff *skb)
{
u8 p_bit = 0;
struct sk_buff *skb = ev->data.prim.data->data->data.skb;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
......@@ -503,14 +490,13 @@ int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk,
llc_pdu_init_as_i_cmd(skb, p_bit, llc->vS, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_conn_send_pdu(sk, skb);
llc_conn_ac_inc_vs_by_1(sk, ev);
llc_conn_ac_inc_vs_by_1(sk, skb);
return 0;
}
int llc_conn_ac_resend_i_cmd_p_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_resend_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 nr = LLC_I_GET_NR(pdu);
llc_conn_resend_i_pdu_as_cmd(sk, nr, 1);
......@@ -518,22 +504,20 @@ int llc_conn_ac_resend_i_cmd_p_set_1(struct sock *sk,
}
int llc_conn_ac_resend_i_cmd_p_set_1_or_send_rr(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 nr = LLC_I_GET_NR(pdu);
int rc = llc_conn_ac_send_rr_cmd_p_set_1(sk, ev);
int rc = llc_conn_ac_send_rr_cmd_p_set_1(sk, skb);
if (!rc)
llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
return rc;
}
int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
u8 p_bit = 0;
struct sk_buff *skb = ev->data.prim.data->data->data.skb;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
......@@ -542,14 +526,13 @@ int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk,
llc_pdu_init_as_i_cmd(skb, p_bit, llc->vS, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_conn_send_pdu(sk, skb);
llc_conn_ac_inc_vs_by_1(sk, ev);
llc_conn_ac_inc_vs_by_1(sk, skb);
return 0;
}
int llc_conn_ac_resend_i_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_resend_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 nr = LLC_I_GET_NR(pdu);
llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
......@@ -557,25 +540,25 @@ int llc_conn_ac_resend_i_xxx_x_set_0(struct sock *sk,
}
int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
u8 nr;
u8 f_bit = 0;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
if (rc) {
nr = LLC_I_GET_NR(pdu);
......@@ -585,149 +568,142 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
return rc;
}
int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 nr = LLC_I_GET_NR(pdu);
llc_conn_resend_i_pdu_as_rsp(sk, nr, 1);
return 0;
}
int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 p_bit = 1;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rej_cmd(skb, p_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rej_cmd(nskb, p_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
u8 f_bit = 1;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rej_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 0;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rej_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 p_bit = 1;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rnr_cmd(skb, p_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rnr_cmd(nskb, p_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 1;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rnr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
u8 f_bit = 0;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rnr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_set_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -743,246 +719,234 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 0;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rnr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
u8 p_bit = 1;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rr_cmd(skb, p_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_cmd(nskb, p_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_ack_cmd_p_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_ack_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
u8 p_bit = 1;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rr_cmd(skb, p_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_cmd(nskb, p_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 1;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 1;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 0;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = 0;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
struct llc_opt *llc = llc_sk(sk);
u8 p_bit = 1;
if (skb) {
if (nskb) {
struct llc_sap *sap = llc->sap;
u8 *dmac = llc->daddr.mac;
if (llc->dev->flags & IFF_LOOPBACK)
dmac = llc->dev->dev_addr;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_sabme_cmd(skb, p_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, dmac);
llc_pdu_init_as_sabme_cmd(nskb, p_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, dmac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
llc->p_flag = p_bit;
return rc;
}
int llc_conn_ac_send_ua_rsp_f_set_f_flag(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_ua_rsp_f_set_f_flag(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = llc->f_flag;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_ua_rsp(skb, f_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_ua_rsp(nskb, f_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
{
u8 f_bit;
int rc = 1;
struct sk_buff *rx_skb = ev->data.pdu.skb;
struct sk_buff *skb;
struct sk_buff *nskb = llc_alloc_frame();
llc_pdu_decode_pf_bit(rx_skb, &f_bit);
skb = llc_alloc_frame();
if (skb) {
llc_pdu_decode_pf_bit(skb, &f_bit);
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_ua_rsp(skb, f_bit);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_ua_rsp(nskb, f_bit);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
int llc_conn_ac_set_s_flag_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_s_flag_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->s_flag = 0;
return 0;
}
int llc_conn_ac_set_s_flag_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_s_flag_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->s_flag = 1;
return 0;
}
int llc_conn_ac_start_p_timer(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1000,18 +964,16 @@ int llc_conn_ac_start_p_timer(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_conn_ac_send_ack_if_needed - check if ack is needed
* @sk: current connection structure
* @ev: current event
* @skb: current event
*
* Checks number of received PDUs which have not been acknowledged, yet,
* If number of them reaches to "npta"(Number of PDUs To Acknowledge) then
* sends an RR response as acknowledgement for them. Returns 0 for
* success, 1 otherwise.
*/
int llc_conn_ac_send_ack_if_needed(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_ack_if_needed(struct sock *sk, struct sk_buff *skb)
{
u8 pf_bit;
struct sk_buff *skb = ev->data.pdu.skb;
struct llc_opt *llc = llc_sk(sk);
llc_pdu_decode_pf_bit(skb, &pf_bit);
......@@ -1022,10 +984,10 @@ int llc_conn_ac_send_ack_if_needed(struct sock *sk,
llc->ack_pf = pf_bit & 1;
}
if (((llc->vR - llc->first_pdu_Ns + 129) % 128) >= llc->npta) {
llc_conn_ac_send_rr_rsp_f_set_ackpf(sk, ev);
llc_conn_ac_send_rr_rsp_f_set_ackpf(sk, skb);
llc->ack_must_be_send = 0;
llc->ack_pf = 0;
llc_conn_ac_inc_npta_value(sk, ev);
llc_conn_ac_inc_npta_value(sk, skb);
}
return 0;
}
......@@ -1033,14 +995,13 @@ int llc_conn_ac_send_ack_if_needed(struct sock *sk,
/**
* llc_conn_ac_rst_sendack_flag - resets ack_must_be_send flag
* @sk: current connection structure
* @ev: current event
* @skb: current event
*
* This action resets ack_must_be_send flag of given connection, this flag
* indicates if there is any PDU which has not been acknowledged yet.
* Returns 0 for success, 1 otherwise.
*/
int llc_conn_ac_rst_sendack_flag(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_sendack_flag(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->ack_must_be_send = llc_sk(sk)->ack_pf = 0;
return 0;
......@@ -1049,17 +1010,15 @@ int llc_conn_ac_rst_sendack_flag(struct sock *sk,
/**
* llc_conn_ac_send_i_rsp_f_set_ackpf - acknowledge received PDUs
* @sk: current connection structure
* @ev: current event
* @skb: current event
*
* Sends an I response PDU with f-bit set to ack_pf flag as acknowledge to
* all received PDUs which have not been acknowledged, yet. ack_pf flag is
* set to one if one PDU with p-bit set to one is received. Returns 0 for
* success, 1 otherwise.
*/
int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk, struct sk_buff *skb)
{
struct sk_buff *skb = ev->data.prim.data->data->data.skb;
struct llc_opt *llc = llc_sk(sk);
u8 p_bit = llc->ack_pf;
struct llc_sap *sap = llc->sap;
......@@ -1069,61 +1028,60 @@ int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk,
llc_pdu_init_as_i_cmd(skb, p_bit, llc->vS, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_conn_send_pdu(sk, skb);
llc_conn_ac_inc_vs_by_1(sk, ev);
llc_conn_ac_inc_vs_by_1(sk, skb);
return 0;
}
/**
* llc_conn_ac_send_i_as_ack - sends an I-format PDU to acknowledge rx PDUs
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* This action sends an I-format PDU as acknowledge to received PDUs which
* have not been acknowledged, yet, if there is any. By using of this
* action number of acknowledgements decreases, this technic is called
* piggy backing. Returns 0 for success, 1 otherwise.
*/
int llc_conn_ac_send_i_as_ack(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_send_i_as_ack(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
if (llc->ack_must_be_send) {
llc_conn_ac_send_i_rsp_f_set_ackpf(sk, ev);
llc_conn_ac_send_i_rsp_f_set_ackpf(sk, skb);
llc->ack_must_be_send = 0 ;
llc->ack_pf = 0;
} else
llc_conn_ac_send_i_cmd_p_set_0(sk, ev);
llc_conn_ac_send_i_cmd_p_set_0(sk, skb);
return 0;
}
/**
* llc_conn_ac_send_rr_rsp_f_set_ackpf - ack all rx PDUs not yet acked
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* This action sends an RR response with f-bit set to ack_pf flag as
* acknowledge to all received PDUs which have not been acknowledged, yet,
* if there is any. ack_pf flag indicates if a PDU has been received with
* p-bit set to one. Returns 0 for success, 1 otherwise.
*/
int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct sk_buff *skb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame();
if (skb) {
if (nskb) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
u8 f_bit = llc->ack_pf;
skb->dev = llc->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_S, sap->laddr.lsap,
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(skb, f_bit, llc->vR);
lan_hdrs_init(skb, llc->dev->dev_addr, llc->daddr.mac);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
lan_hdrs_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
rc = 0;
llc_conn_send_pdu(sk, skb);
llc_conn_send_pdu(sk, nskb);
}
return rc;
}
......@@ -1131,14 +1089,14 @@ int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
/**
* llc_conn_ac_inc_npta_value - tries to make value of npta greater
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* After "inc_cntr" times calling of this action, "npta" increase by one.
* this action tries to make vale of "npta" greater as possible; number of
* acknowledgements decreases by increasing of "npta". Returns 0 for
* success, 1 otherwise.
*/
int llc_conn_ac_inc_npta_value(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1156,12 +1114,12 @@ int llc_conn_ac_inc_npta_value(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_conn_ac_adjust_npta_by_rr - decreases "npta" by one
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* After receiving "dec_cntr" times RR command, this action decreases
* "npta" by one. Returns 0 for success, 1 otherwise.
*/
int llc_conn_ac_adjust_npta_by_rr(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_adjust_npta_by_rr(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1182,13 +1140,12 @@ int llc_conn_ac_adjust_npta_by_rr(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_conn_ac_adjust_npta_by_rnr - decreases "npta" by one
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* After receiving "dec_cntr" times RNR command, this action decreases
* "npta" by one. Returns 0 for success, 1 otherwise.
*/
int llc_conn_ac_adjust_npta_by_rnr(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_adjust_npta_by_rnr(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1207,13 +1164,13 @@ int llc_conn_ac_adjust_npta_by_rnr(struct sock *sk,
/**
* llc_conn_ac_dec_tx_win_size - decreases tx window size
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* After receiving of a REJ command or response, transmit window size is
* decreased by number of PDUs which are outstanding yet. Returns 0 for
* success, 1 otherwise.
*/
int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
u8 unacked_pdu = skb_queue_len(&llc->pdu_unack_q);
......@@ -1227,12 +1184,12 @@ int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_conn_ac_inc_tx_win_size - tx window size is inc by 1
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* After receiving an RR response with f-bit set to one, transmit window
* size is increased by one. Returns 0 for success, 1 otherwise.
*/
int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1242,7 +1199,7 @@ int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_stop_all_timers(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_stop_all_timers(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1259,7 +1216,7 @@ int llc_conn_ac_stop_all_timers(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_stop_other_timers(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_stop_other_timers(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1274,7 +1231,7 @@ int llc_conn_ac_stop_other_timers(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_start_ack_timer(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1287,7 +1244,7 @@ int llc_conn_ac_start_ack_timer(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_start_rej_timer(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1302,7 +1259,7 @@ int llc_conn_ac_start_rej_timer(struct sock *sk, struct llc_conn_state_ev *ev)
}
int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1317,14 +1274,14 @@ int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
return 0;
}
int llc_conn_ac_stop_ack_timer(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_stop_ack_timer(struct sock *sk, struct sk_buff *skb)
{
del_timer(&llc_sk(sk)->ack_timer.timer);
llc_sk(sk)->ack_timer.running = 0;
return 0;
}
int llc_conn_ac_stop_p_timer(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_stop_p_timer(struct sock *sk, struct sk_buff *skb)
{
struct llc_opt *llc = llc_sk(sk);
......@@ -1334,20 +1291,19 @@ int llc_conn_ac_stop_p_timer(struct sock *sk, struct llc_conn_state_ev *ev)
return 0;
}
int llc_conn_ac_stop_rej_timer(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_stop_rej_timer(struct sock *sk, struct sk_buff *skb)
{
del_timer(&llc_sk(sk)->rej_sent_timer.timer);
llc_sk(sk)->rej_sent_timer.running = 0;
return 0;
}
int llc_conn_ac_upd_nr_received(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
{
int acked;
u16 unacked = 0;
u8 fbit;
struct sk_buff *skb = ev->data.pdu.skb;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
struct llc_opt *llc = llc_sk(sk);
llc->last_nr = PDU_SUPV_GET_Nr(pdu);
......@@ -1363,7 +1319,7 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct llc_conn_state_ev *ev)
* can send data and must inform to upper layer.
*/
llc->failed_data_req = 0;
llc_conn_ac_data_confirm(sk, ev);
llc_conn_ac_data_confirm(sk, skb);
}
if (unacked) {
llc->ack_timer.timer.expires = jiffies +
......@@ -1377,201 +1333,203 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct llc_conn_state_ev *ev)
llc_pdu_decode_pf_bit(skb, &fbit);
if (fbit == 1) {
llc->failed_data_req = 0;
llc_conn_ac_data_confirm(sk, ev);
llc_conn_ac_data_confirm(sk, skb);
}
}
return 0;
}
int llc_conn_ac_upd_p_flag(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_upd_p_flag(struct sock *sk, struct sk_buff *skb)
{
struct sk_buff *skb = ev->data.pdu.skb;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 f_bit;
if (!LLC_PDU_IS_RSP(pdu) &&
!llc_pdu_decode_pf_bit(skb, &f_bit) && f_bit) {
llc_sk(sk)->p_flag = 0;
llc_conn_ac_stop_p_timer(sk, ev);
llc_conn_ac_stop_p_timer(sk, skb);
}
return 0;
}
int llc_conn_ac_set_data_flag_2(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_data_flag_2(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->data_flag = 2;
return 0;
}
int llc_conn_ac_set_data_flag_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_data_flag_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->data_flag = 0;
return 0;
}
int llc_conn_ac_set_data_flag_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_data_flag_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->data_flag = 1;
return 0;
}
int llc_conn_ac_set_data_flag_1_if_data_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
if (!llc_sk(sk)->data_flag)
llc_sk(sk)->data_flag = 1;
return 0;
}
int llc_conn_ac_set_p_flag_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_p_flag_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->p_flag = 0;
return 0;
}
int llc_conn_ac_set_p_flag_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_p_flag_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->p_flag = 1;
return 0;
}
int llc_conn_ac_set_remote_busy_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_remote_busy_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->remote_busy_flag = 0;
return 0;
}
int llc_conn_ac_set_cause_flag_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_cause_flag_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->cause_flag = 0;
return 0;
}
int llc_conn_ac_set_cause_flag_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_cause_flag_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->cause_flag = 1;
return 0;
}
int llc_conn_ac_set_retry_cnt_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_retry_cnt_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->retry_count = 0;
return 0;
}
int llc_conn_ac_inc_retry_cnt_by_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ac_inc_retry_cnt_by_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->retry_count++;
return 0;
}
int llc_conn_ac_set_vr_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_vr_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->vR = 0;
return 0;
}
int llc_conn_ac_inc_vr_by_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_inc_vr_by_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->vR = PDU_GET_NEXT_Vr(llc_sk(sk)->vR);
return 0;
}
int llc_conn_ac_set_vs_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_vs_0(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->vS = 0;
return 0;
}
int llc_conn_ac_set_vs_nr(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->vS = llc_sk(sk)->last_nr;
return 0;
}
int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128;
return 0;
}
int llc_conn_ac_set_f_flag_p(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_set_f_flag_p(struct sock *sk, struct sk_buff *skb)
{
llc_pdu_decode_pf_bit(ev->data.pdu.skb, &llc_sk(sk)->f_flag);
llc_pdu_decode_pf_bit(skb, &llc_sk(sk)->f_flag);
return 0;
}
void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
{
struct sock *sk = (struct sock *)timeout_data;
struct llc_conn_state_ev *ev;
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
llc_sk(sk)->pf_cycle_timer.running = 0;
ev = llc_conn_alloc_ev(sk);
if (ev) {
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_P_TMR;
ev->data.tmr.timer_specific = NULL;
llc_process_tmr_ev(sk, ev);
llc_process_tmr_ev(sk, skb);
}
}
static void llc_conn_busy_tmr_cb(unsigned long timeout_data)
{
struct sock *sk = (struct sock *)timeout_data;
struct llc_conn_state_ev *ev;
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
llc_sk(sk)->busy_state_timer.running = 0;
ev = llc_conn_alloc_ev(sk);
if (ev) {
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_BUSY_TMR;
ev->data.tmr.timer_specific = NULL;
llc_process_tmr_ev(sk, ev);
llc_process_tmr_ev(sk, skb);
}
}
void llc_conn_ack_tmr_cb(unsigned long timeout_data)
{
struct sock* sk = (struct sock *)timeout_data;
struct llc_conn_state_ev *ev;
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
llc_sk(sk)->ack_timer.running = 0;
ev = llc_conn_alloc_ev(sk);
if (ev) {
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_ACK_TMR;
ev->data.tmr.timer_specific = NULL;
llc_process_tmr_ev(sk, ev);
llc_process_tmr_ev(sk, skb);
}
}
static void llc_conn_rej_tmr_cb(unsigned long timeout_data)
{
struct sock *sk = (struct sock *)timeout_data;
struct llc_conn_state_ev *ev;
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
llc_sk(sk)->rej_sent_timer.running = 0;
ev = llc_conn_alloc_ev(sk);
if (ev) {
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_REJ_TMR;
ev->data.tmr.timer_specific = NULL;
llc_process_tmr_ev(sk, ev);
llc_process_tmr_ev(sk, skb);
}
}
int llc_conn_ac_rst_vs(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb)
{
llc_sk(sk)->X = llc_sk(sk)->vS;
llc_conn_ac_set_vs_nr(sk, ev);
llc_conn_ac_set_vs_nr(sk, skb);
return 0;
}
int llc_conn_ac_upd_vs(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_upd_vs(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 nr = PDU_SUPV_GET_Nr(pdu);
if (llc_circular_between(llc_sk(sk)->vS, nr, llc_sk(sk)->X))
llc_conn_ac_set_vs_nr(sk, ev);
llc_conn_ac_set_vs_nr(sk, skb);
return 0;
}
......@@ -1582,11 +1540,11 @@ int llc_conn_ac_upd_vs(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_conn_disc - removes connection from SAP list and frees it
* @sk: closed connection
* @ev: occurred event
* @skb: occurred event
*
* Returns 2, to indicate the state machine that the connection was freed.
*/
int llc_conn_disc(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_disc(struct sock *sk, struct sk_buff *skb)
{
llc_sap_unassign_sock(llc_sk(sk)->sap, sk);
llc_sock_free(sk);
......@@ -1596,11 +1554,11 @@ int llc_conn_disc(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_conn_reset - resets connection
* @sk : reseting connection.
* @ev: occurred event.
* @skb: occurred event.
*
* Stop all timers, empty all queues and reset all flags.
*/
int llc_conn_reset(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_reset(struct sock *sk, struct sk_buff *skb)
{
llc_sock_reset(sk);
return 0;
......@@ -1626,7 +1584,7 @@ u8 llc_circular_between(u8 a, u8 b, u8 c)
/**
* llc_process_tmr_ev - timer backend
* @sk: active connection
* @ev: occurred event
* @skb: occurred event
*
* This function is called from timer callback functions. When connection
* is busy (during sending a data frame) timer expiration event must be
......@@ -1634,25 +1592,20 @@ u8 llc_circular_between(u8 a, u8 b, u8 c)
* Queued events will process by process_rxframes_events function after
* sending data frame. Returns 0 for success, 1 otherwise.
*/
static void llc_process_tmr_ev(struct sock *sk, struct llc_conn_state_ev *ev)
static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
{
bh_lock_sock(sk);
if (llc_sk(sk)->state == LLC_CONN_OUT_OF_SVC) {
printk(KERN_WARNING "timer called on closed connection\n");
llc_conn_free_ev(ev);
printk(KERN_WARNING "%s: timer called on closed connection\n",
__FUNCTION__);
llc_conn_free_ev(skb);
goto out;
}
if (!sk->lock.users)
llc_conn_send_ev(sk, ev);
llc_conn_send_ev(sk, skb);
else {
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
if (skb) {
skb->cb[0] = LLC_EVENT;
skb->data = (void *)ev;
llc_set_backlog_type(skb, LLC_EVENT);
sk_add_backlog(sk, skb);
} else
llc_conn_free_ev(ev);
}
out:
bh_unlock_sock(sk);
......
......@@ -40,7 +40,7 @@
#include <net/llc_c_ev.h>
#include <net/llc_pdu.h>
#if 0
#if 1
#define dprintk(args...) printk(KERN_DEBUG args)
#else
#define dprintk(args...)
......@@ -97,102 +97,111 @@ static u16 llc_util_nr_inside_tx_window(struct sock *sk, u8 nr)
return rc;
}
int llc_conn_ev_conn_req(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->data.prim.prim == LLC_CONN_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_conn_ev_conn_resp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_conn_resp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->data.prim.prim == LLC_CONN_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_RESP ? 0 : 1;
}
int llc_conn_ev_data_req(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->data.prim.prim == LLC_DATA_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_conn_ev_disc_req(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->data.prim.prim == LLC_DISC_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_conn_ev_rst_req(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->data.prim.prim == LLC_RESET_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_conn_ev_rst_resp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rst_resp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->data.prim.prim == LLC_RESET_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_RESP ? 0 : 1;
}
int llc_conn_ev_local_busy_detected(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
ev->data.a.ev == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1;
}
int llc_conn_ev_local_busy_cleared(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
ev->data.a.ev == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1;
}
int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb)
{
return 1;
}
int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1;
}
int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1;
}
int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1;
}
int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_0(pdu) &&
LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
}
int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_1(pdu) &&
......@@ -200,9 +209,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk,
}
int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -212,9 +221,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
}
int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -224,9 +233,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
}
int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
u16 rc = !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_I(pdu) && ns != vr &&
......@@ -238,39 +247,36 @@ int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_0(pdu) &&
LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
}
int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_1(pdu) &&
LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
}
int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
}
int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -280,9 +286,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
}
int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -292,9 +298,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
}
int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -303,9 +309,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
}
int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
u16 rc = !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) && ns != vr &&
......@@ -317,158 +323,142 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_REJ ? 0 : 1;
}
int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_REJ ? 0 : 1;
}
int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
}
int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
}
int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
}
int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RNR ? 0 : 1;
}
int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RNR ? 0 : 1;
}
int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RNR ? 0 : 1;
}
int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RNR ? 0 : 1;
}
int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RR ? 0 : 1;
}
int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RR ? 0 : 1;
}
int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RR ? 0 : 1;
}
int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RR ? 0 : 1;
}
int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1;
}
int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_UA ? 0 : 1;
}
int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
......@@ -480,11 +470,10 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_xxx_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_xxx_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
......@@ -502,11 +491,10 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_0(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu))
......@@ -522,11 +510,10 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if (!LLC_PDU_IS_RSP(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
......@@ -545,11 +532,10 @@ int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
if (!LLC_PDU_IS_RSP(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu))
......@@ -567,10 +553,10 @@ int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
return rc;
}
int llc_conn_ev_rx_xxx_yyy(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_xxx_yyy(struct sock *sk, struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu))
rc = 0;
......@@ -588,77 +574,79 @@ int llc_conn_ev_rx_xxx_yyy(struct sock *sk, struct llc_conn_state_ev *ev)
}
int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vs = llc_sk(sk)->vS;
u8 nr = LLC_I_GET_NR(pdu);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
if (nr != vs &&
llc_util_nr_inside_tx_window(sk, nr)) {
dprintk(KERN_ERR "conn_ev_rx_zzz_cmd_inv_nr "
"matched, state = %d, vs = %d, "
"nr = %d\n", llc_sk(sk)->state, vs, nr);
if (!LLC_PDU_IS_CMD(pdu) &&
(!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) &&
nr != vs && llc_util_nr_inside_tx_window(sk, nr)) {
dprintk(KERN_ERR "conn_ev_rx_zzz_cmd_inv_nr matched, state = "
"%d, vs = %d, nr = %d\n",
llc_sk(sk)->state, vs, nr);
rc = 0;
}
}
}
return rc;
}
int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
u8 vs = llc_sk(sk)->vS;
u8 nr = LLC_I_GET_NR(pdu);
if (!LLC_PDU_IS_RSP(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
if (nr != vs &&
llc_util_nr_inside_tx_window(sk, nr)) {
if (!LLC_PDU_IS_RSP(pdu) &&
(!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) &&
nr != vs && llc_util_nr_inside_tx_window(sk, nr)) {
rc = 0;
dprintk(KERN_ERR "conn_ev_rx_zzz_fbit_set"
"_x_inval_nr matched, state = %d, "
"vs = %d, nr = %d\n",
dprintk(KERN_ERR "conn_ev_rx_zzz_fbit_set_x_inval_nr matched, "
"state = %d, vs = %d, nr = %d\n",
llc_sk(sk)->state, vs, nr);
}
}
}
return rc;
}
int llc_conn_ev_rx_any_frame(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb)
{
return 0;
}
int llc_conn_ev_p_tmr_exp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type != LLC_CONN_EV_TYPE_P_TMR;
}
int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type != LLC_CONN_EV_TYPE_ACK_TMR;
}
int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type != LLC_CONN_EV_TYPE_REJ_TMR;
}
int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR;
}
int llc_conn_ev_any_tmr_exp(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_any_tmr_exp(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type == LLC_CONN_EV_TYPE_P_TMR ||
ev->type == LLC_CONN_EV_TYPE_ACK_TMR ||
......@@ -666,13 +654,15 @@ int llc_conn_ev_any_tmr_exp(struct sock *sk, struct llc_conn_state_ev *ev)
ev->type == LLC_CONN_EV_TYPE_BUSY_TMR ? 0 : 1;
}
int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb)
{
return 1;
}
int llc_conn_ev_tx_buffer_full(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
ev->data.a.ev == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1;
}
......@@ -683,26 +673,22 @@ int llc_conn_ev_tx_buffer_full(struct sock *sk, struct llc_conn_state_ev *ev)
* the connection and return either a 0 for success or a non-zero value
* for not-success; verify the event is the type we expect
*/
int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->data_flag != 1;
}
int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->data_flag;
}
int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->data_flag != 2;
}
int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->p_flag != 1;
}
......@@ -710,7 +696,7 @@ int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk,
/**
* conn_ev_qlfy_last_frame_eq_1 - checks if frame is last in tx window
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* This function determines when frame which is sent, is last frame of
* transmit window, if it is then this function return zero else return
......@@ -718,8 +704,7 @@ int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk,
* as I-format command with p-bit set to one. Returns 0 if frame is last
* frame, 1 otherwise.
*/
int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk, struct sk_buff *skb)
{
return !(skb_queue_len(&llc_sk(sk)->pdu_unack_q) + 1 == llc_sk(sk)->k);
}
......@@ -727,147 +712,144 @@ int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk,
/**
* conn_ev_qlfy_last_frame_eq_0 - checks if frame isn't last in tx window
* @sk: current connection structure.
* @ev: current event.
* @skb: current event.
*
* This function determines when frame which is sent, isn't last frame of
* transmit window, if it isn't then this function return zero else return
* one. Returns 0 if frame isn't last frame, 1 otherwise.
*/
int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk, struct sk_buff *skb)
{
return skb_queue_len(&llc_sk(sk)->pdu_unack_q) + 1 == llc_sk(sk)->k;
}
int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->p_flag;
}
int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb)
{
u8 f_bit;
struct sk_buff *skb;
if (ev->type == LLC_CONN_EV_TYPE_PDU)
skb = ev->data.pdu.skb;
else
skb = ev->data.prim.data->data->conn.skb;
llc_pdu_decode_pf_bit(skb, &f_bit);
return llc_sk(sk)->p_flag == f_bit ? 0 : 1;
}
int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->remote_busy_flag;
}
int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk, struct sk_buff *skb)
{
return !llc_sk(sk)->remote_busy_flag;
}
int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk, struct sk_buff *skb)
{
return !(llc_sk(sk)->retry_count < llc_sk(sk)->n2);
}
int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk, struct sk_buff *skb)
{
return !(llc_sk(sk)->retry_count >= llc_sk(sk)->n2);
}
int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb)
{
return !llc_sk(sk)->s_flag;
}
int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->s_flag;
}
int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk, struct sk_buff *skb)
{
return !llc_sk(sk)->cause_flag;
}
int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk, struct sk_buff *skb)
{
return llc_sk(sk)->cause_flag;
}
int llc_conn_ev_qlfy_init_p_f_cycle(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_init_p_f_cycle(struct sock *sk, struct sk_buff *skb)
{
return 0;
}
int llc_conn_ev_qlfy_set_status_conn(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_conn(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_CONN;
return 0;
}
int llc_conn_ev_qlfy_set_status_disc(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_disc(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_DISC;
return 0;
}
int llc_conn_ev_qlfy_set_status_impossible(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_impossible(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_IMPOSSIBLE;
return 0;
}
int llc_conn_ev_qlfy_set_status_failed(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_failed(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_FAILED;
return 0;
}
int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_REMOTE_BUSY;
return 0;
}
int llc_conn_ev_qlfy_set_status_received(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_received(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_RECEIVED;
return 0;
}
int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_REFUSE;
return 0;
}
int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_CONFLICT;
return 0;
}
int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk,
struct llc_conn_state_ev *ev)
int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->status = LLC_STATUS_RESET_DONE;
return 0;
}
......@@ -347,7 +347,7 @@ static struct llc_conn_state_trans llc_common_state_trans_11d = {
* Common dummy state transition; must be last entry for all state
* transition groups - it'll be on .bss, so will be zeroed.
*/
static struct llc_conn_state_trans llc_common_state_trans_n;
static struct llc_conn_state_trans llc_common_state_trans_end;
/* LLC_CONN_STATE_ADM transitions */
/* State transitions for LLC_CONN_EV_CONN_REQ event */
......@@ -432,15 +432,15 @@ static struct llc_conn_state_trans llc_adm_state_trans_5 = {
*/
static struct llc_conn_state_trans *llc_adm_state_transitions[] = {
[0] = &llc_adm_state_trans_1, /* Request */
[1] = &llc_common_state_trans_n,
[2] = &llc_common_state_trans_n, /* local_busy */
[3] = &llc_common_state_trans_n, /* init_pf_cycle */
[4] = &llc_common_state_trans_n, /* timer */
[1] = &llc_common_state_trans_end,
[2] = &llc_common_state_trans_end, /* local_busy */
[3] = &llc_common_state_trans_end, /* init_pf_cycle */
[4] = &llc_common_state_trans_end, /* timer */
[5] = &llc_adm_state_trans_2, /* Receive frame */
[6] = &llc_adm_state_trans_3,
[7] = &llc_adm_state_trans_4,
[8] = &llc_adm_state_trans_5,
[9] = &llc_common_state_trans_n,
[9] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_SETUP transitions */
......@@ -593,18 +593,18 @@ static struct llc_conn_state_trans llc_setup_state_trans_8 = {
* one to each transition
*/
static struct llc_conn_state_trans *llc_setup_state_transitions[] = {
[0] = &llc_common_state_trans_n, /* Request */
[1] = &llc_common_state_trans_n, /* local busy */
[2] = &llc_common_state_trans_n, /* init_pf_cycle */
[0] = &llc_common_state_trans_end, /* Request */
[1] = &llc_common_state_trans_end, /* local busy */
[2] = &llc_common_state_trans_end, /* init_pf_cycle */
[3] = &llc_setup_state_trans_3, /* Timer */
[4] = &llc_setup_state_trans_7,
[5] = &llc_setup_state_trans_8,
[6] = &llc_common_state_trans_n,
[6] = &llc_common_state_trans_end,
[7] = &llc_setup_state_trans_1, /* Receive frame */
[8] = &llc_setup_state_trans_2,
[9] = &llc_setup_state_trans_4,
[10] = &llc_setup_state_trans_5,
[11] = &llc_common_state_trans_n,
[11] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_NORMAL transitions */
......@@ -1287,13 +1287,13 @@ static struct llc_conn_state_trans *llc_normal_state_transitions[] = {
[2] = &llc_normal_state_trans_2_1,
[3] = &llc_common_state_trans_1,
[4] = &llc_common_state_trans_2,
[5] = &llc_common_state_trans_n,
[5] = &llc_common_state_trans_end,
[6] = &llc_normal_state_trans_21,
[7] = &llc_normal_state_trans_3, /* Local busy */
[8] = &llc_normal_state_trans_4,
[9] = &llc_common_state_trans_n,
[9] = &llc_common_state_trans_end,
[10] = &llc_normal_state_trans_18, /* Init pf cycle */
[11] = &llc_common_state_trans_n,
[11] = &llc_common_state_trans_end,
[12] = &llc_common_state_trans_11a, /* Timers */
[13] = &llc_common_state_trans_11b,
[14] = &llc_common_state_trans_11c,
......@@ -1301,7 +1301,7 @@ static struct llc_conn_state_trans *llc_normal_state_transitions[] = {
[16] = &llc_normal_state_trans_19,
[17] = &llc_normal_state_trans_20a,
[18] = &llc_normal_state_trans_20b,
[19] = &llc_common_state_trans_n,
[19] = &llc_common_state_trans_end,
[20] = &llc_normal_state_trans_8b, /* Receive frames */
[21] = &llc_normal_state_trans_9b,
[22] = &llc_normal_state_trans_10,
......@@ -1337,7 +1337,7 @@ static struct llc_conn_state_trans *llc_normal_state_transitions[] = {
[52] = &llc_common_state_trans_8c,
[53] = &llc_common_state_trans_9,
/* [54] = &llc_common_state_trans_10, */
[54] = &llc_common_state_trans_n,
[54] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_BUSY transitions */
......@@ -2096,16 +2096,16 @@ static struct llc_conn_state_trans *llc_busy_state_transitions[] = {
[2] = &llc_busy_state_trans_1,
[3] = &llc_busy_state_trans_2,
[4] = &llc_busy_state_trans_2_1,
[5] = &llc_common_state_trans_n,
[5] = &llc_common_state_trans_end,
[6] = &llc_busy_state_trans_3, /* Local busy */
[7] = &llc_busy_state_trans_4,
[8] = &llc_busy_state_trans_5,
[9] = &llc_busy_state_trans_6,
[10] = &llc_busy_state_trans_7,
[11] = &llc_busy_state_trans_8,
[12] = &llc_common_state_trans_n,
[12] = &llc_common_state_trans_end,
[13] = &llc_busy_state_trans_22, /* Initiate PF cycle */
[14] = &llc_common_state_trans_n,
[14] = &llc_common_state_trans_end,
[15] = &llc_common_state_trans_11a, /* Timer */
[16] = &llc_common_state_trans_11b,
[17] = &llc_common_state_trans_11c,
......@@ -2115,7 +2115,7 @@ static struct llc_conn_state_trans *llc_busy_state_transitions[] = {
[21] = &llc_busy_state_trans_24b,
[22] = &llc_busy_state_trans_25,
[23] = &llc_busy_state_trans_26,
[24] = &llc_common_state_trans_n,
[24] = &llc_common_state_trans_end,
[25] = &llc_busy_state_trans_9a, /* Receive frame */
[26] = &llc_busy_state_trans_9b,
[27] = &llc_busy_state_trans_10a,
......@@ -2150,7 +2150,7 @@ static struct llc_conn_state_trans *llc_busy_state_transitions[] = {
[56] = &llc_common_state_trans_8c,
[57] = &llc_common_state_trans_9,
/* [58] = &llc_common_state_trans_10, */
[58] = &llc_common_state_trans_n,
[58] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_REJ transitions */
......@@ -2770,15 +2770,15 @@ static struct llc_conn_state_trans llc_reject_state_trans_20b = {
static struct llc_conn_state_trans *llc_reject_state_transitions[] = {
[0] = &llc_common_state_trans_1, /* Request */
[1] = &llc_common_state_trans_2,
[2] = &llc_common_state_trans_n,
[2] = &llc_common_state_trans_end,
[3] = &llc_reject_state_trans_1,
[4] = &llc_reject_state_trans_2,
[5] = &llc_reject_state_trans_2_1,
[6] = &llc_reject_state_trans_3, /* Local busy */
[7] = &llc_reject_state_trans_4,
[8] = &llc_common_state_trans_n,
[8] = &llc_common_state_trans_end,
[9] = &llc_reject_state_trans_17, /* Initiate PF cycle */
[10] = &llc_common_state_trans_n,
[10] = &llc_common_state_trans_end,
[11] = &llc_common_state_trans_11a, /* Timer */
[12] = &llc_common_state_trans_11b,
[13] = &llc_common_state_trans_11c,
......@@ -2787,7 +2787,7 @@ static struct llc_conn_state_trans *llc_reject_state_transitions[] = {
[16] = &llc_reject_state_trans_19,
[17] = &llc_reject_state_trans_20a,
[18] = &llc_reject_state_trans_20b,
[19] = &llc_common_state_trans_n,
[19] = &llc_common_state_trans_end,
[20] = &llc_common_state_trans_3, /* Receive frame */
[21] = &llc_common_state_trans_4,
[22] = &llc_common_state_trans_5,
......@@ -2821,7 +2821,7 @@ static struct llc_conn_state_trans *llc_reject_state_transitions[] = {
[49] = &llc_reject_state_trans_15a,
[50] = &llc_reject_state_trans_15b,
[51] = &llc_reject_state_trans_16,
[52] = &llc_common_state_trans_n,
[52] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_AWAIT transitions */
......@@ -3209,16 +3209,16 @@ static struct llc_conn_state_trans *llc_await_state_transitions[] = {
[0] = &llc_common_state_trans_1, /* Request */
[1] = &llc_common_state_trans_2,
[2] = &llc_await_state_trans_1_0,
[3] = &llc_common_state_trans_n,
[3] = &llc_common_state_trans_end,
[4] = &llc_await_state_trans_1, /* Local busy */
[5] = &llc_common_state_trans_n,
[6] = &llc_common_state_trans_n, /* Initiate PF Cycle */
[5] = &llc_common_state_trans_end,
[6] = &llc_common_state_trans_end, /* Initiate PF Cycle */
[7] = &llc_common_state_trans_11a, /* Timer */
[8] = &llc_common_state_trans_11b,
[9] = &llc_common_state_trans_11c,
[10] = &llc_common_state_trans_11d,
[11] = &llc_await_state_trans_14,
[12] = &llc_common_state_trans_n,
[12] = &llc_common_state_trans_end,
[13] = &llc_common_state_trans_3, /* Receive frame */
[14] = &llc_common_state_trans_4,
[15] = &llc_common_state_trans_5,
......@@ -3250,7 +3250,7 @@ static struct llc_conn_state_trans *llc_await_state_transitions[] = {
[40] = &llc_await_state_trans_12a,
[41] = &llc_await_state_trans_12b,
[42] = &llc_await_state_trans_13,
[43] = &llc_common_state_trans_n,
[43] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_AWAIT_BUSY transitions */
......@@ -3683,18 +3683,18 @@ static struct llc_conn_state_trans *llc_await_busy_state_transitions[] = {
[0] = &llc_common_state_trans_1, /* Request */
[1] = &llc_common_state_trans_2,
[2] = &llc_await_busy_state_trans_1_0,
[3] = &llc_common_state_trans_n,
[3] = &llc_common_state_trans_end,
[4] = &llc_await_busy_state_trans_1, /* Local busy */
[5] = &llc_await_busy_state_trans_2,
[6] = &llc_await_busy_state_trans_3,
[7] = &llc_common_state_trans_n,
[8] = &llc_common_state_trans_n, /* Initiate PF cycle */
[7] = &llc_common_state_trans_end,
[8] = &llc_common_state_trans_end, /* Initiate PF cycle */
[9] = &llc_common_state_trans_11a, /* Timer */
[10] = &llc_common_state_trans_11b,
[11] = &llc_common_state_trans_11c,
[12] = &llc_common_state_trans_11d,
[13] = &llc_await_busy_state_trans_16,
[14] = &llc_common_state_trans_n,
[14] = &llc_common_state_trans_end,
[15] = &llc_await_busy_state_trans_4, /* Receive frame */
[16] = &llc_await_busy_state_trans_5a,
[17] = &llc_await_busy_state_trans_5b,
......@@ -3726,7 +3726,7 @@ static struct llc_conn_state_trans *llc_await_busy_state_transitions[] = {
[43] = &llc_common_state_trans_8c,
[44] = &llc_common_state_trans_9,
/* [45] = &llc_common_state_trans_10, */
[45] = &llc_common_state_trans_n,
[45] = &llc_common_state_trans_end,
};
/* ----------------- LLC_CONN_STATE_AWAIT_REJ transitions --------------- */
......@@ -4110,16 +4110,16 @@ static struct llc_conn_state_trans *llc_await_rejct_state_transitions[] = {
[0] = &llc_await_reject_state_trans_1_0,
[1] = &llc_common_state_trans_1, /* requests */
[2] = &llc_common_state_trans_2,
[3] = &llc_common_state_trans_n,
[3] = &llc_common_state_trans_end,
[4] = &llc_await_rejct_state_trans_1, /* local busy */
[5] = &llc_common_state_trans_n,
[6] = &llc_common_state_trans_n, /* Initiate PF cycle */
[5] = &llc_common_state_trans_end,
[6] = &llc_common_state_trans_end, /* Initiate PF cycle */
[7] = &llc_await_rejct_state_trans_13, /* timers */
[8] = &llc_common_state_trans_11a,
[9] = &llc_common_state_trans_11b,
[10] = &llc_common_state_trans_11c,
[11] = &llc_common_state_trans_11d,
[12] = &llc_common_state_trans_n,
[12] = &llc_common_state_trans_end,
[13] = &llc_await_rejct_state_trans_2a, /* receive frames */
[14] = &llc_await_rejct_state_trans_2b,
[15] = &llc_await_rejct_state_trans_3,
......@@ -4151,7 +4151,7 @@ static struct llc_conn_state_trans *llc_await_rejct_state_transitions[] = {
[41] = &llc_common_state_trans_8c,
[42] = &llc_common_state_trans_9,
/* [43] = &llc_common_state_trans_10, */
[43] = &llc_common_state_trans_n,
[43] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_D_CONN transitions */
......@@ -4392,13 +4392,13 @@ static struct llc_conn_state_trans llc_d_conn_state_trans_8 = {
*/
static struct llc_conn_state_trans *llc_d_conn_state_transitions[] = {
[0] = &llc_d_conn_state_trans_5, /* Request */
[1] = &llc_common_state_trans_n,
[2] = &llc_common_state_trans_n, /* Local busy */
[3] = &llc_common_state_trans_n, /* Initiate PF cycle */
[1] = &llc_common_state_trans_end,
[2] = &llc_common_state_trans_end, /* Local busy */
[3] = &llc_common_state_trans_end, /* Initiate PF cycle */
[4] = &llc_d_conn_state_trans_6, /* Timer */
[5] = &llc_d_conn_state_trans_7,
[6] = &llc_d_conn_state_trans_8,
[7] = &llc_common_state_trans_n,
[7] = &llc_common_state_trans_end,
[8] = &llc_d_conn_state_trans_1, /* Receive frame */
[9] = &llc_d_conn_state_trans_1_1,
[10] = &llc_d_conn_state_trans_2,
......@@ -4406,7 +4406,7 @@ static struct llc_conn_state_trans *llc_d_conn_state_transitions[] = {
[12] = &llc_d_conn_state_trans_3,
[13] = &llc_d_conn_state_trans_4,
[14] = &llc_d_conn_state_trans_4_1,
[15] = &llc_common_state_trans_n,
[15] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_RESET transitions */
......@@ -4678,14 +4678,14 @@ static struct llc_conn_state_trans llc_rst_state_trans_8_1 = {
*/
static struct llc_conn_state_trans *llc_rst_state_transitions[] = {
[0] = &llc_rst_state_trans_6, /* Request */
[1] = &llc_common_state_trans_n,
[2] = &llc_common_state_trans_n, /* Local busy */
[3] = &llc_common_state_trans_n, /* Initiate PF cycle */
[1] = &llc_common_state_trans_end,
[2] = &llc_common_state_trans_end, /* Local busy */
[3] = &llc_common_state_trans_end, /* Initiate PF cycle */
[4] = &llc_rst_state_trans_3, /* Timer */
[5] = &llc_rst_state_trans_7,
[6] = &llc_rst_state_trans_8,
[7] = &llc_rst_state_trans_8_1,
[8] = &llc_common_state_trans_n,
[8] = &llc_common_state_trans_end,
[9] = &llc_rst_state_trans_1, /* Receive frame */
[10] = &llc_rst_state_trans_2,
[11] = &llc_rst_state_trans_2_1,
......@@ -4693,7 +4693,7 @@ static struct llc_conn_state_trans *llc_rst_state_transitions[] = {
[13] = &llc_rst_state_trans_4_1,
[14] = &llc_rst_state_trans_5,
[15] = &llc_rst_state_trans_5_1,
[16] = &llc_common_state_trans_n,
[16] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_ERROR transitions */
......@@ -4849,19 +4849,19 @@ static struct llc_conn_state_trans llc_error_state_trans_9 = {
*/
static struct llc_conn_state_trans *llc_error_state_transitions[] = {
[0] = &llc_error_state_trans_9, /* Request */
[1] = &llc_common_state_trans_n,
[2] = &llc_common_state_trans_n, /* Local busy */
[3] = &llc_common_state_trans_n, /* Initiate PF cycle */
[1] = &llc_common_state_trans_end,
[2] = &llc_common_state_trans_end, /* Local busy */
[3] = &llc_common_state_trans_end, /* Initiate PF cycle */
[4] = &llc_error_state_trans_7, /* Timer */
[5] = &llc_error_state_trans_8,
[6] = &llc_common_state_trans_n,
[6] = &llc_common_state_trans_end,
[7] = &llc_error_state_trans_1, /* Receive frame */
[8] = &llc_error_state_trans_2,
[9] = &llc_error_state_trans_3,
[10] = &llc_error_state_trans_4,
[11] = &llc_error_state_trans_5,
[12] = &llc_error_state_trans_6,
[13] = &llc_common_state_trans_n,
[13] = &llc_common_state_trans_end,
};
/* LLC_CONN_STATE_TEMP transitions */
......@@ -4886,61 +4886,61 @@ static struct llc_conn_state_trans llc_temp_state_trans_1 = {
*/
static struct llc_conn_state_trans *llc_temp_state_transitions[] = {
[0] = &llc_temp_state_trans_1, /* requests */
[1] = &llc_common_state_trans_n,
[2] = &llc_common_state_trans_n, /* local busy */
[3] = &llc_common_state_trans_n, /* init_pf_cycle */
[4] = &llc_common_state_trans_n, /* timer */
[5] = &llc_common_state_trans_n, /* receive */
[1] = &llc_common_state_trans_end,
[2] = &llc_common_state_trans_end, /* local busy */
[3] = &llc_common_state_trans_end, /* init_pf_cycle */
[4] = &llc_common_state_trans_end, /* timer */
[5] = &llc_common_state_trans_end, /* receive */
};
/* Connection State Transition Table */
struct llc_conn_state llc_conn_state_table[] = {
{
.current_state =LLC_CONN_STATE_ADM,
struct llc_conn_state llc_conn_state_table[NBR_CONN_STATES] = {
[LLC_CONN_STATE_ADM - 1] = {
.current_state = LLC_CONN_STATE_ADM,
.transitions = llc_adm_state_transitions,
},
{
.current_state =LLC_CONN_STATE_SETUP,
[LLC_CONN_STATE_SETUP - 1] = {
.current_state = LLC_CONN_STATE_SETUP,
.transitions = llc_setup_state_transitions,
},
{
.current_state =LLC_CONN_STATE_NORMAL,
[LLC_CONN_STATE_NORMAL - 1] = {
.current_state = LLC_CONN_STATE_NORMAL,
.transitions = llc_normal_state_transitions,
},
{
.current_state =LLC_CONN_STATE_BUSY,
[LLC_CONN_STATE_BUSY - 1] = {
.current_state = LLC_CONN_STATE_BUSY,
.transitions = llc_busy_state_transitions,
},
{
.current_state =LLC_CONN_STATE_REJ,
[LLC_CONN_STATE_REJ - 1] = {
.current_state = LLC_CONN_STATE_REJ,
.transitions = llc_reject_state_transitions,
},
{
.current_state =LLC_CONN_STATE_AWAIT,
[LLC_CONN_STATE_AWAIT - 1] = {
.current_state = LLC_CONN_STATE_AWAIT,
.transitions = llc_await_state_transitions,
},
{
.current_state =LLC_CONN_STATE_AWAIT_BUSY,
[LLC_CONN_STATE_AWAIT_BUSY - 1] = {
.current_state = LLC_CONN_STATE_AWAIT_BUSY,
.transitions = llc_await_busy_state_transitions,
},
{
.current_state =LLC_CONN_STATE_AWAIT_REJ,
[LLC_CONN_STATE_AWAIT_REJ - 1] = {
.current_state = LLC_CONN_STATE_AWAIT_REJ,
.transitions = llc_await_rejct_state_transitions,
},
{
.current_state =LLC_CONN_STATE_D_CONN,
[LLC_CONN_STATE_D_CONN - 1] = {
.current_state = LLC_CONN_STATE_D_CONN,
.transitions = llc_d_conn_state_transitions,
},
{
.current_state =LLC_CONN_STATE_RESET,
[LLC_CONN_STATE_RESET - 1] = {
.current_state = LLC_CONN_STATE_RESET,
.transitions = llc_rst_state_transitions,
},
{
.current_state =LLC_CONN_STATE_ERROR,
[LLC_CONN_STATE_ERROR - 1] = {
.current_state = LLC_CONN_STATE_ERROR,
.transitions = llc_error_state_transitions,
},
{
.current_state =LLC_CONN_STATE_TEMP,
[LLC_CONN_STATE_TEMP - 1] = {
.current_state = LLC_CONN_STATE_TEMP,
.transitions = llc_temp_state_transitions,
},
};
......@@ -28,56 +28,37 @@
static int llc_find_offset(int state, int ev_type);
static void llc_conn_send_pdus(struct sock *sk);
static int llc_conn_service(struct sock *sk, struct llc_conn_state_ev *ev);
static int llc_conn_service(struct sock *sk, struct sk_buff *skb);
static int llc_exec_conn_trans_actions(struct sock *sk,
struct llc_conn_state_trans *trans,
struct llc_conn_state_ev *ev);
static struct llc_conn_state_trans *
llc_qualify_conn_ev(struct sock *sk, struct llc_conn_state_ev *ev);
struct sk_buff *ev);
static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
struct sk_buff *skb);
/* Offset table on connection states transition diagram */
static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
/**
* llc_conn_alloc_event: allocates an event
* @sk: socket that event is associated
*
* Returns pointer to allocated connection on success, %NULL on failure.
*/
struct llc_conn_state_ev *llc_conn_alloc_ev(struct sock *sk)
{
struct llc_conn_state_ev *ev = NULL;
/* verify connection is valid, active and open */
if (llc_sk(sk)->state != LLC_CONN_OUT_OF_SVC) {
/* get event structure to build a station event */
ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
if (ev)
memset(ev, 0, sizeof(*ev));
}
return ev;
}
/**
* llc_conn_send_event - sends event to connection state machine
* @sk: connection
* @ev: occurred event
* @skb: occurred event
*
* Sends an event to connection state machine. after processing event
* (executing it's actions and changing state), upper layer will be
* indicated or confirmed, if needed. Returns 0 for success, 1 for
* failure. The socket lock has to be held before calling this function.
*/
int llc_conn_send_ev(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_send_ev(struct sock *sk, struct sk_buff *skb)
{
/* sending event to state machine */
int rc = llc_conn_service(sk, ev);
int rc = llc_conn_service(sk, skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
u8 flag = ev->flag;
struct llc_prim_if_block *ind_prim = ev->ind_prim;
struct llc_prim_if_block *cfm_prim = ev->cfm_prim;
llc_conn_free_ev(ev);
llc_conn_free_ev(skb);
#ifdef THIS_BREAKS_DISCONNECT_NOTIFICATION_BADLY
/* check if the connection was freed by the state machine by
* means of llc_conn_disc */
......@@ -125,15 +106,14 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb)
* llc_conn_rtn_pdu - sends received data pdu to upper layer
* @sk: Active connection
* @skb: Received data frame
* @ev: Occurred event
*
* Sends received data pdu to upper layer (by using indicate function).
* Prepares service parameters (prim and prim_data). calling indication
* function will be done in llc_conn_send_ev.
*/
void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb,
struct llc_conn_state_ev *ev)
void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
......@@ -291,34 +271,37 @@ static void llc_conn_send_pdus(struct sock *sk)
/**
* llc_conn_free_ev - free event
* @ev: event to free
* @skb: event to free
*
* Free allocated event.
*/
void llc_conn_free_ev(struct llc_conn_state_ev *ev)
void llc_conn_free_ev(struct sk_buff *skb)
{
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
if (ev->type == LLC_CONN_EV_TYPE_PDU) {
/* free the frame that binded to this event */
struct llc_pdu_sn *pdu =
(struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
/* free the frame that is bound to this event */
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if (LLC_PDU_TYPE_IS_I(pdu) || !ev->flag || !ev->ind_prim)
kfree_skb(ev->data.pdu.skb);
}
/* free event structure to free list of the same */
kfree(ev);
kfree_skb(skb);
} else if (ev->type == LLC_CONN_EV_TYPE_PRIM &&
ev->data.prim.prim != LLC_DATA_PRIM)
kfree_skb(skb);
else if (ev->type == LLC_CONN_EV_TYPE_P_TMR)
kfree_skb(skb);
}
/**
* llc_conn_service - finds transition and changes state of connection
* @sk: connection
* @ev: happened event
* @skb: happened event
*
* This function finds transition that matches with happened event, then
* executes related actions and finally changes state of connection.
* Returns 0 for success, 1 for failure.
*/
static int llc_conn_service(struct sock *sk, struct llc_conn_state_ev *ev)
static int llc_conn_service(struct sock *sk, struct sk_buff *skb)
{
int rc = 1;
struct llc_conn_state_trans *trans;
......@@ -326,9 +309,9 @@ static int llc_conn_service(struct sock *sk, struct llc_conn_state_ev *ev)
if (llc_sk(sk)->state > NBR_CONN_STATES)
goto out;
rc = 0;
trans = llc_qualify_conn_ev(sk, ev);
trans = llc_qualify_conn_ev(sk, skb);
if (trans) {
rc = llc_exec_conn_trans_actions(sk, trans, ev);
rc = llc_exec_conn_trans_actions(sk, trans, skb);
if (!rc && trans->next_state != NO_STATE_CHANGE)
llc_sk(sk)->state = trans->next_state;
}
......@@ -339,26 +322,28 @@ static int llc_conn_service(struct sock *sk, struct llc_conn_state_ev *ev)
/**
* llc_qualify_conn_ev - finds transition for event
* @sk: connection
* @ev: happened event
* @skb: happened event
*
* This function finds transition that matches with happened event.
* Returns pointer to found transition on success, %NULL otherwise.
*/
static struct llc_conn_state_trans *
llc_qualify_conn_ev(struct sock *sk, struct llc_conn_state_ev *ev)
static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
struct sk_buff *skb)
{
struct llc_conn_state_trans **next_trans;
llc_conn_ev_qfyr_t *next_qualifier;
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
struct llc_conn_state *curr_state =
&llc_conn_state_table[llc_sk(sk)->state - 1];
&llc_conn_state_table[llc->state - 1];
/* search thru events for this state until
* list exhausted or until no more
*/
for (next_trans = curr_state->transitions +
llc_find_offset(llc_sk(sk)->state - 1, ev->type);
llc_find_offset(llc->state - 1, ev->type);
(*next_trans)->ev; next_trans++) {
if (!((*next_trans)->ev)(sk, ev)) {
if (!((*next_trans)->ev)(sk, skb)) {
/* got POSSIBLE event match; the event may require
* qualification based on the values of a number of
* state flags; if all qualifications are met (i.e.,
......@@ -367,7 +352,7 @@ static struct llc_conn_state_trans *
*/
for (next_qualifier = (*next_trans)->ev_qualifiers;
next_qualifier && *next_qualifier &&
!(*next_qualifier)(sk, ev); next_qualifier++)
!(*next_qualifier)(sk, skb); next_qualifier++)
/* nothing */;
if (!next_qualifier || !*next_qualifier)
/* all qualifiers executed successfully; this is
......@@ -384,7 +369,7 @@ static struct llc_conn_state_trans *
* llc_exec_conn_trans_actions - executes related actions
* @sk: connection
* @trans: transition that it's actions must be performed
* @ev: happened event
* @skb: happened event
*
* Executes actions that is related to happened event. Returns 0 for
* success, 1 to indicate failure of at least one action or 2 if the
......@@ -392,14 +377,14 @@ static struct llc_conn_state_trans *
*/
static int llc_exec_conn_trans_actions(struct sock *sk,
struct llc_conn_state_trans *trans,
struct llc_conn_state_ev *ev)
struct sk_buff *skb)
{
int rc = 0;
llc_conn_action_t *next_action;
for (next_action = trans->ev_actions;
next_action && *next_action; next_action++) {
int rc2 = (*next_action)(sk, ev);
int rc2 = (*next_action)(sk, skb);
if (rc2 == 2) {
rc = rc2;
......
......@@ -24,39 +24,48 @@
#include <net/llc_pdu.h>
int llc_stat_ev_enable_with_dup_addr_check(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
return ev->type == LLC_STATION_EV_TYPE_SIMPLE &&
ev->data.a.ev ==
LLC_STATION_EV_ENABLE_WITH_DUP_ADDR_CHECK ? 0 : 1;
}
int llc_stat_ev_enable_without_dup_addr_check(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
return ev->type == LLC_STATION_EV_TYPE_SIMPLE &&
ev->data.a.ev ==
LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK ? 0 : 1;
}
int llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
return ev->type == LLC_STATION_EV_TYPE_ACK_TMR &&
station->retry_count < station->maximum_retry ? 0 : 1;
}
int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
return ev->type == LLC_STATION_EV_TYPE_ACK_TMR &&
station->retry_count == station->maximum_retry ? 0 : 1;
}
int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_station_state_ev *ev = llc_station_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */
......@@ -66,9 +75,10 @@ int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
}
int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_station_state_ev *ev = llc_station_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */
......@@ -79,9 +89,10 @@ int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
}
int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_station_state_ev *ev = llc_station_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */
......@@ -92,9 +103,10 @@ int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
}
int llc_stat_ev_rx_null_dsap_test_c(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_station_state_ev *ev = llc_station_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */
......@@ -103,9 +115,10 @@ int llc_stat_ev_rx_null_dsap_test_c(struct llc_station *station,
!pdu->dsap ? 0 : 1; /* NULL DSAP */
}
int llc_stat_ev_disable_req(struct llc_station *station,
struct llc_station_state_ev *ev)
int llc_stat_ev_disable_req(struct llc_station *station, struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
return ev->type == LLC_STATION_EV_TYPE_PRIM &&
ev->data.prim.prim == LLC_DISABLE_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
......
......@@ -168,15 +168,13 @@ static int llc_unitdata_req_handler(struct llc_prim_if_block *prim)
if (!sap)
goto out;
ev = llc_sap_alloc_ev(sap);
if (!ev)
goto out;
ev = llc_sap_ev(prim->data->udata.skb);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_DATAUNIT_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
rc = 0;
llc_sap_send_ev(sap, ev);
llc_sap_send_ev(sap, prim->data->udata.skb);
out:
return rc;
}
......@@ -196,15 +194,13 @@ static int llc_test_req_handler(struct llc_prim_if_block *prim)
struct llc_sap *sap = llc_sap_find(prim->data->udata.saddr.lsap);
if (!sap)
goto out;
ev = llc_sap_alloc_ev(sap);
if (!ev)
goto out;
ev = llc_sap_ev(prim->data->udata.skb);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_TEST_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
rc = 0;
llc_sap_send_ev(sap, ev);
llc_sap_send_ev(sap, prim->data->udata.skb);
out:
return rc;
}
......@@ -225,15 +221,13 @@ static int llc_xid_req_handler(struct llc_prim_if_block *prim)
if (!sap)
goto out;
ev = llc_sap_alloc_ev(sap);
if (!ev)
goto out;
ev = llc_sap_ev(prim->data->udata.skb);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_XID_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
rc = 0;
llc_sap_send_ev(sap, ev);
llc_sap_send_ev(sap, prim->data->udata.skb);
out:
return rc;
}
......@@ -273,29 +267,26 @@ static int llc_data_req_handler(struct llc_prim_if_block *prim)
llc->failed_data_req = 1;
goto out;
}
rc = -ENOMEM;
ev = llc_conn_alloc_ev(sk);
if (ev) {
ev = llc_conn_ev(prim->data->data.skb);
ev->type = LLC_CONN_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_DATA_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
prim->data->data.skb->dev = llc->dev;
rc = llc_conn_send_ev(sk, ev);
}
rc = llc_conn_send_ev(sk, prim->data->data.skb);
out:
release_sock(sk);
return rc;
}
/**
* confirm_impossible - Informs upper layer about failed connection
* llc_confirm_impossible - Informs upper layer about failed connection
* @prim: pointer to structure that contains confirmation data.
*
* Informs upper layer about failing in connection establishment. This
* function is called by llc_conn_req_handler.
*/
static void confirm_impossible(struct llc_prim_if_block *prim)
static void llc_confirm_impossible(struct llc_prim_if_block *prim)
{
prim->data->conn.status = LLC_STATUS_IMPOSSIBLE;
prim->sap->conf(prim);
......@@ -316,7 +307,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
int rc = -EBUSY;
struct llc_opt *llc;
struct llc_sap *sap = prim->sap;
struct llc_conn_state_ev *ev;
struct sk_buff *skb;
struct net_device *ddev = mac_dev_peer(prim->data->conn.dev,
prim->data->conn.dev->type,
prim->data->conn.daddr.mac),
......@@ -334,7 +325,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
daddr.lsap = prim->data->conn.daddr.lsap;
sk = llc_find_sock(sap, &daddr, &laddr);
if (sk) {
confirm_impossible(prim);
llc_confirm_impossible(prim);
goto out_put;
}
rc = -ENOMEM;
......@@ -345,7 +336,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
} else {
sk = llc_sock_alloc();
if (!sk) {
confirm_impossible(prim);
llc_confirm_impossible(prim);
goto out;
}
prim->data->conn.sk = sk;
......@@ -360,18 +351,20 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
llc->dev = ddev;
llc->link = prim->data->conn.link;
llc->handler = prim->data->conn.handler;
ev = llc_conn_alloc_ev(sk);
if (ev) {
skb = alloc_skb(1, GFP_ATOMIC);
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_CONN_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, ev);
rc = llc_conn_send_ev(sk, skb);
}
if (rc) {
llc_sap_unassign_sock(sap, sk);
llc_sock_free(sk);
confirm_impossible(prim);
llc_confirm_impossible(prim);
}
release_sock(sk);
out_put:
......@@ -393,6 +386,7 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim)
{
u16 rc = 1;
struct llc_conn_state_ev *ev;
struct sk_buff *skb;
struct sock* sk = prim->data->disc.sk;
sock_hold(sk);
......@@ -400,17 +394,19 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim)
if (llc_sk(sk)->state == LLC_CONN_STATE_ADM ||
llc_sk(sk)->state == LLC_CONN_OUT_OF_SVC)
goto out;
/* postpone unassigning the connection from its SAP and returning the
/*
* Postpone unassigning the connection from its SAP and returning the
* connection until all ACTIONs have been completely executed
*/
ev = llc_conn_alloc_ev(sk);
if (!ev)
skb = alloc_skb(1, GFP_ATOMIC);
if (!skb)
goto out;
ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_DISC_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, ev);
rc = llc_conn_send_ev(sk, skb);
out:
release_sock(sk);
sock_put(sk);
......@@ -428,18 +424,20 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim)
*/
static int llc_rst_req_handler(struct llc_prim_if_block *prim)
{
struct sk_buff *skb;
int rc = 1;
struct sock *sk = prim->data->res.sk;
struct llc_conn_state_ev *ev;
lock_sock(sk);
ev = llc_conn_alloc_ev(sk);
if (ev) {
skb = alloc_skb(1, GFP_ATOMIC);
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
ev->type = LLC_CONN_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_RESET_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, ev);
rc = llc_conn_send_ev(sk, skb);
}
release_sock(sk);
return rc;
......@@ -497,18 +495,21 @@ static int llc_conn_rsp_handler(struct llc_prim_if_block *prim)
static int llc_rst_rsp_handler(struct llc_prim_if_block *prim)
{
int rc = 1;
/* network layer supplies connection handle; map it to a connection;
/*
* Network layer supplies connection handle; map it to a connection;
* package as event and send it to connection event handler
*/
struct sock *sk = prim->data->res.sk;
struct llc_conn_state_ev *ev = llc_conn_alloc_ev(sk);
struct sk_buff *skb = alloc_skb(1, GFP_ATOMIC);
if (skb) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
if (ev) {
ev->type = LLC_CONN_EV_TYPE_PRIM;
ev->data.prim.prim = LLC_RESET_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_RESP;
ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, ev);
rc = llc_conn_send_ev(sk, skb);
}
return rc;
}
......
......@@ -27,6 +27,12 @@
#include <net/llc_s_ev.h>
#include <linux/trdevice.h>
#if 1
#define dprintk(args...) printk(KERN_DEBUG args)
#else
#define dprintk(args...)
#endif
/* function prototypes */
static void fix_up_incoming_skb(struct sk_buff *skb);
......@@ -46,7 +52,7 @@ int mac_send_pdu(struct sk_buff *skb)
int pri = GFP_ATOMIC, rc = -1;
if (!skb->dev) {
printk(KERN_ERR "%s: skb->dev == NULL!", __FUNCTION__);
dprintk(KERN_ERR "%s: skb->dev == NULL!", __FUNCTION__);
goto out;
}
if (skb->sk)
......@@ -83,7 +89,7 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
* receives, do not try to analyse it.
*/
if (skb->pkt_type == PACKET_OTHERHOST) {
printk(KERN_INFO "%s: PACKET_OTHERHOST\n", __FUNCTION__);
dprintk(KERN_INFO "%s: PACKET_OTHERHOST\n", __FUNCTION__);
goto drop;
}
skb = skb_share_check(skb, GFP_ATOMIC);
......@@ -140,7 +146,8 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
rc = llc_pdu_router(llc_sk(sk)->sap, sk, skb,
LLC_TYPE_2);
} else {
skb->cb[0] = LLC_PACKET;
dprintk(KERN_INFO "%s: add to backlog\n", __FUNCTION__);
llc_set_backlog_type(skb, LLC_PACKET);
sk_add_backlog(sk, skb);
rc = 0;
}
......@@ -207,38 +214,27 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
if (!pdu->dsap) {
struct llc_station *station = llc_station_get();
struct llc_station_state_ev *stat_ev =
llc_station_alloc_ev(station);
if (stat_ev) {
stat_ev->type = LLC_STATION_EV_TYPE_PDU;
stat_ev->data.pdu.skb = skb;
stat_ev->data.pdu.reason = 0;
llc_station_send_ev(station, stat_ev);
} else
rc = -ENOMEM;
struct llc_station_state_ev *ev = llc_station_ev(skb);
ev->type = LLC_STATION_EV_TYPE_PDU;
ev->data.pdu.reason = 0;
llc_station_send_ev(station, skb);
} else if (type == LLC_TYPE_1) {
struct llc_sap_state_ev *sap_ev = llc_sap_alloc_ev(sap);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
if (sap_ev) {
sap_ev->type = LLC_SAP_EV_TYPE_PDU;
sap_ev->data.pdu.skb = skb;
sap_ev->data.pdu.reason = 0;
llc_sap_send_ev(sap, sap_ev);
} else
rc = -ENOMEM;
ev->type = LLC_SAP_EV_TYPE_PDU;
ev->data.pdu.reason = 0;
llc_sap_send_ev(sap, skb);
} else if (type == LLC_TYPE_2) {
struct llc_conn_state_ev *conn_ev = llc_conn_alloc_ev(sk);
struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk);
if (!llc->dev)
llc->dev = skb->dev;
if (conn_ev) {
conn_ev->type = LLC_CONN_EV_TYPE_PDU;
conn_ev->data.pdu.skb = skb;
conn_ev->data.pdu.reason = 0;
rc = llc_conn_send_ev(sk, conn_ev);
} else
rc = -ENOMEM;
ev->type = LLC_CONN_EV_TYPE_PDU;
ev->data.pdu.reason = 0;
rc = llc_conn_send_ev(sk, skb);
} else
rc = -EINVAL;
return rc;
......
......@@ -38,16 +38,16 @@
/* static function prototypes */
static void llc_station_service_events(struct llc_station *station);
static void llc_station_free_ev(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
static void llc_station_send_pdus(struct llc_station *station);
static u16 llc_station_next_state(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
static u16 llc_exec_station_trans_actions(struct llc_station *station,
struct llc_station_state_trans *trans,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
static struct llc_station_state_trans *
llc_find_station_trans(struct llc_station *station,
struct llc_station_state_ev *ev);
struct sk_buff *skb);
static int llc_rtn_all_conns(struct llc_sap *sap);
static struct llc_station llc_main_station; /* only one of its kind */
......@@ -144,21 +144,23 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
int rc = 0;
struct llc_opt *llc = llc_sk(sk);
if (skb->cb[0] == LLC_PACKET) {
if (llc_backlog_type(skb) == LLC_PACKET) {
if (llc->state > 1) /* not closed */
rc = llc_pdu_router(llc->sap, sk, skb, LLC_TYPE_2);
else
kfree_skb(skb);
} else if (skb->cb[0] == LLC_EVENT) {
struct llc_conn_state_ev *ev =
(struct llc_conn_state_ev *)skb->data;
} else if (llc_backlog_type(skb) == LLC_EVENT) {
/* timer expiration event */
if (llc->state > 1) /* not closed */
rc = llc_conn_send_ev(sk, ev);
rc = llc_conn_send_ev(sk, skb);
else
llc_conn_free_ev(ev);
llc_conn_free_ev(skb);
kfree_skb(skb);
} else {
printk(KERN_ERR "%s: invalid skb in backlog\n", __FUNCTION__);
kfree_skb(skb);
}
return rc;
}
......@@ -232,9 +234,11 @@ void __llc_sock_free(struct sock *sk, u8 free)
/* stop all (possibly) running timers */
llc_conn_ac_stop_all_timers(sk, NULL);
/* handle return of frames on lists */
#if 0
printk(KERN_INFO "%s: unackq=%d, txq=%d\n", __FUNCTION__,
skb_queue_len(&llc->pdu_unack_q),
skb_queue_len(&sk->write_queue));
#endif
skb_queue_purge(&sk->write_queue);
skb_queue_purge(&llc->pdu_unack_q);
if (free)
......@@ -315,35 +319,18 @@ struct llc_station *llc_station_get(void)
return &llc_main_station;
}
/**
* llc_station_alloc_ev - allocates an event
* @station: Address of the station
*
* Allocates an event in this station. Returns the allocated event on
* success, %NULL otherwise.
*/
struct llc_station_state_ev *llc_station_alloc_ev(struct llc_station *station)
{
struct llc_station_state_ev *ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
if (ev)
memset(ev, 0, sizeof(*ev));
return ev;
}
/**
* llc_station_send_ev: queue event and try to process queue.
* @station: Address of the station
* @ev: Address of the event
* @skb: Address of the event
*
* Queues an event (on the station event queue) for handling by the
* station state machine and attempts to process any queued-up events.
*/
void llc_station_send_ev(struct llc_station *station,
struct llc_station_state_ev *ev)
void llc_station_send_ev(struct llc_station *station, struct sk_buff *skb)
{
spin_lock_bh(&station->ev_q.lock);
list_add_tail(&ev->node, &station->ev_q.list);
skb_queue_tail(&station->ev_q.list, skb);
llc_station_service_events(station);
spin_unlock_bh(&station->ev_q.lock);
}
......@@ -384,18 +371,17 @@ static void llc_station_send_pdus(struct llc_station *station)
/**
* llc_station_free_ev - frees an event
* @station: Address of the station
* @event: Address of the event
* @skb: Address of the event
*
* Frees an event.
*/
static void llc_station_free_ev(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
struct sk_buff *skb = ev->data.pdu.skb;
struct llc_station_state_ev *ev = llc_station_ev(skb);
if (ev->type == LLC_STATION_EV_TYPE_PDU)
kfree_skb(skb);
kfree(ev);
}
/**
......@@ -412,39 +398,35 @@ static void llc_station_free_ev(struct llc_station *station,
*/
static void llc_station_service_events(struct llc_station *station)
{
struct llc_station_state_ev *ev;
struct list_head *entry, *tmp;
struct sk_buff *skb;
list_for_each_safe(entry, tmp, &station->ev_q.list) {
ev = list_entry(entry, struct llc_station_state_ev, node);
list_del(&ev->node);
llc_station_next_state(station, ev);
}
while ((skb = skb_dequeue(&station->ev_q.list)) != NULL)
llc_station_next_state(station, skb);
}
/**
* llc_station_next_state - processes event and goes to the next state
* @station: Address of the station
* @ev: Address of the event
* @skb: Address of the event
*
* Processes an event, executes any transitions related to that event and
* updates the state of the station.
*/
static u16 llc_station_next_state(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
u16 rc = 1;
struct llc_station_state_trans *trans;
if (station->state > LLC_NBR_STATION_STATES)
goto out;
trans = llc_find_station_trans(station, ev);
trans = llc_find_station_trans(station, skb);
if (trans) {
/* got the state to which we next transition; perform the
* actions associated with this transition before actually
* transitioning to the next state
*/
rc = llc_exec_station_trans_actions(station, trans, ev);
rc = llc_exec_station_trans_actions(station, trans, skb);
if (!rc)
/* transition station to next state if all actions
* execute successfully; done; wait for next event
......@@ -456,14 +438,14 @@ static u16 llc_station_next_state(struct llc_station *station,
*/
rc = 0;
out:
llc_station_free_ev(station, ev);
llc_station_free_ev(station, skb);
return rc;
}
/**
* llc_find_station_trans - finds transition for this event
* @station: Address of the station
* @ev: Address of the event
* @skb: Address of the event
*
* Search thru events of the current state of the station until list
* exhausted or it's obvious that the event is not valid for the current
......@@ -471,7 +453,7 @@ static u16 llc_station_next_state(struct llc_station *station,
*/
static struct llc_station_state_trans *
llc_find_station_trans(struct llc_station *station,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
int i = 0;
struct llc_station_state_trans *rc = NULL;
......@@ -480,7 +462,7 @@ static struct llc_station_state_trans *
&llc_station_state_table[station->state - 1];
for (next_trans = curr_state->transitions; next_trans[i]->ev; i++)
if (!next_trans[i]->ev(station, ev)) {
if (!next_trans[i]->ev(station, skb)) {
rc = next_trans[i];
break;
}
......@@ -491,21 +473,20 @@ static struct llc_station_state_trans *
* llc_exec_station_trans_actions - executes actions for transition
* @station: Address of the station
* @trans: Address of the transition
* @ev: Address of the event that caused the transition
* @skb: Address of the event that caused the transition
*
* Executes actions of a transition of the station state machine. Returns
* 0 if all actions complete successfully, nonzero otherwise.
*/
static u16 llc_exec_station_trans_actions(struct llc_station *station,
struct llc_station_state_trans *trans,
struct llc_station_state_ev *ev)
struct sk_buff *skb)
{
u16 rc = 0;
llc_station_action_t *next_action;
llc_station_action_t *next_action = trans->ev_actions;
for (next_action = trans->ev_actions;
next_action && *next_action; next_action++)
if ((*next_action)(station, ev))
for (; next_action && *next_action; next_action++)
if ((*next_action)(station, skb))
rc = 1;
return rc;
}
......@@ -595,21 +576,24 @@ static char llc_error_msg[] __initdata =
static int __init llc_init(void)
{
u16 rc = 0;
struct sk_buff *skb;
struct llc_station_state_ev *ev;
printk(llc_banner);
INIT_LIST_HEAD(&llc_main_station.ev_q.list);
spin_lock_init(&llc_main_station.ev_q.lock);
INIT_LIST_HEAD(&llc_main_station.sap_list.list);
spin_lock_init(&llc_main_station.sap_list.lock);
skb_queue_head_init(&llc_main_station.mac_pdu_q);
ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
if (!ev)
skb_queue_head_init(&llc_main_station.ev_q.list);
spin_lock_init(&llc_main_station.ev_q.lock);
skb = alloc_skb(1, GFP_ATOMIC);
if (!skb)
goto err;
llc_build_offset_table();
ev = llc_station_ev(skb);
memset(ev, 0, sizeof(*ev));
if(dev_base->next)
memcpy(llc_main_station.mac_sa, dev_base->next->dev_addr, ETH_ALEN);
if (dev_base->next)
memcpy(llc_main_station.mac_sa,
dev_base->next->dev_addr, ETH_ALEN);
else
memset(llc_main_station.mac_sa, 0, ETH_ALEN);
llc_main_station.ack_timer.expires = jiffies + 3 * HZ;
......@@ -617,7 +601,7 @@ static int __init llc_init(void)
llc_main_station.state = LLC_STATION_STATE_DOWN;
ev->type = LLC_STATION_EV_TYPE_SIMPLE;
ev->data.a.ev = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK;
rc = llc_station_next_state(&llc_main_station, ev);
rc = llc_station_next_state(&llc_main_station, skb);
proc_net_create("802.2", 0, llc_proc_get_info);
llc_ui_init();
dev_add_pack(&llc_packet_type);
......
......@@ -28,32 +28,31 @@
/**
* llc_sap_action_unit_data_ind - forward UI PDU to network layer
* @sap: SAP
* @ev: the event to forward
* @skb: the event to forward
*
* Received a UI PDU from MAC layer; forward to network layer as a
* UNITDATA INDICATION; verify our event is the kind we expect
*/
int llc_sap_action_unitdata_ind(struct llc_sap *sap,
struct llc_sap_state_ev *ev)
int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb)
{
llc_sap_rtn_pdu(sap, ev->data.pdu.skb, ev);
llc_sap_rtn_pdu(sap, skb);
return 0;
}
/**
* llc_sap_action_send_ui - sends UI PDU resp to UNITDATA REQ to MAC layer
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Sends a UI PDU to the MAC layer in response to a UNITDATA REQUEST
* primitive from the network layer. Verifies event is a primitive type of
* event. Verify the primitive is a UNITDATA REQUEST.
*/
int llc_sap_action_send_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_prim_if_block *prim = ev->data.prim.data;
struct llc_prim_unit_data *prim_data = &prim->data->udata;
struct sk_buff *skb = prim->data->udata.skb;
int rc;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, prim_data->saddr.lsap,
......@@ -71,17 +70,17 @@ int llc_sap_action_send_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev)
/**
* llc_sap_action_send_xid_c - send XID PDU as response to XID REQ
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Send a XID command PDU to MAC layer in response to a XID REQUEST
* primitive from the network layer. Verify event is a primitive type
* event. Verify the primitive is a XID REQUEST.
*/
int llc_sap_action_send_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_prim_if_block *prim = ev->data.prim.data;
struct llc_prim_xid *prim_data = &prim->data->xid;
struct sk_buff *skb = prim_data->skb;
int rc;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, prim_data->saddr.lsap,
......@@ -99,33 +98,32 @@ int llc_sap_action_send_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
/**
* llc_sap_action_send_xid_r - send XID PDU resp to MAC for received XID
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Send XID response PDU to MAC in response to an earlier received XID
* command PDU. Verify event is a PDU type event
*/
int llc_sap_action_send_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)
{
u8 mac_da[ETH_ALEN], mac_sa[ETH_ALEN], dsap;
int rc = 1;
struct sk_buff *ev_skb = ev->data.pdu.skb;
struct sk_buff *skb;
struct sk_buff *nskb;
llc_pdu_decode_sa(ev_skb, mac_da);
llc_pdu_decode_da(ev_skb, mac_sa);
llc_pdu_decode_ssap(ev_skb, &dsap);
skb = llc_alloc_frame();
if (!skb)
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_da(skb, mac_sa);
llc_pdu_decode_ssap(skb, &dsap);
nskb = llc_alloc_frame();
if (!nskb)
goto out;
skb->dev = ev_skb->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
nskb->dev = skb->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
LLC_PDU_RSP);
rc = llc_pdu_init_as_xid_rsp(skb, LLC_XID_NULL_CLASS_2, 0);
rc = llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0);
if (rc)
goto out;
rc = lan_hdrs_init(skb, mac_sa, mac_da);
rc = lan_hdrs_init(nskb, mac_sa, mac_da);
if (!rc)
llc_sap_send_pdu(sap, skb);
llc_sap_send_pdu(sap, nskb);
out:
return rc;
}
......@@ -133,17 +131,17 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
/**
* llc_sap_action_send_test_c - send TEST PDU to MAC in resp to TEST REQ
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Send a TEST command PDU to the MAC layer in response to a TEST REQUEST
* primitive from the network layer. Verify event is a primitive type
* event; verify the primitive is a TEST REQUEST.
*/
int llc_sap_action_send_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_prim_if_block *prim = ev->data.prim.data;
struct llc_prim_test *prim_data = &prim->data->test;
struct sk_buff *skb = prim_data->skb;
int rc;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, prim_data->saddr.lsap,
......@@ -158,28 +156,27 @@ int llc_sap_action_send_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
return rc;
}
int llc_sap_action_send_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
{
u8 mac_da[ETH_ALEN], mac_sa[ETH_ALEN], dsap;
struct sk_buff *nskb;
int rc = 1;
struct sk_buff *ev_skb = ev->data.pdu.skb;
struct sk_buff *skb;
llc_pdu_decode_sa(ev_skb, mac_da);
llc_pdu_decode_da(ev_skb, mac_sa);
llc_pdu_decode_ssap(ev_skb, &dsap);
skb = llc_alloc_frame();
if (!skb)
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_da(skb, mac_sa);
llc_pdu_decode_ssap(skb, &dsap);
nskb = llc_alloc_frame();
if (!nskb)
goto out;
skb->dev = ev_skb->dev;
llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
nskb->dev = skb->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
LLC_PDU_RSP);
rc = llc_pdu_init_as_test_rsp(skb, ev_skb);
rc = llc_pdu_init_as_test_rsp(nskb, skb);
if (rc)
goto out;
rc = lan_hdrs_init(skb, mac_sa, mac_da);
rc = lan_hdrs_init(nskb, mac_sa, mac_da);
if (!rc)
llc_sap_send_pdu(sap, skb);
llc_sap_send_pdu(sap, nskb);
out:
return rc;
}
......@@ -187,13 +184,12 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
/**
* llc_sap_action_report_status - report data link status to layer mgmt
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Report data link status to layer management. Verify our event is the
* kind we expect.
*/
int llc_sap_action_report_status(struct llc_sap *sap,
struct llc_sap_state_ev *ev)
int llc_sap_action_report_status(struct llc_sap *sap, struct sk_buff *skb)
{
return 0;
}
......@@ -201,27 +197,27 @@ int llc_sap_action_report_status(struct llc_sap *sap,
/**
* llc_sap_action_xid_ind - send XID PDU resp to net layer via XID IND
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Send a XID response PDU to the network layer via a XID INDICATION
* primitive.
*/
int llc_sap_action_xid_ind(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_xid_ind(struct llc_sap *sap, struct sk_buff *skb)
{
llc_sap_rtn_pdu(sap, ev->data.pdu.skb, ev);
llc_sap_rtn_pdu(sap, skb);
return 0;
}
/**
* llc_sap_action_test_ind - send TEST PDU to net layer via TEST IND
* @sap: SAP
* @ev: the event to send
* @skb: the event to send
*
* Send a TEST response PDU to the network layer via a TEST INDICATION
* primitive. Verify our event is a PDU type event.
*/
int llc_sap_action_test_ind(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_action_test_ind(struct llc_sap *sap, struct sk_buff *skb)
{
llc_sap_rtn_pdu(sap, ev->data.pdu.skb, ev);
llc_sap_rtn_pdu(sap, skb);
return 0;
}
......@@ -20,82 +20,96 @@
#include <net/llc_s_ev.h>
#include <net/llc_pdu.h>
int llc_sap_ev_activation_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_activation_req(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
return ev->type == LLC_SAP_EV_TYPE_SIMPLE &&
ev->data.a.ev == LLC_SAP_EV_ACTIVATION_REQ ? 0 : 1;
}
int llc_sap_ev_rx_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_ui(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_UI ? 0 : 1;
}
int llc_sap_ev_unitdata_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_unitdata_req(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
return ev->type == LLC_SAP_EV_TYPE_PRIM &&
ev->data.prim.prim == LLC_DATAUNIT_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_sap_ev_xid_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_xid_req(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
return ev->type == LLC_SAP_EV_TYPE_PRIM &&
ev->data.prim.prim == LLC_XID_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1;
}
int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1;
}
int llc_sap_ev_test_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_test_req(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
return ev->type == LLC_SAP_EV_TYPE_PRIM &&
ev->data.prim.prim == LLC_TEST_PRIM &&
ev->data.prim.type == LLC_PRIM_TYPE_REQ ? 0 : 1;
}
int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1;
}
int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1;
}
int llc_sap_ev_deactivation_req(struct llc_sap *sap,
struct llc_sap_state_ev *ev)
int llc_sap_ev_deactivation_req(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
return ev->type == LLC_SAP_EV_TYPE_SIMPLE &&
ev->data.a.ev == LLC_SAP_EV_DEACTIVATION_REQ ? 0 : 1;
}
......@@ -24,7 +24,7 @@
* last entry for this state
* all members are zeros, .bss zeroes it
*/
static struct llc_sap_state_trans llc_sap_state_trans_n;
static struct llc_sap_state_trans llc_sap_state_trans_end;
/* state LLC_SAP_STATE_INACTIVE transition for
* LLC_SAP_EV_ACTIVATION_REQ event
......@@ -43,7 +43,7 @@ static struct llc_sap_state_trans llc_sap_inactive_state_trans_1 = {
/* array of pointers; one to each transition */
static struct llc_sap_state_trans *llc_sap_inactive_state_transitions[] = {
[0] = &llc_sap_inactive_state_trans_1,
[1] = &llc_sap_state_trans_n,
[1] = &llc_sap_state_trans_end,
};
/* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_UI event */
......@@ -167,16 +167,16 @@ static struct llc_sap_state_trans *llc_sap_active_state_transitions[] = {
[6] = &llc_sap_active_state_trans_7,
[7] = &llc_sap_active_state_trans_8,
[8] = &llc_sap_active_state_trans_9,
[9] = &llc_sap_state_trans_n,
[9] = &llc_sap_state_trans_end,
};
/* SAP state transition table */
struct llc_sap_state llc_sap_state_table[] = {
{
struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES] = {
[LLC_SAP_STATE_INACTIVE - 1] = {
.curr_state = LLC_SAP_STATE_INACTIVE,
.transitions = llc_sap_inactive_state_transitions,
},
{
[LLC_SAP_STATE_ACTIVE - 1] = {
.curr_state = LLC_SAP_STATE_ACTIVE,
.transitions = llc_sap_active_state_transitions,
},
......
......@@ -23,13 +23,13 @@
#include <net/llc_pdu.h>
#include <linux/if_tr.h>
static void llc_sap_free_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev);
static int llc_sap_next_state(struct llc_sap *sap, struct llc_sap_state_ev *ev);
static void llc_sap_free_ev(struct llc_sap *sap, struct sk_buff *skb);
static int llc_sap_next_state(struct llc_sap *sap, struct sk_buff *skb);
static int llc_exec_sap_trans_actions(struct llc_sap *sap,
struct llc_sap_state_trans *trans,
struct llc_sap_state_ev *ev);
struct sk_buff *skb);
static struct llc_sap_state_trans *llc_find_sap_trans(struct llc_sap *sap,
struct llc_sap_state_ev *ev);
struct sk_buff *skb);
/**
* llc_sap_assign_sock - adds a connection to a SAP
......@@ -63,50 +63,35 @@ void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk)
spin_unlock_bh(&sap->sk_list.lock);
}
/**
* llc_sap_alloc_ev - allocates sap event
* @sap: pointer to SAP
* @ev: allocated event (output argument)
*
* Returns the allocated sap event or %NULL when out of memory.
*/
struct llc_sap_state_ev *llc_sap_alloc_ev(struct llc_sap *sap)
{
struct llc_sap_state_ev *ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
if (ev)
memset(ev, 0, sizeof(*ev));
return ev;
}
/**
* llc_sap_send_ev - sends event to SAP state machine
* @sap: pointer to SAP
* @ev: pointer to occurred event
* @skb: pointer to occurred event
*
* After executing actions of the event, upper layer will be indicated
* if needed(on receiving an UI frame).
*/
void llc_sap_send_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
void llc_sap_send_ev(struct llc_sap *sap, struct sk_buff *skb)
{
llc_sap_next_state(sap, ev);
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
llc_sap_next_state(sap, skb);
if (ev->ind_cfm_flag == LLC_IND) {
skb_get(ev->data.pdu.skb);
skb_get(skb);
sap->ind(ev->prim);
}
llc_sap_free_ev(sap, ev);
llc_sap_free_ev(sap, skb);
}
/**
* llc_sap_rtn_pdu - Informs upper layer on rx of an UI, XID or TEST pdu.
* @sap: pointer to SAP
* @skb: received pdu
* @ev: pointer to occurred event
*/
void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
struct llc_sap_state_ev *ev)
void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_pdu_un *pdu;
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
u8 lfb;
......@@ -160,37 +145,38 @@ void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb)
/**
* llc_sap_free_ev - frees an sap event
* @sap: pointer to SAP
* @ev: released event
* @skb: released event
*/
static void llc_sap_free_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
static void llc_sap_free_ev(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
if (ev->type == LLC_SAP_EV_TYPE_PDU)
kfree_skb(ev->data.pdu.skb);
kfree(ev);
kfree_skb(skb);
}
/**
* llc_sap_next_state - finds transition, execs actions & change SAP state
* @sap: pointer to SAP
* @ev: happened event
* @skb: happened event
*
* This function finds transition that matches with happened event, then
* executes related actions and finally changes state of SAP. It returns
* 0 on success and 1 for failure.
*/
static int llc_sap_next_state(struct llc_sap *sap, struct llc_sap_state_ev *ev)
static int llc_sap_next_state(struct llc_sap *sap, struct sk_buff *skb)
{
int rc = 1;
struct llc_sap_state_trans *trans;
if (sap->state <= LLC_NBR_SAP_STATES) {
trans = llc_find_sap_trans(sap, ev);
if (sap->state <= LLC_NR_SAP_STATES) {
trans = llc_find_sap_trans(sap, skb);
if (trans) {
/* got the state to which we next transition; perform
* the actions associated with this transition before
* actually transitioning to the next state
*/
rc = llc_exec_sap_trans_actions(sap, trans, ev);
rc = llc_exec_sap_trans_actions(sap, trans, skb);
if (!rc)
/* transition SAP to next state if all actions
* execute successfully
......@@ -204,14 +190,14 @@ static int llc_sap_next_state(struct llc_sap *sap, struct llc_sap_state_ev *ev)
/**
* llc_find_sap_trans - finds transition for event
* @sap: pointer to SAP
* @ev: happened event
* @skb: happened event
*
* This function finds transition that matches with happened event.
* Returns the pointer to found transition on success or %NULL for
* failure.
*/
static struct llc_sap_state_trans *llc_find_sap_trans(struct llc_sap *sap,
struct llc_sap_state_ev* ev)
struct sk_buff* skb)
{
int i = 0;
struct llc_sap_state_trans *rc = NULL;
......@@ -221,7 +207,7 @@ static struct llc_sap_state_trans *llc_find_sap_trans(struct llc_sap *sap,
* its obvious the event is not valid for the current state
*/
for (next_trans = curr_state->transitions; next_trans [i]->ev; i++)
if (!next_trans[i]->ev(sap, ev)) {
if (!next_trans[i]->ev(sap, skb)) {
/* got event match; return it */
rc = next_trans[i];
break;
......@@ -233,21 +219,20 @@ static struct llc_sap_state_trans *llc_find_sap_trans(struct llc_sap *sap,
* llc_exec_sap_trans_actions - execute actions related to event
* @sap: pointer to SAP
* @trans: pointer to transition that it's actions must be performed
* @ev: happened event.
* @skb: happened event.
*
* This function executes actions that is related to happened event.
* Returns 0 for success and 1 for failure of at least one action.
*/
static int llc_exec_sap_trans_actions(struct llc_sap *sap,
struct llc_sap_state_trans *trans,
struct llc_sap_state_ev *ev)
struct sk_buff *skb)
{
int rc = 0;
llc_sap_action_t *next_action;
llc_sap_action_t *next_action = trans->ev_actions;
for (next_action = trans->ev_actions;
next_action && *next_action; next_action++)
if ((*next_action)(sap, ev))
for (; next_action && *next_action; next_action++)
if ((*next_action)(sap, skb))
rc = 1;
return rc;
}
......@@ -1629,6 +1629,13 @@ static int llc_ui_confirm(struct llc_prim_if_block *prim)
}
#ifdef CONFIG_PROC_FS
#define MAC_FORMATTED_SIZE 17
static void llc_ui_format_mac(char *bf, unsigned char *mac)
{
sprintf(bf, "%02X:%02X:%02X:%02X:%02X:%02X",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
/**
* llc_ui_get_info - return info to procfs
* @buffer: where to put the formatted output
......@@ -1656,41 +1663,25 @@ static int llc_ui_get_info(char *buffer, char **start, off_t offset, int length)
if (llc_ui->sap) {
if (llc_ui->dev &&
llc_ui_mac_null(llc_ui->addr.sllc_mmac))
len += sprintf(buffer + len,
"%02X:%02X:%02X:%02X:%02X:%02X",
llc_ui->dev->dev_addr[0],
llc_ui->dev->dev_addr[1],
llc_ui->dev->dev_addr[2],
llc_ui->dev->dev_addr[3],
llc_ui->dev->dev_addr[4],
llc_ui->dev->dev_addr[5]);
llc_ui_format_mac(buffer + len,
llc_ui->dev->dev_addr);
else {
if (!llc_ui_mac_null(llc_ui->addr.sllc_mmac))
len += sprintf(buffer + len,
"%02X:%02X:%02X:%02X:%02X:%02X",
llc_ui->addr.sllc_mmac[0],
llc_ui->addr.sllc_mmac[1],
llc_ui->addr.sllc_mmac[2],
llc_ui->addr.sllc_mmac[3],
llc_ui->addr.sllc_mmac[4],
llc_ui->addr.sllc_mmac[5]);
llc_ui_format_mac(buffer + len,
llc_ui->addr.sllc_mmac);
else
len += sprintf(buffer + len,
sprintf(buffer + len,
"00:00:00:00:00:00");
}
len += MAC_FORMATTED_SIZE;
len += sprintf(buffer + len, "@%02X ",
llc_ui->sap->laddr.lsap);
} else
len += sprintf(buffer + len, "00:00:00:00:00:00@00 ");
llc_ui_format_mac(buffer + len, llc_ui->addr.sllc_dmac);
len += MAC_FORMATTED_SIZE;
len += sprintf(buffer + len,
"%02X:%02X:%02X:%02X:%02X:%02X@%02X "
"%08X:%08X %02X %-3d ",
llc_ui->addr.sllc_dmac[0],
llc_ui->addr.sllc_dmac[1],
llc_ui->addr.sllc_dmac[2],
llc_ui->addr.sllc_dmac[3],
llc_ui->addr.sllc_dmac[4],
llc_ui->addr.sllc_dmac[5],
"@%02X %08d:%08d %02d %-3d ",
llc_ui->addr.sllc_dsap,
atomic_read(&s->wmem_alloc),
atomic_read(&s->rmem_alloc), s->state,
......
......@@ -24,7 +24,7 @@
* last entry for this state
* all members are zeros, .bss zeroes it
*/
static struct llc_station_state_trans llc_stat_state_trans_n;
static struct llc_station_state_trans llc_stat_state_trans_end;
/* DOWN STATE transitions */
......@@ -59,7 +59,7 @@ static struct llc_station_state_trans llc_stat_down_state_trans_2 = {
static struct llc_station_state_trans *llc_stat_dwn_state_trans[] = {
[0] = &llc_stat_down_state_trans_1,
[1] = &llc_stat_down_state_trans_2,
[2] = &llc_stat_state_trans_n,
[2] = &llc_stat_state_trans_end,
};
/* UP STATE transitions */
......@@ -104,7 +104,7 @@ static struct llc_station_state_trans *llc_stat_up_state_trans [] = {
[0] = &llc_stat_up_state_trans_1,
[1] = &llc_stat_up_state_trans_2,
[2] = &llc_stat_up_state_trans_3,
[3] = &llc_stat_state_trans_n,
[3] = &llc_stat_state_trans_end,
};
/* DUP ADDR CHK STATE transitions */
......@@ -162,7 +162,7 @@ static llc_station_action_t llc_stat_dupaddr_state_actions_4[] = {
static struct llc_station_state_trans llc_stat_dupaddr_state_trans_4 = {
.ev = llc_stat_ev_ack_tmr_exp_lt_retry_cnt_max_retry,
.next_state = LLC_STATION_STATE_DUP_ADDR_CHK,
.ev_actions = llc_stat_dupaddr_state_actions_4
.ev_actions = llc_stat_dupaddr_state_actions_4,
};
/* state transition for LLC_STATION_EV_ACK_TMR_EXP_EQ_RETRY_CNT_MAX_RETRY
......@@ -199,20 +199,20 @@ static struct llc_station_state_trans *llc_stat_dupaddr_state_trans[] = {
[3] = &llc_stat_dupaddr_state_trans_1, /* Receive frame */
[4] = &llc_stat_dupaddr_state_trans_2,
[5] = &llc_stat_dupaddr_state_trans_3,
[6] = &llc_stat_state_trans_n
[6] = &llc_stat_state_trans_end,
};
struct llc_station_state llc_station_state_table[LLC_NBR_STATION_STATES] = {
{
[LLC_STATION_STATE_DOWN - 1] = {
.curr_state = LLC_STATION_STATE_DOWN,
.transitions = llc_stat_dwn_state_trans,
},
{
[LLC_STATION_STATE_DUP_ADDR_CHK - 1] = {
.curr_state = LLC_STATION_STATE_DUP_ADDR_CHK,
.transitions = llc_stat_dupaddr_state_trans,
},
{
[LLC_STATION_STATE_UP - 1] = {
.curr_state = LLC_STATION_STATE_UP,
.transitions = llc_stat_up_state_trans,
}
},
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment