2 * llc_output.c - LLC minimal output path
4 * Copyright (c) 1997 by Procom Technology, Inc.
5 * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
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
10 * This program is distributed without any warranty or implied warranty
11 * of merchantability or fitness for a particular purpose.
13 * See the GNU General Public License version 2 for more details.
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>
22 #include <net/llc_pdu.h>
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
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.
33 int llc_mac_hdr_init(struct sk_buff
*skb
,
34 const unsigned char *sa
, const unsigned char *da
)
38 switch (skb
->dev
->type
) {
40 case ARPHRD_IEEE802_TR
: {
41 struct net_device
*dev
= skb
->dev
;
44 skb
->mac
.raw
= skb_push(skb
, sizeof(*trh
));
49 memcpy(trh
->saddr
, sa
, dev
->addr_len
);
51 memset(trh
->saddr
, 0, dev
->addr_len
);
53 memcpy(trh
->daddr
, da
, dev
->addr_len
);
54 tr_source_route(skb
, trh
, dev
);
55 skb
->mac
.raw
= skb
->data
;
61 case ARPHRD_LOOPBACK
: {
62 unsigned short len
= skb
->len
;
65 skb
->mac
.raw
= skb_push(skb
, sizeof(*eth
));
67 eth
->h_proto
= htons(len
);
68 memcpy(eth
->h_dest
, da
, ETH_ALEN
);
69 memcpy(eth
->h_source
, sa
, ETH_ALEN
);
73 printk(KERN_WARNING
"device type not supported: %d\n",
81 * llc_build_and_send_ui_pkt - unitdata request interface for upper layers
83 * @skb: packet to send
84 * @dmac: destination mac address
85 * @dsap: destination sap
87 * Upper layers calls this function when upper layer wants to send data
88 * using connection-less mode communication (UI pdu).
90 * Accept data frame from network layer to be sent using connection-
91 * less mode communication; timeout/retries handled by network layer;
92 * package primitive as an event and send to SAP event handler
94 int llc_build_and_send_ui_pkt(struct llc_sap
*sap
, struct sk_buff
*skb
,
95 unsigned char *dmac
, unsigned char dsap
)
98 llc_pdu_header_init(skb
, LLC_PDU_TYPE_U
, sap
->laddr
.lsap
,
100 llc_pdu_init_as_ui_cmd(skb
);
101 rc
= llc_mac_hdr_init(skb
, skb
->dev
->dev_addr
, dmac
);
103 rc
= dev_queue_xmit(skb
);
107 EXPORT_SYMBOL(llc_mac_hdr_init
);
108 EXPORT_SYMBOL(llc_build_and_send_ui_pkt
);