// SPDX-License-Identifier: GPL-2.0-only1/*2* llc_output.c - LLC minimal output path3*4* Copyright (c) 1997 by Procom Technology, Inc.5* 2001-2003 by Arnaldo Carvalho de Melo <[email protected]>6*/78#include <linux/if_arp.h>9#include <linux/netdevice.h>10#include <linux/skbuff.h>11#include <linux/export.h>12#include <net/llc.h>13#include <net/llc_pdu.h>1415/**16* llc_mac_hdr_init - fills MAC header fields17* @skb: Address of the frame to initialize its MAC header18* @sa: The MAC source address19* @da: The MAC destination address20*21* Fills MAC header fields, depending on MAC type. Returns 0, If MAC type22* is a valid type and initialization completes correctly 1, otherwise.23*/24int llc_mac_hdr_init(struct sk_buff *skb,25const unsigned char *sa, const unsigned char *da)26{27int rc = -EINVAL;2829switch (skb->dev->type) {30case ARPHRD_ETHER:31case ARPHRD_LOOPBACK:32rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,33skb->len);34if (rc > 0)35rc = 0;36break;37default:38break;39}40return rc;41}4243/**44* llc_build_and_send_ui_pkt - unitdata request interface for upper layers45* @sap: sap to use46* @skb: packet to send47* @dmac: destination mac address48* @dsap: destination sap49*50* Upper layers calls this function when upper layer wants to send data51* using connection-less mode communication (UI pdu).52*53* Accept data frame from network layer to be sent using connection-54* less mode communication; timeout/retries handled by network layer;55* package primitive as an event and send to SAP event handler56*/57int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,58const unsigned char *dmac, unsigned char dsap)59{60int rc;61llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,62dsap, LLC_PDU_CMD);63llc_pdu_init_as_ui_cmd(skb);64rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac);65if (likely(!rc))66rc = dev_queue_xmit(skb);67else68kfree_skb(skb);69return rc;70}7172EXPORT_SYMBOL(llc_mac_hdr_init);73EXPORT_SYMBOL(llc_build_and_send_ui_pkt);747576