Blame resolv/res_enable_icmp.c

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