Planeshift

sockuni.h

Go to the documentation of this file.
00001 /*
00002  * sockuni.h
00003  *
00004  * Copyright (C) 2001 Atomic Blue ([email protected], http://www.atomicblue.org) 
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  * Socket definitions for UNIX
00019  *
00020  * Author: Matthias Braun <[email protected]>
00021  */
00022 
00023 #ifndef __SOCKUNI_H__
00024 #define __SOCKUNI_H__
00025 
00026 /* Include various files needed for sockets */
00027 #include <sys/socket.h>
00028 #include <sys/types.h>
00029 #include <sys/ioctl.h>
00030 #include <netinet/in.h>
00031 #include <arpa/inet.h>
00032 #include <netdb.h>
00033 #include <unistd.h>
00034 
00039 //#define INCLUDE_IPV6_SUPPORT true
00040 
00041 /* define some types */
00042 #ifndef SOCKET
00043 #define SOCKET    int
00044 #endif
00045 
00046 #ifndef IN_ADDR
00047 #ifdef INCLUDE_IPV6_SUPPORT
00048 #define IN_ADDR struct in6_addr
00049 #else
00050 #define IN_ADDR struct in_addr
00051 #endif
00052 #endif
00053 
00054 #ifndef SOCKADDR_IN
00055 #ifdef INCLUDE_IPV6_SUPPORT
00056 #define SOCKADDR_IN struct sockaddr_in6
00057 #else
00058 #define SOCKADDR_IN struct sockaddr_in
00059 #endif
00060 #endif
00061 
00062 #ifndef LPSOCKADDR
00063 #define LPSOCKADDR  struct sockaddr *
00064 #endif
00065 
00066 #ifndef LPSOCKADDR_IN
00067 #ifdef INCLUDE_IPV6_SUPPORT
00068 #define LPSOCKADDR_IN    struct sockaddr_in6 *
00069 #else
00070 #define LPSOCKADDR_IN    struct sockaddr_in *
00071 #endif
00072 #endif
00073 
00074 #define SOCK_SENDTO(a,b,c,d,e,f)                        sendto(a,(const void *) b,c,d,e,f)
00075 #define SOCK_RECVFROM(a,b,c,d,e,f)                      recvfrom(a,(void *) b,c,d,e,f)
00076 #define SOCK_IOCTL(a,b,c)                               ioctl(a,b,c)
00077 #define SOCK_CLOSE(a)                                   close(a)
00078 #define SOCK_SELECT(max,read,write,except,timeout)      select(max,read,write,except,timeout)
00079 
00080 #define INVALID_SOCKET    -1
00081 
00082 static inline int initSocket()
00083 {
00084     /* we don't need to init sockets in unix... */
00085     return 0;
00086 }
00087 
00088 static inline void exitSocket()
00089 {
00090     return;
00091 }
00092 
00095 #endif