0001
0002
0003
0004
0005
0006 #ifndef _WG_SOCKET_H
0007 #define _WG_SOCKET_H
0008
0009 #include <linux/netdevice.h>
0010 #include <linux/udp.h>
0011 #include <linux/if_vlan.h>
0012 #include <linux/if_ether.h>
0013
0014 int wg_socket_init(struct wg_device *wg, u16 port);
0015 void wg_socket_reinit(struct wg_device *wg, struct sock *new4,
0016 struct sock *new6);
0017 int wg_socket_send_buffer_to_peer(struct wg_peer *peer, void *data,
0018 size_t len, u8 ds);
0019 int wg_socket_send_skb_to_peer(struct wg_peer *peer, struct sk_buff *skb,
0020 u8 ds);
0021 int wg_socket_send_buffer_as_reply_to_skb(struct wg_device *wg,
0022 struct sk_buff *in_skb,
0023 void *out_buffer, size_t len);
0024
0025 int wg_socket_endpoint_from_skb(struct endpoint *endpoint,
0026 const struct sk_buff *skb);
0027 void wg_socket_set_peer_endpoint(struct wg_peer *peer,
0028 const struct endpoint *endpoint);
0029 void wg_socket_set_peer_endpoint_from_skb(struct wg_peer *peer,
0030 const struct sk_buff *skb);
0031 void wg_socket_clear_peer_endpoint_src(struct wg_peer *peer);
0032
0033 #if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
0034 #define net_dbg_skb_ratelimited(fmt, dev, skb, ...) do { \
0035 struct endpoint __endpoint; \
0036 wg_socket_endpoint_from_skb(&__endpoint, skb); \
0037 net_dbg_ratelimited(fmt, dev, &__endpoint.addr, \
0038 ##__VA_ARGS__); \
0039 } while (0)
0040 #else
0041 #define net_dbg_skb_ratelimited(fmt, skb, ...)
0042 #endif
0043
0044 #endif