"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "contrib/lease-tools/dhcp_release.c" between
dnsmasq-2.80.tar.gz and dnsmasq-2.81.tar.xz

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

dhcp_release.c  (dnsmasq-2.80):dhcp_release.c  (dnsmasq-2.81.tar.xz)
skipping to change at line 181 skipping to change at line 181
in = r+1; in = r+1;
} }
return i; return i;
} }
static int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask) static int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask)
{ {
return (a.s_addr & mask.s_addr) == (b.s_addr & mask.s_addr); return (a.s_addr & mask.s_addr) == (b.s_addr & mask.s_addr);
} }
static struct in_addr find_interface(struct in_addr client, int fd, unsigned int index) static struct in_addr find_interface(struct in_addr client, int fd, unsigned int index, int ifrfd, struct ifreq *ifr)
{ {
struct sockaddr_nl addr; struct sockaddr_nl addr;
struct nlmsghdr *h; struct nlmsghdr *h;
ssize_t len; ssize_t len;
struct { struct {
struct nlmsghdr nlh; struct nlmsghdr nlh;
struct rtgenmsg g; struct rtgenmsg g;
} req; } req;
skipping to change at line 221 skipping to change at line 221
while (1) while (1)
{ {
if ((len = netlink_recv(fd)) == -1) if ((len = netlink_recv(fd)) == -1)
{ {
perror("netlink"); perror("netlink");
exit(1); exit(1);
} }
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NL MSG_NEXT(h, len)) for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NL MSG_NEXT(h, len))
if (h->nlmsg_type == NLMSG_DONE) if (h->nlmsg_type == NLMSG_DONE)
exit(0); {
/* No match found, return first address as src/dhcp.c code does */
ifr->ifr_addr.sa_family = AF_INET;
if (ioctl(ifrfd, SIOCGIFADDR, ifr) != -1)
return ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr;
else
{
fprintf(stderr, "error: local IPv4 address not found\n");
exit(1);
}
}
else if (h->nlmsg_type == RTM_NEWADDR) else if (h->nlmsg_type == RTM_NEWADDR)
{ {
struct ifaddrmsg *ifa = NLMSG_DATA(h); struct ifaddrmsg *ifa = NLMSG_DATA(h);
struct rtattr *rta; struct rtattr *rta;
unsigned int len1 = h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa)); unsigned int len1 = h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa));
if (ifa->ifa_index == index && ifa->ifa_family == AF_INET) if (ifa->ifa_index == index && ifa->ifa_family == AF_INET)
{ {
struct in_addr netmask, addr; struct in_addr netmask, addr;
skipping to change at line 288 skipping to change at line 298
exit(1); exit(1);
} }
if (inet_addr(argv[2]) == INADDR_NONE) if (inet_addr(argv[2]) == INADDR_NONE)
{ {
perror("invalid ip address"); perror("invalid ip address");
exit(1); exit(1);
} }
lease.s_addr = inet_addr(argv[2]); lease.s_addr = inet_addr(argv[2]);
server = find_interface(lease, nl, if_nametoindex(argv[1])); server = find_interface(lease, nl, if_nametoindex(argv[1]), fd, &ifr);
memset(&packet, 0, sizeof(packet)); memset(&packet, 0, sizeof(packet));
packet.hlen = parse_hex(argv[3], packet.chaddr, DHCP_CHADDR_MAX, &mac_type); packet.hlen = parse_hex(argv[3], packet.chaddr, DHCP_CHADDR_MAX, &mac_type);
if (mac_type == 0) if (mac_type == 0)
packet.htype = ARPHRD_ETHER; packet.htype = ARPHRD_ETHER;
else else
packet.htype = mac_type; packet.htype = mac_type;
packet.op = BOOTREQUEST; packet.op = BOOTREQUEST;
 End of changes. 3 change blocks. 
3 lines changed or deleted 13 lines changed or added

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