Search Linux Wireless

[RFC v1 223/256] cl8k: add utils/ip.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Viktor Barna <viktor.barna@xxxxxxxxxx>

(Part of the split. Please, take a look at the cover letter for more
details).

Signed-off-by: Viktor Barna <viktor.barna@xxxxxxxxxx>
---
 drivers/net/wireless/celeno/cl8k/utils/ip.h | 51 +++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/utils/ip.h

diff --git a/drivers/net/wireless/celeno/cl8k/utils/ip.h b/drivers/net/wireless/celeno/cl8k/utils/ip.h
new file mode 100644
index 000000000000..93aa9fcc2384
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/utils/ip.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: MIT */
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#ifndef CL_IP_H
+#define CL_IP_H
+
+#include <linux/version.h>
+#include <linux/skbuff.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
+#include <linux/if_vlan.h>
+#include <linux/netdevice.h>
+#include <linux/igmp.h>
+#include <asm/unaligned.h>
+
+/* Check if a packet has specific LLC fields e.g. DSAP, SSAP and Control */
+#define PKT_HAS_LLC_HDR(a) ((a[0] == 0xAA) && (a[1] == 0xAA) && (a[2] == 0x03))
+#define LENGTH_LLC 3
+#define LENGTH_SSNAP 5
+
+/* Multiply by 4 because IHL is number of 32-bit words */
+#define IPV4_HDR_LEN(ihl) ((ihl) << 2)
+#define TCP_ACK_MAX_LEN 100
+
+bool set_network_header_if_proto(struct sk_buff *skb, u16 protocol);
+bool is_ipv4_packet(struct sk_buff *skb);
+bool is_ipv6_packet(struct sk_buff *skb);
+bool is_ssdp_packet(struct sk_buff *skb);
+bool is_mdns_packet(const u8 *dest_mac);
+bool is_ipv4_service_multicast_packet(struct sk_buff *skb);
+bool is_ipv6_service_multicast_packet(struct sk_buff *skb);
+bool is_tcp_ack(struct sk_buff *skb, bool *syn_rst_push);
+
+static inline unsigned short get_ether_type(int offset, unsigned char *src_buf)
+{
+       unsigned short type_len = *(unsigned short *)(src_buf + offset);
+
+       return htons(type_len);
+}
+
+static inline bool cl_ip_addr_parse_str(const u8 *str, u8 *addr)
+{
+       return (sscanf(str,
+                      "%hhd.%hhd.%hhd.%hhd",
+                      &addr[0],
+                      &addr[1],
+                      &addr[2],
+                      &addr[3]) == 4);
+}
+
+#endif /* CL_IP_H */
--
2.30.0

________________________________
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any retransmission, dissemination, copying or other use of, or taking of any action in reliance upon this information is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Nothing contained herein shall be deemed as a representation, warranty or a commitment by Celeno. No warranties are expressed or implied, including, but not limited to, any implied warranties of non-infringement, merchantability and fitness for a particular purpose.
________________________________





[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux