build nativenet on Linux

This commit is contained in:
David Rose 2007-02-09 00:10:28 +00:00
parent f05b41cc96
commit 0db570a622
17 changed files with 93 additions and 32 deletions

View File

@ -19,6 +19,8 @@
// to a subsequent version of Panda. // to a subsequent version of Panda.
// ******************************************************************* // *******************************************************************
#define IS_LINUX 1
// What additional flags should we pass to interrogate? // What additional flags should we pass to interrogate?
#define SYSTEM_IGATE_FLAGS -D__i386__ -D__const=const -Dvolatile= #define SYSTEM_IGATE_FLAGS -D__i386__ -D__const=const -Dvolatile=

View File

@ -19,10 +19,13 @@
// to a subsequent version of Panda. // to a subsequent version of Panda.
// ******************************************************************* // *******************************************************************
#define IS_OSX 1
// Assume that OSX has OpenGL available.
#define HAVE_GL 1
// What additional flags should we pass to interrogate? // What additional flags should we pass to interrogate?
#define SYSTEM_IGATE_FLAGS -D__FLT_EVAL_METHOD__=0 -D__i386__ -D__const=const -Dvolatile -D__LITTLE_ENDIAN__ -D__inline__=inline -D__GNUC__ #define SYSTEM_IGATE_FLAGS -D__FLT_EVAL_METHOD__=0 -D__i386__ -D__const=const -Dvolatile -D__LITTLE_ENDIAN__ -D__inline__=inline -D__GNUC__
#define HAVE_GL 1
#define IS_OSX 1
// We don't need worry about defining WORDS_BIGENDIAN (and we // We don't need worry about defining WORDS_BIGENDIAN (and we
// shouldn't anyway, since ppc and intel are different). We rely on // shouldn't anyway, since ppc and intel are different). We rely on

View File

@ -410,6 +410,10 @@
#define NSPR_LIBS nspr4 #define NSPR_LIBS nspr4
#defer HAVE_NSPR $[isfile $[NSPR_IPATH]/prtypes.h] #defer HAVE_NSPR $[isfile $[NSPR_IPATH]/prtypes.h]
// Define this true to build a native network implementation,
// bypassing NSPR.
#define WANT_NATIVE_NET
// Is a third-party STL library installed, and where? This is only // Is a third-party STL library installed, and where? This is only
// necessary if the default include and link lines that come with the // necessary if the default include and link lines that come with the
// compiler don't provide adequate STL support. At least some form of // compiler don't provide adequate STL support. At least some form of

View File

@ -506,7 +506,7 @@ $[cdefine USE_MEMORY_PTMALLOC2]
$[cdefine USE_MEMORY_MALLOC] $[cdefine USE_MEMORY_MALLOC]
$[cdefine USE_MEMORY_NOWRAPPERS] $[cdefine USE_MEMORY_NOWRAPPERS]
#define if we want native net // If we are to build the native net interfaces.
$[cdefine WANT_NATIVE_NET] $[cdefine WANT_NATIVE_NET]
@ -514,7 +514,9 @@ $[cdefine WANT_NATIVE_NET]
$[cdefine USE_STL_ALLOCATOR] $[cdefine USE_STL_ALLOCATOR]
/* Platform-identifying defines. */
$[cdefine IS_OSX] $[cdefine IS_OSX]
$[cdefine IS_LINUX]
#end dtool_config.h #end dtool_config.h

View File

@ -11,5 +11,6 @@
avcodec.h avformat.h avio.h avutil.h common.h integer.h \ avcodec.h avformat.h avio.h avutil.h common.h integer.h \
intfloat_readwrite.h mathematics.h rational.h rtp.h \ intfloat_readwrite.h mathematics.h rational.h rtp.h \
rtsp.h rtspcodes.h winsock2.h \ rtsp.h rtspcodes.h winsock2.h \
ode/config.h ode/common.h collision_trimesh.h ode/config.h ode/common.h collision_trimesh.h \
netinet/tcp.h netinet/ip.h

22
dtool/src/parser-inc/ip.h Normal file
View File

@ -0,0 +1,22 @@
// Filename: ip.h
// Created by: drose (08Feb07)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
// This file, and all the other files in this directory, aren't
// intended to be compiled--they're just parsed by CPPParser (and
// interrogate) in lieu of the actual system headers, to generate the
// interrogate database.

View File

@ -0,0 +1,22 @@
// Filename: tcp.h
// Created by: drose (08Feb07)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
// This file, and all the other files in this directory, aren't
// intended to be compiled--they're just parsed by CPPParser (and
// interrogate) in lieu of the actual system headers, to generate the
// interrogate database.

View File

@ -11,12 +11,10 @@
// 3. Handle Framing and Unframing properly .. // 3. Handle Framing and Unframing properly ..
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "dtoolbase.h" #include "pandabase.h"
#include <vector>
#include "socket_base.h" #include "socket_base.h"
//#include "../express/datagram.h"
#include "datagram.h" #include "datagram.h"
#include "pvector.h"
#include "buffered_datagramreader.h" #include "buffered_datagramreader.h"
#include "buffered_datagramwriter.h" #include "buffered_datagramwriter.h"
@ -31,7 +29,7 @@
class EXPCL_PANDA Buffered_DatagramConnection : protected Socket_TCP class EXPCL_PANDA Buffered_DatagramConnection : protected Socket_TCP
{ {
private: private:
struct AddressQueue : private std::vector<Socket_Address> // this is used to do a round robin for addres to connect to .. struct AddressQueue : private pvector<Socket_Address> // this is used to do a round robin for addres to connect to ..
{ {
size_t _active_index; size_t _active_index;
bool GetNext(Socket_Address &out) bool GetNext(Socket_Address &out)
@ -46,17 +44,17 @@ private:
return true; return true;
} }
void clear() { std::vector<Socket_Address>::clear(); }; void clear() { pvector<Socket_Address>::clear(); };
void push_back(Socket_Address &address) void push_back(Socket_Address &address)
{ {
iterator ii; iterator ii;
for(ii = begin(); ii != end(); ii++) for(ii = begin(); ii != end(); ii++)
if(*ii == address) if(*ii == address)
return; return;
std::vector<Socket_Address>::push_back(address); pvector<Socket_Address>::push_back(address);
} }
size_t size() { return std::vector<Socket_Address>::size(); }; size_t size() { return pvector<Socket_Address>::size(); };
}; };
protected: protected:
// c++ upcals for // c++ upcals for

View File

@ -56,7 +56,7 @@ public:
int gotbytes = sck.RecvData(ff,(int)readsize); int gotbytes = sck.RecvData(ff,(int)readsize);
if(gotbytes < 0) // some error if(gotbytes < 0) // some error
{ {
int er = GETERROR(); //int er = GETERROR();
if(!sck.ErrorIs_WouldBlocking(gotbytes) ) if(!sck.ErrorIs_WouldBlocking(gotbytes) )
{ {
answer = -3; // hard error ? answer = -3; // hard error ?

View File

@ -60,7 +60,7 @@ public:
if(Writesize > 0) { if(Writesize > 0) {
int Writen = sck.SendData(GetMessageHead(),(int)Writesize); int Writen = sck.SendData(GetMessageHead(),(int)Writesize);
if(_are_we_going_to_block_on_write == true && Writen < 0 && sck.ErrorIs_WouldBlocking(Writen) == TRUE) { if(_are_we_going_to_block_on_write == true && Writen < 0 && sck.ErrorIs_WouldBlocking(Writen) == true) {
//sck.SetBlocking(); //sck.SetBlocking();
Writen = sck.SendData(GetMessageHead(),(int)Writesize); Writen = sck.SendData(GetMessageHead(),(int)Writesize);
//sck.SetNonBlocking(); //sck.SetNonBlocking();
@ -74,7 +74,7 @@ public:
answer = 1; answer = 1;
} }
else if(Writen < 0) { else if(Writen < 0) {
if(sck.ErrorIs_WouldBlocking(Writen) != TRUE) if(sck.ErrorIs_WouldBlocking(Writen) != true)
answer = -1; answer = -1;
} }
} }

View File

@ -1,9 +1,9 @@
#ifndef __SOCKET_ADDRESS_H__ #ifndef __SOCKET_ADDRESS_H__
#define __SOCKET_ADDRESS_H__ #define __SOCKET_ADDRESS_H__
#include <string>
#include "dtoolbase.h"
#include "pandabase.h" #include "pandabase.h"
#include "numeric_types.h"
/////////////////////////////////// ///////////////////////////////////
// Class : Socket_Address // Class : Socket_Address
// //
@ -202,7 +202,7 @@ inline bool Socket_Address::set_host(const std::string &hostname, int port)
// //
// //
UINT32 addr = (long)inet_addr (hostname.c_str()); PN_uint32 addr = (long)inet_addr (hostname.c_str());
if(addr == INADDR_NONE) if(addr == INADDR_NONE)
{ {
hp = gethostbyname(hostname.c_str()); hp = gethostbyname(hostname.c_str());
@ -241,7 +241,7 @@ inline bool Socket_Address::set_host(const std::string &hostname)
// Function name : Socket_Address::set_host // Function name : Socket_Address::set_host
// Description : // Description :
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
inline bool Socket_Address::set_host(UINT32 in_hostname, int port) inline bool Socket_Address::set_host(PN_uint32 in_hostname, int port)
{ {
memcpy(&_addr.sin_addr, &in_hostname, sizeof(in_hostname)); memcpy(&_addr.sin_addr, &in_hostname, sizeof(in_hostname));
_addr.sin_port = htons(port); _addr.sin_port = htons(port);
@ -276,7 +276,7 @@ inline bool Socket_Address::operator < (const Socket_Address &in) const
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
inline bool Socket_Address::isMcastRange(void) inline bool Socket_Address::isMcastRange(void)
{ {
UINT32 address = ntohl(_addr.sin_addr.s_addr); PN_uint32 address = ntohl(_addr.sin_addr.s_addr);
//224.0.0.0-239.255.255.255 .. e0,ef //224.0.0.0-239.255.255.255 .. e0,ef
if(address >= 0xe0000000 && address < 0xefffffff) if(address >= 0xe0000000 && address < 0xefffffff)
return true; return true;

View File

@ -1,8 +1,10 @@
#ifndef __SOCKET_BASE_H__ #ifndef __SOCKET_BASE_H__
#define __SOCKET_BASE_H__ #define __SOCKET_BASE_H__
//////////////////////////////////////////// ////////////////////////////////////////////
// Quick way to get all the network code defined // Quick way to get all the network code defined
//////////////////////////////////////////// ////////////////////////////////////////////
#include "pandabase.h"
#include "socket_portable.h" #include "socket_portable.h"
#include "socket_address.h" #include "socket_address.h"
#include "socket_ip.h" #include "socket_ip.h"

View File

@ -11,6 +11,8 @@
// fits more with the normal Berkeley mind set... ** Not ** Should think about using POLL() on BSD-based systems // fits more with the normal Berkeley mind set... ** Not ** Should think about using POLL() on BSD-based systems
// //
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
#include "pandabase.h"
#include "numeric_types.h"
#include "time_base.h" #include "time_base.h"
class Socket_fdset class Socket_fdset
@ -20,9 +22,9 @@ public:
inline Socket_fdset(); inline Socket_fdset();
inline void setForSocket(const Socket_IP &incon); inline void setForSocket(const Socket_IP &incon);
inline bool IsSetFor(const Socket_IP & incon) const; inline bool IsSetFor(const Socket_IP & incon) const;
inline int WaitForRead(bool zeroFds, UINT32 sleep_time = 0xffffffff); inline int WaitForRead(bool zeroFds, PN_uint32 sleep_time = 0xffffffff);
inline int WaitForWrite(bool zeroFds, UINT32 sleep_time = 0xffffffff); inline int WaitForWrite(bool zeroFds, PN_uint32 sleep_time = 0xffffffff);
inline int WaitForError(bool zeroFds, UINT32 sleep_time = 0xffffffff); inline int WaitForError(bool zeroFds, PN_uint32 sleep_time = 0xffffffff);
inline int WaitForRead(bool zeroFds, const Time_Span & timeout); inline int WaitForRead(bool zeroFds, const Time_Span & timeout);
@ -90,7 +92,7 @@ inline bool Socket_fdset::IsSetFor(const Socket_IP & incon) const
// Function name : WaitForRead // Function name : WaitForRead
// Description : // Description :
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
inline int Socket_fdset::WaitForRead(bool zeroFds, UINT32 sleep_time) inline int Socket_fdset::WaitForRead(bool zeroFds, PN_uint32 sleep_time)
{ {
int retVal = 0; int retVal = 0;
if (sleep_time == 0xffffffff) if (sleep_time == 0xffffffff)
@ -151,7 +153,7 @@ inline void Socket_fdset::setForSocket(const Socket_IP &incon)
// Description : This is the function that will wait till // Description : This is the function that will wait till
// one of the sockets is ready for writing // one of the sockets is ready for writing
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
inline int Socket_fdset::WaitForWrite(bool zeroFds, UINT32 sleep_time) inline int Socket_fdset::WaitForWrite(bool zeroFds, PN_uint32 sleep_time)
{ {
int retVal = 0; int retVal = 0;
if (sleep_time == 0xffffffff) if (sleep_time == 0xffffffff)
@ -177,7 +179,7 @@ inline int Socket_fdset::WaitForWrite(bool zeroFds, UINT32 sleep_time)
// Description : This is the function that will wait till // Description : This is the function that will wait till
// one of the sockets is in error state // one of the sockets is in error state
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
inline int Socket_fdset::WaitForError(bool zeroFds, UINT32 sleep_time) inline int Socket_fdset::WaitForError(bool zeroFds, PN_uint32 sleep_time)
{ {
int retVal = 0; int retVal = 0;
if (sleep_time == 0xffffffff) if (sleep_time == 0xffffffff)

View File

@ -244,7 +244,7 @@ const int LOCAL_CONNECT_BLOCKING = EINPROGRESS;
* LINUX and FreeBSD STUFF * LINUX and FreeBSD STUFF
************************************************************************/ ************************************************************************/
#elif defined(Linux) || defined(FreeBSD) ||defined(LINUX) #elif defined(IS_LINUX) || defined(FreeBSD)
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>

View File

@ -9,6 +9,9 @@
// platform differences from machine to machine // platform differences from machine to machine
// //
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
#include "pandabase.h"
#include "numeric_types.h"
#include <openssl/rsa.h> /* SSLeay stuff */ #include <openssl/rsa.h> /* SSLeay stuff */
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/x509.h> #include <openssl/x509.h>
@ -281,12 +284,12 @@ inline void Socket_TCP_SSL::DetailErrorFormat(void)
{ {
return; // turn on fir debuging return; // turn on fir debuging
UINT32 l; PN_uint32 l;
char buf[256]; char buf[256];
char buf2[4096]; char buf2[4096];
const char *file,*data; const char *file,*data;
int line,flags; int line,flags;
UINT32 es; PN_uint32 es;
es=CRYPTO_thread_id(); es=CRYPTO_thread_id();
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)

View File

@ -247,7 +247,7 @@ inline std::string Time_Clock::Format(char * pFormat) const
*pch++ = ch1; *pch++ = ch1;
break; break;
case 'N': case 'N':
pch += sprintf(pch, "%03d", _my_time.tv_usec / 1000); pch += sprintf(pch, "%03ld", _my_time.tv_usec / 1000);
break; break;
} }
} }
@ -295,7 +295,7 @@ inline std::string Time_Clock::FormatGmt(char * pFormat) const
*pch++ = ch1; *pch++ = ch1;
break; break;
case 'N': case 'N':
pch += sprintf(pch, "%03d", _my_time.tv_usec / 1000); pch += sprintf(pch, "%03ld", _my_time.tv_usec / 1000);
break; break;
} }
} }

View File

@ -372,7 +372,7 @@ inline std::string Time_Span::Format(char * pFormat) const
pch += sprintf(pch, "%02d", GetSeconds()); pch += sprintf(pch, "%02d", GetSeconds());
break; break;
case 'N': case 'N':
pch += sprintf(pch, "%03d", _my_time.tv_usec / 1000); pch += sprintf(pch, "%03ld", _my_time.tv_usec / 1000);
break; break;
} }
} else { } else {