Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * ppp_defs.h - PPP definitions.
4 *
5 * Copyright 1994-2000 Paul Mackerras.
6 */
7#ifndef _PPP_DEFS_H_
8#define _PPP_DEFS_H_
9
10#include <linux/crc-ccitt.h>
11#include <linux/skbuff.h>
12#include <uapi/linux/ppp_defs.h>
13
14#define PPP_FCS(fcs, c) crc_ccitt_byte(fcs, c)
15
16/**
17 * ppp_proto_is_valid - checks if PPP protocol is valid
18 * @proto: PPP protocol
19 *
20 * Assumes proto is not compressed.
21 * Protocol is valid if the value is odd and the least significant bit of the
22 * most significant octet is 0 (see RFC 1661, section 2).
23 */
24static inline bool ppp_proto_is_valid(u16 proto)
25{
26 return !!((proto & 0x0101) == 0x0001);
27}
28
29/**
30 * ppp_skb_is_compressed_proto - checks if PPP protocol in a skb is compressed
31 * @skb: skb to check
32 *
33 * Check if the PPP protocol field is compressed (the least significant
34 * bit of the most significant octet is 1). skb->data must point to the PPP
35 * protocol header.
36 *
37 * Return: Whether the PPP protocol field is compressed.
38 */
39static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)
40{
41 return unlikely(skb->data[0] & 0x01);
42}
43
44#endif /* _PPP_DEFS_H_ */