"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dump.c" between
dnsmasq-2.80.tar.gz and dnsmasq-2.81.tar.xz

About: Dnsmasq is a lightweight caching DNS forwarder and DHCP server.

dump.c  (dnsmasq-2.80):dump.c  (dnsmasq-2.81.tar.xz)
/* dnsmasq is Copyright (c) 2000-2018 Simon Kelley /* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991, or the Free Software Foundation; version 2 dated June, 1991, or
(at your option) version 3 dated 29 June, 2007. (at your option) version 3 dated 29 June, 2007.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 84 skipping to change at line 84
{ {
lseek(daemon->dumpfd, pcap_header.incl_len, SEEK_CUR); lseek(daemon->dumpfd, pcap_header.incl_len, SEEK_CUR);
packet_count++; packet_count++;
} }
} }
} }
void dump_packet(int mask, void *packet, size_t len, union mysockaddr *src, unio n mysockaddr *dst) void dump_packet(int mask, void *packet, size_t len, union mysockaddr *src, unio n mysockaddr *dst)
{ {
struct ip ip; struct ip ip;
#ifdef HAVE_IPV6
struct ip6_hdr ip6; struct ip6_hdr ip6;
int family; int family;
#endif
struct udphdr { struct udphdr {
u16 uh_sport; /* source port */ u16 uh_sport; /* source port */
u16 uh_dport; /* destination port */ u16 uh_dport; /* destination port */
u16 uh_ulen; /* udp length */ u16 uh_ulen; /* udp length */
u16 uh_sum; /* udp checksum */ u16 uh_sum; /* udp checksum */
} udp; } udp;
struct pcaprec_hdr_s pcap_header; struct pcaprec_hdr_s pcap_header;
struct timeval time; struct timeval time;
u32 i, sum; u32 i, sum;
void *iphdr; void *iphdr;
size_t ipsz; size_t ipsz;
int rc; int rc;
if (daemon->dumpfd == -1 || !(mask & daemon->dump_mask)) if (daemon->dumpfd == -1 || !(mask & daemon->dump_mask))
return; return;
/* So wireshark can Id the packet. */ /* So wireshark can Id the packet. */
udp.uh_sport = udp.uh_dport = htons(NAMESERVER_PORT); udp.uh_sport = udp.uh_dport = htons(NAMESERVER_PORT);
#ifdef HAVE_IPV6
if (src) if (src)
family = src->sa.sa_family; family = src->sa.sa_family;
else else
family = dst->sa.sa_family; family = dst->sa.sa_family;
if (family == AF_INET6) if (family == AF_INET6)
{ {
iphdr = &ip6; iphdr = &ip6;
ipsz = sizeof(ip6); ipsz = sizeof(ip6);
memset(&ip6, 0, sizeof(ip6)); memset(&ip6, 0, sizeof(ip6));
skipping to change at line 137 skipping to change at line 134
udp.uh_sport = src->in6.sin6_port; udp.uh_sport = src->in6.sin6_port;
} }
if (dst) if (dst)
{ {
memcpy(&ip6.ip6_dst, &dst->in6.sin6_addr, IN6ADDRSZ); memcpy(&ip6.ip6_dst, &dst->in6.sin6_addr, IN6ADDRSZ);
udp.uh_dport = dst->in6.sin6_port; udp.uh_dport = dst->in6.sin6_port;
} }
/* start UDP checksum */ /* start UDP checksum */
for (sum = 0, i = 0; i < IN6ADDRSZ; i++) for (sum = 0, i = 0; i < IN6ADDRSZ; i+=2)
sum += ((u16 *)&ip6.ip6_src)[i]; {
sum += ip6.ip6_src.s6_addr[i] + (ip6.ip6_src.s6_addr[i+1] << 8) ;
sum += ip6.ip6_dst.s6_addr[i] + (ip6.ip6_dst.s6_addr[i+1] << 8) ;
}
} }
else else
#endif
{ {
iphdr = &ip; iphdr = &ip;
ipsz = sizeof(ip); ipsz = sizeof(ip);
memset(&ip, 0, sizeof(ip)); memset(&ip, 0, sizeof(ip));
ip.ip_v = IPVERSION; ip.ip_v = IPVERSION;
ip.ip_hl = sizeof(struct ip) / 4; ip.ip_hl = sizeof(struct ip) / 4;
ip.ip_len = htons(sizeof(struct ip) + sizeof(struct udphdr) + len); ip.ip_len = htons(sizeof(struct ip) + sizeof(struct udphdr) + len);
ip.ip_ttl = IPDEFTTL; ip.ip_ttl = IPDEFTTL;
ip.ip_p = IPPROTO_UDP; ip.ip_p = IPPROTO_UDP;
 End of changes. 6 change blocks. 
7 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)