groupsock/inet.c File Reference

#include "NetCommon.h"
#include <stdio.h>
#include <stdlib.h>

Include dependency graph for inet.c:

Go to the source code of this file.

Defines

#define initializeWinsockIfNecessary()   1
#define NULL   0

Functions

unsigned our_inet_addr (char const *cp)
char * our_inet_ntoa (struct in_addr in)
hostent * our_gethostbyname (char *name)
long our_random ()
void our_srandom (unsigned int x)
u_int32_t our_random32 ()


Define Documentation

 
#define initializeWinsockIfNecessary (  )     1

Definition at line 79 of file inet.c.

#define NULL   0

Definition at line 83 of file inet.c.


Function Documentation

struct hostent* our_gethostbyname ( char*  name  )  [read]

Definition at line 87 of file inet.c.

References initializeWinsockIfNecessary, and NULL.

Referenced by NetAddressList::NetAddressList().

00089 {
00090         if (!initializeWinsockIfNecessary()) return NULL;
00091 
00092         return (struct hostent*) gethostbyname(name);
00093 }

unsigned our_inet_addr ( char const*  cp  ) 

Definition at line 17 of file inet.c.

Referenced by RTSPServer::RTSPClientSession::handleCmd_SETUP(), main(), NetAddressList::NetAddressList(), and ourIPAddress().

00019 {
00020         return inet_addr(cp);
00021 }

char* our_inet_ntoa ( struct in_addr  in  ) 

Definition at line 24 of file inet.c.

Referenced by ServerMediaSession::generateSDPDescription(), RTSPServer::RTSPClientSession::handleCmd_SETUP(), Groupsock::handleRead(), RTSPOverHTTPServer::incomingConnectionHandler1(), RTSPServer::incomingConnectionHandler1(), RTCPInstance::incomingReportHandler1(), RTSPServer::RTSPClientSession::livenessTimeoutTask(), main(), operator<<(), RTSPServer::rtspURLPrefix(), PassiveServerMediaSubsession::sdpLines(), DarwinInjector::setDestination(), OnDemandServerMediaSubsession::setSDPLinesFromRTPSink(), and SIPClient::SIPClient().

00026 {
00027 #ifndef VXWORKS
00028   return inet_ntoa(in);
00029 #else
00030   /* according the man pages of inet_ntoa :
00031 
00032      NOTES
00033      The return value from inet_ntoa() points to a  buffer  which
00034      is  overwritten on each call.  This buffer is implemented as
00035      thread-specific data in multithreaded applications.
00036 
00037      the vxworks version of inet_ntoa allocates a buffer for each
00038      ip address string, and does not reuse the same buffer.
00039 
00040      this is merely to simulate the same behaviour (not multithread
00041      safe though):
00042   */
00043   static char result[INET_ADDR_LEN];
00044   inet_ntoa_b(in, result);
00045   return(result);
00046 #endif
00047 }

long our_random (  ) 

Definition at line 99 of file inet.c.

Referenced by FileSink::addData(), chooseRandomIPv4SSMAddress(), MP3FromADUSource::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), drand30(), SIPClient::invite(), MediaSession::MediaSession(), MultiFramedRTPSource::networkReadHandler(), our_random32(), MultiFramedRTPSink::sendPacketIfNecessary(), and DarwinInjector::setDestination().

00099                   {
00100 #if defined(__WIN32__) || defined(_WIN32)
00101   return rand();
00102 #else
00103   return random();
00104 #endif
00105 }

u_int32_t our_random32 (  ) 

Definition at line 446 of file inet.c.

References our_random().

00446                          {
00447   // Return a 32-bit random number.
00448   // Because "our_random()" returns a 31-bit random number, we call it a second
00449   // time, to generate the high bit:
00450   long random1 = our_random();
00451   long random2 = our_random();
00452   return (u_int32_t)((random2<<31) | random1);
00453 }

void our_srandom ( unsigned int  x  ) 

Definition at line 106 of file inet.c.

00106                                  {
00107 #if defined(__WIN32__) || defined(_WIN32)
00108   srand(x);
00109 #else
00110   srandom(x);
00111 #endif
00112 }


Generated on Tue Oct 7 15:38:20 2008 for live by  doxygen 1.5.2