Blame resolv/res_enable_icmp.c

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