include/net/llc_pdu.h

Source file repositories/reference/linux-study-clean/include/net/llc_pdu.h

File Facts

System
Linux kernel
Corpus path
include/net/llc_pdu.h
Extension
.h
Size
14504 bytes
Lines
439
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct llc_pdu_sn {
	u8 dsap;
	u8 ssap;
	u8 ctrl_1;
	u8 ctrl_2;
} __packed;

static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
{
	return (struct llc_pdu_sn *)skb_network_header(skb);
}

/* Un-numbered PDU format (3 bytes in length) */
struct llc_pdu_un {
	u8 dsap;
	u8 ssap;
	u8 ctrl_1;
} __packed;

static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
{
	return (struct llc_pdu_un *)skb_network_header(skb);
}

/**
 *	llc_pdu_header_init - initializes pdu header
 *	@skb: input skb that header must be set into it.
 *	@type: type of PDU (U, I or S).
 *	@ssap: source sap.
 *	@dsap: destination sap.
 *	@cr: command/response bit (0 or 1).
 *
 *	This function sets DSAP, SSAP and command/Response bit in LLC header.
 */
static inline void llc_pdu_header_init(struct sk_buff *skb, u8 type,
				       u8 ssap, u8 dsap, u8 cr)
{
	int hlen = 4; /* default value for I and S types */
	struct llc_pdu_un *pdu;

	switch (type) {
	case LLC_PDU_TYPE_U:
		hlen = 3;
		break;
	case LLC_PDU_TYPE_U_XID:
		hlen = 6;
		break;
	}

	skb_push(skb, hlen);
	skb_reset_network_header(skb);
	pdu = llc_pdu_un_hdr(skb);
	pdu->dsap = dsap;
	pdu->ssap = ssap;
	pdu->ssap |= cr;
}

/**
 *	llc_pdu_decode_sa - extracts, source address (MAC) of input frame
 *	@skb: input skb that source address must be extracted from it.
 *	@sa: pointer to source address (6 byte array).
 *
 *	This function extracts source address(MAC) of input frame.
 */
static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
{
	memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
}

/**
 *	llc_pdu_decode_da - extracts dest address of input frame
 *	@skb: input skb that destination address must be extracted from it
 *	@da: pointer to destination address (6 byte array).
 *
 *	This function extracts destination address(MAC) of input frame.
 */
static inline void llc_pdu_decode_da(struct sk_buff *skb, u8 *da)
{
	memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN);
}

/**
 *	llc_pdu_decode_ssap - extracts source SAP of input frame
 *	@skb: input skb that source SAP must be extracted from it.
 *	@ssap: source SAP (output argument).
 *
 *	This function extracts source SAP of input frame. Right bit of SSAP is
 *	command/response bit.
 */
static inline void llc_pdu_decode_ssap(struct sk_buff *skb, u8 *ssap)

Annotation

Implementation Notes