/*1* llc_output.c - LLC minimal output path2*3* Copyright (c) 1997 by Procom Technology, Inc.4* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]>5*6* This program can be redistributed or modified under the terms of the7* GNU General Public License version 2 as published by the Free Software8* Foundation.9* This program is distributed without any warranty or implied warranty10* of merchantability or fitness for a particular purpose.11*12* See the GNU General Public License version 2 for more details.13*/1415#include <linux/if_arp.h>16#include <linux/if_tr.h>17#include <linux/netdevice.h>18#include <linux/trdevice.h>19#include <linux/skbuff.h>20#include <net/llc.h>21#include <net/llc_pdu.h>2223/**24* llc_mac_hdr_init - fills MAC header fields25* @skb: Address of the frame to initialize its MAC header26* @sa: The MAC source address27* @da: The MAC destination address28*29* Fills MAC header fields, depending on MAC type. Returns 0, If MAC type30* is a valid type and initialization completes correctly 1, otherwise.31*/32int llc_mac_hdr_init(struct sk_buff *skb,33const unsigned char *sa, const unsigned char *da)34{35int rc = -EINVAL;3637switch (skb->dev->type) {38case ARPHRD_IEEE802_TR:39case ARPHRD_ETHER:40case ARPHRD_LOOPBACK:41rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,42skb->len);43if (rc > 0)44rc = 0;45break;46default:47WARN(1, "device type not supported: %d\n", skb->dev->type);48}49return rc;50}5152/**53* llc_build_and_send_ui_pkt - unitdata request interface for upper layers54* @sap: sap to use55* @skb: packet to send56* @dmac: destination mac address57* @dsap: destination sap58*59* Upper layers calls this function when upper layer wants to send data60* using connection-less mode communication (UI pdu).61*62* Accept data frame from network layer to be sent using connection-63* less mode communication; timeout/retries handled by network layer;64* package primitive as an event and send to SAP event handler65*/66int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,67unsigned char *dmac, unsigned char dsap)68{69int rc;70llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,71dsap, LLC_PDU_CMD);72llc_pdu_init_as_ui_cmd(skb);73rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac);74if (likely(!rc))75rc = dev_queue_xmit(skb);76return rc;77}7879EXPORT_SYMBOL(llc_mac_hdr_init);80EXPORT_SYMBOL(llc_build_and_send_ui_pkt);818283