25 #include <linux/llc.h>
26 #include <linux/slab.h>
28 static int llc_mac_header_len(
unsigned short devtype)
33 return sizeof(
struct ethhdr);
53 hlen += llc_mac_header_len(dev->
type);
57 skb_reset_mac_header(skb);
58 skb_reserve(skb, hlen);
59 skb_reset_network_header(skb);
60 skb_reset_transport_header(skb);
64 skb_set_owner_w(skb, sk);
76 memset(addr, 0,
sizeof(*addr));
82 llc_pdu_decode_sa(skb, addr->
sllc_mac);
83 llc_pdu_decode_ssap(skb, &addr->
sllc_sap);
127 for (next_trans = curr_state->
transitions; next_trans[i]->
ev; i++)
128 if (!next_trans[i]->ev(sap, skb)) {
144 static int llc_exec_sap_trans_actions(
struct llc_sap *sap,
151 for (; next_action && *next_action; next_action++)
152 if ((*next_action)(sap, skb))
166 static int llc_sap_next_state(
struct llc_sap *sap,
struct sk_buff *skb)
173 trans = llc_find_sap_trans(sap, skb);
181 rc = llc_exec_sap_trans_actions(sap, trans, skb);
201 static void llc_sap_state_process(
struct llc_sap *sap,
struct sk_buff *skb)
212 llc_sap_next_state(sap, skb);
250 llc_sap_state_process(sap, skb);
276 llc_sap_state_process(sap, skb);
294 llc_sap_state_process(sap, skb);
297 static inline bool llc_dgram_match(
const struct llc_sap *sap,
305 llc_mac_match(llc->
laddr.mac, laddr->
mac);
316 static struct sock *llc_lookup_dgram(
struct llc_sap *sap,
321 int slot = llc_sk_laddr_hashfn(sap, laddr);
327 if (llc_dgram_match(sap, laddr, rc)) {
331 if (
unlikely(llc_sk(rc)->sap != sap ||
332 !llc_dgram_match(sap, laddr, rc))) {
345 if (
unlikely(get_nulls_value(node) != slot))
348 rcu_read_unlock_bh();
352 static inline bool llc_mcast_match(
const struct llc_sap *sap,
364 static void llc_do_mcast(
struct llc_sap *sap,
struct sk_buff *skb,
370 for (i = 0; i <
count; i++) {
377 llc_sap_rcv(sap, skb1, stack[i]);
390 static void llc_sap_mcast(
struct llc_sap *sap,
394 int i = 0, count = 256 /
sizeof(
struct sock *);
398 struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->
dev->ifindex);
405 if (!llc_mcast_match(sap, laddr, skb, sk))
412 llc_do_mcast(sap, skb, stack, i);
418 llc_do_mcast(sap, skb, stack, i);
426 llc_pdu_decode_da(skb, laddr.
mac);
427 llc_pdu_decode_dsap(skb, &laddr.
lsap);
429 if (llc_mac_multicast(laddr.
mac)) {
430 llc_sap_mcast(sap, &laddr, skb);
433 struct sock *sk = llc_lookup_dgram(sap, &laddr);
435 llc_sap_rcv(sap, skb, sk);