Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
llc_output.c
Go to the documentation of this file.
1 /*
2  * llc_output.c - LLC minimal output path
3  *
4  * Copyright (c) 1997 by Procom Technology, Inc.
5  * 2001-2003 by Arnaldo Carvalho de Melo <[email protected]>
6  *
7  * This program can be redistributed or modified under the terms of the
8  * GNU General Public License version 2 as published by the Free Software
9  * Foundation.
10  * This program is distributed without any warranty or implied warranty
11  * of merchantability or fitness for a particular purpose.
12  *
13  * See the GNU General Public License version 2 for more details.
14  */
15 
16 #include <linux/if_arp.h>
17 #include <linux/netdevice.h>
18 #include <linux/skbuff.h>
19 #include <linux/export.h>
20 #include <net/llc.h>
21 #include <net/llc_pdu.h>
22 
33  const unsigned char *sa, const unsigned char *da)
34 {
35  int rc = -EINVAL;
36 
37  switch (skb->dev->type) {
38  case ARPHRD_ETHER:
39  case ARPHRD_LOOPBACK:
40  rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
41  skb->len);
42  if (rc > 0)
43  rc = 0;
44  break;
45  default:
46  WARN(1, "device type not supported: %d\n", skb->dev->type);
47  }
48  return rc;
49 }
50 
65 int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
66  unsigned char *dmac, unsigned char dsap)
67 {
68  int rc;
69  llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
70  dsap, LLC_PDU_CMD);
71  llc_pdu_init_as_ui_cmd(skb);
72  rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac);
73  if (likely(!rc))
74  rc = dev_queue_xmit(skb);
75  return rc;
76 }
77