aboutsummaryrefslogtreecommitdiffstats
path: root/net/llc/llc_output.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /net/llc/llc_output.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'net/llc/llc_output.c')
-rw-r--r--net/llc/llc_output.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/net/llc/llc_output.c b/net/llc/llc_output.c
new file mode 100644
index 000000000000..ab5784cf163e
--- /dev/null
+++ b/net/llc/llc_output.c
@@ -0,0 +1,107 @@
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 <acme@conectiva.com.br>
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/if_tr.h>
18#include <linux/netdevice.h>
19#include <linux/trdevice.h>
20#include <linux/skbuff.h>
21#include <net/llc.h>
22#include <net/llc_pdu.h>
23
24/**
25 * llc_mac_hdr_init - fills MAC header fields
26 * @skb: Address of the frame to initialize its MAC header
27 * @sa: The MAC source address
28 * @da: The MAC destination address
29 *
30 * Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
31 * is a valid type and initialization completes correctly 1, otherwise.
32 */
33int llc_mac_hdr_init(struct sk_buff *skb, unsigned char *sa, unsigned char *da)
34{
35 int rc = 0;
36
37 switch (skb->dev->type) {
38#ifdef CONFIG_TR
39 case ARPHRD_IEEE802_TR: {
40 struct net_device *dev = skb->dev;
41 struct trh_hdr *trh;
42
43 skb->mac.raw = skb_push(skb, sizeof(*trh));
44 trh = tr_hdr(skb);
45 trh->ac = AC;
46 trh->fc = LLC_FRAME;
47 if (sa)
48 memcpy(trh->saddr, sa, dev->addr_len);
49 else
50 memset(trh->saddr, 0, dev->addr_len);
51 if (da) {
52 memcpy(trh->daddr, da, dev->addr_len);
53 tr_source_route(skb, trh, dev);
54 skb->mac.raw = skb->data;
55 }
56 break;
57 }
58#endif
59 case ARPHRD_ETHER:
60 case ARPHRD_LOOPBACK: {
61 unsigned short len = skb->len;
62 struct ethhdr *eth;
63
64 skb->mac.raw = skb_push(skb, sizeof(*eth));
65 eth = eth_hdr(skb);
66 eth->h_proto = htons(len);
67 memcpy(eth->h_dest, da, ETH_ALEN);
68 memcpy(eth->h_source, sa, ETH_ALEN);
69 break;
70 }
71 default:
72 printk(KERN_WARNING "device type not supported: %d\n",
73 skb->dev->type);
74 rc = -EINVAL;
75 }
76 return rc;
77}
78
79/**
80 * llc_build_and_send_ui_pkt - unitdata request interface for upper layers
81 * @sap: sap to use
82 * @skb: packet to send
83 * @dmac: destination mac address
84 * @dsap: destination sap
85 *
86 * Upper layers calls this function when upper layer wants to send data
87 * using connection-less mode communication (UI pdu).
88 *
89 * Accept data frame from network layer to be sent using connection-
90 * less mode communication; timeout/retries handled by network layer;
91 * package primitive as an event and send to SAP event handler
92 */
93int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
94 unsigned char *dmac, unsigned char dsap)
95{
96 int rc;
97 llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
98 dsap, LLC_PDU_CMD);
99 llc_pdu_init_as_ui_cmd(skb);
100 rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac);
101 if (!rc)
102 rc = dev_queue_xmit(skb);
103 return rc;
104}
105
106EXPORT_SYMBOL(llc_mac_hdr_init);
107EXPORT_SYMBOL(llc_build_and_send_ui_pkt);