Socket6

 view release on metacpan or  search on metacpan

Socket6.xs  view on Meta::CPAN

 * Project.
 *
 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the project nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifdef WIN32

#define	WINVER		0x0501
#include <winsock2.h>
#include <ws2tcpip.h>
#ifndef NI_NUMERICSERV
#error Microsoft Platform SDK (Aug. 2001) or later required.
#endif
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
#define	WSA_DECLARE					\
	WSADATA wsaData;				\
	int wsa = 0
#define	WSA_STARTUP()					\
	wsa = WSAStartup(MAKEWORD(2,2), &wsaData)
#define	WSA_CLEANUP()					\
	if (!wsa) WSACleanup()

#else /* WIN32 */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifdef __KAME__
# include <sys/param.h>
# include <net/route.h>
# if (defined(__FreeBSD__) && __FreeBSD_version >= 700048) || \
     (defined(__NetBSD__) && __NetBSD_Version__ >= 899002500)
#  include <netipsec/ipsec.h>
# elif !defined(__OpenBSD__) && !defined(__DragonFly__)
#  include <netinet6/ipsec.h>
# endif
#endif
#include <netdb.h>
#define	WSA_DECLARE
#define	WSA_STARTUP()
#define	WSA_CLEANUP()

#endif /* WIN32 */

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "config.h"

#if defined(HAVE_INET_NTOP) && !defined(CAN_INET_NTOP)
#undef HAVE_INET_NTOP
#endif

#ifndef HAVE_GETADDRINFO
#include "getaddrinfo.c"
#define	NI_MAXHOST		1025
#define	NI_MAXSERV		32
#define	HAVE_GETADDRINFO	1
#endif
#ifndef	HAVE_GETNAMEINFO
#include "getnameinfo.c"
#define	HAVE_GETNAMEINFO	1
#endif

#ifndef HAVE_INET_NTOP
#include "inet_ntop.c"
#define	HAVE_INET_NTOP		1
#endif
#ifndef HAVE_INET_PTON
#include "inet_pton.c"
#define	HAVE_INET_PTON		1
#endif

#ifndef HAVE_PL_SV_UNDEF
#define	PL_sv_undef		sv_undef
#endif

static int
not_here(char *s)
{
    croak("Socket6::%s not implemented on this architecture", s);
    return -1;
}

static double
constant(char *name, int arg)
{
    errno = 0;
    switch (*name) {
    case 'A':
	if (strEQ(name, "AF_INET6"))
#ifdef AF_INET6
	    return AF_INET6;
#else



( run in 0.767 second using v1.01-cache-2.11-cpan-39bf76dae61 )