Commit eb7a418e 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 64882de1 9a1d0278
......@@ -29,8 +29,6 @@
#define LLC_GLOBAL_DEFAULT_MAX_NBR_SAPS 4
#define LLC_GLOBAL_DEFAULT_MAX_NBR_CONNS 64
extern struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
/* LLC station component (SAP and connection resource manager) */
/* Station component; one per adapter */
struct llc_station {
......
......@@ -198,6 +198,11 @@ struct llc_pdu_sn {
u8 ctrl_2;
};
static __inline__ struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
{
return (struct llc_pdu_sn *)skb->nh.raw;
}
/* Un-numbered PDU format (3 bytes in length) */
struct llc_pdu_un {
u8 dsap;
......@@ -205,6 +210,16 @@ struct llc_pdu_un {
u8 ctrl_1;
};
static __inline__ struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
{
return (struct llc_pdu_un *)skb->nh.raw;
}
static __inline__ void *llc_set_pdu_hdr(struct sk_buff *skb, void *ptr)
{
return skb->nh.raw = ptr;
}
/* LLC Type 1 XID command/response information fields format */
struct llc_xid_info {
u8 fmt_id; /* always 0x18 for LLC */
......
......@@ -12,23 +12,38 @@
* See the GNU General Public License for more details.
*/
#include <linux/skbuff.h>
/* Defines the SAP component */
/**
* struct llc_sap - Defines the SAP component
*
* @p_bit - only lowest-order bit used
* @f_bit - only lowest-order bit used
* @req - provided by LLC layer
* @resp - provided by LLC layer
* @ind - provided by network layer
* @conf - provided by network layer
* @laddr - SAP value in this 'lsap'
* @node - entry in station sap_list
* @sk_list - LLC sockets this one manages
* @mac_pdu_q - PDUs ready to send to MAC
*/
struct llc_sap {
u8 state;
struct llc_station *parent_station;
u8 p_bit; /* only lowest-order bit used */
u8 f_bit; /* only lowest-order bit used */
llc_prim_call_t req; /* provided by LLC layer */
llc_prim_call_t resp; /* provided by LLC layer */
llc_prim_call_t ind; /* provided by network layer */
llc_prim_call_t conf; /* provided by network layer */
struct llc_addr laddr; /* SAP value in this 'lsap' */
struct list_head node; /* entry in station sap_list */
struct llc_station *parent_station;
u8 state;
u8 p_bit;
u8 f_bit;
llc_prim_call_t req;
llc_prim_call_t resp;
llc_prim_call_t ind;
llc_prim_call_t conf;
struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
union llc_u_prim_data llc_ind_data_prim, llc_cfm_data_prim;
struct llc_addr laddr;
struct list_head node;
struct {
spinlock_t lock;
struct list_head list;
} sk_list; /* LLC sockets this one manages */
struct sk_buff_head mac_pdu_q; /* PDUs ready to send to MAC */
} sk_list;
struct sk_buff_head mac_pdu_q;
};
struct llc_sap_state_ev;
......
......@@ -61,15 +61,18 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{
int rc = 1;
u8 dsap;
struct sk_buff *skb = ev->data.pdu.skb;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
struct llc_sap *sap;
struct llc_opt *llc = llc_sk(sk);
llc_pdu_decode_dsap(skb, &prim_data->conn.daddr.lsap);
sap = llc_sap_find(prim_data->conn.daddr.lsap);
llc_pdu_decode_dsap(skb, &dsap);
sap = llc_sap_find(dsap);
if (sap) {
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);
prim_data->conn.daddr.lsap = dsap;
llc_pdu_decode_sa(skb, llc->daddr.mac);
llc_pdu_decode_da(skb, llc->laddr.mac);
llc->dev = skb->dev;
......@@ -90,14 +93,11 @@ int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct sk_buff *skb = ev->data.pdu.skb;
/* FIXME: wtf, this is global, so the whole thing is really
* non reentrant...
*/
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->conn.sk = sk;
prim_data->conn.pri = 0;
......@@ -118,17 +118,19 @@ int llc_conn_ac_conn_confirm(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)
{
struct llc_prim_if_block *prim = &llc_cfm_prim;
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->data.sk = sk;
prim_data->data.pri = 0;
prim_data->data.link = llc_sk(sk)->link;
prim_data->data.link = llc->link;
prim_data->data.status = LLC_STATUS_RECEIVED;
prim_data->data.skb = NULL;
prim->data = prim_data;
prim->prim = LLC_DATA_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
ev->cfm_prim = prim;
return 0;
......@@ -144,12 +146,9 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{
u8 reason = 0;
int rc = 1;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
if (ev->type == LLC_CONN_EV_TYPE_PDU) {
struct llc_pdu_un *pdu =
(struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -170,12 +169,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
rc = 1;
}
if (!rc) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->disc.sk = sk;
prim_data->disc.reason = reason;
prim_data->disc.link = llc_sk(sk)->link;
prim_data->disc.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_DISC_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = llc->sap;
ev->flag = 1;
ev->ind_prim = prim;
}
......@@ -184,15 +188,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_disc_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->disc.sk = sk;
prim_data->disc.reason = ev->status;
prim_data->disc.link = llc_sk(sk)->link;
prim_data->disc.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_DISC_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
ev->cfm_prim = prim;
return 0;
......@@ -202,9 +208,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{
u8 reason = 0;
int rc = 1;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_opt *llc = llc_sk(sk);
switch (ev->type) {
......@@ -237,12 +241,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
break;
}
if (!rc) {
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->res.sk = sk;
prim_data->res.reason = reason;
prim_data->res.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_RESET_PRIM;
prim->sap = llc->sap;
prim->sap = sap;
ev->flag = 1;
ev->ind_prim = prim;
}
......@@ -251,14 +259,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->res.sk = sk;
prim_data->res.link = llc_sk(sk)->link;
prim_data->res.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_RESET_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
ev->cfm_prim = prim;
return 0;
......
......@@ -87,10 +87,10 @@ static u16 llc_util_nr_inside_tx_window(struct sock *sk, u8 nr)
if (!skb_queue_len(&llc->pdu_unack_q))
goto out;
skb = skb_peek(&llc->pdu_unack_q);
pdu = (struct llc_pdu_sn *)skb->nh.raw;
pdu = llc_pdu_sn_hdr(skb);
nr1 = LLC_I_GET_NS(pdu);
skb = skb_peek_tail(&llc->pdu_unack_q);
pdu = (struct llc_pdu_sn *)skb->nh.raw;
pdu = llc_pdu_sn_hdr(skb);
nr2 = LLC_I_GET_NS(pdu);
rc = !llc_circular_between(nr1, nr, (nr2 + 1) % LLC_2_SEQ_NBR_MODULO);
out:
......@@ -155,7 +155,7 @@ int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.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;
......@@ -164,7 +164,7 @@ int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk,
int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.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;
......@@ -173,7 +173,7 @@ int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk,
int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.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;
......@@ -182,7 +182,7 @@ int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk,
int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_0(pdu) &&
......@@ -192,7 +192,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk,
int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_1(pdu) &&
......@@ -202,7 +202,7 @@ 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 llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -214,7 +214,7 @@ 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 llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -226,7 +226,7 @@ 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 llc_pdu_sn * pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(ev->data.pdu.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 &&
......@@ -241,7 +241,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_0(pdu) &&
......@@ -251,7 +251,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk,
int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
!LLC_I_PF_IS_1(pdu) &&
......@@ -261,7 +261,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk,
int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_I(pdu) &&
LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
......@@ -270,7 +270,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk,
int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -282,7 +282,7 @@ 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 llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -294,7 +294,7 @@ 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 llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vr = llc_sk(sk)->vR;
u8 ns = LLC_I_GET_NS(pdu);
......@@ -305,7 +305,7 @@ 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 llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.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 &&
......@@ -320,7 +320,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
......@@ -330,7 +330,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk,
int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
......@@ -340,7 +340,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk,
int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
......@@ -350,7 +350,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk,
int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
......@@ -360,7 +360,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk,
int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.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;
......@@ -369,7 +369,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk,
int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
......@@ -379,7 +379,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk,
int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
......@@ -389,7 +389,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk,
int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
......@@ -399,7 +399,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk,
int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
......@@ -409,7 +409,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk,
int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
......@@ -419,7 +419,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk,
int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_CMD(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
......@@ -429,7 +429,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk,
int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_0(pdu) &&
......@@ -439,7 +439,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk,
int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
return !LLC_PDU_IS_RSP(pdu) && !LLC_PDU_TYPE_IS_S(pdu) &&
!LLC_S_PF_IS_1(pdu) &&
......@@ -449,7 +449,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk,
int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.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;
......@@ -458,7 +458,7 @@ int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk,
int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.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;
......@@ -468,7 +468,7 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
......@@ -484,7 +484,7 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_0(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
......@@ -506,7 +506,7 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_CMD(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu))
......@@ -526,7 +526,7 @@ int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_RSP(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu)) {
......@@ -549,7 +549,7 @@ int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_RSP(pdu)) {
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu))
......@@ -570,7 +570,7 @@ int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
int llc_conn_ev_rx_xxx_yyy(struct sock *sk, struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
if (!LLC_PDU_TYPE_IS_I(pdu) || !LLC_PDU_TYPE_IS_S(pdu))
rc = 0;
......@@ -591,7 +591,7 @@ int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vs = llc_sk(sk)->vS;
u8 nr = LLC_I_GET_NR(pdu);
......@@ -613,7 +613,7 @@ int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
struct llc_conn_state_ev *ev)
{
u16 rc = 1;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(ev->data.pdu.skb);
u8 vs = llc_sk(sk)->vS;
u8 nr = LLC_I_GET_NR(pdu);
......
......@@ -134,16 +134,18 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb)
void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb,
struct llc_conn_state_ev *ev)
{
struct llc_prim_if_block *prim = &llc_ind_prim;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->data.sk = sk;
prim_data->data.pri = 0;
prim_data->data.skb = skb;
prim_data->data.link = llc_sk(sk)->link;
prim_data->data.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_DATA_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
/* saving prepd prim in event for future use in llc_conn_send_ev */
ev->ind_prim = prim;
......
......@@ -56,7 +56,7 @@ int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */
......@@ -68,7 +68,7 @@ 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 llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */
......@@ -81,7 +81,7 @@ 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 llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */
......@@ -94,7 +94,7 @@ 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 llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */
......
......@@ -90,7 +90,7 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
if (!skb)
goto out;
fix_up_incoming_skb(skb);
pdu = (struct llc_pdu_sn *)skb->nh.raw;
pdu = llc_pdu_sn_hdr(skb);
if (!pdu->dsap) { /* NULL DSAP, refer to station */
if (llc_pdu_router(NULL, NULL, skb, 0))
goto drop;
......@@ -202,7 +202,7 @@ static void fix_up_incoming_skb(struct sk_buff *skb)
int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
struct sk_buff *skb, u8 type)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
int rc = 0;
if (!pdu->dsap) {
......
......@@ -51,8 +51,6 @@ static struct llc_station_state_trans *
static int llc_rtn_all_conns(struct llc_sap *sap);
static struct llc_station llc_main_station; /* only one of its kind */
struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
static union llc_u_prim_data llc_ind_data_prim, llc_cfm_data_prim;
/**
* llc_sap_alloc - allocates and initializes sap.
......@@ -70,6 +68,8 @@ struct llc_sap *llc_sap_alloc(void)
spin_lock_init(&sap->sk_list.lock);
INIT_LIST_HEAD(&sap->sk_list.list);
skb_queue_head_init(&sap->mac_pdu_q);
sap->llc_ind_prim.data = &sap->llc_ind_data_prim;
sap->llc_cfm_prim.data = &sap->llc_cfm_data_prim;
}
return sap;
}
......@@ -618,8 +618,6 @@ static int __init llc_init(void)
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);
llc_ind_prim.data = &llc_ind_data_prim;
llc_cfm_prim.data = &llc_cfm_data_prim;
proc_net_create("802.2", 0, llc_proc_get_info);
llc_ui_init();
dev_add_pack(&llc_packet_type);
......
......@@ -19,26 +19,23 @@
#include <net/llc_main.h>
static int llc_pdu_decode_pdu_type(struct sk_buff *skb, u8 *type);
static int llc_get_llc_hdr_length(u8 pdu_type);
static __inline__ int llc_get_hdr_len(u8 pdu_type);
static u8 llc_pdu_get_pf_bit(struct llc_pdu_sn *pdu);
/**
* llc_pdu_header_init - initializes pdu header
* @skb: input skb that header must be set into it.
* @pdu_type: type of PDU (U, I or S).
* @type: type of PDU (U, I or S).
* @ssap: source sap.
* @dsap: destination sap.
* @cr: command/response bit (0 or 1).
*
* This function sets DSAP, SSAP and command/Response bit in LLC header.
*/
void llc_pdu_header_init(struct sk_buff *skb, u8 pdu_type, u8 ssap,
u8 dsap, u8 cr)
void llc_pdu_header_init(struct sk_buff *skb, u8 type, u8 ssap, u8 dsap, u8 cr)
{
struct llc_pdu_un *pdu;
skb->nh.raw = skb_push(skb, llc_get_llc_hdr_length(pdu_type));
pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu =
llc_set_pdu_hdr(skb, skb_push(skb, llc_get_hdr_len(type)));
pdu->dsap = dsap;
pdu->ssap = ssap;
pdu->ssap |= cr;
......@@ -46,7 +43,7 @@ void llc_pdu_header_init(struct sk_buff *skb, u8 pdu_type, u8 ssap,
void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 pdu_type)
{
((struct llc_pdu_un *)skb->nh.raw)->ssap |= pdu_type;
llc_pdu_un_hdr(skb)->ssap |= pdu_type;
}
/**
......@@ -66,7 +63,7 @@ void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value)
if (llc_pdu_decode_pdu_type(skb, &pdu_type))
goto out;
pdu = (struct llc_pdu_sn *)skb->nh.raw;
pdu = llc_pdu_sn_hdr(skb);
switch (pdu_type) {
case LLC_PDU_TYPE_I:
......@@ -98,7 +95,7 @@ int llc_pdu_decode_pf_bit(struct sk_buff *skb, u8 *pf_bit)
if (rc)
goto out;
pdu = (struct llc_pdu_sn *)skb->nh.raw;
pdu = llc_pdu_sn_hdr(skb);
switch (pdu_type) {
case LLC_PDU_TYPE_I:
......@@ -123,8 +120,7 @@ int llc_pdu_decode_pf_bit(struct sk_buff *skb, u8 *pf_bit)
*/
int llc_pdu_decode_cr_bit(struct sk_buff *skb, u8 *cr_bit)
{
*cr_bit = ((struct llc_pdu_un *)skb->nh.raw)->ssap &
LLC_PDU_CMD_RSP_MASK;
*cr_bit = llc_pdu_un_hdr(skb)->ssap & LLC_PDU_CMD_RSP_MASK;
return 0;
}
......@@ -170,7 +166,7 @@ int llc_pdu_decode_da(struct sk_buff *skb, u8 *da)
*/
int llc_pdu_decode_dsap(struct sk_buff *skb, u8 *dsap)
{
*dsap = ((struct llc_pdu_un *)skb->nh.raw)->dsap & 0xFE;
*dsap = llc_pdu_un_hdr(skb)->dsap & 0xFE;
return 0;
}
......@@ -184,7 +180,7 @@ int llc_pdu_decode_dsap(struct sk_buff *skb, u8 *dsap)
*/
int llc_pdu_decode_ssap(struct sk_buff *skb, u8 *ssap)
{
*ssap = ((struct llc_pdu_un *)skb->nh.raw)->ssap & 0xFE;
*ssap = llc_pdu_un_hdr(skb)->ssap & 0xFE;
return 0;
}
......@@ -196,7 +192,7 @@ int llc_pdu_decode_ssap(struct sk_buff *skb, u8 *ssap)
*/
int llc_pdu_init_as_ui_cmd(struct sk_buff *skb)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_1_PDU_CMD_UI;
......@@ -214,7 +210,7 @@ int llc_pdu_init_as_xid_cmd(struct sk_buff *skb, u8 svcs_supported,
u8 rx_window)
{
struct llc_xid_info *xid_info;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_1_PDU_CMD_XID;
......@@ -235,7 +231,7 @@ int llc_pdu_init_as_xid_cmd(struct sk_buff *skb, u8 svcs_supported,
*/
int llc_pdu_init_as_test_cmd(struct sk_buff *skb)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST;
......@@ -252,7 +248,7 @@ int llc_pdu_init_as_test_cmd(struct sk_buff *skb)
*/
int llc_pdu_init_as_disc_cmd(struct sk_buff *skb, u8 p_bit)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_2_PDU_CMD_DISC;
......@@ -271,7 +267,7 @@ int llc_pdu_init_as_disc_cmd(struct sk_buff *skb, u8 p_bit)
*/
int llc_pdu_init_as_i_cmd(struct sk_buff *skb, u8 p_bit, u8 ns, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_I;
pdu->ctrl_2 = 0;
......@@ -291,7 +287,7 @@ int llc_pdu_init_as_i_cmd(struct sk_buff *skb, u8 p_bit, u8 ns, u8 nr)
*/
int llc_pdu_init_as_rej_cmd(struct sk_buff *skb, u8 p_bit, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_CMD_REJ;
......@@ -312,7 +308,7 @@ int llc_pdu_init_as_rej_cmd(struct sk_buff *skb, u8 p_bit, u8 nr)
*/
int llc_pdu_init_as_rnr_cmd(struct sk_buff *skb, u8 p_bit, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_CMD_RNR;
......@@ -333,7 +329,7 @@ int llc_pdu_init_as_rnr_cmd(struct sk_buff *skb, u8 p_bit, u8 nr)
*/
int llc_pdu_init_as_rr_cmd(struct sk_buff *skb, u8 p_bit, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_CMD_RR;
......@@ -352,7 +348,7 @@ int llc_pdu_init_as_rr_cmd(struct sk_buff *skb, u8 p_bit, u8 nr)
*/
int llc_pdu_init_as_sabme_cmd(struct sk_buff *skb, u8 p_bit)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_2_PDU_CMD_SABME;
......@@ -369,7 +365,7 @@ int llc_pdu_init_as_sabme_cmd(struct sk_buff *skb, u8 p_bit)
*/
int llc_pdu_init_as_dm_rsp(struct sk_buff *skb, u8 f_bit)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_2_PDU_RSP_DM;
......@@ -389,7 +385,7 @@ int llc_pdu_init_as_xid_rsp(struct sk_buff *skb, u8 svcs_supported,
u8 rx_window)
{
struct llc_xid_info *xid_info;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_1_PDU_CMD_XID;
......@@ -413,15 +409,16 @@ int llc_pdu_init_as_xid_rsp(struct sk_buff *skb, u8 svcs_supported,
int llc_pdu_init_as_test_rsp(struct sk_buff *skb, struct sk_buff *ev_skb)
{
int dsize;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST;
pdu->ctrl_1 |= LLC_U_PF_BIT_MASK;
if (ev_skb->protocol == ntohs(ETH_P_802_2)) {
struct llc_pdu_un *ev_pdu = llc_pdu_un_hdr(ev_skb);
dsize = ntohs(((struct ethhdr *)ev_skb->mac.raw)->h_proto) - 3;
memcpy(((u8 *)skb->nh.raw) + 3,
((u8 *)ev_skb->nh.raw) + 3, dsize);
memcpy(((u8 *)pdu) + 3, ((u8 *)ev_pdu) + 3, dsize);
skb_put(skb, dsize);
}
return 0;
......@@ -444,7 +441,7 @@ int llc_pdu_init_as_frmr_rsp(struct sk_buff *skb, struct llc_pdu_sn *prev_pdu,
struct llc_frmr_info *frmr_info;
u8 prev_pf = 0;
u8 *ctrl;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_2_PDU_RSP_FRMR;
......@@ -476,7 +473,7 @@ int llc_pdu_init_as_frmr_rsp(struct sk_buff *skb, struct llc_pdu_sn *prev_pdu,
*/
int llc_pdu_init_as_rr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_RSP_RR;
......@@ -497,7 +494,7 @@ int llc_pdu_init_as_rr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr)
*/
int llc_pdu_init_as_rej_rsp(struct sk_buff *skb, u8 f_bit, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_RSP_REJ;
......@@ -518,7 +515,7 @@ int llc_pdu_init_as_rej_rsp(struct sk_buff *skb, u8 f_bit, u8 nr)
*/
int llc_pdu_init_as_rnr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_RSP_RNR;
......@@ -538,7 +535,7 @@ int llc_pdu_init_as_rnr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr)
*/
int llc_pdu_init_as_ua_rsp(struct sk_buff *skb, u8 f_bit)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_U;
pdu->ctrl_1 |= LLC_2_PDU_RSP_UA;
......@@ -555,7 +552,7 @@ int llc_pdu_init_as_ua_rsp(struct sk_buff *skb, u8 f_bit)
*/
static int llc_pdu_decode_pdu_type(struct sk_buff *skb, u8 *type)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
if (pdu->ctrl_1 & 1) {
if ((pdu->ctrl_1 & LLC_PDU_TYPE_U) == LLC_PDU_TYPE_U)
......@@ -577,7 +574,7 @@ static int llc_pdu_decode_pdu_type(struct sk_buff *skb, u8 *type)
int llc_decode_pdu_type(struct sk_buff *skb, u8 *dest)
{
u8 type = LLC_DEST_CONN; /* I-PDU or S-PDU type */
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) != LLC_PDU_TYPE_U)
goto out;
......@@ -603,26 +600,21 @@ int llc_decode_pdu_type(struct sk_buff *skb, u8 *dest)
}
/**
* get_llc_hdr_len - designates LLC header length
* @pdu_type: type of PDU.
* llc_get_hdr_len - designates LLC header length
* @type: type of PDU.
*
* This function designates LLC header length of PDU. header length for I
* and S PDU is 4 and for U is 3 bytes. Returns the length of header.
*/
static int llc_get_llc_hdr_length(u8 pdu_type)
static __inline__ int llc_get_hdr_len(u8 type)
{
int rtn_val = 0;
static int hdr_len[] = {
[LLC_PDU_TYPE_U] = 3,
[LLC_PDU_TYPE_I] = 4,
[LLC_PDU_TYPE_S] = 4,
};
switch (pdu_type) {
case LLC_PDU_TYPE_I:
case LLC_PDU_TYPE_S:
rtn_val = 4;
break;
case LLC_PDU_TYPE_U:
rtn_val = 3;
break;
}
return rtn_val;
return hdr_len[type];
}
/**
......
......@@ -28,7 +28,7 @@ int llc_sap_ev_activation_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -52,7 +52,7 @@ int llc_sap_ev_xid_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -61,7 +61,7 @@ int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -77,7 +77,7 @@ int llc_sap_ev_test_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -86,7 +86,7 @@ int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......
......@@ -89,15 +89,10 @@ struct llc_sap_state_ev *llc_sap_alloc_ev(struct llc_sap *sap)
*/
void llc_sap_send_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_prim_if_block *prim;
u8 flag;
llc_sap_next_state(sap, ev);
flag = ev->ind_cfm_flag;
prim = ev->prim;
if (flag == LLC_IND) {
if (ev->ind_cfm_flag == LLC_IND) {
skb_get(ev->data.pdu.skb);
sap->ind(prim);
sap->ind(ev->prim);
}
llc_sap_free_ev(sap, ev);
}
......@@ -112,8 +107,8 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu;
struct llc_prim_if_block *prim = &llc_ind_prim;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
u8 lfb;
llc_pdu_decode_sa(skb, prim_data->udata.saddr.mac);
......@@ -122,7 +117,7 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
llc_pdu_decode_ssap(skb, &prim_data->udata.saddr.lsap);
prim_data->udata.pri = 0;
prim_data->udata.skb = skb;
pdu = (struct llc_pdu_un *)skb->nh.raw;
pdu = llc_pdu_un_hdr(skb);
switch (LLC_U_PDU_RSP(pdu)) {
case LLC_1_PDU_CMD_TEST:
prim->prim = LLC_TEST_PRIM;
......
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