o LLC: move llc_decode_pdu_type to llc_mac

And also rename it to llc_pdu_type and make it return the type,
this is to make llc_mac more and more autonomous of the rest of
the llc code, to the point where it will be a separate loadable
module.
parent b16e6ef4
......@@ -243,7 +243,6 @@ extern void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa);
extern void llc_pdu_decode_da(struct sk_buff *skb, u8 *ds);
extern void llc_pdu_decode_dsap(struct sk_buff *skb, u8 *dsap);
extern void llc_pdu_decode_ssap(struct sk_buff *skb, u8 *ssap);
extern void llc_decode_pdu_type(struct sk_buff *skb, u8 *destination);
extern void llc_pdu_header_init(struct sk_buff *skb, u8 pdu_type, u8 ssap,
u8 dsap, u8 cr);
extern void llc_pdu_init_as_ui_cmd(struct sk_buff *skb);
......
......@@ -52,6 +52,39 @@ static void (*llc_type_handlers[2])(struct llc_sap *sap,
[LLC_DEST_CONN - 1] = llc_conn_handler,
};
/**
* llc_pdu_type - returns which LLC component must handle for PDU
* @skb: input skb
*
* This function returns which LLC component must handle this PDU.
*/
static __inline__ int llc_pdu_type(struct sk_buff *skb)
{
int type = LLC_DEST_CONN; /* I-PDU or S-PDU type */
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) != LLC_PDU_TYPE_U)
goto out;
switch (LLC_U_PDU_CMD(pdu)) {
case LLC_1_PDU_CMD_XID:
case LLC_1_PDU_CMD_UI:
case LLC_1_PDU_CMD_TEST:
type = LLC_DEST_SAP;
break;
case LLC_2_PDU_CMD_SABME:
case LLC_2_PDU_CMD_DISC:
case LLC_2_PDU_RSP_UA:
case LLC_2_PDU_RSP_DM:
case LLC_2_PDU_RSP_FRMR:
break;
default:
type = LLC_DEST_INVALID;
break;
}
out:
return type;
}
/**
* llc_rcv - 802.2 entry point from net lower layers
* @skb: received pdu
......@@ -69,7 +102,7 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
{
struct llc_sap *sap;
struct llc_pdu_sn *pdu;
u8 dest;
int dest;
/*
* When the interface is in promisc. mode, drop all the crap that it
......@@ -104,7 +137,7 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
sap->rcv_func(skb, dev, pt);
goto out;
}
llc_decode_pdu_type(skb, &dest);
dest = llc_pdu_type(skb);
if (unlikely(!dest || !llc_type_handlers[dest - 1]))
goto drop;
llc_type_handlers[dest - 1](sap, skb);
......
......@@ -532,40 +532,6 @@ static void llc_pdu_decode_pdu_type(struct sk_buff *skb, u8 *type)
*type = LLC_PDU_TYPE_I;
}
/**
* llc_decode_pdu_type - designates component LLC must handle for PDU
* @skb: input skb
* @dest: destination component
*
* This function designates which component of LLC must handle this PDU.
*/
void 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 = llc_pdu_sn_hdr(skb);
if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) != LLC_PDU_TYPE_U)
goto out;
switch (LLC_U_PDU_CMD(pdu)) {
case LLC_1_PDU_CMD_XID:
case LLC_1_PDU_CMD_UI:
case LLC_1_PDU_CMD_TEST:
type = LLC_DEST_SAP;
break;
case LLC_2_PDU_CMD_SABME:
case LLC_2_PDU_CMD_DISC:
case LLC_2_PDU_RSP_UA:
case LLC_2_PDU_RSP_DM:
case LLC_2_PDU_RSP_FRMR:
break;
default:
type = LLC_DEST_INVALID;
break;
}
out:
*dest = type;
}
/**
* llc_get_hdr_len - designates LLC header length
* @type: type of PDU.
......
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