Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /* include/net/dsfield.h - Manipulation of the Differentiated Services field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) /* Written 1998-2000 by Werner Almesberger, EPFL ICA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #ifndef __NET_DSFIELD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #define __NET_DSFIELD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/ipv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static inline __u8 ipv4_get_dsfield(const struct iphdr *iph)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	return iph->tos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static inline __u8 ipv6_get_dsfield(const struct ipv6hdr *ipv6h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	return ntohs(*(__force const __be16 *)ipv6h) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)     __u8 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)         __u32 check = ntohs((__force __be16)iph->check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	__u8 dsfield;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	dsfield = (iph->tos & mask) | value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	check += iph->tos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	if ((check+1) >> 16) check = (check+1) & 0xffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	check -= dsfield;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	check += check >> 16; /* adjust carry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	iph->check = (__force __sum16)htons(check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	iph->tos = dsfield;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)     __u8 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	__be16 *p = (__force __be16 *)ipv6h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	*p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #endif