/** * union ovpn_sockaddr - basic transport layer address * @in4: IPv4 address * @in6: IPv6 address
*/ union ovpn_sockaddr { struct sockaddr_in in4; struct sockaddr_in6 in6;
};
/** * struct ovpn_bind - remote peer binding * @remote: the remote peer sockaddress * @local: local endpoint used to talk to the peer * @local.ipv4: local IPv4 used to talk to the peer * @local.ipv6: local IPv6 used to talk to the peer * @rcu: used to schedule RCU cleanup job
*/ struct ovpn_bind { union ovpn_sockaddr remote; /* remote sockaddr */
union { struct in_addr ipv4; struct in6_addr ipv6;
} local;
struct rcu_head rcu;
};
/** * ovpn_bind_skb_src_match - match packet source with binding * @bind: the binding to match * @skb: the packet to match * * Return: true if the packet source matches the remote peer sockaddr * in the binding
*/ staticinlinebool ovpn_bind_skb_src_match(conststruct ovpn_bind *bind, conststruct sk_buff *skb)
{ constunion ovpn_sockaddr *remote;
if (unlikely(!bind)) returnfalse;
remote = &bind->remote;
switch (skb->protocol) { case htons(ETH_P_IP): if (unlikely(remote->in4.sin_family != AF_INET)) returnfalse;
if (unlikely(remote->in4.sin_addr.s_addr != ip_hdr(skb)->saddr)) returnfalse;
if (unlikely(remote->in4.sin_port != udp_hdr(skb)->source)) returnfalse; break; case htons(ETH_P_IPV6): if (unlikely(remote->in6.sin6_family != AF_INET6)) returnfalse;
if (unlikely(!ipv6_addr_equal(&remote->in6.sin6_addr,
&ipv6_hdr(skb)->saddr))) returnfalse;
if (unlikely(remote->in6.sin6_port != udp_hdr(skb)->source)) returnfalse; break; default: returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.