o LLC: create a register interface for llc_station_rcv

parent e22ab5e3
...@@ -25,4 +25,6 @@ struct sk_buff; ...@@ -25,4 +25,6 @@ struct sk_buff;
extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap, extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap,
struct sk_buff *skb)); struct sk_buff *skb));
extern void llc_remove_pack(int type); extern void llc_remove_pack(int type);
extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb));
#endif /* LLC_MAC_H */ #endif /* LLC_MAC_H */
...@@ -12,15 +12,10 @@ ...@@ -12,15 +12,10 @@
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
*/ */
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/if_tr.h>
#include <linux/rtnetlink.h>
#include <net/llc_mac.h> #include <net/llc_mac.h>
#include <net/llc_pdu.h> #include <net/llc_pdu.h>
#include <net/llc_sap.h> #include <net/llc_sap.h>
#include <net/llc_main.h> #include <net/llc_main.h>
#include <net/llc_evnt.h>
#include <linux/trdevice.h>
#if 0 #if 0
#define dprintk(args...) printk(KERN_DEBUG args) #define dprintk(args...) printk(KERN_DEBUG args)
...@@ -28,7 +23,13 @@ ...@@ -28,7 +23,13 @@
#define dprintk(args...) #define dprintk(args...)
#endif #endif
static void llc_station_rcv(struct sk_buff *skb); /*
* Packet handler for the station, registerable because in the minimal
* LLC core that is taking shape only the very minimal subset of LLC that
* is needed for things like IPX, Appletalk, etc will stay, with all the
* rest in the llc1 and llc2 modules.
*/
static void (*llc_station_handler)(struct sk_buff *skb);
/* /*
* Packet handlers for LLC_DEST_SAP and LLC_DEST_CONN. * Packet handlers for LLC_DEST_SAP and LLC_DEST_CONN.
...@@ -49,6 +50,11 @@ void llc_remove_pack(int type) ...@@ -49,6 +50,11 @@ void llc_remove_pack(int type)
llc_type_handlers[type] = NULL; llc_type_handlers[type] = NULL;
} }
void llc_set_station_handler(void (*handler)(struct sk_buff *skb))
{
llc_station_handler = handler;
}
/** /**
* llc_pdu_type - returns which LLC component must handle for PDU * llc_pdu_type - returns which LLC component must handle for PDU
* @skb: input skb * @skb: input skb
...@@ -147,11 +153,8 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -147,11 +153,8 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
if (unlikely(!llc_fixup_skb(skb))) if (unlikely(!llc_fixup_skb(skb)))
goto drop; goto drop;
pdu = llc_pdu_sn_hdr(skb); pdu = llc_pdu_sn_hdr(skb);
if (unlikely(!pdu->dsap)) { /* NULL DSAP, refer to station */ if (unlikely(!pdu->dsap)) /* NULL DSAP, refer to station */
dprintk("%s: calling llc_station_rcv!\n", __FUNCTION__); goto handle_station;
llc_station_rcv(skb);
goto out;
}
sap = llc_sap_find(pdu->dsap); sap = llc_sap_find(pdu->dsap);
if (unlikely(!sap)) {/* unknown SAP */ if (unlikely(!sap)) {/* unknown SAP */
dprintk("%s: llc_sap_find(%02X) failed!\n", __FUNCTION__, dprintk("%s: llc_sap_find(%02X) failed!\n", __FUNCTION__,
...@@ -175,22 +178,13 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -175,22 +178,13 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
drop: drop:
kfree_skb(skb); kfree_skb(skb);
goto out; goto out;
} handle_station:
if (!llc_station_handler)
/* goto drop;
* llc_station_rcv - send received pdu to the station state machine llc_station_handler(skb);
* @skb: received frame. goto out;
*
* Sends data unit to station state machine.
*/
static void llc_station_rcv(struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
ev->type = LLC_STATION_EV_TYPE_PDU;
ev->reason = 0;
llc_station_state_process(&llc_main_station, skb);
} }
EXPORT_SYMBOL(llc_add_pack); EXPORT_SYMBOL(llc_add_pack);
EXPORT_SYMBOL(llc_remove_pack); EXPORT_SYMBOL(llc_remove_pack);
EXPORT_SYMBOL(llc_set_station_handler);
...@@ -250,6 +250,21 @@ static u16 llc_exec_station_trans_actions(struct llc_station *station, ...@@ -250,6 +250,21 @@ static u16 llc_exec_station_trans_actions(struct llc_station *station,
return rc; return rc;
} }
/*
* llc_station_rcv - send received pdu to the station state machine
* @skb: received frame.
*
* Sends data unit to station state machine.
*/
static void llc_station_rcv(struct sk_buff *skb)
{
struct llc_station_state_ev *ev = llc_station_ev(skb);
ev->type = LLC_STATION_EV_TYPE_PDU;
ev->reason = 0;
llc_station_state_process(&llc_main_station, skb);
}
/** /**
* llc_alloc_frame - allocates sk_buff for frame * llc_alloc_frame - allocates sk_buff for frame
* *
...@@ -303,6 +318,7 @@ static int __init llc_init(void) ...@@ -303,6 +318,7 @@ static int __init llc_init(void)
skb = alloc_skb(0, GFP_ATOMIC); skb = alloc_skb(0, GFP_ATOMIC);
if (!skb) if (!skb)
goto err; goto err;
llc_set_station_handler(llc_station_rcv);
ev = llc_station_ev(skb); ev = llc_station_ev(skb);
memset(ev, 0, sizeof(*ev)); memset(ev, 0, sizeof(*ev));
if (dev_base->next) if (dev_base->next)
...@@ -330,6 +346,7 @@ static void __exit llc_exit(void) ...@@ -330,6 +346,7 @@ static void __exit llc_exit(void)
{ {
dev_remove_pack(&llc_packet_type); dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type); dev_remove_pack(&llc_tr_packet_type);
llc_set_station_handler(NULL);
} }
module_init(llc_init); module_init(llc_init);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <net/llc_s_ev.h> #include <net/llc_s_ev.h>
#include <net/llc_pdu.h> #include <net/llc_pdu.h>
#include <net/llc_mac.h> #include <net/llc_mac.h>
#include "llc_output.h"
/** /**
* llc_sap_action_unit_data_ind - forward UI PDU to network layer * llc_sap_action_unit_data_ind - forward UI PDU to network layer
......
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