Blame pcap/socket.h

Packit 209cc3
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
Packit 209cc3
/*
Packit 209cc3
 * Copyright (c) 1993, 1994, 1995, 1996, 1997
Packit 209cc3
 *	The Regents of the University of California.  All rights reserved.
Packit 209cc3
 *
Packit 209cc3
 * Redistribution and use in source and binary forms, with or without
Packit 209cc3
 * modification, are permitted provided that the following conditions
Packit 209cc3
 * are met:
Packit 209cc3
 * 1. Redistributions of source code must retain the above copyright
Packit 209cc3
 *    notice, this list of conditions and the following disclaimer.
Packit 209cc3
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 209cc3
 *    notice, this list of conditions and the following disclaimer in the
Packit 209cc3
 *    documentation and/or other materials provided with the distribution.
Packit 209cc3
 * 3. All advertising materials mentioning features or use of this software
Packit 209cc3
 *    must display the following acknowledgement:
Packit 209cc3
 *	This product includes software developed by the Computer Systems
Packit 209cc3
 *	Engineering Group at Lawrence Berkeley Laboratory.
Packit 209cc3
 * 4. Neither the name of the University nor of the Laboratory may be used
Packit 209cc3
 *    to endorse or promote products derived from this software without
Packit 209cc3
 *    specific prior written permission.
Packit 209cc3
 *
Packit 209cc3
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
Packit 209cc3
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 209cc3
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 209cc3
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
Packit 209cc3
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 209cc3
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 209cc3
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 209cc3
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 209cc3
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 209cc3
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 209cc3
 * SUCH DAMAGE.
Packit 209cc3
 */
Packit 209cc3
Packit 209cc3
#ifndef lib_pcap_socket_h
Packit 209cc3
#define lib_pcap_socket_h
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * Some minor differences between sockets on various platforms.
Packit 209cc3
 * We include whatever sockets are needed for Internet-protocol
Packit 209cc3
 * socket access on UN*X and Windows.
Packit 209cc3
 */
Packit 209cc3
#ifdef _WIN32
Packit 209cc3
  /* Need windef.h for defines used in winsock2.h under MingW32 */
Packit 209cc3
  #ifdef __MINGW32__
Packit 209cc3
    #include <windef.h>
Packit 209cc3
  #endif
Packit 209cc3
  #include <winsock2.h>
Packit 209cc3
  #include <ws2tcpip.h>
Packit 209cc3
Packit 209cc3
  /*
Packit 209cc3
   * Winsock doesn't have this UN*X type; it's used in the UN*X
Packit 209cc3
   * sockets API.
Packit 209cc3
   *
Packit 209cc3
   * XXX - do we need to worry about UN*Xes so old that *they*
Packit 209cc3
   * don't have it, either?
Packit 209cc3
   */
Packit 209cc3
  typedef int socklen_t;
Packit 209cc3
Packit 209cc3
  /*
Packit 209cc3
   * Winsock doesn't have this POSIX type; it's used for the
Packit 209cc3
   * tv_usec value of struct timeval.
Packit 209cc3
   */
Packit 209cc3
  typedef long suseconds_t;
Packit 209cc3
#else /* _WIN32 */
Packit 209cc3
  #include <sys/types.h>
Packit 209cc3
  #include <sys/socket.h>
Packit 209cc3
  #include <netdb.h>		/* for struct addrinfo/getaddrinfo() */
Packit 209cc3
  #include <netinet/in.h>	/* for sockaddr_in, in BSD at least */
Packit 209cc3
  #include <arpa/inet.h>
Packit 209cc3
Packit 209cc3
  /*!
Packit 209cc3
   * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's
Packit 209cc3
   * a file descriptor, and therefore a signed integer.
Packit 209cc3
   * We define SOCKET to be a signed integer on UN*X, so that it can
Packit 209cc3
   * be used on both platforms.
Packit 209cc3
   */
Packit 209cc3
  #ifndef SOCKET
Packit 209cc3
    #define SOCKET int
Packit 209cc3
  #endif
Packit 209cc3
Packit 209cc3
  /*!
Packit 209cc3
   * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
Packit 209cc3
   * in UN*X, it's -1.
Packit 209cc3
   * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
Packit 209cc3
   * both platforms.
Packit 209cc3
   */
Packit 209cc3
  #ifndef INVALID_SOCKET
Packit 209cc3
    #define INVALID_SOCKET -1
Packit 209cc3
  #endif
Packit 209cc3
#endif /* _WIN32 */
Packit 209cc3
Packit 209cc3
#endif /* lib_pcap_socket_h */