Lines Matching refs:ipv4
132 * Check whether destination IPv4 is in allowed IPs list
134 static int dest_ip_allowed4(struct xdp_server *xdp, struct iphdr *ipv4);
180 static inline void swap_ipv4(struct iphdr *ipv4);
183 static inline void *parse_ipv4(struct iphdr *ipv4);
574 static int dest_ip_allowed4(struct xdp_server *xdp, struct iphdr *ipv4) {
582 ipv4
663 static inline void swap_ipv4(struct iphdr *ipv4) {
665 memcpy(&tmp_ip, &ipv4->saddr, sizeof(tmp_ip));
666 memcpy(&ipv4->saddr, &ipv4->daddr, sizeof(tmp_ip));
667 memcpy(&ipv4->daddr, &tmp_ip, sizeof(tmp_ip));
684 static inline void *parse_ipv4(struct iphdr *ipv4) {
685 if (ipv4->protocol != IPPROTO_UDP)
688 return (void *)(ipv4 + 1);
748 struct iphdr *ipv4 = NULL;
753 * at least an ethernet header, an ipv4 header (ipv6 header is larger), and
778 ipv4 = (struct iphdr *)(eth + 1);
780 if (!(udp = parse_ipv4(ipv4)))
783 dnslen -= (uint32_t) (sizeof(*eth) + sizeof(*ipv4) + sizeof(*udp));
784 data_before_dnshdr_len += sizeof(*ipv4);
786 if (!dest_ip_allowed4(xdp, ipv4))
824 sock4->sin_addr.s_addr = ipv4->saddr;
847 if (ipv4) {
848 __be16 ipv4_old_len = ipv4->tot_len;
849 swap_ipv4(ipv4);
850 ipv4->tot_len = htons(sizeof(*ipv4)) + udp->len;
851 csum16_replace(&ipv4->check, ipv4_old_len, ipv4->tot_len);
852 udp->check = calc_csum_udp4(udp, ipv4);