Blame resolv/res_enable_icmp.c

Packit Service c7a3bb
/* Enable full ICMP errors on a socket.
Packit Service c7a3bb
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service c7a3bb
   This file is part of the GNU C Library.
Packit Service c7a3bb
Packit Service c7a3bb
   The GNU C Library is free software; you can redistribute it and/or
Packit Service c7a3bb
   modify it under the terms of the GNU Lesser General Public
Packit Service c7a3bb
   License as published by the Free Software Foundation; either
Packit Service c7a3bb
   version 2.1 of the License, or (at your option) any later version.
Packit Service c7a3bb
Packit Service c7a3bb
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service c7a3bb
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service c7a3bb
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service c7a3bb
   Lesser General Public License for more details.
Packit Service c7a3bb
Packit Service c7a3bb
   You should have received a copy of the GNU Lesser General Public
Packit Service c7a3bb
   License along with the GNU C Library; if not, see
Packit Service c7a3bb
   <http://www.gnu.org/licenses/>.  */
Packit Service c7a3bb
Packit Service c7a3bb
#include <errno.h>
Packit Service c7a3bb
#include <netinet/in.h>
Packit Service c7a3bb
#include <sys/socket.h>
Packit Service c7a3bb
Packit Service c7a3bb
int
Packit Service c7a3bb
__res_enable_icmp (int family, int fd)
Packit Service c7a3bb
{
Packit Service c7a3bb
  int one = 1;
Packit Service c7a3bb
  switch (family)
Packit Service c7a3bb
    {
Packit Service c7a3bb
    case AF_INET:
Packit Service c7a3bb
      return setsockopt (fd, SOL_IP, IP_RECVERR, &one, sizeof (one));
Packit Service c7a3bb
    case AF_INET6:
Packit Service c7a3bb
      return setsockopt (fd, SOL_IPV6, IPV6_RECVERR, &one, sizeof (one));
Packit Service c7a3bb
    default:
Packit Service c7a3bb
      __set_errno (EAFNOSUPPORT);
Packit Service c7a3bb
      return -1;
Packit Service c7a3bb
    }
Packit Service c7a3bb
}