brintos

brintos / linux-shallow public Read only

0
0
Text · 1.5 KiB · bab5848 Raw
45 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.4 */5 6#ifndef _WG_SOCKET_H7#define _WG_SOCKET_H8 9#include <linux/netdevice.h>10#include <linux/udp.h>11#include <linux/if_vlan.h>12#include <linux/if_ether.h>13 14int wg_socket_init(struct wg_device *wg, u16 port);15void wg_socket_reinit(struct wg_device *wg, struct sock *new4,16		      struct sock *new6);17int wg_socket_send_buffer_to_peer(struct wg_peer *peer, void *data,18				  size_t len, u8 ds);19int wg_socket_send_skb_to_peer(struct wg_peer *peer, struct sk_buff *skb,20			       u8 ds);21int wg_socket_send_buffer_as_reply_to_skb(struct wg_device *wg,22					  struct sk_buff *in_skb,23					  void *out_buffer, size_t len);24 25int wg_socket_endpoint_from_skb(struct endpoint *endpoint,26				const struct sk_buff *skb);27void wg_socket_set_peer_endpoint(struct wg_peer *peer,28				 const struct endpoint *endpoint);29void wg_socket_set_peer_endpoint_from_skb(struct wg_peer *peer,30					  const struct sk_buff *skb);31void wg_socket_clear_peer_endpoint_src(struct wg_peer *peer);32 33#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)34#define net_dbg_skb_ratelimited(fmt, dev, skb, ...) do {                       \35		struct endpoint __endpoint;                                    \36		wg_socket_endpoint_from_skb(&__endpoint, skb);                 \37		net_dbg_ratelimited(fmt, dev, &__endpoint.addr,                \38				    ##__VA_ARGS__);                            \39	} while (0)40#else41#define net_dbg_skb_ratelimited(fmt, skb, ...)42#endif43 44#endif /* _WG_SOCKET_H */45