Blame resolv/res_enable_icmp.c

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